mirror of
https://github.com/nzp-team/quakec.git
synced 2024-11-22 20:01:34 +00:00
SERVER: Require client to look at certain entities for triggering
This commit is contained in:
parent
c3fa9ac216
commit
81693dcd77
3 changed files with 41 additions and 7 deletions
|
@ -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;
|
||||
};
|
|
@ -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;
|
||||
}
|
||||
|
||||
|
|
|
@ -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);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
//
|
||||
|
|
Loading…
Reference in a new issue