Modified frontend so that updating campaogn progress no longer changes current index of the mission combo box
authorbelphegorr <szabibibi@gmail.com>
Sun, 08 Jul 2012 19:15:38 +0300
changeset 7245 53f73f4ae203
parent 7243 9ae9178c525e
child 7247 9aba0c6458af
Modified frontend so that updating campaogn progress no longer changes current index of the mission combo box Updated Animate.lua (forgot to copy it last time) Mission 1: Fixed a bug where events would cause animations to stutter Moved a crate Made the princess and the elder pay attention to Leaks A Lot Changed the name of the chief to Righteous Beard Mission 2: - Mission 3: Removed leftover debug lines Solved a bug where Dense Cloud could not select weapons during final scene Made the hogs fave each other during the final animation Mission 4: Solved a bug where Dense Cloud would appear even if he's dead
QTfrontend/hwform.cpp
QTfrontend/hwform.h
share/hedgewars/Data/Missions/Campaign/A Classic Fairytale/first_blood.lua
share/hedgewars/Data/Missions/Campaign/A Classic Fairytale/journey.lua
share/hedgewars/Data/Missions/Campaign/A Classic Fairytale/united.lua
share/hedgewars/Data/Scripts/Animate.lua
--- a/QTfrontend/hwform.cpp	Fri Jul 06 15:10:36 2012 +0300
+++ b/QTfrontend/hwform.cpp	Sun Jul 08 19:15:38 2012 +0300
@@ -1357,7 +1357,7 @@
 void HWForm::CreateGame(GameCFGWidget * gamecfg, TeamSelWidget* pTeamSelWidget, QString ammo)
 {
     game = new HWGame(config, gamecfg, ammo, pTeamSelWidget);
-    connect(game, SIGNAL(CampStateChanged(int)), this, SLOT(UpdateCampaignPage(int)));
+    connect(game, SIGNAL(CampStateChanged(int)), this, SLOT(UpdateCampaignPageProgress(int)));
     connect(game, SIGNAL(GameStateChanged(GameState)), this, SLOT(GameStateChanged(GameState)));
     connect(game, SIGNAL(GameStats(char, const QString &)), ui.pageGameStats, SLOT(GameStats(char, const QString &)));
     connect(game, SIGNAL(ErrorMessage(const QString &)), this, SLOT(ShowErrorMessage(const QString &)), Qt::QueuedConnection);
@@ -1592,6 +1592,13 @@
     }
 }
 
+void HWForm::UpdatecampaignPageProgress(int index)
+{
+  int missionIndex = ui.pageCampaign->CBMission->currentIndex();
+  UpdateCampaignPage(0);
+  ui.pageCampaign->CBMission->setCurrentIndex(missionIndex);
+}
+
 // used for --set-everything [screen width] [screen height] [color dept] [volume] [enable music] [enable sounds] [language file] [full screen] [show FPS] [alternate damage] [timer value] [reduced quality]
 QString HWForm::getDemoArguments()
 {
--- a/QTfrontend/hwform.h	Fri Jul 06 15:10:36 2012 +0300
+++ b/QTfrontend/hwform.h	Sun Jul 08 19:15:38 2012 +0300
@@ -121,6 +121,7 @@
         void onFrontendEffects(bool value);
         void Music(bool checked);
         void UpdateCampaignPage(int index);
+        void UpdatecampaignPageProgress(int index);
         void InitCampaignPage();
         //Starts the transmission process for the feedback
         void SendFeedback();
--- a/share/hedgewars/Data/Missions/Campaign/A Classic Fairytale/first_blood.lua	Fri Jul 06 15:10:36 2012 +0300
+++ b/share/hedgewars/Data/Missions/Campaign/A Classic Fairytale/first_blood.lua	Sun Jul 08 19:15:38 2012 +0300
@@ -57,6 +57,8 @@
 desertTaken = false
 challengeFailed = false
 difficultyChoice = false
+princessFace = "Left"
+elderFace = "Left"
 
 goals = {
   [startDialogue] = {loc("First Blood"), loc("First Steps"), loc("Press [Left] or [Right] to move around, [Enter] to jump"), 1, 4000},
@@ -78,6 +80,9 @@
   if goals[anim] ~= nil then
     ShowMission(unpack(goals[anim]))
   end
+  if anim == startDialogue then
+    HogTurnLeft(princess, false)
+  end
 end
 
 function SkipDamageAnim(anim)
@@ -131,7 +136,6 @@
   table.insert(onShroomAnim, {func = AnimShowMission, args = {youngh, loc("First Blood"), loc("A leap in a leap"), loc("Go on top of the flower"), 1, 4000}}) 
 
   AddSkipFunction(onFlowerAnim, Skipanim, {onFlowerAnim})
-  table.insert(onFlowerAnim, {func = AnimTurn, args = {elderh, "Right"}, skipFunc = Skipanim, skipArgs = onFlowerAnim})
   table.insert(onFlowerAnim, {func = AnimSay, args = {elderh, loc("See that crate farther on the right?"), SAY_SAY, 4000}})
   table.insert(onFlowerAnim, {func = AnimSay, args = {elderh, loc("Swing, Leaks A Lot, on the wings of the wind!"), SAY_SAY, 6000}})
   table.insert(onFlowerAnim, {func = AnimSay, args = {princess, loc("His arms are so strong!"), SAY_THINK, 4000}})
@@ -166,7 +170,6 @@
   table.insert(tookRope2Anim, {func = AnimSwitchHog, args = {youngh}})
 
   AddSkipFunction(tookPunchAnim, Skipanim, {tookPunchAnim})
-  table.insert(tookPunchAnim, {func = AnimTurn, args = {elderh, "Left"}, skipFunc = Skipanim, skipArgs = tookPunchAnim})
   table.insert(tookPunchAnim, {func = AnimSay, args = {elderh, loc("It is time to practice your fighting skills."), SAY_SAY, 4000}})
   table.insert(tookPunchAnim, {func = AnimSay, args = {elderh, loc("Imagine those targets are the wolves that killed your parents! Take your anger out on them!"), SAY_SAY, 5000}})
   table.insert(tookPunchAnim, {func = AnimShowMission, args = {youngh, loc("First Blood"), loc("The Slaughter"), loc("Destroy the targets!|Hint: Select the Shoryuken and hit [Space]|P.S. You can use it mid-air."), 1, 5000}}) 
@@ -216,6 +219,46 @@
   table.insert(cannKilledEarlyAnim, {func = AnimSay, args = {elderh, loc("What?! A cannibal? Here? There is no time to waste! Come, you are prepared."), SAY_SHOUT, 4000}})
 end
 -----------------------------Events------------------------------------
+function CheckNeedToTurn(gear)
+  if gear == princess then
+    if princessKilled ~= true then
+      if (GetX(princess) > GetX(youngh) and princessFace == "Right")
+        or (GetX(princess) < GetX(youngh) and princessFace == "Left") then
+      --if (GetX(princess) > GetX(youngh))
+       -- or (GetX(princess) < GetX(youngh)) then
+        return true
+      end
+    end
+  else
+    if elderKilled ~= true then
+      if (GetX(elderh) > GetX(youngh) and elderFace == "Right")
+        or (GetX(elderh) < GetX(youngh) and elderFace == "Left") then
+        return true
+      end
+    end
+  end
+  return false
+end
+
+function DoNeedToTurn(gear)
+  if gear == princess then
+    if GetX(princess) > GetX(youngh) then
+      HogTurnLeft(princess, true)
+      princessFace = "Left"
+    elseif GetX(princess) < GetX(youngh) then
+      HogTurnLeft(princess, false)
+      princessFace = "Right"
+    end
+  else
+    if GetX(elderh) > GetX(youngh) then
+      HogTurnLeft(elderh, true)
+      elderFace = "Left"
+    elseif GetX(elderh) < GetX(youngh) then
+      HogTurnLeft(elderh, false)
+      elderFace = "Right"
+    end
+  end
+end
 
 function CheckDamage()
   return youngdamaged and StoppedGear(youngh) 
@@ -274,7 +317,7 @@
 end
 
 function CheckOnShroom()
-  return GetX(youngh) >= 2461
+  return GetX(youngh) >= 2461 and StoppedGear(youngh)
 end
 
 function DoOnShroom()
@@ -284,7 +327,7 @@
 end
 
 function CheckOnFlower()
-  return rope1Taken
+  return rope1Taken and StoppedGear(youngh)
 end
 
 function DoOnFlower()
@@ -355,7 +398,7 @@
   targets[2] = AddGear(2188, 1314, gtTarget, 0, 0, 0, 0)
   targets[3] = AddGear(1961, 1318, gtTarget, 0, 0, 0, 0)
   targets[4] = AddGear(1961, 1200, gtTarget, 0, 0, 0, 0)
-  targets[5] = AddGear(1900, 1100, gtTarget, 0, 0, 0, 0)
+  targets[5] = AddGear(1800, 900, gtTarget, 0, 0, 0, 0)
   AddEvent(CheckTargDestroyed, {}, DoTargDestroyed, {}, 0)
 end
 
@@ -554,7 +597,7 @@
 
 	AddTeam(loc("Natives"), 29439, "Bone", "Island", "HillBilly", "cm_birdy")
 	youngh = AddHog(loc("Leaks A Lot"), 0, 100, "Rambo")
-  elderh = AddHog(loc("White Raven"), 0, 99, "IndianChief")
+  elderh = AddHog(loc("Righteous Beard"), 0, 99, "IndianChief")
   princess = AddHog(loc("Fell From Heaven"), 0, 300, "tiara")
   SetGearPosition(princess, 1911, 1361)
   HogTurnLeft(princess, true)
@@ -579,6 +622,9 @@
   SetState(cannibal, gstInvisible)
 
   AddAnim(startDialogue)
+  princessFace = "Right"
+  AddEvent(CheckNeedToTurn, {princess}, DoNeedToTurn, {princess}, 1)
+  AddEvent(CheckNeedToTurn, {elderh}, DoNeedToTurn, {elderh}, 1)
   AddEvent(CheckDamage, {}, DoOnDamage, {}, 1)
   AddEvent(CheckDeath, {}, DoDeath, {}, 0)
   AddEvent(CheckDamagedOthers, {}, DoOnDamagedOthers, {}, 1)
--- a/share/hedgewars/Data/Missions/Campaign/A Classic Fairytale/journey.lua	Fri Jul 06 15:10:36 2012 +0300
+++ b/share/hedgewars/Data/Missions/Campaign/A Classic Fairytale/journey.lua	Sun Jul 08 19:15:38 2012 +0300
@@ -149,6 +149,7 @@
   stage = endStage
   SwitchHog(leaks)
   SetGearMessage(leaks, 0)
+  SetGearMessage(dense, 0)
   TurnTimeLeft = -1
   ShowMission(loc("The Journey Back"), loc("Collateral Damage II"), loc("Save Fell From Heaven!"), 1, 4000)
   AddEvent(CheckLost, {}, DoLost, {}, 0)
@@ -280,6 +281,7 @@
 function RestoreCyborgOnly(x, y)
   RestoreHog(cyborg)
   cyborgHidden = false
+  SetState(cyborg, 0)
   AnimOutOfNowhere(cyborg, x, y)
   return true
 end
@@ -454,6 +456,7 @@
   
   table.insert(endFailAnim, {func = AnimCaption, args = {leaks, loc("Leaks A Lot, depressed for killing his loved one, failed to save the village..."), 3000}})
 
+  table.insert(winAnimAD, {func = AnimCustomFunction, args = {princess, CondNeedToTurn, {leaks, princess}}})
   table.insert(winAnimAD, {func = AnimSay, args = {princess, loc("Thank you, oh, thank you, Leaks A Lot!"), SAY_SAY, 5000}})
   table.insert(winAnimAD, {func = AnimSay, args = {princess, loc("How can I ever repay you for saving my life?"), SAY_SAY, 6000}})
   table.insert(winAnimAD, {func = AnimSay, args = {leaks, loc("There's nothing more satisfying for me than seeing you share your beauty with the world every morning, my princess!"), SAY_SAY, 10000}})
@@ -516,9 +519,11 @@
   
   table.insert(endFailAnim, {func = AnimCaption, args = {leaks, loc("Leaks A Lot, depressed for killing his loved one, failed to save the village..."), 3000}})
 
+  table.insert(winAnim, {func = AnimCustomFunction, args = {princess, CondNeedToTurn, {leaks, princess}}})
   table.insert(winAnim, {func = AnimSay, args = {princess, loc("Thank you, oh, thank you, my heroes!"), SAY_SAY, 5000}})
   table.insert(winAnim, {func = AnimSay, args = {princess, loc("How can I ever repay you for saving my life?"), SAY_SAY, 6000}})
-  table.insert(winAnim, {func = AnimSay, args = {leaks, loc("There's nothing more satisfying to us than seeing you share your beauty with the world every morning, my princess!"), SAY_SAY, 10000}})
+  table.insert(winAnim, {func = AnimSay, args = {leaks, loc("There's nothing more satisfying to us than seeing you share your beauty..."), SAY_SAY, 7000}})
+  table.insert(winAnim, {func = AnimSay, args = {leaks, loc("... share your beauty with the world every morning, my princess!"), SAY_SAY, 7000}})
   table.insert(winAnim, {func = AnimSay, args = {leaks, loc("Let's go home!"), SAY_SAY, 3000}})
   table.insert(winAnim, {func = AnimCaption, args = {leaks, loc("And so they discovered that cyborgs weren't invulnerable..."), 2000}})
 
@@ -576,6 +581,7 @@
   
   table.insert(endFailAnim, {func = AnimCaption, args = {leaks, loc("Leaks A Lot, depressed for killing his loved one, failed to save the village..."), 3000}})
 
+  table.insert(winAnim, {func = AnimCustomFunction, args = {princess, CondNeedToTurn, {leaks, princess}}})
   table.insert(winAnim, {func = AnimSay, args = {princess, loc("Thank you, oh, thank you, my heroes!"), SAY_SAY, 5000}})
   table.insert(winAnim, {func = AnimSay, args = {princess, loc("How can I ever repay you for saving my life?"), SAY_SAY, 6000}})
   table.insert(winAnim, {func = AnimSay, args = {leaks, loc("There's nothing more satisfying to us than seeing you share your beauty with the world every morning, my princess!"), SAY_SAY, 10000}})
@@ -963,8 +969,6 @@
   m2DenseDead = tonumber(GetCampaignVar("M2DenseDead"))
   m2RamonDead = tonumber(GetCampaignVar("M2RamonDead"))
   m2SpikyDead = tonumber(GetCampaignVar("M2SpikyDead"))
-  m2Choice = choiceAttacked
-  m2DenseDead = 1
   StartMission()
 end
 
--- a/share/hedgewars/Data/Missions/Campaign/A Classic Fairytale/united.lua	Fri Jul 06 15:10:36 2012 +0300
+++ b/share/hedgewars/Data/Missions/Campaign/A Classic Fairytale/united.lua	Sun Jul 08 19:15:38 2012 +0300
@@ -161,7 +161,6 @@
   table.insert(startAnim, {func = AnimTurn, args = {water, "Left"}})
   table.insert(startAnim, {func = AnimMove, args = {water, "Left", 2467, 754}})
   table.insert(startAnim, {func = AnimSay, args = {water, loc("Hey guys!"), SAY_SAY, 2500}})
-  table.insert(startAnim, {func = AnimTurn, args = {chief, "Right"}})
   table.insert(startAnim, {func = AnimSay, args = {chief, loc("..."), SAY_THINK, 1500}})
   table.insert(startAnim, {func = AnimSay, args = {chief, loc("Where have you been?"), SAY_SAY, 4000}})
   table.insert(startAnim, {func = AnimSay, args = {water, loc("Just on a walk."), SAY_SAY, 3000}})
@@ -247,7 +246,7 @@
 end
 
 function SetupPlace()
-  if m2DenseDead == true then
+  if m2DenseDead == 1 then
     DeleteGear(dense)
   end
   for i = 1, 8 do
--- a/share/hedgewars/Data/Scripts/Animate.lua	Fri Jul 06 15:10:36 2012 +0300
+++ b/share/hedgewars/Data/Scripts/Animate.lua	Sun Jul 08 19:15:38 2012 +0300
@@ -55,7 +55,7 @@
   lasty = 0
   jumpTypes = {long = gmLJump, high = gmHJump, back = gmHJump}
   jumpTimes = {long = 500, high = 500, back = 300, backback = 500} 
-  moveDirs = {right = gmRight, left = gmLeft}
+  moveDirs = {Right = gmRight, Left = gmLeft}
   jumpStarted = false
   backJumped = false
   jTimer = 0
@@ -182,6 +182,7 @@
 	AddVisualGear(GetX(gear)+5, GetY(gear)+5, vgtSmoke, 0, false)
 	AddVisualGear(GetX(gear)-5, GetY(gear)+5, vgtSmoke, 0, false)
 	AddVisualGear(GetX(gear)+5, GetY(gear)-5, vgtSmoke, 0, false)
+  PlaySound(sndExplosion)
 	SetGearPosition(gear, destX, destY)
   return true
 end
@@ -189,6 +190,7 @@
 function AnimOutOfNowhere(gear, destX, destY)
   SetGearPosition(gear, destX, destY)
   AddVisualGear(destX, destY, vgtBigExplosion, 0, false)
+  PlaySound(sndExplosion)
   AnimGearWait(gear, 50)
   return true
 end
@@ -200,6 +202,7 @@
 	AddVisualGear(GetX(gear)+5, GetY(gear)-5, vgtSmoke, 0, false)
 	SetGearPosition(gear, destX, destY)
 	AddVisualGear(GetX(gear), GetY(gear), vgtBigExplosion, 0, false)
+  PlaySound(sndExplosion)
   FollowGear(gear)
   AnimGearWait(gear, 50)
   return true