--- a/ChangeLog.txt Wed May 29 13:21:23 2019 +0200
+++ b/ChangeLog.txt Fri May 31 11:10:01 2019 +0200
@@ -71,6 +71,7 @@
* Chasing the blue hog: Fix player winning if Crazy Runner died
* Bad timing: Win mission in "flee" variant if all enemy hogs are dead
* Getting to the device: Fix clan colors
+ * Fix errors when hero and enemies die in same turn
* Various minor tweaks and bugfixes
Controls:
--- a/share/hedgewars/Data/Missions/Campaign/A_Space_Adventure/death01.lua Wed May 29 13:21:23 2019 +0200
+++ b/share/hedgewars/Data/Missions/Campaign/A_Space_Adventure/death01.lua Fri May 31 11:10:01 2019 +0200
@@ -261,6 +261,9 @@
end
function onEnemiesDeath(gear)
+ if (not IsHogAlive(gear)) or (not StoppedGear(gear)) then
+ return false
+ end
local allDead = true
if GetHealth(hero.gear) and professor.dead then
for i=1,table.getn(thugs) do
--- a/share/hedgewars/Data/Missions/Campaign/A_Space_Adventure/death02.lua Wed May 29 13:21:23 2019 +0200
+++ b/share/hedgewars/Data/Missions/Campaign/A_Space_Adventure/death02.lua Fri May 31 11:10:01 2019 +0200
@@ -199,6 +199,9 @@
end
function onHeroWin(gear)
+ if not IsHogAlive(gear) then
+ return false
+ end
local allDead = true
for i=1,table.getn(enemies) do
if GetHealth(enemies[i].gear) then
--- a/share/hedgewars/Data/Missions/Campaign/A_Space_Adventure/final.lua Wed May 29 13:21:23 2019 +0200
+++ b/share/hedgewars/Data/Missions/Campaign/A_Space_Adventure/final.lua Fri May 31 11:10:01 2019 +0200
@@ -136,17 +136,18 @@
end
function onBoom(gear)
- local win = true
+ if (not IsHogAlive(gear)) or (not StoppedGear(gear)) then
+ return false
+ end
for i=1,table.getn(explosives) do
if GetHealth(explosives[i]) then
- win = false
- break
+ return false
end
end
if currentHealth <= currentDamage then
- win = false
+ return false
end
- return win
+ return true
end
-------------- ACTIONS ------------------
--- a/share/hedgewars/Data/Missions/Campaign/A_Space_Adventure/fruit01.lua Wed May 29 13:21:23 2019 +0200
+++ b/share/hedgewars/Data/Missions/Campaign/A_Space_Adventure/fruit01.lua Fri May 31 11:10:01 2019 +0200
@@ -297,35 +297,39 @@
end
function onBattleWin(gear)
- local win = true
for i=1,7 do
if i<3 then
if GetHealth(yellowArmy[i].gear) then
- win = false
+ return false
end
else
if GetHealth(yellowArmy[i].gear) and not yellowArmy[i].hidden then
- win = false
+ return false
end
end
end
if GetHealth(yellow1.gear) then
- win = false
+ return false
end
- return win
+ if (not IsHogAlive(gear)) or (not StoppedGear(gear)) then
+ return false
+ end
+ return true
end
function onEscapeWinByKill(gear)
- local win = true
for i=1,7 do
if GetHealth(yellowArmy[i].gear) or yellowArmy[i].hidden then
- win = false
+ return false
end
end
if GetHealth(yellow1.gear) then
- win = false
+ return false
end
- return win
+ if (not IsHogAlive(gear)) or (not StoppedGear(gear)) then
+ return false
+ end
+ return true
end
function isHeroOnLaunchPad()
--- a/share/hedgewars/Data/Missions/Campaign/A_Space_Adventure/fruit02.lua Wed May 29 13:21:23 2019 +0200
+++ b/share/hedgewars/Data/Missions/Campaign/A_Space_Adventure/fruit02.lua Fri May 31 11:10:01 2019 +0200
@@ -344,7 +344,10 @@
return false
end
-function onGaptainLimeDeath(gear)
+function onCaptainLimeDeath(gear)
+ if (not IsHogAlive(hero.gear)) or (not StoppedGear(hero.gear)) then
+ return false
+ end
if green1.dead then
return true
end
@@ -352,6 +355,9 @@
end
function onRedTeamDeath(gear)
+ if (not IsHogAlive(hero.gear)) or (not StoppedGear(hero.gear)) then
+ return false
+ end
local redDead = true
for i=1,table.getn(redHedgehogs) do
if GetHealth(redHedgehogs[i].gear) then
@@ -433,7 +439,7 @@
AddAmmo(green1.gear, amBazooka, 6)
AddAmmo(green1.gear, amGrenade, 6)
AddAmmo(green1.gear, amDEagle, 2)
- AddEvent(onGaptainLimeDeath, {green1.gear}, captainLimeDeath, {green1.gear}, 0)
+ AddEvent(onCaptainLimeDeath, {green1.gear}, captainLimeDeath, {green1.gear}, 0)
end
EndTurn(true)
escapeHog(green2.gear)
--- a/share/hedgewars/Data/Missions/Campaign/A_Space_Adventure/fruit03.lua Wed May 29 13:21:23 2019 +0200
+++ b/share/hedgewars/Data/Missions/Campaign/A_Space_Adventure/fruit03.lua Fri May 31 11:10:01 2019 +0200
@@ -244,6 +244,9 @@
end
function onHeroWin(gear)
+ if (not IsHogAlive(hero.gear)) or (not StoppedGear(hero.gear)) then
+ return false
+ end
local enemies = enemiesOdd
for i=1,table.getn(enemiesEven) do
table.insert(enemies, enemiesEven[i])
--- a/share/hedgewars/Data/Missions/Campaign/A_Space_Adventure/ice01.lua Wed May 29 13:21:23 2019 +0200
+++ b/share/hedgewars/Data/Missions/Campaign/A_Space_Adventure/ice01.lua Fri May 31 11:10:01 2019 +0200
@@ -425,6 +425,9 @@
end
function onHeroWin(gear)
+ if (not IsHogAlive(gear)) or (not StoppedGear(gear)) then
+ return false
+ end
if (not hero.dead and not bandit1.dead) and heroDamageAtCurrentTurn == 0 and (GetX(hero.gear)>=GetX(bandit1.gear)-80
and GetX(hero.gear)<=GetX(bandit1.gear)+80) and (GetY(hero.gear)>=GetY(bandit1.gear)-30 and GetY(hero.gear)<=GetY(bandit1.gear)+30) then
return true
--- a/share/hedgewars/Data/Missions/Campaign/A_Space_Adventure/moon01.lua Wed May 29 13:21:23 2019 +0200
+++ b/share/hedgewars/Data/Missions/Campaign/A_Space_Adventure/moon01.lua Fri May 31 11:10:01 2019 +0200
@@ -397,7 +397,9 @@
function professorAndMinionsDeath(gear)
if gameOver then return end
- SendStat(siCustomAchievement, loc("You have eliminated the whole evil team. You're pretty tough!"))
+ if (not IsHogAlive(hero.gear)) or (not StoppedGear(hero.gear)) then return end
+ SendStat(siCustomAchievement, loc("You have eliminated Professor Hogevil."))
+ SendStat(siCustomAchievement, loc("You have eliminated the evil minions."))
SaveCampaignVar("ProfDiedOnMoon", "1")
victory()
@@ -405,6 +407,7 @@
function professorDeath(gear)
if gameOver then return end
+ if (not IsHogAlive(hero.gear)) or (not StoppedGear(hero.gear)) then return end
local m1h = GetHealth(minion1.gear)
local m2h = GetHealth(minion2.gear)
local m3h = GetHealth(minion3.gear)
@@ -421,6 +424,7 @@
end
function afterDialog06()
+ if (not IsHogAlive(hero.gear)) or (not StoppedGear(hero.gear)) then return end
EndTurn(true)
SendStat(siCustomAchievement, loc("You have eliminated Professor Hogevil."))
SendStat(siCustomAchievement, loc("You drove the minions away."))
@@ -429,6 +433,7 @@
end
function afterDialog05()
+ if (not IsHogAlive(hero.gear)) or (not StoppedGear(hero.gear)) then return end
EndTurn(true)
HideHog(professor.gear)
SendStat(siCustomAchievement, loc("You have eliminated the evil minions."))
@@ -441,6 +446,7 @@
function minionsDeath(gear)
if professor.dead or GetHealth(professor.gear) == nil or GetHealth(professor.gear) == 0 then return end
if gameOver then return end
+ if (not IsHogAlive(hero.gear)) or (not StoppedGear(hero.gear)) then return end
AddAnim(dialog05)
end
--- a/share/hedgewars/Data/Missions/Campaign/A_Space_Adventure/moon02.lua Wed May 29 13:21:23 2019 +0200
+++ b/share/hedgewars/Data/Missions/Campaign/A_Space_Adventure/moon02.lua Fri May 31 11:10:01 2019 +0200
@@ -256,9 +256,10 @@
------------- other functions ---------------
function isHeroNextToRunner()
- if GetGearType(hero.gear) == gtHedgehog and GetGearType(runner.gear) == gtHedgehog and
+ if IsHogAlive(hero.gear) and IsHogAlive(runner.gear) and
math.abs(GetX(hero.gear) - GetX(runner.gear)) < 75 and
- math.abs(GetY(hero.gear) - GetY(runner.gear)) < 75 and StoppedGear(hero.gear) then
+ math.abs(GetY(hero.gear) - GetY(runner.gear)) < 75 and
+ StoppedGear(hero.gear) and StoppedGear(runner.gear) then
return true
end
return false