X-Git-Url: http://de.git.xonotic.org/?a=blobdiff_plain;f=qcsrc%2Fserver%2Fmutators%2Fmutator%2Fgamemode_ctf.qc;h=79ac9994625de1b4a1f05da3ad540dee3d75d876;hb=268f9c69576b6bb929f66d19f0d077d19ba47edd;hp=0383d2e50986537500f104709d771cef84e0d625;hpb=83aad9e1a69d8e924df17cdbad05b015c6c6f0fc;p=xonotic%2Fxonotic-data.pk3dir.git diff --git a/qcsrc/server/mutators/mutator/gamemode_ctf.qc b/qcsrc/server/mutators/mutator/gamemode_ctf.qc index 0383d2e50..79ac99946 100644 --- a/qcsrc/server/mutators/mutator/gamemode_ctf.qc +++ b/qcsrc/server/mutators/mutator/gamemode_ctf.qc @@ -1,6 +1,5 @@ #include "gamemode_ctf.qh" -#ifdef IMPLEMENTATION #ifndef CSQC void ctf_Initialize(); @@ -260,7 +259,7 @@ bool ctf_CaptureShield_CheckStatus(entity p) if(ctf_captureshield_max_ratio <= 0) return false; - s = PlayerScore_Add(p, SP_CTF_CAPS, 0); + 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); @@ -274,7 +273,7 @@ bool ctf_CaptureShield_CheckStatus(entity p) FOREACH_CLIENT(IS_PLAYER(it), LAMBDA( if(DIFF_TEAM(it, p)) continue; - se = PlayerScore_Add(it, SP_CTF_CAPS, 0); + 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); @@ -720,7 +719,7 @@ void ctf_Handle_Pickup(entity flag, entity player, int pickuptype) { 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), "\n"); + LOG_TRACE("pickup_dropped_score is ", ftos(pickup_dropped_score)); PlayerTeamScore_AddScore(player, pickup_dropped_score); ctf_EventLog("pickup", flag.team, player); break; @@ -893,7 +892,7 @@ void ctf_FlagThink(entity this) // sanity checks if(this.mins != CTF_FLAG.m_mins || this.maxs != CTF_FLAG.m_maxs) { // reset the flag boundaries in case it got squished - LOG_TRACE("wtf the flag got squashed?\n"); + LOG_TRACE("wtf the flag got squashed?"); tracebox(this.origin, CTF_FLAG.m_mins, CTF_FLAG.m_maxs, this.origin, MOVE_NOMONSTERS, this); if(!trace_startsolid || this.noalign) // can we resize it without getting stuck? setsize(this, CTF_FLAG.m_mins, CTF_FLAG.m_maxs); } @@ -1019,7 +1018,7 @@ void ctf_FlagThink(entity this) default: // this should never happen { - LOG_TRACE("ctf_FlagThink(): Flag exists with no status?\n"); + LOG_TRACE("ctf_FlagThink(): Flag exists with no status?"); return; } } @@ -1107,7 +1106,7 @@ METHOD(Flag, giveTo, bool(Flag this, entity flag, entity toucher)) case FLAG_CARRY: { - LOG_TRACE("Someone touched a flag even though it was being carried?\n"); + LOG_TRACE("Someone touched a flag even though it was being carried?"); break; } @@ -1235,6 +1234,7 @@ void ctf_FlagSetup(int teamnumber, entity flag) // called when spawning a flag e flag.classname = "item_flag_team"; flag.target = "###item###"; // wut? flag.flags = FL_ITEM | FL_NOTARGET; + IL_PUSH(g_items, flag); flag.solid = SOLID_TRIGGER; flag.takedamage = DAMAGE_NO; flag.damageforcescale = autocvar_g_ctf_flag_damageforcescale; @@ -1528,23 +1528,19 @@ void havocbot_goalrating_ctf_droppedflags(entity this, float ratingscale, vector void havocbot_goalrating_ctf_carrieritems(entity this, float ratingscale, vector org, float sradius) { - entity head; - float t; - head = findchainfloat(bot_pickup, true); - while (head) + IL_EACH(g_items, it.bot_pickup, { // gather health and armor only - if (head.solid) - if (head.health || head.armorvalue) - if (vdist(head.origin - org, <, sradius)) + if (it.solid) + if (it.health || it.armorvalue) + if (vdist(it.origin - org, <, sradius)) { // get the value of the item - t = head.bot_pickupevalfunc(this, head) * 0.0001; + float t = it.bot_pickupevalfunc(this, it) * 0.0001; if (t > 0) - navigation_routerating(this, head, t * ratingscale, 500); + navigation_routerating(this, it, t * ratingscale, 500); } - head = head.chain; - } + }); } void havocbot_ctf_reset_role(entity this) @@ -1965,47 +1961,47 @@ void havocbot_role_ctf_defense(entity this) void havocbot_role_ctf_setrole(entity bot, int role) { - LOG_TRACE(strcat(bot.netname," switched to ")); + string s = "(null)"; switch(role) { case HAVOCBOT_CTF_ROLE_CARRIER: - LOG_TRACE("carrier"); + s = "carrier"; bot.havocbot_role = havocbot_role_ctf_carrier; bot.havocbot_role_timeout = 0; bot.havocbot_cantfindflag = time + 10; bot.bot_strategytime = 0; break; case HAVOCBOT_CTF_ROLE_DEFENSE: - LOG_TRACE("defense"); + s = "defense"; bot.havocbot_role = havocbot_role_ctf_defense; bot.havocbot_role_timeout = 0; break; case HAVOCBOT_CTF_ROLE_MIDDLE: - LOG_TRACE("middle"); + s = "middle"; bot.havocbot_role = havocbot_role_ctf_middle; bot.havocbot_role_timeout = 0; break; case HAVOCBOT_CTF_ROLE_OFFENSE: - LOG_TRACE("offense"); + s = "offense"; bot.havocbot_role = havocbot_role_ctf_offense; bot.havocbot_role_timeout = 0; break; case HAVOCBOT_CTF_ROLE_RETRIEVER: - LOG_TRACE("retriever"); + s = "retriever"; bot.havocbot_previous_role = bot.havocbot_role; bot.havocbot_role = havocbot_role_ctf_retriever; bot.havocbot_role_timeout = time + 10; bot.bot_strategytime = 0; break; case HAVOCBOT_CTF_ROLE_ESCORT: - LOG_TRACE("escort"); + s = "escort"; bot.havocbot_previous_role = bot.havocbot_role; bot.havocbot_role = havocbot_role_ctf_escort; bot.havocbot_role_timeout = time + 30; bot.bot_strategytime = 0; break; } - LOG_TRACE("\n"); + LOG_TRACE(bot.netname, " switched to ", s); } @@ -2422,10 +2418,10 @@ MUTATOR_HOOKFUNCTION(ctf, SV_ParseClientCommand) { switch(argv(1)) { - case "red": _team = NUM_TEAM_1; break; - case "blue": _team = NUM_TEAM_2; break; - case "yellow": if(ctf_teams >= 3) _team = NUM_TEAM_3; break; - case "pink": if(ctf_teams >= 4) _team = NUM_TEAM_4; break; + case "red": if(ctf_teams & BIT(0)) _team = NUM_TEAM_1; break; + case "blue": if(ctf_teams & BIT(1)) _team = NUM_TEAM_2; break; + case "yellow": if(ctf_teams & BIT(2)) _team = NUM_TEAM_3; break; + case "pink": if(ctf_teams & BIT(3)) _team = NUM_TEAM_4; break; } } @@ -2448,7 +2444,7 @@ MUTATOR_HOOKFUNCTION(ctf, SV_ParseClientCommand) MUTATOR_HOOKFUNCTION(ctf, DropSpecialItems) { entity frag_target = M_ARGV(0, entity); - + if(frag_target.flagcarried) ctf_Handle_Throw(frag_target, NULL, DROP_THROW); } @@ -2471,7 +2467,7 @@ Keys: "noise5" sound played when flag touches the ground... */ spawnfunc(item_flag_team1) { - if(!g_ctf) { remove(this); return; } + if(!g_ctf) { delete(this); return; } ctf_FlagSetup(NUM_TEAM_1, this); } @@ -2489,7 +2485,7 @@ Keys: "noise5" sound played when flag touches the ground... */ spawnfunc(item_flag_team2) { - if(!g_ctf) { remove(this); return; } + if(!g_ctf) { delete(this); return; } ctf_FlagSetup(NUM_TEAM_2, this); } @@ -2507,7 +2503,7 @@ Keys: "noise5" sound played when flag touches the ground... */ spawnfunc(item_flag_team3) { - if(!g_ctf) { remove(this); return; } + if(!g_ctf) { delete(this); return; } ctf_FlagSetup(NUM_TEAM_3, this); } @@ -2525,7 +2521,7 @@ Keys: "noise5" sound played when flag touches the ground... */ spawnfunc(item_flag_team4) { - if(!g_ctf) { remove(this); return; } + if(!g_ctf) { delete(this); return; } ctf_FlagSetup(NUM_TEAM_4, this); } @@ -2543,8 +2539,8 @@ Keys: "noise5" sound played when flag touches the ground... */ spawnfunc(item_flag_neutral) { - if(!g_ctf) { remove(this); return; } - if(!cvar("g_ctf_oneflag")) { remove(this); return; } + if(!g_ctf) { delete(this); return; } + if(!cvar("g_ctf_oneflag")) { delete(this); return; } ctf_FlagSetup(0, this); } @@ -2557,7 +2553,7 @@ Keys: "cnt" Scoreboard color of the team (for example 4 is red and 13 is blue)... */ spawnfunc(ctf_team) { - if(!g_ctf) { remove(this); return; } + if(!g_ctf) { delete(this); return; } this.classname = "ctf_team"; this.team = this.cnt + 1; @@ -2587,12 +2583,12 @@ void ctf_ScoreRules(int teams) CheckAllowedTeams(NULL); ScoreRules_basics(teams, SFL_SORT_PRIO_PRIMARY, 0, true); ScoreInfo_SetLabel_TeamScore (ST_CTF_CAPS, "caps", SFL_SORT_PRIO_PRIMARY); - ScoreInfo_SetLabel_PlayerScore(SP_CTF_CAPS, "caps", SFL_SORT_PRIO_SECONDARY); - ScoreInfo_SetLabel_PlayerScore(SP_CTF_CAPTIME, "captime", SFL_LOWER_IS_BETTER | SFL_TIME); - ScoreInfo_SetLabel_PlayerScore(SP_CTF_PICKUPS, "pickups", 0); - ScoreInfo_SetLabel_PlayerScore(SP_CTF_FCKILLS, "fckills", 0); - ScoreInfo_SetLabel_PlayerScore(SP_CTF_RETURNS, "returns", 0); - ScoreInfo_SetLabel_PlayerScore(SP_CTF_DROPS, "drops", SFL_LOWER_IS_BETTER); + ScoreInfo_SetLabel_PlayerScore(SP_CTF_CAPS, "caps", SFL_SORT_PRIO_SECONDARY); + ScoreInfo_SetLabel_PlayerScore(SP_CTF_CAPTIME, "captime", SFL_LOWER_IS_BETTER | SFL_TIME); + ScoreInfo_SetLabel_PlayerScore(SP_CTF_PICKUPS, "pickups", 0); + ScoreInfo_SetLabel_PlayerScore(SP_CTF_FCKILLS, "fckills", 0); + ScoreInfo_SetLabel_PlayerScore(SP_CTF_RETURNS, "returns", 0); + ScoreInfo_SetLabel_PlayerScore(SP_CTF_DROPS, "drops", SFL_LOWER_IS_BETTER); ScoreRules_basics_end(); } @@ -2608,27 +2604,44 @@ void ctf_SpawnTeam (string teamname, int teamcolor) void ctf_DelayedInit(entity this) // Do this check with a delay so we can wait for teams to be set up. { - ctf_teams = 2; + ctf_teams = 0; entity tmp_entity; for(tmp_entity = ctf_worldflaglist; tmp_entity; tmp_entity = tmp_entity.ctf_worldflagnext) { - if(tmp_entity.team == NUM_TEAM_3) { ctf_teams = max(3, ctf_teams); } - if(tmp_entity.team == NUM_TEAM_4) { ctf_teams = max(4, ctf_teams); } + //if(tmp_entity.team == NUM_TEAM_3) { ctf_teams = max(3, ctf_teams); } + //if(tmp_entity.team == NUM_TEAM_4) { ctf_teams = max(4, ctf_teams); } + + switch(tmp_entity.team) + { + case NUM_TEAM_1: BITSET_ASSIGN(ctf_teams, BIT(0)); break; + case NUM_TEAM_2: BITSET_ASSIGN(ctf_teams, BIT(1)); break; + case NUM_TEAM_3: BITSET_ASSIGN(ctf_teams, BIT(2)); break; + case NUM_TEAM_4: BITSET_ASSIGN(ctf_teams, BIT(3)); break; + } if(tmp_entity.team == 0) { ctf_oneflag = true; } } - ctf_teams = bound(2, ctf_teams, 4); + if(NumTeams(ctf_teams) < 2) // somehow, there's not enough flags! + { + ctf_teams = 0; // so set the default red and blue teams + BITSET_ASSIGN(ctf_teams, BIT(0)); + BITSET_ASSIGN(ctf_teams, BIT(1)); + } + + //ctf_teams = bound(2, ctf_teams, 4); // if no teams are found, spawn defaults if(find(NULL, classname, "ctf_team") == NULL) { - LOG_TRACE("No \"ctf_team\" entities found on this map, creating them anyway.\n"); - ctf_SpawnTeam("Red", NUM_TEAM_1); - ctf_SpawnTeam("Blue", NUM_TEAM_2); - if(ctf_teams >= 3) + LOG_TRACE("No \"ctf_team\" entities found on this map, creating them anyway."); + if(ctf_teams & BIT(0)) + ctf_SpawnTeam("Red", NUM_TEAM_1); + if(ctf_teams & BIT(1)) + ctf_SpawnTeam("Blue", NUM_TEAM_2); + if(ctf_teams & BIT(2)) ctf_SpawnTeam("Yellow", NUM_TEAM_3); - if(ctf_teams >= 4) + if(ctf_teams & BIT(3)) ctf_SpawnTeam("Pink", NUM_TEAM_4); } @@ -2645,5 +2658,3 @@ void ctf_Initialize() InitializeEntity(NULL, ctf_DelayedInit, INITPRIO_GAMETYPE); } - -#endif