1 // NOTE: also contains trigger_once at bottom
4 // the wait time has passed, so set back up for another activation
9 self.health = self.max_health;
10 self.takedamage = DAMAGE_YES;
11 self.solid = SOLID_BBOX;
16 // the trigger was just touched/killed/used
17 // self.enemy should be set to the activator so it can be held through a delay
18 // so wait for the delay time before firing
21 if (self.nextthink > time)
23 return; // allready been triggered
26 if(self.spawnflags & 16384)
27 if(!IS_PLAYER(self.enemy))
28 return; // only players
30 if (self.classname == "trigger_secret")
32 if (!IS_PLAYER(self.enemy))
34 found_secrets = found_secrets + 1;
35 WriteByte (MSG_ALL, SVC_FOUNDSECRET);
39 _sound (self.enemy, CH_TRIGGER, self.noise, VOL_BASE, ATTEN_NORM);
41 // don't trigger again until reset
42 self.takedamage = DAMAGE_NO;
44 activator = self.enemy;
45 other = self.goalentity;
50 self.think = multi_wait;
51 self.nextthink = time + self.wait;
53 else if (self.wait == 0)
55 multi_wait(); // waiting finished
58 { // we can't just remove (self) here, because this is a touch function
59 // called wheil C code is looping through area links...
60 self.touch = func_null;
66 self.goalentity = other;
67 self.enemy = activator;
73 if(!(self.spawnflags & 2))
78 if(((self.spawnflags & 4) == 0) == (self.team != other.team))
81 // if the trigger has an angles field, check player's facing direction
82 if (self.movedir != '0 0 0')
84 makevectors (other.angles);
85 if (v_forward * self.movedir < 0)
86 return; // not facing the right way
89 // if the trigger has pressed keys, check that the player is pressing those keys
91 if(IS_PLAYER(other)) // only for players
92 if(!(other.pressedkeys & self.pressedkeys))
98 self.goalentity = other;
102 void multi_eventdamage (entity inflictor, entity attacker, float damage, int deathtype, vector hitloc, vector force)
104 if (!self.takedamage)
106 if(self.spawnflags & DOOR_NOSPLASH)
107 if(!(DEATH_ISSPECIAL(deathtype)) && (deathtype & HITTYPE_SPLASH))
109 self.health = self.health - damage;
110 if (self.health <= 0)
112 self.enemy = attacker;
113 self.goalentity = inflictor;
120 if ( !(self.spawnflags & SPAWNFLAG_NOTOUCH) )
121 self.touch = multi_touch;
124 self.health = self.max_health;
125 self.takedamage = DAMAGE_YES;
126 self.solid = SOLID_BBOX;
128 self.think = func_null;
130 self.team = self.team_saved;
133 /*QUAKED spawnfunc_trigger_multiple (.5 .5 .5) ? notouch
134 Variable sized repeatable trigger. Must be targeted at one or more entities. If "health" is set, the trigger must be killed to activate each time.
135 If "delay" is set, the trigger waits some time after activating before firing.
136 "wait" : Seconds between triggerings. (.2 default)
137 If notouch is set, the trigger is only fired by other entities, not by touching.
138 NOTOUCH has been obsoleted by spawnfunc_trigger_relay!
144 set "message" to text string
146 spawnfunc(trigger_multiple)
148 self.reset = multi_reset;
149 if (self.sounds == 1)
151 precache_sound ("misc/secret.wav");
152 self.noise = "misc/secret.wav";
154 else if (self.sounds == 2)
156 self.noise = strzone(SND(TALK));
158 else if (self.sounds == 3)
160 precache_sound ("misc/trigger1.wav");
161 self.noise = "misc/trigger1.wav";
166 else if(self.wait < -1)
168 self.use = multi_use;
172 self.team_saved = self.team;
176 if (self.spawnflags & SPAWNFLAG_NOTOUCH)
177 objerror ("health and notouch don't make sense\n");
178 self.max_health = self.health;
179 self.event_damage = multi_eventdamage;
180 self.takedamage = DAMAGE_YES;
181 self.solid = SOLID_BBOX;
182 setorigin (self, self.origin); // make sure it links into the world
186 if ( !(self.spawnflags & SPAWNFLAG_NOTOUCH) )
188 self.touch = multi_touch;
189 setorigin (self, self.origin); // make sure it links into the world
195 /*QUAKED spawnfunc_trigger_once (.5 .5 .5) ? notouch
196 Variable sized trigger. Triggers once, then removes itself. You must set the key "target" to the name of another object in the level that has a matching
197 "targetname". If "health" is set, the trigger must be killed to activate.
198 If notouch is set, the trigger is only fired by other entities, not by touching.
199 if "killtarget" is set, any objects that have a matching "target" will be removed when the trigger is fired.
200 if "angle" is set, the trigger will only fire when someone is facing the direction of the angle. Use "360" for an angle of 0.
206 set "message" to text string
208 spawnfunc(trigger_once)
211 spawnfunc_trigger_multiple(this);