From 81693dcd77725b79ee3cf6b76292c549686fc595 Mon Sep 17 00:00:00 2001 From: cypress Date: Wed, 18 Oct 2023 10:00:25 -0400 Subject: [PATCH] SERVER: Require client to look at certain entities for triggering --- source/server/clientfuncs.qc | 20 ++++++++++++++++++++ source/server/entities/machines.qc | 4 ++-- source/server/entities/wall_weapon.qc | 24 +++++++++++++++++++----- 3 files changed, 41 insertions(+), 7 deletions(-) diff --git a/source/server/clientfuncs.qc b/source/server/clientfuncs.qc index 9fb85c3..1471227 100644 --- a/source/server/clientfuncs.qc +++ b/source/server/clientfuncs.qc @@ -624,4 +624,24 @@ void(entity person, float expamt, float doublepoint) addmoney = person.points += expamt; UpdatePlayerPoints(person.playernum, person.points, expamt, person.kills, person.netname, person); +}; + +float(entity them, entity me) PlayerIsLooking = +{ + float ret = false; + float old_solid = me.solid; + me.solid = SOLID_BBOX; + setorigin(me, me.origin); + + vector source; + makevectors (them.v_angle); + source = them.origin + them.view_ofs; + traceline (source, source + v_forward*500, 0, them); + + if (trace_ent == me) + ret = true; + + me.solid = old_solid; + setorigin(me, me.origin); + return ret; }; \ No newline at end of file diff --git a/source/server/entities/machines.qc b/source/server/entities/machines.qc index f7ac19c..665e795 100644 --- a/source/server/entities/machines.qc +++ b/source/server/entities/machines.qc @@ -261,7 +261,7 @@ void() ReviveGoAway = // void() touch_perk = { - if (other.classname != "player" || other.downed || other.isBuying == true) + if (other.classname != "player" || other.downed || other.isBuying == true || !PlayerIsLooking(other, self)) return; // If we're proned and the map permits, collect some spare change @@ -1206,7 +1206,7 @@ void PapUpgrade(entity pap, entity buyer) { void touch_pap() { - if (other.classname != "player" || other.downed) { + if (other.classname != "player" || other.downed || !PlayerIsLooking(other, self)) { return; } diff --git a/source/server/entities/wall_weapon.qc b/source/server/entities/wall_weapon.qc index cea9f04..f6e0427 100644 --- a/source/server/entities/wall_weapon.qc +++ b/source/server/entities/wall_weapon.qc @@ -92,7 +92,7 @@ void() weapon_wall = // We are, indeed, Wall Chalk. Precache_Set("models/misc/chalk.mdl"); - setsize (self, VEC_HULL2_MIN, VEC_HULL2_MAX); + setsize (self, '-12 -12 -12', '12 12 12'); // Set-Up Weapon Prop. entity weapon_prop = spawn(); @@ -102,7 +102,7 @@ void() weapon_wall = self.enemy.solid = SOLID_NOT; self.enemy.owner = self; self.enemy.classname = "weapon_wall_prop"; - setsize(self.enemy, VEC_HULL2_MIN, VEC_HULL2_MAX); + setsize(self.enemy, '0 0 0', '0 0 0'); // We want the Prop to be slightly behind the Chalk. makevectors(self.angles); @@ -136,7 +136,7 @@ void () WallWeapon_TouchTrigger = float wcost; - if (other.classname != "player" || other.downed || other.isBuying) { + if (other.classname != "player" || other.downed || other.isBuying || !PlayerIsLooking(other, self)) { return; } @@ -333,6 +333,13 @@ void () WallWeapon_TouchTrigger = W_HideCrosshair(other); addmoney(other, -self.cost2, FALSE); other.ach_tracker_coll++; + if (self.enemy) + { + oldent = self; + self = self.enemy; + self.use(); + self = oldent; + } entity tempz; tempz = self; self = other; @@ -396,8 +403,15 @@ void() WallWeapon_LinkChalk = ent = find (world, targetname, self.target); - if (ent.classname == "weapon_wall") - self.enemy = ent; + if (ent.classname == "weapon_wall") { + self.enemy = ent; + self.mins = self.enemy.mins; + self.maxs = self.enemy.maxs; + self.origin = self.enemy.origin; + setsize(self, self.mins, self.maxs); + setorigin(self, self.origin); + } + } //