ASA: Fruit03: Show collected ammo
authorWuzzy <Wuzzy2@mail.ru>
Tue, 06 Feb 2018 23:48:34 +0100
changeset 12906 4ea0691d0ad5
parent 12905 06791c62c759
child 12907 7bf84ebc6389
ASA: Fruit03: Show collected ammo
share/hedgewars/Data/Missions/Campaign/A_Space_Adventure/fruit03.lua
--- a/share/hedgewars/Data/Missions/Campaign/A_Space_Adventure/fruit03.lua	Tue Feb 06 06:33:32 2018 +0100
+++ b/share/hedgewars/Data/Missions/Campaign/A_Space_Adventure/fruit03.lua	Tue Feb 06 23:48:34 2018 +0100
@@ -171,15 +171,42 @@
 	end
 end
 
+-- Display ammo icon above gear. i = offset (start at 1)
+local function displayAmmoIcon(gear, ammoType, i)
+	local x = GetX(gear) + 2
+	local y = GetY(gear) + 32 * i
+	local vgear = AddVisualGear(x, y, vgtAmmo, 0, true)
+	if vgear ~= nil then
+		local vgtX,vgtY,vgtdX,vgtdY,vgtAngle,vgtFrame,vgtFrameTicks,vgtState,vgtTimer,vgtTint = GetVisualGearValues(vgear)
+		local vgtFrame = ammoType
+		SetVisualGearValues(vgear,vgtX,vgtY,vgtdX,vgtdY,vgtAngle,vgtFrame,vgtFrameTicks,vgtState,vgtTimer,vgtTint)
+	end
+end
+
 function onGearDelete(gear)
 	if (isHog(gear)) then
 		local availableTeleports = GetAmmoCount(hero.gear,amTeleport)
 		local availableSniper = GetAmmoCount(hero.gear,amSniperRifle)
+		local ammolist = ""
+		local tele = false
 		if availableTeleports < 2 then
 			AddAmmo(hero.gear, amTeleport, availableTeleports + 1 )
+			displayAmmoIcon(hero.gear, amTeleport, 1)
+			tele = true
+			ammolist = ammolist .. string.format(loc("%s (+1)"), GetAmmoName(amTeleport))
 		end
 		if availableSniper < 4 then
 			AddAmmo(hero.gear, amSniperRifle, availableSniper + 1 )
+			displayAmmoIcon(hero.gear, amSniperRifle, 2)
+			if tele then
+				ammolist = ammolist .. " • "
+			end
+			ammolist = ammolist .. string.format(loc("%s (+1)"), GetAmmoName(amSniperRifle))
+		end
+		-- Show collected ammo
+		if ammolist ~= "" then
+			PlaySound(sndShotgunReload)
+			AddCaption(ammolist, GetClanColor(GetHogClan(hero.gear)), capgrpAmmoinfo)
 		end
 	end
 end