Killing The Specialists mission: Fix misleading hints, add messages and visual effects
authorWuzzy <Wuzzy2@mail.ru>
Fri, 09 Feb 2018 10:47:21 +0100
changeset 12940 ff42888333bc
parent 12939 bc7138add7eb
child 12941 b9904380ce26
Killing The Specialists mission: Fix misleading hints, add messages and visual effects
ChangeLog.txt
share/hedgewars/Data/Missions/Campaign/A_Space_Adventure/death02.lua
--- a/ChangeLog.txt	Fri Feb 09 07:41:37 2018 +0100
+++ b/ChangeLog.txt	Fri Feb 09 10:47:21 2018 +0100
@@ -18,6 +18,8 @@
 A Space Adventure:
  + Precise Shooting: Display collected ammo
  + Hard Flying: Display personal best at mission start
+ + Killing the Specialists: Add event messages and graphical effects
+ * Killing the Specialists: Fix very misleading hints in mission panel
 
 A Classic Fairytale:
  + Mission 3: Display number of turns left at timed parcours
--- a/share/hedgewars/Data/Missions/Campaign/A_Space_Adventure/death02.lua	Fri Feb 09 07:41:37 2018 +0100
+++ b/share/hedgewars/Data/Missions/Campaign/A_Space_Adventure/death02.lua	Fri Feb 09 10:47:21 2018 +0100
@@ -11,13 +11,13 @@
 -- globals
 local missionName = loc("Killing the specialists")
 local challengeObjectives = loc("Use your available weapons in order to eliminate the enemies.").."|"..
-	loc("Each time you play this mission, enemy hogs will play in a random order.").."|"..
+	loc("The enemy hogs play in a random order.").."|"..
 	loc("At the start of the game each enemy hog has only the weapon that he is named after.").."|"..
 	loc("A random hedgehog will inherit the weapons of his deceased team-mates.").."|"..
-	loc("If you kill a hedgehog with the respective weapon your health points will be set to 100.").."|"..
-	loc("If you injure a hedgehog you'll get 35% of the damage dealt.").."|"..
-	loc("Every time you kill an enemy hog your ammo will get reset next turn.").."|"..
-	loc("The rope won't get reset.")
+	loc("After you killed an enemy, you'll lose the weapon that he is named after.").."|"..
+	loc("If only one enemy is left, you'll get bonus ammo.").."|"..
+	loc("If you hurt an enemy, you'll get one third of the damage dealt.").."|"..
+	loc("If you kill an enemy, your health will be set to 100.")
 -- mission objectives
 local goals = {
 	["init"] = {missionName, loc("Challenge objectives"), challengeObjectives, 1, 35000},
@@ -54,6 +54,25 @@
 local battleStarted = false
 local firstTurn = true
 
+-- Spawn health particles and print health message
+local function healthBoostAnim(gear, health, tint)
+	if health < 1 then
+		return
+	end
+	local h = 0
+	while (h < health and h < 1000) do
+		local vg = AddVisualGear(GetX(gear), GetY(gear), vgtStraightShot, sprHealth, false)
+		if vg ~= nil then
+			SetVisualGearValues(vg, nil, nil, nil, nil, nil, nil, nil, nil, nil, tint)
+			SetState(vg, sprHealth)
+		end
+		h = h + 5
+	end
+	if math.floor(health) >= 1 then
+		AddCaption(string.format(loc("+%d"), math.floor(health)), GetClanColor(GetHogClan(gear)), capgrpMessage2)
+	end
+end
+
 -------------- LuaAPI EVENT HANDLERS ------------------
 
 function onGameInit()
@@ -111,14 +130,14 @@
 	end
 	if CurrentHedgehog ~= hero.gear then
 		enemyWeapons()
-	elseif heroWeaponResetPending then
-		refreshHeroAmmo()
 	end
 end
 
 function onGearDelete(gear)
 	if isHog(gear) then
+		local healthDiff = 100 - GetHealth(hero.gear)
 		SetHealth(hero.gear, 100)
+		healthBoostAnim(hero.gear, healthDiff, 0x00FF00FF)
 		local deadHog = getHog(gear)
 		if deadHog.weapon == amMortar then
 			hero.mortarAmmo = 0
@@ -145,7 +164,9 @@
 
 function onGearDamage(gear, damage)
 	if isHog(gear) and GetHealth(hero.gear) then
-		SetHealth(hero.gear, GetHealth(hero.gear) + damage/3)
+		local bonusHealth = damage/3
+		SetHealth(hero.gear, GetHealth(hero.gear) + bonusHealth)
+		healthBoostAnim(hero.gear, bonusHealth, 0xFF0000FF)
 	end
 end
 
@@ -158,6 +179,13 @@
 	CheckEvents()
 end
 
+function onGameTick20()
+	-- Refresh hero ammo immediately after its not his turn anymore
+	if CurrentHedgehog ~= hero.gear and heroWeaponResetPending then
+		refreshHeroAmmo()
+	end
+end
+
 -- Hide mission panel when player does anything
 function hideMissionOnAction()
 	if battleStarted then
@@ -235,6 +263,8 @@
 	local extraAmmo = 0
 	if getAliveEnemiesCount() == 1 then
 		extraAmmo = 2
+		PlaySound(sndShotgunReload)
+		AddCaption(loc("Reinforcements! +2 of each weapon!"), GetClanColor(GetHogClan(hero.gear)), capgrpAmmoinfo)
 	end
 	AddAmmo(hero.gear, amMortar, hero.mortarAmmo + extraAmmo)
 	AddAmmo(hero.gear, amFirePunch, hero.firepunchAmmo + extraAmmo)