if(isclient)
{
if(pscore > 0)
- PlayerScore_Add(ball.pusher, SP_NEXBALL_GOALS, pscore);
+ GameRules_scoring_add(ball.pusher, NEXBALL_GOALS, pscore);
else if(pscore < 0)
- PlayerScore_Add(ball.pusher, SP_NEXBALL_FAULTS, -pscore);
+ GameRules_scoring_add(ball.pusher, NEXBALL_FAULTS, -pscore);
}
if(ball.owner) // Happens on spawnflag GOAL_TOUCHPLAYER
pointparticles(EFFECT_ROCKET_EXPLODE, this.origin, '0 0 0', 1);
Send_Notification(NOTIF_ALL, NULL, MSG_INFO, APP_TEAM_NUM(this.team, INFO_ONSLAUGHT_CPDESTROYED), this.owner.message, attacker.netname);
- PlayerScore_Add(attacker, SP_ONS_TAKES, 1);
- PlayerScore_Add(attacker, SP_SCORE, 10);
+ GameRules_scoring_add(attacker, ONS_TAKES, 1);
+ GameRules_scoring_add(attacker, SCORE, 10);
this.owner.goalentity = NULL;
this.owner.islinked = false;
Send_Notification(NOTIF_ALL, NULL, MSG_INFO, INFO_ONSLAUGHT_CAPTURE, this.owner.ons_toucher.netname, this.owner.message);
Send_Notification(NOTIF_ALL_EXCEPT, this.owner.ons_toucher, MSG_CENTER, APP_TEAM_NUM(this.owner.ons_toucher.team, CENTER_ONS_CAPTURE_TEAM), this.owner.message);
Send_Notification(NOTIF_ONE, this.owner.ons_toucher, MSG_CENTER, CENTER_ONS_CAPTURE, this.owner.message);
- PlayerScore_Add(this.owner.ons_toucher, SP_ONS_CAPS, 1);
- PlayerTeamScore_AddScore(this.owner.ons_toucher, 10);
+ GameRules_scoring_add(this.owner.ons_toucher, ONS_CAPS, 1);
+ GameRules_scoring_add_team(this.owner.ons_toucher, SCORE, 10);
}
this.owner.ons_toucher = NULL;
else
{
Send_Notification(NOTIF_ALL, NULL, MSG_INFO, APP_TEAM_NUM(this.team, INFO_ONSLAUGHT_GENDESTROYED));
- PlayerScore_Add(attacker, SP_SCORE, 100);
+ GameRules_scoring_add(attacker, SCORE, 100);
}
this.iscaptured = false;
this.islinked = false;
{
return player.m_GameRules_scoring_vip;
}
+
+float _GameRules_scoring_add(entity client, entity sp, float value)
+{
+ return PlayerScore_Add(client, sp, value);
+}
+float _GameRules_scoring_add_team(entity client, entity sp, int st, float value)
+{
+ return PlayerTeamScore_Add(client, sp, st, value);
+}
*/
void GameRules_scoring_vip(entity player, bool value);
bool GameRules_scoring_is_vip(entity player);
+
+#define GameRules_scoring_add(client, fld, value) _GameRules_scoring_add(client, SP_##fld, value)
+float _GameRules_scoring_add(entity client, entity sp, float value);
+#define GameRules_scoring_add_team(client, fld, value) _GameRules_scoring_add_team(client, SP_##fld, ST_##fld, value)
+float _GameRules_scoring_add_team(entity client, entity sp, int st, float value);
if(IS_PLAYER(attacker))
if(autocvar_g_monsters_score_spawned || !((this.spawnflags & MONSTERFLAG_SPAWNED) || (this.spawnflags & MONSTERFLAG_RESPAWNED)))
- PlayerScore_Add(attacker, SP_SCORE, +autocvar_g_monsters_score_kill);
+ GameRules_scoring_add(attacker, SCORE, +autocvar_g_monsters_score_kill);
if(gibbed)
{
void PlayerStats_PlayerBasic(entity joiningplayer, float newrequest)
{
- PlayerScore_Add(joiningplayer, SP_ELO, -1);
+ GameRules_scoring_add(joiningplayer, ELO, -1);
// http://stats.xonotic.org/player/GgXRw6piDtFIbMArMuiAi8JG4tiin8VLjZgsKB60Uds=/elo.txt
if(autocvar_g_playerstats_playerbasic_uri != "")
{
string uri = autocvar_g_playerstats_playerbasic_uri;
if (joiningplayer.crypto_idfp == "") {
- PlayerScore_Add(joiningplayer, SP_ELO, -1);
+ GameRules_scoring_add(joiningplayer, ELO, -1);
} else {
// create the database if it doesn't already exist
if(PS_B_IN_DB < 0)
else
{
// server has this disabled, kill the DB and set status to idle
- PlayerScore_Add(joiningplayer, SP_ELO, -1);
+ GameRules_scoring_add(joiningplayer, ELO, -1);
if(PS_B_IN_DB >= 0)
{
db_close(PS_B_IN_DB);
if (gt == PlayerStats_GetGametype()) {
handled = true;
float e = stof(data);
- PlayerScore_Add(p, SP_ELO, +1 + e);
+ GameRules_scoring_add(p, ELO, +1 + e);
}
if (gt == "") {
// PlayerInfo_AddItem(p, value, data);
break;
}
}
- PlayerScore_Add(p, SP_ELO, -1);
+ GameRules_scoring_add(p, ELO, -1);
}
#endif // SVQC
void UpdateFrags(entity player, int f)
{
- PlayerTeamScore_AddScore(player, f);
+ GameRules_scoring_add_team(player, SCORE, f);
}
void GiveFrags (entity attacker, entity targ, float f, int deathtype)
if(targ == attacker)
{
// suicide
- PlayerScore_Add(attacker, SP_SUICIDES, 1);
+ GameRules_scoring_add(attacker, SUICIDES, 1);
}
else
{
// teamkill
- PlayerScore_Add(attacker, SP_KILLS, -1); // or maybe add a teamkills field?
+ GameRules_scoring_add(attacker, KILLS, -1); // or maybe add a teamkills field?
}
}
else
{
// regular frag
- PlayerScore_Add(attacker, SP_KILLS, 1);
+ GameRules_scoring_add(attacker, KILLS, 1);
if(targ.playerid)
PS_GR_P_ADDVAL(attacker, sprintf("kills-%d", targ.playerid), 1);
}
- PlayerScore_Add(targ, SP_DEATHS, 1);
+ GameRules_scoring_add(targ, DEATHS, 1);
.entity weaponentity = weaponentities[0]; // TODO: unhardcode
LogDeath("accident", deathtype, targ, targ);
GiveFrags(targ, targ, -1, deathtype);
- if(PlayerScore_Add(targ, SP_SCORE, 0) == -5)
+ if(GameRules_scoring_add(targ, SCORE, 0) == -5)
{
Send_Notification(NOTIF_ONE, targ, MSG_ANNCE, ANNCE_ACHIEVEMENT_BOTLIKE);
PS_GR_P_ADDVAL(attacker, PLAYERSTATS_ACHIEVEMENT_BOTLIKE, 1);
totalplayers = playerswithlaps = readyplayers = 0;
FOREACH_CLIENT(IS_PLAYER(it), {
++totalplayers;
- if(PlayerScore_Add(it, SP_RACE_FASTEST, 0))
+ if(GameRules_scoring_add(it, RACE_FASTEST, 0))
++playerswithlaps;
if(it.ready)
++readyplayers;
{
if(this.enemy.health - this.dmg > 0.5)
{
- PlayerTeamScore_Add(actor, SP_SCORE, ST_SCORE, this.dmg);
+ GameRules_scoring_add_team(actor, SCORE, this.dmg);
this.enemy.health = this.enemy.health - this.dmg;
}
else
{
- PlayerTeamScore_Add(actor, SP_SCORE, ST_SCORE, this.enemy.health);
- PlayerTeamScore_Add(actor, SP_ASSAULT_OBJECTIVES, ST_ASSAULT_OBJECTIVES, 1);
+ GameRules_scoring_add_team(actor, SCORE, this.enemy.health);
+ GameRules_scoring_add_team(actor, ASSAULT_OBJECTIVES, 1);
this.enemy.health = -1;
if(this.enemy.message)
float excess = max(0, frag_damage - damage_take - damage_save);
if (frag_target != frag_attacker && IS_PLAYER(frag_attacker))
- PlayerTeamScore_Add(frag_attacker, SP_SCORE, ST_SCORE, (frag_damage - excess) * autocvar_g_ca_damage2score_multiplier);
+ GameRules_scoring_add_team(frag_attacker, SCORE, (frag_damage - excess) * autocvar_g_ca_damage2score_multiplier);
}
MUTATOR_HOOKFUNCTION(ca, PlayerRegen)
if(ctf_captureshield_max_ratio <= 0)
return false;
- s = PlayerScore_Add(p, SP_CTF_CAPS, 0);
- s2 = PlayerScore_Add(p, SP_CTF_PICKUPS, 0);
- s3 = PlayerScore_Add(p, SP_CTF_RETURNS, 0);
- s4 = PlayerScore_Add(p, SP_CTF_FCKILLS, 0);
+ s = GameRules_scoring_add(p, CTF_CAPS, 0);
+ s2 = GameRules_scoring_add(p, CTF_PICKUPS, 0);
+ s3 = GameRules_scoring_add(p, CTF_RETURNS, 0);
+ s4 = GameRules_scoring_add(p, CTF_FCKILLS, 0);
sr = ((s - s2) + (s3 + s4));
FOREACH_CLIENT(IS_PLAYER(it), {
if(DIFF_TEAM(it, p))
continue;
- se = PlayerScore_Add(it, SP_CTF_CAPS, 0);
- se2 = PlayerScore_Add(it, SP_CTF_PICKUPS, 0);
- se3 = PlayerScore_Add(it, SP_CTF_RETURNS, 0);
- se4 = PlayerScore_Add(it, SP_CTF_FCKILLS, 0);
+ se = GameRules_scoring_add(it, CTF_CAPS, 0);
+ se2 = GameRules_scoring_add(it, CTF_PICKUPS, 0);
+ se3 = GameRules_scoring_add(it, CTF_RETURNS, 0);
+ se4 = GameRules_scoring_add(it, CTF_FCKILLS, 0);
ser = ((se - se2) + (se3 + se4));
ctf_EventLog("dropped", player.team, player);
// scoring
- PlayerTeamScore_AddScore(player, -((flag.score_drop) ? flag.score_drop : autocvar_g_ctf_score_penalty_drop));
- PlayerScore_Add(player, SP_CTF_DROPS, 1);
+ GameRules_scoring_add_team(player, SCORE, -((flag.score_drop) ? flag.score_drop : autocvar_g_ctf_score_penalty_drop));
+ GameRules_scoring_add(player, CTF_DROPS, 1);
// waypoints
if(autocvar_g_ctf_flag_dropped_waypoint) {
float pscore = 0;
if(enemy_flag.score_capture || flag.score_capture)
pscore = floor((max(1, enemy_flag.score_capture) + max(1, flag.score_capture)) * 0.5);
- PlayerTeamScore_AddScore(player, ((pscore) ? pscore : autocvar_g_ctf_score_capture));
+ GameRules_scoring_add_team(player, SCORE, ((pscore) ? pscore : autocvar_g_ctf_score_capture));
float capscore = 0;
if(enemy_flag.score_team_capture || flag.score_team_capture)
capscore = floor((max(1, enemy_flag.score_team_capture) + max(1, flag.score_team_capture)) * 0.5);
- PlayerTeamScore_Add(player, SP_CTF_CAPS, ST_CTF_CAPS, ((capscore) ? capscore : 1));
+ GameRules_scoring_add_team(player, CTF_CAPS, ((capscore) ? capscore : 1));
- old_time = PlayerScore_Add(player, SP_CTF_CAPTIME, 0);
+ old_time = GameRules_scoring_add(player, CTF_CAPTIME, 0);
new_time = TIME_ENCODE(time - enemy_flag.ctf_pickuptime);
if(!old_time || new_time < old_time)
- PlayerScore_Add(player, SP_CTF_CAPTIME, new_time - old_time);
+ GameRules_scoring_add(player, CTF_CAPTIME, new_time - old_time);
// effects
Send_Effect_(flag.capeffect, flag.origin, '0 0 0', 1);
if(flag.speedrunning) { ctf_FakeTimeLimit(player, -1); }
if((enemy_flag.ctf_dropper) && (player != enemy_flag.ctf_dropper))
- { PlayerTeamScore_AddScore(enemy_flag.ctf_dropper, ((enemy_flag.score_assist) ? enemy_flag.score_assist : autocvar_g_ctf_score_capture_assist)); }
+ { GameRules_scoring_add_team(enemy_flag.ctf_dropper, SCORE, ((enemy_flag.score_assist) ? enemy_flag.score_assist : autocvar_g_ctf_score_capture_assist)); }
}
// reset the flag
// scoring
if(IS_PLAYER(player))
{
- PlayerTeamScore_AddScore(player, ((flag.score_return) ? flag.score_return : autocvar_g_ctf_score_return)); // reward for return
- PlayerScore_Add(player, SP_CTF_RETURNS, 1); // add to count of returns
+ GameRules_scoring_add_team(player, SCORE, ((flag.score_return) ? flag.score_return : autocvar_g_ctf_score_return)); // reward for return
+ GameRules_scoring_add(player, CTF_RETURNS, 1); // add to count of returns
nades_GiveBonus(player,autocvar_g_nades_bonus_score_medium);
}
if(flag.ctf_dropper)
{
- PlayerScore_Add(flag.ctf_dropper, SP_SCORE, -autocvar_g_ctf_score_penalty_returned); // punish the player who dropped the flag
+ GameRules_scoring_add(flag.ctf_dropper, SCORE, -autocvar_g_ctf_score_penalty_returned); // punish the player who dropped the flag
ctf_CaptureShield_Update(flag.ctf_dropper, 0); // shield player from picking up flag
flag.ctf_dropper.next_take_time = time + autocvar_g_ctf_flag_collect_delay; // set next take time
}
_sound(player, CH_TRIGGER, flag.snd_flag_taken, VOL_BASE, ATTEN_NONE);
// scoring
- PlayerScore_Add(player, SP_CTF_PICKUPS, 1);
+ GameRules_scoring_add(player, CTF_PICKUPS, 1);
nades_GiveBonus(player, autocvar_g_nades_bonus_score_minor);
switch(pickuptype)
{
case PICKUP_BASE:
{
- PlayerTeamScore_AddScore(player, ((flag.score_pickup) ? flag.score_pickup : autocvar_g_ctf_score_pickup_base));
+ GameRules_scoring_add_team(player, SCORE, ((flag.score_pickup) ? flag.score_pickup : autocvar_g_ctf_score_pickup_base));
ctf_EventLog("steal", flag.team, player);
break;
}
pickup_dropped_score = (autocvar_g_ctf_flag_return_time ? bound(0, ((flag.ctf_droptime + autocvar_g_ctf_flag_return_time) - time) / autocvar_g_ctf_flag_return_time, 1) : 1);
pickup_dropped_score = floor((autocvar_g_ctf_score_pickup_dropped_late * (1 - pickup_dropped_score) + autocvar_g_ctf_score_pickup_dropped_early * pickup_dropped_score) + 0.5);
LOG_TRACE("pickup_dropped_score is ", ftos(pickup_dropped_score));
- PlayerTeamScore_AddScore(player, pickup_dropped_score);
+ GameRules_scoring_add_team(player, SCORE, pickup_dropped_score);
ctf_EventLog("pickup", flag.team, player);
break;
}
if((frag_attacker != frag_target) && (IS_PLAYER(frag_attacker)) && (frag_target.flagcarried))
{
- PlayerTeamScore_AddScore(frag_attacker, ((SAME_TEAM(frag_attacker, frag_target)) ? -autocvar_g_ctf_score_kill : autocvar_g_ctf_score_kill));
- PlayerScore_Add(frag_attacker, SP_CTF_FCKILLS, 1);
+ GameRules_scoring_add_team(frag_attacker, SCORE, ((SAME_TEAM(frag_attacker, frag_target)) ? -autocvar_g_ctf_score_kill : autocvar_g_ctf_score_kill));
+ GameRules_scoring_add(frag_attacker, CTF_FCKILLS, 1);
}
if(frag_target.flagcarried)
FOREACH_CLIENT(true, {
if(it.race_place)
{
- s = PlayerScore_Add(it, SP_RACE_FASTEST, 0);
+ s = GameRules_scoring_add(it, RACE_FASTEST, 0);
if(!s)
it.race_place = 0;
}
{
entity player = M_ARGV(0, entity);
- if(PlayerScore_Add(player, SP_RACE_FASTEST, 0))
+ if(GameRules_scoring_add(player, RACE_FASTEST, 0))
player.frags = FRAGS_LMS_LOSER;
else
player.frags = FRAGS_SPECTATOR;
Send_Notification(NOTIF_ALL, NULL, MSG_INFO, INFO_DOMINATION_CAPTURE_TIME, head.netname, this.message, points, wait_time);
if(this.enemy.playerid == this.enemy_playerid)
- PlayerScore_Add(this.enemy, SP_DOM_TAKES, 1);
+ GameRules_scoring_add(this.enemy, DOM_TAKES, 1);
else
this.enemy = NULL;
// give credit to the individual player, if he is still there
if (this.enemy.playerid == this.enemy_playerid)
{
- PlayerScore_Add(this.enemy, SP_SCORE, fragamt);
- PlayerScore_Add(this.enemy, SP_DOM_TICKS, fragamt);
+ GameRules_scoring_add(this.enemy, SCORE, fragamt);
+ GameRules_scoring_add(this.enemy, DOM_TICKS, fragamt);
}
else
this.enemy = NULL;
{
// you froze your own dumb targ
// counted as "suicide" already
- PlayerScore_Add(targ, SP_SCORE, -1);
+ GameRules_scoring_add(targ, SCORE, -1);
}
else if(IS_PLAYER(attacker))
{
// got frozen by an enemy
// counted as "kill" and "death" already
- PlayerScore_Add(targ, SP_SCORE, -1);
- PlayerScore_Add(attacker, SP_SCORE, +1);
+ GameRules_scoring_add(targ, SCORE, -1);
+ GameRules_scoring_add(attacker, SCORE, +1);
}
// else nothing - got frozen by the game type rules themselves
}
// EVERY team mate nearby gets a point (even if multiple!)
FOREACH_CLIENT(IS_PLAYER(it) && it.reviving, {
- PlayerScore_Add(it, SP_FREEZETAG_REVIVALS, +1);
- PlayerScore_Add(it, SP_SCORE, +1);
+ GameRules_scoring_add(it, FREEZETAG_REVIVALS, +1);
+ GameRules_scoring_add(it, SCORE, +1);
nades_GiveBonus(it,autocvar_g_nades_bonus_score_low);
});
else
{
FOREACH_CLIENT(IS_PLAYER(it), {
- float cs = PlayerScore_Add(it, SP_KILLS, 0);
+ float cs = GameRules_scoring_add(it, KILLS, 0);
if(cs > winning_score)
{
winning_score = cs;
if(IS_PLAYER(frag_attacker))
if(SAME_TEAM(frag_attacker, frag_target)) // in non-teamplay modes, same team = same player, so this works
- PlayerScore_Add(frag_attacker, SP_KILLS, -1);
+ GameRules_scoring_add(frag_attacker, KILLS, -1);
else
{
- PlayerScore_Add(frag_attacker, SP_KILLS, +1);
+ GameRules_scoring_add(frag_attacker, KILLS, +1);
if(teamplay)
TeamScore_AddToTeam(frag_attacker.team, ST_INV_KILLS, +1);
}
if(this.owner.ballcarried)
{ // add points for holding the ball after a certain amount of time
if(autocvar_g_keepaway_score_timepoints)
- PlayerScore_Add(this.owner, SP_SCORE, autocvar_g_keepaway_score_timepoints);
+ GameRules_scoring_add(this.owner, SCORE, autocvar_g_keepaway_score_timepoints);
- PlayerScore_Add(this.owner, SP_KEEPAWAY_BCTIME, (autocvar_g_keepaway_score_timeinterval / 1)); // interval is divided by 1 so that time always shows "seconds"
+ GameRules_scoring_add(this.owner, KEEPAWAY_BCTIME, (autocvar_g_keepaway_score_timeinterval / 1)); // interval is divided by 1 so that time always shows "seconds"
this.nextthink = time + autocvar_g_keepaway_score_timeinterval;
}
}
sound(this.owner, CH_TRIGGER, SND_KA_PICKEDUP, VOL_BASE, ATTEN_NONE); // ATTEN_NONE (it's a sound intended to be heard anywhere)
// scoring
- PlayerScore_Add(toucher, SP_KEEPAWAY_PICKUPS, 1);
+ GameRules_scoring_add(toucher, KEEPAWAY_PICKUPS, 1);
// waypoints
WaypointSprite_AttachCarrier(WP_KaBallCarrier, toucher, RADARICON_FLAGCARRIER);
sound(NULL, CH_TRIGGER, SND_KA_DROPPED, VOL_BASE, ATTEN_NONE); // ATTEN_NONE (it's a sound intended to be heard anywhere)
// scoring
- // PlayerScore_Add(plyr, SP_KEEPAWAY_DROPS, 1); Not anymore, this is 100% the same as pickups and is useless.
+ // GameRules_scoring_add(plyr, KEEPAWAY_DROPS, 1); Not anymore, this is 100% the same as pickups and is useless.
// waypoints
WaypointSprite_Spawn(WP_KaBall, 0, 0, ball, '0 0 64', NULL, ball.team, ball, waypointsprite_attachedforcarrier, false, RADARICON_FLAGCARRIER);
if((frag_attacker != frag_target) && (IS_PLAYER(frag_attacker)))
{
if(frag_target.ballcarried) { // add to amount of times killing carrier
- PlayerScore_Add(frag_attacker, SP_KEEPAWAY_CARRIERKILLS, 1);
+ GameRules_scoring_add(frag_attacker, KEEPAWAY_CARRIERKILLS, 1);
if(autocvar_g_keepaway_score_bckill) // add bckills to the score
- PlayerScore_Add(frag_attacker, SP_SCORE, autocvar_g_keepaway_score_bckill);
+ GameRules_scoring_add(frag_attacker, SCORE, autocvar_g_keepaway_score_bckill);
}
else if(!frag_attacker.ballcarried)
if(autocvar_g_keepaway_noncarrier_warn)
Send_Notification(NOTIF_ONE_ONLY, frag_attacker, MSG_CENTER, CENTER_KEEPAWAY_WARN);
if(frag_attacker.ballcarried) // add to amount of kills while ballcarrier
- PlayerScore_Add(frag_attacker, SP_SCORE, autocvar_g_keepaway_score_killac);
+ GameRules_scoring_add(frag_attacker, SCORE, autocvar_g_keepaway_score_killac);
}
if(frag_target.ballcarried) { ka_DropEvent(frag_target); } // a player with the ball has died, drop it
if(key.kh_dropperteam != player.team)
{
kh_Scores_Event(player, key, "collect", autocvar_g_balance_keyhunt_score_collect, 0);
- PlayerScore_Add(player, SP_KH_PICKUPS, 1);
+ GameRules_scoring_add(player, KH_PICKUPS, 1);
}
key.kh_dropperteam = 0;
int realteam = kh_Team_ByID(key.count);
{
float f = DistributeEvenly_Get(1);
kh_Scores_Event(key.owner, key, "capture", f, 0);
- PlayerTeamScore_Add(key.owner, SP_KH_CAPS, ST_KH_CAPS, 1);
+ GameRules_scoring_add_team(key.owner, KH_CAPS, 1);
nades_GiveBonus(key.owner, autocvar_g_nades_bonus_score_high);
}
kh_Scores_Event(lostkey.kh_previous_owner, NULL, "pushed", 0, -autocvar_g_balance_keyhunt_score_push);
// don't actually GIVE him the -nn points, just log
kh_Scores_Event(attacker, NULL, "push", autocvar_g_balance_keyhunt_score_push, 0);
- PlayerScore_Add(attacker, SP_KH_PUSHES, 1);
+ GameRules_scoring_add(attacker, KH_PUSHES, 1);
//centerprint(attacker, "Your push is the best!"); // does this really need to exist?
}
else
// don't actually GIVE him the -nn points, just log
if(lostkey.kh_previous_owner.playerid == lostkey.kh_previous_owner_playerid)
- PlayerScore_Add(lostkey.kh_previous_owner, SP_KH_DESTROYS, 1);
+ GameRules_scoring_add(lostkey.kh_previous_owner, KH_DESTROYS, 1);
DistributeEvenly_Init(autocvar_g_balance_keyhunt_score_destroyed, keys * of + players);
key.enemy = player;
kh_Scores_Event(player, key, "dropkey", 0, 0);
- PlayerScore_Add(player, SP_KH_LOSSES, 1);
+ GameRules_scoring_add(player, KH_LOSSES, 1);
int realteam = kh_Team_ByID(key.count);
Send_Notification(NOTIF_ALL, NULL, MSG_INFO, APP_TEAM_NUM(realteam, INFO_KEYHUNT_DROP), player.netname);
while((key = player.kh_next))
{
kh_Scores_Event(player, key, "losekey", 0, 0);
- PlayerScore_Add(player, SP_KH_LOSSES, 1);
+ GameRules_scoring_add(player, KH_LOSSES, 1);
int realteam = kh_Team_ByID(key.count);
Send_Notification(NOTIF_ALL, NULL, MSG_INFO, APP_TEAM_NUM(realteam, INFO_KEYHUNT_LOST), player.netname);
kh_Key_AssignTo(key, NULL);
else
{
kh_Scores_Event(attacker, targ.kh_next, "carrierfrag", autocvar_g_balance_keyhunt_score_carrierfrag-1, 0);
- PlayerScore_Add(attacker, SP_KH_KCKILLS, 1);
+ GameRules_scoring_add(attacker, KH_KCKILLS, 1);
// the frag gets added later
}
}
{
// a winner!
// and assign him his first place
- PlayerScore_Add(head, SP_LMS_RANK, 1);
+ GameRules_scoring_add(head, LMS_RANK, 1);
if(warmup_stage)
return WINNING_NO;
else
FOREACH_CLIENT(true, {
TRANSMUTE(Player, it);
it.frags = FRAGS_PLAYER;
- PlayerScore_Add(it, SP_LMS_LIVES, LMS_NewPlayerLives());
+ GameRules_scoring_add(it, LMS_LIVES, LMS_NewPlayerLives());
PutClientInServer(it);
});
}
TRANSMUTE(Observer, player);
else
{
- float tl = PlayerScore_Add(player, SP_LMS_LIVES, 0);
+ float tl = GameRules_scoring_add(player, LMS_LIVES, 0);
if(tl < lms_lowest_lives)
lms_lowest_lives = tl;
if(tl <= 0)
TRANSMUTE(Observer, player);
if(warmup_stage)
- PlayerScore_Add(player, SP_LMS_RANK, -PlayerScore_Add(player, SP_LMS_RANK, 0));
+ GameRules_scoring_add(player, LMS_RANK, -GameRules_scoring_add(player, LMS_RANK, 0));
}
}
return false;
if(player.frags == FRAGS_SPECTATOR)
return true;
- if(PlayerScore_Add(player, SP_LMS_LIVES, 0) <= 0)
+ if(GameRules_scoring_add(player, LMS_LIVES, 0) <= 0)
{
Send_Notification(NOTIF_ONE, player, MSG_CENTER, CENTER_LMS_NOLIVES);
return true;
void lms_RemovePlayer(entity player)
{
static int quitters = 0;
- float player_rank = PlayerScore_Add(player, SP_LMS_RANK, 0);
+ float player_rank = GameRules_scoring_add(player, LMS_RANK, 0);
if (!player_rank)
{
int pl_cnt = 0;
if(IS_BOT_CLIENT(player))
bot_clear(player);
player.frags = FRAGS_LMS_LOSER;
- PlayerScore_Add(player, SP_LMS_RANK, pl_cnt + 1);
+ GameRules_scoring_add(player, LMS_RANK, pl_cnt + 1);
}
else
{
FOREACH_CLIENT(true, {
if (it.frags == FRAGS_LMS_LOSER)
{
- float it_rank = PlayerScore_Add(it, SP_LMS_RANK, 0);
+ float it_rank = GameRules_scoring_add(it, LMS_RANK, 0);
if (it_rank > player_rank && it_rank <= 256)
- PlayerScore_Add(it, SP_LMS_RANK, -1);
+ GameRules_scoring_add(it, LMS_RANK, -1);
lms_lowest_lives = 0;
}
else if (it.frags != FRAGS_SPECTATOR)
{
- float tl = PlayerScore_Add(it, SP_LMS_LIVES, 0);
+ float tl = GameRules_scoring_add(it, LMS_LIVES, 0);
if(tl < lms_lowest_lives)
lms_lowest_lives = tl;
}
});
- PlayerScore_Add(player, SP_LMS_RANK, 665 - quitters); // different from 666
+ GameRules_scoring_add(player, LMS_RANK, 665 - quitters); // different from 666
if(!warmup_stage)
{
- PlayerScore_Add(player, SP_LMS_LIVES, -PlayerScore_Add(player, SP_LMS_LIVES, 0));
+ GameRules_scoring_add(player, LMS_LIVES, -GameRules_scoring_add(player, LMS_LIVES, 0));
++quitters;
}
player.frags = FRAGS_LMS_LOSER;
}
if(CS(player).killcount != FRAGS_SPECTATOR)
- if(PlayerScore_Add(player, SP_LMS_RANK, 0) > 0 && player.lms_spectate_warning != 2)
+ if(GameRules_scoring_add(player, LMS_RANK, 0) > 0 && player.lms_spectate_warning != 2)
Send_Notification(NOTIF_ALL, NULL, MSG_INFO, INFO_LMS_NOLIVES, player.netname);
else
Send_Notification(NOTIF_ALL, NULL, MSG_INFO, INFO_LMS_FORFEIT, player.netname);
TRANSMUTE(Player, player);
campaign_bots_may_start = true;
- if(PlayerScore_Add(player, SP_LMS_LIVES, LMS_NewPlayerLives()) <= 0)
+ if(GameRules_scoring_add(player, LMS_LIVES, LMS_NewPlayerLives()) <= 0)
{
- PlayerScore_Add(player, SP_LMS_RANK, 666); // mark as forced spectator for the hud code
+ GameRules_scoring_add(player, LMS_RANK, 666); // mark as forced spectator for the hud code
player.frags = FRAGS_SPECTATOR;
}
}
if (!warmup_stage)
{
// remove a life
- int tl = PlayerScore_Add(frag_target, SP_LMS_LIVES, -1);
+ int tl = GameRules_scoring_add(frag_target, LMS_LIVES, -1);
if(tl < lms_lowest_lives)
lms_lowest_lives = tl;
if(tl <= 0)
if(IS_BOT_CLIENT(frag_target))
bot_clear(frag_target);
frag_target.frags = FRAGS_LMS_LOSER;
- PlayerScore_Add(frag_target, SP_LMS_RANK, pl_cnt);
+ GameRules_scoring_add(frag_target, LMS_RANK, pl_cnt);
}
}
M_ARGV(2, float) = 0; // frag score
if(item.itemdef == ITEM_ExtraLife)
{
Send_Notification(NOTIF_ONE, toucher, MSG_CENTER, CENTER_EXTRALIVES);
- PlayerScore_Add(toucher, SP_LMS_LIVES, autocvar_g_lms_extra_lives);
+ GameRules_scoring_add(toucher, LMS_LIVES, autocvar_g_lms_extra_lives);
return MUT_ITEMTOUCH_PICKUP;
}
FOREACH_CLIENT(true, {
if(it.race_place)
{
- s = PlayerScore_Add(it, SP_RACE_FASTEST, 0);
+ s = GameRules_scoring_add(it, RACE_FASTEST, 0);
if(!s)
it.race_place = 0;
}
entity player = M_ARGV(0, entity);
if(g_race_qualifying)
- if(PlayerScore_Add(player, SP_RACE_FASTEST, 0))
+ if(GameRules_scoring_add(player, RACE_FASTEST, 0))
player.frags = FRAGS_LMS_LOSER;
else
player.frags = FRAGS_SPECTATOR;
if (this != attacker) {
float realdmg = damage - excess;
if (IS_PLAYER(attacker)) {
- PlayerScore_Add(attacker, SP_DMG, realdmg);
+ GameRules_scoring_add(attacker, DMG, realdmg);
}
if (IS_PLAYER(this)) {
- PlayerScore_Add(this, SP_DMGTAKEN, realdmg);
+ GameRules_scoring_add(this, DMGTAKEN, realdmg);
}
}
#include "../common/deathtypes/all.qh"
#include "../common/notifications/all.qh"
#include "../common/mapinfo.qh"
+#include <common/gamemodes/rules.qh>
#include <common/net_linked.qh>
#include <common/state.qh>
#include "../common/triggers/subs.qh"
float s;
if(g_race_qualifying)
{
- s = PlayerScore_Add(e, SP_RACE_FASTEST, 0);
+ s = GameRules_scoring_add(e, RACE_FASTEST, 0);
if(!s || t < s)
- PlayerScore_Add(e, SP_RACE_FASTEST, t - s);
+ GameRules_scoring_add(e, RACE_FASTEST, t - s);
}
else
{
- s = PlayerScore_Add(e, SP_RACE_FASTEST, 0);
+ s = GameRules_scoring_add(e, RACE_FASTEST, 0);
if(!s || t < s)
- PlayerScore_Add(e, SP_RACE_FASTEST, t - s);
+ GameRules_scoring_add(e, RACE_FASTEST, t - s);
- s = PlayerScore_Add(e, SP_RACE_TIME, 0);
+ s = GameRules_scoring_add(e, RACE_TIME, 0);
snew = TIME_ENCODE(time - game_starttime);
- PlayerScore_Add(e, SP_RACE_TIME, snew - s);
- l = PlayerTeamScore_Add(e, SP_RACE_LAPS, ST_RACE_LAPS, 1);
+ GameRules_scoring_add(e, RACE_TIME, snew - s);
+ l = GameRules_scoring_add_team(e, RACE_LAPS, 1);
if(autocvar_fraglimit)
if(l >= autocvar_fraglimit)
entity oth = race_checkpoint_lastplayers[cp];
if(oth)
{
- mylaps = PlayerScore_Add(e, SP_RACE_LAPS, 0);
+ mylaps = GameRules_scoring_add(e, RACE_LAPS, 0);
lother = race_checkpoint_lastlaps[cp];
othtime = race_checkpoint_lasttimes[cp];
}
// links on CP entities)
float l;
- l = PlayerScore_Add(e, SP_RACE_LAPS, 0);
+ l = GameRules_scoring_add(e, RACE_LAPS, 0);
if(CS(e).race_completed)
return l; // not fractional
*/
float PlayerTeamScore_Add(entity player, PlayerScoreField pscorefield, float tscorefield, float score);
-/**
- * Adds to the generic score fields for both the player and the team.
- */
-#define PlayerTeamScore_AddScore(p, s) PlayerTeamScore_Add(p, SP_SCORE, ST_SCORE, s)
-
/**
* Set the label of a team score item, as well as the scoring flags.
*/