Add healing visual effect + heal msg in scripts
authorWuzzy <Wuzzy2@mail.ru>
Fri, 09 Feb 2018 14:33:00 +0100
changeset 12945 39b7b3ed619e
parent 12944 0112ef349ddc
child 12946 ffbd31afed96
Add healing visual effect + heal msg in scripts
ChangeLog.txt
share/hedgewars/Data/Missions/Campaign/A_Space_Adventure/death02.lua
share/hedgewars/Data/Scripts/Multiplayer/Construction_Mode.lua
share/hedgewars/Data/Scripts/Multiplayer/Continental_supplies.lua
share/hedgewars/Data/Scripts/Multiplayer/Mutant.lua
--- a/ChangeLog.txt	Fri Feb 09 12:52:05 2018 +0100
+++ b/ChangeLog.txt	Fri Feb 09 14:33:00 2018 +0100
@@ -4,7 +4,7 @@
 Game:
  + New weapon: Minigun
  + Change weapon icons: Mudball, air mine
- + Add visual effect when hogs heal in "reset health" mode
+ + Add healing visual effect in Paramedics mode and a few scripts
  * Fix time box being usable in Sudden Death with 0 health decrease
  * Fix chat input key being sometimes registered twice
 
--- a/share/hedgewars/Data/Missions/Campaign/A_Space_Adventure/death02.lua	Fri Feb 09 12:52:05 2018 +0100
+++ b/share/hedgewars/Data/Missions/Campaign/A_Space_Adventure/death02.lua	Fri Feb 09 14:33:00 2018 +0100
@@ -54,25 +54,6 @@
 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()
@@ -135,9 +116,13 @@
 
 function onGearDelete(gear)
 	if isHog(gear) then
+		-- Set health to 100 (with heal effect, if health was smaller)
 		local healthDiff = 100 - GetHealth(hero.gear)
-		SetHealth(hero.gear, 100)
-		healthBoostAnim(hero.gear, healthDiff, 0x00FF00FF)
+		if healthDiff > 1 then
+			HealHog(hero.gear, healthDiff, true, 0x00FF00FF)
+		else
+			SetHealth(hero.gear, 100)
+		end
 		local deadHog = getHog(gear)
 		if deadHog.weapon == amMortar then
 			hero.mortarAmmo = 0
@@ -165,8 +150,7 @@
 function onGearDamage(gear, damage)
 	if isHog(gear) and GetHealth(hero.gear) then
 		local bonusHealth = div(damage, 3)
-		SetHealth(hero.gear, GetHealth(hero.gear) + bonusHealth)
-		healthBoostAnim(hero.gear, bonusHealth, 0xFF0000FF)
+		HealHog(hero.gear, bonusHealth, true, 0xFF0000FF)
 	end
 end
 
--- a/share/hedgewars/Data/Scripts/Multiplayer/Construction_Mode.lua	Fri Feb 09 12:52:05 2018 +0100
+++ b/share/hedgewars/Data/Scripts/Multiplayer/Construction_Mode.lua	Fri Feb 09 14:33:00 2018 +0100
@@ -624,11 +624,16 @@
 			if GetGearType(gear) == gtHedgehog then
 				if GetHogClan(gear) == strucClan[tempID] then
 
-					hogLife = GetHealth(gear) + 1
-					if hogLife > 150 then
-						hogLife = 150
+					local hogLife = GetHealth(gear)
+					-- Heal hog by 1 HP, up to 150 HP total
+					if hogLife < 150 then
+						if ((hogLife + 1) % 5) == 0 then
+							-- Health anim every 5 HP
+							HealHog(gear, 1, false)
+						else
+							SetHealth(gear, hogLife+1)
+						end
 					end
-					SetHealth(gear, hogLife)
 
 					-- change this to the med kit sprite health ++++s later
 					tempE = AddVisualGear(GetX(strucGear[tempID]), GetY(strucGear[tempID]), vgtSmoke, 0, true)
--- a/share/hedgewars/Data/Scripts/Multiplayer/Continental_supplies.lua	Fri Feb 09 12:52:05 2018 +0100
+++ b/share/hedgewars/Data/Scripts/Multiplayer/Continental_supplies.lua	Fri Feb 09 14:33:00 2018 +0100
@@ -707,7 +707,7 @@
 	then
 		if(gearIsInCircle(GLOBAL_TEMP_VALUE,GetX(hog), GetY(hog), 100, false))
 		then
-			SetHealth(hog, GetHealth(hog)+25+(div(25*GLOBAL_VAMPIRIC_IS_ON,100)))
+			HealHog(hog, 25 + (div(25*GLOBAL_VAMPIRIC_IS_ON,100)), hog == CurrentHedgehog)
 			SetEffect(hog, hePoisoned, false)
 			GLOBAL_SABOTAGE_HOGS[hog]=0
 		end
@@ -1259,7 +1259,7 @@
 		then
 			GLOBAL_TEMP_VALUE=0
 			runOnGears(KerguelenSpecialRed)
-			SetHealth(CurrentHedgehog, GetHealth(CurrentHedgehog)+GLOBAL_TEMP_VALUE)
+			HealHog(CurrentHedgehog, GLOBAL_TEMP_VALUE)
 			PlaySound(sndHellish)
 
 		--swap
--- a/share/hedgewars/Data/Scripts/Multiplayer/Mutant.lua	Fri Feb 09 12:52:05 2018 +0100
+++ b/share/hedgewars/Data/Scripts/Multiplayer/Mutant.lua	Fri Feb 09 14:33:00 2018 +0100
@@ -633,9 +633,8 @@
                 else
                     if curr_team ~=GetHogTeamName(gear) then
                         if CurrentHedgehog==mutant and getGearValue(mutant,"SelfDestruct")==false then
-                            SetHealth(CurrentHedgehog, GetHealth(CurrentHedgehog)+kill_reward)
+                            HealHog(CurrentHedgehog, kill_reward)
                             AddCaption(loc("+1 point"), GetClanColor(GetHogClan(CurrentHedgehog)), capgrpMessage)
-                            AddCaption(string.format(loc("+%d health"), kill_reward), GetClanColor(GetHogClan(CurrentHedgehog)), capgrpMessage2)
                             increaseTeamValue(curr_team,"Score")
                         end
                         if getGearValue(CurrentHedgehog,"Feeder") then