Guest User

Untitled

a guest
May 23rd, 2018
106
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 12.59 KB | None | 0 0
  1. #include <amxmodx>
  2. #include <cstrike>
  3. #include <engine>
  4. #include <fakemeta_util>
  5. #include <fun>
  6. #include <hamsandwich>
  7. #include <zombieplague>
  8.  
  9. #define Plugin "Jump bomb"
  10. #define Version "1.2"
  11. #define Author "Zombie-rus"
  12.  
  13. new const g_PlayerModel [ ] = "models/OV/Zombie_bombs/p_zombiebomb.mdl"
  14. new const g_WorldModel [ ] = "models/OV/Zombie_bombs/w_zombiebomb.mdl"
  15.  
  16. new const g_SoundGrenadeBuy [ ] [ ] = { "items/gunpickup2.wav" }
  17. new const g_SoundAmmoPurchase [ ] [ ] = { "items/9mmclip1.wav" }
  18.  
  19. new const g_SoundBombExplode [ ] [ ] = { "OV/Zombies/zombie_bomb_exp.wav" }
  20.  
  21. new const g_szItemName [ ] = "Jump bomb"
  22. new const g_iItemPrice = 2
  23.  
  24. #define RADIUS 200.0
  25.  
  26. #define MAXPLAYERS 32
  27. #define pev_nade_type pev_flTimeStepSound
  28. #define NADE_TYPE_JUMPING 26517
  29. #define AMMOID_SM 13
  30.  
  31. new g_iExplo
  32. new g_iNadeID
  33.  
  34. new g_iJumpingNadeCount [ MAXPLAYERS+1 ]
  35. new g_iCurrentWeapon [ MAXPLAYERS+1 ]
  36.  
  37. new cvar_speed
  38. new iconstatus
  39. new grenade_icons[33][32]
  40.  
  41. new g_msgScreenShake
  42.  
  43. new g_MaxPlayers
  44. new g_msgAmmoPickup
  45.  
  46. const UNIT_SECOND = (1<<12)
  47.  
  48. public plugin_precache()
  49. {
  50. precache_model ( g_PlayerModel )
  51. precache_model ( g_WorldModel )
  52. precache_sound("OV/Zombies/zombie_bomb_pull.wav")
  53. precache_sound("OV/Zombies/zombie_bomb_deploy.wav")
  54. precache_sound("OV/Zombies/zombie_bomb_idle1.wav")
  55. precache_sound("OV/Zombies/zombie_bomb_idle2.wav")
  56. precache_sound("OV/Zombies/zombie_bomb_idle3.wav")
  57. precache_sound("OV/Zombies/zombie_bomb_idle4.wav")
  58. precache_sound("OV/Zombies/zombie_bomb_throw.wav")
  59. precache_generic( "sprites/weapon_zombc_ov.txt" );
  60. precache_generic( "sprites/OV/640hud49.spr" );
  61. precache_generic( "sprites/OV/640hud50.spr" );
  62. precache_generic( "sprites/OV/640hud7x.spr" );
  63.  
  64. new i
  65. for ( i = 0; i < sizeof g_SoundGrenadeBuy; i++ )
  66. precache_sound ( g_SoundGrenadeBuy [ i ] )
  67. for ( i = 0; i < sizeof g_SoundAmmoPurchase; i++ )
  68. precache_sound ( g_SoundAmmoPurchase [ i ] )
  69. for ( i = 0; i < sizeof g_SoundBombExplode; i++ )
  70. precache_sound ( g_SoundBombExplode [ i ] )
  71. g_iExplo = precache_model ( "sprites/OV/jump_bomb_exp.spr" )
  72. }
  73.  
  74. new MsgIndexWeaponList;
  75.  
  76. public plugin_init()
  77. {
  78. register_plugin ( Plugin, Version, Author )
  79.  
  80. g_iNadeID = zp_register_extra_item ( g_szItemName, g_iItemPrice, ZP_TEAM_ZOMBIE )
  81.  
  82. RegisterHam( Ham_Item_AddToPlayer, "weapon_smokegrenade", "OnAddToPlayerSmokeGrenade", .Post = true );
  83.  
  84. MsgIndexWeaponList = get_user_msgid( "WeaponList" );
  85.  
  86. register_event ( "CurWeapon", "EV_CurWeapon", "be", "1=1" )
  87. register_event ( "HLTV", "EV_NewRound", "a", "1=0", "2=0" )
  88. register_event ( "DeathMsg", "EV_DeathMsg", "a" )
  89.  
  90. register_forward ( FM_SetModel, "fw_SetModel" )
  91. RegisterHam(Ham_Think, "grenade", "fw_ThinkGrenade")
  92. RegisterHam(Ham_Spawn, "player", "fw_PlayerSpawn_Post", 1)
  93. g_msgScreenShake = get_user_msgid("ScreenShake")
  94.  
  95. register_clcmd("weapon_zombc_ov", "zombiebomb_ch")
  96.  
  97. cvar_speed = register_cvar ( "zp_zombiebomb_knockback", "900" )
  98.  
  99. g_msgAmmoPickup = get_user_msgid ( "AmmoPickup" )
  100.  
  101. g_MaxPlayers = get_maxplayers ( )
  102. register_event("CurWeapon", "grenade_icon", "be", "1=1")
  103. register_event("DeathMsg", "event_death", "a")
  104. iconstatus = get_user_msgid("StatusIcon")
  105. }
  106.  
  107. public ClientCommand_SelectFlare( const client )
  108. {
  109. engclient_cmd( client, "weapon_smokegrenade" );
  110. }
  111.  
  112. public client_connect(id)
  113. {
  114. g_iJumpingNadeCount[id] = 0
  115. }
  116.  
  117. public OnAddToPlayerSmokeGrenade( const item, const player )
  118. {
  119. if( pev_valid( item ) && is_user_alive( player ) ) // just for safety.
  120. {
  121. message_begin( MSG_ONE, MsgIndexWeaponList, .player = player );
  122. {
  123. write_string(g_iJumpingNadeCount[player] > 0 ? "weapon_zombc_ov" : "weapon_smokegrenade"); // WeaponName
  124. write_byte( 13 ); // PrimaryAmmoID
  125. write_byte( 1 ); // PrimaryAmmoMaxAmount
  126. write_byte( -1 ); // SecondaryAmmoID
  127. write_byte( -1 ); // SecondaryAmmoMaxAmount
  128. write_byte( 3 ); // SlotID (0...N)
  129. write_byte( 3 ); // NumberInSlot (1...N)
  130. write_byte( 9 ); // WeaponID
  131. write_byte( 24 ); // Flags
  132. }
  133. message_end();
  134. }
  135. }
  136. public zombiebomb_ch(id) client_cmd(id, "weapon_smokegrenade")
  137.  
  138. public zp_extra_item_selected (id, Item)
  139. {
  140. if(Item == g_iNadeID)
  141. {
  142. new iBpAmmo = cs_get_user_bpammo(id, CSW_SMOKEGRENADE)
  143.  
  144. if(g_iJumpingNadeCount[id] >= 1)
  145. {
  146. cs_set_user_bpammo (id, CSW_SMOKEGRENADE, iBpAmmo+1)
  147. emit_sound (id, CHAN_ITEM, g_SoundAmmoPurchase[random_num(0, sizeof g_SoundAmmoPurchase-1)], VOL_NORM, ATTN_NORM, 0, PITCH_NORM)
  148. AmmoPickup(id, AMMOID_SM, 1)
  149. g_iJumpingNadeCount[id] ++
  150. }
  151. else
  152. {
  153. give_item(id, "weapon_smokegrenade")
  154. emit_sound(id, CHAN_ITEM, g_SoundGrenadeBuy[random_num(0, sizeof g_SoundGrenadeBuy-1)], VOL_NORM, ATTN_NORM, 0, PITCH_NORM)
  155. AmmoPickup(id, AMMOID_SM, 1)
  156. g_iJumpingNadeCount [ id ] = 1
  157. }
  158. }
  159.  
  160. return PLUGIN_CONTINUE
  161. }
  162.  
  163. public zp_user_infected_post (id, Infector)
  164. {
  165. if(zp_get_user_zombie(id) && !zp_get_user_nemesis(id))
  166. {
  167. g_iJumpingNadeCount [id] = 0
  168. give_item ( id, "weapon_smokegrenade" )
  169. cs_set_user_bpammo(id, CSW_SMOKEGRENADE, 1)
  170. emit_sound ( id, CHAN_ITEM, g_SoundGrenadeBuy[random_num(0, sizeof g_SoundGrenadeBuy-1)], VOL_NORM, ATTN_NORM, 0, PITCH_NORM )
  171. AmmoPickup ( id, AMMOID_SM, 1 )
  172. g_iJumpingNadeCount [ id ] = 1
  173. }
  174. }
  175.  
  176. public zp_user_humanized_post(id, Survivor)
  177. {
  178. if (Survivor)
  179. {
  180. g_iJumpingNadeCount[Survivor] = 0
  181. }
  182. }
  183.  
  184. public EV_CurWeapon(id)
  185. {
  186.  
  187. if ( !is_user_alive(id) || !zp_get_user_zombie(id) || zp_get_user_nemesis(id))
  188. return PLUGIN_CONTINUE
  189.  
  190. g_iCurrentWeapon[id] = read_data(2)
  191. if (g_iJumpingNadeCount[id] > 0 && g_iCurrentWeapon[id] == CSW_SMOKEGRENADE)
  192. {
  193. set_pev(id, pev_weaponmodel2, g_PlayerModel)
  194. }
  195.  
  196. return PLUGIN_CONTINUE
  197. }
  198.  
  199. public EV_NewRound()
  200. {
  201. arrayset(g_iJumpingNadeCount, 0, 33)
  202. }
  203.  
  204. public EV_DeathMsg()
  205. {
  206. new iVictim = read_data(2)
  207.  
  208. if ( !is_user_connected(iVictim))
  209. return
  210.  
  211. g_iJumpingNadeCount[iVictim] = 0
  212. }
  213.  
  214. public fw_SetModel(Entity, const Model[])
  215. {
  216. if(Entity < 0)
  217. return FMRES_IGNORED
  218.  
  219. if(pev (Entity, pev_dmgtime) == 0.0)
  220. return FMRES_IGNORED
  221.  
  222. new iOwner = entity_get_edict(Entity, EV_ENT_owner)
  223.  
  224. if(g_iJumpingNadeCount[iOwner] >= 1 && equal(Model[7], "w_sm", 4))
  225. {
  226. set_pev(Entity, pev_nade_type, 0)
  227. set_pev(Entity, pev_nade_type, NADE_TYPE_JUMPING)
  228. g_iJumpingNadeCount[iOwner]--
  229. entity_set_model(Entity, g_WorldModel)
  230. fm_set_rendering(Entity, kRenderFxGlowShell, 255, 210, 0, kRenderNormal, 16)
  231.  
  232. return FMRES_SUPERCEDE
  233. }
  234. return FMRES_IGNORED
  235. }
  236.  
  237. public fw_ThinkGrenade ( Entity )
  238. {
  239. if ( !pev_valid ( Entity ) )
  240. return HAM_IGNORED
  241.  
  242. static Float:dmg_time
  243. pev ( Entity, pev_dmgtime, dmg_time )
  244.  
  245. if ( dmg_time > get_gametime ( ) )
  246. return HAM_IGNORED
  247.  
  248. if ( pev ( Entity, pev_nade_type ) == NADE_TYPE_JUMPING )
  249. {
  250. jumping_explode ( Entity )
  251. return HAM_SUPERCEDE
  252. }
  253. return HAM_IGNORED
  254. }
  255.  
  256. public fw_PlayerSpawn_Post(id)
  257. {
  258. if(!zp_get_user_zombie(id))
  259. {
  260. if(user_has_weapon(id, CSW_SMOKEGRENADE))
  261. {
  262. ham_strip_weapon(id, "weapon_smokegrenade")
  263. return HAM_SUPERCEDE
  264. }
  265. }
  266. return HAM_IGNORED
  267. }
  268.  
  269. public jumping_explode(Entity)
  270. {
  271. if(Entity < 0)
  272. return
  273.  
  274. static Float:flOrigin[3]
  275. pev(Entity, pev_origin, flOrigin)
  276.  
  277. engfunc(EngFunc_MessageBegin, MSG_PVS, SVC_TEMPENTITY, flOrigin, 0)
  278. write_byte(TE_SPRITE)
  279. engfunc(EngFunc_WriteCoord, flOrigin[0])
  280. engfunc(EngFunc_WriteCoord, flOrigin[1])
  281. engfunc(EngFunc_WriteCoord, flOrigin[2] + 45.0)
  282. write_short(g_iExplo)
  283. write_byte(35)
  284. write_byte(186)
  285. message_end()
  286.  
  287. //new iOwner = entity_get_edict(Entity, EV_ENT_owner)
  288.  
  289. emit_sound(Entity, CHAN_WEAPON, g_SoundBombExplode[random_num(0, sizeof g_SoundBombExplode-1)], VOL_NORM, ATTN_NORM, 0, PITCH_NORM)
  290.  
  291. for(new i = 1; i < g_MaxPlayers; i++)
  292. {
  293. if(!is_user_alive(i))
  294. continue
  295.  
  296. new Float:flVictimOrigin[3]
  297. pev(i, pev_origin, flVictimOrigin)
  298.  
  299. new Float:flDistance = get_distance_f (flOrigin, flVictimOrigin)
  300.  
  301. if (flDistance <= RADIUS)
  302. {
  303. static Float:flSpeed
  304. flSpeed = get_pcvar_float(cvar_speed)
  305.  
  306. static Float:flNewSpeed
  307. flNewSpeed = flSpeed * (1.0 - (flDistance / RADIUS))
  308.  
  309. static Float:flVelocity [3]
  310. get_speed_vector(flOrigin, flVictimOrigin, flNewSpeed, flVelocity)
  311.  
  312. set_pev(i, pev_velocity,flVelocity)
  313.  
  314. message_begin(MSG_ONE_UNRELIABLE, g_msgScreenShake, _, i)
  315. write_short(UNIT_SECOND*4) // amplitude
  316. write_short(UNIT_SECOND*10) // duration
  317. write_short(UNIT_SECOND*10) // frequency
  318. message_end()
  319.  
  320. fm_fakedamage(i, "knockback-bomb", 0.0, DMG_BLAST);
  321. }
  322. }
  323.  
  324. engfunc ( EngFunc_RemoveEntity, Entity )
  325. }
  326.  
  327. public AmmoPickup(id, AmmoID, AmmoAmount)
  328. {
  329. message_begin(MSG_ONE, g_msgAmmoPickup, _, id)
  330. write_byte(AmmoID)
  331. write_byte(AmmoAmount)
  332. message_end()
  333. }
  334.  
  335. stock get_speed_vector(const Float:origin1[3],const Float:origin2[3],Float:speed, Float:new_velocity[3])
  336. {
  337. new_velocity[0] = origin2[0] - origin1[0]
  338. new_velocity[1] = origin2[1] - origin1[1]
  339. new_velocity[2] = origin2[2] - origin1[2]
  340. new Float:num = floatsqroot(speed*speed / (new_velocity[0]*new_velocity[0] + new_velocity[1]*new_velocity[1] + new_velocity[2]*new_velocity[2]))
  341. new_velocity[0] *= num
  342. new_velocity[1] *= num
  343. new_velocity[2] *= num
  344.  
  345. return 1;
  346. }
  347.  
  348. public grenade_icon(id)
  349. {
  350. remove_grenade_icon(id)
  351.  
  352. if(is_user_bot(id))
  353. return
  354.  
  355. static igrenade, grenade_sprite[16], grenade_color[3]
  356. igrenade = get_user_weapon(id)
  357.  
  358. switch(igrenade)
  359. {
  360. case CSW_SMOKEGRENADE:
  361. {
  362.  
  363. if(!is_user_alive(id) || zp_get_user_zombie(id)) {
  364. grenade_sprite = "dmg_gas"
  365. grenade_color = {255, 185, 0}
  366. }
  367. else
  368. {
  369. grenade_sprite = ""
  370. grenade_color = {0, 0, 0}
  371. }
  372. }
  373.  
  374. default:
  375. return
  376. }
  377. grenade_icons[id] = grenade_sprite
  378.  
  379. message_begin(MSG_ONE,iconstatus,{0,0,0},id)
  380. write_byte(1) // status (0=hide, 1=show, 2=flash)
  381. write_string(grenade_icons[id]) // sprite name
  382. write_byte(grenade_color[0]) // red
  383. write_byte(grenade_color[1]) // green
  384. write_byte(grenade_color[2]) // blue
  385. message_end()
  386.  
  387. return
  388. }
  389.  
  390. public remove_grenade_icon(id)
  391. {
  392. message_begin(MSG_ONE,iconstatus,{0,0,0},id)
  393. write_byte(0) // status (0=hide, 1=show, 2=flash)
  394. write_string(grenade_icons[id]) // sprite name
  395. message_end()
  396. }
  397.  
  398. public event_death()
  399. {
  400. new id = read_data(2)
  401.  
  402. if(!is_user_bot(id))
  403. remove_grenade_icon(id)
  404. }
  405.  
  406. stock ham_strip_weapon(id, weapon[]) // strip weapon (tERoR)
  407. {
  408. if(!equal(weapon, "weapon_", 7)) return 0
  409.  
  410. new wId = get_weaponid(weapon)
  411. if(!wId) return 0
  412.  
  413. new wEnt
  414. while((wEnt = engfunc(EngFunc_FindEntityByString,wEnt,"classname",weapon)) && pev(wEnt,pev_owner) != id) {}
  415. if(!wEnt) return 0
  416.  
  417. if(get_user_weapon(id) == wId) ExecuteHamB(Ham_Weapon_RetireWeapon,wEnt)
  418.  
  419. if(!ExecuteHamB(Ham_RemovePlayerItem,id,wEnt)) return 0;
  420. ExecuteHamB(Ham_Item_Kill,wEnt)
  421.  
  422. set_pev(id, pev_weapons, pev(id, pev_weapons) & ~(1<<wId))
  423.  
  424. if(wId == CSW_C4)
  425. {
  426. cs_set_user_plant(id, 0, 0)
  427. cs_set_user_bpammo(id, CSW_C4, 0)
  428. }
  429. else if(wId == CSW_SMOKEGRENADE || wId == CSW_FLASHBANG || wId == CSW_HEGRENADE)
  430. cs_set_user_bpammo(id,wId,0)
  431.  
  432. return 1
  433. }
Add Comment
Please, Sign In to add comment