CS: Don't start sabotage damage before ready phase ends
authorWuzzy <Wuzzy2@mail.ru>
Wed, 28 Nov 2018 00:49:46 +0100
changeset 14324 5da99c43b96f
parent 14323 461a9a2d9ed8
child 14325 bd2bbd607f5e
CS: Don't start sabotage damage before ready phase ends
share/hedgewars/Data/Scripts/Multiplayer/Continental_supplies.lua
--- a/share/hedgewars/Data/Scripts/Multiplayer/Continental_supplies.lua	Tue Nov 27 20:23:48 2018 +0100
+++ b/share/hedgewars/Data/Scripts/Multiplayer/Continental_supplies.lua	Wed Nov 28 00:49:46 2018 +0100
@@ -1633,7 +1633,7 @@
 
 -- Spawn sabotage smoke for inactive hogs (red smoke, more subtle than for active hogs)
 function SabotageSmokeInactive(gear)
-	if GetGearType(gear) == gtHedgehog and gear ~= CurrentHedgehog and CS.SABOTAGE_HOGS[gear]~=nil and CS.SABOTAGE_HOGS[gear]>=1 then
+	if GetGearType(gear) == gtHedgehog and (gear ~= CurrentHedgehog or ReadyTimeLeft > 0) and CS.SABOTAGE_HOGS[gear]~=nil and CS.SABOTAGE_HOGS[gear]>=1 then
 		local vg = AddVisualGear(GetX(gear), GetY(gear), vgtSmokeWhite, 0, false)
 		SetVisualGearValues(vg, nil, nil, nil, nil, nil, nil, nil, nil, nil, 0xFF8080B0)
 	end
@@ -1773,7 +1773,7 @@
 	if(CS.SABOTAGE_HOGS[CurrentHedgehog]~=nil and CS.SABOTAGE_HOGS[CurrentHedgehog]>=1)
 	then
 		--for sabotage
-		if(CS.SABOTAGE_HOGS[CurrentHedgehog]==1)
+		if(CS.SABOTAGE_HOGS[CurrentHedgehog]==1 and ReadyTimeLeft == 0)
 		then
 			AddCaption(loc("You are sabotaged, RUN!"))
 
@@ -1785,7 +1785,7 @@
 			CS.SABOTAGE_HOGS[CurrentHedgehog]=2
 		end
 
-		if(CS.SABOTAGE_COUNTER % 20 == 0)
+		if(CS.SABOTAGE_HOGS[CurrentHedgehog]==2 and CS.SABOTAGE_COUNTER % 20 == 0)
 		then
 			-- Sabotage effect (red smoke)
 			local vg = AddVisualGear(GetX(CurrentHedgehog), GetY(CurrentHedgehog), vgtSmokeWhite, 0, false)
@@ -1799,10 +1799,11 @@
 		then
 			-- Sabotage decreases hog health regularily,
 			-- but invulnerable protects.
-			-- Also do not decrease health while retreating or attacking.
+			-- Also do not decrease health while retreating, attacking or in ready phase.
 			if(GetEffect(CurrentHedgehog, heInvulnerable) == 0 and
 			band(GetState(CurrentHedgehog), gstHHDriven) ~= 0 and
-			band(GetState(CurrentHedgehog), gstAttacked+gstAttacking) == 0)
+			band(GetState(CurrentHedgehog), gstAttacked+gstAttacking) == 0) and
+			(ReadyTimeLeft == 0)
 			then
 				if(GetHealth(CurrentHedgehog)<=CS.SABOTAGE_DAMAGE)
 				then