4
button and multiple button
6
Copyright (C) 1996-1997 Id Software, Inc.
8
This program is free software; you can redistribute it and/or
9
modify it under the terms of the GNU General Public License
10
as published by the Free Software Foundation; either version 2
11
of the License, or (at your option) any later version.
13
This program is distributed in the hope that it will be useful,
14
but WITHOUT ANY WARRANTY; without even the implied warranty of
15
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
17
See the GNU General Public License for more details.
19
You should have received a copy of the GNU General Public License
20
along with this program; if not, write to:
22
Free Software Foundation, Inc.
23
59 Temple Place - Suite 330
24
Boston, MA 02111-1307, USA
28
void button_return ();
32
self.state = STATE_TOP;
33
self.nextthink = self.ltime + self.wait;
34
self.think = button_return;
35
activator = self.enemy;
37
self.frame = 1; // use alternate textures
42
self.state = STATE_BOTTOM;
47
self.state = STATE_DOWN;
48
SUB_CalcMove (self.pos1, self.speed, button_done);
49
self.frame = 0; // use normal textures
51
self.takedamage = DAMAGE_YES; // can be shot again
55
void button_blocked ()
56
{ // do nothing, just don't come all the way back out
62
if (self.state == STATE_UP || self.state == STATE_TOP)
65
sound (self, CHAN_VOICE, self.noise, 1, ATTN_NORM);
67
self.state = STATE_UP;
68
SUB_CalcMove (self.pos2, self.speed, button_wait);
74
self.enemy = activator;
80
if (other.classname != "player")
88
self.enemy = damage_attacker;
89
self.health = self.max_health;
90
self.takedamage = DAMAGE_NO; // wil be reset upon return
95
/*QUAKED func_button (0 .5 .8) ?
96
When a button is touched, it moves some distance in the direction of its angle, triggers all of its targets, waits some time, then returns to its original position where it can be triggered again.
98
"angle" determines the opening direction
99
"target" all entities with a matching targetname will be used
100
"speed" override the default 40 speed
101
"wait" override the default 1 second wait (-1 = never return)
102
"lip" override the default 4 pixel lip remaining at end of move
103
"health" if set, the button must be killed instead of touched
112
if (self.sounds == 0)
114
precache_sound ("buttons/airbut1.wav");
115
self.noise = "buttons/airbut1.wav";
117
if (self.sounds == 1)
119
precache_sound ("buttons/switch21.wav");
120
self.noise = "buttons/switch21.wav";
122
if (self.sounds == 2)
124
precache_sound ("buttons/switch02.wav");
125
self.noise = "buttons/switch02.wav";
127
if (self.sounds == 3)
129
precache_sound ("buttons/switch04.wav");
130
self.noise = "buttons/switch04.wav";
135
self.movetype = MOVETYPE_PUSH;
136
self.solid = SOLID_BSP;
137
setmodel (self, self.model);
139
self.blocked = button_blocked;
140
self.use = button_use;
144
self.max_health = self.health;
145
self.th_die = button_killed;
146
self.takedamage = DAMAGE_YES;
149
self.touch = button_touch;
158
self.state = STATE_BOTTOM;
160
self.pos1 = self.origin;
161
self.pos2 = self.pos1 + self.movedir*(fabs(self.movedir*self.size) - self.lip);