2003-10-22 09:24:50 +00:00
#include "config.rh"
#include "paroxysm.rh"
/ / button and multiple button
void ( ) button_wait ;
void ( ) button_return ;
void ( ) button_wait =
{
2003-10-22 21:54:29 +00:00
@ self.state = STATE_TOP ;
@ self.nextthink = @ self.ltime + @ self.wait ;
@ self.think = button_return ;
activator = @ self.enemy ;
2003-10-22 09:24:50 +00:00
SUB_UseTargets ( ) ;
2003-10-22 21:54:29 +00:00
@ self.frame = 1 ; / / use alternate textures
2003-10-22 09:24:50 +00:00
} ;
void ( ) button_done =
{
2003-10-22 21:54:29 +00:00
@ self.state = STATE_BOTTOM ;
2003-10-22 09:24:50 +00:00
} ;
void ( ) button_return =
{
2003-10-22 21:54:29 +00:00
@ self.state = STATE_DOWN ;
SUB_CalcMove ( @ self.pos1 , @ self.speed , button_done ) ;
@ self.frame = 0 ; / / use normal textures
if ( @ self.health )
@ self.takedamage = DAMAGE_YES ; / / can be shot again
2003-10-22 09:24:50 +00:00
} ;
void ( ) button_blocked = / / do nothing , just don ' t c o m e a l l t h e w a y b a c k o u t
{
} ;
void ( ) button_fire =
{
2003-10-22 21:54:29 +00:00
if ( @ self.state == STATE_UP || @ self.state == STATE_TOP )
2003-10-22 09:24:50 +00:00
return ;
2003-10-22 21:54:29 +00:00
sound ( @ self , CHAN_VOICE , @ self.noise , 1 , ATTN_NORM ) ;
2003-10-22 09:24:50 +00:00
2003-10-22 21:54:29 +00:00
@ self.state = STATE_UP ;
SUB_CalcMove ( @ self.pos2 , @ self.speed , button_wait ) ;
2003-10-22 09:24:50 +00:00
} ;
void ( ) button_use =
{
2003-10-22 21:54:29 +00:00
@ self.enemy = activator ;
2003-10-22 09:24:50 +00:00
button_fire ( ) ;
} ;
void ( ) button_touch =
{
if ( other.classname != " player" )
return ;
2003-10-22 21:54:29 +00:00
@ self.enemy = other ;
2003-10-22 09:24:50 +00:00
button_fire ( ) ;
} ;
void ( ) button_killed =
{
2003-10-22 21:54:29 +00:00
@ self.enemy = damage_attacker ;
@ self.health = @ self.max_health ;
@ self.takedamage = DAMAGE_NO ; / / wil be reset upon return
2003-10-22 09:24:50 +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 o r i g i n a l p o s i t i o n w h e r e i t c a n b e t r i g g e r e d a g a i n .
" 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
* /
void ( ) func_button =
{
2003-10-22 21:54:29 +00:00
if ( @ self.sounds == 0 ) {
2003-10-22 09:24:50 +00:00
precache_sound ( " buttons/airbut1.wav" ) ;
2003-10-22 21:54:29 +00:00
@ self.noise = " buttons/airbut1.wav" ;
2003-10-22 09:24:50 +00:00
}
2003-10-22 21:54:29 +00:00
if ( @ self.sounds == 1 ) {
2003-10-22 09:24:50 +00:00
precache_sound ( " buttons/switch21.wav" ) ;
2003-10-22 21:54:29 +00:00
@ self.noise = " buttons/switch21.wav" ;
2003-10-22 09:24:50 +00:00
}
2003-10-22 21:54:29 +00:00
if ( @ self.sounds == 2 ) {
2003-10-22 09:24:50 +00:00
precache_sound ( " buttons/switch02.wav" ) ;
2003-10-22 21:54:29 +00:00
@ self.noise = " buttons/switch02.wav" ;
2003-10-22 09:24:50 +00:00
}
2003-10-22 21:54:29 +00:00
if ( @ self.sounds == 3 ) {
2003-10-22 09:24:50 +00:00
precache_sound ( " buttons/switch04.wav" ) ;
2003-10-22 21:54:29 +00:00
@ self.noise = " buttons/switch04.wav" ;
2003-10-22 09:24:50 +00:00
}
SetMovedir ( ) ;
2003-10-22 21:54:29 +00:00
@ self.movetype = MOVETYPE_PUSH ;
@ self.solid = SOLID_BSP ;
setmodel ( @ self , @ self.model ) ;
2003-10-22 09:24:50 +00:00
2003-10-22 21:54:29 +00:00
@ self.blocked = button_blocked ;
@ self.use = button_use ;
2003-10-22 09:24:50 +00:00
2003-10-22 21:54:29 +00:00
if ( @ self.health ) {
@ self.max_health = @ self.health ;
@ self.th_die = button_killed ;
@ self.takedamage = DAMAGE_YES ;
2003-10-22 09:24:50 +00:00
2003-10-22 21:54:29 +00:00
@ self.nobleed = TRUE ; / / + POX
2003-10-22 09:24:50 +00:00
} else
2003-10-22 21:54:29 +00:00
@ self.touch = button_touch ;
2003-10-22 09:24:50 +00:00
2003-10-22 21:54:29 +00:00
if ( ! @ self.speed )
@ self.speed = 40 ;
if ( ! @ self.wait )
@ self.wait = 1 ;
if ( ! @ self.lip )
@ self.lip = 4 ;
2003-10-22 09:24:50 +00:00
2003-10-22 21:54:29 +00:00
@ self.state = STATE_BOTTOM ;
2003-10-22 09:24:50 +00:00
2003-10-22 21:54:29 +00:00
@ self.pos1 = @ self.origin ;
@ self.pos2 = @ self.pos1 + @ self.movedir * ( fabs ( @ self.movedir * @ self.size ) - @ self.lip ) ;
2003-10-22 09:24:50 +00:00
} ;