]> git.rm.cloudns.org Git - xonotic/xonotic-data.pk3dir.git/commitdiff
Move camp check to the mutator system
authorMario <mario.mario@y7mail.com>
Tue, 11 Jun 2013 05:47:08 +0000 (15:47 +1000)
committerMario <mario.mario@y7mail.com>
Tue, 11 Jun 2013 05:47:08 +0000 (15:47 +1000)
gamemodes.cfg
mutators.cfg
qcsrc/common/notifications.qh
qcsrc/server/autocvars.qh
qcsrc/server/miscfunctions.qc
qcsrc/server/mutators/gamemode_lms.qc
qcsrc/server/mutators/gamemode_lms.qh
qcsrc/server/mutators/mutator_campcheck.qc [new file with mode: 0644]
qcsrc/server/mutators/mutators.qh
qcsrc/server/progs.src

index b7e65c8eb8fb9aa734bf0a11f2d7b688915ca5b1..35bd7acff3e3b118c3aac82510b5d8637e69a99b 100644 (file)
@@ -343,9 +343,6 @@ set g_lms 0 "Last Man Standing: everyone starts with a certain amount of lives,
 set g_lms_lives_override -1
 set g_lms_extra_lives 0
 set g_lms_regenerate 0
-set g_lms_campcheck_interval 10
-set g_lms_campcheck_damage 100
-set g_lms_campcheck_distance 1800
 set g_lms_last_join 3  "if g_lms_join_anytime is false, new players can only join if the worst active player has more than (fraglimit - g_lms_last_join) lives"
 set g_lms_join_anytime 1       "if true, new players can join, but get same amount of lives as the worst player"
 
index 9ae9b26cc98c368e0d84b9dad799ee3cd484df11..b43bc006aa7d5bc982db7d11fd4c2562d485aeb2 100644 (file)
@@ -158,3 +158,12 @@ set g_riflearena_rifle_secondary_shots 1
 set g_riflearena_rifle_secondary_animtime 0.15
 set g_riflearena_rifle_secondary_refire 0.15
 set g_riflearena_rifle_secondary_damage 40
+
+
+// ============
+//  camp check
+// ============
+set g_campcheck 0 "damages campers every few seconds"
+set g_campcheck_interval 10
+set g_campcheck_damage 100
+set g_campcheck_distance 1800
index 853b717443cb8cc3e2c4d37d4e77d5ef51eaf9e1..be2006714b9f0ea8c872aca55be1a360d1ed7a16 100644 (file)
@@ -440,6 +440,7 @@ void Send_Notification_WOVA(
        MSG_CENTER_NOTIF(1, CENTER_COUNTDOWN_ROUNDSTOP,         0, 0, "",             CPID_ROUND,          "2 0", _("^F4Round cannot start"), "") \
        MSG_CENTER_NOTIF(1, CENTER_ROUND_TIED,                  0, 0, "",             CPID_ROUND,          "0 0", _("^BGRound tied"), "") \
        MSG_CENTER_NOTIF(1, CENTER_ROUND_OVER,                  0, 0, "",             CPID_ROUND,          "0 0", _("^BGRound over, there's no winner"), "") \
+       MSG_CENTER_NOTIF(1, CENTER_CAMPCHECK,                   0, 0, "",             CPID_CAMPCHECK,      "0 0", _("^F2Don't camp!"), "") \
        MSG_CENTER_NOTIF(1, CENTER_CTF_CAPTURESHIELD_FREE,      0, 0, "",             CPID_CTF_CAPSHIELD,  "0 0", _("^BGYou are now free.\n^BGFeel free to ^F2try to capture^BG the flag again\n^BGif you think you will succeed."), "") \
        MSG_CENTER_NOTIF(1, CENTER_CTF_CAPTURESHIELD_SHIELDED,  0, 0, "",             CPID_CTF_CAPSHIELD,  "0 0", _("^BGYou are now ^F1shielded^BG from the flag\n^BGfor ^F2too many unsuccessful attempts^BG to capture.\n^BGMake some defensive scores before trying again."), "") \
        MULTITEAM_CENTER(1, CENTER_CTF_CAPTURE_, 2,             0, 0, "",             CPID_CTF_LOWPRIO,    "0 0", _("^BGYou captured the ^TC^TT^BG flag!"), "") \
@@ -530,7 +531,6 @@ void Send_Notification_WOVA(
        MSG_CENTER_NOTIF(1, CENTER_KEYHUNT_WAIT,                0, 4, "missing_teams", CPID_KEYHUNT_OTHER,    "0 0", _("^BGWaiting for players to join...\nNeed active players for: %s"), "") \
        MSG_CENTER_NOTIF(1, CENTER_MISSING_TEAMS,               0, 4, "missing_teams", CPID_MISSING_TEAMS,    "-1 0", _("^BGWaiting for players to join...\nNeed active players for: %s"), "") \
        MSG_CENTER_NOTIF(1, CENTER_MISSING_PLAYERS,             0, 1, "f1",            CPID_MISSING_PLAYERS,  "-1 0", _("^BGWaiting for %s player(s) to join..."), "") \
-       MSG_CENTER_NOTIF(1, CENTER_LMS_CAMPCHECK,               0, 0, "",              CPID_LMS_CAMP,         "0 0", _("^F2Don't camp!"), "") \
        MSG_CENTER_NOTIF(1, CENTER_MINSTA_FINDAMMO,             0, 0, "",              CPID_MINSTA_FINDAMMO,  "1 9", _("^F4^COUNT^BG left to find some ammo!"), "") \
        MSG_CENTER_NOTIF(1, CENTER_MINSTA_FINDAMMO_FIRST,       0, 0, "",              CPID_MINSTA_FINDAMMO,  "1 10", _("^BGGet some ammo or you'll be dead in ^F4^COUNT^BG!"), _("^BGGet some ammo! ^F4^COUNT^BG left!")) \
        MSG_CENTER_NOTIF(1, CENTER_MINSTA_LIVES_REMAINING,      0, 1, "f1",            NO_CPID,                           "0 0", _("^F2Extra lives remaining: ^K1%s"), "") \
index 7a5622a42d7c659efc860ec6ad9ae81645036003..d1cce37c22b4886ae83656520776674b080faad2 100644 (file)
@@ -865,10 +865,7 @@ float autocvar_g_keyhunt_point_leadlimit;
 #define autocvar_g_keyhunt_point_limit cvar("g_keyhunt_point_limit")
 float autocvar_g_keyhunt_teams;
 float autocvar_g_keyhunt_teams_override;
-float autocvar_g_lms_campcheck_damage;
-float autocvar_g_lms_campcheck_distance;
 float autocvar_g_lms_extra_lives;
-float autocvar_g_lms_campcheck_interval;
 float autocvar_g_lms_join_anytime;
 float autocvar_g_lms_last_join;
 #define autocvar_g_lms_lives_override cvar("g_lms_lives_override")
@@ -1253,3 +1250,6 @@ float autocvar_g_nades_nade_edgedamage;
 float autocvar_g_nades_nade_radius;
 float autocvar_g_nades_nade_force;
 float autocvar_g_nades_nade_newton_style;
+float autocvar_g_campcheck_damage;
+float autocvar_g_campcheck_distance;
+float autocvar_g_campcheck_interval;
index 8489c8a46dca54ca444cc84ab60288755e0978c8..0e34fcc0bed59d939776c511f415e9c56017a00f 100644 (file)
@@ -927,6 +927,7 @@ void readlevelcvars(void)
        CHECK_MUTATOR_ADD("g_nades", mutator_nades, 1);
        CHECK_MUTATOR_ADD("g_sandbox", sandbox, 1);
     CHECK_MUTATOR_ADD("g_riflearena", mutator_riflearena, !cvar("g_minstagib"));
+       CHECK_MUTATOR_ADD("g_campcheck", mutator_campcheck, 1);
        
        #undef CHECK_MUTATOR_ADD
        
index 193b5378ecf594af3e08e5891e1fe216a531f28d..aa8e8f37eaa656cea53e3273e364d33ef30bf614 100644 (file)
@@ -46,14 +46,6 @@ MUTATOR_HOOKFUNCTION(lms_PlayerPreSpawn)
        return FALSE;
 }
 
-MUTATOR_HOOKFUNCTION(lms_PlayerSpawn)
-{
-       self.lms_nextcheck = time + autocvar_g_lms_campcheck_interval*2;
-       self.lms_traveled_distance = 0;
-               
-       return FALSE;
-}
-
 MUTATOR_HOOKFUNCTION(lms_PlayerDies)
 {
        self.respawn_flags |= RESPAWN_FORCE;
@@ -97,50 +89,6 @@ MUTATOR_HOOKFUNCTION(lms_PlayerThink)
        if(self.deadflag == DEAD_DYING)
                self.deadflag = DEAD_RESPAWNING;
                
-       if not(self.deadflag)
-       if(autocvar_g_lms_campcheck_interval)
-       {
-               vector dist;
-
-               // calculate player movement (in 2 dimensions only, so jumping on one spot doesn't count as movement)
-               dist = self.prevorigin - self.origin;
-               dist_z = 0;
-               self.lms_traveled_distance += fabs(vlen(dist));
-
-               if((autocvar_g_campaign && !campaign_bots_may_start) || (time < game_starttime))
-               {
-                       self.lms_nextcheck = time + autocvar_g_lms_campcheck_interval*2;
-                       self.lms_traveled_distance = 0;
-               }
-
-               if(time > self.lms_nextcheck)
-               {
-                       if(self.lms_traveled_distance < autocvar_g_lms_campcheck_distance)
-                       {
-                               Send_Notification(NOTIF_ONE, self, MSG_CENTER, CENTER_LMS_CAMPCHECK);
-                               if(self.vehicle)
-                                       Damage(self.vehicle, self, self, autocvar_g_lms_campcheck_damage * 2, DEATH_CAMP, self.vehicle.origin, '0 0 0');
-                               else
-                                       Damage(self, self, self, bound(0, autocvar_g_lms_campcheck_damage, self.health + self.armorvalue * autocvar_g_balance_armor_blockpercent + 5), DEATH_CAMP, self.origin, '0 0 0');
-                       }
-                       self.lms_nextcheck = time + autocvar_g_lms_campcheck_interval;
-                       self.lms_traveled_distance = 0;
-               }
-       }
-               
-       return FALSE;
-}
-
-MUTATOR_HOOKFUNCTION(lms_PlayerDamage)
-{
-       if(IS_PLAYER(frag_target))
-       if(IS_PLAYER(frag_attacker))
-       if(frag_attacker != frag_target)
-       {
-               frag_target.lms_traveled_distance = autocvar_g_lms_campcheck_distance;
-               frag_attacker.lms_traveled_distance = autocvar_g_lms_campcheck_distance;
-       }
-               
        return FALSE;
 }
 
@@ -237,12 +185,10 @@ MUTATOR_DEFINITION(gamemode_lms)
        MUTATOR_HOOK(reset_map_global, lms_ResetMap, CBC_ORDER_ANY);
        MUTATOR_HOOK(reset_map_players, lms_ResetPlayers, CBC_ORDER_ANY);
        MUTATOR_HOOK(PutClientInServer, lms_PlayerPreSpawn, CBC_ORDER_ANY);
-       MUTATOR_HOOK(PlayerSpawn, lms_PlayerSpawn, CBC_ORDER_ANY);
        MUTATOR_HOOK(PlayerDies, lms_PlayerDies, CBC_ORDER_ANY);
        MUTATOR_HOOK(MakePlayerObserver, lms_RemovePlayer, CBC_ORDER_ANY);
        MUTATOR_HOOK(ClientConnect, lms_ClientConnect, CBC_ORDER_ANY);
        MUTATOR_HOOK(PlayerPreThink, lms_PlayerThink, CBC_ORDER_ANY);
-       MUTATOR_HOOK(PlayerDamage_Calculate, lms_PlayerDamage, CBC_ORDER_ANY);
        MUTATOR_HOOK(ForbidThrowCurrentWeapon, lms_ForbidThrowing, CBC_ORDER_ANY);
        MUTATOR_HOOK(GiveFragsForKill, lms_GiveFragsForKill, CBC_ORDER_ANY);
        MUTATOR_HOOK(SetStartItems, lms_SetStartItems, CBC_ORDER_ANY);
index 508bf8c6cd12b98af08be540322c31a346adea79..16fda61550823e6a098e27a2f47e1cfe2506550d 100644 (file)
@@ -5,8 +5,4 @@
 // lives related defs
 float lms_lowest_lives;
 float lms_next_place;
-float LMS_NewPlayerLives();
-
-// camp check
-.float lms_nextcheck;
-.float lms_traveled_distance;
\ No newline at end of file
+float LMS_NewPlayerLives();
\ No newline at end of file
diff --git a/qcsrc/server/mutators/mutator_campcheck.qc b/qcsrc/server/mutators/mutator_campcheck.qc
new file mode 100644 (file)
index 0000000..d9d219c
--- /dev/null
@@ -0,0 +1,84 @@
+.float campcheck_nextcheck;
+.float campcheck_traveled_distance;
+
+MUTATOR_HOOKFUNCTION(campcheck_PlayerDies)
+{
+       Kill_Notification(NOTIF_ONE_ONLY, self, MSG_CENTER_CPID, CPID_CAMPCHECK);
+       
+       return FALSE;
+}
+
+MUTATOR_HOOKFUNCTION(campcheck_PlayerDamage)
+{
+       if(IS_PLAYER(frag_target))
+       if(IS_PLAYER(frag_attacker))
+       if(frag_attacker != frag_target)
+       {
+               frag_target.campcheck_traveled_distance = autocvar_g_campcheck_distance;
+               frag_attacker.campcheck_traveled_distance = autocvar_g_campcheck_distance;
+       }
+       
+       return FALSE;
+}
+
+MUTATOR_HOOKFUNCTION(campcheck_PlayerThink)
+{
+       if(IS_PLAYER(self))
+       if(self.deadflag == DEAD_NO)
+       if(autocvar_g_campcheck_interval)
+       {
+               vector dist;
+
+               // calculate player movement (in 2 dimensions only, so jumping on one spot doesn't count as movement)
+               dist = self.prevorigin - self.origin;
+               dist_z = 0;
+               self.campcheck_traveled_distance += fabs(vlen(dist));
+
+               if((autocvar_g_campaign && !campaign_bots_may_start) || (time < game_starttime) || (round_handler_IsActive() && !round_handler_IsRoundStarted()))
+               {
+                       self.campcheck_nextcheck = time + autocvar_g_campcheck_interval * 2;
+                       self.campcheck_traveled_distance = 0;
+               }
+
+               if(time > self.campcheck_nextcheck)
+               {
+                       if(self.campcheck_traveled_distance < autocvar_g_campcheck_distance)
+                       {
+                               Send_Notification(NOTIF_ONE, self, MSG_CENTER, CENTER_CAMPCHECK);
+                               if(self.vehicle)
+                                       Damage(self.vehicle, self, self, autocvar_g_campcheck_damage * 2, DEATH_CAMP, self.vehicle.origin, '0 0 0');
+                               else
+                                       Damage(self, self, self, bound(0, autocvar_g_campcheck_damage, self.health + self.armorvalue * autocvar_g_balance_armor_blockpercent + 5), DEATH_CAMP, self.origin, '0 0 0');
+                       }
+                       self.campcheck_nextcheck = time + autocvar_g_campcheck_interval;
+                       self.campcheck_traveled_distance = 0;
+               }
+       }
+
+       return FALSE;
+}
+
+MUTATOR_HOOKFUNCTION(campcheck_PlayerSpawn)
+{
+       self.campcheck_nextcheck = time + autocvar_g_campcheck_interval * 2;
+       self.campcheck_traveled_distance = 0;
+               
+       return FALSE;
+}
+
+MUTATOR_HOOKFUNCTION(campcheck_BuildMutatorsString)
+{
+       ret_string = strcat(ret_string, ":CampCheck");
+       return FALSE;
+}
+
+MUTATOR_DEFINITION(mutator_campcheck)
+{
+       MUTATOR_HOOK(PlayerDies, campcheck_PlayerDies, CBC_ORDER_ANY);
+       MUTATOR_HOOK(PlayerDamage_Calculate, campcheck_PlayerDamage, CBC_ORDER_ANY);
+       MUTATOR_HOOK(PlayerPreThink, campcheck_PlayerThink, CBC_ORDER_ANY);
+       MUTATOR_HOOK(PlayerSpawn, campcheck_PlayerSpawn, CBC_ORDER_ANY);
+       MUTATOR_HOOK(BuildMutatorsString, campcheck_BuildMutatorsString, CBC_ORDER_ANY);
+
+       return FALSE;
+}
index f6f79c73f8eec9fd179b2a3478ca05629e17e0d7..3d5ca72958f15b71c1a1c9793a96e79da1302490 100644 (file)
@@ -32,5 +32,6 @@ MUTATOR_DECLARATION(mutator_footsteps);
 MUTATOR_DECLARATION(mutator_melee_only);
 MUTATOR_DECLARATION(mutator_nades);
 MUTATOR_DECLARATION(mutator_riflearena);
+MUTATOR_DECLARATION(mutator_campcheck);
 
 MUTATOR_DECLARATION(sandbox);
index 6894c9909b93247dc0f11603668b35eca70ce9ff..79a7bf21bde1995a8d70ba4a3924fb78c1b8074c 100644 (file)
@@ -260,6 +260,7 @@ mutators/mutator_footsteps.qc
 mutators/mutator_melee_only.qc
 mutators/mutator_nades.qc
 mutators/mutator_riflearena.qc
+mutators/mutator_campcheck.qc
 
 ../warpzonelib/anglestransform.qc
 ../warpzonelib/mathlib.qc