self.nextthink = self.ltime + 1; // delay going down
}
};
void() plat_outside_touch = {
if(other.classname != "player") {
return;
}
if(other.health <= 0) {
return;
}
//dprint("plat_outside_touch\n");
self = self.enemy;
if(self.state == STATE_TOP) {
plat_go_down();
}
};
void() plat_trigger_use = {
if(self.think) {
return; // allready activated
}
plat_go_down();
};
void() plat_crush = {
//dprint("plat_crush\n");
T_Damage(other, self, self, 1);
if(self.state == STATE_UP) {
plat_go_down();
} else if(self.state == STATE_DOWN) {
plat_go_up();
} else {
objerror("plat_crush: bad self.state\n");
}
};
void() plat_use = {
self.use = SUB_Null;
if(self.state != STATE_UP) {
objerror("plat_use: not in up state");
}
plat_go_down();
};
/*QUAKED func_plat(0 .5 .8) ? PLAT_LOW_TRIGGER
speed default 150
Plats are always drawn in the extended position, so they will light correctly.
If the plat is the target of another trigger or button, it will start out disabled in the extended position until it is trigger, when it will lower and become a normal plat.
If the "height" key is set, that will determine the amount the plat moves, instead of being implicitly determined by the model's height.
Set "sounds" to one of the following:
1) base fast
2) chain slow
*/
void() func_plat =
{
local entity t;
if(!self.t_length) {
self.t_length = 80;
}
if(!self.t_width) {
self.t_width = 10;
}
if(self.sounds == 0) {
self.sounds = 2;
}
// FIX THIS TO LOAD A GENERIC PLAT SOUND
if(self.sounds == 1) {
precache_sound("plats/plat1.wav");
precache_sound("plats/plat2.wav");
self.noise = "plats/plat1.wav";
self.noise1 = "plats/plat2.wav";
}
if(self.sounds == 2) {
precache_sound("plats/medplat1.wav");
precache_sound("plats/medplat2.wav");
self.noise = "plats/medplat1.wav";
self.noise1 = "plats/medplat2.wav";
}
self.mangle = self.angles;
self.angles = '0 0 0';
self.classname = "plat";
self.solid = SOLID_BSP;
self.movetype = MOVETYPE_PUSH;
setorigin(self, self.origin);
setmodel(self, self.model);
setsize(self, self.mins, self.maxs);
self.blocked = plat_crush;
if(!self.speed) {
self.speed = 150;
}
// pos1 is the top position, pos2 is the bottom
self.pos1 = self.origin;
self.pos2 = self.origin;
if(self.height) {
self.pos2_z = self.origin_z - self.height;
} else {
self.pos2_z = self.origin_z - self.size_z + 8;
}
self.use = plat_trigger_use;
plat_spawn_inside_trigger(); // the "start moving" trigger