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 if (GetResourceAmount(toucher, RESOURCE_HEALTH) < this.max_health)
24 GiveResourceWithLimit(toucher, RESOURCE_HEALTH, GetResourceAmount(this, RESOURCE_HEALTH), this.max_health);
25 toucher.pauserothealth_finished = max(toucher.pauserothealth_finished, time + autocvar_g_balance_pause_health_rot);
29 _sound (toucher, CH_TRIGGER, this.noise, VOL_BASE, ATTEN_NORM);
34 void trigger_heal_use(entity this, entity actor, entity trigger)
36 trigger_heal_touch(this, actor);
39 void trigger_heal_init(entity this)
41 this.active = ACTIVE_ACTIVE;
44 if(!GetResourceAmount(this, RESOURCE_HEALTH))
45 SetResourceAmountExplicit(this, RESOURCE_HEALTH, 10);
47 this.max_health = 200; // max health topoff for field
49 this.noise = "misc/mediumhealth.wav";
50 precache_sound(this.noise);
53 spawnfunc(trigger_heal)
56 settouch(this, trigger_heal_touch);
57 trigger_heal_init(this);
60 spawnfunc(target_heal)
62 this.use = trigger_heal_use;
63 trigger_heal_init(this);