SERVER: Require client to look at certain entities for triggering

This commit is contained in:
cypress 2023-10-18 10:00:25 -04:00
parent c3fa9ac216
commit 81693dcd77
3 changed files with 41 additions and 7 deletions

View file

@ -625,3 +625,23 @@ void(entity person, float expamt, float doublepoint) addmoney =
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;
};

View file

@ -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;
}

View file

@ -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")
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);
}
}
//