}
}
-void calculate_player_respawn_time()
-{SELFPARAM();
+void calculate_player_respawn_time(entity this)
+{
if(g_ca)
return;
float waves = GAMETYPE_DEFAULTED_SETTING(respawn_waves);
float pcount = 1; // Include myself whether or not team is already set right and I'm a "player".
- entity pl;
if (teamplay)
{
- FOR_EACH_PLAYER(pl)
- if (pl != self)
- if (pl.team == self.team)
- ++pcount;
+ FOREACH_CLIENT(IS_PLAYER(it) && it != this, LAMBDA(
+ if(it.team == this.team)
+ ++pcount;
+ ));
if (sdelay_small_count == 0)
sdelay_small_count = 1;
if (sdelay_large_count == 0)
}
else
{
- FOR_EACH_PLAYER(pl)
- if (pl != self)
- ++pcount;
+ FOREACH_CLIENT(IS_PLAYER(it) && it != this, LAMBDA(
+ ++pcount;
+ ));
if (sdelay_small_count == 0)
{
if (g_cts)
sdelay = sdelay_small + (sdelay_large - sdelay_small) * (pcount - sdelay_small_count) / (sdelay_large_count - sdelay_small_count);
if(waves)
- self.respawn_time = ceil((time + sdelay) / waves) * waves;
+ this.respawn_time = ceil((time + sdelay) / waves) * waves;
else
- self.respawn_time = time + sdelay;
+ this.respawn_time = time + sdelay;
if(sdelay < sdelay_max)
- self.respawn_time_max = time + sdelay_max;
+ this.respawn_time_max = time + sdelay_max;
else
- self.respawn_time_max = self.respawn_time;
+ this.respawn_time_max = this.respawn_time;
- if((sdelay + waves >= 5.0) && (self.respawn_time - time > 1.75))
- self.respawn_countdown = 10; // first number to count down from is 10
+ if((sdelay + waves >= 5.0) && (this.respawn_time - time > 1.75))
+ this.respawn_countdown = 10; // first number to count down from is 10
else
- self.respawn_countdown = -1; // do not count down
+ this.respawn_countdown = -1; // do not count down
if(autocvar_g_forced_respawn)
- self.respawn_flags = self.respawn_flags | RESPAWN_FORCE;
+ this.respawn_flags = this.respawn_flags | RESPAWN_FORCE;
}
void PlayerDamage (entity inflictor, entity attacker, float damage, int deathtype, vector hitloc, vector force)
{SELFPARAM();
float take, save, dh, da;
- int j;
vector v;
float valid_damage_for_weaponstats;
float excess;
// exclude pain sounds for laserjumps as long as you aren't REALLY low on health and would die of the next two
{
if(deathtype == DEATH_FALL.m_id)
- PlayerSound(playersound_fall, CH_PAIN, VOICETYPE_PLAYERSOUND);
+ PlayerSound(self, playersound_fall, CH_PAIN, VOICETYPE_PLAYERSOUND);
else if(self.health > 75) // TODO make a "gentle" version?
- PlayerSound(playersound_pain100, CH_PAIN, VOICETYPE_PLAYERSOUND);
+ PlayerSound(self, playersound_pain100, CH_PAIN, VOICETYPE_PLAYERSOUND);
else if(self.health > 50)
- PlayerSound(playersound_pain75, CH_PAIN, VOICETYPE_PLAYERSOUND);
+ PlayerSound(self, playersound_pain75, CH_PAIN, VOICETYPE_PLAYERSOUND);
else if(self.health > 25)
- PlayerSound(playersound_pain50, CH_PAIN, VOICETYPE_PLAYERSOUND);
+ PlayerSound(self, playersound_pain50, CH_PAIN, VOICETYPE_PLAYERSOUND);
else
- PlayerSound(playersound_pain25, CH_PAIN, VOICETYPE_PLAYERSOUND);
+ PlayerSound(self, playersound_pain25, CH_PAIN, VOICETYPE_PLAYERSOUND);
}
}
}
if(DIFF_TEAM(self, attacker))
{
if(DEATH_ISSPECIAL(deathtype))
- awep = get_weaponinfo(attacker.weapon);
+ awep = PS(attacker).m_weapon;
else
awep = DEATH_WEAPONOF(deathtype);
valid_damage_for_weaponstats = 1;
{
dh = dh - max(self.health, 0);
da = da - max(self.armorvalue, 0);
- WeaponStats_LogDamage(awep.m_id, abot, self.weapon, vbot, dh + da);
+ WeaponStats_LogDamage(awep.m_id, abot, PS(self).m_weapon.m_id, vbot, dh + da);
MUTATOR_CALLHOOK(PlayerDamaged, attacker, self, dh, da, hitloc, deathtype);
}
}
if(valid_damage_for_weaponstats)
- WeaponStats_LogKill(awep.m_id, abot, self.weapon, vbot);
+ WeaponStats_LogKill(awep.m_id, abot, PS(self).m_weapon.m_id, vbot);
if(autocvar_sv_gentle < 1) // TODO make a "gentle" version?
if(sound_allowed(MSG_BROADCAST, attacker))
{
if(deathtype == DEATH_DROWN.m_id)
- PlayerSound(playersound_drown, CH_PAIN, VOICETYPE_PLAYERSOUND);
+ PlayerSound(self, playersound_drown, CH_PAIN, VOICETYPE_PLAYERSOUND);
else
- PlayerSound(playersound_death, CH_PAIN, VOICETYPE_PLAYERSOUND);
+ PlayerSound(self, playersound_death, CH_PAIN, VOICETYPE_PLAYERSOUND);
}
// get rid of kill indicator
MUTATOR_CALLHOOK(PlayerDies, inflictor, attacker, self, deathtype);
excess = frag_damage;
- Weapon wep = get_weaponinfo(self.weapon);
+ Weapon wep = PS(self).m_weapon;
wep.wr_playerdeath(wep);
RemoveGrapplingHook(self);
// clear waypoints
WaypointSprite_PlayerDead();
// throw a weapon
- SpawnThrownWeapon (self.origin + (self.mins + self.maxs) * 0.5, self.switchweapon);
+ SpawnThrownWeapon (self.origin + (self.mins + self.maxs) * 0.5, PS(self).m_switchweapon.m_id);
// become fully visible
self.alpha = default_player_alpha;
self.deadflag = DEAD_DYING;
// when to allow respawn
- calculate_player_respawn_time();
+ calculate_player_respawn_time(this);
self.death_time = time;
if (random() < 0.5)
}
// reset fields the weapons may use just in case
- for (j = WEP_FIRST; j <= WEP_LAST; ++j)
- {
- Weapon w = get_weaponinfo(j);
- w.wr_resetplayer(w);
- for (int slot = 0; slot < MAX_WEAPONSLOTS; ++slot)
+ FOREACH(Weapons, it != WEP_Null, LAMBDA(
+ it.wr_resetplayer(it);
+ for(int slot = 0; slot < MAX_WEAPONSLOTS; ++slot)
{
- ATTACK_FINISHED_FOR(self, j, slot) = 0;
+ ATTACK_FINISHED_FOR(self, it.m_id, slot) = 0;
}
- }
+ ));
}
}