share/hedgewars/Data/Missions/Training/Basic_Training_-_Flying_Saucer.lua
changeset 14453 09bfe9df51e9
parent 13763 29abd3d5f9bb
child 14464 ead8928a59f8
equal deleted inserted replaced
14452:df065d68e513 14453:09bfe9df51e9
    48 
    48 
    49 --[[
    49 --[[
    50 List of all targets (or "objectives"). The player has to complete them one-by-one and must always land safely afterwards.
    50 List of all targets (or "objectives"). The player has to complete them one-by-one and must always land safely afterwards.
    51 Some target numbers have names for easier reference.
    51 Some target numbers have names for easier reference.
    52 ]]
    52 ]]
       
    53 -- Intro
    53 TargetPos[1] =  {
    54 TargetPos[1] =  {
    54 	Targets = {{ X = 1027, Y = 217 }},
    55 	Targets = {{ X = 1027, Y = 217 }},
    55 	Ammo = { },
    56 	Ammo = { },
    56 	Message = loc("Here you will learn how to fly the flying saucer|and get so learn some cool tricks.") .. "|" ..
    57 	Message = loc("Here you will learn how to fly the flying saucer|and get so learn some cool tricks.") .. "|" ..
    57 	loc("Collect the first crate to begin!"),
    58 	loc("Collect the first crate to begin!"),
    58 	MessageIcon = -amJetpack, }
    59 	MessageIcon = -amJetpack, }
       
    60 
       
    61 -- First flight, infinite fuel
    59 TargetPos[2] = {
    62 TargetPos[2] = {
    60 	Targets = {{ X = 1369, Y = 265 }},
    63 	Targets = {{ X = 1369, Y = 265 }},
    61 	Ammo = { [amJetpack] = 100 },
    64 	Ammo = { [amJetpack] = 100 },
    62 	InfFuel = true,
    65 	InfFuel = true,
    63 	MessageTime = 10000,
    66 	MessageTime = 10000,
    64 	Message = loc("Get to the crate using your flying saucer!") .. "|" ..
    67 	Message = loc("Get to the crate using your flying saucer!") .. "|" ..
    65 	loc("Press [Attack] (space bar by default) to start,|repeatedly tap the up, left and right movement keys to accelerate.") .. "|" ..
    68 	loc("Press [Attack] (space bar by default) to start,|repeatedly tap the up, left and right movement keys to accelerate.") .. "|" ..
    66 	loc("Try to land softly, as you can still take fall damage!"), }
    69 	loc("Try to land softly, as you can still take fall damage!"), }
       
    70 
       
    71 -- First flight, limited fuel
    67 TargetPos[3] = {
    72 TargetPos[3] = {
    68 	Targets = {{ X = 689, Y = 58 }},
    73 	Targets = {{ X = 689, Y = 58 }},
    69 	Ammo = { [amJetpack] = 100 },
    74 	Ammo = { [amJetpack] = 100 },
    70 	MessageTime = 5000,
    75 	MessageTime = 5000,
    71 	Message = loc("Now collect the next crate!") .. "|" .. loc("Be careful, your fuel is limited from now on!") .."|" ..
    76 	Message = loc("Now collect the next crate!") .. "|" .. loc("Be careful, your fuel is limited from now on!") .."|" ..
    72 	loc("Tip: If you get stuck in this training, use \"Skip turn\" to restart the current objective.") }
    77 	loc("Tip: If you get stuck in this training, use \"Skip turn\" to restart the current objective.") }
    73 
    78 
    74 -- The Double Target
    79 -- The Double Target
    75 local DoubleTarget = 4
       
    76 TargetPos[4] = {
    80 TargetPos[4] = {
    77 	Targets = { { X = 84, Y = -20 }, { X = 1980 , Y = -20 } },
    81 	Targets = { { X = 178, Y = -20 }, { X = 1962 , Y = -20 } },
    78 	Ammo = { [amJetpack] = 2 },
    82 	Ammo = { [amJetpack] = 2 },
       
    83 	CratesContainAmmo = true,
    79 	MessageTime = 9000,
    84 	MessageTime = 9000,
    80 	Message = loc("Now collect the 2 crates to the far left and right.") .. "|" ..
    85 	Message = loc("Now collect the 2 crates to the far left and right.") .. "|" ..
    81 	loc("You only have 2 flying saucers this time.") .. "|" ..
    86 	loc("You only have 2 flying saucers this time.") .. "|" ..
    82 	loc("Tip: You can change your flying saucer|in mid-flight by hitting the [Attack] key twice."), }
    87 	loc("Tip: You can change your flying saucer|in mid-flight by hitting the [Attack] key twice."), }
       
    88 
       
    89 -- Intermission
    83 TargetPos[5] = {
    90 TargetPos[5] = {
    84 	Targets = {{ X = 47, Y = 804 }},
    91 	Targets = {{ X = 47, Y = 804 }},
    85 	Ammo = { [amJetpack] = 100 },
    92 	Ammo = { [amJetpack] = 100 },
    86 	MessageTime = 5000,
    93 	MessageTime = 5000,
    87 	Message = loc("Time for a more interesting stunt, but first just collect the next crate!"), }
    94 	Message = loc("Time for a more interesting stunt, but first just collect the next crate!"), }
       
    95 
       
    96 -- First Dive
    88 TargetPos[6] = {
    97 TargetPos[6] = {
    89 	Targets = {{ X = 604, Y = 871}},
    98 	Targets = {{ X = 604, Y = 871}},
    90 	MessageTime = 15000,
    99 	MessageTime = 15000,
    91 	Message = loc("You can dive with your flying saucer!") .. "|" ..
   100 	Message = loc("You can dive with your flying saucer!") .. "|" ..
    92 	loc("Try it now and dive here to collect the crate on the right girder.") .. "|" ..
   101 	loc("Try it now and dive here to collect the crate on the right girder.") .. "|" ..
    93 	loc("You only have one flying saucer this time.") .. "|" ..
   102 	loc("You only have one flying saucer this time.") .. "|" ..
    94 	loc("Beware, though, you will only be able to move slowly through the water.") .. "|" ..
   103 	loc("Beware, though, you will only be able to move slowly through the water.") .. "|" ..
    95 	loc("Warning: Never ever leave the flying saucer while in water!"),
   104 	loc("Warning: Never ever leave the flying saucer while in water!"),
    96 	Ammo = { [amJetpack] = 1 }, }
   105 	Ammo = { [amJetpack] = 1 },
    97 
   106 	Respawn = { X = 758, Y = 847, FaceLeft = false }, }
       
   107 
       
   108 -- Second Dive
    98 TargetPos[7] = { 
   109 TargetPos[7] = { 
    99 	Targets = {{ X = 1884, Y = 704 }},
   110 	Targets = {{ X = 1884, Y = 704 }},
   100 	MessageTime = 6500,
   111 	MessageTime = 6500,
   101 	Message = loc("Now dive just one more time and collect the next crate.") .. "|" ..
   112 	Message = loc("Now dive just one more time and collect the next crate.") .. "|" ..
   102 		loc("Tip: Don't remain for too long in the water, or you won't make it."),
   113 		loc("Tip: Don't remain for too long in the water, or you won't make it."),
   103 	Ammo = { [amJetpack] = 1}, }
   114 	Ammo = { [amJetpack] = 2 }, }
   104 
   115 
   105 -- The Boom Target
   116 -- The Grenade Drop Target
   106 local BoomTarget = 8
   117 local BoomTarget = 8
   107 TargetPos[8] = {
   118 TargetPos[8] = {
   108 	Modifier = true, Func = function()
   119 	Modifier = true, Func = function()
   109 		Info(loc("Instructions"),
   120 		Info(loc("Instructions"),
   110 		loc("Now let's try to drop weapons while flying!") .. "|" ..
   121 		loc("Now let's try to drop weapons while flying!") .. "|" ..
   126 		end
   137 		end
   127 		GrenadeThrown = false
   138 		GrenadeThrown = false
   128 
   139 
   129 	end,
   140 	end,
   130 	Ammo = { [amJetpack] = 100 },
   141 	Ammo = { [amJetpack] = 100 },
   131 	Respawn = { X = 2000, Y = 742 }, }
   142 	Respawn = { X = 2000, Y = 742, FaceLeft = true }, }
   132 
   143 
   133 -- The Launch Target
   144 -- The Launch Target
   134 local LaunchTarget = 9
   145 local LaunchTarget = 9
   135 TargetPos[9] = {
   146 TargetPos[9] = {
   136 	Targets = {{ X = 1700, Y = 640, Type = gtTarget }, { X = 1460, Y = 775, Type = gtTarget }},
   147 	Targets = {{ X = 1700, Y = 640, Type = gtTarget }, { X = 1460, Y = 775, Type = gtTarget }},
   141 		loc("So you are able to launch projectiles into your aiming direction, always at full power.") .."|"..
   152 		loc("So you are able to launch projectiles into your aiming direction, always at full power.") .."|"..
   142 		loc("To launch a projectile in mid-flight, hold [Precise] and press [Long jump].") .. "|" ..
   153 		loc("To launch a projectile in mid-flight, hold [Precise] and press [Long jump].") .. "|" ..
   143 		loc("You can even change your aiming direction in mid-flight if you first hold [Precise] and then press [Up] or [Down].") .. "|" ..
   154 		loc("You can even change your aiming direction in mid-flight if you first hold [Precise] and then press [Up] or [Down].") .. "|" ..
   144 		loc("Tip: Changing your aim while flying is very difficult, so adjust it before you take off."),
   155 		loc("Tip: Changing your aim while flying is very difficult, so adjust it before you take off."),
   145 	Ammo = { [amJetpack] = 1, },
   156 	Ammo = { [amJetpack] = 1, },
   146 	Respawn = { X = 1764, Y = 916 },
   157 	Respawn = { X = 1760, Y = 754, FaceLeft = true },
   147 	ExtraFunc = function()
   158 	ExtraFunc = function()
   148 		HogTurnLeft(Player, true)
       
   149 		if SaucerGear ~= nil then
   159 		if SaucerGear ~= nil then
   150 			AddAmmo(Player, amBazooka, 2)
   160 			AddAmmo(Player, amBazooka, 2)
   151 		else
   161 		else
   152 			AddAmmo(Player, amBazooka, 0)
   162 			AddAmmo(Player, amBazooka, 0)
   153 		end
   163 		end
   163 	loc("Basically this is a combination of diving and launching.") .. "|" ..
   173 	loc("Basically this is a combination of diving and launching.") .. "|" ..
   164 	loc("Dropping a weapon while in water would just drown it, but launching one would work.") .."|" ..
   174 	loc("Dropping a weapon while in water would just drown it, but launching one would work.") .."|" ..
   165 	loc("Based on what you've learned, destroy the target on the girder and as always, land safely!"), 
   175 	loc("Based on what you've learned, destroy the target on the girder and as always, land safely!"), 
   166 	Targets = {{ X = 1200, Y = 930, Type = gtTarget }},
   176 	Targets = {{ X = 1200, Y = 930, Type = gtTarget }},
   167 	Ammo = { [amJetpack] = 1, },
   177 	Ammo = { [amJetpack] = 1, },
   168 	Respawn = { X = 1027, Y = 217 },
   178 	Respawn = { X = 1027, Y = 217, FaceLeft = true },
   169 	ExtraFunc = function()
   179 	ExtraFunc = function()
   170 		if SaucerGear ~= nil then
   180 		if SaucerGear ~= nil then
   171 			AddAmmo(Player, amBazooka, 1)
   181 			AddAmmo(Player, amBazooka, 1)
   172 		else
   182 		else
   173 			AddAmmo(Player, amBazooka, 0)
   183 			AddAmmo(Player, amBazooka, 0)
   174 		end
   184 		end
   175 		BazookasLeft = 1
   185 		BazookasLeft = 1
   176 	end }
   186 	end }
       
   187 -- Final target / Sandbox
   177 TargetPos[11] = {
   188 TargetPos[11] = {
   178 	Targets = {{ X = 742, Y = 290 }},
   189 	Targets = {{ X = 742, Y = 290 }},
   179 	MessageTime = 5000,
   190 	MessageTime = 5000,
   180 	Message = loc("This almost concludes our tutorial.") .. "|" ..
   191 	Message = loc("This almost concludes our tutorial.") .. "|" ..
   181 	loc("You now have infinite fuel, grenades and bazookas for fun.") .. "|" ..
   192 	loc("You now have infinite fuel, grenades and bazookas for fun.") .. "|" ..
   182 	loc("Collect or destroy the final crate to finish the training."),
   193 	loc("Collect or destroy the final crate to finish the training."),
   183 	Ammo = { [amJetpack] = 100, [amGrenade] = 100, [amBazooka] = 100 },
   194 	Ammo = { [amJetpack] = 100, [amGrenade] = 100, [amBazooka] = 100 },
   184 	InfFuel = true, }
   195 	InfFuel = true, }
       
   196 -- Outro
   185 TargetPos[12] = { Modifier = true, Func = function()
   197 TargetPos[12] = { Modifier = true, Func = function()
   186 	Objective = true
   198 	Objective = true
   187 	AddCaption(loc("Training complete!"), capcolDefault, capgrpGameState)
   199 	AddCaption(loc("Training complete!"), capcolDefault, capgrpGameState)
   188 	Info(loc("Training complete!"), loc("Good bye!"), 4, 5000)
   200 	Info(loc("Training complete!"), loc("Good bye!"), 4, 5000)
   189 
   201 
   232 -- Generic target spawning for the current target
   244 -- Generic target spawning for the current target
   233 function SpawnTargets()
   245 function SpawnTargets()
   234 	for i=1,#TargetPos[TargetNumber].Targets do
   246 	for i=1,#TargetPos[TargetNumber].Targets do
   235 		if TargetGears[i] == nil then
   247 		if TargetGears[i] == nil then
   236 			SpawnTarget(TargetPos[TargetNumber].Targets[i].X, TargetPos[TargetNumber].Targets[i].Y,
   248 			SpawnTarget(TargetPos[TargetNumber].Targets[i].X, TargetPos[TargetNumber].Targets[i].Y,
   237 				TargetPos[TargetNumber].Targets[i].Type, i)
   249 				TargetPos[TargetNumber].Targets[i].Type, i, TargetPos[TargetNumber].CratesContainAmmo )
   238 		end
   250 		end
   239 	end
   251 	end
   240 end
   252 end
   241 
   253 
   242 function SpawnTarget( PosX, PosY, Type, ID )
   254 function SpawnTarget( PosX, PosY, Type, ID, ContainsAmmo )
   243 	if Type ~= nil and Type ~= gtCase then
   255 	if Type ~= nil and Type ~= gtCase then
   244 		if Type == gtTarget then
   256 		if Type == gtTarget then
   245 			TargetGears[ID] = AddGear(PosX, PosY, gtTarget, 0, 0, 0, 0)
   257 			TargetGears[ID] = AddGear(PosX, PosY, gtTarget, 0, 0, 0, 0)
   246 		end
   258 		end
   247 	else
   259 	else
   248 		TargetGears[ID] = SpawnFakeUtilityCrate(PosX, PosY, false, false)
   260 		if ContainsAmmo == true then
       
   261 			TargetGears[ID] = SpawnSupplyCrate(PosX, PosY, amJetpack)
       
   262 		else
       
   263 			TargetGears[ID] = SpawnFakeUtilityCrate(PosX, PosY, false, false)
       
   264 		end
   249 	end
   265 	end
   250 	TargetsRemaining = TargetsRemaining + 1
   266 	TargetsRemaining = TargetsRemaining + 1
   251 end
   267 end
   252 
   268 
   253 function AutoSpawn() -- Auto-spawn the next target after you've obtained the current target!
   269 function AutoSpawn() -- Auto-spawn the next target after you've obtained the current target!
   326 	end
   342 	end
   327 	Check = false
   343 	Check = false
   328 
   344 
   329 	CleanUpGears()
   345 	CleanUpGears()
   330 
   346 
   331 	local X, Y
   347 	local X, Y, FaceLeft
   332 	if TargetNumber == 1 then
   348 	if TargetNumber == 1 then
   333 		X, Y = StartPos.X, StartPos.Y
   349 		X, Y = StartPos.X, StartPos.Y
   334 	else
   350 	else
   335 		if TargetPos[TargetNumber-1].Modifier or TargetPos[TargetNumber-1].Respawn ~= nil then
   351 		if TargetPos[TargetNumber-1].Modifier or TargetPos[TargetNumber-1].Respawn ~= nil then
   336 			X, Y = TargetPos[TargetNumber-1].Respawn.X, TargetPos[TargetNumber-1].Respawn.Y
   352 			X, Y = TargetPos[TargetNumber-1].Respawn.X, TargetPos[TargetNumber-1].Respawn.Y
       
   353 			FaceLeft = TargetPos[TargetNumber-1].Respawn.FaceLeft
   337 		else
   354 		else
   338 			X, Y = TargetPos[TargetNumber-1].Targets[1].X, TargetPos[TargetNumber-1].Targets[1].Y
   355 			X, Y = TargetPos[TargetNumber-1].Targets[1].X, TargetPos[TargetNumber-1].Targets[1].Y
   339 		end
   356 		end
   340 	end
   357 	end
   341 	if TargetNumber == BoomTarget then
   358 	if TargetNumber == BoomTarget then
   358 		InfFuel = false
   375 		InfFuel = false
   359 	end
   376 	end
   360 	UpdateInfFuel()
   377 	UpdateInfFuel()
   361 
   378 
   362 	SetGearPosition(Player, X, Y)
   379 	SetGearPosition(Player, X, Y)
       
   380 	if FaceLeft ~= nil then
       
   381 		HogTurnLeft(Player, FaceLeft)
       
   382 	end
   363 end
   383 end
   364 
   384 
   365 function onGameInit()
   385 function onGameInit()
   366 	Seed = 1
   386 	Seed = 1
   367 	GameFlags = gfInfAttack + gfOneClanMode + gfSolidLand + gfDisableWind
   387 	GameFlags = gfInfAttack + gfOneClanMode + gfSolidLand + gfDisableWind
   390 
   410 
   391 	-- Girder near first crate
   411 	-- Girder near first crate
   392 	PlaceGirder(1257, 204, 6)
   412 	PlaceGirder(1257, 204, 6)
   393 
   413 
   394 	-- The upper girders
   414 	-- The upper girders
   395 	PlaceGirder(84, 16, 0)
   415 	PlaceGirder(84, 16, 4)
   396 	PlaceGirder(1980, 16, 0)
   416 	PlaceGirder(243, 16, 4)
       
   417 	PlaceGirder(1967, 16, 4)
   397 
   418 
   398 	-- The lower girder platform at the water pit
   419 	-- The lower girder platform at the water pit
   399 	PlaceGirder(509, 896, 4)
   420 	PlaceGirder(509, 896, 4)
   400 	PlaceGirder(668, 896, 4)
   421 	PlaceGirder(668, 896, 4)
   401 	PlaceGirder(421, 896, 2)
   422 	PlaceGirder(421, 896, 2)
   413 	-- Spawn our 1st target using the wrapper function
   434 	-- Spawn our 1st target using the wrapper function
   414 	AutoSpawn()
   435 	AutoSpawn()
   415 end
   436 end
   416 
   437 
   417 function onAmmoStoreInit()
   438 function onAmmoStoreInit()
   418 	SetAmmo(amJetpack, 0, 0, 0, 0)
   439 	SetAmmo(amJetpack, 0, 0, 0, 1)
   419 	SetAmmo(amGrenade, 0, 0, 0, 0)
   440 	SetAmmo(amGrenade, 0, 0, 0, 1)
   420 	SetAmmo(amBazooka, 0, 0, 0, 0)
   441 	SetAmmo(amBazooka, 0, 0, 0, 1)
   421 
   442 
   422 	-- Added for resetting current target/objective when player is stuck somehow
   443 	-- Added for resetting current target/objective when player is stuck somehow
   423 	SetAmmo(amSkip, 9, 0, 0, 0)
   444 	SetAmmo(amSkip, 9, 0, 0, 0)
   424 end
   445 end
   425 
   446 
   480 		end
   501 		end
   481 		if TargetNumber == LaunchTarget or TargetNumber == UnderwaterAttackTarget then
   502 		if TargetNumber == LaunchTarget or TargetNumber == UnderwaterAttackTarget then
   482 			AddAmmo(Player, amBazooka, 0)
   503 			AddAmmo(Player, amBazooka, 0)
   483 		end
   504 		end
   484 	end
   505 	end
   485 	if GetGearType(Gear) == gtCase and GetGearType(Player) ~= nil then
   506 	-- Fake crate collected
       
   507 	if GetGearType(Gear) == gtCase and band(GetGearMessage(Gear), gmDestroy) ~= 0 and band(GetGearPos(Gear), 0x8) ~= 0 then
   486 		PlaySound(sndShotgunReload)
   508 		PlaySound(sndShotgunReload)
   487 	end
   509 	end
   488 	if Gear == Barrels[1] then
   510 	if Gear == Barrels[1] then
   489 		Barrels[1] = nil
   511 		Barrels[1] = nil
   490 	end
   512 	end