1 void SUB_DontUseTargets() { }
7 activator = self.enemy;
12 void FixSize(entity e)
14 e.mins_x = rint(e.mins_x);
15 e.mins_y = rint(e.mins_y);
16 e.mins_z = rint(e.mins_z);
18 e.maxs_x = rint(e.maxs_x);
19 e.maxs_y = rint(e.maxs_y);
20 e.maxs_z = rint(e.maxs_z);
25 void trigger_init(entity this)
27 string m = this.model;
28 WITH(entity, self, this, WarpZoneLib_ExactTrigger_Init());
32 _setmodel(this, m); // no precision needed
34 setorigin(this, this.origin);
36 setsize(this, this.mins * this.scale, this.maxs * this.scale);
38 setsize(this, this.mins, this.maxs);
40 BITSET_ASSIGN(this.effects, EF_NODEPTHTEST);
43 void trigger_link(entity this, bool(entity this, entity to, int sendflags) sendfunc)
45 this.SendEntity = SendEntity_self;
46 this.SendEntity3 = sendfunc;
47 this.SendFlags = 0xFFFFFF;
50 void trigger_common_write(entity this, bool withtarget)
53 if(this.warpzone_isboxy)
55 if(this.origin != '0 0 0')
57 WriteByte(MSG_ENTITY, f);
61 WriteString(MSG_ENTITY, this.target);
62 WriteString(MSG_ENTITY, this.target2);
63 WriteString(MSG_ENTITY, this.target3);
64 WriteString(MSG_ENTITY, this.target4);
65 WriteString(MSG_ENTITY, this.targetname);
66 WriteString(MSG_ENTITY, this.killtarget);
71 WriteCoord(MSG_ENTITY, this.origin.x);
72 WriteCoord(MSG_ENTITY, this.origin.y);
73 WriteCoord(MSG_ENTITY, this.origin.z);
76 WriteShort(MSG_ENTITY, this.modelindex);
77 WriteCoord(MSG_ENTITY, this.mins.x);
78 WriteCoord(MSG_ENTITY, this.mins.y);
79 WriteCoord(MSG_ENTITY, this.mins.z);
80 WriteCoord(MSG_ENTITY, this.maxs.x);
81 WriteCoord(MSG_ENTITY, this.maxs.y);
82 WriteCoord(MSG_ENTITY, this.maxs.z);
83 WriteByte(MSG_ENTITY, bound(1, this.scale * 16, 255));
85 WriteCoord(MSG_ENTITY, this.movedir_x);
86 WriteCoord(MSG_ENTITY, this.movedir_y);
87 WriteCoord(MSG_ENTITY, this.movedir_z);
89 WriteCoord(MSG_ENTITY, this.angles_x);
90 WriteCoord(MSG_ENTITY, this.angles_y);
91 WriteCoord(MSG_ENTITY, this.angles_z);
96 void trigger_common_read(bool withtarget)
99 self.warpzone_isboxy = (f & 1);
103 if(self.target) { strunzone(self.target); }
104 self.target = strzone(ReadString());
105 if(self.target2) { strunzone(self.target2); }
106 self.target2 = strzone(ReadString());
107 if(self.target3) { strunzone(self.target3); }
108 self.target3 = strzone(ReadString());
109 if(self.target4) { strunzone(self.target4); }
110 self.target4 = strzone(ReadString());
111 if(self.targetname) { strunzone(self.targetname); }
112 self.targetname = strzone(ReadString());
113 if(self.killtarget) { strunzone(self.killtarget); }
114 self.killtarget = strzone(ReadString());
119 self.origin_x = ReadCoord();
120 self.origin_y = ReadCoord();
121 self.origin_z = ReadCoord();
124 self.origin = '0 0 0';
125 setorigin(self, self.origin);
127 self.modelindex = ReadShort();
128 self.mins_x = ReadCoord();
129 self.mins_y = ReadCoord();
130 self.mins_z = ReadCoord();
131 self.maxs_x = ReadCoord();
132 self.maxs_y = ReadCoord();
133 self.maxs_z = ReadCoord();
134 self.scale = ReadByte() / 16;
135 setsize(self, self.mins, self.maxs);
137 self.movedir_x = ReadCoord();
138 self.movedir_y = ReadCoord();
139 self.movedir_z = ReadCoord();
141 self.angles_x = ReadCoord();
142 self.angles_y = ReadCoord();
143 self.angles_z = ReadCoord();
146 void trigger_remove_generic()
148 if(self.target) { strunzone(self.target); }
149 self.target = string_null;
151 if(self.target2) { strunzone(self.target2); }
152 self.target2 = string_null;
154 if(self.target3) { strunzone(self.target3); }
155 self.target3 = string_null;
157 if(self.target4) { strunzone(self.target4); }
158 self.target4 = string_null;
160 if(self.targetname) { strunzone(self.targetname); }
161 self.target = string_null;
163 if(self.killtarget) { strunzone(self.killtarget); }
164 self.killtarget = string_null;
169 ==============================
172 the global "activator" should be set to the entity that initiated the firing.
174 If self.delay is set, a DelayedUse entity will be created that will actually
175 do the SUB_UseTargets after that many seconds have passed.
177 Centerprints any self.message to the activator.
179 Removes all entities with a targetname that match self.killtarget,
180 and removes them, so some events can remove other triggers.
182 Search for (string)targetname in all entities that
183 match (string)self.target and call their .use function
185 ==============================
187 void SUB_UseTargets()
189 entity t, otemp, act;
198 // create a temp object to fire at a later time
200 t.nextthink = time + self.delay;
201 t.think = DelayThink;
203 t.message = self.message;
204 t.killtarget = self.killtarget;
205 t.target = self.target;
206 t.target2 = self.target2;
207 t.target3 = self.target3;
208 t.target4 = self.target4;
218 if(IS_PLAYER(activator) && self.message != "")
219 if(IS_REAL_CLIENT(activator))
221 centerprint(activator, self.message);
222 if (self.noise == "")
223 play2(activator, SND(TALK));
227 // kill the killtagets
232 for(t = world; (t = find(t, targetname, s)); )
243 if(this.target_random)
244 RandomSelection_Init();
246 for(i = 0; i < 4; ++i)
251 case 0: s = this.target; break;
252 case 1: s = this.target2; break;
253 case 2: s = this.target3; break;
254 case 3: s = this.target4; break;
258 // Flag to set func_clientwall state
259 // 1 == deactivate, 2 == activate, 0 == do nothing
260 float aw_flag = self.antiwall_flag;
261 for(t = world; (t = find(t, targetname, s)); )
264 if(this.target_random)
266 RandomSelection_Add(t, 0, string_null, 1, 0);
270 if (t.classname == "func_clientwall" || t.classname == "func_clientillusionary")
271 t.antiwall_flag = aw_flag;
281 if(this.target_random && RandomSelection_chosen_ent)
283 setself(RandomSelection_chosen_ent);
295 void trigger_touch_generic(void() touchfunc)
298 for(e = findradius((self.absmin + self.absmax) * 0.5, vlen(self.absmax - self.absmin) * 0.5 + 1); e; e = e.chain)
299 if(e.isplayermodel || e.classname == "csqcprojectile")
301 vector emin = e.absmin, emax = e.absmax;
302 if(self.solid == SOLID_BSP)
307 if(boxesoverlap(emin, emax, self.absmin, self.absmax)) // quick
308 if(WarpZoneLib_BoxTouchesBrush(emin, emax, self, e)) // accurate
315 void trigger_draw_generic(entity this)
317 float dt = time - self.move_time;
318 self.move_time = time;
319 if(dt <= 0) { return; }
321 if(self.trigger_touch) { trigger_touch_generic(self.trigger_touch); }