]> git.xonotic.org Git - xonotic/xonotic-data.pk3dir.git/commitdiff
added tagging and tag teleportation, tried bug fixing but with no success
authordrjaska <drjaska83@gmail.com>
Wed, 24 Nov 2021 00:31:11 +0000 (02:31 +0200)
committerdrjaska <drjaska83@gmail.com>
Wed, 24 Nov 2021 00:31:11 +0000 (02:31 +0200)
gamemodes-server.cfg
qcsrc/common/gamemodes/gamemode/mh/TODO.txt
qcsrc/common/gamemodes/gamemode/mh/sv_mh.qc
qcsrc/common/gamemodes/gamemode/mh/sv_mh.qh

index 3fdfb009bcb98acfd56965b2a9e0f9f18b08d139..5249c10e07ee543dc3e812b2977865e75315ebdd 100644 (file)
@@ -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"
index 1ea205fbfe877194caa1f319a9d0f87587e8fedb..13f5615ad73b66274abb363bee7b8c2a1146dbdb 100644 (file)
@@ -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
 
index 48d85b0c79596460292f2c9e64ca7f270597fb74..dac768d40f8fea7fcaee0ba11a8d700c7b8f71d9 100644 (file)
@@ -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;
 }
index b780239975d8bd351b356723d9335ee326dd0ea3..fb47a8c4cdc751af0045f2213660db55e2663d86 100644 (file)
@@ -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;