Skip to content

Commit

Permalink
Merge pull request #2 from jjelliott/trigger_heal_improvements
Browse files Browse the repository at this point in the history
Trigger heal improvements
  • Loading branch information
jjelliott committed Apr 14, 2023
2 parents 6de47a3 + 857e2b5 commit fb79f3b
Show file tree
Hide file tree
Showing 8 changed files with 1,426 additions and 14 deletions.
15 changes: 15 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,2 +1,17 @@
mod_template
progs.*
*.cfg
*.zip

# Map compilation leftovers
*.log
*.prt
*.texinfo.json
autosave/
mapsrc/*.bsp
mapsrc/*.lit
mapsrc/*-compile.map
*.pts

# Ironwail screenshots folder
screenshots/
12 changes: 11 additions & 1 deletion fgd_def/pd_300.fgd
Original file line number Diff line number Diff line change
Expand Up @@ -3323,12 +3323,22 @@ Any object touching this will be healed
heal_amount -- the amount to heal each time (default 5)
wait -- the time between each healing (default 1)
health_max -- the upper limit for the healing (default 100, max 250)
noise -- path to custom sound file"
noise -- path to custom sound file
message -- message to print on heal
count -- maximum heal before exhausted
speed -- amount to recharge at a time
delay -- time before recharging
message2 -- message to print when exhausted"
[
wait(integer) : "Time between each healing (default 1)" : 1
heal_amount(integer) : "Healing per second" : 5
health_max(integer) : "Maximum heath given" : 100 : "The upper limit for healing (default 100, max 250)"
noise(string) : "Path to custom healing sound."
message(string) : "Message to print on heal"
count(integer) : "Maximum to heal before exhausted"
speed(integer) : "Amount to recharge at a time"
delay(integer) : "Time before / between recharging"
message2(string) : "Message to print when exhausted"
spawnflags(Flags) =
[
// 1 : "Start on (if targeted)" : 0 : "Start on if using targetname. Only needed if triggered by something other than touching."
Expand Down
8 changes: 7 additions & 1 deletion fgd_def/pd_300_JACK.fgd
Original file line number Diff line number Diff line change
Expand Up @@ -2880,12 +2880,18 @@ spawnflags(flags) =
]
]
//____TW_EDIT____
@SolidClass base(Appearflags, OneTargetname, TriggerWait) = trigger_heal : "Trigger: Heal - Any object touching this will be healed. 'heal_amount ' - the amount to heal each time (default 5). 'wait ' - the time between each healing (default 1). 'health_max' - the upper limit for the healing (default 100, max 250). 'noise' - path to custom sound file."
@SolidClass base(Appearflags, OneTargetname, TriggerWait) = trigger_heal : "Trigger: Heal - Any object touching this will be healed. 'heal_amount ' - the amount to heal each time (default 5). 'wait ' - the time between each healing (default 1). 'health_max' - the upper limit for the healing (default 100, max 250). 'noise' - path to custom sound file. 'message' - message to print on heal. 'count' - maximum heal before exhausted. 'speed' - amount to recharge at a time. 'delay' - time before recharging. 'message2' - message to print when exhausted."
[
wait(integer) : "Time between each healing (default 1)" : 1
heal_amount(integer) : "Healing per second" : 5
health_max(integer) : "Maximum heath given" : 100 : "The upper limit for healing (default 100, max 250)"
noise(string) : "Path to custom healing sound."

message(string) : "Message to print on heal"
count(integer) : "Maximum to heal before exhausted"
speed(integer) : "Amount to recharge at a time"
delay(integer) : "Time before / between recharging"
message2(string) : "Message to print when exhausted"
spawnflags(Flags) =
[
// 1 : "Start on (if targeted)" : 0 : "Start on if using targetname. Only needed if triggered by something other than touching."
Expand Down
Binary file added maps/pd_heal.bsp
Binary file not shown.
Binary file added maps/pd_heal.lit
Binary file not shown.
1,314 changes: 1,314 additions & 0 deletions mapsrc/pd_heal.map

Large diffs are not rendered by default.

3 changes: 0 additions & 3 deletions qc/.gitignore

This file was deleted.

88 changes: 79 additions & 9 deletions qc/dtmisc.qc
Original file line number Diff line number Diff line change
Expand Up @@ -1047,6 +1047,31 @@ void() misc_particle_stream =
//##########################################
// Original entity submitted by Jan Martin Mathiassen, aka. TGR

void() heal_think =
{
if (self.cnt == self.count)
{
dprint("trigger_heal think: full\n");
self.think = SUB_Null;
return;
}
local float recharge_amount = self.speed;
if (self.count < (self.cnt + self.speed))
{
recharge_amount = self.count - self.cnt;
}
dprint("trigger_heal think: [max: ");
dprint(ftos(self.count));
dprint(", current: ");
dprint(ftos(self.cnt));
dprint(", recharging: ");
dprint(ftos(recharge_amount));
dprint("]\n");

self.cnt = self.cnt + recharge_amount;
self.nextthink = time + self.delay;
};

void() heal_touch =
{
if (self.estate != STATE_ACTIVE)
Expand All @@ -1063,29 +1088,56 @@ void() heal_touch =
if(other.heal_timer > time)
return;

if(self.count && self.cnt <= 0)
{
if(self.message2)
centerprint(other, self.message2);
return;
}

if ((other.takedamage) && (other.health < self.health_max))
{

if (self.noise != "")
sound (self, CHAN_AUTO, self.noise, 1, ATTN_NORM);
else
sound (self, CHAN_AUTO, "items/r_item1.wav", 1, ATTN_NORM);

local float calculated_healing;
if ((other.health + self.heal_amount) > self.health_max)
{
// if(self.spawnflags & HEAL_OBEY_MAX)
// T_Heal (other, (self.health - other.health), 0);
// else
T_Heal (other, (self.health_max - other.health), 1);
calculated_healing = self.health_max - other.health;
}
else
{
// if(self.spawnflags & HEAL_OBEY_MAX)
// T_Heal (other, self.cnt, 0);
// else
T_Heal (other, self.heal_amount, 1);
calculated_healing = self.heal_amount;
}

if (self.count)
{

if (calculated_healing > self.cnt)
{
calculated_healing = self.cnt;
}
self.cnt = self.cnt - calculated_healing;
if (self.delay)
{
self.think = heal_think;
self.nextthink = time + self.delay;
}
dprint("trigger_heal used: [max: ");
dprint(ftos(self.count));
dprint(", current: ");
dprint(ftos(self.cnt));
dprint(", using: ");
dprint(ftos(calculated_healing));
dprint("]\n");
}
if (self.message)
{
centerprint(other, self.message);
}
T_Heal (other, calculated_healing, 1);
other.heal_timer = time + self.wait;
}
};
Expand All @@ -1106,6 +1158,11 @@ wait -- the time between each healing (default 1)
health_max -- the upper limit for the healing (default 100, max 250)
sounds -- set to 1 to enable the noise1 field for custom healing sound
noise -- path to custom sound file
message -- message to print on heal
count -- maximum heal before exhausted
speed -- amount to recharge at a time
delay -- time before recharging
message2 -- message to print when exhausted
*/
void() trigger_heal =
{
Expand All @@ -1126,6 +1183,19 @@ void() trigger_heal =
else if (self.health_max > 250)
self.health_max = 250;

if (self.count)
{
self.cnt = self.count;

if (self.speed && !self.delay)
{
self.delay = 10;
} else if (!self.speed && self.delay)
{
self.speed = 5;
}
}

// if(self.targetname)
// {
// self.use = heal_toggle;
Expand Down

0 comments on commit fb79f3b

Please sign in to comment.