share/hedgewars/Data/Missions/Campaign/A_Space_Adventure/ice02.lua
branchspacecampaign
changeset 9457 934f4d8370f1
parent 9455 4bf3fac0e49d
child 9459 8c653c0dd332
equal deleted inserted replaced
9455:4bf3fac0e49d 9457:934f4d8370f1
     1 ------------------- ABOUT ----------------------
     1 ------------------- ABOUT ----------------------
     2 --
     2 --
     3 -- Hero has to pass as fast as possible inside the
     3 -- Hero has to pass as fast as possible inside the
     4 -- rings as in the runner mode
     4 -- rings as in the racer mode
     5 
     5 
     6 HedgewarsScriptLoad("/Scripts/Locale.lua")
     6 HedgewarsScriptLoad("/Scripts/Locale.lua")
     7 HedgewarsScriptLoad("/Scripts/Animate.lua")
     7 HedgewarsScriptLoad("/Scripts/Animate.lua")
     8 
     8 
     9 ----------------- VARIABLES --------------------
     9 ----------------- VARIABLES --------------------
    10 -- globals
    10 -- globals
    11 local campaignName = loc("A Space Adventure")
    11 local campaignName = loc("A Space Adventure")
    12 local missionName = loc("Ice planet, a frozen adventure!")
    12 local missionName = loc("Ice planet, a frozen adventure!")
    13 local heroAtAntiFlyArea = false
    13 local currentWaypoint = 1
    14 local heroVisitedAntiFlyArea = false
    14 local radius = 75
    15 local heroAtFinalStep = false
       
    16 local iceGunTaken = false
       
    17 local checkPointReached = 1 -- 1 is normal spawn
       
    18 -- dialogs
    15 -- dialogs
    19 local dialog01 = {}
    16 local dialog01 = {}
    20 local dialog02 = {}
       
    21 -- mission objectives
    17 -- mission objectives
    22 local goals = {
    18 local goals = {
    23 	[dialog01] = {missionName, loc("Getting ready"), loc("Collect the icegun and get the device part from Thanta"), 1, 4500},
    19 	[dialog01] = {missionName, loc("Getting ready"), loc("Collect the icegun and get the device part from Thanta"), 1, 4500},
    24 }
    20 }
    25 -- crates
       
    26 local icegunY = 1950
       
    27 local icegunX = 260
       
    28 -- hogs
    21 -- hogs
    29 local hero = {}
    22 local hero = {}
    30 local ally = {}
    23 local ally = {}
    31 -- teams
    24 -- teams
    32 local teamA = {}
    25 local teamA = {}
    33 local teamB = {}
    26 local teamB = {}
    34 local teamC = {}
       
    35 -- hedgehogs values
    27 -- hedgehogs values
    36 hero.name = "Hog Solo"
    28 hero.name = "Hog Solo"
    37 hero.x = 450
    29 hero.x = 750
    38 hero.y = 200
    30 hero.y = 130
    39 hero.dead = false
    31 hero.dead = false
    40 ally.name = "Paul McHoggy"
    32 ally.name = "Paul McHoggy"
    41 ally.x = 512
    33 ally.x = 860
    42 ally.y = 200
    34 ally.y = 130
    43 teamA.name = loc("Hog Solo")
    35 teamA.name = loc("Hog Solo")
    44 teamA.color = tonumber("38D61C",16) -- green
    36 teamA.color = tonumber("38D61C",16) -- green
    45 teamB.name = loc("Allies")
    37 teamB.name = loc("Allies")
    46 teamB.color = tonumber("FF0000",16) -- red
    38 teamB.color = tonumber("FF0000",16) -- red
       
    39 -- way points
       
    40 local current waypoint = 1
       
    41 local waypoints = { 
       
    42 	[1] = {x=1450, y=140},
       
    43 	[2] = {x=990, y=580},
       
    44 	[3] = {x=1650, y=950},
       
    45 	[4] = {x=620, y=630},
       
    46 	[5] = {x=1470, y=540},
       
    47 	[6] = {x=1960, y=60},
       
    48 	[7] = {x=1600, y=400},
       
    49 	[8] = {x=240, y=940},
       
    50 	[9] = {x=200, y=530},
       
    51 	[10] = {x=1180, y=120},
       
    52 	[11] = {x=1950, y=660},
       
    53 	[12] = {x=1280, y=980},
       
    54 	[13] = {x=590, y=1100},
       
    55 	[14] = {x=20, y=620},
       
    56 	[15] = {x=hero.x, y=hero.y}
       
    57 }
    47 
    58 
    48 -------------- LuaAPI EVENT HANDLERS ------------------
    59 -------------- LuaAPI EVENT HANDLERS ------------------
    49 
    60 
    50 function onGameInit()
    61 function onGameInit()
    51 	Seed = 1
    62 	Seed = 1
    52 	TurnTime = 25000
    63 	TurnTime = 15000
    53 	CaseFreq = 0
    64 	CaseFreq = 0
    54 	MinesNum = 0
    65 	MinesNum = 0
    55 	MinesTime = 1
    66 	MinesTime = 1
    56 	Explosives = 0
    67 	Explosives = 0
    57 	Delay = 3
       
    58 	Map = "ice02_map"
    68 	Map = "ice02_map"
    59 	Theme = "Snow"
    69 	Theme = "Snow"
    60 	
    70 	
    61 	-- Hog Solo
    71 	-- Hog Solo
    62 	AddTeam(teamA.name, teamA.color, "Bone", "Island", "HillBilly", "cm_birdy")
    72 	AddTeam(teamA.name, teamA.color, "Bone", "Island", "HillBilly", "cm_birdy")
    63 	hero.gear = AddHog(hero.name, 0, 100, "war_desertgrenadier1")
    73 	hero.gear = AddHog(hero.name, 0, 100, "war_desertgrenadier1")
    64 	AnimSetGearPosition(hero.gear, hero.x, hero.y)
    74 	AnimSetGearPosition(hero.gear, hero.x, hero.y)
    65 	HogTurnLeft(hero.gear, true)
       
    66 	-- Ally
    75 	-- Ally
    67 	AddTeam(teamB.name, teamB.color, "Bone", "Island", "HillBilly", "cm_birdy")
    76 	AddTeam(teamB.name, teamB.color, "Bone", "Island", "HillBilly", "cm_birdy")
    68 	ally.gear = AddHog(ally.name, 0, 100, "tophats")
    77 	ally.gear = AddHog(ally.name, 0, 100, "tophats")
    69 	AnimSetGearPosition(ally.gear, ally.x, ally.y)
    78 	AnimSetGearPosition(ally.gear, ally.x, ally.y)
       
    79 	HogTurnLeft(ally.gear, true)
    70 	
    80 	
    71 	AnimInit()
    81 	AnimInit()
    72 	--AnimationSetup()	
    82 	--AnimationSetup()	
    73 end
    83 end
    74 
    84 local wp = 0
    75 function onGameStart()
    85 function onGameStart()
    76 	AnimWait(hero.gear, 3000)
    86 	AnimWait(hero.gear, 3000)
    77 	FollowGear(hero.gear)
    87 	FollowGear(hero.gear)
    78 	
    88 	
    79 	AddAmmo(hero.gear, amJetpack, 99)
    89 	AddAmmo(hero.gear, amJetpack, 3)
       
    90 	
       
    91 	-- place a waypoint
       
    92 	placeNextWaypoint()
    80 	
    93 	
    81 	SendHealthStatsOff()
    94 	SendHealthStatsOff()
    82 end
    95 end
       
    96 
       
    97 function onGameTick20()
       
    98 	if checkIfHeroInWaypoint() then
       
    99 		if not placeNextWaypoint() then
       
   100 			-- GAME OVER, WIN!
       
   101 			EndGame()
       
   102 		end
       
   103 	end
       
   104 end
       
   105 
       
   106 function onGearDelete(gear)
       
   107 	if gear == hero.gear then
       
   108 		hero.dead = true
       
   109 	end
       
   110 end
       
   111 
       
   112 ------------------ Other Functions -------------------
       
   113 
       
   114 function placeNextWaypoint()
       
   115 	WriteLnToConsole("IN PLACE NEXT POINT")
       
   116 	if currentWaypoint > 1 then
       
   117 		local wp = waypoints[currentWaypoint-1]
       
   118 		DeleteVisualGear(wp.gear)
       
   119 	end
       
   120 	if currentWaypoint < 16 then
       
   121 		local wp = waypoints[currentWaypoint]
       
   122 		wp.gear = AddVisualGear(1,1,vgtCircle,1,true)
       
   123 		SetVisualGearValues(wp.gear, wp.x,wp.y, 20, 200, 0, 0, 100, radius, 3, 0xff0000ff)
       
   124 		-- add bonus time and "fuel"		
       
   125 		WriteLnToConsole("Before "..TurnTimeLeft)
       
   126 		if currentWaypoint % 2 == 0 then
       
   127 			AddAmmo(hero.gear, amJetpack, GetAmmoCount(hero.gear, amJetpack)+1)
       
   128 			TurnTimeLeft = TurnTimeLeft + 10000		
       
   129 		else
       
   130 			TurnTimeLeft = TurnTimeLeft + 8000
       
   131 		end		
       
   132 		WriteLnToConsole("After "..TurnTimeLeft)
       
   133 		radius = radius - 4
       
   134 		currentWaypoint = currentWaypoint + 1
       
   135 		return true
       
   136 	end
       
   137 	return false
       
   138 end
       
   139 
       
   140 function checkIfHeroInWaypoint()
       
   141 	if not hero.dead then
       
   142 		local wp = waypoints[currentWaypoint-1]
       
   143 		local distance = math.sqrt((GetX(hero.gear)-wp.x)^2 + (GetY(hero.gear)-wp.y)^2)
       
   144 		if distance <= radius+4 then
       
   145 			SetWind(math.random(-100,100))
       
   146 			return true
       
   147 		end
       
   148 	end
       
   149 	return false
       
   150 end