Skip to content

Commit f3d01bb

Browse files
committed
warriors now regen health after being shot
1 parent f0a8492 commit f3d01bb

2 files changed

Lines changed: 29 additions & 0 deletions

File tree

Data/MuIlaak.rte/Actors/Infantry/Warrior/Warrior.ini

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -432,6 +432,7 @@ AddActor = AHuman
432432
HitsMOs = 1
433433
GetsHitByMOs = 1
434434
ScriptPath = Base.rte/AI/HumanAI.lua
435+
ScriptPath = MuIlaak.rte/Shared/Scripts/LaakRegen.lua
435436
SpriteFile = ContentFile
436437
FilePath = MuIlaak.rte/Actors/Infantry/Warrior/TorsoA.png
437438
FrameCount = 1
Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
function Create(self)
2+
self.healAmount = 1;
3+
self.regenDelay = 250;
4+
self.regenTimer = Timer();
5+
6+
self.lastWoundCount = self.WoundCount;
7+
end
8+
9+
function ThreadedUpdate(self)
10+
if self.regenTimer:IsPastSimMS(self.regenDelay) then
11+
self.regenTimer:Reset();
12+
if self.Health > 0 then
13+
local damageRatio = (self.WoundCount - self.lastWoundCount)/self:GetGibWoundLimit(true, false, false) + (self.PrevHealth - self.Health)/self.MaxHealth;
14+
if damageRatio > 0 then
15+
self.regenDelay = self.regenDelay * (1 + damageRatio);
16+
else
17+
local healed = self:RemoveWounds(1);
18+
if healed ~= 0 and self.Health < self.MaxHealth then
19+
self:AddHealth(self.healAmount);
20+
if self.Health > self.MaxHealth then
21+
self.Health = self.MaxHealth;
22+
end
23+
end
24+
end
25+
end
26+
self.lastWoundCount = self.WoundCount;
27+
end
28+
end

0 commit comments

Comments
 (0)