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.classname == "trigger_secret")
28 if (!IS_PLAYER(self.enemy))
30 found_secrets = found_secrets + 1;
31 WriteByte (MSG_ALL, SVC_FOUNDSECRET);
35 sound (self.enemy, CH_TRIGGER, self.noise, VOL_BASE, ATTEN_NORM);
37 // don't trigger again until reset
38 self.takedamage = DAMAGE_NO;
40 activator = self.enemy;
41 other = self.goalentity;
46 self.think = multi_wait;
47 self.nextthink = time + self.wait;
49 else if (self.wait == 0)
51 multi_wait(); // waiting finished
54 { // we can't just remove (self) here, because this is a touch function
55 // called wheil C code is looping through area links...
56 self.touch = func_null;
62 self.goalentity = other;
63 self.enemy = activator;
69 if(!(self.spawnflags & 2))
74 if(((self.spawnflags & 4) == 0) == (self.team != other.team))
77 // if the trigger has an angles field, check player's facing direction
78 if (self.movedir != '0 0 0')
80 makevectors (other.angles);
81 if (v_forward * self.movedir < 0)
82 return; // not facing the right way
85 // if the trigger has pressed keys, check that the player is pressing those keys
87 if(IS_PLAYER(other)) // only for players
88 if(!(other.pressedkeys & self.pressedkeys))
94 self.goalentity = other;
98 void multi_eventdamage (entity inflictor, entity attacker, float damage, int deathtype, vector hitloc, vector force)
100 if (!self.takedamage)
102 if(self.spawnflags & DOOR_NOSPLASH)
103 if(!(DEATH_ISSPECIAL(deathtype)) && (deathtype & HITTYPE_SPLASH))
105 self.health = self.health - damage;
106 if (self.health <= 0)
108 self.enemy = attacker;
109 self.goalentity = inflictor;
116 if ( !(self.spawnflags & SPAWNFLAG_NOTOUCH) )
117 self.touch = multi_touch;
120 self.health = self.max_health;
121 self.takedamage = DAMAGE_YES;
122 self.solid = SOLID_BBOX;
124 self.think = func_null;
126 self.team = self.team_saved;
129 /*QUAKED spawnfunc_trigger_multiple (.5 .5 .5) ? notouch
130 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.
131 If "delay" is set, the trigger waits some time after activating before firing.
132 "wait" : Seconds between triggerings. (.2 default)
133 If notouch is set, the trigger is only fired by other entities, not by touching.
134 NOTOUCH has been obsoleted by spawnfunc_trigger_relay!
140 set "message" to text string
142 void spawnfunc_trigger_multiple()
144 self.reset = multi_reset;
145 if (self.sounds == 1)
147 precache_sound ("misc/secret.wav");
148 self.noise = "misc/secret.wav";
150 else if (self.sounds == 2)
152 precache_sound ("misc/talk.wav");
153 self.noise = "misc/talk.wav";
155 else if (self.sounds == 3)
157 precache_sound ("misc/trigger1.wav");
158 self.noise = "misc/trigger1.wav";
163 else if(self.wait < -1)
165 self.use = multi_use;
169 self.team_saved = self.team;
173 if (self.spawnflags & SPAWNFLAG_NOTOUCH)
174 objerror ("health and notouch don't make sense\n");
175 self.max_health = self.health;
176 self.event_damage = multi_eventdamage;
177 self.takedamage = DAMAGE_YES;
178 self.solid = SOLID_BBOX;
179 setorigin (self, self.origin); // make sure it links into the world
183 if ( !(self.spawnflags & SPAWNFLAG_NOTOUCH) )
185 self.touch = multi_touch;
186 setorigin (self, self.origin); // make sure it links into the world
192 /*QUAKED spawnfunc_trigger_once (.5 .5 .5) ? notouch
193 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
194 "targetname". If "health" is set, the trigger must be killed to activate.
195 If notouch is set, the trigger is only fired by other entities, not by touching.
196 if "killtarget" is set, any objects that have a matching "target" will be removed when the trigger is fired.
197 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.
203 set "message" to text string
205 void spawnfunc_trigger_once()
208 spawnfunc_trigger_multiple();