3 bool isPushable(entity e)
20 case "bullet": // antilagged bullets can't hit this either
23 if (e.projectiledeathtype)
27 if(e.flags & FL_PROJECTILE)
35 void SUB_DontUseTargets(entity this, entity actor, entity trigger) { }
37 void SUB_UseTargets(entity this, entity actor, entity trigger);
39 void DelayThink(entity this)
41 SUB_UseTargets (this, this.enemy, NULL);
46 void generic_setactive(entity this, int act)
48 if(act == ACTIVE_TOGGLE)
50 if(this.active == ACTIVE_ACTIVE)
52 this.active = ACTIVE_NOT;
56 this.active = ACTIVE_ACTIVE;
65 void generic_netlinked_setactive(entity this, int act)
67 int old_status = this.active;
68 generic_setactive(this, act);
70 if (this.active != old_status)
72 this.SendFlags |= SF_TRIGGER_UPDATE;
76 void generic_netlinked_reset(entity this)
78 if(this.targetname && this.targetname != "")
80 if(this.spawnflags & START_ENABLED)
82 this.active = ACTIVE_ACTIVE;
86 this.active = ACTIVE_NOT;
91 this.active = ACTIVE_ACTIVE;
94 this.SendFlags |= SF_TRIGGER_UPDATE;
97 // Compatibility with old maps
98 void generic_netlinked_legacy_use(entity this, entity actor, entity trigger)
100 //LOG_WARNF("Entity %s was (de)activated by a trigger, please update map to use relays", this.targetname);
101 this.setactive(this, ACTIVE_TOGGLE);
104 void trigger_link(entity this, bool(entity this, entity to, int sendflags) sendfunc)
106 setSendEntity(this, sendfunc);
107 this.SendFlags = 0xFFFFFF;
110 void trigger_common_write(entity this, bool withtarget)
113 if(this.warpzone_isboxy)
115 if(this.origin != '0 0 0')
117 if(this.movedir != '0 0 0')
119 if(this.angles != '0 0 0')
120 BITSET_ASSIGN(f, 16);
121 WriteByte(MSG_ENTITY, f);
125 // probably some way to clean this up...
127 if(this.target && this.target != "") targbits |= BIT(0);
128 if(this.target2 && this.target2 != "") targbits |= BIT(1);
129 if(this.target3 && this.target3 != "") targbits |= BIT(2);
130 if(this.target4 && this.target4 != "") targbits |= BIT(3);
131 if(this.targetname && this.targetname != "") targbits |= BIT(4);
132 if(this.killtarget && this.killtarget != "") targbits |= BIT(5);
134 WriteByte(MSG_ENTITY, targbits);
136 if(targbits & BIT(0))
137 WriteString(MSG_ENTITY, this.target);
138 if(targbits & BIT(1))
139 WriteString(MSG_ENTITY, this.target2);
140 if(targbits & BIT(2))
141 WriteString(MSG_ENTITY, this.target3);
142 if(targbits & BIT(3))
143 WriteString(MSG_ENTITY, this.target4);
144 if(targbits & BIT(4))
145 WriteString(MSG_ENTITY, this.targetname);
146 if(targbits & BIT(5))
147 WriteString(MSG_ENTITY, this.killtarget);
151 WriteVector(MSG_ENTITY, this.origin);
154 WriteVector(MSG_ENTITY, this.movedir);
157 WriteVector(MSG_ENTITY, this.angles);
159 WriteShort(MSG_ENTITY, this.modelindex);
160 WriteVector(MSG_ENTITY, this.mins);
161 WriteVector(MSG_ENTITY, this.maxs);
162 WriteByte(MSG_ENTITY, bound(1, this.scale * 16, 255));
167 void trigger_common_read(entity this, bool withtarget)
170 this.warpzone_isboxy = (f & 1);
174 strfree(this.target);
175 strfree(this.target2);
176 strfree(this.target3);
177 strfree(this.target4);
178 strfree(this.targetname);
179 strfree(this.killtarget);
181 int targbits = ReadByte();
183 this.target = ((targbits & BIT(0)) ? strzone(ReadString()) : string_null);
184 this.target2 = ((targbits & BIT(1)) ? strzone(ReadString()) : string_null);
185 this.target3 = ((targbits & BIT(2)) ? strzone(ReadString()) : string_null);
186 this.target4 = ((targbits & BIT(3)) ? strzone(ReadString()) : string_null);
187 this.targetname = ((targbits & BIT(4)) ? strzone(ReadString()) : string_null);
188 this.killtarget = ((targbits & BIT(5)) ? strzone(ReadString()) : string_null);
192 this.origin = ReadVector();
194 this.origin = '0 0 0';
195 setorigin(this, this.origin);
198 this.movedir = ReadVector();
200 this.movedir = '0 0 0';
203 this.angles = ReadVector();
205 this.angles = '0 0 0';
207 this.modelindex = ReadShort();
208 this.mins = ReadVector();
209 this.maxs = ReadVector();
210 this.scale = ReadByte() / 16;
211 setsize(this, this.mins, this.maxs);
214 void trigger_remove_generic(entity this)
216 strfree(this.target);
217 strfree(this.target2);
218 strfree(this.target3);
219 strfree(this.target4);
220 strfree(this.targetname);
221 strfree(this.killtarget);
227 ==============================
230 the global "activator" should be set to the entity that initiated the firing.
232 If this.delay is set, a DelayedUse entity will be created that will actually
233 do the SUB_UseTargets after that many seconds have passed.
235 Centerprints any this.message to the activator.
237 Removes all entities with a targetname that match this.killtarget,
238 and removes them, so some events can remove other triggers.
240 Search for (string)targetname in all entities that
241 match (string)this.target and call their .use function
243 ==============================
246 void SUB_UseTargets_Ex(entity this, entity actor, entity trigger, bool preventReuse, int skiptargets)
253 // create a temp object to fire at a later time
254 entity t = new_pure(DelayedUse);
255 t.nextthink = time + this.delay;
256 setthink(t, DelayThink);
258 t.message = this.message;
259 t.killtarget = this.killtarget;
260 if(!(skiptargets & BIT(1))) t.target = this.target;
261 if(!(skiptargets & BIT(2))) t.target2 = this.target2;
262 if(!(skiptargets & BIT(3))) t.target3 = this.target3;
263 if(!(skiptargets & BIT(4))) t.target4 = this.target4;
264 t.antiwall_flag = this.antiwall_flag;
275 if(IS_PLAYER(actor) && this.message != "")
276 if(IS_REAL_CLIENT(actor))
278 centerprint(actor, this.message);
279 if (this.noise == "")
280 play2(actor, SND(TALK));
284 // kill the killtagets
289 for(entity t = NULL; (t = find(t, targetname, s)); )
298 if(this.target_random)
299 RandomSelection_Init();
301 for(int i = 0; i < 4; ++i)
303 if(skiptargets & BIT(i + 1))
308 case 0: s = this.target; break;
309 case 1: s = this.target2; break;
310 case 2: s = this.target3; break;
311 case 3: s = this.target4; break;
315 for(entity t = NULL; (t = find(t, targetname, s)); )
317 if(t != this && t.use && (t.sub_target_used != time || !preventReuse))
319 if(this.target_random)
321 RandomSelection_AddEnt(t, 1, 0);
325 t.use(t, actor, this);
327 t.sub_target_used = time;
334 if(this.target_random && RandomSelection_chosen_ent)
336 RandomSelection_chosen_ent.use(RandomSelection_chosen_ent, actor, this);
338 RandomSelection_chosen_ent.sub_target_used = time;
342 void SUB_UseTargets(entity this, entity actor, entity trigger) { SUB_UseTargets_Ex(this, actor, trigger, false, 0); }
343 void SUB_UseTargets_PreventReuse(entity this, entity actor, entity trigger) { SUB_UseTargets_Ex(this, actor, trigger, true, 0); }
344 void SUB_UseTargets_SkipTargets(entity this, entity actor, entity trigger, int skiptargets) { SUB_UseTargets_Ex(this, actor, trigger, false, skiptargets); }