X-Git-Url: http://de.git.xonotic.org/?a=blobdiff_plain;f=qcsrc%2Fserver%2Fmutators%2Fmutator%2Fgamemode_domination.qc;h=55996db47cfcb5fe1f189b26ebd48f2330fe6162;hb=61bd69dc7a8e218b6beff349fd332eb7ac8a81ae;hp=5195177dfcb1b493093e7ad385b590158c2f02ad;hpb=948c08402a7b9b7af36059104937650e343ecefe;p=xonotic%2Fxonotic-data.pk3dir.git diff --git a/qcsrc/server/mutators/mutator/gamemode_domination.qc b/qcsrc/server/mutators/mutator/gamemode_domination.qc index 5195177df..55996db47 100644 --- a/qcsrc/server/mutators/mutator/gamemode_domination.qc +++ b/qcsrc/server/mutators/mutator/gamemode_domination.qc @@ -1,3 +1,4 @@ +#include "gamemode_domination.qh" #ifndef GAMEMODE_DOMINATION_H #define GAMEMODE_DOMINATION_H @@ -10,19 +11,19 @@ void dom_Initialize(); REGISTER_MUTATOR(dom, false) { - int fraglimit_override = autocvar_g_domination_point_limit; - if (autocvar_g_domination_roundbased && autocvar_g_domination_roundbased_point_limit) - fraglimit_override = autocvar_g_domination_roundbased_point_limit; - - ActivateTeamplay(); - SetLimits(fraglimit_override, autocvar_g_domination_point_leadlimit, -1, -1); - have_team_spawns = -1; // request team spawns - MUTATOR_ONADD { if (time > 1) // game loads at time 1 error("This is a game type and it cannot be added at runtime."); dom_Initialize(); + + int fraglimit_override = autocvar_g_domination_point_limit; + if (autocvar_g_domination_roundbased && autocvar_g_domination_roundbased_point_limit) + fraglimit_override = autocvar_g_domination_roundbased_point_limit; + + ActivateTeamplay(); + SetLimits(fraglimit_override, autocvar_g_domination_point_leadlimit, -1, -1); + have_team_spawns = -1; // request team spawns } MUTATOR_ONREMOVE @@ -36,17 +37,14 @@ REGISTER_MUTATOR(dom, false) // score rule declarations const float ST_DOM_TICKS = 1; -const float SP_DOM_TICKS = 4; -const float SP_DOM_TAKES = 5; const float ST_DOM_CAPS = 1; -const float SP_DOM_CAPS = 4; // pps: points per second -.float dom_total_pps; -.float dom_pps_red; -.float dom_pps_blue; -.float dom_pps_yellow; -.float dom_pps_pink; +.float dom_total_pps = _STAT(DOM_TOTAL_PPS); +.float dom_pps_red = _STAT(DOM_PPS_RED); +.float dom_pps_blue = _STAT(DOM_PPS_BLUE); +.float dom_pps_yellow = _STAT(DOM_PPS_YELLOW); +.float dom_pps_pink = _STAT(DOM_PPS_PINK); float total_pps; float pps_red; float pps_blue; @@ -65,7 +63,7 @@ float domination_teams; #ifdef IMPLEMENTATION -#include "../../teamplay.qh" +#include bool g_domination; @@ -167,40 +165,31 @@ void dompoint_captured () 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; else - points = head.frags; + points = it.frags; if (autocvar_g_domination_point_rate) wait_time = autocvar_g_domination_point_rate; else - wait_time = head.wait; - switch(head.goalentity.team) + wait_time = it.wait; + switch(it.goalentity.team) { - case NUM_TEAM_1: - pps_red += points/wait_time; - break; - case NUM_TEAM_2: - pps_blue += points/wait_time; - break; - case NUM_TEAM_3: - pps_yellow += points/wait_time; - break; - case NUM_TEAM_4: - pps_pink += points/wait_time; - break; + case NUM_TEAM_1: pps_red += points/wait_time; break; + case NUM_TEAM_2: pps_blue += points/wait_time; break; + case NUM_TEAM_3: pps_yellow += points/wait_time; break; + case NUM_TEAM_4: pps_pink += points/wait_time; break; } total_pps += points/wait_time; - } + )); WaypointSprite_UpdateTeamRadar(self.sprite, RADARICON_DOMPOINT, colormapPaletteColor(self.goalentity.team - 1, 0)); WaypointSprite_Ping(self.sprite); self.captime = time; - FOR_EACH_REALCLIENT(head) - set_dom_state(head); + FOREACH_CLIENT(IS_REAL_CLIENT(it), LAMBDA(set_dom_state(it))); } void AnimateDomPoint() @@ -315,8 +304,10 @@ void dompointtouch() dompoint_captured(); } -void dom_controlpoint_setup() -{SELFPARAM(); +void dom_controlpoint_setup(entity this); +void dom_controlpoint_setup_self() { SELFPARAM(); dom_controlpoint_setup(this); } +void dom_controlpoint_setup(entity this) +{ entity head; // find the spawnfunc_dom_team representing unclaimed points head = find(world, classname, "dom_team"); @@ -431,8 +422,8 @@ float Domination_CheckWinner() if(winner_team > 0) { - Send_Notification(NOTIF_ALL, world, MSG_CENTER, APP_TEAM_NUM_4(winner_team, CENTER_ROUND_TEAM_WIN_)); - Send_Notification(NOTIF_ALL, world, MSG_INFO, APP_TEAM_NUM_4(winner_team, INFO_ROUND_TEAM_WIN_)); + 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)); TeamScore_AddToTeam(winner_team, ST_DOM_CAPS, +1); } else if(winner_team == -1) @@ -453,26 +444,24 @@ float Domination_CheckPlayers() void Domination_RoundStart() { - entity e; - FOR_EACH_PLAYER(e) - e.player_blocked = 0; + FOREACH_CLIENT(IS_PLAYER(it), LAMBDA(it.player_blocked = false)); } //go to best items, or control points you don't own -void havocbot_role_dom() -{SELFPARAM(); - if(self.deadflag != DEAD_NO) +void havocbot_role_dom(entity this) +{ + if(IS_DEAD(this)) return; - if (self.bot_strategytime < time) + if (this.bot_strategytime < time) { - self.bot_strategytime = time + autocvar_bot_ai_strategyinterval; - navigation_goalrating_start(); - havocbot_goalrating_controlpoints(10000, self.origin, 15000); - havocbot_goalrating_items(8000, self.origin, 8000); - //havocbot_goalrating_enemyplayers(3000, self.origin, 2000); - //havocbot_goalrating_waypoints(1, self.origin, 1000); - navigation_goalrating_end(); + this.bot_strategytime = time + autocvar_bot_ai_strategyinterval; + navigation_goalrating_start(this); + havocbot_goalrating_controlpoints(this, 10000, this.origin, 15000); + havocbot_goalrating_items(this, 8000, this.origin, 8000); + //havocbot_goalrating_enemyplayers(this, 3000, this.origin, 2000); + //havocbot_goalrating_waypoints(1, this.origin, 1000); + navigation_goalrating_end(this); } } @@ -507,15 +496,14 @@ MUTATOR_HOOKFUNCTION(dom, GetTeamCount) MUTATOR_HOOKFUNCTION(dom, reset_map_players) {SELFPARAM(); total_pps = 0, pps_red = 0, pps_blue = 0, pps_yellow = 0, pps_pink = 0; - entity e; - FOR_EACH_PLAYER(e) - { - setself(e); + FOREACH_CLIENT(IS_PLAYER(it), LAMBDA( + setself(it); PutClientInServer(); - self.player_blocked = 1; + if(domination_roundbased) + self.player_blocked = 1; if(IS_REAL_CLIENT(self)) set_dom_state(self); - } + )); return 1; } @@ -551,7 +539,7 @@ spawnfunc(dom_controlpoint) remove(self); return; } - self.think = dom_controlpoint_setup; + self.think = dom_controlpoint_setup_self; self.nextthink = time + 0.1; self.reset = dom_controlpoint_setup; @@ -639,17 +627,18 @@ void ScoreRules_dom(float teams) } // code from here on is just to support maps that don't have control point and team entities -void dom_spawnteam (string teamname, float teamcolor, string pointmodel, float pointskin, string capsound, string capnarration, string capmessage) +void dom_spawnteam (string teamname, float teamcolor, string pointmodel, float pointskin, Sound capsound, string capnarration, string capmessage) {SELFPARAM(); + TC(Sound, capsound); setself(spawn()); self.classname = "dom_team"; - self.netname = teamname; + self.netname = strzone(teamname); self.cnt = teamcolor; self.model = pointmodel; self.skin = pointskin; - self.noise = capsound; - self.noise1 = capnarration; - self.message = capmessage; + self.noise = strzone(Sound_fixpath(capsound)); + self.noise1 = strzone(capnarration); + self.message = strzone(capmessage); // this code is identical to spawnfunc_dom_team _setmodel(self, self.model); // precision not needed @@ -664,12 +653,12 @@ void dom_spawnteam (string teamname, float teamcolor, string pointmodel, float p setself(this); } -void _spawnfunc_dom_controlpoint() { SELFPARAM(); spawnfunc_dom_controlpoint(self); } +void self_spawnfunc_dom_controlpoint() { SELFPARAM(); spawnfunc_dom_controlpoint(self); } void dom_spawnpoint(vector org) {SELFPARAM(); setself(spawn()); self.classname = "dom_controlpoint"; - self.think = _spawnfunc_dom_controlpoint; + self.think = self_spawnfunc_dom_controlpoint; self.nextthink = time; setorigin(self, org); spawnfunc_dom_controlpoint(this); @@ -677,23 +666,24 @@ void dom_spawnpoint(vector org) } // spawn some default teams if the map is not set up for domination -void dom_spawnteams(float teams) +void dom_spawnteams(int teams) { - dom_spawnteam("Red", NUM_TEAM_1-1, "models/domination/dom_red.md3", 0, SND(DOM_CLAIM), "", "Red team has captured a control point"); - dom_spawnteam("Blue", NUM_TEAM_2-1, "models/domination/dom_blue.md3", 0, SND(DOM_CLAIM), "", "Blue team has captured a control point"); + TC(int, teams); + dom_spawnteam(Team_ColoredFullName(NUM_TEAM_1), NUM_TEAM_1-1, "models/domination/dom_red.md3", 0, SND_DOM_CLAIM, "", "Red team has captured a control point"); + dom_spawnteam(Team_ColoredFullName(NUM_TEAM_2), NUM_TEAM_2-1, "models/domination/dom_blue.md3", 0, SND_DOM_CLAIM, "", "Blue team has captured a control point"); if(teams >= 3) - dom_spawnteam("Yellow", NUM_TEAM_3-1, "models/domination/dom_yellow.md3", 0, SND(DOM_CLAIM), "", "Yellow team has captured a control point"); + dom_spawnteam(Team_ColoredFullName(NUM_TEAM_3), NUM_TEAM_3-1, "models/domination/dom_yellow.md3", 0, SND_DOM_CLAIM, "", "Yellow team has captured a control point"); if(teams >= 4) - dom_spawnteam("Pink", NUM_TEAM_4-1, "models/domination/dom_pink.md3", 0, SND(DOM_CLAIM), "", "Pink team has captured a control point"); - dom_spawnteam("", 0, "models/domination/dom_unclaimed.md3", 0, "", "", ""); + dom_spawnteam(Team_ColoredFullName(NUM_TEAM_4), NUM_TEAM_4-1, "models/domination/dom_pink.md3", 0, SND_DOM_CLAIM, "", "Pink team has captured a control point"); + dom_spawnteam("", 0, "models/domination/dom_unclaimed.md3", 0, SND_Null, "", ""); } -void dom_DelayedInit() // Do this check with a delay so we can wait for teams to be set up. +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) { - LOG_INFO("No ""dom_team"" entities found on this map, creating them anyway.\n"); + 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); } @@ -701,12 +691,6 @@ void dom_DelayedInit() // Do this check with a delay so we can wait for teams to CheckAllowedTeams(world); domination_teams = ((c4>=0) ? 4 : (c3>=0) ? 3 : 2); - addstat(STAT_DOM_TOTAL_PPS, AS_FLOAT, dom_total_pps); - addstat(STAT_DOM_PPS_RED, AS_FLOAT, dom_pps_red); - addstat(STAT_DOM_PPS_BLUE, AS_FLOAT, dom_pps_blue); - if(domination_teams >= 3) addstat(STAT_DOM_PPS_YELLOW, AS_FLOAT, dom_pps_yellow); - if(domination_teams >= 4) addstat(STAT_DOM_PPS_PINK, AS_FLOAT, dom_pps_pink); - domination_roundbased = autocvar_g_domination_roundbased; ScoreRules_dom(domination_teams);