From: Mario Date: Tue, 11 Jun 2013 05:47:08 +0000 (+1000) Subject: Move camp check to the mutator system X-Git-Tag: xonotic-v0.8.0~366^2~20 X-Git-Url: https://git.rm.cloudns.org/?a=commitdiff_plain;h=1041da5e4a7daafadc97e2812c7adf688899cc35;p=xonotic%2Fxonotic-data.pk3dir.git Move camp check to the mutator system --- diff --git a/gamemodes.cfg b/gamemodes.cfg index b7e65c8eb..35bd7acff 100644 --- a/gamemodes.cfg +++ b/gamemodes.cfg @@ -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" diff --git a/mutators.cfg b/mutators.cfg index 9ae9b26cc..b43bc006a 100644 --- a/mutators.cfg +++ b/mutators.cfg @@ -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 diff --git a/qcsrc/common/notifications.qh b/qcsrc/common/notifications.qh index 853b71744..be2006714 100644 --- a/qcsrc/common/notifications.qh +++ b/qcsrc/common/notifications.qh @@ -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"), "") \ diff --git a/qcsrc/server/autocvars.qh b/qcsrc/server/autocvars.qh index 7a5622a42..d1cce37c2 100644 --- a/qcsrc/server/autocvars.qh +++ b/qcsrc/server/autocvars.qh @@ -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; diff --git a/qcsrc/server/miscfunctions.qc b/qcsrc/server/miscfunctions.qc index 8489c8a46..0e34fcc0b 100644 --- a/qcsrc/server/miscfunctions.qc +++ b/qcsrc/server/miscfunctions.qc @@ -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 diff --git a/qcsrc/server/mutators/gamemode_lms.qc b/qcsrc/server/mutators/gamemode_lms.qc index 193b5378e..aa8e8f37e 100644 --- a/qcsrc/server/mutators/gamemode_lms.qc +++ b/qcsrc/server/mutators/gamemode_lms.qc @@ -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); diff --git a/qcsrc/server/mutators/gamemode_lms.qh b/qcsrc/server/mutators/gamemode_lms.qh index 508bf8c6c..16fda6155 100644 --- a/qcsrc/server/mutators/gamemode_lms.qh +++ b/qcsrc/server/mutators/gamemode_lms.qh @@ -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 index 000000000..d9d219c5a --- /dev/null +++ b/qcsrc/server/mutators/mutator_campcheck.qc @@ -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; +} diff --git a/qcsrc/server/mutators/mutators.qh b/qcsrc/server/mutators/mutators.qh index f6f79c73f..3d5ca7295 100644 --- a/qcsrc/server/mutators/mutators.qh +++ b/qcsrc/server/mutators/mutators.qh @@ -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); diff --git a/qcsrc/server/progs.src b/qcsrc/server/progs.src index 6894c9909..79a7bf21b 100644 --- a/qcsrc/server/progs.src +++ b/qcsrc/server/progs.src @@ -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