1 void SUB_DontUseTargets() { }
7 activator = this.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 WITHSELF(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 this.warpzone_isboxy = (f & 1);
103 if(this.target) { strunzone(this.target); }
104 this.target = strzone(ReadString());
105 if(this.target2) { strunzone(this.target2); }
106 this.target2 = strzone(ReadString());
107 if(this.target3) { strunzone(this.target3); }
108 this.target3 = strzone(ReadString());
109 if(this.target4) { strunzone(this.target4); }
110 this.target4 = strzone(ReadString());
111 if(this.targetname) { strunzone(this.targetname); }
112 this.targetname = strzone(ReadString());
113 if(this.killtarget) { strunzone(this.killtarget); }
114 this.killtarget = strzone(ReadString());
119 this.origin_x = ReadCoord();
120 this.origin_y = ReadCoord();
121 this.origin_z = ReadCoord();
124 this.origin = '0 0 0';
125 setorigin(this, this.origin);
127 this.modelindex = ReadShort();
128 this.mins_x = ReadCoord();
129 this.mins_y = ReadCoord();
130 this.mins_z = ReadCoord();
131 this.maxs_x = ReadCoord();
132 this.maxs_y = ReadCoord();
133 this.maxs_z = ReadCoord();
134 this.scale = ReadByte() / 16;
135 setsize(this, this.mins, this.maxs);
137 this.movedir_x = ReadCoord();
138 this.movedir_y = ReadCoord();
139 this.movedir_z = ReadCoord();
141 this.angles_x = ReadCoord();
142 this.angles_y = ReadCoord();
143 this.angles_z = ReadCoord();
146 void trigger_remove_generic(entity this)
148 if(this.target) { strunzone(this.target); }
149 this.target = string_null;
151 if(this.target2) { strunzone(this.target2); }
152 this.target2 = string_null;
154 if(this.target3) { strunzone(this.target3); }
155 this.target3 = string_null;
157 if(this.target4) { strunzone(this.target4); }
158 this.target4 = string_null;
160 if(this.targetname) { strunzone(this.targetname); }
161 this.target = string_null;
163 if(this.killtarget) { strunzone(this.killtarget); }
164 this.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 + this.delay;
201 t.think = DelayThink;
203 t.message = this.message;
204 t.killtarget = this.killtarget;
205 t.target = this.target;
206 t.target2 = this.target2;
207 t.target3 = this.target3;
208 t.target4 = this.target4;
218 if(IS_PLAYER(activator) && this.message != "")
219 if(IS_REAL_CLIENT(activator))
221 centerprint(activator, this.message);
222 if (this.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 = this.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(entity this, void() touchfunc)
298 for(e = findradius((this.absmin + this.absmax) * 0.5, vlen(this.absmax - this.absmin) * 0.5 + 1); e; e = e.chain)
299 if(e.classname == "csqcprojectile")
301 vector emin = e.absmin, emax = e.absmax;
302 if(this.solid == SOLID_BSP)
307 if(boxesoverlap(emin, emax, this.absmin, this.absmax)) // quick
308 if(WarpZoneLib_BoxTouchesBrush(emin, emax, this, e)) // accurate
311 WITHSELF(this, touchfunc());
315 void trigger_draw_generic(entity this)
317 float dt = time - this.move_time;
318 this.move_time = time;
319 if(dt <= 0) { return; }
321 if(this.trigger_touch) { trigger_touch_generic(this, this.trigger_touch); }