From: drjaska Date: Wed, 24 Nov 2021 00:31:11 +0000 (+0200) Subject: added tagging and tag teleportation, tried bug fixing but with no success X-Git-Url: https://git.rm.cloudns.org/?a=commitdiff_plain;h=d0be8374b788d4f47ee32d8773a028d910f5a0f1;p=xonotic%2Fxonotic-data.pk3dir.git added tagging and tag teleportation, tried bug fixing but with no success --- diff --git a/gamemodes-server.cfg b/gamemodes-server.cfg index 3fdfb009b..5249c10e0 100644 --- a/gamemodes-server.cfg +++ b/gamemodes-server.cfg @@ -578,5 +578,4 @@ set g_mh_team_spawns 0 "when 1, players spawn from the team spawnpoints of the m set g_mh_point_limit -1 "MH point limit overriding the mapinfo specified one (use 0 to play without limit, and -1 to use the mapinfo's limit)" set g_mh_warmup 1 //10 "time players get to run around before the round starts" set g_mh_round_timelimit 60 //180 "round time limit in seconds" -set g_mh_weaponarena "okmachinegun" "starting weapons - takes the same options as g_weaponarena" -// change ^ to " " after tagging has been implemented to remove all weapons by default \ No newline at end of file +set g_mh_weaponarena " " "starting weapons - takes the same options as g_weaponarena" diff --git a/qcsrc/common/gamemodes/gamemode/mh/TODO.txt b/qcsrc/common/gamemodes/gamemode/mh/TODO.txt index 1ea205fbf..13f5615ad 100644 --- a/qcsrc/common/gamemodes/gamemode/mh/TODO.txt +++ b/qcsrc/common/gamemodes/gamemode/mh/TODO.txt @@ -1,13 +1,16 @@ +fix broken hunters and players not resetting decide names for teams, runners and hunters? add g_mh_startitem cvars to the balance files -collision detection which kills the runner(?), check if goombastomp's or touchexplode's code is reusable +add waypoints on runners + +count dead players to be in a team avoid players bumping into each other and losing speed regardless of team without affecting ^ -teleport tagged players to where they got tagged / restore their velocity, coordinates and view angles +more dynamic, offswitch for shuffle on-screen notification (and sound?) for getting tagged diff --git a/qcsrc/common/gamemodes/gamemode/mh/sv_mh.qc b/qcsrc/common/gamemodes/gamemode/mh/sv_mh.qc index 48d85b0c7..dac768d40 100644 --- a/qcsrc/common/gamemodes/gamemode/mh/sv_mh.qc +++ b/qcsrc/common/gamemodes/gamemode/mh/sv_mh.qc @@ -1,5 +1,11 @@ #include "sv_mh.qh" +.bool tagteleport; +.vector taggedplayerlocation; +.vector taggedplayervelocity; +.vector taggedplayerviewangles; + + MUTATOR_HOOKFUNCTION(mh, TeamBalance_CheckAllowedTeams, CBC_ORDER_EXCLUSIVE) { M_ARGV(1, string) = "mh_team"; @@ -15,6 +21,35 @@ MUTATOR_HOOKFUNCTION(mh, Scores_CountFragsRemaining) // weaponarena hooks // =================== +//damage dealing for tagging +MUTATOR_HOOKFUNCTION(mh, PlayerPreThink) +{ + entity player = M_ARGV(0, entity); + + if(player.team == Team_IndexToTeam(1) && !game_stopped && !IS_DEAD(player) && IS_PLAYER(player) && !IS_INDEPENDENT_PLAYER(player)) + { + FOREACH_CLIENT(IS_PLAYER(it) && it != player && it.team == Team_IndexToTeam(2), { + if(!IS_DEAD(it) && !IS_INDEPENDENT_PLAYER(it)) + if(boxesoverlap(player.absmin, player.absmax, it.absmin, it.absmax)) + { + float health = GetResource(it, RES_HEALTH); + float armor = GetResource(it, RES_ARMOR); + float max_dmg; + if(autocvar_g_balance_armor_blockpercent == 1){ + max_dmg = health + armor; //skip handling (1 - autocvar_g_balance_armor_blockpercent) in case of value of 1 as it leads to divide by 0 + } else { + max_dmg = health + bound(0, armor, ((health / (1 - autocvar_g_balance_armor_blockpercent))- health)); + } + Damage(it, player, player, max_dmg, DEATH_CAMP.m_id, DMG_NOWEP, player.origin, '0 0 0'); + it.tagteleport = true; + it.taggedplayerlocation = it.origin; + it.taggedplayervelocity = it.velocity; + it.taggedplayerviewangles = it.angles; + } + }); + } +} + MUTATOR_HOOKFUNCTION(mh, SetWeaponArena) { if (M_ARGV(0, string) == "0" || M_ARGV(0, string) == "") @@ -240,6 +275,7 @@ void MH_count_alive_players() // Team_ int MH_GetWinnerTeam() { + //both teams have alive players if ((Team_GetNumberOfAlivePlayers(Team_GetTeamFromIndex(1)) >= 1) && (Team_GetNumberOfAlivePlayers(Team_GetTeamFromIndex(2)) >= 1)){ return Team_IndexToTeam(2); } @@ -298,10 +334,11 @@ float MH_CheckWinner() game_stopped = true; round_handler_Init(5, autocvar_g_mh_warmup, autocvar_g_mh_round_timelimit); - if(pymod(round_counter_for_teamchanging, 2)) - shuffleteams_on_reset_map = !allowed_to_spawn_untagged; //only shuffle every other round - ++round_counter_for_teamchanging; - FOREACH_CLIENT(IS_PLAYER(it), { CS(it).killcount = 0; nades_Clear(it); }); //hopefully "{ CS(it).killcount = 0; nades_Clear(it); }" works and doesn't cut off nades_Clear, untested + //if(pymod(round_counter_for_teamchanging, 2)) + // shuffleteams_on_reset_map = !allowed_to_spawn_untagged; //only shuffle every other round + //++round_counter_for_teamchanging; + //FOREACH_CLIENT(IS_PLAYER(it), { CS(it).killcount = 0; nades_Clear(it); }); //hopefully "{ CS(it).killcount = 0; nades_Clear(it); }" works and doesn't cut off nades_Clear, untested + FOREACH_CLIENT(IS_PLAYER(it), { nades_Clear(it); }); //hopefully "{ CS(it).killcount = 0; nades_Clear(it); }" works and doesn't cut off nades_Clear, untested return did_the_round_end; } @@ -381,7 +418,7 @@ void MH_RoundStart() MUTATOR_HOOKFUNCTION(mh, PutClientInServer) { entity player = M_ARGV(0, entity); - + if (!allowed_to_spawn_untagged && IS_PLAYER(player)){ // this is true even when player is trying to join if (CS(player).jointime != time){ // not when connecting Send_Notification(NOTIF_ONE_ONLY, player, MSG_INFO, INFO_MH_JOIN_LATE); @@ -403,13 +440,49 @@ MUTATOR_HOOKFUNCTION(mh, PutClientInServer) // qcsrc/common/mutators/mutator/nades/nades.qc nades_Clear void nades_Clear(entity player); +// Function: +// PlayerDies +// Purpose in CA: +// handle players dying +// Needed in MH? Purpose?: +// yes, handle players getting tagged +// Needed modifications for MH: +// change respawning +// Called by: +// a player dying/dc'ing +// Calls: +// mh_LastPlayerForTeam_Notify +MUTATOR_HOOKFUNCTION(mh, PlayerDies) +{ + entity frag_target = M_ARGV(2, entity); + + mh_LastPlayerForTeam_Notify(frag_target); + if (!allowed_to_spawn_untagged) + { + frag_target.respawn_flags = RESPAWN_SILENT; //idk what this exactly does yet, below comment was there for respawn time = time + 2 and this line inside the backets + // prevent unwanted sudden rejoin as spectator and movement of spectator camera + } + frag_target.respawn_time = time; + frag_target.respawn_flags |= RESPAWN_FORCE; + + return true; +} + // =========== // to change // =========== - +MUTATOR_HOOKFUNCTION(mh, reset_map_players) +{ + FOREACH_CLIENT(true, { + CS(it).killcount = 0; + TRANSMUTE(Player, it); + } + ); + return true; +} // Maybe add player teleporting to where they died if they just got tagged? @@ -434,36 +507,10 @@ MUTATOR_HOOKFUNCTION(mh, PlayerSpawn) MoveToTeam(player, 1, 6); //index of 1 static is wrong way but it's working somehow with bubblegum and prayers player.deadflag = 0; // with bubblegum and prayers, there probably is probably a better check to use here } - //if (!warmup_stage) - // eliminatedPlayers.SendFlags |= 1; -} - -// Maybe add player teleporting to where they died if they just got tagged? - -// Function: -// PlayerDies -// Purpose in CA: -// handle players dying -// Needed in MH? Purpose?: -// yes, handle players getting tagged -// Needed modifications for MH: -// change respawning -// Called by: -// a player dying/dc'ing -// Calls: -// mh_LastPlayerForTeam_Notify -MUTATOR_HOOKFUNCTION(mh, PlayerDies) -{ - entity frag_target = M_ARGV(2, entity); - - mh_LastPlayerForTeam_Notify(frag_target); - if (!allowed_to_spawn_untagged) - { - frag_target.respawn_flags = RESPAWN_SILENT; //idk what this exactly does yet, below comment was there for respawn time = time + 2 and this line inside the backets - // prevent unwanted sudden rejoin as spectator and movement of spectator camera + if(player.team == Team_IndexToTeam(1) && !IS_DEAD(player) && player.tagteleport == true && !allowed_to_spawn_untagged){ + player.tagteleport = false; + player.origin = player.taggedplayerlocation; + player.velocity = player.taggedplayervelocity; + player.angles = player.taggedplayerviewangles; } - frag_target.respawn_time = time; - frag_target.respawn_flags |= RESPAWN_FORCE; - - return true; } diff --git a/qcsrc/common/gamemodes/gamemode/mh/sv_mh.qh b/qcsrc/common/gamemodes/gamemode/mh/sv_mh.qh index b78023997..fb47a8c4c 100644 --- a/qcsrc/common/gamemodes/gamemode/mh/sv_mh.qh +++ b/qcsrc/common/gamemodes/gamemode/mh/sv_mh.qh @@ -15,7 +15,7 @@ string autocvar_g_mh_weaponarena; int mh_teams; bool allowed_to_spawn_untagged = 1; -int round_counter_for_teamchanging = 1; +//int round_counter_for_teamchanging = 1; const int ST_MH_ROUNDS = 1;