share/hedgewars/Data/Missions/Training/User_Mission_-_Dangerous_Ducklings.lua
changeset 11968 1de4d6b35748
parent 11967 7dd85fe00de3
child 11969 7718ebf8cf14
equal deleted inserted replaced
11967:7dd85fe00de3 11968:1de4d6b35748
     1 
       
     2 HedgewarsScriptLoad("/Scripts/Locale.lua")
       
     3 
       
     4 local player = nil -- This variable will point to the hog's gear
       
     5 local instructor = nil
       
     6 local enemy = nil
       
     7 
       
     8 local speechStage = 0
       
     9 
       
    10 local gameLost = false
       
    11 local gameWon = false
       
    12 local notListening = false
       
    13 
       
    14 local endTimer = 0
       
    15 
       
    16 function onGameInit()
       
    17 
       
    18 	-- Things we don't modify here will use their default values.
       
    19 
       
    20 	Seed = 0 -- The base number for the random number generator
       
    21 	GameFlags = gfInfAttack -- Game settings and rules
       
    22 	TurnTime = 60000 -- The time the player has to move each round (in ms)
       
    23 	CaseFreq = 0 -- The frequency of crate drops
       
    24 	MinesNum = 0 -- The number of mines being placed
       
    25 	Explosives = 0 -- The number of explosives being placed
       
    26 	Delay = 0 -- The delay between each round
       
    27 	Map = "Bath" -- The map to be played
       
    28 	Theme = "Bath" -- The theme to be used
       
    29 	SuddenDeathTurns = 99999
       
    30 
       
    31 
       
    32 	AddTeam(loc("Bloody Rookies"), 14483456, "Simple", "Island", "Default")
       
    33 	player = AddHog(loc("Hunter"), 0, 1, "NoHat")
       
    34 	instructor = AddHog(loc("Instructor"), 0, 100, "sf_vega")
       
    35 
       
    36 	AddTeam(loc("Blue Team"), 29439, "Simple", "Island", "Default")
       
    37 	enemy = AddHog(loc("Filthy Blue"), 1, 100, "Skull")
       
    38 
       
    39 	SetGearPosition(player,146,902)
       
    40 	SetGearPosition(instructor,317,902)
       
    41 	SetGearPosition(enemy,1918,837)
       
    42 
       
    43 	HogSay(player, ".............................", SAY_THINK)
       
    44 	HogTurnLeft(instructor, true)
       
    45 
       
    46 end
       
    47 
       
    48 
       
    49 function onGameStart()
       
    50 
       
    51 	SpawnAmmoCrate(475,476,amRope)
       
    52 	SpawnAmmoCrate(1729,476,amFirePunch)
       
    53 
       
    54 	FollowGear(player)
       
    55 
       
    56 	ShowMission(loc("Dangerous Ducklings"), "", loc("Eliminate the Blue Team"), -amRope, 5000);
       
    57 
       
    58 end
       
    59 
       
    60 
       
    61 function onGameTick()
       
    62 
       
    63 
       
    64 	-- opening speech
       
    65 	if (notListening == false) and (gameLost == false) then
       
    66 
       
    67 		if (TurnTimeLeft == 58000) and (speechStage == 0)  then
       
    68 			HogSay(instructor, loc("Listen up, maggot!!"), SAY_SHOUT)
       
    69 			speechStage = 1
       
    70 		elseif (TurnTimeLeft == 57000) and (speechStage == 1) then
       
    71 			HogSay(player,loc("!!!"),SAY_SHOUT)
       
    72 		elseif (TurnTimeLeft == 55000) and (speechStage == 1) then
       
    73 			HogSay(instructor, loc("The enemy is hiding out on yonder ducky!"), SAY_SAY)
       
    74 			speechStage = 2
       
    75 
       
    76 		elseif (TurnTimeLeft == 49000) and (speechStage == 2) then
       
    77 			FollowGear(enemy)
       
    78 		elseif (TurnTimeLeft == 46500) and (speechStage == 2) then
       
    79 			FollowGear(instructor)
       
    80 			HogSay(instructor, loc("Get on over there and take him out!"), SAY_SAY)
       
    81 			speechStage = 3
       
    82 		elseif (TurnTimeLeft == 43500) and (speechStage == 3) then
       
    83 			HogSay(instructor, loc("GO! GO! GO!"), SAY_SHOUT)
       
    84 			speechStage = 4
       
    85 			givenSpeech = true
       
    86 		end
       
    87 
       
    88 	end
       
    89 
       
    90 	-- if player falls in water or if player ignores speech
       
    91 	if (CurrentHedgehog ~= nil) and (CurrentHedgehog == player) then
       
    92 		if (GetY(player) > WaterLine) and (gameLost == false) then
       
    93 			HogSay(instructor, loc("DAMMIT, ROOKIE!"), SAY_SHOUT)
       
    94 			gameLost = true
       
    95 		end
       
    96 
       
    97 		if (GetX(player) > 300) and (GetY(player) > 880) and (notListening == false) and (speechStage < 3) then
       
    98 			HogSay(instructor, loc("DAMMIT, ROOKIE! GET OFF MY HEAD!"), SAY_SHOUT)
       
    99 			notListening = true
       
   100 		end
       
   101 
       
   102 	end
       
   103 
       
   104 	--player out of time
       
   105 	if (TurnTimeLeft == 1) and (gameWon == false) then
       
   106 		SetHealth(player, 0)
       
   107 	end
       
   108 
       
   109 	-- meh
       
   110 	if gameLost == true then
       
   111 		endTimer = endTimer + 1
       
   112 		if (CurrentHedgehog ~= nil) and (CurrentHedgehog == instructor) then
       
   113 			if endTimer >= 3000 then
       
   114 				--SetHealth(instructor,0)
       
   115 				TurnTimeLeft = 1
       
   116 				DismissTeam(loc("Bloody Rookies"))
       
   117 			end
       
   118 			ShowMission(loc("MISSION FAILED"), loc(":("), loc("You've failed. Try again."), -amRope, 5000);
       
   119 		end
       
   120 	end
       
   121 
       
   122 end
       
   123 
       
   124 
       
   125 function onAmmoStoreInit()
       
   126 	SetAmmo(amFirePunch, 0, 0, 0, 1)
       
   127 	SetAmmo(amParachute, 1, 0, 0, 0)
       
   128 	SetAmmo(amRope, 0, 0, 0, 1)
       
   129 end
       
   130 
       
   131 function onGearDelete(gear)
       
   132 	if GetGearType(gear) == gtHedgehog then
       
   133 		if gear == player then
       
   134 			gameLost = true
       
   135 		elseif (gear == instructor) and (GetY(gear) > WaterLine) then
       
   136 			HogSay(player, loc("See ya!"), SAY_THINK)
       
   137 			TurnTimeLeft = 3000
       
   138 			AddCaption(loc("Achievement Unlocked") .. ": " .. loc("Naughty Ninja"),0xffba00ff,capgrpMessage2)
       
   139 			DismissTeam(loc("Blue Team"))
       
   140 			gameWon = true
       
   141 		elseif gear == enemy then
       
   142 			HogSay(player, loc("Enjoy the swim..."), SAY_THINK)
       
   143 			gameWon = true
       
   144 			TurnTimeLeft = 3000
       
   145 		end
       
   146 
       
   147 	end
       
   148 end