Bazooka/Grenade Training: Make weapon selection detection future-proof
The old check relied on hardcoded slot IDs for the weapons, which is not good.
--- a/share/hedgewars/Data/Missions/Training/Basic_Training_-_Bazooka.lua Sun Mar 11 12:08:49 2018 +0100
+++ b/share/hedgewars/Data/Missions/Training/Basic_Training_-_Bazooka.lua Sun Mar 11 21:38:08 2018 +0100
@@ -199,19 +199,6 @@
end
end
-function onSetWeapon(ammoType)
- if ammoType == amBazooka and not weaponSelected and gamePhase == 1 then
- newGamePhase()
- weaponSelected = true
- end
-end
-function onSlot(msgParam)
- if msgParam == 0 and not weaponSelected and gamePhase == 1 then
- newGamePhase()
- weaponSelected = true
- end
-end
-
function onHogAttack(ammoType)
if ammoType == amBazooka then
HideMission()
@@ -278,6 +265,11 @@
PlaySound(sndMissed, hog)
missedTauntTimer = -1
end
+
+ if not weaponSelected and gamePhase == 1 and GetCurAmmoType() == amBazooka then
+ newGamePhase()
+ weaponSelected = true
+ end
end
function onAmmoStoreInit()
--- a/share/hedgewars/Data/Missions/Training/Basic_Training_-_Grenade.lua Sun Mar 11 12:08:49 2018 +0100
+++ b/share/hedgewars/Data/Missions/Training/Basic_Training_-_Grenade.lua Sun Mar 11 21:38:08 2018 +0100
@@ -171,15 +171,8 @@
end
end
-function onSetWeapon(ammoType)
- if ammoType == amGrenade and not weaponSelected and gamePhase == 1 then
- newGamePhase()
- weaponSelected = true
- end
-end
-
-function onSlot(msgParam)
- if msgParam <= 1 and not weaponSelected and gamePhase == 1 then
+function onGameTick20()
+ if not weaponSelected and gamePhase == 1 and GetCurAmmoType() == amGrenade then
newGamePhase()
weaponSelected = true
end