From: Mario Date: Fri, 12 Oct 2018 10:46:56 +0000 (+1000) Subject: Remove teamplay support from invasion and fix mage only ever teleporting once X-Git-Tag: xonotic-v0.8.5~7^2~1^2~33 X-Git-Url: https://git.rm.cloudns.org/?a=commitdiff_plain;h=e8cdddd1f91bf4c12a80877388eca8ffc4136f9d;p=xonotic%2Fxonotic-data.pk3dir.git Remove teamplay support from invasion and fix mage only ever teleporting once --- diff --git a/qcsrc/common/gamemodes/gamemode/invasion/sv_invasion.qc b/qcsrc/common/gamemodes/gamemode/invasion/sv_invasion.qc index 5039eb1005..5b61762784 100644 --- a/qcsrc/common/gamemodes/gamemode/invasion/sv_invasion.qc +++ b/qcsrc/common/gamemodes/gamemode/invasion/sv_invasion.qc @@ -4,8 +4,6 @@ #include #include -#include - IntrusiveList g_invasion_roundends; IntrusiveList g_invasion_waves; IntrusiveList g_invasion_spawns; @@ -97,7 +95,7 @@ int WinningCondition_Invasion() if(it.winning) { bprint("Invasion: round completed.\n"); - // winners already set (TODO: teamplay support) + // winners already set status = WINNING_YES; break; @@ -232,32 +230,6 @@ void invasion_SpawnChosenMonster(Monster mon) monster.target2 = spawn_point.target2; } - if(teamplay) - { - if(spawn_point && spawn_point.team && inv_monsters_perteam[spawn_point.team] > 0) - monster.team = spawn_point.team; - else - { - RandomSelection_Init(); - if(inv_monsters_perteam[NUM_TEAM_1] > 0) RandomSelection_AddFloat(NUM_TEAM_1, 1, 1); - if(inv_monsters_perteam[NUM_TEAM_2] > 0) RandomSelection_AddFloat(NUM_TEAM_2, 1, 1); - if(invasion_teams >= 3) if(inv_monsters_perteam[NUM_TEAM_3] > 0) { RandomSelection_AddFloat(NUM_TEAM_3, 1, 1); } - if(invasion_teams >= 4) if(inv_monsters_perteam[NUM_TEAM_4] > 0) { RandomSelection_AddFloat(NUM_TEAM_4, 1, 1); } - - monster.team = RandomSelection_chosen_float; - } - - monster_setupcolors(monster); - - if(monster.sprite) - { - WaypointSprite_UpdateTeamRadar(monster.sprite, RADARICON_DANGER, ((monster.team) ? Team_ColorRGB(monster.team) : '1 0 0')); - - monster.sprite.team = 0; - monster.sprite.SendFlags |= 1; - } - } - if(monster.monster_attack) IL_REMOVE(g_monster_targets, monster); monster.monster_attack = false; // it's the player's job to kill all the monsters @@ -289,22 +261,13 @@ bool Invasion_CheckWinner() return 1; } - float total_alive_monsters = 0, supermonster_count = 0, red_alive = 0, blue_alive = 0, yellow_alive = 0, pink_alive = 0; + float total_alive_monsters = 0, supermonster_count = 0; IL_EACH(g_monsters, GetResourceAmount(it, RESOURCE_HEALTH) > 0, { if((get_monsterinfo(it.monsterid)).spawnflags & MON_FLAG_SUPERMONSTER) ++supermonster_count; ++total_alive_monsters; - - if(teamplay) - switch(it.team) - { - case NUM_TEAM_1: ++red_alive; break; - case NUM_TEAM_2: ++blue_alive; break; - case NUM_TEAM_3: ++yellow_alive; break; - case NUM_TEAM_4: ++pink_alive; break; - } }); if((total_alive_monsters + inv_numkilled) < inv_maxspawned && inv_maxcurrent < inv_maxspawned) @@ -321,42 +284,20 @@ bool Invasion_CheckWinner() if(inv_numspawned < 1) return 0; // nothing has spawned yet - if(teamplay) - { - if(((red_alive > 0) + (blue_alive > 0) + (yellow_alive > 0) + (pink_alive > 0)) > 1) - return 0; - } - else if(inv_numkilled < inv_maxspawned) + if(inv_numkilled < inv_maxspawned) return 0; entity winner = NULL; - float winning_score = 0, winner_team = 0; + float winning_score = 0; - - if(teamplay) - { - if(red_alive > 0) { winner_team = NUM_TEAM_1; } - if(blue_alive > 0) - if(winner_team) { winner_team = 0; } - else { winner_team = NUM_TEAM_2; } - if(yellow_alive > 0) - if(winner_team) { winner_team = 0; } - else { winner_team = NUM_TEAM_3; } - if(pink_alive > 0) - if(winner_team) { winner_team = 0; } - else { winner_team = NUM_TEAM_4; } - } - else - { - FOREACH_CLIENT(IS_PLAYER(it), { - float cs = GameRules_scoring_add(it, KILLS, 0); - if(cs > winning_score) - { - winning_score = cs; - winner = it; - } - }); - } + FOREACH_CLIENT(IS_PLAYER(it), { + float cs = GameRules_scoring_add(it, KILLS, 0); + if(cs > winning_score) + { + winning_score = cs; + winner = it; + } + }); IL_EACH(g_monsters, true, { @@ -364,15 +305,7 @@ bool Invasion_CheckWinner() }); IL_CLEAR(g_monsters); - if(teamplay) - { - if(winner_team) - { - 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)); - } - } - else if(winner) + if(winner) { Send_Notification(NOTIF_ALL, NULL, MSG_CENTER, CENTER_ROUND_PLAYER_WIN, winner.netname); Send_Notification(NOTIF_ALL, NULL, MSG_INFO, INFO_ROUND_PLAYER_WIN, winner.netname); @@ -406,15 +339,6 @@ void Invasion_RoundStart() inv_numkilled = 0; inv_maxspawned = rint(max(autocvar_g_invasion_monster_count, autocvar_g_invasion_monster_count * (inv_roundcnt * 0.5))); - - if(teamplay) - { - DistributeEvenly_Init(inv_maxspawned, invasion_teams); - inv_monsters_perteam[NUM_TEAM_1] = DistributeEvenly_Get(1); - inv_monsters_perteam[NUM_TEAM_2] = DistributeEvenly_Get(1); - if(invasion_teams >= 3) inv_monsters_perteam[NUM_TEAM_3] = DistributeEvenly_Get(1); - if(invasion_teams >= 4) inv_monsters_perteam[NUM_TEAM_4] = DistributeEvenly_Get(1); - } } MUTATOR_HOOKFUNCTION(inv, MonsterDies) @@ -429,16 +353,13 @@ MUTATOR_HOOKFUNCTION(inv, MonsterDies) inv_numkilled += 1; inv_maxcurrent -= 1; } - if(teamplay) { inv_monsters_perteam[frag_target.team] -= 1; } if(IS_PLAYER(frag_attacker)) - if(SAME_TEAM(frag_attacker, frag_target)) // in non-teamplay modes, same team = same player, so this works - GameRules_scoring_add(frag_attacker, KILLS, -1); - else { - GameRules_scoring_add(frag_attacker, KILLS, +1); - if(teamplay) - TeamScore_AddToTeam(frag_attacker.team, ST_INV_KILLS, +1); + if(SAME_TEAM(frag_attacker, frag_target)) + GameRules_scoring_add(frag_attacker, KILLS, -1); + else + GameRules_scoring_add(frag_attacker, KILLS, +1); } } } @@ -549,44 +470,28 @@ MUTATOR_HOOKFUNCTION(inv, CheckRules_World) return true; } -MUTATOR_HOOKFUNCTION(inv, TeamBalance_CheckAllowedTeams, CBC_ORDER_EXCLUSIVE) -{ - M_ARGV(0, float) = invasion_teams; - return true; -} - MUTATOR_HOOKFUNCTION(inv, AllowMobButcher) { M_ARGV(0, string) = "This command does not work during an invasion!"; return true; } -void invasion_ScoreRules(int inv_teams) +void invasion_ScoreRules() { GameRules_score_enabled(false); - GameRules_scoring(inv_teams, 0, 0, { - if (inv_teams) { - field_team(ST_INV_KILLS, "frags", SFL_SORT_PRIO_PRIMARY); - } - field(SP_KILLS, "frags", ((inv_teams) ? SFL_SORT_PRIO_SECONDARY : SFL_SORT_PRIO_PRIMARY)); + GameRules_scoring(0, 0, 0, { + field(SP_KILLS, "frags", SFL_SORT_PRIO_PRIMARY); }); } -void invasion_DelayedInit(entity this) // Do this check with a delay so we can wait for teams to be set up. +void invasion_DelayedInit(entity this) { if(autocvar_g_invasion_type == INV_TYPE_HUNT || autocvar_g_invasion_type == INV_TYPE_STAGE) cvar_set("fraglimit", "0"); - if(autocvar_g_invasion_teams) - { - invasion_teams = BITS(bound(2, autocvar_g_invasion_teams, 4)); - } - else - invasion_teams = 0; - independent_players = 1; // to disable extra useless scores - invasion_ScoreRules(invasion_teams); + invasion_ScoreRules(); independent_players = 0; diff --git a/qcsrc/common/gamemodes/gamemode/invasion/sv_invasion.qh b/qcsrc/common/gamemodes/gamemode/invasion/sv_invasion.qh index 167380eeb2..2011a35982 100644 --- a/qcsrc/common/gamemodes/gamemode/invasion/sv_invasion.qh +++ b/qcsrc/common/gamemodes/gamemode/invasion/sv_invasion.qh @@ -2,9 +2,7 @@ #include #define autocvar_g_invasion_point_limit cvar("g_invasion_point_limit") -int autocvar_g_invasion_teams; int autocvar_g_invasion_type; -bool autocvar_g_invasion_team_spawns; bool g_invasion; void invasion_Initialize(); @@ -13,10 +11,6 @@ REGISTER_MUTATOR(inv, false) MUTATOR_STATIC(); MUTATOR_ONADD { - if (autocvar_g_invasion_teams >= 2) { - GameRules_teams(true); - GameRules_spawning_teams(autocvar_g_invasion_team_spawns); - } GameRules_limit_score(autocvar_g_invasion_point_limit); g_invasion = true; @@ -26,21 +20,16 @@ REGISTER_MUTATOR(inv, false) return 0; } -float inv_numspawned; -float inv_maxspawned; -float inv_roundcnt; -float inv_maxrounds; -float inv_numkilled; +int inv_numspawned; +int inv_maxspawned; +int inv_roundcnt; +int inv_maxrounds; +int inv_numkilled; float inv_lastcheck; -float inv_maxcurrent; - -float invasion_teams; -float inv_monsters_perteam[17]; +int inv_maxcurrent; float inv_monsterskill; -const float ST_INV_KILLS = 1; - const int INV_TYPE_ROUND = 0; // round-based waves of enemies const int INV_TYPE_HUNT = 1; // clear the map of placed enemies const int INV_TYPE_STAGE = 2; // reach the end of the level diff --git a/qcsrc/common/mapinfo.qh b/qcsrc/common/mapinfo.qh index 4ece921560..fe41609fed 100644 --- a/qcsrc/common/mapinfo.qh +++ b/qcsrc/common/mapinfo.qh @@ -472,14 +472,11 @@ REGISTER_GAMETYPE(KEEPAWAY, NEW(Keepaway)); CLASS(Invasion, Gametype) INIT(Invasion) { - this.gametype_init(this, _("Invasion"),"inv","g_invasion",false,"","pointlimit=50 teams=0 type=0",_("Survive against waves of monsters")); + this.gametype_init(this, _("Invasion"),"inv","g_invasion",false,"","pointlimit=50 type=0",_("Survive against waves of monsters")); } METHOD(Invasion, m_parse_mapinfo, bool(string k, string v)) { switch (k) { - case "teams": - cvar_set("g_invasion_teams", v); - return true; case "type": cvar_set("g_invasion_type", v); return true; diff --git a/qcsrc/common/monsters/monster/mage.qc b/qcsrc/common/monsters/monster/mage.qc index 16fdd410a7..8f16459da8 100644 --- a/qcsrc/common/monsters/monster/mage.qc +++ b/qcsrc/common/monsters/monster/mage.qc @@ -298,15 +298,16 @@ void M_Mage_Attack_Push(entity this) void M_Mage_Attack_Teleport(entity this, entity targ) { if(!targ) return; + if(!IS_ONGROUND(targ)) return; if(vdist(targ.origin - this.origin, >, 1500)) return; makevectors(targ.angles); - tracebox(targ.origin + ((v_forward * -1) * 200), this.mins, this.maxs, this.origin, MOVE_NOMONSTERS, this); + tracebox(CENTER_OR_VIEWOFS(targ), this.mins, this.maxs, CENTER_OR_VIEWOFS(targ) + ((v_forward * -1) * 200), MOVE_NOMONSTERS, this); if(trace_fraction < 1) return; - vector newpos = targ.origin + ((v_forward * -1) * 200); + vector newpos = trace_endpos; Send_Effect(EFFECT_SPAWN_NEUTRAL, this.origin, '0 0 0', 1); Send_Effect(EFFECT_SPAWN_NEUTRAL, newpos, '0 0 0', 1); @@ -363,7 +364,8 @@ bool M_Mage_Attack(int attack_type, entity actor, entity targ, .entity weaponent if(random() <= 0.4) { OffhandWeapon off = OFFHAND_MAGE_TELEPORT; - off.offhand_think(off, actor, true); + actor.OffhandMageTeleport_key_pressed = 0; + off.offhand_think(off, actor, 1); return true; } else diff --git a/qcsrc/server/g_world.qc b/qcsrc/server/g_world.qc index 522f4f041c..f54aa5e980 100644 --- a/qcsrc/server/g_world.qc +++ b/qcsrc/server/g_world.qc @@ -268,7 +268,6 @@ void cvar_changes_init() BADCVAR("g_duel"); BADCVAR("g_freezetag"); BADCVAR("g_freezetag_teams"); - BADCVAR("g_invasion_teams"); BADCVAR("g_invasion_type"); BADCVAR("g_jailbreak"); BADCVAR("g_jailbreak_teams");