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);
24 void trigger_common_write(bool withtarget)
26 WriteByte(MSG_ENTITY, self.warpzone_isboxy);
27 WriteByte(MSG_ENTITY, self.scale);
31 WriteString(MSG_ENTITY, self.target);
32 WriteString(MSG_ENTITY, self.target2);
33 WriteString(MSG_ENTITY, self.target3);
34 WriteString(MSG_ENTITY, self.target4);
35 WriteString(MSG_ENTITY, self.targetname);
36 WriteString(MSG_ENTITY, self.killtarget);
39 WriteCoord(MSG_ENTITY, self.origin_x);
40 WriteCoord(MSG_ENTITY, self.origin_y);
41 WriteCoord(MSG_ENTITY, self.origin_z);
43 WriteCoord(MSG_ENTITY, self.mins_x);
44 WriteCoord(MSG_ENTITY, self.mins_y);
45 WriteCoord(MSG_ENTITY, self.mins_z);
46 WriteCoord(MSG_ENTITY, self.maxs_x);
47 WriteCoord(MSG_ENTITY, self.maxs_y);
48 WriteCoord(MSG_ENTITY, self.maxs_z);
50 WriteCoord(MSG_ENTITY, self.movedir_x);
51 WriteCoord(MSG_ENTITY, self.movedir_y);
52 WriteCoord(MSG_ENTITY, self.movedir_z);
54 WriteCoord(MSG_ENTITY, self.angles_x);
55 WriteCoord(MSG_ENTITY, self.angles_y);
56 WriteCoord(MSG_ENTITY, self.angles_z);
61 void trigger_common_read(bool withtarget)
63 self.warpzone_isboxy = ReadByte();
64 self.scale = ReadByte();
68 self.target = strzone(ReadString());
69 self.target2 = strzone(ReadString());
70 self.target3 = strzone(ReadString());
71 self.target4 = strzone(ReadString());
72 self.targetname = strzone(ReadString());
73 self.killtarget = strzone(ReadString());
76 self.origin_x = ReadCoord();
77 self.origin_y = ReadCoord();
78 self.origin_z = ReadCoord();
79 setorigin(self, self.origin);
81 self.mins_x = ReadCoord();
82 self.mins_y = ReadCoord();
83 self.mins_z = ReadCoord();
84 self.maxs_x = ReadCoord();
85 self.maxs_y = ReadCoord();
86 self.maxs_z = ReadCoord();
87 setsize(self, self.mins, self.maxs);
89 self.movedir_x = ReadCoord();
90 self.movedir_y = ReadCoord();
91 self.movedir_z = ReadCoord();
93 self.angles_x = ReadCoord();
94 self.angles_y = ReadCoord();
95 self.angles_z = ReadCoord();
98 void trigger_remove_generic()
100 if(self.target) { strunzone(self.target); }
101 self.target = string_null;
103 if(self.target2) { strunzone(self.target2); }
104 self.target2 = string_null;
106 if(self.target3) { strunzone(self.target3); }
107 self.target3 = string_null;
109 if(self.target4) { strunzone(self.target4); }
110 self.target4 = string_null;
112 if(self.targetname) { strunzone(self.targetname); }
113 self.target = string_null;
115 if(self.killtarget) { strunzone(self.killtarget); }
116 self.killtarget = string_null;
121 ==============================
124 the global "activator" should be set to the entity that initiated the firing.
126 If self.delay is set, a DelayedUse entity will be created that will actually
127 do the SUB_UseTargets after that many seconds have passed.
129 Centerprints any self.message to the activator.
131 Removes all entities with a targetname that match self.killtarget,
132 and removes them, so some events can remove other triggers.
134 Search for (string)targetname in all entities that
135 match (string)self.target and call their .use function
137 ==============================
139 void SUB_UseTargets()
141 entity t, stemp, otemp, act;
150 // create a temp object to fire at a later time
152 t.classname = "DelayedUse";
153 t.nextthink = time + self.delay;
154 t.think = DelayThink;
156 t.message = self.message;
157 t.killtarget = self.killtarget;
158 t.target = self.target;
159 t.target2 = self.target2;
160 t.target3 = self.target3;
161 t.target4 = self.target4;
171 if(IS_PLAYER(activator) && self.message != "")
172 if(IS_REAL_CLIENT(activator))
174 centerprint(activator, self.message);
175 if (self.noise == "")
176 play2(activator, "misc/talk.wav");
180 // kill the killtagets
185 for(t = world; (t = find(t, targetname, s)); )
197 if(stemp.target_random)
198 RandomSelection_Init();
200 for(i = 0; i < 4; ++i)
205 case 0: s = stemp.target; break;
206 case 1: s = stemp.target2; break;
207 case 2: s = stemp.target3; break;
208 case 3: s = stemp.target4; break;
212 for(t = world; (t = find(t, targetname, s)); )
215 if(stemp.target_random)
217 RandomSelection_Add(t, 0, string_null, 1, 0);
230 if(stemp.target_random && RandomSelection_chosen_ent)
232 self = RandomSelection_chosen_ent;
244 void trigger_think_generic()
246 self.nextthink = time;
249 if(self.trigger_touch)
250 for(e = findradius((self.absmin + self.absmax) * 0.5, vlen(self.absmax - self.absmin) * 0.5 + 1); e; e = e.chain)
252 vector emin = e.absmin, emax = e.absmax;
253 if(self.solid == SOLID_BSP)
258 if(boxesoverlap(emin, emax, self.absmin, self.absmax)) // quick
259 if(WarpZoneLib_BoxTouchesBrush(emin, emax, self, e)) // accurate
262 self.trigger_touch();
269 void trigger_touch_generic(void() touchfunc)
272 for(e = findradius((self.absmin + self.absmax) * 0.5, vlen(self.absmax - self.absmin) * 0.5 + 1); e; e = e.chain)
273 if(e.isplayermodel || e.classname == "csqcprojectile")
275 vector emin = e.absmin, emax = e.absmax;
276 if(self.solid == SOLID_BSP)
281 if(boxesoverlap(emin, emax, self.absmin, self.absmax)) // quick
282 if(WarpZoneLib_BoxTouchesBrush(emin, emax, self, e)) // accurate
289 void trigger_draw_generic()
291 float dt = time - self.move_time;
292 self.move_time = time;
293 if(dt <= 0) { return; }
295 if(self.trigger_touch) { trigger_touch_generic(self.trigger_touch); }