1.
2.
3.
4.
5.
6.
7.
8.
9.
10.
11.
12.
13.
14.
15.
16.
17.
18.
19.
20.
21.
22.
23.
24.
25.
26.
27.
28.
29.
30.
31.
32.
33.
34.
35.
36.
37.
38.
39.
40.
41.
42.
43.
44.
45.
46.
47.
48.
49.
50.
51.
52.
53.
54.
55.
56.
57.
58.
59.
60.
61.
62.
63.
64.
65.
66.
67.
68.
69.
70.
71.
72.
73.
74.
75.
76.
77.
78.
79.
80.
81.
82.
83.
84.
85.
86.
87.
88.
89.
90.
91.
92.
93.
94.
95.
96.
97.
98.
99.
100.
101.
102.
103.
104.
105.
106.
107.
108.
109.
110.
111.
112.
113.
114.
115.
116.
117.
118.
119.
120.
121.
122.
123.
124.
125.
126.
127.
128.
129.
130.
131.
132.
133.
134.
135.
136.
137.
138.
139.
140.
141.
142.
143.
144.
145.
146.
147.
148.
149.
150.
151.
152.
153.
154.
155.
156.
157.
158.
159.
160.
161.
162.
163.
164.
165.
166.
167.
168.
169.
170.
171.
172.
173.
174.
175.
176.
177.
178.
179.
180.
181.
182.
183.
184.
185.
186.
187.
188.
189.
190.
191.
192.
193.
194.
195.
196.
197.
198.
199.
200.
201.
202.
203.
204.
205.
206.
207.
208.
209.
210.
211.
212.
213.
214.
215.
216.
217.
218.
219.
220.
221.
222.
223.
224.
225.
226.
227.
228.
229.
230.
231.
232.
233.
234.
235.
236.
237.
238.
239.
240.
241.
242.
243.
244.
245.
246.
247.
248.
249.
250.
251.
252.
253.
254.
255.
256.
257.
258.
259.
260.
261.
262.
263.
264.
265.
266.
267.
268.
269.
270.
271.
272.
273.
274.
275.
276.
277.
278.
279.
280.
281.
282.
283.
284.
285.
286.
287.
288.
289.
290.
291.
292.
293.
294.
295.
296.
297.
298.
299.
300.
301.
302.
303.
304. | #include < amxmodx >
#include < cstrike >
#include < engine >
#include < fakemeta >
#include < fun >
#include < hamsandwich >
#include < zombieplague >
#define Plugin "[ZP] Knockback Bomba"
#define Version "1.0"
#define Author "NiHiLaNTh/amx-x.ru"
// === Customization starts below! ===
new const g_PlayerModel [ ] = "models/zombie_plague/p_zombibomb.mdl"
new const g_ViewModel [ ] = "models/zombie_plague/v_zombibomb.mdl"
new const g_WorldModel [ ] = "models/zombie_plague/w_zombibomb.mdl"
// You can add more than 1 sound!
new const g_SoundGrenadeBuy [ ] [ ] = { "nst_zombie/Zombi_Bomb_Deploy.wav" }
new const g_SoundAmmoPurchase [ ] [ ] = { "nst_zombie/Zombi_Bomb_Pull_1.wav" }
new const g_SoundBombExplode [ ] [ ] = { "nst_zombie/Zombi_Bomb_Throw.wav" }
new const frogbomb_sound [ ] = { "nst_zombie/Zombi_Bomb_Pull_1.wav", "zombie_plague/Zombi_Bomb_Deploy.wav", "zombie_plague/Zombi_Bomb_Idle_1.wav", "zombie_plague/Zombi_Bomb_Idle_2.wav" }
new const frogbomb_sound2 [ ] = { "nst_zombie/Zombi_Bomb_Deploy.wav", "zombie_plague/Zombi_Bomb_Idle_3.wav", "zombie_plague/Zombi_Bomb_Idle_4.wav" }
new const g_szItemName [ ] = "Skoczek" // Name
new const g_iItemPrice = 2 // Price
#define MAXCARRY 5 // How many grenades 1 player can hold at the same time
#define RADIUS 300.0 // Affect radius
// === Customization ends above! ===
#define MAXPLAYERS 32
#define pev_nade_type pev_flTimeStepSound
#define NADE_TYPE_JUMPING 26517
#define AMMOID_SM 13
new g_iExplo
new g_iNadeID
new g_iJumpingNadeCount [ MAXPLAYERS+1 ]
new g_iCurrentWeapon [ MAXPLAYERS+1 ]
new cvar_speed
new g_MaxPlayers
new g_msgAmmoPickup
public plugin_precache ( )
{
precache_model ( g_PlayerModel )
precache_model ( g_ViewModel )
precache_model ( g_WorldModel )
precache_sound ( frogbomb_sound )
precache_sound ( frogbomb_sound2 )
new i
for ( i = 0; i < sizeof g_SoundGrenadeBuy; i++ )
precache_sound ( g_SoundGrenadeBuy [ i ] )
for ( i = 0; i < sizeof g_SoundAmmoPurchase; i++ )
precache_sound ( g_SoundAmmoPurchase [ i ] )
for ( i = 0; i < sizeof g_SoundBombExplode; i++ )
precache_sound ( g_SoundBombExplode [ i ] )
g_iExplo = precache_model ( "sprites/zombiebomb_exp.spr" )
}
public plugin_init ( )
{
register_plugin ( Plugin, Version, Author )
g_iNadeID = zp_register_extra_item ( g_szItemName, g_iItemPrice, ZP_TEAM_ZOMBIE )
register_event ( "CurWeapon", "EV_CurWeapon", "be", "1=1" )
register_event ( "HLTV", "EV_NewRound", "a", "1=0", "2=0" )
register_event ( "DeathMsg", "EV_DeathMsg", "a" )
register_forward ( FM_SetModel, "fw_SetModel" )
RegisterHam ( Ham_Think, "grenade", "fw_ThinkGrenade" )
cvar_speed = register_cvar ( "zp_zombiebomb_knockback", "800" )
g_msgAmmoPickup = get_user_msgid ( "AmmoPickup" )
g_MaxPlayers = get_maxplayers ( )
}
public client_connect ( id )
{
g_iJumpingNadeCount [ id ] = 0
}
public zp_extra_item_selected ( id, Item )
{
if ( Item == g_iNadeID )
{
if ( g_iJumpingNadeCount [ id ] >= MAXCARRY )
{
client_print ( id, print_chat, "[ZP] Cannot hold mode grenades!" )
return ZP_PLUGIN_HANDLED
}
new iBpAmmo = cs_get_user_bpammo ( id, CSW_SMOKEGRENADE )
if ( g_iJumpingNadeCount [ id ] >= 1 )
{
cs_set_user_bpammo ( id, CSW_SMOKEGRENADE, iBpAmmo+1 )
emit_sound ( id, CHAN_ITEM, g_SoundAmmoPurchase[random_num(0, sizeof g_SoundAmmoPurchase-1)], VOL_NORM, ATTN_NORM, 0, PITCH_NORM )
AmmoPickup ( id, AMMOID_SM, 1 )
g_iJumpingNadeCount [ id ]++
}
else
{
give_item ( id, "weapon_smokegrenade" )
emit_sound ( id, CHAN_ITEM, g_SoundGrenadeBuy[random_num(0, sizeof g_SoundGrenadeBuy-1)], VOL_NORM, ATTN_NORM, 0, PITCH_NORM )
AmmoPickup ( id, AMMOID_SM, 1 )
g_iJumpingNadeCount [ id ] = 1
}
}
return PLUGIN_CONTINUE
}
public zp_user_infected_post ( id, Infector, Nemesis )
{
g_iJumpingNadeCount [ id ] = 0
give_item ( id, "weapon_smokegrenade" )
emit_sound ( id, CHAN_ITEM, g_SoundGrenadeBuy[random_num(0, sizeof g_SoundGrenadeBuy-1)], VOL_NORM, ATTN_NORM, 0, PITCH_NORM )
AmmoPickup ( id, AMMOID_SM, 1 )
g_iJumpingNadeCount [ id ] = 1
}
public zp_user_humanized_post ( id, Survivor )
{
if ( Survivor )
{
g_iJumpingNadeCount [ Survivor ] = 0
}
}
public EV_CurWeapon ( id )
{
if ( !is_user_alive ( id ) || !zp_get_user_zombie ( id ) )
return PLUGIN_CONTINUE
g_iCurrentWeapon [ id ] = read_data ( 2 )
if ( g_iJumpingNadeCount [ id ] > 0 && g_iCurrentWeapon [ id ] == CSW_SMOKEGRENADE )
{
set_pev ( id, pev_viewmodel2, g_ViewModel )
set_pev ( id, pev_weaponmodel2, g_WorldModel )
}
return PLUGIN_CONTINUE
}
public EV_NewRound ( )
{
arrayset ( g_iJumpingNadeCount, 0, 33 )
}
public EV_DeathMsg ( )
{
new iVictim = read_data ( 2 )
if ( !is_user_connected ( iVictim ) )
return
g_iJumpingNadeCount [ iVictim ] = 0
}
public fw_SetModel ( Entity, const Model [ ] )
{
if ( Entity < 0 )
return FMRES_IGNORED
if ( pev ( Entity, pev_dmgtime ) == 0.0 )
return FMRES_IGNORED
new iOwner = entity_get_edict ( Entity, EV_ENT_owner )
if ( g_iJumpingNadeCount [ iOwner ] >= 1 && equal ( Model [ 7 ], "w_sm", 4 ) )
{
// Reset any other nade
set_pev ( Entity, pev_nade_type, 0 )
set_pev ( Entity, pev_nade_type, NADE_TYPE_JUMPING )
g_iJumpingNadeCount [ iOwner ]--
entity_set_model ( Entity, g_WorldModel )
return FMRES_SUPERCEDE
}
return FMRES_IGNORED
}
public fw_ThinkGrenade ( Entity )
{
if ( !pev_valid ( Entity ) )
return HAM_IGNORED
static Float:dmg_time
pev ( Entity, pev_dmgtime, dmg_time )
if ( dmg_time > get_gametime ( ) )
return HAM_IGNORED
if ( pev ( Entity, pev_nade_type ) == NADE_TYPE_JUMPING )
{
jumping_explode ( Entity )
return HAM_SUPERCEDE
}
return HAM_IGNORED
}
public jumping_explode ( Entity )
{
if ( Entity < 0 )
return
static Float:flOrigin [ 3 ]
pev ( Entity, pev_origin, flOrigin )
engfunc ( EngFunc_MessageBegin, MSG_PVS, SVC_TEMPENTITY, flOrigin, 0 )
write_byte ( TE_SPRITE )
engfunc ( EngFunc_WriteCoord, flOrigin [ 0 ] )
engfunc ( EngFunc_WriteCoord, flOrigin [ 1 ] )
engfunc ( EngFunc_WriteCoord, flOrigin [ 2 ] + 45.0 )
write_short ( g_iExplo )
write_byte ( 35 )
write_byte ( 186 )
message_end ( )
new iOwner = entity_get_edict ( Entity, EV_ENT_owner )
emit_sound ( Entity, CHAN_WEAPON, g_SoundBombExplode[random_num(0, sizeof g_SoundBombExplode-1)], VOL_NORM, ATTN_NORM, 0, PITCH_NORM )
for ( new i = 1; i < g_MaxPlayers; i++ )
{
if ( !is_user_alive ( i ) )
continue
new Float:flVictimOrigin [ 3 ]
pev ( i, pev_origin, flVictimOrigin )
new Float:flDistance = get_distance_f ( flOrigin, flVictimOrigin )
if ( flDistance <= RADIUS )
{
static Float:flSpeed
flSpeed = get_pcvar_float ( cvar_speed )
static Float:flNewSpeed
flNewSpeed = flSpeed * ( 1.0 - ( flDistance / RADIUS ) )
static Float:flVelocity [ 3 ]
get_speed_vector ( flOrigin, flVictimOrigin, flNewSpeed, flVelocity )
set_pev ( i, pev_velocity,flVelocity )
}
}
engfunc ( EngFunc_RemoveEntity, Entity )
}
public AmmoPickup ( id, AmmoID, AmmoAmount )
{
message_begin ( MSG_ONE, g_msgAmmoPickup, _, id )
write_byte ( AmmoID )
write_byte ( AmmoAmount )
message_end ( )
}
stock get_speed_vector(const Float:origin1[3],const Float:origin2[3],Float:speed, Float:new_velocity[3])
{
new_velocity[0] = origin2[0] - origin1[0]
new_velocity[1] = origin2[1] - origin1[1]
new_velocity[2] = origin2[2] - origin1[2]
new Float:num = floatsqroot(speed*speed / (new_velocity[0]*new_velocity[0] + new_velocity[1]*new_velocity[1] + new_velocity[2]*new_velocity[2]))
new_velocity[0] *= num
new_velocity[1] *= num
new_velocity[2] *= num
return 1;
}
/* AMXX-Studio Notes - DO NOT MODIFY BELOW HERE
*{\\ rtf1\\ ansi\\ deff0{\\ fonttbl{\\ f0\\ fnil Tahoma;}}\n\\ viewkind4\\ uc1\\ pard\\ lang1051\\ f0\\ fs16 \n\\ par }
*/ |