Code: Select all
#include <zombie_escape>
#include <fakemeta_util>
new g_has_grenade[33],g_item_id,
g_trail,g_ring,
g_gibss,g_traser
#define NADE_ENTIY "weapon_flashbang"
#define NADE_NAME "\r|\wGrom\r|"
#define NADE_COST 0
#define NADE_CSW CSW_FLASHBANG
#define NADE_TYPE_GROM 382878
#define NADE_EXPLODE_DAMAGE 400.0
#define NADE_RADIUS_HOOK 700.0
#define NADE_RADIUS_EXPLODE 300.0
#define NADE_SPEED 130.0
#define NADE_DURATION 8
#define PLUGIN "Grom grenade"
#define VERSION "1.0"
#define AUTHOR "PaXaN-ZOMBIE"
new const models[][] = {
"models/csozz/v_zombibomb.mdl",
"models/csozz/p_bomb.mdl",
"models/csozz/w_zombibomb.mdl"
}
new const hud_spr[][] = {
"sprites/csozz/ionbeam.spr",
"sprites/csozz/lasthope_bflare.spr",
"sprites/shockwave.spr",
"sprites/laserbeam.spr",
"sprites/csozz/640hud65.spr",
"sprites/csozz/640hud64.spr",
"sprites/csozz/640hud7x.spr"
}
new const sound[][] = {
"city/other/beacon_attack.wav",
"city/other/beacon_beep.wav"
}
enum
{
TRASER_STARTFRAME = 0,
TRASER_FRAMERATE = 0,
TRASER_LIFE = 40,
TRASER_WEIGTH = 180,
TRASER_NOISE = 0,
TRASER_COLOR_RED = 255,
TRASER_COLOR_GREEN = 255,
TRASER_COLOR_BLUE = 255,
TRASER_BRIGHTNESS = 255,
TRASER_SPEED = 0,
GIBS_COUNT = 100,
GIBS_LIFE = 90,
GIBS_SCALE = 6,
GIBS_VELOSITY = 50,
GIBS_RENDOM_OF_VELOSITY = 40,
RENDERING_RED = 255,
RENDERING_GREEN = 20,
RENDERING_BLUE = 147,
TRAIL_LIFE = 10,
TRAIL_WEIGTH = 10,
TRAIL_RED = 255,
TRAIL_GREEN = 20,
TRAIL_BLUE = 147,
TRAIL_BRIGHTNESS = 255
}
new const wpnlist_txt_name[] = "weapon_zombth_paxan"
public plugin_init() {
register_plugin(PLUGIN, VERSION, AUTHOR)
RegisterHam(Ham_Think, "grenade", "HAM_Think", false)
RegisterHam(Ham_Spawn, "player", "HAM_Spawn", false)
RegisterHam(Ham_Item_Deploy, NADE_ENTIY, "HAM_Deploy", true)
register_forward(FM_SetModel, "FM_Set_Model", false)
g_item_id = ze_register_item("Grome Grenade", 80, 0)
}
public plugin_precache() {
new sFile[64];formatex(sFile, charsmax(sFile), "sprites/%s.txt", wpnlist_txt_name)
precache_generic(sFile)
for(new i;i<=charsmax(models);i++)precache_model(models[i])
for(new i;i<=charsmax(sound);i++)precache_sound(sound[i])
for(new i;i<=charsmax(hud_spr);i++) precache_generic(hud_spr[i])
g_trail = precache_model(hud_spr[3])
g_ring = precache_model(hud_spr[2])
g_gibss = precache_model(hud_spr[1])
g_traser = precache_model(hud_spr[0])
register_clcmd(wpnlist_txt_name, "Weapon_Hook_Select")
}
public ze_select_item_pre(id, itemid)
{
// Return Available and we will block it in Post, So it dosen't affect other plugins
if (itemid != g_item_id)
return ZE_ITEM_AVAILABLE
// Available for Zombies only, So don't show it for Humans
if (!ze_is_user_zombie(id))
return ZE_ITEM_DONT_SHOW
return ZE_ITEM_AVAILABLE
}
public ze_select_item_post(id, itemid){
if(itemid == g_item_id){
if(g_has_grenade[id] >= 1){
return PLUGIN_HANDLED;
}
g_has_grenade[id] = true
fm_give_item(id, NADE_ENTIY)
SET_WPNLIST(id, wpnlist_txt_name, 11, 2, -1, -1, 3,2, 25, 24)
}
return PLUGIN_HANDLED;
}
public HAM_Deploy(ent){
if(!pev_valid(ent))return;
new id = get_pdata_cbase(ent, 41, 4)
if(is_user_alive(id))return
if(g_has_grenade[id]){
set_pev(id, pev_viewmodel2, models[0])
set_pev(id, pev_weaponmodel2, models[1])
}
}
public HAM_Think(entity) {
if(!pev_valid(entity))return HAM_IGNORED;
static Float:flDmgTime, Float:flTime;
pev(entity, pev_dmgtime, flDmgTime);
flTime = get_gametime();
if( flDmgTime > flTime){
return HAM_IGNORED;
}
if(pev(entity, pev_flTimeStepSound) == NADE_TYPE_GROM){
static duration;duration = pev(entity, pev_flSwimTime);
if (duration > 0){
new Float:originF[3]
pev(entity, pev_origin, originF);
if (duration == 1){
remove_task(entity)
EFFECKT_EXPLODE(originF, entity)
engfunc(EngFunc_RemoveEntity, entity);
return HAM_SUPERCEDE;
}
EFFECKT(originF, duration);
set_task(0.1, "HUMAN_HOOK", entity, _, _, "b");
if(duration == 2)
set_task(0.1, "BEEP_SOUNDS", entity, _, _, "b");
else emit_sound(entity, CHAN_WEAPON, sound[1], 1.0, ATTN_NORM, 0, PITCH_HIGH);
set_pev(entity, pev_flSwimTime, --duration);
set_pev(entity, pev_dmgtime, flTime + 3.0);
} else if ((pev(entity, pev_flags) & FL_ONGROUND) && fm_get_speed(entity) < 10){
set_pev(entity, pev_flSwimTime, 1 + NADE_DURATION)/3
set_pev(entity, pev_dmgtime, flTime + 0.1)
} else set_pev(entity, pev_dmgtime, flTime + 0.5)
}
return HAM_IGNORED;
}
public FM_Set_Model(Entity, const Model[]) {
static owner
owner = pev(Entity, pev_owner)
if(!pev_valid(Entity))return FMRES_IGNORED
if (g_has_grenade [ owner ] >= 1 && equal ( Model [ 7 ], "w_fl", 4 ) ){
g_has_grenade[owner]--
fm_entity_set_model(Entity, models[2])
fm_set_rendering(Entity, kRenderFxGlowShell, RENDERING_RED, RENDERING_GREEN, RENDERING_BLUE, kRenderNormal, 16)
message_begin(MSG_BROADCAST, SVC_TEMPENTITY)
write_byte(TE_BEAMFOLLOW)
write_short(Entity)
write_short(g_trail)
write_byte(TRAIL_LIFE)
write_byte(TRAIL_WEIGTH)
write_byte(TRAIL_RED)
write_byte(TRAIL_GREEN)
write_byte(TRAIL_BLUE)
write_byte(TRAIL_BRIGHTNESS)
message_end()
set_pev(Entity, pev_flTimeStepSound, NADE_TYPE_GROM)
return FMRES_SUPERCEDE
}
return FMRES_IGNORED
}
public BEEP_SOUNDS(entity) {
if (!pev_valid(entity)){
remove_task(entity);
return;
}
emit_sound(entity, CHAN_WEAPON, sound[1], 1.0, ATTN_NORM, 0, PITCH_HIGH);
}
public HUMAN_HOOK(entity){
if (!pev_valid(entity)){
remove_task(entity);
return;
}
static Float:originF[3], Float:radius, victim = -1;
radius = NADE_RADIUS_HOOK
pev(entity, pev_origin, originF);
while ((victim = engfunc(EngFunc_FindEntityInSphere, victim, originF, radius)) != 0){
if (!is_user_alive(victim) || ze_is_user_zombie(victim))continue;
new Float:fl_Velocity[3];
new vicOrigin[3], originN[3];
get_user_origin(victim, vicOrigin);
originN[0] = floatround(originF[0]);
originN[1] = floatround(originF[1]);
originN[2] = floatround(originF[2]);
new distance = get_distance(originN, vicOrigin);
if (distance > 1){
new Float:fl_Time = distance / NADE_SPEED
fl_Velocity[0] = (originN[0] - vicOrigin[0]) / fl_Time;
fl_Velocity[1] = (originN[1] - vicOrigin[1]) / fl_Time;
fl_Velocity[2] = (originN[2] - vicOrigin[2]) / fl_Time;
}else{
fl_Velocity[0] = 0.0
fl_Velocity[1] = 0.0
fl_Velocity[2] = 0.0
}
fm_set_user_velocity(victim, fl_Velocity)
message_begin(MSG_ONE_UNRELIABLE, get_user_msgid("ScreenShake"), _, victim)
write_short(1<<14) // amplitude
write_short(1<<14) // duration
write_short(1<<14) // frequency
message_end()
}
}
public EFFECKT(const Float:originF[3], duration) {
engfunc(EngFunc_MessageBegin, MSG_PAS, SVC_TEMPENTITY, originF, 0);
write_byte(TE_DLIGHT);
engfunc(EngFunc_WriteCoord, originF[0]);
engfunc(EngFunc_WriteCoord, originF[1]);
engfunc(EngFunc_WriteCoord, originF[2]);
write_byte(5);
write_byte(255);
write_byte(20);
write_byte(147);
write_byte(51);
write_byte((duration < 2) ? 3 : 0);
message_end();
create_blast_effect(originF, 255, 20, 147, 200, 350.0);
create_blast_effect(originF, 255, 100, 147, 200, 450.0);
create_blast_effect(originF, 255, 220, 147, 200, 550.0);
}
public EFFECKT_EXPLODE(const Float:originF[3], ent) {
engfunc(EngFunc_MessageBegin, MSG_PVS, SVC_TEMPENTITY, originF, 0)
write_byte(TE_BEAMPOINTS)
engfunc(EngFunc_WriteCoord, originF[0])
engfunc(EngFunc_WriteCoord, originF[1])
engfunc(EngFunc_WriteCoord, originF[2])
engfunc(EngFunc_WriteCoord, originF[0])
engfunc(EngFunc_WriteCoord, originF[1])
engfunc(EngFunc_WriteCoord, originF[2] + 900)
write_short(g_traser)
write_byte(TRASER_STARTFRAME)
write_byte(TRASER_FRAMERATE)
write_byte(TRASER_LIFE)
write_byte(TRASER_WEIGTH)
write_byte(TRASER_NOISE)
write_byte(TRASER_COLOR_RED)
write_byte(TRASER_COLOR_GREEN)
write_byte(TRASER_COLOR_BLUE)
write_byte(TRASER_BRIGHTNESS)
write_byte(TRASER_SPEED)
message_end()
engfunc(EngFunc_MessageBegin, MSG_PAS, SVC_TEMPENTITY, originF, 0);
write_byte( TE_SPRITETRAIL )
engfunc(EngFunc_WriteCoord, originF[ 0 ])
engfunc(EngFunc_WriteCoord, originF[ 1 ])
engfunc(EngFunc_WriteCoord, originF[ 2 ])
engfunc(EngFunc_WriteCoord, originF[ 0 ])
engfunc(EngFunc_WriteCoord, originF[ 1 ])
engfunc(EngFunc_WriteCoord, originF[ 2 ] + 200)
write_short(g_gibss)
write_byte(GIBS_COUNT)
write_byte(GIBS_LIFE)
write_byte(GIBS_SCALE)
write_byte(GIBS_VELOSITY)
write_byte(GIBS_RENDOM_OF_VELOSITY)
message_end()
engfunc(EngFunc_MessageBegin, MSG_PVS, SVC_TEMPENTITY, originF, 0)
write_byte(TE_PARTICLEBURST) // TE id
engfunc(EngFunc_WriteCoord, originF[0]) // x
engfunc(EngFunc_WriteCoord, originF[1]) // y
engfunc(EngFunc_WriteCoord, originF[2]) // z
write_short(600) // radius
write_byte(152) // color
write_byte(15) // duration (will be randomized a bit)
message_end()
emit_sound(ent, CHAN_WEAPON, sound[0], 1.0, ATTN_NORM, 0, PITCH_NORM)
static owner; owner = pev(ent, pev_owner)
new victim
while((victim=engfunc(EngFunc_FindEntityInSphere, victim, originF, NADE_RADIUS_EXPLODE))!=0) {
if(pev(victim, pev_takedamage)!=DAMAGE_NO && pev(victim, pev_solid)!=SOLID_NOT) {
if(!is_user_alive(victim) || !ze_is_user_zombie(victim))continue
new victim_origin[3], distance, Float:distance_damage, floated_origin[3]
floated_origin[0] = floatround(originF[0]),floated_origin[1] = floatround(originF[1]),floated_origin[2] = floatround(originF[2])
get_user_origin(victim, victim_origin),distance = get_distance(victim_origin, floated_origin)
distance_damage = NADE_EXPLODE_DAMAGE - floatmul(NADE_EXPLODE_DAMAGE, floatdiv(float(distance), 500.0))
ExecuteHam(Ham_TakeDamage, victim, ent, owner, distance_damage, DMG_BULLET)
}
}
}
public SET_WPNLIST( Player, const szWeapon[ ], int, int2, int3, int4, int5, int6, int7, int8 ){
message_begin( MSG_ONE, get_user_msgid("WeaponList"), _, Player );
write_string( szWeapon );
write_byte( int );
write_byte( int2);
write_byte( int3 );
write_byte( int4 );
write_byte( int5 );
write_byte( int6 );
write_byte( int7 );
write_byte( int8 );
message_end( );
}
stock create_blast_effect(const Float:originF[3], red, green, blue, brightness, Float:radius){
engfunc(EngFunc_MessageBegin, MSG_PVS, SVC_TEMPENTITY, originF, 0)
write_byte(TE_BEAMCYLINDER) // TE id: 21
engfunc(EngFunc_WriteCoord, originF[0]) // x
engfunc(EngFunc_WriteCoord, originF[1]) // y
engfunc(EngFunc_WriteCoord, originF[2]) // z
engfunc(EngFunc_WriteCoord, originF[0]) // x axis
engfunc(EngFunc_WriteCoord, originF[1]) // y axis
engfunc(EngFunc_WriteCoord, originF[2] + radius) // z axis
write_short(g_ring) // sprite
write_byte(0) // startframe
write_byte(0) // framerate
write_byte(7) // life
write_byte(50) // width
write_byte(0) // noise
write_byte(red) // red
write_byte(green) // green
write_byte(blue) // blue
write_byte(brightness) // brightness
write_byte(0) // speed
message_end()
}
public Weapon_Hook_Select(id){
engclient_cmd(id, NADE_ENTIY)
return PLUGIN_HANDLED
}
public HAM_Spawn(id)g_has_grenade[id] = false;