Clean up more visual gears stuff in scripts
- Make vgears non-critical if possible
- Add nil checks where needed
- Fix related bugs
- Remove doomed attempts to call FollowGear on vgears
--- a/share/hedgewars/Data/Maps/CTF_Blizzard/map.lua Tue Aug 21 22:57:56 2018 +0200
+++ b/share/hedgewars/Data/Maps/CTF_Blizzard/map.lua Tue Aug 21 23:56:49 2018 +0200
@@ -183,9 +183,7 @@
-- smoketrace and eviltrace are not effected by wind?
-- chunk is a LR falling gear
local tempE = AddVisualGear(eX, eY, vgtDust, 0, false)
- if tempE ~= 0 then
- SetVisualGearValues(tempE, eX, eY, nil, nil, nil, nil, nil, nil, nil, fCol[i])
- end
+ SetVisualGearValues(tempE, eX, eY, nil, nil, nil, nil, nil, nil, nil, fCol[i])
end
end
end
--- a/share/hedgewars/Data/Maps/Control/map.lua Tue Aug 21 22:57:56 2018 +0200
+++ b/share/hedgewars/Data/Maps/Control/map.lua Tue Aug 21 23:56:49 2018 +0200
@@ -217,10 +217,8 @@
for i = 0,(zCount-1) do
if CurrentHedgehog ~= nil then
if cOwnerClan[i] == GetHogClan(CurrentHedgehog) then
- g = AddVisualGear(vCircX[i], vCircY[i]-100, vgtHealthTag, 100, False)
- if g ~= 0 then
- SetVisualGearValues(g, vCircX[i], vCircY[i]-100, 0, 0, 0, 0, 0, teamScore[cOwnerClan[i]], 1500, GetClanColor(cOwnerClan[i]))
- end
+ local g = AddVisualGear(vCircX[i], vCircY[i]-100, vgtHealthTag, 100, false)
+ SetVisualGearValues(g, vCircX[i], vCircY[i]-100, 0, 0, 0, 0, 0, teamScore[cOwnerClan[i]], 1500, GetClanColor(cOwnerClan[i]))
end
end
end
--- a/share/hedgewars/Data/Missions/Campaign/A_Classic_Fairytale/backstab.lua Tue Aug 21 22:57:56 2018 +0200
+++ b/share/hedgewars/Data/Missions/Campaign/A_Classic_Fairytale/backstab.lua Tue Aug 21 23:56:49 2018 +0200
@@ -392,7 +392,6 @@
table.insert(wave2DeadAnim, {func = AnimSay, args = {natives[wiseNum], loc("I sense another wave of cannibals heading our way!"), SAY_SAY, 6500}})
table.insert(wave2DeadAnim, {func = AnimSay, args = {natives[wiseNum], loc("I feel something...a place! They will arrive near the circles!"), SAY_SAY, 7500}})
table.insert(wave2DeadAnim, {func = AnimCustomFunction, args = {natives[wiseNum], PutCircles, {}}})
- table.insert(wave2DeadAnim, {func = AnimFollowGear, swh = false, args = {vCircs[1]}})
table.insert(wave2DeadAnim, {func = AnimWait, args = {natives[wiseNum], 1500}})
table.insert(wave2DeadAnim, {func = AnimSay, args = {natives[wiseNum], loc("We need to prevent their arrival!"), SAY_SAY, 4500}})
table.insert(wave2DeadAnim, {func = AnimSay, args = {natives[wiseNum], loc("Go, quick!"), SAY_SAY, 2500}})
@@ -413,7 +412,6 @@
table.insert(wave2DeadAnim, {func = AnimSay, args = {natives[wiseNum], loc("I sense another wave of cannibals heading my way!"), SAY_THINK, 6500}})
table.insert(wave2DeadAnim, {func = AnimSay, args = {natives[wiseNum], loc("I feel something...a place! They will arrive near the circles!"), SAY_SAY, 7500}})
table.insert(wave2DeadAnim, {func = AnimCustomFunction, args = {natives[wiseNum], PutCircles, {}}})
- table.insert(wave2DeadAnim, {func = AnimFollowGear, swh = false, args = {vCircs[1]}})
table.insert(wave2DeadAnim, {func = AnimSay, args = {natives[wiseNum], loc("I need to prevent their arrival!"), SAY_THINK, 4500}})
table.insert(wave2DeadAnim, {func = AnimSay, args = {natives[wiseNum], loc("If only I had a way..."), SAY_THINK, 3000}})
table.insert(wave2DeadAnim, {func = AnimSay, args = {natives[wiseNum], loc("Oh, silly me! I forgot that I'm the shaman."), SAY_THINK, 6000}})
@@ -430,7 +428,6 @@
table.insert(wave2DeadAnim, {func = AnimSay, args = {cyborg, loc("I believe there's more of them."), SAY_SAY, 4000}})
table.insert(wave2DeadAnim, {func = AnimSay, args = {cyborg, loc("I marked the place of their arrival. You're welcome!"), SAY_SAY, 6000}})
table.insert(wave2DeadAnim, {func = AnimCustomFunction, args = {natives[wiseNum], PutCircles, {}}})
- table.insert(wave2DeadAnim, {func = AnimFollowGear, swh = false, args = {vCircs[1]}})
table.insert(wave2DeadAnim, {func = AnimCustomFunction, args = {deployedHog, DeployHog, {}}})
if nativesNum > 1 then
-- table.insert(wave2DeadAnim, {func = AnimCustomFunction, args = {natives[wiseNum], RestoreCyborg, {}}})
@@ -476,26 +473,26 @@
end
function PutCGI()
- AddVisualGear(710, 299, vgtExplosion, 0, true)
- AddVisualGear(690, 299, vgtExplosion, 0, true)
- AddVisualGear(761, 209, vgtExplosion, 0, true)
- AddVisualGear(921, 209, vgtExplosion, 0, true)
- AddVisualGear(1081, 209, vgtExplosion, 0, true)
- AddVisualGear(761, 189, vgtExplosion, 0, true)
- AddVisualGear(921, 189, vgtExplosion, 0, true)
- AddVisualGear(1081, 189, vgtExplosion, 0, true)
- AddVisualGear(761, 169, vgtExplosion, 0, true)
- AddVisualGear(921, 169, vgtExplosion, 0, true)
- AddVisualGear(1081, 169, vgtExplosion, 0, true)
- AddVisualGear(761, 149, vgtExplosion, 0, true)
- AddVisualGear(921, 149, vgtExplosion, 0, true)
- AddVisualGear(1081, 149, vgtExplosion, 0, true)
- AddVisualGear(761, 129, vgtExplosion, 0, true)
- AddVisualGear(921, 129, vgtExplosion, 0, true)
- AddVisualGear(1081, 129, vgtExplosion, 0, true)
- AddVisualGear(1120, 261, vgtExplosion, 0, true)
- AddVisualGear(1140, 261, vgtExplosion, 0, true)
- AddVisualGear(1160, 261, vgtExplosion, 0, true)
+ AddVisualGear(710, 299, vgtExplosion, 0, false)
+ AddVisualGear(690, 299, vgtExplosion, 0, false)
+ AddVisualGear(761, 209, vgtExplosion, 0, false)
+ AddVisualGear(921, 209, vgtExplosion, 0, false)
+ AddVisualGear(1081, 209, vgtExplosion, 0, false)
+ AddVisualGear(761, 189, vgtExplosion, 0, false)
+ AddVisualGear(921, 189, vgtExplosion, 0, false)
+ AddVisualGear(1081, 189, vgtExplosion, 0, false)
+ AddVisualGear(761, 169, vgtExplosion, 0, false)
+ AddVisualGear(921, 169, vgtExplosion, 0, false)
+ AddVisualGear(1081, 169, vgtExplosion, 0, false)
+ AddVisualGear(761, 149, vgtExplosion, 0, false)
+ AddVisualGear(921, 149, vgtExplosion, 0, false)
+ AddVisualGear(1081, 149, vgtExplosion, 0, false)
+ AddVisualGear(761, 129, vgtExplosion, 0, false)
+ AddVisualGear(921, 129, vgtExplosion, 0, false)
+ AddVisualGear(1081, 129, vgtExplosion, 0, false)
+ AddVisualGear(1120, 261, vgtExplosion, 0, false)
+ AddVisualGear(1140, 261, vgtExplosion, 0, false)
+ AddVisualGear(1160, 261, vgtExplosion, 0, false)
end
function TeleportNatives()
--- a/share/hedgewars/Data/Missions/Campaign/A_Classic_Fairytale/family.lua Tue Aug 21 22:57:56 2018 +0200
+++ b/share/hedgewars/Data/Missions/Campaign/A_Classic_Fairytale/family.lua Tue Aug 21 23:56:49 2018 +0200
@@ -231,7 +231,7 @@
loc("Hint: It might be a good idea to place a girder before starting to drill. Just saying.").."|"..
string.format(loc("Hint: %s needs to get really close to the princess!"), nativeNames[m5DeployedNum]).."|"..
loc("Mines time: 5 seconds"), 1, 7000)
- vCirc = AddVisualGear(0,0,vgtCircle,0,true)
+ local vCirc = AddVisualGear(0,0,vgtCircle,0,true)
SetVisualGearValues(vCirc, 2625, 1500, 100, 255, 1, 10, 0, 120, 3, 0xff00ffff)
end
--- a/share/hedgewars/Data/Scripts/Multiplayer/HedgeEditor.lua Tue Aug 21 22:57:56 2018 +0200
+++ b/share/hedgewars/Data/Scripts/Multiplayer/HedgeEditor.lua Tue Aug 21 23:56:49 2018 +0200
@@ -2490,16 +2490,16 @@
-- Destroy portal ball when max. distance reached
if remLife == 0 then
- local tempE = AddVisualGear(GetX(gear)+15, GetY(gear), vgtSmoke, 0, true)
+ local tempE = AddVisualGear(GetX(gear)+15, GetY(gear), vgtSmoke, 0, false)
SetVisualGearValues(tempE, nil, nil, nil, nil, nil, nil, nil, nil, nil, col)
- tempE = AddVisualGear(GetX(gear)-15, GetY(gear), vgtSmoke, 0, true)
+ tempE = AddVisualGear(GetX(gear)-15, GetY(gear), vgtSmoke, 0, false)
SetVisualGearValues(tempE, nil, nil, nil, nil, nil, nil, nil, nil, nil, col)
- tempE = AddVisualGear(GetX(gear), GetY(gear)+15, vgtSmoke, 0, true)
+ tempE = AddVisualGear(GetX(gear), GetY(gear)+15, vgtSmoke, 0, false)
SetVisualGearValues(tempE, nil, nil, nil, nil, nil, nil, nil, nil, nil, col)
- tempE = AddVisualGear(GetX(gear), GetY(gear)-15, vgtSmoke, 0, true)
+ tempE = AddVisualGear(GetX(gear), GetY(gear)-15, vgtSmoke, 0, false)
SetVisualGearValues(tempE, nil, nil, nil, nil, nil, nil, nil, nil, nil, col)
PlaySound(sndVaporize)
--- a/share/hedgewars/Data/Scripts/Multiplayer/Space_Invasion.lua Tue Aug 21 22:57:56 2018 +0200
+++ b/share/hedgewars/Data/Scripts/Multiplayer/Space_Invasion.lua Tue Aug 21 23:56:49 2018 +0200
@@ -1014,15 +1014,12 @@
HealthDecrease = 0
WorldEdge = weNone
- for i = 0, 4 do
- vTag[0] = AddVisualGear(0, 0, vgtHealthTag, 0, false)
+ local tags = { TAG_TIME, TAG_BARRELS, TAG_SHIELD, TAG_ROUND_SCORE }
+ for t=1, #tags do
+ vTag[tags[t]] = AddVisualGear(0, 0, vgtHealthTag, 0, false)
+ HideTag(tags[t])
end
- HideTag(TAG_TIME)
- HideTag(TAG_BARRELS)
- HideTag(TAG_SHIELD)
- HideTag(TAG_ROUND_SCORE)
-
wep[0] = loc("Barrel Launcher")
wep[1] = loc("Mine Deployer")
wep[2] = loc("Flamer")
--- a/share/hedgewars/Data/Scripts/Multiplayer/TechRacer.lua Tue Aug 21 22:57:56 2018 +0200
+++ b/share/hedgewars/Data/Scripts/Multiplayer/TechRacer.lua Tue Aug 21 23:56:49 2018 +0200
@@ -1087,16 +1087,16 @@
if remLife == 0 then
-- Make portal ball disappear in a puff of smoke
- local tempE = AddVisualGear(GetX(gear)+15, GetY(gear), vgtSmoke, 0, true)
+ local tempE = AddVisualGear(GetX(gear)+15, GetY(gear), vgtSmoke, 0, false)
SetVisualGearValues(tempE, nil, nil, nil, nil, nil, nil, nil, nil, nil, col)
- tempE = AddVisualGear(GetX(gear)-15, GetY(gear), vgtSmoke, 0, true)
+ tempE = AddVisualGear(GetX(gear)-15, GetY(gear), vgtSmoke, 0, false)
SetVisualGearValues(tempE, nil, nil, nil, nil, nil, nil, nil, nil, nil, col)
- tempE = AddVisualGear(GetX(gear), GetY(gear)+15, vgtSmoke, 0, true)
+ tempE = AddVisualGear(GetX(gear), GetY(gear)+15, vgtSmoke, 0, false)
SetVisualGearValues(tempE, nil, nil, nil, nil, nil, nil, nil, nil, nil, col)
- tempE = AddVisualGear(GetX(gear), GetY(gear)-15, vgtSmoke, 0, true)
+ tempE = AddVisualGear(GetX(gear), GetY(gear)-15, vgtSmoke, 0, false)
SetVisualGearValues(tempE, nil, nil, nil, nil, nil, nil, nil, nil, nil, col)
PlaySound(sndVaporize)
--- a/share/hedgewars/Data/Scripts/Multiplayer/Tumbler.lua Tue Aug 21 22:57:56 2018 +0200
+++ b/share/hedgewars/Data/Scripts/Multiplayer/Tumbler.lua Tue Aug 21 23:56:49 2018 +0200
@@ -594,7 +594,7 @@
Delay = 1000
for i = 0, 3 do
- vTag[0] = AddVisualGear(0, 0, vgtHealthTag, 0, false)
+ vTag[i] = AddVisualGear(0, 0, vgtHealthTag, 0, false)
end
HideTags()
--- a/share/hedgewars/Data/Scripts/Multiplayer/WxW.lua Tue Aug 21 22:57:56 2018 +0200
+++ b/share/hedgewars/Data/Scripts/Multiplayer/WxW.lua Tue Aug 21 23:56:49 2018 +0200
@@ -705,7 +705,9 @@
baseColor = GetClanColor(GetHogClan(CurrentHedgehog))
alpha = rAlpha
end
- SetVisualGearValues(getGearValue(gear,"CIRC"), getGearValue(gear,"RX"), getGearValue(gear,"RY"), 100, 255, 1, 10, 0, radius, 3, baseColor-alpha)
+ if getGearValue(gear,"CIRC") ~= nil then
+ SetVisualGearValues(getGearValue(gear,"CIRC"), getGearValue(gear,"RX"), getGearValue(gear,"RY"), 100, 255, 1, 10, 0, radius, 3, baseColor-alpha)
+ end
end
function TrackRadarBlip(gear)
@@ -1640,11 +1642,14 @@
trackGear(gear)
- table.insert(rCirc, AddVisualGear(0,0,vgtCircle,0,true) )
- setGearValue(gear,"CIRC",rCirc[#rCirc])
+ local vg = AddVisualGear(0, 0, vgtCircle, 0, true)
+ if vg then
+ table.insert(rCirc, vg)
+ setGearValue(gear,"CIRC",vg)
+ SetVisualGearValues(vg, 0, 0, 100, 255, 1, 10, 0, 40, 3, 0xff00ffff)
+ end
setGearValue(gear,"RX",0)
setGearValue(gear,"RY",0)
- SetVisualGearValues(rCirc[#rCirc], 0, 0, 100, 255, 1, 10, 0, 40, 3, 0xff00ffff)
allowCrate = false
crateSpawned = true
@@ -1681,7 +1686,8 @@
crateGearsInGame = crateGearsInGame - 1
for i = 1, #rCirc do
- if rCirc[i] == getGearValue(gear,"CIRC") then
+ local CIRC = getGearValue(gear,"CIRC")
+ if CIRC ~= nil and rCirc[i] == CIRC then
DeleteVisualGear(rCirc[i])
table.remove(rCirc, i)
end