{
entity thehook = M_ARGV(0, entity);
- entity dmgent = ((SAME_TEAM(thehook.owner, thehook.aiment) && autocvar_g_vampirehook_teamheal) ? thehook.owner : thehook.aiment);
-
- if(IS_PLAYER(thehook.aiment))
- if(thehook.last_dmg < time)
- if(!STAT(FROZEN, thehook.aiment))
- if(time >= game_starttime)
- if(DIFF_TEAM(thehook.owner, thehook.aiment) || autocvar_g_vampirehook_teamheal)
- if(GetResource(thehook.aiment, RES_HEALTH) > 0)
- if(autocvar_g_vampirehook_damage)
+ if (!autocvar_g_vampirehook_damage || thehook.last_dmg > time || time < game_starttime)
+ return;
+
+ entity hook_owner = thehook.owner;
+ entity hook_aiment = thehook.aiment;
+
+ if (IS_PLAYER(hook_aiment) && !STAT(FROZEN, hook_aiment)
+ && (DIFF_TEAM(hook_owner, hook_aiment) || autocvar_g_vampirehook_teamheal)
+ && GetResource(hook_aiment, RES_HEALTH) > 0)
{
thehook.last_dmg = time + autocvar_g_vampirehook_damagerate;
- thehook.owner.hitsound_damage_dealt += autocvar_g_vampirehook_damage;
- Damage(dmgent, thehook, thehook.owner, autocvar_g_vampirehook_damage, WEP_HOOK.m_id, DMG_NOWEP, thehook.origin, '0 0 0');
- entity targ = ((SAME_TEAM(thehook.owner, thehook.aiment)) ? thehook.aiment : thehook.owner);
+ hook_owner.hitsound_damage_dealt += autocvar_g_vampirehook_damage;
+ entity dmgent = ((SAME_TEAM(hook_owner, hook_aiment) && autocvar_g_vampirehook_teamheal) ? hook_owner : hook_aiment);
+ Damage(dmgent, thehook, hook_owner, autocvar_g_vampirehook_damage, WEP_HOOK.m_id, DMG_NOWEP, thehook.origin, '0 0 0');
+ entity targ = ((SAME_TEAM(hook_owner, hook_aiment)) ? hook_aiment : hook_owner);
// TODO: we can't do this due to an issue with globals and the mutator arguments
- //Heal(targ, thehook.owner, autocvar_g_vampirehook_health_steal, g_pickup_healthsmall_max);
+ //Heal(targ, hook_owner, autocvar_g_vampirehook_health_steal, g_pickup_healthsmall_max);
SetResourceExplicit(targ, RES_HEALTH, min(GetResource(targ, RES_HEALTH) + autocvar_g_vampirehook_health_steal, g_pickup_healthsmall_max));
- if(dmgent == thehook.owner)
+ if(dmgent == hook_owner)
TakeResource(dmgent, RES_HEALTH, autocvar_g_vampirehook_damage); // FIXME: friendly fire?!
}
}
{
if((prefix == "") || PS_GR_OUT_DB < 0) { return 0; }
- string key = sprintf("%s:%s", prefix, event_id);
+ // use a cheaper strcat here since this function is called often in game
+ string key = strcat(prefix, ":", event_id);
float val = stof(db_get(PS_GR_OUT_DB, key));
val += value;
db_put(PS_GR_OUT_DB, key, ftos(val));
bool PlayerHeal(entity targ, entity inflictor, float amount, float limit)
{
- if(GetResource(targ, RES_HEALTH) <= 0 || GetResource(targ, RES_HEALTH) >= limit)
+ float hlth = GetResource(targ, RES_HEALTH);
+ if (hlth <= 0 || hlth >= limit)
return false;
GiveResourceWithLimit(targ, RES_HEALTH, amount, limit);