void dom_EventLog(string mode, float team_before, entity actor) // use an alias for easy changing and quick editing later
{
if(autocvar_sv_eventlog)
- GameLogEcho(strcat(":dom:", mode, ":", ftos(team_before), ((actor != world) ? (strcat(":", ftos(actor.playerid))) : "")));
+ GameLogEcho(strcat(":dom:", mode, ":", ftos(team_before), ((actor != NULL) ? (strcat(":", ftos(actor.playerid))) : "")));
}
void set_dom_state(entity e)
this.cnt = -1;
dom_EventLog("taken", this.team, this.dmg_inflictor);
- this.dmg_inflictor = world;
+ this.dmg_inflictor = NULL;
this.goalentity = head;
this.model = head.mdl;
if(domination_roundbased)
bprint(sprintf("^3%s^3%s\n", head.netname, this.message));
else
- Send_Notification(NOTIF_ALL, world, MSG_INFO, INFO_DOMINATION_CAPTURE_TIME, head.netname, this.message, points, wait_time);
+ 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);
else
- this.enemy = world;
+ this.enemy = NULL;
if (head.noise != "")
if(this.enemy)
WaypointSprite_UpdateSprites(this.sprite, msg, WP_Null, WP_Null);
total_pps = 0, pps_red = 0, pps_blue = 0, pps_yellow = 0, pps_pink = 0;
- for(head = world; (head = find(head, classname, "dom_controlpoint")) != world; )
FOREACH_ENTITY_CLASS("dom_controlpoint", true, LAMBDA(
if (autocvar_g_domination_point_amt)
points = autocvar_g_domination_point_amt;
PlayerScore_Add(this.enemy, SP_DOM_TICKS, fragamt);
}
else
- this.enemy = world;
+ this.enemy = NULL;
}
}
-void dompointtouch(entity this)
+void dompointtouch(entity this, entity toucher)
{
- if (!IS_PLAYER(other))
+ if (!IS_PLAYER(toucher))
return;
- if (other.health < 1)
+ if (toucher.health < 1)
return;
if(round_handler_IsActive() && !round_handler_IsRoundStarted())
return;
// only valid teams can claim it
- entity head = find(world, classname, "dom_team");
- while (head && head.team != other.team)
+ entity head = find(NULL, classname, "dom_team");
+ while (head && head.team != toucher.team)
head = find(head, classname, "dom_team");
if (!head || head.netname == "" || head == this.goalentity)
return;
this.team = this.goalentity.team; // this stores the PREVIOUS team!
- this.cnt = other.team;
+ this.cnt = toucher.team;
this.owner = head; // team to switch to after the delay
- this.dmg_inflictor = other;
+ this.dmg_inflictor = toucher;
// this.state = 1;
// this.delay = time + cvar("g_domination_point_capturetime");
//this.think = dompoint_captured;
// go to neutral team in the mean time
- head = find(world, classname, "dom_team");
+ head = find(NULL, classname, "dom_team");
while (head && head.netname != "")
head = find(head, classname, "dom_team");
- if(head == world)
+ if(head == NULL)
return;
WaypointSprite_UpdateSprites(this.sprite, WP_DomNeut, WP_Null, WP_Null);
this.modelindex = head.dmg;
this.skin = head.skin;
- this.enemy = other; // individual player scoring
- this.enemy_playerid = other.playerid;
+ this.enemy = toucher; // individual player scoring
+ this.enemy_playerid = toucher.playerid;
dompoint_captured(this);
}
{
entity head;
// find the spawnfunc_dom_team representing unclaimed points
- head = find(world, classname, "dom_team");
+ head = find(NULL, classname, "dom_team");
while(head && head.netname != "")
head = find(head, classname, "dom_team");
if (!head)
- objerror("no spawnfunc_dom_team with netname \"\" found\n");
+ objerror(this, "no spawnfunc_dom_team with netname \"\" found\n");
// copy important properties from spawnfunc_dom_team entity
this.goalentity = head;
float total_controlpoints;
void Domination_count_controlpoints()
{
- entity e;
total_controlpoints = redowned = blueowned = yellowowned = pinkowned = 0;
- for(e = world; (e = find(e, classname, "dom_controlpoint")) != world; )
+ FOREACH_ENTITY_CLASS("dom_controlpoint", true,
{
++total_controlpoints;
- redowned += (e.goalentity.team == NUM_TEAM_1);
- blueowned += (e.goalentity.team == NUM_TEAM_2);
- yellowowned += (e.goalentity.team == NUM_TEAM_3);
- pinkowned += (e.goalentity.team == NUM_TEAM_4);
- }
+ redowned += (it.goalentity.team == NUM_TEAM_1);
+ blueowned += (it.goalentity.team == NUM_TEAM_2);
+ yellowowned += (it.goalentity.team == NUM_TEAM_3);
+ pinkowned += (it.goalentity.team == NUM_TEAM_4);
+ });
}
float Domination_GetWinnerTeam()
{
if(round_handler_GetEndTime() > 0 && round_handler_GetEndTime() - time <= 0)
{
- Send_Notification(NOTIF_ALL, world, MSG_CENTER, CENTER_ROUND_OVER);
- Send_Notification(NOTIF_ALL, world, MSG_INFO, INFO_ROUND_OVER);
+ Send_Notification(NOTIF_ALL, NULL, MSG_CENTER, CENTER_ROUND_OVER);
+ Send_Notification(NOTIF_ALL, NULL, MSG_INFO, INFO_ROUND_OVER);
round_handler_Init(5, autocvar_g_domination_warmup, autocvar_g_domination_round_timelimit);
return 1;
}
if(winner_team > 0)
{
- Send_Notification(NOTIF_ALL, world, MSG_CENTER, APP_TEAM_NUM(winner_team, CENTER_ROUND_TEAM_WIN));
- Send_Notification(NOTIF_ALL, world, MSG_INFO, APP_TEAM_NUM(winner_team, INFO_ROUND_TEAM_WIN));
+ Send_Notification(NOTIF_ALL, NULL, MSG_CENTER, APP_TEAM_NUM(winner_team, CENTER_ROUND_TEAM_WIN));
+ Send_Notification(NOTIF_ALL, NULL, MSG_INFO, APP_TEAM_NUM(winner_team, INFO_ROUND_TEAM_WIN));
TeamScore_AddToTeam(winner_team, ST_DOM_CAPS, +1);
}
else if(winner_team == -1)
{
- Send_Notification(NOTIF_ALL, world, MSG_CENTER, CENTER_ROUND_TIED);
- Send_Notification(NOTIF_ALL, world, MSG_INFO, INFO_ROUND_TIED);
+ Send_Notification(NOTIF_ALL, NULL, MSG_CENTER, CENTER_ROUND_TIED);
+ Send_Notification(NOTIF_ALL, NULL, MSG_INFO, INFO_ROUND_TIED);
}
round_handler_Init(5, autocvar_g_domination_warmup, autocvar_g_domination_round_timelimit);
M_ARGV(0, float) = domination_teams;
string ret_string = "dom_team";
- entity head = find(world, classname, ret_string);
+ entity head = find(NULL, classname, ret_string);
while(head)
{
if(head.netname != "")
{
total_pps = 0, pps_red = 0, pps_blue = 0, pps_yellow = 0, pps_pink = 0;
FOREACH_CLIENT(IS_PLAYER(it), LAMBDA(
- WITHSELF(it, PutClientInServer());
+ PutClientInServer(it);
if(domination_roundbased)
it.player_blocked = 1;
if(IS_REAL_CLIENT(it))
set_dom_state(it);
));
- return 1;
+ return true;
}
MUTATOR_HOOKFUNCTION(dom, PlayerSpawn)
player.player_blocked = 1;
else
player.player_blocked = 0;
- return false;
}
MUTATOR_HOOKFUNCTION(dom, ClientConnect)
}
// scoreboard setup
-void ScoreRules_dom(float teams)
+void ScoreRules_dom(int teams)
{
if(domination_roundbased)
{
void dom_DelayedInit(entity this) // Do this check with a delay so we can wait for teams to be set up.
{
// if no teams are found, spawn defaults
- if(find(world, classname, "dom_team") == world || autocvar_g_domination_teams_override >= 2)
+ if(find(NULL, classname, "dom_team") == NULL || autocvar_g_domination_teams_override >= 2)
{
LOG_TRACE("No \"dom_team\" entities found on this map, creating them anyway.\n");
domination_teams = bound(2, ((autocvar_g_domination_teams_override < 2) ? autocvar_g_domination_default_teams : autocvar_g_domination_teams_override), 4);
dom_spawnteams(domination_teams);
}
- CheckAllowedTeams(world);
- domination_teams = ((c4>=0) ? 4 : (c3>=0) ? 3 : 2);
+ CheckAllowedTeams(NULL);
+ //domination_teams = ((c4>=0) ? 4 : (c3>=0) ? 3 : 2);
+
+ int teams = 0;
+ if(c1 >= 0) teams |= BIT(0);
+ if(c2 >= 0) teams |= BIT(1);
+ if(c3 >= 0) teams |= BIT(2);
+ if(c4 >= 0) teams |= BIT(3);
+ domination_teams = teams;
domination_roundbased = autocvar_g_domination_roundbased;
void dom_Initialize()
{
g_domination = true;
- InitializeEntity(world, dom_DelayedInit, INITPRIO_GAMETYPE);
+ InitializeEntity(NULL, dom_DelayedInit, INITPRIO_GAMETYPE);
}
#endif