3 .float triggerhealtime;
4 void trigger_heal_touch(entity this, entity toucher)
6 if (this.active != ACTIVE_ACTIVE)
9 // only do the EXACTTRIGGER_TOUCH checks when really needed (saves some cpu)
10 if (toucher.iscreature)
12 if (toucher.takedamage && !IS_DEAD(toucher) && toucher.triggerhealtime < time)
14 bool is_trigger = this.targetname == "";
16 EXACTTRIGGER_TOUCH(this, toucher);
18 toucher.triggerhealtime = time + this.delay;
20 bool playthesound = (this.spawnflags & HEAL_SOUND_ALWAYS);
21 bool healed = Heal(toucher, this, GetResource(this, RES_HEALTH), this.max_health);
23 if(playthesound || healed)
24 _sound (toucher, CH_TRIGGER, this.noise, VOL_BASE, ATTEN_NORM);
29 void trigger_heal_use(entity this, entity actor, entity trigger)
31 trigger_heal_touch(this, actor);
34 void trigger_heal_init(entity this)
36 this.active = ACTIVE_ACTIVE;
39 if(!GetResource(this, RES_HEALTH))
40 SetResourceExplicit(this, RES_HEALTH, 10); // TODO: use a special field for this, it doesn't have actual health!
42 this.max_health = 200; // max health topoff for field
44 this.noise = "misc/mediumhealth.wav";
45 precache_sound(this.noise);
48 spawnfunc(trigger_heal)
51 settouch(this, trigger_heal_touch);
52 trigger_heal_init(this);
55 spawnfunc(target_heal)
57 this.use = trigger_heal_use;
58 trigger_heal_init(this);