|
Senior Member
Join Date: Aug 2011
Location: Romania
|

12-27-2014
, 16:15
Zm staper bug
|
#1
|
If iou plant coffin besides human, the coffin freez human 10 seconds, after 10 seconds the human is unfreez but if human transform to zombie while it is freez, never will be unfreezen.
Code:
#include <amxmodx>
#include <biohazard>
#include <engine>
#include <fakemeta>
#include <hamsandwich>
#include <xs>
#define PLUGIN "[Bio] Zombie Class: Stamper"
#define AUTHOR "Aragon*"
#define VERSION "1.0"
#define ZOMBIE_NAME "Stamper (Coffin)" //Zombie Name
#define ZOMBIE_DESC "press G for Coffin" //Zobmie Description
#define ZOMBIE_MODEL "models/player/bio30_stamper/bio30_stamper.mdl"
#define ZOMBIE_CLAWS "models/player/bio30_stamper/claws_stamper.mdl"
#define ZOMBIE_HEALTH 555.0 //Health value
#define ZOMBIE_SPEED 300.0 //Speed value
#define ZOMBIE_GRAVITY 0.7 //Gravity multiplier
#define ZOMBIE_ATTACK 2.0 //Zombie damage multiplier
#define ZOMBIE_REGENDLY 0.30 //Regeneration delay value
#define ZOMBIE_KNOCKBACK 0.0 //Knockback multiplier
#define TASK_COFFIN 1948
#define TASK_FREEZE 2105
#define TASK_COOLDOWN 7503
#define TASK_BOT 8209
#define TASK_HEALTH 3507
#define ID_COFFIN (taskid - TASK_COFFIN)
#define ID_FREEZE (taskid - TASK_FREEZE)
#define ID_COOLDOWN (taskid - TASK_COOLDOWN)
#define ID_BOT (taskid - TASK_BOT)
#define ID_HEALTH (taskid - TASK_HEALTH)
new const CLASSNAME[] = "Coffin"
new const SOUND_DROP[] = "Biohazard30/bio30_stamper/CoffinIronMaidenPlanting.wav"
new const SOUND_HIT[] = "debris/wood1.wav"
new const SOUND_EXPLODE[] = "Biohazard30/bio30_stamper/CoffinIronMaidenExplosion.wav"
new const MODEL[] = "models/Biohazard30/bio30_stamper/Coffin.mdl"
const UNIT_SECOND = (1<<12)
const BREAK_WOOD = 0x08
new Class
new Planting[33], Power_Cooldown[33], Frozen[33], Float:TempSpeed[33], bool:cd[33];
new SpriteBeam, SpriteExplode, SpriteBlast
new CvarExplosionRadius, CvarExplosionDamage, CvarCooldown, CvareFreezeCooldown, CvarCoffinHealth, CvarHumanTrappedSpeed;
new const Tag[ ] = "[Biohazard]";
public plugin_init() {
register_plugin(PLUGIN,AUTHOR,VERSION)
is_biomod_active() ? plugin_init2() : pause("ad")
}
public plugin_init2() {
Class = register_class(ZOMBIE_NAME, ZOMBIE_DESC)
set_class_pmodel(Class, ZOMBIE_MODEL)
set_class_wmodel(Class, ZOMBIE_CLAWS)
set_class_data(Class, DATA_HEALTH, ZOMBIE_HEALTH);
set_class_data(Class, DATA_SPEED, ZOMBIE_SPEED);
set_class_data(Class, DATA_GRAVITY, ZOMBIE_GRAVITY);
set_class_data(Class, DATA_ATTACK, ZOMBIE_ATTACK);
set_class_data(Class, DATA_REGENDLY, ZOMBIE_REGENDLY);
set_class_data(Class, DATA_KNOCKBACK, ZOMBIE_KNOCKBACK);
CvarExplosionRadius = register_cvar("bio_coffin_explosion_radius", "170.0")
CvarExplosionDamage = register_cvar("bio_coffin_explosion_damage", "20.0")
CvarCooldown = register_cvar("bio_coffin_cooldown", "10")
CvareFreezeCooldown = register_cvar("bio_coffin_freeze_cooldown", "10.0")
CvarCoffinHealth = register_cvar("bio_coffin_health", "500.0")
CvarHumanTrappedSpeed = register_cvar("bio_coffin_human_traped_speed", "70.0")
register_clcmd("drop", "Coffin")
register_event("HLTV", "RoundStart", "a", "1=0", "2=0")
register_event("DeathMsg", "Death", "a")
register_event("CurWeapon","CurWeapon","be","1=1")
register_logevent("RoundEnd", 2, "1=Round_End")
RegisterHam(Ham_TraceAttack, "info_target", "CoffinTraceAttack")
RegisterHam(Ham_Think, "info_target", "CoffinThink")
}
public plugin_precache() {
precache_model(ZOMBIE_MODEL)
precache_model(ZOMBIE_CLAWS)
precache_sound(SOUND_DROP)
precache_sound(SOUND_HIT)
precache_sound(SOUND_EXPLODE)
precache_model(MODEL)
SpriteBeam = precache_model("sprites/shockwave.spr")
SpriteExplode = precache_model("models/woodgibs.mdl")
SpriteBlast = precache_model("sprites/Biohazard30/Weapons/K1ases/k1ases_ability.spr")
}
public client_putinserver(id) {
ResetValue(id)
}
public client_disconnect(id) {
ResetValue(id)
}
public RoundStart() {
for(new id = 1; id <= get_maxplayers(); id++) {
if(is_user_connected(id)) ResetValue(id);
}
}
public RoundEnd() {
RemoveAllCoffin()
}
public Death() {
new id = read_data(2)
if(is_user_connected(id)) ResetValue(id);
}
public CurWeapon(id) {
if(!is_user_alive(id)) return PLUGIN_CONTINUE;
if(Frozen[id]) set_pev(id, pev_maxspeed, get_pcvar_float(CvarHumanTrappedSpeed));
return PLUGIN_CONTINUE;
}
public event_infect(victim, attacker) {
if(get_user_class(victim) == Class) {
ResetValue(victim)
ColorChat(victim, "^x04%s^x01 Pentru a planta un^x03 Coffin^x01 apasa tasta^x03 G^x01.", Tag)
}
}
public Coffin(id) {
if(!is_user_alive(id) || !is_user_zombie(id)) return PLUGIN_CONTINUE
if(get_user_class(id) == Class && get_user_weapon(id) == CSW_KNIFE) {
if(!Planting[id] && !cd[id]) {
Planting[id] = 1
TaskCoffin(id)
return PLUGIN_HANDLED
}
}
return PLUGIN_CONTINUE
}
public TaskCoffin(id) {
Planting[id] = 0
cd[id] = true;
Power_Cooldown[id] = get_pcvar_num(CvarCooldown)
CreateCoffinCancer(id)
set_task(get_pcvar_float(CvarCooldown), "ResetCooldown", id)
Power_Cooldown[id] = get_pcvar_num(CvarCooldown)
set_task(1.0, "ShowHUD", id, _, _, "b")
set_hudmessage(0, 100, 200, 0.05, 0.60, 0, 1.0, 1.1, 0.0, 0.0, -11)
if(get_pcvar_num(CvarCooldown) != 1) {
show_hudmessage(id, "Puterea iti va reveni in: %d secunde.",get_pcvar_num(CvarCooldown))
}
if(get_pcvar_num(CvarCooldown) == 1) {
show_hudmessage(id, "Puterea iti va reveni in: %d secunda.",get_pcvar_num(CvarCooldown))
}
}
public ShowHUD(id) {
if (!is_user_alive(id) || !is_user_zombie(id) || get_user_class(id) != Class) {
remove_task(id)
cd[id] = false
Power_Cooldown[id] = 0;
return PLUGIN_HANDLED
}
set_hudmessage(0, 100, 200, 0.05, 0.60, 0, 1.0, 1.1, 0.0, 0.0, -11)
if(is_user_alive(id) && Power_Cooldown[id] == 1) {
Power_Cooldown[id] --;
show_hudmessage(id, "Puterea iti va reveni in: %d secunda.",Power_Cooldown[id])
}
if(is_user_alive(id) && Power_Cooldown[id] > 1) {
Power_Cooldown[id] --;
show_hudmessage(id, "Puterea iti va reveni in: %d secunde.",Power_Cooldown[id])
}
if(Power_Cooldown[id] <= 0) {
show_hudmessage(id, "Ti-a revenit puterea.")
remove_task(id)
cd[id] = false
Power_Cooldown[id] = 0;
}
return PLUGIN_HANDLED
}
public ResetCooldown(id) {
Power_Cooldown[id] = 0
cd[id] = false
ColorChat(id, "^x04%s^x01 Apasa din nou tasta^x03 G^x01 pentru a planta un Coffin.", Tag)
}
public ResetFreeze(taskid) {
UnFreezePlayer(ID_FREEZE)
}
public CoffinTraceAttack(ent, attacker, Float: damage, Float: direction[3], trace, damageBits) {
if(ent == attacker || !is_user_connected(attacker) || !is_valid_ent(ent)) return HAM_IGNORED;
if(!(damageBits & DMG_BULLET)) return HAM_IGNORED;
new className[32];
entity_get_string(ent, EV_SZ_classname, className, charsmax(className))
if(!equali(className, CLASSNAME)) return HAM_IGNORED;
new Float: end[3]
get_tr2(trace, TR_vecEndPos, end);
message_begin(MSG_BROADCAST,SVC_TEMPENTITY)
write_byte(TE_SPARKS)
engfunc(EngFunc_WriteCoord, end[0])
engfunc(EngFunc_WriteCoord, end[1])
engfunc(EngFunc_WriteCoord, end[2])
message_end()
emit_sound(ent, CHAN_VOICE, SOUND_HIT, VOL_NORM, ATTN_NORM, 0, PITCH_NORM)
return HAM_IGNORED;
}
public CoffinThink(ent) {
if(!is_valid_ent(ent)) return;
static className[32];
entity_get_string(ent, EV_SZ_classname, className, charsmax(className))
if(!equali(className, CLASSNAME)) return;
CoffinExplodeKaboom(ent)
}
CreateCoffinCancer(id) {
new Float: origin[3], Float: angle[3], Float:angle2[3], Float:vector[3]
entity_get_vector(id, EV_VEC_origin, origin)
get_origin_distance(id, vector, 40.0)
vector[2] += 25.0
entity_get_vector(id, EV_VEC_angles, angle)
new ent = create_entity("info_target")
entity_set_string(ent, EV_SZ_classname, CLASSNAME)
entity_get_vector(ent, EV_VEC_angles, angle2)
angle[0] = angle2[0]
entity_set_vector(ent, EV_VEC_angles, angle)
entity_set_origin(ent, vector)
entity_set_float(ent, EV_FL_takedamage, 1.0)
entity_set_float(ent, EV_FL_health, 1000.0+get_pcvar_float(CvarCoffinHealth))
entity_set_model(ent, MODEL)
entity_set_int(ent, EV_INT_movetype, MOVETYPE_PUSHSTEP)
entity_set_int(ent, EV_INT_solid, SOLID_BBOX)
new Float:mins[3] = {-10.0, -6.0, -36.0}
new Float:maxs[3] = {10.0, 6.0, 36.0}
entity_set_size(ent, mins, maxs)
entity_set_int(ent, EV_INT_iuser2, id)
drop_to_floor(ent)
engfunc(EngFunc_MessageBegin, MSG_PVS, SVC_TEMPENTITY, origin, 0)
write_byte(TE_BEAMCYLINDER)
engfunc(EngFunc_WriteCoord, origin[0])
engfunc(EngFunc_WriteCoord, origin[1])
engfunc(EngFunc_WriteCoord, origin[2])
engfunc(EngFunc_WriteCoord, origin[0])
engfunc(EngFunc_WriteCoord, origin[1])
engfunc(EngFunc_WriteCoord, origin[2]+200.0)
write_short(SpriteBeam)
write_byte(0)
write_byte(0)
write_byte(4)
write_byte(10)
write_byte(0)
write_byte(150)
write_byte(150)
write_byte(150)
write_byte(200)
write_byte(0)
message_end()
emit_sound(ent, CHAN_VOICE, SOUND_DROP, VOL_NORM, ATTN_NORM, 0, PITCH_NORM)
set_task(0.2, "TaskCoffinHealth", ent+TASK_HEALTH, _, _, "b")
entity_set_float(ent, EV_FL_nextthink, get_gametime() + get_pcvar_float(CvarCooldown))
static victim; victim = -1
while((victim = find_ent_in_sphere(victim, origin, get_pcvar_float(CvarExplosionRadius))) != 0) {
if(!is_user_alive(victim) || is_user_zombie(victim) || Frozen[victim]) continue;
SetFreezePlayer(victim)
CreateScreenShake(victim)
set_task(get_pcvar_float(CvareFreezeCooldown), "ResetFreeze", victim+TASK_FREEZE)
}
set_task(0.2, "CheckStuck", ent)
}
public CheckStuck(ent) {
if(!is_valid_ent(ent)) return;
if(is_player_stuck(ent)) CoffinExplodeKaboom(ent);
}
public TaskCoffinHealth(taskid) {
if(!is_valid_ent(ID_HEALTH)) return;
if(pev(ID_HEALTH, pev_health) < 1000.0) CoffinExplodeKaboom(ID_HEALTH);
}
CoffinExplodeKaboom(ent) {
if(!is_valid_ent(ent)) return;
remove_task(ent+TASK_HEALTH)
static Float:flOrigin[3]
entity_get_vector(ent, EV_VEC_origin, flOrigin)
message_begin(MSG_BROADCAST, SVC_TEMPENTITY)
write_byte(TE_EXPLOSION)
engfunc(EngFunc_WriteCoord, flOrigin[0])
engfunc(EngFunc_WriteCoord, flOrigin[1])
engfunc(EngFunc_WriteCoord, flOrigin[2])
write_short(SpriteBlast)
write_byte(40)
write_byte(30)
write_byte(14)
message_end()
engfunc(EngFunc_MessageBegin, MSG_PVS, SVC_TEMPENTITY, flOrigin, 0)
write_byte(TE_BREAKMODEL)
engfunc(EngFunc_WriteCoord, flOrigin[0])
engfunc(EngFunc_WriteCoord, flOrigin[1])
engfunc(EngFunc_WriteCoord, flOrigin[2]+24)
engfunc(EngFunc_WriteCoord, 16)
engfunc(EngFunc_WriteCoord, 16)
engfunc(EngFunc_WriteCoord, 16)
engfunc(EngFunc_WriteCoord, random_num(-50, 50))
engfunc(EngFunc_WriteCoord, random_num(-50, 50))
engfunc(EngFunc_WriteCoord, 25)
write_byte(10)
write_short(SpriteExplode)
write_byte(10)
write_byte(25)
write_byte(BREAK_WOOD)
message_end()
emit_sound(ent, CHAN_VOICE, SOUND_EXPLODE, VOL_NORM, ATTN_NORM, 0, PITCH_NORM)
static attacker; attacker = entity_get_int(ent, EV_INT_iuser2)
if (!is_user_connected(attacker)) {
remove_entity(ent)
return;
}
static victim; victim = -1
while((victim = find_ent_in_sphere(victim, flOrigin, get_pcvar_float(CvarExplosionRadius))) != 0) {
if(!is_user_alive(victim) || !is_valid_ent(victim)) continue;
CreateScreenShake(victim)
if(get_user_health(victim) > get_pcvar_float(CvarExplosionDamage)) ExecuteHam(Ham_TakeDamage, victim, attacker, attacker, get_pcvar_float(CvarExplosionDamage), DMG_BLAST);
else ExecuteHamB(Ham_Killed, victim, attacker, 0);
}
remove_entity(ent)
}
SetFreezePlayer(id) {
Frozen[id] = 1
pev(id, pev_maxspeed, TempSpeed[id])
set_pev(id, pev_maxspeed, get_pcvar_float(CvarHumanTrappedSpeed))
client_print(id, print_center, "You are trapped right now!")
}
UnFreezePlayer(id) {
Frozen[id] = 0
if(is_user_zombie(id)) return;
set_pev(id, pev_maxspeed, TempSpeed[id])
client_print(id, print_center, "You no longer trapped!")
RemoveSlowSprites(id)
}
RemoveAllCoffin() {
new ent
ent = find_ent_by_class(-1, CLASSNAME)
while(ent > 0) {
remove_task(ent+TASK_HEALTH)
remove_entity(ent)
ent = find_ent_by_class(-1, CLASSNAME)
}
}
get_origin_distance(index, Float:origin[3], Float:dist) {
new Float:start[3]
new Float:view_ofs[3]
pev(index, pev_origin, start)
pev(index, pev_view_ofs, view_ofs)
xs_vec_add(start, view_ofs, start)
new Float:dest[3]
pev(index, pev_angles, dest)
engfunc(EngFunc_MakeVectors, dest)
global_get(glb_v_forward, dest)
xs_vec_mul_scalar(dest, dist, dest)
xs_vec_add(start, dest, dest)
engfunc(EngFunc_TraceLine, start, dest, 0, index, 0)
get_tr2(0, TR_vecEndPos, origin)
return 1
}
is_player_stuck(id) {
static Float:originF[3]
pev(id, pev_origin, originF)
engfunc(EngFunc_TraceHull, originF, originF, 0, (pev(id, pev_flags) & FL_DUCKING) ? HULL_HEAD : HULL_HUMAN, id, 0)
if (get_tr2(0, TR_StartSolid) || get_tr2(0, TR_AllSolid) || !get_tr2(0, TR_InOpen))
return true
return false
}
CreateScreenShake(id) {
if(is_user_connected(id)) {
new shake[3]
shake[0] = random_num(2,20)
shake[1] = random_num(2,5)
shake[2] = random_num(2,20)
message_begin(MSG_ONE_UNRELIABLE, get_user_msgid("ScreenShake"), _, id)
write_short(UNIT_SECOND*shake[0])
write_short(UNIT_SECOND*shake[1])
write_short(UNIT_SECOND*shake[2])
message_end()
}
}
RemoveSlowSprites(id) {
if(is_user_connected(id)) {
message_begin(MSG_ALL, SVC_TEMPENTITY)
write_byte(TE_KILLPLAYERATTACHMENTS)
write_byte(id)
message_end()
}
}
ResetValue(id) {
if(Frozen[id]) RemoveSlowSprites(id);
Planting[id] = 0
Power_Cooldown[id] = 0
Frozen[id] = 0
cd[id] = false
remove_task(id+TASK_COFFIN)
remove_task(id+TASK_FREEZE)
remove_task(id+TASK_COOLDOWN)
remove_task(id+TASK_BOT)
}
stock ColorChat(const id, const input[], any:...) {
new count = 1, players[32];
static msg[191];
vformat(msg, 190, input, 3);
replace_all(msg, 190, "!x04", "^4");
replace_all(msg, 190, "!x01", "^1");
replace_all(msg, 190, "!x03", "^3");
if(id) players[0] = id;
else get_players(players, count, "ch"); {
for(new i = 0; i < count; i++) {
if(is_user_connected(players[i])) {
message_begin(MSG_ONE_UNRELIABLE, get_user_msgid("SayText"), _, players[i]);
write_byte(players[i]);
write_string(msg);
message_end();
}
}
}
}
|
|