Advertisement
Guest User

Untitled

a guest
Jan 18th, 2017
103
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 39.79 KB | None | 0 0
  1. /* - - - - - - - - - - -
  2.  
  3. AMX Mod X script.
  4.  
  5. | Author : Arkshine
  6. | Plugin : WPN Squeak Grenade
  7. | Version : v1.0.6 - without WM.
  8.  
  9. (!) Support : http://forums.alliedmods.net/showthread.php?t=93659
  10. (!) Version without WeaponMod required and for Zombie Plague.
  11.  
  12. This program is free software; you can redistribute it and/or modify it
  13. under the terms of the GNU General Public License as published by the
  14. Free Software Foundation; either version 2 of the License, or (at
  15. your option) any later version.
  16.  
  17. This program is distributed in the hope that it will be useful, but
  18. WITHOUT ANY WARRANTY; without even the implied warranty of
  19. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
  20. General Public License for more details.
  21.  
  22. You should have received a copy of the GNU General Public License
  23. along with this program; if not, write to the Free Software Foundation,
  24. Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
  25.  
  26. ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~
  27.  
  28.  
  29. Description :
  30. - - - - - - -
  31. Basically, it's almost the same weapon that you can see in Half-life 1.
  32.  
  33. Snarks are small, red, and bulbous, with a large (in relation to body porportion)
  34. single green eye and a large pincer-like mandible. Snarks are normally calm creatures
  35. that show little signs of intelligence, but if they see any living creature other
  36. than another Snark, they immediately begin to attack it. They attack aggressively,
  37. persistently, and erratically, leaping and biting at their target.
  38.  
  39. A full description can be found here : http://half-life.wikia.com/wiki/Snark .
  40.  
  41.  
  42. Requirement :
  43. - - - - - - -
  44. * CS 1.6 / CZ.
  45. * AMX Mod X 1.8.x or higher.
  46.  
  47.  
  48. Changelog :
  49. - - - - - -
  50. v1.0.6 : [ 11 jul 2009 ]
  51.  
  52. (+) Initial release.
  53.  
  54.  
  55. Credits :
  56. - - - - -
  57. * HLSDK
  58. * DevconeS
  59. * VEN
  60. * Sproily ( Alternative models )
  61.  
  62. - - - - - - - - - - - */
  63.  
  64. #include <amxmodx>
  65. #include <fakemeta>
  66. #include <cstrike>
  67. #include <hamsandwich>
  68. #include <engine>
  69. #include <fun>
  70. #include <biohazard>
  71.  
  72.  
  73. #define Plugin "[ZP] Extra: Squeak Grenade"
  74. #define Version "1.0.6-wwm"
  75. #define Author "Arkshine"
  76.  
  77. new g_LCOST
  78.  
  79. // --| Comment if you want to use the default model from valve.
  80. #define ALTERNATIVE_MODEL
  81.  
  82. // --| Snark trail.
  83. #define TRAIL_LIFE 40 // Life
  84. #define TRAIL_WIDTH 4 // Width
  85. #define TRAIL_RED 10 // Red
  86. #define TRAIL_GREEN 224 // Red
  87. #define TRAIL_BLUE 10 // Green
  88. #define TRAIL_BRIGTHNESS 200 // Blue
  89.  
  90. /* - - -
  91. | WEAPON MODELS |
  92. - - - */
  93. #if !defined ALTERNATIVE_MODEL
  94. new const gModel_P[] = "models/p_squeak.mdl";
  95. new const gModel_V[] = "models/v_squeak.mdl";
  96. #else
  97. new const gModel_P[] = "models/p_alt_squeak.mdl";
  98. new const gModel_V[] = "models/v_alt_squeak_gflip.mdl";
  99. #endif
  100.  
  101. /* - - -
  102. | SNARK SOUNDS |
  103. - - - */
  104. new const gSnarkHunt1Sound [] = "squeek/sqk_hunt1.wav";
  105. new const gSnarkHunt2Sound [] = "squeek/sqk_hunt2.wav";
  106. new const gSnarkHunt3Sound [] = "squeek/sqk_hunt3.wav";
  107. new const gSnarkDieSound [] = "squeek/sqk_die1.wav";
  108. new const gSnarkAttackSound [] = "squeek/sqk_deploy1.wav";
  109. new const gSnarkBlastSound [] = "weapons/sqk_blast2.wav";
  110. new const gSnarkBodySplatSound[] = "common/bodysplat.wav";
  111.  
  112. /* - - -
  113. | SNARK MODEL |
  114. - - - */
  115. new
  116. #if !defined ALTERNATIVE_MODEL
  117. gSnarkModel[] = "models/w_squeak.mdl";
  118. #else
  119. gSnarkModel[] = "models/w_alt_squeak.mdl";
  120. #endif
  121.  
  122. /* - - -
  123. | SEQUENCE |
  124. - - - */
  125. enum
  126. {
  127. wsqueak_idle1,
  128. wsqueak_fidget,
  129. wsqueak_jump,
  130. wsqueak_run
  131. };
  132.  
  133. enum
  134. {
  135. squeak_idle1,
  136. squeak_fidgetfit,
  137. squeak_fidgetnip,
  138. squeak_down,
  139. squeak_up,
  140. squeak_throw
  141. };
  142.  
  143. /* - -
  144. | CONSTANTS |
  145. - - */
  146. const BLOOD_COLOR_RED = 247;
  147. const BLOOD_COLOR_YELLOW = 195;
  148.  
  149. const MAX_CLIENTS = 32;
  150. const MAX_KNIFE_MODEL_LENGTH = 128;
  151. const NONE = -1;
  152. const NULL_ENT = 0;
  153.  
  154. enum _:Coord_e
  155. {
  156. Float:x,
  157. Float:y,
  158. Float:z
  159. };
  160.  
  161. enum _:Angle_e
  162. {
  163. Float:Pitch,
  164. Float:Yaw,
  165. Float:Roll
  166. };
  167.  
  168. enum
  169. {
  170. HuntThink = 1,
  171. SuperBounceTouch,
  172. RemoveSnark
  173. };
  174.  
  175. new const Float:gHullMin [ Coord_e ] = { -16.0, -16.0, -36.0 };
  176. new const Float:gDuckHullMin[ Coord_e ] = { -16.0, -16.0, -18.0 };
  177.  
  178. new const gWeaponCommand [] = "weapon_hegrenade";
  179. new const gWeaponIndex = CSW_HEGRENADE;
  180.  
  181. new const gGenericEntity [] = "info_target";
  182. new const gSnarkClassName[] = "wpn_snark";
  183.  
  184. /* - - - -
  185. | PLAYER/WEAPON OFFSETS |
  186. - - - - */
  187. const m_flNextAttack = 83 // Player.
  188. const m_pActiveWeapon = 373; // Player.
  189. const m_pPlayer = 41; // Weapon.
  190. const m_flNextPrimaryAttack = 46; // Weapon.
  191.  
  192. /* - - -
  193. | CUSTOM FIELD |
  194. - - - */
  195. #define pev_NextHunt pev_fuser1
  196. #define pev_NextBounceSoundTime pev_fuser2
  197. #define pev_NextHit pev_fuser3
  198. #define pev_NextAttack pev_fuser4
  199. #define pev_DetonateDelay pev_ltime
  200. #define pev_RealOwner pev_iuser1
  201. #define pev_Remove pev_iuser2
  202. #define pev_EnemyTarget pev_vuser1
  203. #define pev_PosPrev pev_vuser2
  204.  
  205. /* - - -
  206. | CVAR POINTER |
  207. - - - */
  208. new pCvarAmmo;
  209. new pCvarRefireRate;
  210. new pCvarHealth;
  211. new pCvarVelocity;
  212. new pCvarDamagePop;
  213. new pCvarDamageRadius;
  214. new pCvarGravity;
  215. new pCvarFriction;
  216. new pCvarDetonateDelay;
  217. new pCvarFieldOfView;
  218. new pCvarShowTrail;
  219.  
  220. /* - - - -
  221. | SPRITES/MODELS INDEX |
  222. - - - - */
  223. new gBloodSpray;
  224. new gBloodDrop;
  225. new gSmokeTrail;
  226.  
  227. /* - - - -
  228. | OTHERS STUFFS |
  229. - - - */
  230. new bool:gHasSnark [ MAX_CLIENTS + 1 char ];
  231. new bool:gWeaponActive[ MAX_CLIENTS + 1 char ];
  232. new bool:gJustThrown [ MAX_CLIENTS + 1 char ];
  233.  
  234. new Float:gNextShot [ MAX_CLIENTS + 1 ];
  235. new Float:gTimeWeaponIdle[ MAX_CLIENTS + 1 ];
  236.  
  237. new gPlayerAmmo[ MAX_CLIENTS + 1 char ];
  238.  
  239. new const gSnarkHealthReference = 10000;
  240. new gSnarkClassNameReference;
  241. new gMaxEntities;
  242. new gMaxClients;
  243. new gMsgidAmmoX;
  244. new bool:armor[33],bool:is_alive[33],bool:is_connected[33],bool:is_bot[33],g_MaxPlayers;
  245. /* - -
  246. | MACROS |
  247. - - */
  248. #define VectorSubtract(%1,%2,%3) ( %3[ x ] = %1[ x ] - %2[ x ], %3[ y ] = %1[ y ] - %2[ y ], %3[ z ] = %1[ z ] - %2[ z ] )
  249. #define VectorAdd(%1,%2,%3) ( %3[ x ] = %1[ x ] + %2[ x ], %3[ y ] = %1[ y ] + %2[ y ], %3[ z ] = %1[ z ] + %2[ z ] )
  250. #define VectorCopy(%1,%2) ( %2[ x ] = %1[ x ], %2[ y ] = %1[ y ], %2[ z ] = %1[ z ] )
  251. #define VectorScale(%1,%2,%3) ( %3[ x ] = %2 * %1[ x ], %3[ y ] = %2 * %1[ y ], %3[ z ] = %2 * %1[ z ] )
  252. #define VectorMA(%1,%2,%3,%4) ( %4[ x ] = %1[ x ] + %2 * %3[ x ], %4[ y ] = %1[ y ] + %2 * %3[ y ], %4[ z ] = %1[ z ] + %2 * %3[ z ] )
  253. #define VectorMS(%1,%2,%3,%4) ( %4[ x ] = %1[ x ] - %2 * %3[ x ], %4[ y ] = %1[ y ] - %2 * %3[ y ], %4[ z ] = %1[ z ] - %2 * %3[ z ] )
  254. #define VectorLength(%1) ( floatsqroot ( %1[ x ] * %1[ x ] + %1[ y ] * %1[ y ] + %1[ z ] * %1[ z ] ) )
  255. #define VectorEqual(%1,%2) ( %1[ x ] == %2[ x ] && %1[ y ] == %2[ y ] && %1[ z ] == %2[ z ] )
  256. #define DotProduct(%1,%2) ( %1[ x ] * %2[ x ]+ %1[ y ] * %2[ y ] + %1[ z ] * %2[ z ] )
  257.  
  258. #define message_begin_f(%1,%2,%3) ( engfunc ( EngFunc_MessageBegin, %1, %2, %3 ) )
  259. #define write_coord_f(%1) ( engfunc ( EngFunc_WriteCoord, %1 ) )
  260.  
  261. //connect valid?
  262. #define is_user_valid_connected(%1) (1 <= %1 <= g_MaxPlayers && is_connected[%1])
  263.  
  264. public plugin_precache ()
  265. {
  266. // --| Weapon models.
  267. precache_model( gModel_P );
  268. precache_model( gModel_V );
  269.  
  270. // --| Snark model.
  271. precache_model( gSnarkModel );
  272.  
  273. // --| Snark sounds.
  274. precache_sound( gSnarkBlastSound );
  275. precache_sound( gSnarkBodySplatSound );
  276. precache_sound( gSnarkDieSound );
  277. precache_sound( gSnarkHunt1Sound );
  278. precache_sound( gSnarkHunt2Sound );
  279. precache_sound( gSnarkHunt3Sound );
  280. precache_sound( gSnarkAttackSound );
  281.  
  282. gBloodSpray = precache_model( "sprites/bloodspray.spr" ); // initial blood
  283. gBloodDrop = precache_model( "sprites/blood.spr" ); // splattered blood
  284. }
  285.  
  286.  
  287. public plugin_init ()
  288. {
  289. register_plugin( Plugin, Version, Author );
  290. register_cvar( "zp_snark_version", Version, FCVAR_SERVER | FCVAR_SPONLY );
  291.  
  292. g_MaxPlayers = get_maxplayers()
  293.  
  294. pCvarAmmo = register_cvar( "wpn_sg_ammo" , "2" );
  295. pCvarRefireRate = register_cvar( "wpn_sg_refire_rate" , "0.3" );
  296. pCvarHealth = register_cvar( "wpn_sg_health" , "50" );
  297. pCvarVelocity = register_cvar( "wpn_sg_velocity" , "10" );
  298. pCvarDamagePop = register_cvar( "wpn_sg_damage_pop" , "3" );
  299. pCvarDamageRadius = register_cvar( "wpn_sg_damage_radius" , "300" );
  300. pCvarGravity = register_cvar( "wpn_sg_gravity" , "0.2" );
  301. pCvarFriction = register_cvar( "wpn_sg_friction" , "0.3" );
  302. pCvarDetonateDelay = register_cvar( "wpn_sg_detonate_delay" , "15" );
  303. pCvarFieldOfView = register_cvar( "wpn_sg_fov" , "1" );
  304. pCvarShowTrail = register_cvar( "wpn_sg_show_trail" , "0" );
  305. g_LCOST = register_cvar("bio_snark_cost","4000")
  306. RegisterHam( Ham_Item_Deploy , gWeaponCommand, "CSqueak_Deploy", 1 );
  307. RegisterHam( Ham_Item_Holster, gWeaponCommand, "CSqueak_Holster", 1 );
  308. RegisterHam( Ham_TakeDamage, gGenericEntity, "CSqueak_TakeDamage", 1 );
  309. RegisterHam(Ham_Killed, "player", "fw_PlayerKilled")
  310. RegisterHam(Ham_Spawn, "player", "fw_PlayerSpawn_Post", 1)
  311. register_forward(FM_ClientDisconnect, "fw_ClientDisconnect")
  312. register_forward( FM_CmdStart, "CSqueak_HookButtons" );
  313. register_forward( FM_PlayerPreThink, "CSqueak_WeaponIdle" );
  314. register_event("HLTV", "event_start_freezetime", "a", "1=0", "2=0")
  315. register_think( gSnarkClassName, "CSqueak_HuntThink" );
  316. register_touch( gSnarkClassName, "*", "CSqueak_SuperBounceTouch" );
  317.  
  318. register_clcmd( "say /snark", "CSqueak_GiveWeapon" );
  319. register_clcmd( "say_team /snark", "CSqueak_GiveWeapon" );
  320. register_clcmd( "snark", "CSqueak_GiveWeapon" );
  321.  
  322. gMaxEntities = global_get( glb_maxEntities );
  323. gMaxClients = global_get( glb_maxClients );
  324.  
  325. gSnarkClassNameReference = engfunc( EngFunc_AllocString, gSnarkClassName );
  326. gMsgidAmmoX = get_user_msgid( "AmmoX" );
  327.  
  328. if ( get_pcvar_num( pCvarShowTrail ) )
  329. {
  330. gSmokeTrail = engfunc( EngFunc_PrecacheModel, "sprites/smoke.spr" );
  331. }
  332. }
  333.  
  334. // Client joins the game
  335. public client_putinserver(id)
  336. {
  337. // Player joined
  338. is_connected[id] = true
  339. if (!is_user_bot(id)){
  340. is_bot[id] = false
  341. }else{
  342. is_bot[id] = true
  343. }
  344. }
  345.  
  346. // Client leaving
  347. public fw_ClientDisconnect(id)
  348. {
  349. is_connected[id] = false
  350. is_alive[id] = false
  351. }
  352. public fw_PlayerSpawn_Post(id)
  353. {
  354. // Not alive or didn't join a team yet
  355. if (!is_user_alive(id) || !cs_get_user_team(id))
  356. return;
  357. // Player spawned
  358. is_alive[id] = true
  359. }
  360. public fw_PlayerKilled(victim, attacker, shouldgib)
  361. {
  362. //player die
  363. is_alive[victim] = false
  364. }
  365.  
  366. public zp_user_humanized_post(id, survivor){
  367. CheckAndRemoveWeapon ( id );
  368. gHasSnark{ id } = false;
  369. }
  370. //shark stuff
  371. public event_start_freezetime(){
  372. new Snark = -1;
  373.  
  374. while ( ( Snark = find_ent_by_class( Snark, gSnarkClassName ) ) != NULL_ENT )
  375. {
  376. CSqueak_Killed ( Snark, 0, false );
  377. }
  378.  
  379. for ( new Player = 1; Player <= gMaxClients; Player++ )
  380. {
  381. CheckAndRemoveWeapon ( Player );
  382. gHasSnark{ Player } = false;
  383. }
  384. }
  385.  
  386.  
  387. public CheckAndRemoveWeapon ( const Player )
  388. {
  389. gHasSnark{ Player } = false;
  390. gWeaponActive{ Player } = false;
  391. }
  392.  
  393.  
  394. public client_connect ( Player )
  395. {
  396. gHasSnark { Player } = false;
  397. gWeaponActive{ Player } = false;
  398. gJustThrown { Player } = false;
  399. gPlayerAmmo { Player } = get_pcvar_num( pCvarAmmo );
  400. }
  401.  
  402.  
  403. public CSqueak_GiveWeapon( const Player )
  404. {
  405. if(cs_get_user_money(Player) < get_pcvar_num(g_LCOST)){
  406. client_print(Player,print_center,"You don't have enough money to buy a snark's")
  407. return;
  408. }
  409. if(is_user_zombie(Player)){
  410. cs_set_user_money(Player,cs_get_user_money(Player) - get_pcvar_num(g_LCOST))
  411. gHasSnark{ Player } = true;
  412. gPlayerAmmo{ Player } = get_pcvar_num( pCvarAmmo );
  413.  
  414. give_item( Player, gWeaponCommand );
  415. engclient_cmd( Player, gWeaponCommand );
  416. }
  417. else
  418. {
  419. client_print(Player,print_center,"Only for zombies")
  420. }
  421. }
  422.  
  423.  
  424. public CSqueak_PrimaryAttack ( const Player )
  425. {
  426. static Float:VAngle [ Angle_e ];
  427. static Float:Origin [ Coord_e ];
  428. static Float:TraceOrigin[ Coord_e ];
  429. static Float:Forward [ Coord_e ];
  430. static Float:Start [ Coord_e ];
  431. static Float:End [ Coord_e ];
  432. static Float:EndPos [ Coord_e ];
  433. static Float:Velocity [ Coord_e ];
  434. static Float:Fraction;
  435.  
  436. if ( gPlayerAmmo{ Player } )
  437. {
  438. if ( pev( Player, pev_waterlevel ) >= 3 )
  439. {
  440. emit_sound( Player, CHAN_WEAPON, gSnarkDieSound, VOL_NORM, ATTN_NORM, 0, PITCH_NORM + 5 );
  441. gNextShot[ Player ] = get_gametime() + get_pcvar_float( pCvarRefireRate );
  442. return PLUGIN_HANDLED;
  443. }
  444.  
  445. pev( Player, pev_origin, Origin );
  446. pev( Player, pev_v_angle, VAngle );
  447. pev( Player, pev_velocity, Velocity );
  448.  
  449. engfunc( EngFunc_MakeVectors, VAngle );
  450.  
  451. VectorCopy( Origin, TraceOrigin );
  452.  
  453. if ( pev( Player, pev_flags ) & FL_DUCKING )
  454. {
  455. TraceOrigin[ x ] = TraceOrigin[ x ] - ( gHullMin[ x ] - gDuckHullMin[ x ] );
  456. TraceOrigin[ y ] = TraceOrigin[ y ] - ( gHullMin[ y ] - gDuckHullMin[ y ] );
  457. TraceOrigin[ z ] = TraceOrigin[ z ] - ( gHullMin[ z ] - gDuckHullMin[ z ] );
  458. }
  459.  
  460. global_get( glb_v_forward, Forward );
  461.  
  462. VectorMA ( TraceOrigin, 20.0, Forward, Start );
  463. VectorMA ( TraceOrigin, 64.0, Forward, End );
  464.  
  465. engfunc( EngFunc_TraceLine, Start, End, DONT_IGNORE_MONSTERS, NULL_ENT, 0 );
  466.  
  467. get_tr2( 0, TR_Fraction, Fraction );
  468. get_tr2( 0, TR_vecEndPos, EndPos );
  469.  
  470. if ( !get_tr2( 0, TR_AllSolid ) && !get_tr2( 0, TR_StartSolid ) && Fraction > 0.25 )
  471. {
  472. // --| Play the throw animation.
  473. UTIL_PlayWeaponAnimation ( Player, squeak_throw );
  474.  
  475. // --| player "shoot" animation
  476. //
  477.  
  478. VectorMA ( Velocity, get_pcvar_float( pCvarVelocity ), Forward, Velocity );
  479.  
  480. if ( CSqueak_Create ( Player, EndPos, VAngle, Velocity ) )
  481. {
  482. new Float:CurrentTime = get_gametime();
  483.  
  484. switch ( random_num( 0, 2 ) )
  485. {
  486. case 0: emit_sound( Player, CHAN_WEAPON, gSnarkHunt1Sound, VOL_NORM, ATTN_NORM, 0, PITCH_NORM );
  487. case 1: emit_sound( Player, CHAN_WEAPON, gSnarkHunt2Sound, VOL_NORM, ATTN_NORM, 0, PITCH_NORM );
  488. case 2: emit_sound( Player, CHAN_WEAPON, gSnarkHunt3Sound, VOL_NORM, ATTN_NORM, 0, PITCH_NORM );
  489. }
  490.  
  491. gPlayerAmmo{ Player }--;
  492. gJustThrown{ Player } = true;
  493.  
  494. UpdateHud ( Player );
  495.  
  496. gNextShot[ Player ] = CurrentTime + get_pcvar_float( pCvarRefireRate );
  497. gTimeWeaponIdle[ Player ] = CurrentTime + 1.0;
  498.  
  499. return PLUGIN_CONTINUE;
  500. }
  501. }
  502. }
  503.  
  504. return PLUGIN_HANDLED;
  505. }
  506.  
  507.  
  508. public CSqueak_Deploy ( const Weapon )
  509. {
  510. // --| Get the knife's owner index.
  511. new Player = get_pdata_cbase( Weapon, m_pPlayer, 4 );
  512.  
  513. if ( Player && gHasSnark{ Player } )
  514. {
  515. // --| Change knife to snark weapon.
  516. ChangeWeaponToSnark ( Player );
  517.  
  518. // --| Play the deploy animation.
  519. UTIL_PlayWeaponAnimation ( Player, squeak_up );
  520. emit_sound ( Weapon, CHAN_VOICE , random_float ( 0.0, 1.0 ) <= 0.5 ? gSnarkHunt2Sound : gSnarkHunt3Sound, VOL_NORM, ATTN_NORM, 0, PITCH_NORM );
  521.  
  522. // --| Block the primary attack.
  523. set_pdata_float( Weapon, m_flNextPrimaryAttack, 9999.0, 4 );
  524. set_pdata_float( Player, m_flNextAttack, 9999.0 );
  525.  
  526. // --| Update Ammo on HUD.
  527. UpdateHud ( Player );
  528.  
  529. // --| We are holding the weapon.
  530. gWeaponActive{ Player } = true;
  531. }
  532. }
  533.  
  534.  
  535. public CSqueak_Holster ( const Weapon )
  536. {
  537. // --| Get the knife's owner index.
  538. new Player = get_pdata_cbase( Weapon, m_pPlayer, 4 );
  539.  
  540. if ( Player && gHasSnark{ Player } && gWeaponActive{ Player } )
  541. {
  542. // --| We are not holding the weapon anymore.
  543. gWeaponActive{ Player } = false;
  544. set_pdata_float( Player, m_flNextAttack, get_gametime() + 0.5 );
  545.  
  546. if ( !gPlayerAmmo{ Player } && user_has_weapon( Player, gWeaponIndex ) )
  547. {
  548. RemoveWeapon ( Player, get_pdata_cbase( Player, m_pActiveWeapon ) );
  549. }
  550. else
  551. {
  552. // --| Play the holster animation.
  553. UTIL_PlayWeaponAnimation ( Player, squeak_down );
  554. emit_sound( Player, CHAN_WEAPON, "common/null.wav", VOL_NORM, ATTN_NORM, 0, PITCH_NORM );
  555. }
  556. }
  557. }
  558.  
  559.  
  560. public CSqueak_Killed ( const Snark, const Killer, const bool:ShouldGib )
  561. {
  562. new Float:Origin [ Coord_e ];
  563. if(ShouldGib){
  564. new Float:Direction[ Coord_e ];
  565.  
  566. pev( Snark, pev_origin, Origin );
  567.  
  568. set_pev( Snark, pev_model, 0 );
  569. set_pev( Snark, pev_Remove, RemoveSnark );
  570. set_pev( Snark, pev_DetonateDelay, get_gametime() + 0.1 );
  571. set_pev( Snark, pev_takedamage, DAMAGE_NO );
  572.  
  573. emit_sound( Snark, CHAN_ITEM, gSnarkBlastSound, VOL_NORM, ATTN_NORM / 2, 0, PITCH_NORM );
  574. emit_sound( Snark, CHAN_VOICE, gSnarkBodySplatSound, 0.75, ATTN_NORM, 0, PITCH_NORM * 2 );
  575.  
  576. UTIL_RandomBloodVector( Direction );
  577.  
  578. FX_BloodDrips ( Origin, BLOOD_COLOR_YELLOW, .Amount = 60 );
  579. FX_StreakSplash ( Origin, Direction, .Color = 5, .Count = 16, .Speed = 50, .VelocityRange = 200 );
  580.  
  581. UTIL_RadiusDamage ( Origin, Snark, pev( Snark, pev_RealOwner ), get_pcvar_float( pCvarDamagePop ), get_pcvar_float( pCvarDamageRadius ), DMG_BLAST );
  582. } else {
  583. pev( Snark, pev_origin, Origin );
  584.  
  585. set_pev( Snark, pev_model, 0 );
  586. set_pev( Snark, pev_Remove, RemoveSnark );
  587. set_pev( Snark, pev_DetonateDelay, get_gametime() + 0.1 );
  588.  
  589. set_pev( Snark, pev_takedamage, DAMAGE_NO );
  590. }
  591. }
  592.  
  593.  
  594. /* public CZombie_Killed ( const Zombie, const Human, const bool:ShouldGid )
  595. {
  596. if ( is_user_zombie( Zombie ) && gHasSnark{ Zombie } )
  597. {
  598.  
  599. }
  600. } */
  601.  
  602.  
  603. public CSqueak_TakeDamage ( const Snark, const Inflictor, const Attacker, const Float:Damage, const DamageBits )
  604. {
  605. if ( is_valid_ent( Snark ) && pev( Snark, pev_groupinfo ) == gSnarkClassNameReference )
  606. {
  607. if ( pev( Snark, pev_health ) - gSnarkHealthReference <= 0 )
  608. {
  609. CSqueak_Killed ( Snark, Attacker, .ShouldGib = true );
  610. }
  611. }
  612. }
  613.  
  614.  
  615. public CSqueak_HookButtons ( const Player, const UC_Handle, const Seed )
  616. {
  617. static Float:CurrentTime;
  618. static Buttons;
  619.  
  620. if ( gHasSnark{ Player } && gWeaponActive{ Player } && ( Buttons = get_uc( UC_Handle, UC_Buttons ) ) & IN_ATTACK )
  621. {
  622. CurrentTime = get_gametime();
  623.  
  624. if ( gNextShot[ Player ] > CurrentTime )
  625. {
  626. return FMRES_HANDLED;
  627. }
  628.  
  629. if ( CSqueak_PrimaryAttack ( Player ) == PLUGIN_HANDLED )
  630. {
  631. return FMRES_HANDLED;
  632. }
  633.  
  634. set_uc( UC_Handle, UC_Buttons, Buttons & ~IN_ATTACK );
  635. return FMRES_HANDLED;
  636. }
  637.  
  638. return FMRES_IGNORED;
  639. }
  640.  
  641. const g_armor_amount = 50
  642. const g_armor_limit = 999
  643.  
  644. public CSqueak_HuntThink ( const Snark )
  645. {
  646. if ( !is_valid_ent( Snark ) )
  647. {
  648. return HAM_IGNORED;
  649. }
  650. static Float:Origin [ Coord_e ];
  651. static Float:Velocity[ Coord_e ];
  652. static Float:Angles [ Coord_e ];
  653. static Float:Flat [ Coord_e ];
  654. static Float:CurrentTime;
  655. static Float:DieDelay;
  656. static Float:NextHunt;
  657. static Float:SPitch;
  658. static Enemy;
  659. pev( Snark, pev_nextthink, NextHunt );
  660. CurrentTime = get_gametime();
  661. if ( NextHunt > CurrentTime )
  662. {
  663. return HAM_IGNORED;
  664. }
  665.  
  666. pev( Snark, pev_velocity, Velocity );
  667. pev( Snark, pev_origin, Origin );
  668.  
  669. if ( !UTIL_IsInWorld ( Origin, Velocity ) )
  670. {
  671. set_pev( Snark, pev_flags, pev( Snark, pev_flags ) | FL_KILLME );
  672. return HAM_IGNORED;
  673. }
  674. set_pev( Snark, pev_nextthink, CurrentTime + 0.5 );
  675.  
  676. pev( Snark, pev_NextHunt, NextHunt );
  677. pev( Snark, pev_DetonateDelay, DieDelay );
  678. pev( Snark, pev_angles, Angles );
  679.  
  680. if ( CurrentTime >= DieDelay )
  681. {
  682. if ( pev( Snark, pev_Remove ) )
  683. {
  684. set_pev( Snark, pev_flags, pev( Snark, pev_flags ) | FL_KILLME );
  685. return HAM_IGNORED;
  686. }
  687.  
  688. set_pev( Snark, pev_health, -1.0 );
  689. CSqueak_Killed ( Snark, 0, true );
  690. return HAM_IGNORED;
  691. }
  692.  
  693. if ( pev( Snark, pev_waterlevel ) != 0 )
  694. {
  695. if ( pev( Snark, pev_movetype ) == MOVETYPE_BOUNCE )
  696. {
  697. set_pev( Snark, pev_movetype, MOVETYPE_FLY );
  698. }
  699.  
  700. VectorScale ( Velocity, 0.9, Velocity );
  701. Velocity[ z ] += 8.0;
  702.  
  703. set_pev( Snark, pev_velocity, Velocity );
  704. }
  705. else if ( pev( Snark, pev_movetype ) == MOVETYPE_FLY )
  706. {
  707. set_pev( Snark, pev_movetype, MOVETYPE_BOUNCE );
  708. }
  709.  
  710. if ( NextHunt > CurrentTime )
  711. {
  712. return HAM_IGNORED;
  713. }
  714.  
  715. set_pev( Snark, pev_NextHunt, CurrentTime + 2.0 );
  716.  
  717. VectorCopy ( Velocity, Flat );
  718. Flat[ z ] = 0.0;
  719. VectorNormalize ( Flat, Flat );
  720.  
  721. engfunc( EngFunc_MakeVectors, Angles );
  722.  
  723. if ( ( Enemy = pev( Snark, pev_enemy ) ) == NULL_ENT || !is_alive[ Enemy ] || is_user_zombie( Enemy ) )
  724. {
  725. Enemy = UTIL_BestVisibleEnemy ( Snark, 512.0 );
  726. }
  727.  
  728. if ( 0.3 <= DieDelay - CurrentTime <= 0.5 )
  729. {
  730. set_pev( Snark, pev_scale, 2.0 );
  731. emit_sound( Snark, CHAN_VOICE, gSnarkDieSound, VOL_NORM, ATTN_NORM, 0, PITCH_NORM + random_num( 0, 0x3F ) );
  732. }
  733.  
  734. SPitch = 155.0 - 60.0 * ( ( DieDelay - CurrentTime ) / get_pcvar_float( pCvarDetonateDelay ) );
  735.  
  736. if ( SPitch < 80.0 ) { SPitch = 80.0; }
  737.  
  738. if ( Enemy != NULL_ENT && !is_user_zombie( Enemy ) )
  739. {
  740. static Float:Target[ Coord_e ];
  741. static Float:Vel;
  742. static Float:Adj;
  743.  
  744. pev( Snark, pev_EnemyTarget, Target );
  745.  
  746. if ( UTIL_FVisible( Snark, Enemy ) )
  747. {
  748. static Float:EyePosition[ Coord_e ];
  749. UTIL_EyePosition ( Enemy, EyePosition );
  750.  
  751. VectorSubtract ( EyePosition, Origin, Target );
  752. VectorNormalize ( Target, Target );
  753.  
  754. set_pev( Snark, pev_EnemyTarget, Target );
  755. }
  756.  
  757. Vel = VectorLength ( Velocity );
  758. Adj = 50.0 / ( Vel + 10.0 );
  759.  
  760. if ( Adj > 1.2 ) { Adj = 1.2; }
  761.  
  762. Velocity[ x ] = Velocity[ x ] * Adj + Target[ x ] * 300.0;
  763. Velocity[ y ] = Velocity[ y ] * Adj + Target[ y ] * 300.0;
  764. Velocity[ z ] = Velocity[ z ] * Adj + Target[ z ] * 300.0;
  765.  
  766. set_pev( Snark, pev_velocity, Velocity );
  767. }
  768.  
  769. if ( pev( Snark, pev_flags ) & FL_ONGROUND )
  770. {
  771. set_pev( Snark, pev_avelocity, Float:{ 0.0, 0.0, 0.0 } );
  772. }
  773. else
  774. {
  775. static Float:AVelocity[ Coord_e ];
  776. pev( Snark, pev_avelocity, AVelocity );
  777.  
  778. if ( AVelocity[ x ] == 0.0 && AVelocity[ y ] == 0.0 && AVelocity[ z ] == 0.0 )
  779. {
  780. AVelocity[ x ] = random_float( -100.0, 100.0 );
  781. AVelocity[ z ] = random_float( -100.0, 100.0 );
  782.  
  783. set_pev( Snark, pev_avelocity, AVelocity );
  784. }
  785. }
  786.  
  787. static Float:PosPrev[ Coord_e ];
  788. pev( Snark, pev_PosPrev, PosPrev );
  789.  
  790. VectorSubtract ( Origin, PosPrev, PosPrev );
  791.  
  792. if ( VectorLength ( PosPrev ) < 1.0 )
  793. {
  794. Velocity[ x ] = random_float( -100.0, 100.0 );
  795. Velocity[ y ] = random_float( -100.0, 100.0 );
  796.  
  797. set_pev( Snark, pev_velocity, Velocity );
  798. }
  799.  
  800. set_pev( Snark, pev_PosPrev, Origin );
  801.  
  802. vector_to_angle( Velocity, Angles );
  803.  
  804. Angles[ z ] = 0.0;
  805. Angles[ x ] = 0.0;
  806.  
  807. set_pev( Snark, pev_angles, Angles );
  808.  
  809. return HAM_IGNORED;
  810. }
  811.  
  812.  
  813. public CSqueak_SuperBounceTouch ( const Snark, const Other )
  814. {
  815. if ( !is_valid_ent( Snark ) )
  816. {
  817. return;
  818. }
  819. static Float:Angles [ Angle_e ];
  820. static Float:NextHit;
  821. static Float:DieDelay;
  822. static Float:NextAttack;
  823. static Float:NextBounceSoundTime;
  824. static Float:SPitch;
  825. static Float:CurrentTime;
  826. static Owner;
  827. CurrentTime = get_gametime();
  828. Owner = pev( Snark, pev_owner );
  829.  
  830. if ( Owner && Other == Owner )
  831. {
  832. return;
  833. }
  834. pev( Snark, pev_NextHit, NextHit );
  835. if ( NextHit > CurrentTime )
  836. {
  837. return;
  838. }
  839.  
  840. SPitch = PITCH_NORM * 1.0;
  841.  
  842. set_pev( Snark, pev_owner, NULL_ENT );
  843.  
  844. pev( Snark, pev_angles, Angles );
  845. pev( Snark, pev_DetonateDelay, DieDelay );
  846. pev( Snark, pev_NextAttack, NextAttack );
  847. pev( Snark, pev_NextBounceSoundTime, NextBounceSoundTime );
  848.  
  849. Angles[ x ] = 0.0;
  850. Angles[ z ] = 0.0;
  851.  
  852. set_pev( Snark, pev_angles, Angles );
  853.  
  854. SPitch = 155.0 - 60.0 * ( ( DieDelay - CurrentTime ) / get_pcvar_float( pCvarDetonateDelay ) );
  855.  
  856. if ( 1 <= Other <= gMaxClients && pev( Other, pev_takedamage ) && NextAttack < CurrentTime )
  857. {
  858. static Hit;
  859. Hit = global_get( glb_trace_ent );
  860.  
  861. if ( Hit == Other && pev( Hit, pev_modelindex ) != pev( Snark, pev_modelindex ) && 1 <= Other <= gMaxClients )
  862. {
  863. Owner = pev( Snark, pev_RealOwner );
  864. if(Other!=Owner && is_alive[Other] && is_user_valid_connected(Owner) && !is_user_zombie( Other ) ){
  865. if(pev(Other, pev_armorvalue)>float(g_armor_amount)) armor[Other] = true
  866. else armor[Other] = false
  867.  
  868. static Float:Forward [ Coord_e ];
  869. static Float:EndPos [ Coord_e ];
  870. static Float:OriginSnark[ Coord_e ];
  871. static Float:OriginOther[ Coord_e ];
  872. static Trace;
  873. static Float:Damage;
  874.  
  875. Trace = create_tr2();
  876.  
  877. pev( Snark, pev_dmg, Damage );
  878. pev( Snark, pev_origin, OriginSnark );
  879. pev( Other, pev_origin, OriginOther );
  880.  
  881. engfunc( EngFunc_TraceLine, OriginSnark, OriginOther, DONT_IGNORE_MONSTERS, Snark, Trace );
  882.  
  883. get_tr2( Trace, TR_vecPlaneNormal, Forward );
  884. get_tr2( Trace, TR_vecEndPos, EndPos );
  885.  
  886. ExecuteHam( Ham_TraceBleed, Other, Damage, Forward, Trace, DMG_SLASH );
  887. free_tr2( Trace );
  888.  
  889. FX_BloodDrips ( EndPos, BLOOD_COLOR_RED, .Amount = floatround( Damage ) );
  890. if(armor[Other])
  891. set_pev(Other, pev_armorvalue, float(min(pev(Other, pev_armorvalue)-g_armor_amount, g_armor_limit)));
  892. else
  893. ExecuteHam( Ham_TakeDamage, Other, Snark, Owner, Damage, DMG_SLASH );
  894. set_pev( Snark, pev_dmg, get_pcvar_float( pCvarDamagePop ) );
  895.  
  896. }
  897. emit_sound( Snark, CHAN_WEAPON, gSnarkAttackSound, VOL_NORM, ATTN_NORM, 0, floatround( SPitch ) );
  898. set_pev( Snark, pev_NextAttack, CurrentTime + 0.5 );
  899. }
  900. }
  901.  
  902. set_pev( Snark, pev_NextHit, CurrentTime + 0.1 );
  903. set_pev( Snark, pev_NextHunt, CurrentTime );
  904.  
  905. if ( CurrentTime < NextBounceSoundTime )
  906. {
  907. return;
  908. }
  909.  
  910. if ( !( pev( Snark, pev_flags ) & FL_ONGROUND ) )
  911. {
  912. switch ( random( 10 ) )
  913. {
  914. case 0 .. 3 : emit_sound( Snark, CHAN_VOICE, gSnarkHunt1Sound, VOL_NORM, ATTN_NORM, 0, floatround( SPitch ) );
  915. case 4 .. 7 : emit_sound( Snark, CHAN_VOICE, gSnarkHunt2Sound, VOL_NORM, ATTN_NORM, 0, floatround( SPitch ) );
  916. default : emit_sound( Snark, CHAN_VOICE, gSnarkHunt3Sound, VOL_NORM, ATTN_NORM, 0, floatround( SPitch ) );
  917. }
  918. }
  919.  
  920. set_pev( Snark, pev_NextBounceSoundTime, CurrentTime + 0.5 );
  921. }
  922.  
  923.  
  924. CSqueak_Create ( const Player, const Float:Origin[ Coord_e ], const Float:Angles[ Coord_e], const Float:Velocity[ Coord_e ] )
  925. {
  926. new Snark = create_entity( gGenericEntity );
  927.  
  928. if ( is_valid_ent( Snark ) )
  929. {
  930. set_pev( Snark, pev_classname, gSnarkClassName );
  931. set_pev( Snark, pev_groupinfo, gSnarkClassNameReference );
  932. set_pev( Snark, pev_owner, Player );
  933. set_pev( Snark, pev_origin, Origin );
  934. set_pev( Snark, pev_angles, Angles );
  935. set_pev( Snark, pev_velocity, Velocity );
  936.  
  937. CSqueak_Spawn ( Player, Snark, Origin );
  938.  
  939. return Snark;
  940. }
  941.  
  942. return NULL_ENT;
  943. }
  944.  
  945.  
  946. CSqueak_Spawn ( const Player, const Snark, const Float:Origin[ Coord_e ] )
  947. {
  948. new Float:CurrentTime = get_gametime();
  949.  
  950. set_pev( Snark, pev_movetype, MOVETYPE_BOUNCE );
  951. set_pev( Snark, pev_solid, SOLID_BBOX );
  952.  
  953. entity_set_model ( Snark, gSnarkModel );
  954. entity_set_size ( Snark, Float:{ -4.0, -4.0, 0.0 }, Float:{ 4.0, 4.0, 8.0 } );
  955. entity_set_origin( Snark, Origin );
  956.  
  957. set_pev( Snark, pev_nextthink, CurrentTime + 0.1 );
  958.  
  959. set_pev( Snark, pev_NextHunt, CurrentTime + 1000000.0 ); // NextHunt
  960. set_pev( Snark, pev_DetonateDelay, CurrentTime + get_pcvar_float( pCvarDetonateDelay ) ); // DetonateDelay
  961. set_pev( Snark, pev_NextBounceSoundTime, CurrentTime ); // NextBounceSoundTime
  962. set_pev( Snark, pev_RealOwner, Player ); // RealOwner
  963.  
  964. set_pev( Snark, pev_flags, pev( Snark, pev_flags ) | FL_MONSTER );
  965. set_pev( Snark, pev_takedamage, DAMAGE_AIM );
  966. set_pev( Snark, pev_health, get_pcvar_float( pCvarHealth ) + gSnarkHealthReference );
  967. set_pev( Snark, pev_gravity, get_pcvar_float( pCvarGravity ) );
  968. set_pev( Snark, pev_friction, get_pcvar_float( pCvarFriction ) );
  969. set_pev( Snark, pev_fov, get_pcvar_num( pCvarFieldOfView ) );
  970. set_pev( Snark, pev_dmg, get_pcvar_float( pCvarDamagePop ) );
  971.  
  972. // --| Force snark to run.
  973. set_pev( Snark, pev_sequence, wsqueak_run );
  974. set_pev( Snark, pev_framerate, 1.0 );
  975. set_pev( Snark, pev_animtime, CurrentTime );
  976.  
  977. if ( get_pcvar_num( pCvarShowTrail ) )
  978. {
  979. message_begin ( MSG_BROADCAST, SVC_TEMPENTITY );
  980. write_byte ( TE_BEAMFOLLOW );
  981. write_short ( Snark );
  982. write_short ( gSmokeTrail );
  983. write_byte ( TRAIL_LIFE ); // life
  984. write_byte ( TRAIL_WIDTH ); // width
  985. write_byte ( TRAIL_RED );
  986. write_byte ( TRAIL_GREEN );
  987. write_byte ( TRAIL_BLUE );
  988. write_byte ( TRAIL_BRIGTHNESS );
  989. message_end();
  990. }
  991. }
  992.  
  993.  
  994. public CSqueak_WeaponIdle ( const Player )
  995. {
  996. if ( gHasSnark{ Player } && gWeaponActive{ Player } )
  997. {
  998. static Float:CurrentTime;
  999. CurrentTime = get_gametime();
  1000.  
  1001. if ( gTimeWeaponIdle[ Player ] > CurrentTime )
  1002. {
  1003. return;
  1004. }
  1005.  
  1006. if ( gJustThrown{ Player } )
  1007. {
  1008. gJustThrown{ Player } = false;
  1009.  
  1010. if ( !gPlayerAmmo{ Player } )
  1011. {
  1012. RemoveWeapon ( Player, get_pdata_cbase( Player, m_pActiveWeapon ) );
  1013. return;
  1014. }
  1015.  
  1016. UTIL_PlayWeaponAnimation ( Player, squeak_up );
  1017. gTimeWeaponIdle[ Player ] = CurrentTime + random_float ( 10.0, 15.0 );
  1018.  
  1019. return;
  1020. }
  1021.  
  1022. new Animation;
  1023. new Float:NewTime;
  1024.  
  1025. switch ( random_num( 0, 10 ) )
  1026. {
  1027. case 0 .. 6 :
  1028. {
  1029. Animation = squeak_idle1;
  1030. NewTime = 30.0 / 16.0 * ( 2.0 );
  1031. }
  1032. case 7 .. 8 :
  1033. {
  1034. Animation = squeak_fidgetfit;
  1035. NewTime = 70.0 / 16.0;
  1036. }
  1037. default :
  1038. {
  1039. Animation = squeak_fidgetnip;
  1040. NewTime = 80.0 / 16.0;
  1041. }
  1042. }
  1043.  
  1044. UTIL_PlayWeaponAnimation ( Player, Animation );
  1045. gTimeWeaponIdle[ Player ] = CurrentTime + NewTime;
  1046. }
  1047. }
  1048.  
  1049.  
  1050. ChangeWeaponToSnark ( const Player )
  1051. {
  1052. set_pev( Player, pev_viewmodel2 , gModel_V );
  1053. set_pev( Player, pev_weaponmodel2, gModel_P );
  1054. }
  1055.  
  1056.  
  1057. UpdateHud ( const Player )
  1058. {
  1059. message_begin( MSG_ONE_UNRELIABLE, gMsgidAmmoX, .player = Player );
  1060. write_byte( 12 );
  1061. write_byte( gPlayerAmmo{ Player } );
  1062. message_end();
  1063. }
  1064.  
  1065.  
  1066. RemoveWeapon ( const Player, const Weapon )
  1067. {
  1068. ExecuteHamB( Ham_Weapon_RetireWeapon, Weapon );
  1069. ExecuteHamB( Ham_RemovePlayerItem, Player, Weapon );
  1070. ExecuteHamB( Ham_Item_Kill, Weapon );
  1071.  
  1072. set_pev( Player, pev_weapons, pev( Player, pev_weapons ) & ~( 1 << gWeaponIndex ) );
  1073. cs_set_user_bpammo( Player, gWeaponIndex, 0 );
  1074.  
  1075. gHasSnark{ Player } = false;
  1076. gWeaponActive{ Player } = false;
  1077. }
  1078.  
  1079.  
  1080. stock bool:UTIL_IsBSPModel ( const Entity )
  1081. {
  1082. return ( pev( entity, pev_solid ) == SOLID_BSP || pev( Entity, pev_movetype ) == MOVETYPE_STEP );
  1083. }
  1084.  
  1085.  
  1086. UTIL_BestVisibleEnemy ( const Snark, const Float:DistanceToSearch /* , const Flags */ )
  1087. {
  1088. static List[ MAX_CLIENTS ];
  1089. static Float:Distance;
  1090. static Float:Nearest;
  1091. static ReturnEntity;
  1092. static Count;
  1093. static Entity;
  1094. static i;
  1095.  
  1096. Nearest = 8192.0;
  1097. ReturnEntity = NULL_ENT;
  1098.  
  1099. Count = find_sphere_class( Snark, "player", DistanceToSearch, List, sizeof List );
  1100.  
  1101. for ( i = 0; i < Count; i++ )
  1102. {
  1103. Entity = List[ i ];
  1104.  
  1105. if ( is_user_zombie( Entity ) )
  1106. {
  1107. continue;
  1108. }
  1109.  
  1110. if ( UTIL_FInViewCone ( Snark, Entity ) && UTIL_FVisible( Snark, Entity ) )
  1111. {
  1112. if ( ( Distance = entity_range( Snark, Entity ) ) <= Nearest )
  1113. {
  1114. Nearest = Distance;
  1115. ReturnEntity = Entity;
  1116. }
  1117. }
  1118. }
  1119.  
  1120. set_pev( Snark, pev_enemy, ReturnEntity );
  1121. return ReturnEntity;
  1122. }
  1123.  
  1124.  
  1125.  
  1126. UTIL_PlayWeaponAnimation ( const Player, const Sequence )
  1127. {
  1128. set_pev( Player, pev_weaponanim, Sequence );
  1129.  
  1130. message_begin( MSG_ONE_UNRELIABLE, SVC_WEAPONANIM, .player = Player );
  1131. write_byte( Sequence );
  1132. write_byte( pev( Player, pev_body ) );
  1133. message_end();
  1134. }
  1135.  
  1136.  
  1137. bool:UTIL_IsInWorld ( const Float:Origin[ Coord_e ], const Float:Velocity[ Coord_e ] )
  1138. {
  1139. static i;
  1140.  
  1141. for ( i = x; i <= z; i++ )
  1142. {
  1143. if ( !( -4096.0 < Origin[ i ] < 4096.0 ) && !( -2000.0 < Velocity[ x ] < 2000.0 ) )
  1144. {
  1145. return false;
  1146. }
  1147. }
  1148.  
  1149. return true;
  1150. }
  1151.  
  1152.  
  1153. UTIL_RandomBloodVector ( Float:Direction[ Coord_e ] )
  1154. {
  1155. Direction[ x ] = random_float( -1.0, 1.0 );
  1156. Direction[ y ] = random_float( -1.0, 1.0 );
  1157. Direction[ z ] = random_float( 0.0, 1.0 );
  1158. }
  1159.  
  1160.  
  1161. FX_BloodDrips ( const Float:Origin[ Coord_e ], const BloodColor, const Amount )
  1162. {
  1163. message_begin_f( MSG_PVS, SVC_TEMPENTITY, Origin, NULL_ENT );
  1164. write_byte( TE_BLOODSPRITE );
  1165. write_coord_f( Origin[ x ] );
  1166. write_coord_f( Origin[ y ] );
  1167. write_coord_f( Origin[ z ] );
  1168. write_short( gBloodSpray ); // initial sprite model
  1169. write_short( gBloodDrop ); // droplet sprite models
  1170. write_byte( BloodColor ); // color index into host_basepal
  1171. write_byte( min( max( 3, ( Amount > 255 ? 255 : Amount ) / 10 ), 16 ) ); // size
  1172. message_end();
  1173. }
  1174.  
  1175.  
  1176. FX_StreakSplash ( const Float:Origin[ Coord_e ], const Float:Direction[ Coord_e ], const Color, const Count, const Speed, const VelocityRange )
  1177. {
  1178. message_begin_f( MSG_PVS, SVC_TEMPENTITY, Origin, NULL_ENT );
  1179. write_byte( TE_STREAK_SPLASH );
  1180. write_coord_f( Origin[ x ] );
  1181. write_coord_f( Origin[ y ] );
  1182. write_coord_f( Origin[ z ] );
  1183. write_coord_f( Direction[ x ] );
  1184. write_coord_f( Direction[ y ] );
  1185. write_coord_f( Direction[ z ] );
  1186. write_byte( min( Color, 255 ) );
  1187. write_short( Count );
  1188. write_short( Speed );
  1189. write_short( VelocityRange );// random velocity modifier
  1190. message_end();
  1191. }
  1192.  
  1193.  
  1194. stock FX_TraceBleed( const Victim, const Float:Damage, const Float:Dir[ Coord_e ], const TraceResult:Trace )
  1195. {
  1196. new TraceResult:BloodTrace;
  1197. new Float:TraceDir[ Coord_e ];
  1198. new Float:EndPos [ Coord_e ];
  1199. new Float:Noise;
  1200. new Float:Fraction;
  1201. new Count;
  1202.  
  1203. if ( Damage < 10 )
  1204. {
  1205. Noise = 0.1;
  1206. Count = 1;
  1207. }
  1208. else if ( Damage < 25 )
  1209. {
  1210. Noise = 0.2;
  1211. Count = 2;
  1212. }
  1213. else
  1214. {
  1215. Noise = 0.3;
  1216. Count = 4;
  1217. }
  1218.  
  1219. for ( new i = 0 ; i < Count ; i++ )
  1220. {
  1221. VectorScale ( Dir, -1.0, TraceDir );
  1222.  
  1223. TraceDir[ x ] += random_float( -Noise, Noise );
  1224. TraceDir[ y ] += random_float( -Noise, Noise );
  1225. TraceDir[ z ] += random_float( -Noise, Noise );
  1226.  
  1227. get_tr2( Trace, TR_vecEndPos, EndPos );
  1228. VectorMA ( EndPos, -172.0, TraceDir, TraceDir );
  1229.  
  1230. engfunc( EngFunc_TraceLine, EndPos, TraceDir, IGNORE_MONSTERS, Victim, BloodTrace );
  1231. get_tr2( BloodTrace, TR_flFraction, Fraction );
  1232.  
  1233. if ( Fraction != 1.0 )
  1234. {
  1235. FX_BloodDecalTrace( BloodTrace, EndPos, BLOOD_COLOR_RED );
  1236. }
  1237. }
  1238. }
  1239.  
  1240.  
  1241. stock FX_BloodDecalTrace ( const TraceResult:Trace, const Float:EndPos[ Coord_e ], const BloodColor )
  1242. {
  1243. new Hit;
  1244. new BaseIndex;
  1245. new DecalIndex;
  1246. new Float:Fraction;
  1247.  
  1248. switch ( BloodColor )
  1249. {
  1250. case BLOOD_COLOR_YELLOW : BaseIndex = get_decal_index( "{yblood1" );
  1251. case BLOOD_COLOR_RED : BaseIndex = get_decal_index( "{blood1" );
  1252. }
  1253.  
  1254. DecalIndex = BaseIndex + random_num( 0, 5 );
  1255.  
  1256. Hit = max( 0, get_tr2( Trace, TR_pHit ) );
  1257. get_tr2( Trace, TR_flFraction, Fraction );
  1258.  
  1259. if ( Fraction == 1.0 || ( Hit && !UTIL_IsBSPModel ( Hit ) ) )
  1260. {
  1261. return;
  1262. }
  1263.  
  1264. message_begin( MSG_BROADCAST, SVC_TEMPENTITY );
  1265. write_byte( Hit ? TE_DECAL : TE_WORLDDECAL );
  1266. write_coord_f( EndPos[ x ] );
  1267. write_coord_f( EndPos[ y ] );
  1268. write_coord_f( EndPos[ z ] );
  1269. write_byte( DecalIndex );
  1270. if ( Hit )
  1271. {
  1272. write_short( Hit );
  1273. }
  1274. message_end();
  1275. }
  1276.  
  1277.  
  1278. stock UTIL_RadiusDamage ( const Float:Origin[ Coord_e ], const Inflictor, const Attacker, const Float:Damage, const Float:Radius, const DamageBits )
  1279. {
  1280. static Entity;
  1281. static Trace;
  1282. static Float:AdjustedDamage;
  1283. static bool:InWater;
  1284.  
  1285. Entity = NULL_ENT;
  1286. InWater = UTIL_LiquidContents( Origin );
  1287.  
  1288. while ( ( Entity = find_ent_in_sphere( Entity, Origin, Radius ) ) != NULL_ENT )
  1289. {
  1290. if ( Entity == Inflictor )
  1291. {
  1292. continue;
  1293. }
  1294. if(!is_user_valid_connected(Entity)) return PLUGIN_CONTINUE
  1295. if(is_bot[Entity] || !is_alive[Entity] || !cs_get_user_team(Entity) ) return PLUGIN_CONTINUE
  1296. if ( pev( Entity, pev_takedamage ) && !is_user_zombie( Entity ))
  1297. {
  1298. static Float:EntOrigin[ Coord_e ];
  1299. static Float:EndPos [ Coord_e ];
  1300. static Float:Fraction;
  1301.  
  1302. pev( Entity, pev_origin, EntOrigin );
  1303.  
  1304. engfunc( EngFunc_TraceLine, Origin, EntOrigin, IGNORE_MONSTERS, Inflictor, Trace );
  1305.  
  1306. get_tr2( Trace, TR_flFraction, Fraction );
  1307. get_tr2( Trace, TR_vecEndPos, EndPos );
  1308.  
  1309. if ( Fraction == 1.0 || get_tr2( Trace, TR_pHit ) == Entity )
  1310. {
  1311. static Float:Delta[ Coord_e ];
  1312. static Float:Len;
  1313.  
  1314. if ( get_tr2( Trace, TR_StartSolid ) )
  1315. {
  1316. EndPos = Origin;
  1317. Fraction = 0.0;
  1318. }
  1319.  
  1320. AdjustedDamage = Damage;
  1321. VectorSubtract ( EndPos, Origin, Delta );
  1322.  
  1323. if ( ( Len = VectorLength ( Delta ) ) != 0.0 )
  1324. {
  1325. VectorScale ( Delta, 1 / Len, Delta );
  1326. }
  1327.  
  1328. if ( Len > 2.0 )
  1329. {
  1330. Len -= 2.0;
  1331. }
  1332.  
  1333. if ( ( AdjustedDamage *= ( 1.0 - Len / Radius ) ) <= 0 )
  1334. {
  1335. continue;
  1336. }
  1337.  
  1338. if ( InWater || pev( Entity, pev_waterlevel ) > 2 )
  1339. {
  1340. AdjustedDamage *= 0.5;
  1341. }
  1342.  
  1343. if ( Fraction != 1.0 )
  1344. {
  1345. ExecuteHam( Ham_TraceAttack, Entity, Inflictor, AdjustedDamage, Delta, Trace, DamageBits );
  1346. ExecuteHam( Ham_TakeDamage, Entity, Inflictor, Attacker, AdjustedDamage, DamageBits );
  1347. }
  1348. else
  1349. {
  1350. ExecuteHam( Ham_TakeDamage, Entity, Inflictor, Attacker, AdjustedDamage, DamageBits );
  1351. }
  1352. }
  1353. }
  1354. }
  1355. return PLUGIN_CONTINUE
  1356. }
  1357.  
  1358.  
  1359. stock UTIL_EntitiesInBox ( List[], const ListMax, const Float:Mins[ Coord_e ], const Float:Maxs[ Coord_e ], const Flags )
  1360. {
  1361. /*
  1362. static Float:Origin [ Coord_e ];
  1363. static Float:Delta [ Coord_e ];
  1364. static Float:Mins [ Coord_e ];
  1365. static Float:Maxs [ Coord_e ];
  1366.  
  1367. pev( Snark, pev_origin, Origin );
  1368.  
  1369. Delta[ x ] = Delta[ y ] = Delta[ z ] = DistanceToSearch;
  1370.  
  1371. VectorSubtract ( Origin, Delta, Mins );
  1372. VectorAdd ( Origin, Delta, Maxs );
  1373.  
  1374. Count = UTIL_EntitiesInBox ( List, sizeof List, Mins, Maxs, Flags );
  1375. */
  1376.  
  1377. static Float:AbsMins[ Coord_e ];
  1378. static Float:AbsMaxs[ Coord_e ];
  1379. static Count;
  1380. static Entity;
  1381.  
  1382. Count = 0;
  1383.  
  1384. for ( Entity = 1; Entity <= gMaxEntities; Entity++ ) if( is_valid_ent( Entity ) )
  1385. {
  1386. if ( !( pev( Entity, pev_flags ) & Flags ) )
  1387. {
  1388. continue;
  1389. }
  1390.  
  1391. pev( Entity, pev_absmin, AbsMins );
  1392. pev( Entity, pev_absmax, AbsMaxs );
  1393.  
  1394. if ( Mins[ x ] > AbsMaxs[ x ] || Mins[ y ] > AbsMaxs[ y ] || Mins[ z ] > AbsMaxs[ z ] ||
  1395. Maxs[ x ] < AbsMins[ x ] || Maxs[ y ] < AbsMins[ y ] || Maxs[ z ] < AbsMins[ z ] )
  1396. {
  1397. continue;
  1398. }
  1399.  
  1400. List[ Count ] = Entity;
  1401.  
  1402. if ( Count++ >= ListMax )
  1403. {
  1404. return Count;
  1405. }
  1406. }
  1407.  
  1408. return Count;
  1409. }
  1410.  
  1411.  
  1412. bool:UTIL_FVisible ( const Entity, const Other )
  1413. {
  1414. static Float:LookerOrigin[ Coord_e ];
  1415. static Float:TargetOrigin[ Coord_e ];
  1416. static Float:Fraction;
  1417. static LookerWLevel;
  1418. static TargetWLevel;
  1419.  
  1420. if ( pev( Other, pev_flags ) & FL_NOTARGET )
  1421. {
  1422. return false;
  1423. }
  1424.  
  1425. LookerWLevel = pev ( Entity, pev_waterlevel );
  1426. TargetWLevel = pev ( Other, pev_waterlevel );
  1427.  
  1428. if ( ( LookerWLevel != 3 && TargetWLevel == 3 ) || ( LookerWLevel == 3 && TargetWLevel == 0 ) )
  1429. {
  1430. return false;
  1431. }
  1432.  
  1433. UTIL_EyePosition ( Entity, LookerOrigin );
  1434. UTIL_EyePosition ( Other, TargetOrigin );
  1435.  
  1436. engfunc( EngFunc_TraceLine, LookerOrigin, TargetOrigin, IGNORE_MONSTERS | IGNORE_GLASS, Entity, 0 );
  1437. get_tr2( 0, TR_flFraction, Fraction );
  1438.  
  1439. return Fraction == 1.0 ? true : false;
  1440. }
  1441.  
  1442.  
  1443. bool:UTIL_FInViewCone ( const Entity, const Other )
  1444. {
  1445. static Float:Angles [ Coord_e ];
  1446. static Float:HOrigin[ Coord_e ];
  1447. static Float:Origin [ Coord_e ];
  1448.  
  1449. pev( Entity, pev_angles, Angles );
  1450. engfunc( EngFunc_MakeVectors, Angles );
  1451. global_get( glb_v_forward, Angles );
  1452.  
  1453. Angles[ z ] = 0.0;
  1454.  
  1455. pev( Entity, pev_origin, HOrigin );
  1456. pev( Other, pev_origin, Origin );
  1457.  
  1458. VectorSubtract ( Origin, HOrigin, Origin );
  1459. Origin[ z ] = 0.0;
  1460.  
  1461. VectorNormalize ( Origin, Origin );
  1462.  
  1463. if ( DotProduct ( Origin, Angles ) > pev( Entity, pev_fov ) )
  1464. {
  1465. return true;
  1466. }
  1467.  
  1468. return false;
  1469. }
  1470.  
  1471.  
  1472. UTIL_EyePosition ( const Entity, Float:Origin[ Coord_e ] )
  1473. {
  1474. static Float:ViewOfs[ Coord_e ];
  1475.  
  1476. pev( Entity, pev_origin, Origin );
  1477. pev( Entity, pev_view_ofs, ViewOfs );
  1478.  
  1479. VectorAdd ( Origin, ViewOfs, Origin );
  1480. }
  1481.  
  1482.  
  1483. stock bool:UTIL_LiquidContents( const Float:Source[ Coord_e ] )
  1484. {
  1485. new Contents = point_contents( Source );
  1486. return ( Contents == CONTENTS_WATER || Contents == CONTENTS_SLIME || Contents == CONTENTS_LAVA );
  1487. }
  1488.  
  1489.  
  1490. VectorNormalize ( const Float:Source[ Coord_e ], Float:Output[ Coord_e ] )
  1491. {
  1492. static Float:InvLen;
  1493.  
  1494. InvLen = 1.0 / VectorLength ( Source );
  1495.  
  1496. Output[ x ] = Source[ x ] * InvLen;
  1497. Output[ y ] = Source[ y ] * InvLen;
  1498. Output[ z ] = Source[ z ] * InvLen;
  1499. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement