X-Git-Url: https://de.git.xonotic.org/?a=blobdiff_plain;f=qcsrc%2Fcommon%2Fmutators%2Fmutator%2Fcampcheck%2Fcampcheck.qc;h=b39a2c1650003d616e95ac73e62e851add50645a;hb=c7e9b42f7acdcbb72758b33371b105054ce5400d;hp=4916464a1be8dc0e5705d9eebaa801628eb40fae;hpb=724a41faf2cbfd86d41f3ab59ff8326a831a8326;p=xonotic%2Fxonotic-data.pk3dir.git diff --git a/qcsrc/common/mutators/mutator/campcheck/campcheck.qc b/qcsrc/common/mutators/mutator/campcheck/campcheck.qc index 4916464a1b..b39a2c1650 100644 --- a/qcsrc/common/mutators/mutator/campcheck/campcheck.qc +++ b/qcsrc/common/mutators/mutator/campcheck/campcheck.qc @@ -10,12 +10,16 @@ REGISTER_MUTATOR(campcheck, cvar("g_campcheck")); MUTATOR_HOOKFUNCTION(campcheck, PlayerDies) { - Kill_Notification(NOTIF_ONE, frag_target, MSG_CENTER_CPID, CPID_CAMPCHECK); - return false; + entity frag_target = M_ARGV(2, entity); + + Kill_Notification(NOTIF_ONE, frag_target, MSG_CENTER, CPID_CAMPCHECK); } MUTATOR_HOOKFUNCTION(campcheck, PlayerDamage_Calculate) { + entity frag_attacker = M_ARGV(1, entity); + entity frag_target = M_ARGV(2, entity); + if(IS_PLAYER(frag_target)) if(IS_PLAYER(frag_attacker)) if(frag_attacker != frag_target) @@ -23,67 +27,65 @@ MUTATOR_HOOKFUNCTION(campcheck, PlayerDamage_Calculate) frag_target.campcheck_traveled_distance = autocvar_g_campcheck_distance; frag_attacker.campcheck_traveled_distance = autocvar_g_campcheck_distance; } - - return false; } MUTATOR_HOOKFUNCTION(campcheck, PlayerPreThink) -{SELFPARAM(); +{ + entity player = M_ARGV(0, entity); + if(!gameover) if(!warmup_stage) // don't consider it camping during warmup? if(time >= game_starttime) - if(IS_PLAYER(self)) - if(IS_REAL_CLIENT(self)) // bots may camp, but that's no reason to constantly kill them - if(!IS_DEAD(self)) - if(!STAT(FROZEN, self)) - if(!self.BUTTON_CHAT) + if(IS_PLAYER(player)) + if(IS_REAL_CLIENT(player)) // bots may camp, but that's no reason to constantly kill them + if(!IS_DEAD(player)) + if(!STAT(FROZEN, player)) + if(!PHYS_INPUT_BUTTON_CHAT(player)) 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 = player.prevorigin - player.origin; dist.z = 0; - self.campcheck_traveled_distance += fabs(vlen(dist)); + player.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; + player.campcheck_nextcheck = time + autocvar_g_campcheck_interval * 2; + player.campcheck_traveled_distance = 0; } - if(time > self.campcheck_nextcheck) + if(time > player.campcheck_nextcheck) { - if(self.campcheck_traveled_distance < autocvar_g_campcheck_distance) + if(player.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.m_id, self.vehicle.origin, '0 0 0'); + Send_Notification(NOTIF_ONE, player, MSG_CENTER, CENTER_CAMPCHECK); + if(player.vehicle) + Damage(player.vehicle, NULL, NULL, autocvar_g_campcheck_damage * 2, DEATH_CAMP.m_id, player.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.m_id, self.origin, '0 0 0'); + Damage(player, NULL, NULL, bound(0, autocvar_g_campcheck_damage, player.health + player.armorvalue * autocvar_g_balance_armor_blockpercent + 5), DEATH_CAMP.m_id, player.origin, '0 0 0'); } - self.campcheck_nextcheck = time + autocvar_g_campcheck_interval; - self.campcheck_traveled_distance = 0; + player.campcheck_nextcheck = time + autocvar_g_campcheck_interval; + player.campcheck_traveled_distance = 0; } - return false; + return; } - self.campcheck_nextcheck = time + autocvar_g_campcheck_interval; // one of the above checks failed, so keep the timer up to date - return false; + player.campcheck_nextcheck = time + autocvar_g_campcheck_interval; // one of the above checks failed, so keep the timer up to date } MUTATOR_HOOKFUNCTION(campcheck, PlayerSpawn) -{SELFPARAM(); - self.campcheck_nextcheck = time + autocvar_g_campcheck_interval * 2; - self.campcheck_traveled_distance = 0; +{ + entity player = M_ARGV(0, entity); - return false; + player.campcheck_nextcheck = time + autocvar_g_campcheck_interval * 2; + player.campcheck_traveled_distance = 0; } MUTATOR_HOOKFUNCTION(campcheck, BuildMutatorsString) { - ret_string = strcat(ret_string, ":CampCheck"); - return false; + M_ARGV(0, string) = strcat(M_ARGV(0, string), ":CampCheck");; } #endif