Merge unC0Rr's control fixes
authorWuzzy <Wuzzy2@mail.ru>
Fri, 09 Mar 2018 00:45:37 +0100
changeset 13141 ee88e766d519
parent 13140 824a75401a61 (diff)
parent 13137 52178e8ffdfc (current diff)
child 13142 475c9d54a8e2
Merge unC0Rr's control fixes
--- a/hedgewars/uAI.pas	Thu Mar 08 23:28:58 2018 +0100
+++ b/hedgewars/uAI.pas	Fri Mar 09 00:45:37 2018 +0100
@@ -474,7 +474,7 @@
 
             // Hog has no idea what to do. Use tardis or skip
             if not bonuses.activity then
-                if ((HHHasAmmo(Me^.Hedgehog^, amTardis) > 0)) and (CanUseTardis(Me^.Hedgehog^.Gear)) and (random(4) < 3) then
+                if (((GameFlags and gfInfAttack) <> 0) or (not isInMultiShoot)) and ((HHHasAmmo(Me^.Hedgehog^, amTardis) > 0)) and (CanUseTardis(Me^.Hedgehog^.Gear)) and (random(4) < 3) then
                     // Tardis brings hog to a random place. Perfect for clueless AI
                     begin
                     AddAction(BestActions, aia_Weapon, Longword(amTardis), 80, 0, 0);
--- a/share/hedgewars/Data/Missions/Campaign/A_Classic_Fairytale/family.lua	Thu Mar 08 23:28:58 2018 +0100
+++ b/share/hedgewars/Data/Missions/Campaign/A_Classic_Fairytale/family.lua	Fri Mar 09 00:45:37 2018 +0100
@@ -130,6 +130,8 @@
 cratesNum = 0
 
 princessFreed = false
+closeToPrincess = false
+friendsEscaped = false
 -----------------------------Animations--------------------------------
 function EmitDenseClouds(dir)
   local dif
@@ -219,8 +221,16 @@
   SetupPlace3()
   SetGearMessage(natives[1], 0)
   AddNewEvent(CheckPrincessFreed, {}, DoPrincessFreed, {}, 0)
+  AddNewEvent(CheckCloseToPrincess, {}, DoCloseToPrincess, {}, 0)
+  AddNewEvent(CheckFriendsEscaped, {}, DoFriendsEscaped, {}, 0)
   EndTurn(true)
-  ShowMission(loc("Family Reunion"), loc("Salvation"), loc("Get your teammates out of their natural prison and save the princess!|All your hedgehogs must be above the marked height!|Hint: Drilling holes should solve everything.|Hint: It might be a good idea to place a girder before starting to drill. Just saying.|Hint: Leaks A Lot needs to get really close to the princess!") .. "|" .. loc("Mines time: 5 seconds"), 1, 7000)
+  ShowMission(loc("Family Reunion"), loc("Salvation"),
+     loc("Get your teammates out of their natural prison and save the princess!") .."|"..
+     loc("All your hedgehogs must be above the marked height!") .."|"..
+     loc("Hint: Drilling holes should solve everything.").."|"..
+     loc("Hint: It might be a good idea to place a girder before starting to drill. Just saying.").."|"..
+     string.format(loc("Hint: %s needs to get really close to the princess!"), nativeNames[m5DeployedNum]).."|"..
+     loc("Mines time: 5 seconds"), 1, 7000)
   vCirc = AddVisualGear(0,0,vgtCircle,0,true)
   SetVisualGearValues(vCirc, 2625, 1500, 100, 255, 1, 10, 0, 120, 3, 0xff00ffff)
 end
@@ -231,7 +241,8 @@
 
 function SkipMidAnim()
   AnimTeleportGear(natives[1], unpack(nativeMidPos2))
-  SkipStartAnim()
+  AnimSwitchHog(natives[1])
+  AnimWait(natives[1], 1)
 end
 
 function SetupPlace3()
@@ -313,18 +324,55 @@
 end
 
 -----------------------------Events------------------------------------
-function CheckPrincessFreed()
-  if GetX(natives[1]) == nil or GetX(natives[2]) == nil or GetX(natives[3]) == nil or GetX(princess) == nil then
+function CheckCloseToPrincess()
+  if GetX(natives[1]) == nil or GetX(princess) == nil then
     return false
   end
-  return math.abs(GetX(natives[1]) - GetX(princess)) <= 15 and math.abs(GetY(natives[1]) - GetY(princess)) <= 15 and StoppedGear(natives[1]) 
-        and GetY(natives[2]) < 1500 and GetY(natives[3]) < 1500 and StoppedGear(natives[2]) and StoppedGear(natives[3])
+  return math.abs(GetX(natives[1]) - GetX(princess)) <= 20 and math.abs(GetY(natives[1]) - GetY(princess)) <= 17 and StoppedGear(natives[1])
+end
+
+function CheckFriendsEscaped()
+  if GetX(natives[2]) == nil or GetX(natives[3]) == nil then
+    return false
+  end
+  return GetY(natives[2]) < 1500 and GetY(natives[3]) < 1500 and StoppedGear(natives[2]) and StoppedGear(natives[3])
+end
+
+function CheckPrincessFreed()
+  return CheckCloseToPrincess() and CheckFriendsEscaped()
 end
 
 function DoPrincessFreed()
   AddAnim(princessFreedAnim)
 end
 
+function DoFriendsEscaped()
+  if friendsEscaped then
+    return
+  end
+  if not CheckCloseToPrincess() then
+    if GetX(natives[2]) == nil and GetX(natives[1]) == nil then
+      return
+    end
+    HogSay(natives[2], string.format(loc("Finally! We're out of this hellhole. Now go save the princess, %s!"), nativeNames[natives[m5DeployedNum]]), SAY_SAY)
+  end
+  friendsEscaped = true
+end
+
+function DoCloseToPrincess()
+  if closeToPrincess then
+    return
+  end
+  if not CheckFriendsEscaped() then
+    if GetX(natives[2]) == nil then
+      return
+    end
+    HogSay(natives[2], loc("Hey, don't forget us! We still need to climb up!"), SAY_SHOUT)
+    FollowGear(natives[2])
+  end
+  closeToPrincess = true
+end
+
 function Victory()
   if not princessFreed then
     if progress and progress<7 then
@@ -383,6 +431,8 @@
 
 function EndMission()
   if not princessFreed then
+    RemoveEventFunc(CheckFriendsEscaped)
+    RemoveEventFunc(CheckCloseToPrincess)
     RemoveEventFunc(CheckPrincessFreed)
     AddCaption(loc("So the princess was never heard of again ..."))
     DismissTeam(loc("Natives"))