ACF5, ACF9: Clear mines around cyborg when it appears
This prevents script problems in case the cyborg dies in a cut scene because of the mines
--- a/ChangeLog.txt Sat May 04 00:56:27 2019 +0200
+++ b/ChangeLog.txt Sat May 04 19:07:58 2019 +0200
@@ -34,6 +34,7 @@
+ Backstab: Disable utilities before traitor has been dealt with
* Backstab: Prevent attacking the cannibals before making the choice
* First blood: Fix Lua error when hitting Attack after failing the rope challenge
+ * General: Clear hazards around cyborg when it appears in cut scenes
* Various minor tweaks and bugfixes
A Space Adventure:
--- a/share/hedgewars/Data/Missions/Campaign/A_Classic_Fairytale/backstab.lua Sat May 04 00:56:27 2019 +0200
+++ b/share/hedgewars/Data/Missions/Campaign/A_Classic_Fairytale/backstab.lua Sat May 04 19:07:58 2019 +0200
@@ -50,6 +50,7 @@
HedgewarsScriptLoad("/Scripts/Locale.lua")
HedgewarsScriptLoad("/Scripts/Animate.lua")
+HedgewarsScriptLoad("/Scripts/Utils.lua")
-----------------------------Constants---------------------------------
choiceAccepted = 1
@@ -156,6 +157,8 @@
wave3DeadAnim = {}
vCircs = {}
+
+trackedMines = {}
-----------------------------Animations--------------------------------
function Wave2Reaction()
local i = 1
@@ -937,6 +940,18 @@
if cyborgHidden == true then
RestoreHog(cyborg)
cyborgHidden = false
+ -- Clear mines around cyborg
+ local vaporized = 0
+ for mine, _ in pairs(trackedMines) do
+ if GetHealth(mine) and GetHealth(cyborg) and gearIsInBox(mine, GetX(cyborg) - 50, GetY(cyborg) - 50, 100, 100) == true then
+ AddVisualGear(GetX(mine), GetY(mine), vgtSmoke, 0, false)
+ DeleteGear(mine)
+ vaporized = vaporized + 1
+ end
+ end
+ if vaporized > 0 then
+ PlaySound(sndVaporize)
+ end
end
end
@@ -1083,7 +1098,19 @@
CheckEvents()
end
+function onGearAdd(gear)
+ local gt = GetGearType(gear)
+ if gt == gtMine or gt == gtSMine or gt == gtAirMine then
+ trackedMines[gear] = true
+ end
+end
+
function onGearDelete(gear)
+ local gt = GetGearType(gear)
+ if gt == gtMine or gt == gtSMine or gt == gtAirMine then
+ trackedMines[gear] = nil
+ end
+
for i = 1, 7 do
if gear == natives[i] then
if nativeDead[i] ~= true then
--- a/share/hedgewars/Data/Missions/Campaign/A_Classic_Fairytale/enemy.lua Sat May 04 00:56:27 2019 +0200
+++ b/share/hedgewars/Data/Missions/Campaign/A_Classic_Fairytale/enemy.lua Sat May 04 19:07:58 2019 +0200
@@ -21,6 +21,7 @@
HedgewarsScriptLoad("/Scripts/Locale.lua")
HedgewarsScriptLoad("/Scripts/Animate.lua")
+HedgewarsScriptLoad("/Scripts/Utils.lua")
--------------------------------------------Constants------------------------------------
@@ -97,6 +98,7 @@
gearDead = {}
hedgeHidden = {}
+trackedMines = {}
startAnim = {}
finalAnim = {}
@@ -410,6 +412,7 @@
function FailedMission()
RestoreHedge(cyborg)
AnimOutOfNowhere(cyborg, unpack(cyborgPos[1]))
+ ClearMinesAroundCyborg()
if CheckCyborgsDead() then
AnimSay(cyborg, loc("Hmmm...it's a draw. How unfortunate!"), SAY_THINK, 6000)
elseif leader ~= nil then
@@ -435,6 +438,7 @@
RestoreHedge(cyborg)
CondNeedToTurn2(cyborg, players[1])
SetupFinalAnim()
+ ClearMinesAroundCyborg()
AddAnim(finalAnim)
AddFunction({func = WinMission, args = {}})
end
@@ -461,6 +465,22 @@
end
end
+function ClearMinesAroundCyborg()
+ if GetHealth(cyborg) then
+ local vaporized = 0
+ for mine, _ in pairs(trackedMines) do
+ if GetHealth(mine) and GetHealth(cyborg) and gearIsInBox(mine, GetX(cyborg) - 50, GetY(cyborg) - 50, 100, 100) == true then
+ AddVisualGear(GetX(mine), GetY(mine), vgtSmoke, 0, false)
+ DeleteGear(mine)
+ vaporized = vaporized + 1
+ end
+ end
+ if vaporized > 0 then
+ PlaySound(sndVaporize)
+ end
+ end
+end
+
function GetVariables()
progress = tonumber(GetCampaignVar("Progress"))
m5DeployedNum = tonumber(GetCampaignVar("M5DeployedNum")) or leaksNum
@@ -615,9 +635,20 @@
CheckEvents()
end
+function onGearAdd(gear)
+ local gt = GetGearType(gear)
+ if gt == gtMine or gt == gtSMine or gt == gtAirMine then
+ trackedMines[gear] = true
+ end
+end
+
function onGearDelete(gear)
+ local gt = GetGearType(gear)
+ if gt == gtMine or gt == gtSMine or gt == gtAirMine then
+ trackedMines[gear] = nil
+ end
gearDead[gear] = true
- if GetGearType(gear) == gtHedgehog then
+ if gt == gtHedgehog then
if GetHogTeamName(gear) == nativesTeamName then
for i = 1, nativesLeft do
if natives[i] == gear then