share/hedgewars/Data/Missions/Scenario/User_Mission_-_Diver.lua
author Wuzzy <Wuzzy2@mail.ru>
Mon, 20 May 2019 16:18:35 +0200
changeset 15015 a1165392c9db
parent 14932 ff4003a90ff8
child 15091 5c8c729a16ce
permissions -rw-r--r--
Scenarios: Drawn games count as mission failure
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
4662
63aafc9c2a81 Add a bunch of lua from mikade, update translation files
mikade+nemo
parents:
diff changeset
     1
8043
da083f8d95e6 We need custom script loading function in lua now
unc0rr
parents: 7877
diff changeset
     2
HedgewarsScriptLoad("/Scripts/Locale.lua")
4662
63aafc9c2a81 Add a bunch of lua from mikade, update translation files
mikade+nemo
parents:
diff changeset
     3
63aafc9c2a81 Add a bunch of lua from mikade, update translation files
mikade+nemo
parents:
diff changeset
     4
local player = nil -- This variable will point to the hog's gear
63aafc9c2a81 Add a bunch of lua from mikade, update translation files
mikade+nemo
parents:
diff changeset
     5
local enemy = nil
63aafc9c2a81 Add a bunch of lua from mikade, update translation files
mikade+nemo
parents:
diff changeset
     6
63aafc9c2a81 Add a bunch of lua from mikade, update translation files
mikade+nemo
parents:
diff changeset
     7
local GameOver = false
63aafc9c2a81 Add a bunch of lua from mikade, update translation files
mikade+nemo
parents:
diff changeset
     8
12390
c051ac2544f2 Add note in Diver scenario that jetpack only has 50% fuel
Wuzzy <almikes@aol.com>
parents: 12354
diff changeset
     9
local jetpackFuel = 1000
c051ac2544f2 Add note in Diver scenario that jetpack only has 50% fuel
Wuzzy <almikes@aol.com>
parents: 12354
diff changeset
    10
4662
63aafc9c2a81 Add a bunch of lua from mikade, update translation files
mikade+nemo
parents:
diff changeset
    11
function onGameInit()
63aafc9c2a81 Add a bunch of lua from mikade, update translation files
mikade+nemo
parents:
diff changeset
    12
63aafc9c2a81 Add a bunch of lua from mikade, update translation files
mikade+nemo
parents:
diff changeset
    13
	-- Things we don't modify here will use their default values.
63aafc9c2a81 Add a bunch of lua from mikade, update translation files
mikade+nemo
parents:
diff changeset
    14
63aafc9c2a81 Add a bunch of lua from mikade, update translation files
mikade+nemo
parents:
diff changeset
    15
	Seed = 0 -- The base number for the random number generator
63aafc9c2a81 Add a bunch of lua from mikade, update translation files
mikade+nemo
parents:
diff changeset
    16
	GameFlags = gfInfAttack + gfDisableWind-- Game settings and rules
63aafc9c2a81 Add a bunch of lua from mikade, update translation files
mikade+nemo
parents:
diff changeset
    17
	TurnTime = 90000 -- The time the player has to move each round (in ms)
63aafc9c2a81 Add a bunch of lua from mikade, update translation files
mikade+nemo
parents:
diff changeset
    18
	CaseFreq = 0 -- The frequency of crate drops
63aafc9c2a81 Add a bunch of lua from mikade, update translation files
mikade+nemo
parents:
diff changeset
    19
	MinesNum = 0 -- The number of mines being placed
63aafc9c2a81 Add a bunch of lua from mikade, update translation files
mikade+nemo
parents:
diff changeset
    20
	MinesTime  = 1000
63aafc9c2a81 Add a bunch of lua from mikade, update translation files
mikade+nemo
parents:
diff changeset
    21
	Explosives = 0 -- The number of explosives being placed
63aafc9c2a81 Add a bunch of lua from mikade, update translation files
mikade+nemo
parents:
diff changeset
    22
	Map = "Hydrant" -- The map to be played
63aafc9c2a81 Add a bunch of lua from mikade, update translation files
mikade+nemo
parents:
diff changeset
    23
	Theme = "City" -- The theme to be used
12224
d62d6f8ebef1 Disable Sudden Death consistently in all missions which don't require it
Wuzzy <almikes@aol.com>
parents: 12078
diff changeset
    24
d62d6f8ebef1 Disable Sudden Death consistently in all missions which don't require it
Wuzzy <almikes@aol.com>
parents: 12078
diff changeset
    25
	-- Disable Sudden Death
d62d6f8ebef1 Disable Sudden Death consistently in all missions which don't require it
Wuzzy <almikes@aol.com>
parents: 12078
diff changeset
    26
	HealthDecrease = 0
d62d6f8ebef1 Disable Sudden Death consistently in all missions which don't require it
Wuzzy <almikes@aol.com>
parents: 12078
diff changeset
    27
	WaterRise = 0
4662
63aafc9c2a81 Add a bunch of lua from mikade, update translation files
mikade+nemo
parents:
diff changeset
    28
14482
d4aa64f51c9f Use player-chosen team identity for most challenges and scenarios
Wuzzy <Wuzzy2@mail.ru>
parents: 14464
diff changeset
    29
	AddMissionTeam(-1)
d4aa64f51c9f Use player-chosen team identity for most challenges and scenarios
Wuzzy <Wuzzy2@mail.ru>
parents: 14464
diff changeset
    30
	player = AddMissionHog(1)
4662
63aafc9c2a81 Add a bunch of lua from mikade, update translation files
mikade+nemo
parents:
diff changeset
    31
			
14932
ff4003a90ff8 Enable automatic voicepack language selection for all missions
Wuzzy <Wuzzy2@mail.ru>
parents: 14482
diff changeset
    32
	AddTeam(loc("Toxic Team"), -6, "skull", "Island", "Default_qau", "cm_magicskull")
4662
63aafc9c2a81 Add a bunch of lua from mikade, update translation files
mikade+nemo
parents:
diff changeset
    33
	enemy = AddHog(loc("Poison"), 1, 100, "Skull")
63aafc9c2a81 Add a bunch of lua from mikade, update translation files
mikade+nemo
parents:
diff changeset
    34
7877
b3fb94986255 Fix training script positions altered by variable land dimension change. Issue #453
nemo
parents: 5823
diff changeset
    35
	SetGearPosition(player,430,516)
b3fb94986255 Fix training script positions altered by variable land dimension change. Issue #453
nemo
parents: 5823
diff changeset
    36
	SetGearPosition(enemy,1464,936)
4662
63aafc9c2a81 Add a bunch of lua from mikade, update translation files
mikade+nemo
parents:
diff changeset
    37
63aafc9c2a81 Add a bunch of lua from mikade, update translation files
mikade+nemo
parents:
diff changeset
    38
end
63aafc9c2a81 Add a bunch of lua from mikade, update translation files
mikade+nemo
parents:
diff changeset
    39
63aafc9c2a81 Add a bunch of lua from mikade, update translation files
mikade+nemo
parents:
diff changeset
    40
63aafc9c2a81 Add a bunch of lua from mikade, update translation files
mikade+nemo
parents:
diff changeset
    41
function onGameStart()
63aafc9c2a81 Add a bunch of lua from mikade, update translation files
mikade+nemo
parents:
diff changeset
    42
63aafc9c2a81 Add a bunch of lua from mikade, update translation files
mikade+nemo
parents:
diff changeset
    43
12933
e65aa3c3d4e6 Refactor scripts to use SpawnSupplyCrate (where it makes sense)
Wuzzy <Wuzzy2@mail.ru>
parents: 12586
diff changeset
    44
	SpawnSupplyCrate(426,886,amJetpack)
e65aa3c3d4e6 Refactor scripts to use SpawnSupplyCrate (where it makes sense)
Wuzzy <Wuzzy2@mail.ru>
parents: 12586
diff changeset
    45
	SpawnSupplyCrate(1544,690,amFirePunch)
e65aa3c3d4e6 Refactor scripts to use SpawnSupplyCrate (where it makes sense)
Wuzzy <Wuzzy2@mail.ru>
parents: 12586
diff changeset
    46
	SpawnSupplyCrate(950,851,amBlowTorch)
e65aa3c3d4e6 Refactor scripts to use SpawnSupplyCrate (where it makes sense)
Wuzzy <Wuzzy2@mail.ru>
parents: 12586
diff changeset
    47
	SpawnSupplyCrate(1032,853,amParachute)
4662
63aafc9c2a81 Add a bunch of lua from mikade, update translation files
mikade+nemo
parents:
diff changeset
    48
7877
b3fb94986255 Fix training script positions altered by variable land dimension change. Issue #453
nemo
parents: 5823
diff changeset
    49
	AddGear(579, 296, gtMine, 0, 0, 0, 0)
4662
63aafc9c2a81 Add a bunch of lua from mikade, update translation files
mikade+nemo
parents:
diff changeset
    50
12354
5e4ac10a03ce Mention inf attack rule in Diver, also fix the in-game mission name
Wuzzy <almikes@aol.com>
parents: 12226
diff changeset
    51
	ShowMission(loc("Diver"), loc("Scenario"),
5e4ac10a03ce Mention inf attack rule in Diver, also fix the in-game mission name
Wuzzy <almikes@aol.com>
parents: 12226
diff changeset
    52
		loc("Eliminate the enemy before the time runs out.") .. "|" .. 
5e4ac10a03ce Mention inf attack rule in Diver, also fix the in-game mission name
Wuzzy <almikes@aol.com>
parents: 12226
diff changeset
    53
		loc("Unlimited Attacks: Attacks don't end your turn") .. "|" ..
5e4ac10a03ce Mention inf attack rule in Diver, also fix the in-game mission name
Wuzzy <almikes@aol.com>
parents: 12226
diff changeset
    54
		loc("Mines time: 1 second"), -amFirePunch, 0);
4662
63aafc9c2a81 Add a bunch of lua from mikade, update translation files
mikade+nemo
parents:
diff changeset
    55
	--SetTag(AddGear(0, 0, gtATSmoothWindCh, 0, 0, 0, 1), -70)
63aafc9c2a81 Add a bunch of lua from mikade, update translation files
mikade+nemo
parents:
diff changeset
    56
12390
c051ac2544f2 Add note in Diver scenario that jetpack only has 50% fuel
Wuzzy <almikes@aol.com>
parents: 12354
diff changeset
    57
	SetAmmoDescriptionAppendix(amJetpack, string.format(loc("In this mission you get %d%% fuel."), div(jetpackFuel, 20)))
c051ac2544f2 Add note in Diver scenario that jetpack only has 50% fuel
Wuzzy <almikes@aol.com>
parents: 12354
diff changeset
    58
4662
63aafc9c2a81 Add a bunch of lua from mikade, update translation files
mikade+nemo
parents:
diff changeset
    59
	SetWind(-100)
63aafc9c2a81 Add a bunch of lua from mikade, update translation files
mikade+nemo
parents:
diff changeset
    60
63aafc9c2a81 Add a bunch of lua from mikade, update translation files
mikade+nemo
parents:
diff changeset
    61
end
63aafc9c2a81 Add a bunch of lua from mikade, update translation files
mikade+nemo
parents:
diff changeset
    62
63aafc9c2a81 Add a bunch of lua from mikade, update translation files
mikade+nemo
parents:
diff changeset
    63
63aafc9c2a81 Add a bunch of lua from mikade, update translation files
mikade+nemo
parents:
diff changeset
    64
function onGameTick()
63aafc9c2a81 Add a bunch of lua from mikade, update translation files
mikade+nemo
parents:
diff changeset
    65
63aafc9c2a81 Add a bunch of lua from mikade, update translation files
mikade+nemo
parents:
diff changeset
    66
63aafc9c2a81 Add a bunch of lua from mikade, update translation files
mikade+nemo
parents:
diff changeset
    67
	if (TotalRounds == 3) and (GameOver == false) then
63aafc9c2a81 Add a bunch of lua from mikade, update translation files
mikade+nemo
parents:
diff changeset
    68
		SetHealth(player, 0)
63aafc9c2a81 Add a bunch of lua from mikade, update translation files
mikade+nemo
parents:
diff changeset
    69
		GameOver = true
63aafc9c2a81 Add a bunch of lua from mikade, update translation files
mikade+nemo
parents:
diff changeset
    70
	end
63aafc9c2a81 Add a bunch of lua from mikade, update translation files
mikade+nemo
parents:
diff changeset
    71
63aafc9c2a81 Add a bunch of lua from mikade, update translation files
mikade+nemo
parents:
diff changeset
    72
	if TurnTimeLeft == 1 then
63aafc9c2a81 Add a bunch of lua from mikade, update translation files
mikade+nemo
parents:
diff changeset
    73
		SetHealth(player, 0)
63aafc9c2a81 Add a bunch of lua from mikade, update translation files
mikade+nemo
parents:
diff changeset
    74
		GameOver = true
63aafc9c2a81 Add a bunch of lua from mikade, update translation files
mikade+nemo
parents:
diff changeset
    75
	end
63aafc9c2a81 Add a bunch of lua from mikade, update translation files
mikade+nemo
parents:
diff changeset
    76
63aafc9c2a81 Add a bunch of lua from mikade, update translation files
mikade+nemo
parents:
diff changeset
    77
end
63aafc9c2a81 Add a bunch of lua from mikade, update translation files
mikade+nemo
parents:
diff changeset
    78
63aafc9c2a81 Add a bunch of lua from mikade, update translation files
mikade+nemo
parents:
diff changeset
    79
63aafc9c2a81 Add a bunch of lua from mikade, update translation files
mikade+nemo
parents:
diff changeset
    80
function onAmmoStoreInit()
63aafc9c2a81 Add a bunch of lua from mikade, update translation files
mikade+nemo
parents:
diff changeset
    81
	SetAmmo(amFirePunch, 1, 0, 0, 1)
63aafc9c2a81 Add a bunch of lua from mikade, update translation files
mikade+nemo
parents:
diff changeset
    82
	SetAmmo(amBlowTorch, 0, 0, 0, 1)
63aafc9c2a81 Add a bunch of lua from mikade, update translation files
mikade+nemo
parents:
diff changeset
    83
	SetAmmo(amGirder, 1, 0, 0, 0)
63aafc9c2a81 Add a bunch of lua from mikade, update translation files
mikade+nemo
parents:
diff changeset
    84
	SetAmmo(amParachute, 0, 0, 0, 1)
63aafc9c2a81 Add a bunch of lua from mikade, update translation files
mikade+nemo
parents:
diff changeset
    85
	SetAmmo(amJetpack, 0, 0, 0, 1)
63aafc9c2a81 Add a bunch of lua from mikade, update translation files
mikade+nemo
parents:
diff changeset
    86
end
63aafc9c2a81 Add a bunch of lua from mikade, update translation files
mikade+nemo
parents:
diff changeset
    87
63aafc9c2a81 Add a bunch of lua from mikade, update translation files
mikade+nemo
parents:
diff changeset
    88
63aafc9c2a81 Add a bunch of lua from mikade, update translation files
mikade+nemo
parents:
diff changeset
    89
function onGearAdd(gear)
63aafc9c2a81 Add a bunch of lua from mikade, update translation files
mikade+nemo
parents:
diff changeset
    90
63aafc9c2a81 Add a bunch of lua from mikade, update translation files
mikade+nemo
parents:
diff changeset
    91
	if GetGearType(gear) == gtJetpack then
12390
c051ac2544f2 Add note in Diver scenario that jetpack only has 50% fuel
Wuzzy <almikes@aol.com>
parents: 12354
diff changeset
    92
		SetHealth(gear, jetpackFuel)
4662
63aafc9c2a81 Add a bunch of lua from mikade, update translation files
mikade+nemo
parents:
diff changeset
    93
	end
63aafc9c2a81 Add a bunch of lua from mikade, update translation files
mikade+nemo
parents:
diff changeset
    94
63aafc9c2a81 Add a bunch of lua from mikade, update translation files
mikade+nemo
parents:
diff changeset
    95
end
63aafc9c2a81 Add a bunch of lua from mikade, update translation files
mikade+nemo
parents:
diff changeset
    96
15015
a1165392c9db Scenarios: Drawn games count as mission failure
Wuzzy <Wuzzy2@mail.ru>
parents: 14932
diff changeset
    97
function onGameResult(winner)
4662
63aafc9c2a81 Add a bunch of lua from mikade, update translation files
mikade+nemo
parents:
diff changeset
    98
15015
a1165392c9db Scenarios: Drawn games count as mission failure
Wuzzy <Wuzzy2@mail.ru>
parents: 14932
diff changeset
    99
	if winner == 0 then
12354
5e4ac10a03ce Mention inf attack rule in Diver, also fix the in-game mission name
Wuzzy <almikes@aol.com>
parents: 12226
diff changeset
   100
		ShowMission(loc("Diver"), loc("MISSION SUCCESSFUL"), loc("Congratulations!"), 0, 0)
14464
ead8928a59f8 Report mission victory for most missions
Wuzzy <Wuzzy2@mail.ru>
parents: 14401
diff changeset
   101
		SaveMissionVar("Won", "true")
15015
a1165392c9db Scenarios: Drawn games count as mission failure
Wuzzy <Wuzzy2@mail.ru>
parents: 14932
diff changeset
   102
		GameOver = true
a1165392c9db Scenarios: Drawn games count as mission failure
Wuzzy <Wuzzy2@mail.ru>
parents: 14932
diff changeset
   103
	else
12354
5e4ac10a03ce Mention inf attack rule in Diver, also fix the in-game mission name
Wuzzy <almikes@aol.com>
parents: 12226
diff changeset
   104
		ShowMission(loc("Diver"), loc("MISSION FAILED"), loc("Oh no! Just try again!"), -amSkip, 0)		
4662
63aafc9c2a81 Add a bunch of lua from mikade, update translation files
mikade+nemo
parents:
diff changeset
   105
		GameOver = true
63aafc9c2a81 Add a bunch of lua from mikade, update translation files
mikade+nemo
parents:
diff changeset
   106
	end
63aafc9c2a81 Add a bunch of lua from mikade, update translation files
mikade+nemo
parents:
diff changeset
   107
63aafc9c2a81 Add a bunch of lua from mikade, update translation files
mikade+nemo
parents:
diff changeset
   108
end