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 SUB_UseTargets(self, self.enemy, NULL);
13 self.frame = 1; // use alternate textures
18 self.state = STATE_BOTTOM;
23 self.state = STATE_DOWN;
24 SUB_CalcMove (self.pos1, TSPEED_LINEAR, self.speed, button_done);
25 self.frame = 0; // use normal textures
27 self.takedamage = DAMAGE_YES; // can be shot again
33 // do nothing, just don't come all the way back out
39 self.health = self.max_health;
40 self.takedamage = DAMAGE_NO; // will be reset upon return
42 if (self.state == STATE_UP || self.state == STATE_TOP)
46 _sound (self, CH_TRIGGER, self.noise, VOL_BASE, ATTEN_NORM);
48 self.state = STATE_UP;
49 SUB_CalcMove (self.pos2, TSPEED_LINEAR, self.speed, button_wait);
54 self.health = self.max_health;
55 setorigin(self, self.pos1);
56 self.frame = 0; // use normal textures
57 self.state = STATE_BOTTOM;
59 self.takedamage = DAMAGE_YES; // can be shot again
62 void button_use(entity this, entity actor, entity trigger)
64 if(this.active != ACTIVE_ACTIVE)
68 WITHSELF(this, button_fire());
75 if (!other.iscreature)
77 if(other.velocity * self.movedir < 0)
81 self.enemy = other.owner;
85 void button_damage(entity this, entity inflictor, entity attacker, float damage, int deathtype, vector hitloc, vector force)
87 if(this.spawnflags & DOOR_NOSPLASH)
88 if(!(DEATH_ISSPECIAL(deathtype)) && (deathtype & HITTYPE_SPLASH))
90 this.health = this.health - damage;
93 this.enemy = damage_attacker;
94 WITHSELF(this, button_fire());
99 /*QUAKED spawnfunc_func_button (0 .5 .8) ?
100 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.
102 "angle" determines the opening direction
103 "target" all entities with a matching targetname will be used
104 "speed" override the default 40 speed
105 "wait" override the default 1 second wait (-1 = never return)
106 "lip" override the default 4 pixel lip remaining at end of move
107 "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
114 spawnfunc(func_button)
118 if (!InitMovingBrushTrigger())
120 self.effects |= EF_LOWPRECISION;
122 self.blocked = button_blocked;
123 self.use1 = button_use;
125 // if (self.health == 0) // all buttons are now shootable
129 self.max_health = self.health;
130 self.event_damage = button_damage;
131 self.takedamage = DAMAGE_YES;
134 self.touch = button_touch;
144 precache_sound(self.noise);
146 self.active = ACTIVE_ACTIVE;
148 self.pos1 = self.origin;
149 self.pos2 = self.pos1 + self.movedir*(fabs(self.movedir*self.size) - self.lip);
150 self.flags |= FL_NOTARGET;