lua api: DismissTeam(teamname)
authorsheepluva
Thu, 12 Jun 2014 21:25:39 +0200
changeset 10290 42efccba0711
parent 10289 c3a77ff02a23
child 10291 d9893b1b76a0
lua api: DismissTeam(teamname)
hedgewars/uScript.pas
share/hedgewars/Data/Missions/Campaign/A_Classic_Fairytale/backstab.lua
share/hedgewars/Data/Missions/Campaign/A_Classic_Fairytale/enemy.lua
share/hedgewars/Data/Missions/Campaign/A_Classic_Fairytale/family.lua
share/hedgewars/Data/Missions/Campaign/A_Classic_Fairytale/journey.lua
share/hedgewars/Data/Missions/Campaign/A_Classic_Fairytale/queen.lua
share/hedgewars/Data/Missions/Campaign/A_Classic_Fairytale/shadow.lua
share/hedgewars/Data/Missions/Campaign/A_Classic_Fairytale/united.lua
share/hedgewars/Data/Missions/Campaign/A_Space_Adventure/moon01.lua
share/hedgewars/Data/Missions/Training/Basic_Training_-_Grenade.lua
share/hedgewars/Data/Missions/Training/Basic_Training_-_Rope.lua
share/hedgewars/Data/Missions/Training/User_Mission_-_Dangerous_Ducklings.lua
share/hedgewars/Data/Missions/Training/User_Mission_-_RCPlane_Challenge.lua
share/hedgewars/Data/Missions/Training/User_Mission_-_Rope_Knock_Challenge.lua
--- a/hedgewars/uScript.pas	Thu Jun 12 20:47:11 2014 +0200
+++ b/hedgewars/uScript.pas	Thu Jun 12 21:25:39 2014 +0200
@@ -1521,6 +1521,14 @@
     lc_addteam:= 0;//1;
 end;
 
+function lc_dismissteam(L : Plua_State) : LongInt; Cdecl;
+var np: LongInt;
+begin
+    if CheckLuaParameterCount(L, 1, 'DismissTeam', 'teamname') then
+        ParseCommand('teamgone ' + lua_tostring(L, 1), true, true);
+    lc_dismissteam:= 0;;
+end;
+
 function lc_addhog(L : Plua_State) : LongInt; Cdecl;
 var temp: ShortString;
 begin
@@ -2647,6 +2655,7 @@
 lua_register(luaState, _P'GetInputMask', @lc_getinputmask);
 lua_register(luaState, _P'SetInputMask', @lc_setinputmask);
 lua_register(luaState, _P'AddGear', @lc_addgear);
+lua_register(luaState, _P'DismissTeam', @lc_dismissteam);
 lua_register(luaState, _P'EnableGameFlags', @lc_enablegameflags);
 lua_register(luaState, _P'DisableGameFlags', @lc_disablegameflags);
 lua_register(luaState, _P'ClearGameFlags', @lc_cleargameflags);
--- a/share/hedgewars/Data/Missions/Campaign/A_Classic_Fairytale/backstab.lua	Thu Jun 12 20:47:11 2014 +0200
+++ b/share/hedgewars/Data/Missions/Campaign/A_Classic_Fairytale/backstab.lua	Thu Jun 12 21:25:39 2014 +0200
@@ -617,9 +617,9 @@
 
 function DoDeployedDead()
   ShowMission(loc("Backstab"), loc("Brutus"), loc("You have failed to save the tribe!"), 0, 6000)
-  ParseCommand("teamgone " .. loc("Natives"))
-  ParseCommand("teamgone " .. loc("Tribe"))
-  ParseCommand("teamgone " .. loc("011101001"))
+  DismissTeam(loc("Natives"))
+  DismissTeam(loc("Tribe"))
+  DismissTeam(loc("011101001"))
   TurnTimeLeft = 0
 end
 
@@ -662,8 +662,8 @@
 
 function DoKilledOther()
   ShowMission(loc("Backstab"), loc("Brutus"), loc("You have killed an innocent hedgehog!"), 0, 6000)
-  ParseCommand("teamgone " .. loc("Natives"))
-  ParseCommand("teamgone " .. loc("Tribe"))
+  DismissTeam(loc("Natives"))
+  DismissTeam(loc("Tribe"))
   TurnTimeLeft = 0
 end
 
@@ -770,10 +770,10 @@
     end
   end
 
-  ParseCommand("teamgone " .. loc("Tribe"))
-  ParseCommand("teamgone " .. loc("Assault Team"))
-  ParseCommand("teamgone " .. loc("Reinforcements"))
-  ParseCommand("teamgone " .. loc("011101001"))
+  DismissTeam(loc("Tribe"))
+  DismissTeam(loc("Assault Team"))
+  DismissTeam(loc("Reinforcements"))
+  DismissTeam(loc("011101001"))
   TurnTimeLeft = 0
 end
 
--- a/share/hedgewars/Data/Missions/Campaign/A_Classic_Fairytale/enemy.lua	Thu Jun 12 20:47:11 2014 +0200
+++ b/share/hedgewars/Data/Missions/Campaign/A_Classic_Fairytale/enemy.lua	Thu Jun 12 21:25:39 2014 +0200
@@ -385,9 +385,9 @@
 end
 
 function LoseMission()
-  ParseCommand("teamgone " .. loc("Natives"))
-  ParseCommand("teamgone " .. loc("Cannibals"))
-  ParseCommand("teamgone " .. loc("011101001"))
+  DismissTeam(loc("Natives"))
+  DismissTeam(loc("Cannibals"))
+  DismissTeam(loc("011101001"))
   TurnTimeLeft = 0
 end
 
@@ -403,7 +403,7 @@
   if progress and progress<9 then
     SaveCampaignVar("Progress", "9")
   end
-  ParseCommand("teamgone " .. loc("011101001"))
+  DismissTeam(loc("011101001"))
   TurnTimeLeft = 0
 end
 -----------------------------Misc--------------------------------------
--- a/share/hedgewars/Data/Missions/Campaign/A_Classic_Fairytale/family.lua	Thu Jun 12 20:47:11 2014 +0200
+++ b/share/hedgewars/Data/Missions/Campaign/A_Classic_Fairytale/family.lua	Thu Jun 12 21:25:39 2014 +0200
@@ -287,7 +287,7 @@
   if progress and progress<7 then
     SaveCampaignVar("Progress", "7")
   end
-  ParseCommand("teamgone " .. loc("011101001"))
+  DismissTeam(loc("011101001"))
   TurnTimeLeft = 0
 end
 
@@ -339,8 +339,8 @@
 function EndMission()
   RemoveEventFunc(CheckPrincessFreed)
   AddCaption("So the princess was never heard of again...")
-  ParseCommand("teamgone " .. loc("Natives"))
-  ParseCommand("teamgone " .. loc("011101001"))
+  DismissTeam(loc("Natives"))
+  DismissTeam(loc("011101001"))
   TurnTimeLeft = 0
 end
 
--- a/share/hedgewars/Data/Missions/Campaign/A_Classic_Fairytale/journey.lua	Thu Jun 12 20:47:11 2014 +0200
+++ b/share/hedgewars/Data/Missions/Campaign/A_Classic_Fairytale/journey.lua	Thu Jun 12 21:25:39 2014 +0200
@@ -80,7 +80,7 @@
 
 --/////////////////////////Animation Functions///////////////////////
 function AfterMidFailAnim()
-  ParseCommand("teamgone " .. loc("Natives"))
+  DismissTeam(loc("Natives"))
   TurnTimeLeft = 0
 end
 
@@ -568,7 +568,7 @@
 end
 
 function KillPrincess()
-  ParseCommand("teamgone " .. loc("Cannibal Sentry"))
+  DismissTeam(loc("Cannibal Sentry"))
   TurnTimeLeft = 0
 end
 --/////////////////////////////Misc Functions////////////////////////
@@ -804,7 +804,7 @@
 
 function DoLeaksDead()
   AddCaption(loc("The village, unprepared, was destroyed by the cyborgs..."))
-  ParseCommand("teamgone " .. loc("Natives"))
+  DismissTeam(loc("Natives"))
 end
 
 function CheckDenseDead()
@@ -813,7 +813,7 @@
 
 function DoDenseDead()
   AddCaption(loc("The village, unprepared, was destroyed by the cyborgs..."))
-  ParseCommand("teamgone " .. loc("Natives"))
+  DismissTeam(loc("Natives"))
 end
 
 function CheckTookBlowTorch()
@@ -895,7 +895,7 @@
 
 function DoLost()
   AddAnim(endFailAnim)
-  AddFunction({func = ParseCommand, args = {'teamgone ' .. loc('Natives')}})
+  AddFunction({func = DismissTeam, args = {loc('Natives')}})
 end
 
 function CheckWon()
@@ -912,8 +912,8 @@
 
 function FinishWon()
   SwitchHog(leaks)
-  ParseCommand("teamgone " .. loc("Cannibal Sentry"))
-  ParseCommand("teamgone " .. loc("011101001"))
+  DismissTeam(loc("Cannibal Sentry"))
+  DismissTeam(loc("011101001"))
   TurnTimeLeft = 0
 end
 
--- a/share/hedgewars/Data/Missions/Campaign/A_Classic_Fairytale/queen.lua	Thu Jun 12 20:47:11 2014 +0200
+++ b/share/hedgewars/Data/Missions/Campaign/A_Classic_Fairytale/queen.lua	Thu Jun 12 21:25:39 2014 +0200
@@ -521,9 +521,9 @@
 
 function KillEnemy()
   if enemyFled == "1" then
-    ParseCommand("teamgone " .. loc("Leaderbot"))
+    DismissTeam(loc("Leaderbot"))
   end
-  ParseCommand("teamgone " .. loc("011101001"))
+  DismissTeam(loc("011101001"))
   TurnTimeLeft = 0
 end
 
--- a/share/hedgewars/Data/Missions/Campaign/A_Classic_Fairytale/shadow.lua	Thu Jun 12 20:47:11 2014 +0200
+++ b/share/hedgewars/Data/Missions/Campaign/A_Classic_Fairytale/shadow.lua	Thu Jun 12 21:25:39 2014 +0200
@@ -664,7 +664,7 @@
   AddAnim(stronglingsAnim)
   AddFunction({func = AfterStronglingsAnim, args = {}})
   stage = interWeakStage
-  ParseCommand("teamgone " .. loc("Weaklings"))
+  DismissTeam(loc("Weaklings"))
 end
 
 function CheckRefuse()
@@ -823,7 +823,7 @@
   AddCaption(loc("...and so the cyborgs took over the world..."))
   stage = loseStage
   TurnTimeLeft = 0
-  ParseCommand("teamgone " .. loc("Natives"))
+  DismissTeam(loc("Natives"))
 end
 
 function CheckDenseDead()
--- a/share/hedgewars/Data/Missions/Campaign/A_Classic_Fairytale/united.lua	Thu Jun 12 20:47:11 2014 +0200
+++ b/share/hedgewars/Data/Missions/Campaign/A_Classic_Fairytale/united.lua	Thu Jun 12 21:25:39 2014 +0200
@@ -112,7 +112,7 @@
   if progress and progress<4 then
     SaveCampaignVar("Progress", "4")
   end
-  ParseCommand("teamgone " .. loc("011101001"))
+  DismissTeam(loc("011101001"))
   TurnTimeLeft = 0
 end
 -----------------------------Animations--------------------------------
--- a/share/hedgewars/Data/Missions/Campaign/A_Space_Adventure/moon01.lua	Thu Jun 12 20:47:11 2014 +0200
+++ b/share/hedgewars/Data/Missions/Campaign/A_Space_Adventure/moon01.lua	Thu Jun 12 21:25:39 2014 +0200
@@ -360,7 +360,7 @@
 	elseif GetHealth(minion3.gear) then
 		AnimSay(minion3.gear, loc("The boss has fallen! Retreat!"), SAY_SHOUT, 6000)
 	end
-	ParseCommand("teamgone " .. teamB.name)
+	DismissTeam(teamB.name)
 	AnimCaption(hero.gear, loc("Congrats! You made them run away!"), 6000)
 	AnimWait(hero.gear,5000)
 
@@ -377,7 +377,7 @@
 function minionsDeath(gear)
 	-- do staffs here
 	AnimSay(professor.gear, loc("I may lost this battle, but I haven't lost the war yet!"), SAY_SHOUT, 6000)
-	ParseCommand("teamgone " .. teamC.name)
+	DismissTeam(teamC.name)
 	AnimCaption(hero.gear, loc("Congrats! You won!"), 6000)
 	AnimWait(hero.gear,5000)
 
--- a/share/hedgewars/Data/Missions/Training/Basic_Training_-_Grenade.lua	Thu Jun 12 20:47:11 2014 +0200
+++ b/share/hedgewars/Data/Missions/Training/Basic_Training_-_Grenade.lua	Thu Jun 12 21:25:39 2014 +0200
@@ -141,7 +141,7 @@
 			-- Remove the team to end the game. Only do this once.
 			if team_death == false then
 				team_death = true
-				ParseCommand("teamgone " .. "Grenadiers")
+				DismissTeam("Grenadiers")
 			end
 		else
 			-- ... or just lower the timer by 1.
--- a/share/hedgewars/Data/Missions/Training/Basic_Training_-_Rope.lua	Thu Jun 12 20:47:11 2014 +0200
+++ b/share/hedgewars/Data/Missions/Training/Basic_Training_-_Rope.lua	Thu Jun 12 21:25:39 2014 +0200
@@ -125,7 +125,7 @@
 end
 
 function onNewTurn()
-	ParseCommand( "setweap " .. string.char( amRope ) ) -- Set the default weapon to Rope
+	SetWeapon(amRope) -- Set the default weapon to Rope
 end
 
 function onGameTick20()
@@ -143,7 +143,7 @@
 	-- in either case, end the game
 	if (Objective == true) or (GameLost == true) then
 		if (WaitTime == 0) then
-			ParseCommand("teamgone " .. loc( "Rope Team" ))
+			DismissTeam(loc( "Rope Team" ))
 
 			--SetHealth( Player, 0 ) -- Kill the player so he can't keep moving!
 			--SetEffect( Player, heResurrectable, 0 )
--- a/share/hedgewars/Data/Missions/Training/User_Mission_-_Dangerous_Ducklings.lua	Thu Jun 12 20:47:11 2014 +0200
+++ b/share/hedgewars/Data/Missions/Training/User_Mission_-_Dangerous_Ducklings.lua	Thu Jun 12 21:25:39 2014 +0200
@@ -113,7 +113,7 @@
 			if endTimer >= 3000 then
 				--SetHealth(instructor,0)
 				TurnTimeLeft = 1
-				ParseCommand("teamgone " .. loc("Bloody Rookies"))
+				DismissTeam(loc("Bloody Rookies"))
 			end
 			ShowMission(loc("MISSION FAILED"), loc(":("), loc("You've failed. Try again."), -amRope, 5000);
 		end
@@ -136,7 +136,7 @@
 			HogSay(player, loc("See ya!"), SAY_THINK)
 			TurnTimeLeft = 3000
 			AddCaption(loc("Achievement Unlocked") .. ": " .. loc("Naughty Ninja"),0xffba00ff,capgrpMessage2)
-			ParseCommand("teamgone " .. loc("Blue Team"))
+			DismissTeam(loc("Blue Team"))
 			gameWon = true
 		elseif gear == enemy then
 			HogSay(player, loc("Enjoy the swim..."), SAY_THINK)
--- a/share/hedgewars/Data/Missions/Training/User_Mission_-_RCPlane_Challenge.lua	Thu Jun 12 20:47:11 2014 +0200
+++ b/share/hedgewars/Data/Missions/Training/User_Mission_-_RCPlane_Challenge.lua	Thu Jun 12 21:25:39 2014 +0200
@@ -326,7 +326,8 @@
                                 )
 
 
-			ParseCommand("teamgone Wannabe Flyboys")
+
+			DismissTeam(loc("Wannabe Flyboys"))
 		end
 
 		if RCGear ~= nil then
--- a/share/hedgewars/Data/Missions/Training/User_Mission_-_Rope_Knock_Challenge.lua	Thu Jun 12 20:47:11 2014 +0200
+++ b/share/hedgewars/Data/Missions/Training/User_Mission_-_Rope_Knock_Challenge.lua	Thu Jun 12 21:25:39 2014 +0200
@@ -57,9 +57,9 @@
 				}
 
 function GenericEnd()
-	ParseCommand("teamgone " .. loc("Wannabe Shoppsta"))
-	ParseCommand("teamgone " .. loc("Unsuspecting Louts"))
-	ParseCommand("teamgone " .. loc("Unlucky Sods"))
+	DismissTeam(loc("Wannabe Shoppsta"))
+	DismissTeam(loc("Unsuspecting Louts"))
+	DismissTeam(loc("Unlucky Sods"))
 end
 
 function GameOverMan()