2 // button and multiple button
9 self.state = STATE_TOP;
10 self.SUB_NEXTTHINK = self.SUB_LTIME + self.wait;
11 self.SUB_THINK = button_return;
12 activator = self.enemy;
14 self.frame = 1; // use alternate textures
19 self.state = STATE_BOTTOM;
24 self.state = STATE_DOWN;
25 SUB_CalcMove (self.pos1, TSPEED_LINEAR, self.speed, button_done);
26 self.frame = 0; // use normal textures
28 self.takedamage = DAMAGE_YES; // can be shot again
34 // do nothing, just don't come all the way back out
40 self.health = self.max_health;
41 self.takedamage = DAMAGE_NO; // will be reset upon return
43 if (self.state == STATE_UP || self.state == STATE_TOP)
47 sound (self, CH_TRIGGER, self.noise, VOL_BASE, ATTEN_NORM);
49 self.state = STATE_UP;
50 SUB_CalcMove (self.pos2, TSPEED_LINEAR, self.speed, button_wait);
55 self.health = self.max_health;
56 setorigin(self, self.pos1);
57 self.frame = 0; // use normal textures
58 self.state = STATE_BOTTOM;
60 self.takedamage = DAMAGE_YES; // can be shot again
65 if(self.active != ACTIVE_ACTIVE)
68 self.enemy = activator;
76 if (!other.iscreature)
78 if(other.velocity * self.movedir < 0)
82 self.enemy = other.owner;
86 void button_damage(entity inflictor, entity attacker, float damage, int deathtype, vector hitloc, vector force)
88 if(self.spawnflags & DOOR_NOSPLASH)
89 if(!(DEATH_ISSPECIAL(deathtype)) && (deathtype & HITTYPE_SPLASH))
91 self.health = self.health - damage;
94 self.enemy = damage_attacker;
100 /*QUAKED spawnfunc_func_button (0 .5 .8) ?
101 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.
103 "angle" determines the opening direction
104 "target" all entities with a matching targetname will be used
105 "speed" override the default 40 speed
106 "wait" override the default 1 second wait (-1 = never return)
107 "lip" override the default 4 pixel lip remaining at end of move
108 "health" if set, the button must be killed instead of touched. If set to -1, the button will fire on ANY attack, even damageless ones like the InstaGib laser
115 void spawnfunc_func_button()
119 if (!InitMovingBrushTrigger())
121 self.effects |= EF_LOWPRECISION;
123 self.blocked = button_blocked;
124 self.use = button_use;
126 // if (self.health == 0) // all buttons are now shootable
130 self.max_health = self.health;
131 self.event_damage = button_damage;
132 self.takedamage = DAMAGE_YES;
135 self.touch = button_touch;
145 precache_sound(self.noise);
147 self.active = ACTIVE_ACTIVE;
149 self.pos1 = self.origin;
150 self.pos2 = self.pos1 + self.movedir*(fabs(self.movedir*self.size) - self.lip);
151 self.flags |= FL_NOTARGET;