2 float autocvar_g_campcheck_damage;
3 float autocvar_g_campcheck_distance;
4 float autocvar_g_campcheck_interval;
6 REGISTER_MUTATOR(campcheck, cvar("g_campcheck"));
8 .float campcheck_nextcheck;
9 .float campcheck_traveled_distance;
11 MUTATOR_HOOKFUNCTION(campcheck, PlayerDies)
13 Kill_Notification(NOTIF_ONE, frag_target, MSG_CENTER, CPID_CAMPCHECK);
17 MUTATOR_HOOKFUNCTION(campcheck, PlayerDamage_Calculate)
19 if(IS_PLAYER(frag_target))
20 if(IS_PLAYER(frag_attacker))
21 if(frag_attacker != frag_target)
23 frag_target.campcheck_traveled_distance = autocvar_g_campcheck_distance;
24 frag_attacker.campcheck_traveled_distance = autocvar_g_campcheck_distance;
30 MUTATOR_HOOKFUNCTION(campcheck, PlayerPreThink)
33 if(!warmup_stage) // don't consider it camping during warmup?
34 if(time >= game_starttime)
36 if(IS_REAL_CLIENT(self)) // bots may camp, but that's no reason to constantly kill them
38 if(!STAT(FROZEN, self))
40 if(autocvar_g_campcheck_interval)
44 // calculate player movement (in 2 dimensions only, so jumping on one spot doesn't count as movement)
45 dist = self.prevorigin - self.origin;
47 self.campcheck_traveled_distance += fabs(vlen(dist));
49 if((autocvar_g_campaign && !campaign_bots_may_start) || (time < game_starttime) || (round_handler_IsActive() && !round_handler_IsRoundStarted()))
51 self.campcheck_nextcheck = time + autocvar_g_campcheck_interval * 2;
52 self.campcheck_traveled_distance = 0;
55 if(time > self.campcheck_nextcheck)
57 if(self.campcheck_traveled_distance < autocvar_g_campcheck_distance)
59 Send_Notification(NOTIF_ONE, self, MSG_CENTER, CENTER_CAMPCHECK);
61 Damage(self.vehicle, self, self, autocvar_g_campcheck_damage * 2, DEATH_CAMP.m_id, self.vehicle.origin, '0 0 0');
63 Damage(self, self, self, bound(0, autocvar_g_campcheck_damage, self.health + self.armorvalue * autocvar_g_balance_armor_blockpercent + 5), DEATH_CAMP.m_id, self.origin, '0 0 0');
65 self.campcheck_nextcheck = time + autocvar_g_campcheck_interval;
66 self.campcheck_traveled_distance = 0;
72 self.campcheck_nextcheck = time + autocvar_g_campcheck_interval; // one of the above checks failed, so keep the timer up to date
76 MUTATOR_HOOKFUNCTION(campcheck, PlayerSpawn)
78 self.campcheck_nextcheck = time + autocvar_g_campcheck_interval * 2;
79 self.campcheck_traveled_distance = 0;
84 MUTATOR_HOOKFUNCTION(campcheck, BuildMutatorsString)
86 ret_string = strcat(ret_string, ":CampCheck");