HLMOD.HU Forrás Megtekintés - www.hlmod.hu
  1. /* AMX Mod X
  2. * Ethereal.
  3. *
  4. * http://aghl.ru/forum/ - Russian Half-Life and Adrenaline Gamer Community
  5. *
  6. * This file is provided as is (no warranties)
  7. */
  8.  
  9. #pragma semicolon 1
  10. #pragma ctrlchar '\'
  11.  
  12. #include <amxmodx>
  13. #include <hamsandwich>
  14. #include <hl_wpnmod>
  15. #include <beams>
  16. #include <xs>
  17.  
  18.  
  19. #define PLUGIN "Ethereal"
  20. #define VERSION "1.0"
  21. #define AUTHOR "KORD_12.7"
  22.  
  23.  
  24. // Weapon settings
  25. #define WEAPON_NAME "weapon_ethereal"
  26. #define WEAPON_SLOT 2
  27. #define WEAPON_POSITION 5
  28. #define WEAPON_PRIMARY_AMMO "uranium"
  29. #define WEAPON_PRIMARY_AMMO_MAX 100
  30. #define WEAPON_SECONDARY_AMMO "" // NULL
  31. #define WEAPON_SECONDARY_AMMO_MAX -1
  32. #define WEAPON_MAX_CLIP 30
  33. #define WEAPON_DEFAULT_AMMO 30
  34. #define WEAPON_FLAGS 0
  35. #define WEAPON_WEIGHT 15
  36. #define WEAPON_DAMAGE 40.0
  37.  
  38. // Hud
  39. #define WEAPON_HUD_TXT "sprites/weapon_ethereal.txt"
  40. #define WEAPON_HUD_SPR "sprites/weapon_ethereal.spr"
  41.  
  42. // Models
  43. #define MODEL_WORLD "models/w_ethereal.mdl"
  44. #define MODEL_VIEW "models/v_ethereal_hev.mdl"
  45. #define MODEL_PLAYER "models/p_ethereal.mdl"
  46.  
  47. // Sounds
  48. #define SOUND_FIRE "weapons/ethereal-1.wav"
  49. #define SOUND_DRAW "weapons/ethereal_draw.wav"
  50. #define SOUND_IDLE "weapons/ethereal_idle1.wav"
  51. #define SOUND_IMPACT "weapons/shock_impact.wav"
  52. #define SOUND_RELOAD "weapons/ethereal_reload.wav"
  53.  
  54. // Sprites
  55. #define SPRITE_LIGHTNING "sprites/lgtning.spr"
  56.  
  57. // Beam
  58. #define BEAM_LIFE 0.09
  59. #define BEAM_COLOR {100.0, 50.0, 253.0}
  60. #define BEAM_BRIGHTNESS 255.0
  61. #define BEAM_SCROLLRATE 10.0
  62.  
  63. // Animation
  64. #define ANIM_EXTENSION "gauss"
  65.  
  66. // Animation Sequence
  67. enum _:Animation
  68. {
  69. ANIM_IDLE = 0,
  70. ANIM_RELOAD,
  71. ANIM_DRAW,
  72. ANIM_FIRE_1,
  73. ANIM_FIRE_2,
  74. ANIM_FIRE_3
  75. };
  76.  
  77. #define Beam_SetLife(%0,%1) \
  78. wpnmod_set_think(%0, "Beam_Remove"); \
  79. set_pev(%0, pev_nextthink, get_gametime() + %1)
  80.  
  81. //**********************************************
  82. //* Precache resources *
  83. //**********************************************
  84.  
  85. public plugin_precache()
  86. {
  87. PRECACHE_MODEL(MODEL_VIEW);
  88. PRECACHE_MODEL(MODEL_WORLD);
  89. PRECACHE_MODEL(MODEL_PLAYER);
  90. PRECACHE_MODEL(SPRITE_LIGHTNING);
  91.  
  92. PRECACHE_SOUND(SOUND_FIRE);
  93. PRECACHE_SOUND(SOUND_DRAW);
  94. PRECACHE_SOUND(SOUND_IDLE);
  95. PRECACHE_SOUND(SOUND_IMPACT);
  96. PRECACHE_SOUND(SOUND_RELOAD);
  97.  
  98. PRECACHE_GENERIC(WEAPON_HUD_TXT);
  99. PRECACHE_GENERIC(WEAPON_HUD_SPR);
  100. }
  101.  
  102. //**********************************************
  103. //* Register weapon. *
  104. //**********************************************
  105.  
  106. public plugin_init()
  107. {
  108. register_plugin(PLUGIN, VERSION, AUTHOR);
  109.  
  110. new iEthereal = wpnmod_register_weapon
  111.  
  112. (
  113. WEAPON_NAME,
  114. WEAPON_SLOT,
  115. WEAPON_POSITION,
  116. WEAPON_PRIMARY_AMMO,
  117. WEAPON_PRIMARY_AMMO_MAX,
  118. WEAPON_SECONDARY_AMMO,
  119. WEAPON_SECONDARY_AMMO_MAX,
  120. WEAPON_MAX_CLIP,
  121. WEAPON_FLAGS,
  122. WEAPON_WEIGHT
  123. );
  124.  
  125. wpnmod_register_weapon_forward(iEthereal, Fwd_Wpn_Spawn, "Ethereal_Spawn");
  126. wpnmod_register_weapon_forward(iEthereal, Fwd_Wpn_Deploy, "Ethereal_Deploy");
  127. wpnmod_register_weapon_forward(iEthereal, Fwd_Wpn_Idle, "Ethereal_Idle");
  128. wpnmod_register_weapon_forward(iEthereal, Fwd_Wpn_Reload, "Ethereal_Reload");
  129. wpnmod_register_weapon_forward(iEthereal, Fwd_Wpn_Holster, "Ethereal_Holster");
  130. wpnmod_register_weapon_forward(iEthereal, Fwd_Wpn_PrimaryAttack, "Ethereal_PrimaryAttack");
  131. }
  132.  
  133. //**********************************************
  134. //* Weapon spawn. *
  135. //**********************************************
  136.  
  137. public Ethereal_Spawn(const iItem)
  138. {
  139. // Setting world model
  140. SET_MODEL(iItem, MODEL_WORLD);
  141.  
  142. // Give a default ammo to weapon
  143. wpnmod_set_offset_int(iItem, Offset_iDefaultAmmo, WEAPON_DEFAULT_AMMO);
  144. }
  145.  
  146. //**********************************************
  147. //* Deploys the weapon. *
  148. //**********************************************
  149.  
  150. public Ethereal_Deploy(const iItem, const iPlayer)
  151. {
  152. // Start idle sound
  153. engfunc(EngFunc_EmitSound, iPlayer, CHAN_AUTO, SOUND_IDLE, 0.4, ATTN_NORM, 0, PITCH_NORM);
  154.  
  155. return wpnmod_default_deploy(iItem, MODEL_VIEW, MODEL_PLAYER, ANIM_DRAW, ANIM_EXTENSION);
  156. }
  157.  
  158. //**********************************************
  159. //* Called when the weapon is holster. *
  160. //**********************************************
  161.  
  162. public Ethereal_Holster(const iItem, const iPlayer)
  163. {
  164. // Cancel any reload in progress.
  165. wpnmod_set_offset_int(iItem, Offset_iInReload, 0);
  166.  
  167. // Stop idle sound
  168. engfunc(EngFunc_EmitSound, iPlayer, CHAN_AUTO, SOUND_IDLE, 0.0, 0.0, SND_STOP, PITCH_NORM);
  169. }
  170.  
  171. //**********************************************
  172. //* Displays the idle animation for the weapon.*
  173. //**********************************************
  174.  
  175. public Ethereal_Idle(const iItem, const iPlayer)
  176. {
  177. wpnmod_reset_empty_sound(iItem);
  178.  
  179. if (wpnmod_get_offset_float(iItem, Offset_flTimeWeaponIdle) > 0.0)
  180. {
  181. return;
  182. }
  183.  
  184. wpnmod_send_weapon_anim(iItem, ANIM_IDLE);
  185. wpnmod_set_offset_float(iItem, Offset_flTimeWeaponIdle, 10.03);
  186. }
  187.  
  188. //**********************************************
  189. //* The main attack of a weapon is triggered. *
  190. //**********************************************
  191.  
  192. public Ethereal_PrimaryAttack(const iItem, const iPlayer, const iClip)
  193. {
  194. if (pev(iPlayer, pev_waterlevel) == 3 || iClip <= 0)
  195. {
  196. wpnmod_play_empty_sound(iItem);
  197. wpnmod_set_offset_float(iItem, Offset_flNextPrimaryAttack, 0.15);
  198. return;
  199. }
  200.  
  201. new Float: vecSrc[3], Float: vecEnd[3], iBeam, iTrace = create_tr2();
  202.  
  203. wpnmod_get_gun_position(iPlayer, vecSrc);
  204. global_get(glb_v_forward, vecEnd);
  205.  
  206. xs_vec_mul_scalar(vecEnd, 8192.0, vecEnd);
  207. xs_vec_add(vecSrc, vecEnd, vecEnd);
  208.  
  209. engfunc(EngFunc_TraceLine, vecSrc, vecEnd, DONT_IGNORE_MONSTERS, iPlayer, iTrace);
  210. get_tr2(iTrace, TR_vecEndPos, vecEnd);
  211.  
  212. if (pev_valid((iBeam = Beam_Create(SPRITE_LIGHTNING, 25.0))))
  213. {
  214. Beam_PointEntInit(iBeam, vecEnd, iPlayer);
  215. Beam_SetEndAttachment(iBeam, 1);
  216. Beam_SetBrightness(iBeam, BEAM_BRIGHTNESS);
  217. Beam_SetScrollRate(iBeam, BEAM_SCROLLRATE);
  218. Beam_SetColor(iBeam, BEAM_COLOR);
  219. Beam_SetLife(iBeam, BEAM_LIFE);
  220. }
  221.  
  222. wpnmod_radius_damage2(vecEnd, iPlayer, iPlayer, WEAPON_DAMAGE, WEAPON_DAMAGE * 2.0, CLASS_NONE, DMG_ENERGYBEAM | DMG_ALWAYSGIB);
  223.  
  224. engfunc(EngFunc_EmitSound, iPlayer, CHAN_AUTO, SOUND_FIRE, 0.9, ATTN_NORM, 0, PITCH_NORM);
  225. engfunc(EngFunc_EmitAmbientSound, 0, vecEnd, SOUND_IMPACT, 0.9, ATTN_NORM, 0, PITCH_NORM);
  226.  
  227. engfunc(EngFunc_MessageBegin, MSG_PVS, SVC_TEMPENTITY, vecEnd, 0);
  228. write_byte(TE_DLIGHT);
  229. engfunc(EngFunc_WriteCoord, vecEnd[0]);
  230. engfunc(EngFunc_WriteCoord, vecEnd[1]);
  231. engfunc(EngFunc_WriteCoord, vecEnd[2]);
  232. write_byte(10);
  233. write_byte(100);
  234. write_byte(50);
  235. write_byte(253);
  236. write_byte(255);
  237. write_byte(25);
  238. write_byte(1);
  239. message_end();
  240.  
  241. engfunc(EngFunc_MessageBegin, MSG_PVS, SVC_TEMPENTITY, vecEnd, 0);
  242. write_byte(TE_SPARKS);
  243. engfunc(EngFunc_WriteCoord, vecEnd[0]);
  244. engfunc(EngFunc_WriteCoord, vecEnd[1]);
  245. engfunc(EngFunc_WriteCoord, vecEnd[2]);
  246. message_end();
  247.  
  248. wpnmod_decal_trace(iTrace, engfunc(EngFunc_DecalIndex, "{smscorch1") + random_num(0, 2));
  249.  
  250. wpnmod_set_offset_int(iItem, Offset_iClip, iClip - 1);
  251. wpnmod_set_offset_int(iPlayer, Offset_iWeaponVolume, LOUD_GUN_VOLUME);
  252. wpnmod_set_offset_int(iPlayer, Offset_iWeaponFlash, BRIGHT_GUN_FLASH);
  253.  
  254. wpnmod_set_offset_float(iItem, Offset_flNextPrimaryAttack, 0.1);
  255. wpnmod_set_offset_float(iItem, Offset_flTimeWeaponIdle, 1.03);
  256.  
  257. wpnmod_set_player_anim(iPlayer, PLAYER_ATTACK1);
  258. wpnmod_send_weapon_anim(iItem, random_num(ANIM_FIRE_1, ANIM_FIRE_3));
  259.  
  260. free_tr2(iTrace);
  261. }
  262.  
  263. //**********************************************
  264. //* Called when the weapon is reloaded. *
  265. //**********************************************
  266.  
  267. public Ethereal_Reload(const iItem, const iPlayer, const iClip, const iAmmo)
  268. {
  269. if (iAmmo <= 0 || iClip >= WEAPON_MAX_CLIP)
  270. {
  271. return;
  272. }
  273.  
  274. wpnmod_default_reload(iItem, WEAPON_MAX_CLIP, ANIM_RELOAD, 3.03);
  275. }
  276.  
  277. //**********************************************
  278. //* Beam remove think. *
  279. //**********************************************
  280.  
  281. public Beam_Remove(const iBeam)
  282. {
  283. set_pev(iBeam, pev_flags, FL_KILLME);
  284. }
  285. /* AMXX-Studio Notes - DO NOT MODIFY BELOW HERE
  286. *{\\ rtf1\\ ansi\\ deff0{\\ fonttbl{\\ f0\\ fnil Tahoma;}}\n\\ viewkind4\\ uc1\\ pard\\ lang1038\\ f0\\ fs16 \n\\ par }
  287. */
  288.