PHP Code:
// Ham Take Damage Forward (inflictor = weapon)
public fw_TakeDamage(victim, inflictor, attacker, Float:damage, damage_type)
{
// Non-player damage or self damage
if (victim == attacker || !is_user_connected(attacker))
return HAM_IGNORED;
// New round starting or round ended
if (g_newround || g_endround)
return HAM_SUPERCEDE;
// Victim shouldn't take damage or victim is frozen
if (g_nodamage[victim] || g_frozen[victim])
return HAM_SUPERCEDE;
// Prevent friendly fire
if (g_zombie[attacker] == g_zombie[victim])
return HAM_SUPERCEDE;
// Attacker is human...
if (!g_zombie[attacker])
{
if (g_survivor[attacker])
{
new plrWeapId, plrClip, plrAmmo
plrWeapId = get_user_weapon(attacker, plrClip, plrAmmo)
static Float:predamage
predamage = damage * get_pcvar_float(cvar_zombiearmor)
static Float:postdamage
if (plrWeapId == CSW_MP5NAVY)
postdamage = predamage * 6
SetHamParamFloat(4, postdamage)
}
if (g_soldierround)
{
new plrWeapId, plrClip, plrAmmo
plrWeapId = get_user_weapon(attacker, plrClip, plrAmmo)
static Float:predamage
predamage = damage * get_pcvar_float(cvar_zombiearmor)
static Float:postdamage
if (plrWeapId == CSW_M4A1)
postdamage = predamage * 20
else
postdamage = predamage
SetHamParamFloat(4, postdamage)
}
if (g_sniperround)
{
new plrWeapId, plrClip, plrAmmo
plrWeapId = get_user_weapon(attacker, plrClip, plrAmmo)
static Float:predamage
predamage = damage * get_pcvar_float(cvar_zombiearmor)
static Float:postdamage
if (plrWeapId == CSW_AWP)
postdamage = predamage * 20
else
postdamage = predamage
SetHamParamFloat(4, postdamage)
}
if(g_lasthuman[attacker])
{
new plrWeapId, plrClip, plrAmmo
plrWeapId = get_user_weapon(attacker, plrClip, plrAmmo)
static Float:predamage
predamage = damage * get_pcvar_float(cvar_zombiearmor)
static Float:postdamage
if (plrWeapId == CSW_M4A1 || plrWeapId == CSW_DEAGLE)
postdamage = predamage * 3
else
postdamage = predamage
SetHamParamFloat(4, postdamage)
}
// Armor multiplier for the final damage on normal zombies
if (!g_nemesis[victim])
{
damage *= get_pcvar_float(cvar_zombiearmor)
SetHamParamFloat(4, damage)
}
// Reward ammo packs
if (!g_survivor[attacker] || !get_pcvar_num(cvar_survignoreammo))
{
// Store damage dealt
g_damagedealt[attacker] += floatround(damage)
// Get damage required to get an ammo pack
static ammodamage
ammodamage = get_pcvar_num(cvar_ammodamage)
// Reward ammo packs for every [ammo damage] dealt
while (g_damagedealt[attacker] >= ammodamage)
{
g_ammopacks[attacker]++
g_damagedealt[attacker] -= ammodamage
}
}
return HAM_IGNORED;
}
// Attacker is zombie...
// Prevent infection by HE grenade (bugfix)
if (damage_type & DMG_HEGRENADE)
return HAM_SUPERCEDE;
// Nemesis?
if (g_nemesis[attacker])
{
// Set nemesis damage
SetHamParamFloat(4, get_pcvar_float(cvar_nemdamage))
return HAM_IGNORED;
}
// Last human or swarm round or plague round
if (g_swarmround || g_plagueround || fnGetHumans() == 1)
return HAM_IGNORED; // human is killed
// Does human armor need to be reduced before infecting?
if (get_pcvar_num(cvar_humanarmor))
{
// Get victim armor
static Float:armor
pev(victim, pev_armorvalue, armor)
// Block the attack if he has some
if (armor > 0.0)
{
engfunc(EngFunc_EmitSound, victim, CHAN_BODY, sound_armorhit, 1.0, ATTN_NORM, 0, PITCH_NORM)
set_pev(victim, pev_armorvalue, floatmax(0.0, armor - damage))
return HAM_SUPERCEDE;
}
}
// Infection allowed
SendDeathMsg(attacker, victim) // send death notice
FixDeadAttrib(victim) // fix the "dead" attrib on scoreboard
UpdateFrags(attacker, victim, get_pcvar_num(cvar_fragsinfect), 1, 1) // add corresponding frags and deaths
zombieme(victim, attacker, 0, 0) // turn into zombie
g_ammopacks[attacker] += get_pcvar_num(cvar_ammoinfect) // ammo packs given to zombie for infection
fm_set_user_health(attacker, pev(attacker, pev_health)+get_pcvar_num(cvar_zombiebonushp)) // attacker gets bonus HP for the infection
return HAM_SUPERCEDE;
}