這個
複製程式
public fw_TakeDamage(victim, inflictor, attacker, Float:damage, damage_type)
{
// Non-player damage or self damage
if (victim == attacker || !is_user_valid_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])
return HAM_SUPERCEDE;
// Prevent friendly fire
if (g_zombie[attacker] == g_zombie[victim])
return HAM_SUPERCEDE;
// Attacker is human...
if (!g_zombie[attacker])
{
// 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)
// Reward ammo packs for every [ammo damage] dealt
while (g_damagedealt[attacker] > get_pcvar_num(cvar_ammodamage))
{
g_ammopacks[attacker]++
g_damagedealt[attacker] -= get_pcvar_num(cvar_ammodamage)
}
}
return HAM_IGNORED;
}
// Attacker is zombie...
// Prevent infection/damage by HE grenade (bugfix)
if (damage_type & DMG_HEGRENADE)
return HAM_SUPERCEDE;
// Nemesis?
if (g_nemesis[attacker])
{
// Ignore nemesis damage override if damage comes from a 3rd party entity
// (to prevent this from affecting a sub-plugin's rockets e.g.)
if (inflictor == attacker)
{
// Set nemesis damage
SetHamParamFloat(4, get_pcvar_float(cvar_nemdamage))
}
return HAM_IGNORED;
}
// Last human or not an infection round
if (g_survround || g_nemround || 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)
{
emit_sound(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
zombieme(victim, attacker, 0, 0, 1) // turn into zombie
return HAM_SUPERCEDE;
}