1 void generic_plat_blocked()
4 if(self.dmg && other.takedamage != DAMAGE_NO)
6 if(self.dmgtime2 < time)
8 Damage (other, self, self, self.dmg, DEATH_HURTTRIGGER, other.origin, '0 0 0');
9 self.dmgtime2 = time + self.dmgtime;
12 // Gib dead/dying stuff
13 if(other.deadflag != DEAD_NO)
14 Damage (other, self, self, 10000, DEATH_HURTTRIGGER, other.origin, '0 0 0');
20 float plat_trigger_send(entity to, float sf)
22 WriteByte(MSG_ENTITY, ENT_CLIENT_PLAT_TRIGGER);
23 WriteShort(MSG_ENTITY, num_for_edict(self.enemy));
25 WriteCoord(MSG_ENTITY, self.origin_x);
26 WriteCoord(MSG_ENTITY, self.origin_y);
27 WriteCoord(MSG_ENTITY, self.origin_z);
29 WriteCoord(MSG_ENTITY, self.mins_x);
30 WriteCoord(MSG_ENTITY, self.mins_y);
31 WriteCoord(MSG_ENTITY, self.mins_z);
32 WriteCoord(MSG_ENTITY, self.maxs_x);
33 WriteCoord(MSG_ENTITY, self.maxs_y);
34 WriteCoord(MSG_ENTITY, self.maxs_z);
38 void plat_spawn_inside_trigger()
44 trigger.touch = plat_center_touch;
45 trigger.movetype = MOVETYPE_NONE;
46 trigger.solid = SOLID_TRIGGER;
49 tmin = self.absmin + '25 25 0';
50 tmax = self.absmax - '25 25 -8';
51 tmin_z = tmax_z - (self.pos1_z - self.pos2_z + 8);
52 if (self.spawnflags & PLAT_LOW_TRIGGER)
55 if (self.size_x <= 50)
57 tmin_x = (self.mins_x + self.maxs_x) / 2;
60 if (self.size_y <= 50)
62 tmin_y = (self.mins_y + self.maxs_y) / 2;
70 setsize (trigger, tmin, tmax);
71 Net_LinkEntity(trigger, false, 0, plat_trigger_send);
75 // otherwise, something is fishy...
77 objerror("plat_spawn_inside_trigger: platform has odd size or lip, can't spawn");
80 void ent_plat_trigger()
82 float myenemy = ReadShort();
83 self.origin_x = ReadCoord();
84 self.origin_y = ReadCoord();
85 self.origin_z = ReadCoord();
86 setorigin(self, self.origin);
88 self.mins_x = ReadCoord();
89 self.mins_y = ReadCoord();
90 self.mins_z = ReadCoord();
91 self.maxs_x = ReadCoord();
92 self.maxs_y = ReadCoord();
93 self.maxs_z = ReadCoord();
94 setsize(self, self.mins, self.maxs);
96 self.enemy = findfloat(world, sv_entnum, myenemy);
97 if(!self.enemy) { print("^1BAD BAD BAD!!!\n"); }
98 self.drawmask = MASK_NORMAL;
99 self.draw = trigger_draw_generic;
100 self.trigger_touch = plat_center_touch;
101 self.solid = SOLID_TRIGGER;
107 sound (self, CH_TRIGGER_SINGLE, self.noise1, VOL_BASE, ATTEN_NORM);
109 self.think = plat_go_down;
110 trigger_setnextthink(self, self.ltime + 3);
113 void plat_hit_bottom()
115 sound (self, CH_TRIGGER_SINGLE, self.noise1, VOL_BASE, ATTEN_NORM);
121 sound (self, CH_TRIGGER_SINGLE, self.noise, VOL_BASE, ATTEN_NORM);
123 SUB_CalcMove (self.pos2, TSPEED_LINEAR, self.speed, plat_hit_bottom);
128 sound (self, CH_TRIGGER_SINGLE, self.noise, VOL_BASE, ATTEN_NORM);
130 SUB_CalcMove (self.pos1, TSPEED_LINEAR, self.speed, plat_hit_top);
133 void plat_center_touch()
136 if (!other.iscreature)
139 if (other.health <= 0)
142 if (!IS_PLAYER(other))
149 else if (self.state == 1)
150 trigger_setnextthink(self, self.ltime + 1);
153 void plat_outside_touch()
156 if (!other.iscreature)
159 if (other.health <= 0)
162 if (!IS_PLAYER(other))
171 void plat_trigger_use()
174 return; // already activated
181 if((self.spawnflags & 4) && (other.takedamage != DAMAGE_NO))
182 { // KIll Kill Kill!!
184 Damage (other, self, self, 10000, DEATH_HURTTRIGGER, other.origin, '0 0 0');
190 if((self.dmg) && (other.takedamage != DAMAGE_NO))
192 Damage (other, self, self, self.dmg, DEATH_HURTTRIGGER, other.origin, '0 0 0');
193 // Gib dead/dying stuff
194 if(other.deadflag != DEAD_NO)
195 Damage (other, self, self, 10000, DEATH_HURTTRIGGER, other.origin, '0 0 0');
201 else if (self.state == 3)
203 // when in other states, then the plat_crush event came delayed after
204 // plat state already had changed
205 // this isn't a bug per se!
211 self.use = func_null;
213 objerror ("plat_use: not in up state");
217 .string sound1, sound2;
223 setorigin (self, self.pos1);
229 setorigin (self, self.pos2);
231 self.use = plat_trigger_use;
235 self.SendFlags |= SF_TRIGGER_RESET;
240 .float platmovetype_start_default, platmovetype_end_default;
241 float set_platmovetype(entity e, string s)
243 // sets platmovetype_start and platmovetype_end based on a string consisting of two values
246 n = tokenize_console(s);
248 e.platmovetype_start = stof(argv(0));
250 e.platmovetype_start = 0;
253 e.platmovetype_end = stof(argv(1));
255 e.platmovetype_end = e.platmovetype_start;
258 if(argv(2) == "force")
259 return true; // no checking, return immediately
261 if(!cubic_speedfunc_is_sane(e.platmovetype_start, e.platmovetype_end))
263 objerror("Invalid platform move type; platform would go in reverse, which is not allowed.");