2001-07-17 05:58:10 +00:00
|
|
|
// button and multiple button
|
2001-07-23 20:52:47 +00:00
|
|
|
#include "defs.qh"
|
2001-07-17 05:58:10 +00:00
|
|
|
|
|
|
|
#define BUTTON_START_OUT 32
|
|
|
|
|
|
|
|
void() button_wait;
|
|
|
|
void() button_return;
|
|
|
|
|
|
|
|
void() button_wait =
|
|
|
|
{
|
2001-07-23 20:52:47 +00:00
|
|
|
self.state = STATE_TOP;
|
2001-07-17 05:58:10 +00:00
|
|
|
self.nextthink = self.ltime + self.wait;
|
|
|
|
self.think = button_return;
|
|
|
|
activator = self.enemy;
|
|
|
|
SUB_UseTargets();
|
|
|
|
self.frame = 1; // use alternate textures
|
|
|
|
};
|
|
|
|
|
|
|
|
void() button_done =
|
|
|
|
{
|
2001-07-23 20:52:47 +00:00
|
|
|
self.state = STATE_BOTTOM;
|
2001-07-17 05:58:10 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
void() button_return =
|
|
|
|
{
|
2001-07-23 20:52:47 +00:00
|
|
|
self.goal_state = TFGS_INACTIVE;
|
2001-07-17 05:58:10 +00:00
|
|
|
|
2001-07-23 20:52:47 +00:00
|
|
|
self.state = STATE_DOWN;
|
2001-07-17 05:58:10 +00:00
|
|
|
SUB_CalcMove (self.pos1, self.speed, button_done);
|
|
|
|
self.frame = 0; // use normal textures
|
|
|
|
if (self.health)
|
2001-07-23 20:52:47 +00:00
|
|
|
self.takedamage = DAMAGE_YES; // can be shot again
|
2001-07-17 05:58:10 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
void() button_blocked =
|
|
|
|
{ // do nothing, just don't come all the way back out
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
void() button_fire =
|
|
|
|
{
|
2001-07-23 20:52:47 +00:00
|
|
|
if (self.state == STATE_UP || self.state == STATE_TOP)
|
2001-07-17 05:58:10 +00:00
|
|
|
return;
|
|
|
|
|
2001-07-23 20:52:47 +00:00
|
|
|
sound (self, CHAN_VOICE, self.noise, 1, ATTN_NORM);
|
2001-07-17 05:58:10 +00:00
|
|
|
|
2001-07-23 20:52:47 +00:00
|
|
|
self.state = STATE_UP;
|
2001-07-17 05:58:10 +00:00
|
|
|
SUB_CalcMove (self.pos2, self.speed, button_wait);
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
void() button_use =
|
|
|
|
{
|
|
|
|
self.enemy = activator;
|
|
|
|
button_fire ();
|
|
|
|
};
|
|
|
|
|
|
|
|
/*void() button_touch =
|
|
|
|
{
|
|
|
|
local entity te;
|
|
|
|
|
|
|
|
if (other.classname != "player")
|
|
|
|
return;
|
|
|
|
|
2001-07-23 20:52:47 +00:00
|
|
|
if (self.goal_activation & TFGA_SPANNER)
|
2001-07-17 05:58:10 +00:00
|
|
|
return;
|
|
|
|
|
|
|
|
if (!Activated(self,other))
|
|
|
|
{
|
|
|
|
// If an else goal should be activated, activate it
|
|
|
|
if (self.else_goal != 0)
|
|
|
|
{
|
|
|
|
te = Findgoal(self.else_goal);
|
|
|
|
if (te)
|
2001-07-23 20:52:47 +00:00
|
|
|
DoResults(te, other, (self.goal_result & TFGR_ADD_BONUSES));
|
2001-07-17 05:58:10 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
self.enemy = other;
|
|
|
|
button_fire ();
|
|
|
|
};*/
|
|
|
|
|
|
|
|
void() button_touch =
|
|
|
|
{
|
|
|
|
local entity te;
|
|
|
|
|
|
|
|
if (other.classname != "player")
|
|
|
|
return;
|
|
|
|
|
|
|
|
// OfN --------------------------------------//
|
|
|
|
//- BUGFIX Avoid observers touching buttons //
|
2001-07-23 20:52:47 +00:00
|
|
|
if (other.playerclass == PC_UNDEFINED)
|
2001-07-17 05:58:10 +00:00
|
|
|
return;
|
|
|
|
//------------------------------------------//
|
|
|
|
|
2001-07-23 20:52:47 +00:00
|
|
|
if (self.goal_activation & TFGA_SPANNER)
|
2001-07-17 05:58:10 +00:00
|
|
|
return;
|
|
|
|
|
|
|
|
if (!Activated(self,other))
|
|
|
|
{
|
|
|
|
// If an else goal should be activated, activate it
|
|
|
|
if (self.else_goal != 0)
|
|
|
|
{
|
|
|
|
te = Findgoal(self.else_goal);
|
|
|
|
if (te)
|
2001-07-23 20:52:47 +00:00
|
|
|
DoResults(te, other, (self.goal_result & TFGR_ADD_BONUSES));
|
2001-07-17 05:58:10 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
self.enemy = other;
|
|
|
|
button_fire ();
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
void() button_killed =
|
|
|
|
{
|
2001-07-23 20:52:47 +00:00
|
|
|
if (self.goal_activation & TFGA_SPANNER)
|
2001-07-17 05:58:10 +00:00
|
|
|
return;
|
|
|
|
|
|
|
|
self.enemy = damage_attacker;
|
|
|
|
self.health = self.max_health;
|
2001-07-23 20:52:47 +00:00
|
|
|
self.takedamage = DAMAGE_NO; // wil be reset upon return
|
2001-07-17 05:58:10 +00:00
|
|
|
button_fire ();
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
/*QUAKED func_button (0 .5 .8) ?
|
|
|
|
When a button is touched, it moves some distance in the direction of it's angle, triggers all of it's targets, waits some time, then returns to it's original position where it can be triggered again.
|
|
|
|
|
|
|
|
"angle" determines the opening direction
|
|
|
|
"target" all entities with a matching targetname will be used
|
|
|
|
"speed" override the default 40 speed
|
|
|
|
"wait" override the default 1 second wait (-1 = never return)
|
|
|
|
"lip" override the default 4 pixel lip remaining at end of move
|
|
|
|
"health" if set, the button must be killed instead of touched
|
|
|
|
"sounds"
|
|
|
|
0) steam metal
|
|
|
|
1) wooden clunk
|
|
|
|
2) metallic click
|
|
|
|
3) in-out
|
|
|
|
|
|
|
|
TF Note:
|
2001-07-23 20:52:47 +00:00
|
|
|
If the spawnflags has the BUTTON_START_OUT (32), then the button
|
2001-07-17 05:58:10 +00:00
|
|
|
will automatically fire at the start of the level, allowing you
|
|
|
|
to light in the out position.
|
|
|
|
|
|
|
|
*/
|
|
|
|
void() func_button =
|
|
|
|
{
|
2001-07-23 20:52:47 +00:00
|
|
|
if (CheckExistence() == FALSE)
|
2001-07-17 05:58:10 +00:00
|
|
|
{
|
|
|
|
dremove(self);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (self.sounds == 0)
|
|
|
|
{
|
|
|
|
precache_sound ("buttons/airbut1.wav");
|
|
|
|
self.noise = "buttons/airbut1.wav";
|
|
|
|
}
|
|
|
|
if (self.sounds == 1)
|
|
|
|
{
|
|
|
|
precache_sound ("buttons/switch21.wav");
|
|
|
|
self.noise = "buttons/switch21.wav";
|
|
|
|
}
|
|
|
|
if (self.sounds == 2)
|
|
|
|
{
|
|
|
|
precache_sound ("buttons/switch02.wav");
|
|
|
|
self.noise = "buttons/switch02.wav";
|
|
|
|
}
|
|
|
|
if (self.sounds == 3)
|
|
|
|
{
|
|
|
|
precache_sound ("buttons/switch04.wav");
|
|
|
|
self.noise = "buttons/switch04.wav";
|
|
|
|
}
|
|
|
|
|
|
|
|
SetMovedir ();
|
|
|
|
|
2001-07-23 20:52:47 +00:00
|
|
|
self.movetype = MOVETYPE_PUSH;
|
|
|
|
self.solid = SOLID_BSP;
|
2001-07-17 05:58:10 +00:00
|
|
|
setmodel (self, self.model);
|
|
|
|
|
|
|
|
self.blocked = button_blocked;
|
|
|
|
self.use = button_use;
|
|
|
|
|
|
|
|
if (self.health)
|
|
|
|
{
|
|
|
|
self.max_health = self.health;
|
|
|
|
self.th_die = button_killed;
|
2001-07-23 20:52:47 +00:00
|
|
|
self.takedamage = DAMAGE_YES;
|
2001-07-17 05:58:10 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
self.touch = button_touch;
|
|
|
|
|
|
|
|
if (!self.speed)
|
|
|
|
self.speed = 40;
|
|
|
|
if (!self.wait)
|
|
|
|
self.wait = 1;
|
|
|
|
if (!self.lip)
|
|
|
|
self.lip = 4;
|
|
|
|
|
2001-07-23 20:52:47 +00:00
|
|
|
self.state = STATE_BOTTOM;
|
2001-07-17 05:58:10 +00:00
|
|
|
|
|
|
|
self.pos1 = self.origin;
|
|
|
|
self.pos2 = self.pos1 + self.movedir*(fabs(self.movedir*self.size) - self.lip);
|
|
|
|
|
2001-07-23 20:52:47 +00:00
|
|
|
if (self.spawnflags & BUTTON_START_OUT)
|
2001-07-17 05:58:10 +00:00
|
|
|
button_fire ();
|
|
|
|
};
|
|
|
|
|
|
|
|
|