--- a/hedgewars/uGearsHandlersMess.pas Wed May 22 23:53:00 2019 +0300
+++ b/hedgewars/uGearsHandlersMess.pas Wed May 22 23:32:22 2019 +0200
@@ -2401,7 +2401,7 @@
doStepCase(Gear)
else
// health texture (FlightTime = health when the last texture was generated)
- if Gear^.Health <> Gear^.FlightTime then
+ if (Gear^.Health <> Gear^.FlightTime) or (Gear^.Tex = nil) then
begin
Gear^.FlightTime:= Gear^.Health;
FreeAndNilTexture(Gear^.Tex);
@@ -2479,7 +2479,7 @@
dec(Gear^.Health, Gear^.Damage);
Gear^.Damage := 0;
// health texture (FlightTime = health when the last texture was generated)
- if Gear^.Health <> Gear^.FlightTime then
+ if (Gear^.Health <> Gear^.FlightTime) or (Gear^.Tex = nil) then
begin
Gear^.FlightTime:= Gear^.Health;
FreeAndNilTexture(Gear^.Tex);
@@ -2507,7 +2507,7 @@
i:= 1;
if i = 1 then
begin
- if Gear^.Health <> Gear^.FlightTime then
+ if (Gear^.Health <> Gear^.FlightTime) or (Gear^.Tex = nil) then
begin
Gear^.FlightTime:= Gear^.Health;
FreeAndNilTexture(Gear^.Tex);
@@ -2516,7 +2516,7 @@
end
else
begin
- if Gear^.FlightTime <> $ffffffff then
+ if (Gear^.FlightTime <> $ffffffff) or (Gear^.Tex = nil) then
begin
Gear^.FlightTime:= $ffffffff;
FreeAndNilTexture(Gear^.Tex);
--- a/share/hedgewars/Data/Missions/Campaign/A_Classic_Fairytale/backstab.lua Wed May 22 23:53:00 2019 +0300
+++ b/share/hedgewars/Data/Missions/Campaign/A_Classic_Fairytale/backstab.lua Wed May 22 23:32:22 2019 +0200
@@ -735,11 +735,11 @@
end
function CheckChoiceRefuse()
- return highJumped == true and StoppedGear(CurrentHedgehog)
+ return GetHealth(CurrentHedgehog) and highJumped == true and StoppedGear(CurrentHedgehog)
end
function CheckChoiceRunaway()
- return CurrentHedgehog and band(GetState(CurrentHedgehog), gstHHDriven) ~= 0 and GetHogTeamName(CurrentHedgehog) == nativesTeamName and GetX(CurrentHedgehog) >= runawayX and GetY(CurrentHedgehog) >= runawayY and StoppedGear(CurrentHedgehog)
+ return GetHealth(CurrentHedgehog) and band(GetState(CurrentHedgehog), gstHHDriven) ~= 0 and GetHogTeamName(CurrentHedgehog) == nativesTeamName and GetX(CurrentHedgehog) >= runawayX and GetY(CurrentHedgehog) >= runawayY and StoppedGear(CurrentHedgehog)
end
function CheckChoiceRunawayAll()
--- a/share/hedgewars/Data/Missions/Campaign/A_Classic_Fairytale/enemy.lua Wed May 22 23:53:00 2019 +0300
+++ b/share/hedgewars/Data/Missions/Campaign/A_Classic_Fairytale/enemy.lua Wed May 22 23:32:22 2019 +0200
@@ -104,7 +104,10 @@
finalAnim = {}
-----------------------------Animations--------------------------------
function CondNeedToTurn(hog1, hog2)
- xl, xd = GetX(hog1), GetX(hog2)
+ if (not GetHealth(hog1)) or (not GetHealth(hog2)) then
+ return
+ end
+ local xl, xd = GetX(hog1), GetX(hog2)
if xl > xd then
AnimInsertStepNext({func = AnimTurn, args = {hog1, "Left"}})
AnimInsertStepNext({func = AnimTurn, args = {hog2, "Right"}})
@@ -115,7 +118,10 @@
end
function CondNeedToTurn2(hog1, hog2)
- xl, xd = GetX(hog1), GetX(hog2)
+ if (not GetHealth(hog1)) or (not GetHealth(hog2)) then
+ return
+ end
+ local xl, xd = GetX(hog1), GetX(hog2)
if xl > xd then
AnimTurn(hog1, "Left")
AnimTurn(hog2, "Right")
--- a/share/hedgewars/Data/Missions/Campaign/A_Classic_Fairytale/first_blood.lua Wed May 22 23:53:00 2019 +0300
+++ b/share/hedgewars/Data/Missions/Campaign/A_Classic_Fairytale/first_blood.lua Wed May 22 23:32:22 2019 +0200
@@ -420,7 +420,7 @@
end
function CheckMovedUntilJump()
- return GetX(youngh) >= 2343
+ return GetHealth(youngh) and GetX(youngh) >= 2343
end
function DoMovedUntilJump()
@@ -435,7 +435,7 @@
end
function CheckOnShroom()
- return GetX(youngh) >= 2461 and StoppedGear(youngh)
+ return GetHealth(youngh) and GetX(youngh) >= 2461 and StoppedGear(youngh)
end
function DoOnShroom()
@@ -473,11 +473,17 @@
end
function CheckOnMoleHead()
+ if not GetHealth(youngh) then
+ return false
+ end
local x = GetX(youngh)
return x >= 3005 and x <= 3126 and StoppedGear(youngh)
end
function CheckPastMoleHead()
+ if not GetHealth(youngh) then
+ return false
+ end
local x = GetX(youngh)
local y = GetY(youngh)
return x < 3005 and y > 1500 and StoppedGear(youngh)
--- a/share/hedgewars/Data/Missions/Campaign/A_Classic_Fairytale/journey.lua Wed May 22 23:53:00 2019 +0300
+++ b/share/hedgewars/Data/Missions/Campaign/A_Classic_Fairytale/journey.lua Wed May 22 23:32:22 2019 +0200
@@ -991,7 +991,7 @@
end
function CheckTookSniper2()
- return sniperTaken and StoppedGear(leaks) and StoppedGear(dense)
+ return sniperTaken and leaksDead == false and StoppedGear(leaks) and denseDead == false and StoppedGear(dense)
end
function DoTookSniper2()
--- a/share/hedgewars/Data/Missions/Campaign/A_Classic_Fairytale/shadow.lua Wed May 22 23:53:00 2019 +0300
+++ b/share/hedgewars/Data/Missions/Campaign/A_Classic_Fairytale/shadow.lua Wed May 22 23:32:22 2019 +0200
@@ -756,10 +756,26 @@
return brainiacDead
end
+function isHogAlive(hog)
+ if GetHealth(hog) == nil or GetHealth(hog) <= 0 then
+ return false
+ else
+ local _,_,_,_,_,_,_,_,_,_,_,damage = GetGearValues(hog)
+ if damage > GetHealth(hog) then
+ return false
+ end
+ end
+ return true
+end
+
function DoBrainiacDead()
if stage == loseStage then
return
end
+ if (not isHogAlive(dense)) or (not isHogAlive(leaks)) then
+ return
+ end
+
EndTurn(true)
SetGearMessage(CurrentHedgehog, 0)
AddAnim(weaklingsAnim)
@@ -780,7 +796,7 @@
if stage == loseStage then
return
end
- if denseDead or GetHealth(dense) == 0 or leaksDead or GetHealth(leaks) == 0 then
+ if (not isHogAlive(dense)) or (not isHogAlive(leaks)) then
return
end
SetGearMessage(CurrentHedgehog, 0)
@@ -809,7 +825,7 @@
-- When close to cyborg, wait for a short time before accepting,
-- to allow player to attack with melee weapons.
checkAcceptTimer = checkAcceptTimer + 1
- if checkAcceptTimer > 2000 and StoppedGear(dense) then
+ if checkAcceptTimer > 2000 and denseDead == false and StoppedGear(dense) then
return true
end
else
@@ -826,7 +842,7 @@
end
function CheckConfront()
- return cyborgAttacked and GetHealth(dense) and StoppedGear(dense)
+ return cyborgAttacked and denseDead == false and StoppedGear(dense)
end
function DoConfront()
@@ -854,7 +870,7 @@
if stage == loseStage then
return false
end
- return GetX(dense) > 1640 and StoppedGear(dense)
+ return denseDead == false and GetX(dense) > 1640 and StoppedGear(dense)
end
function DoNeedGirder()
@@ -874,7 +890,7 @@
if stage == loseStage then
return false
end
- return GetX(dense) > 2522 and StoppedGear(dense)
+ return denseDead == false and GetX(dense) > 2522 and StoppedGear(dense)
end
function DoNeedWeapons()
@@ -924,7 +940,7 @@
if stage == loseStage then
return
end
- if leaksDead or GetHealth(leaks) == 0 then
+ if not isHogAlive(leaks) then
return
end
SetGearMessage(CurrentHedgehog, 0)