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 self.nextthink = 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))
147 print("Got this far\n");
153 else if (self.state == 1)
154 self.nextthink = self.ltime + 1; // delay going down
157 void plat_outside_touch()
160 if (!other.iscreature)
163 if (other.health <= 0)
166 if (!IS_PLAYER(other))
175 void plat_trigger_use()
178 return; // already activated
185 if((self.spawnflags & 4) && (other.takedamage != DAMAGE_NO))
186 { // KIll Kill Kill!!
188 Damage (other, self, self, 10000, DEATH_HURTTRIGGER, other.origin, '0 0 0');
194 if((self.dmg) && (other.takedamage != DAMAGE_NO))
196 Damage (other, self, self, self.dmg, DEATH_HURTTRIGGER, other.origin, '0 0 0');
197 // Gib dead/dying stuff
198 if(other.deadflag != DEAD_NO)
199 Damage (other, self, self, 10000, DEATH_HURTTRIGGER, other.origin, '0 0 0');
205 else if (self.state == 3)
207 // when in other states, then the plat_crush event came delayed after
208 // plat state already had changed
209 // this isn't a bug per se!
215 self.use = func_null;
217 objerror ("plat_use: not in up state");
221 .string sound1, sound2;
227 setorigin (self, self.pos1);
233 setorigin (self, self.pos2);
235 self.use = plat_trigger_use;
239 self.SendFlags |= SF_TRIGGER_RESET;
244 .float platmovetype_start_default, platmovetype_end_default;
245 float set_platmovetype(entity e, string s)
247 // sets platmovetype_start and platmovetype_end based on a string consisting of two values
250 n = tokenize_console(s);
252 e.platmovetype_start = stof(argv(0));
254 e.platmovetype_start = 0;
257 e.platmovetype_end = stof(argv(1));
259 e.platmovetype_end = e.platmovetype_start;
262 if(argv(2) == "force")
263 return true; // no checking, return immediately
265 if(!cubic_speedfunc_is_sane(e.platmovetype_start, e.platmovetype_end))
267 objerror("Invalid platform move type; platform would go in reverse, which is not allowed.");