# HG changeset patch # User Wuzzy # Date 1520800688 -3600 # Node ID 89a6b862e69201720f3d7b4fbb4357ed2b31a497 # Parent a4d257f4b3e0e2b8945e77b7905c7f5e381bc98d Bazooka/Grenade Training: Make weapon selection detection future-proof The old check relied on hardcoded slot IDs for the weapons, which is not good. diff -r a4d257f4b3e0 -r 89a6b862e692 share/hedgewars/Data/Missions/Training/Basic_Training_-_Bazooka.lua --- 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() diff -r a4d257f4b3e0 -r 89a6b862e692 share/hedgewars/Data/Missions/Training/Basic_Training_-_Grenade.lua --- 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