X-Git-Url: https://de.git.xonotic.org/?a=blobdiff_plain;f=qcsrc%2Fserver%2Fdomination.qc;h=9e56023cb500ebb5425d08321fbff54d55d4a7e8;hb=d7931068ce37d3f05c0f4e4f052ff8e43ac9f0e4;hp=10fc2a1ab4aa190bbfa09c83ed37b75c51e650f5;hpb=ac46eb66c927d1d4c0c61f1ada5efe7fc847ac63;p=xonotic%2Fxonotic-data.pk3dir.git diff --git a/qcsrc/server/domination.qc b/qcsrc/server/domination.qc index 10fc2a1ab..9e56023cb 100644 --- a/qcsrc/server/domination.qc +++ b/qcsrc/server/domination.qc @@ -21,12 +21,34 @@ Note: The only teams who can use dom control points are identified by spawnfunc_ .entity sprite; .float captime; +// 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 total_pps; +float pps_red; +float pps_blue; +float pps_yellow; +float pps_pink; +void set_dom_state(entity e) +{ + e.dom_total_pps = total_pps; + e.dom_pps_red = pps_red; + e.dom_pps_blue = pps_blue; + if(c3 >= 0) + e.dom_pps_yellow = pps_yellow; + if(c4 >= 0) + e.dom_pps_pink = pps_pink; +} + void() dom_controlpoint_setup; void LogDom(string mode, float team_before, entity actor) { string s; - if(!cvar("sv_eventlog")) + if(!autocvar_sv_eventlog) return; s = strcat(":dom:", mode); s = strcat(s, ":", ftos(team_before)); @@ -38,8 +60,8 @@ void() dom_spawnteams; void dompoint_captured () { - local entity head; - local float old_delay, old_team, real_team; + entity head; + float old_delay, old_team, real_team; // now that the delay has expired, switch to the latest team to lay claim to this point head = self.owner; @@ -64,12 +86,12 @@ void dompoint_captured () //bprint("\n"); float points, wait_time; - if (cvar("g_domination_point_amt")) - points = cvar("g_domination_point_amt"); + if (autocvar_g_domination_point_amt) + points = autocvar_g_domination_point_amt; else points = self.frags; - if (cvar("g_domination_point_rate")) - wait_time = cvar("g_domination_point_rate"); + if (autocvar_g_domination_point_rate) + wait_time = autocvar_g_domination_point_rate; else wait_time = self.wait; @@ -86,13 +108,13 @@ void dompoint_captured () if (head.noise != "") if(self.enemy) - sound(self.enemy, CHAN_AUTO, head.noise, VOL_BASE, ATTN_NORM); + sound(self.enemy, CH_TRIGGER, head.noise, VOL_BASE, ATTN_NORM); else - sound(self, CHAN_TRIGGER, head.noise, VOL_BASE, ATTN_NORM); + sound(self, CH_TRIGGER, head.noise, VOL_BASE, ATTN_NORM); if (head.noise1 != "") play2all(head.noise1); - //self.nextthink = time + cvar("g_domination_point_rate"); + //self.nextthink = time + autocvar_g_domination_point_rate; //self.think = dompointthink; self.delay = time + wait_time; @@ -120,13 +142,44 @@ void dompoint_captured () break; case COLOR_TEAM4: WaypointSprite_UpdateSprites(self.sprite, "dom-pink", "", ""); - break; } + + 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; ) + { + if (autocvar_g_domination_point_amt) + points = autocvar_g_domination_point_amt; + else + points = head.frags; + if (autocvar_g_domination_point_rate) + wait_time = autocvar_g_domination_point_rate; + else + wait_time = head.wait; + switch(head.goalentity.team) + { + case COLOR_TEAM1: + pps_red += points/wait_time; + break; + case COLOR_TEAM2: + pps_blue += points/wait_time; + break; + case COLOR_TEAM3: + pps_yellow += points/wait_time; + break; + case COLOR_TEAM4: + pps_pink += points/wait_time; + } + 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); +} void AnimateDomPoint() { @@ -143,7 +196,7 @@ void AnimateDomPoint() void dompointthink() { - local float fragamt; + float fragamt; self.nextthink = time + 0.1; @@ -157,8 +210,8 @@ void dompointthink() if (gameover || self.delay > time || time < game_starttime) // game has ended, don't keep giving points return; - if(cvar("g_domination_point_rate")) - self.delay = time + cvar("g_domination_point_rate"); + if(autocvar_g_domination_point_rate) + self.delay = time + autocvar_g_domination_point_rate; else self.delay = time + self.wait; @@ -166,8 +219,8 @@ void dompointthink() // NOTE: this defaults to 0 if (self.goalentity.netname != "") { - if(cvar("g_domination_point_amt")) - fragamt = cvar("g_domination_point_amt"); + if(autocvar_g_domination_point_amt) + fragamt = autocvar_g_domination_point_amt; else fragamt = self.DOMPOINTFRAGS; TeamScore_AddToTeam(self.goalentity.team, ST_SCORE, fragamt); @@ -186,7 +239,7 @@ void dompointthink() void dompointtouch() { - local entity head; + entity head; if (other.classname != "player") return; if (other.health < 1) @@ -234,7 +287,7 @@ void dompointtouch() self.enemy = other; // individual player scoring self.enemy_playerid = other.playerid; dompoint_captured(); -}; +} /*QUAKED spawnfunc_dom_team (0 .5 .8) (-32 -32 -24) (32 32 32) Team declaration for Domination gameplay, this allows you to decide what team @@ -264,7 +317,7 @@ Keys: void spawnfunc_dom_team() { - if(!g_domination || cvar("g_domination_teams_override") >= 2) + if(!g_domination || autocvar_g_domination_teams_override >= 2) { remove(self); return; @@ -283,11 +336,11 @@ void spawnfunc_dom_team() // this would have to be changed if used in quakeworld if(self.cnt) self.team = self.cnt + 1; // WHY are these different anyway? -}; +} void dom_controlpoint_setup() { - local entity head; + entity head; // find the spawnfunc_dom_team representing unclaimed points head = find(world, classname, "dom_team"); while(head && head.netname != "") @@ -305,11 +358,23 @@ void dom_controlpoint_setup() if(!self.message) self.message = " has captured a control point"; - if(!self.DOMPOINTFRAGS) + if(self.DOMPOINTFRAGS <= 0) self.DOMPOINTFRAGS = 1; - if(!self.wait) + if(self.wait <= 0) self.wait = 5; + float points, waittime; + if (autocvar_g_domination_point_amt) + points = autocvar_g_domination_point_amt; + else + points = self.frags; + if (autocvar_g_domination_point_rate) + waittime = autocvar_g_domination_point_rate; + else + waittime = self.wait; + + total_pps += points/waittime; + if(!self.t_width) self.t_width = 0.02; // frame animation rate if(!self.t_length) @@ -325,9 +390,8 @@ void dom_controlpoint_setup() droptofloor(); waypoint_spawnforitem(self); - WaypointSprite_SpawnFixed("dom-neut", self.origin + '0 0 32', self, sprite); - WaypointSprite_UpdateTeamRadar(self.sprite, RADARICON_DOMPOINT, '0 1 1'); -}; + WaypointSprite_SpawnFixed("dom-neut", self.origin + '0 0 32', self, sprite, RADARICON_DOMPOINT, '0 1 1'); +} @@ -339,8 +403,8 @@ void dom_controlpoint_setup() float c1, c2, c3, c4, totalteams, smallestteam, smallestteam_count, selectedteam; float balance_teams, force_balance, balance_type; - balance_teams = cvar("g_balance_teams"); - balance_teams = cvar("g_balance_teams_force"); + balance_teams = autocvar_g_balance_teams; + balance_teams = autocvar_g_balance_teams_force; c1 = c2 = c3 = c4 = -1; totalteams = 0; @@ -541,14 +605,14 @@ void spawnfunc_dom_controlpoint() //if(!self.glow_size) // self.glow_size = cvar("g_domination_point_glow"); self.effects = self.effects | EF_LOWPRECISION; - if (cvar("g_domination_point_fullbright")) + if (autocvar_g_domination_point_fullbright) self.effects |= EF_FULLBRIGHT; -}; +} // 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) { - local entity oldself; + entity oldself; oldself = self; self = spawn(); self.classname = "dom_team"; @@ -571,11 +635,11 @@ void dom_spawnteam (string teamname, float teamcolor, string pointmodel, float p //eprint(self); self = oldself; -}; +} void dom_spawnpoint(vector org) { - local entity oldself; + entity oldself; oldself = self; self = spawn(); self.classname = "dom_controlpoint"; @@ -584,16 +648,16 @@ void dom_spawnpoint(vector org) setorigin(self, org); spawnfunc_dom_controlpoint(); self = oldself; -}; +} // spawn some default teams if the map is not set up for domination void dom_spawnteams() { float numteams; - if(cvar("g_domination_teams_override") < 2) - numteams = cvar("g_domination_default_teams"); + if(autocvar_g_domination_teams_override < 2) + numteams = autocvar_g_domination_default_teams; else - numteams = cvar("g_domination_teams_override"); + numteams = autocvar_g_domination_teams_override; // LordHavoc: edit this if you want to change defaults dom_spawnteam("Red", COLOR_TEAM1-1, "models/domination/dom_red.md3", 0, "domination/claim.wav", "", "Red team has captured a control point"); dom_spawnteam("Blue", COLOR_TEAM2-1, "models/domination/dom_blue.md3", 0, "domination/claim.wav", "", "Blue team has captured a control point"); @@ -602,39 +666,32 @@ void dom_spawnteams() if(numteams > 3) dom_spawnteam("Pink", COLOR_TEAM4-1, "models/domination/dom_pink.md3", 0, "domination/claim.wav", "", "Pink team has captured a control point"); dom_spawnteam("", 0, "models/domination/dom_unclaimed.md3", 0, "", "", ""); -}; +} void dom_delayedinit() { - local entity head; + entity head; // if no teams are found, spawn defaults, if custom teams are set, use them - if (find(world, classname, "dom_team") == world || cvar("g_domination_teams_override") >= 2) + if (find(world, classname, "dom_team") == world || autocvar_g_domination_teams_override >= 2) dom_spawnteams(); // if no control points are found, spawn defaults if (find(world, classname, "dom_controlpoint") == world) { - // here follow default domination points for each map - /* - if (world.model == "maps/e1m1.bsp") - { - dom_spawnpoint('0 0 0'); - } - else - */ + // TODO in a few months (maybe 2011/08): change this into error() and remove this very poor dom point selection + backtrace("This map contains no dom_controlpoint entities. A very poor dom point placement will be chosen. Please fix the map."); + + // if no supported map was found, make every deathmatch spawn a point + head = find(world, classname, "info_player_deathmatch"); + while (head) { - // if no supported map was found, make every deathmatch spawn a point - head = find(world, classname, "info_player_deathmatch"); - while (head) - { - dom_spawnpoint(head.origin); - head = find(head, classname, "info_player_deathmatch"); - } + dom_spawnpoint(head.origin); + head = find(head, classname, "info_player_deathmatch"); } } ScoreRules_dom(); -}; +} void dom_init() { @@ -648,5 +705,11 @@ void dom_init() precache_model("models/domination/dom_unclaimed.md3"); precache_sound("domination/claim.wav"); InitializeEntity(world, dom_delayedinit, INITPRIO_GAMETYPE); -}; + + 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(c3 >= 0) addstat(STAT_DOM_PPS_YELLOW, AS_FLOAT, dom_pps_yellow); + if(c4 >= 0) addstat(STAT_DOM_PPS_PINK, AS_FLOAT, dom_pps_pink); +}