share/hedgewars/Data/Missions/Challenge/User_Mission_-_That_Sinking_Feeling.lua
author Wuzzy <Wuzzy2@mail.ru>
Fri, 31 May 2019 21:39:47 +0200
changeset 15096 5c8c729a16ce
parent 15073 6f51c75994a4
permissions -rw-r--r--
Scenarios: Show "Mission succeeded/failed!" in stats screen
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
5278
1aadb3312828 New User Mission: That Sinking Feeling
mikade
parents:
diff changeset
     1
1aadb3312828 New User Mission: That Sinking Feeling
mikade
parents:
diff changeset
     2
8043
da083f8d95e6 We need custom script loading function in lua now
unc0rr
parents: 5823
diff changeset
     3
HedgewarsScriptLoad("/Scripts/Locale.lua")
14480
2113296b7a29 Keep track of singleplayer high scores in challenges
Wuzzy <Wuzzy2@mail.ru>
parents: 14469
diff changeset
     4
HedgewarsScriptLoad("/Scripts/Utils.lua")
13501
cbda0f842364 Standardize hidden mission achievement in new Lua library "Achievements"
Wuzzy <Wuzzy2@mail.ru>
parents: 12938
diff changeset
     5
HedgewarsScriptLoad("/Scripts/Achievements.lua")
5278
1aadb3312828 New User Mission: That Sinking Feeling
mikade
parents:
diff changeset
     6
1aadb3312828 New User Mission: That Sinking Feeling
mikade
parents:
diff changeset
     7
local player
14487
d4aa64f51c9f Use player-chosen team identity for most challenges and scenarios
Wuzzy <Wuzzy2@mail.ru>
parents: 14480
diff changeset
     8
local playerTeamName, haplessTeamName
5278
1aadb3312828 New User Mission: That Sinking Feeling
mikade
parents:
diff changeset
     9
local hh = {}
1aadb3312828 New User Mission: That Sinking Feeling
mikade
parents:
diff changeset
    10
local hhCount = 8
1aadb3312828 New User Mission: That Sinking Feeling
mikade
parents:
diff changeset
    11
local GameOver = false
1aadb3312828 New User Mission: That Sinking Feeling
mikade
parents:
diff changeset
    12
local introStage = 0
1aadb3312828 New User Mission: That Sinking Feeling
mikade
parents:
diff changeset
    13
local genCounter = 0
1aadb3312828 New User Mission: That Sinking Feeling
mikade
parents:
diff changeset
    14
local waterCounter = 0
1aadb3312828 New User Mission: That Sinking Feeling
mikade
parents:
diff changeset
    15
local waterPix = 0
5823
mikade
parents: 5278
diff changeset
    16
local frig = 0
mikade
parents: 5278
diff changeset
    17
local watGear = nil
11526
dc36fad455f4 add cinematic effect to "sinking feeling" intro sequence
sheepluva
parents: 11266
diff changeset
    18
local cinematic = false
5278
1aadb3312828 New User Mission: That Sinking Feeling
mikade
parents:
diff changeset
    19
14480
2113296b7a29 Keep track of singleplayer high scores in challenges
Wuzzy <Wuzzy2@mail.ru>
parents: 14469
diff changeset
    20
function printMission()
2113296b7a29 Keep track of singleplayer high scores in challenges
Wuzzy <Wuzzy2@mail.ru>
parents: 14469
diff changeset
    21
	local highscore = tonumber(GetMissionVar("Highscore"))
2113296b7a29 Keep track of singleplayer high scores in challenges
Wuzzy <Wuzzy2@mail.ru>
parents: 14469
diff changeset
    22
	local show = (type(highscore) == "number") and (highscore > 0)
2113296b7a29 Keep track of singleplayer high scores in challenges
Wuzzy <Wuzzy2@mail.ru>
parents: 14469
diff changeset
    23
	local recordInfo = ""
2113296b7a29 Keep track of singleplayer high scores in challenges
Wuzzy <Wuzzy2@mail.ru>
parents: 14469
diff changeset
    24
	if show then
2113296b7a29 Keep track of singleplayer high scores in challenges
Wuzzy <Wuzzy2@mail.ru>
parents: 14469
diff changeset
    25
		recordInfo = getReadableChallengeRecord("Highscore")
2113296b7a29 Keep track of singleplayer high scores in challenges
Wuzzy <Wuzzy2@mail.ru>
parents: 14469
diff changeset
    26
	end
14487
d4aa64f51c9f Use player-chosen team identity for most challenges and scenarios
Wuzzy <Wuzzy2@mail.ru>
parents: 14480
diff changeset
    27
	ShowMission(loc("That Sinking Feeling"), loc("Challenge"), loc("Save as many hogs as possible!")
15073
6f51c75994a4 Semi-standardize usage of icons in many mission panels
Wuzzy <Wuzzy2@mail.ru>
parents: 15007
diff changeset
    28
	.. "|" .. recordInfo, 10, 0)
14480
2113296b7a29 Keep track of singleplayer high scores in challenges
Wuzzy <Wuzzy2@mail.ru>
parents: 14469
diff changeset
    29
end
2113296b7a29 Keep track of singleplayer high scores in challenges
Wuzzy <Wuzzy2@mail.ru>
parents: 14469
diff changeset
    30
5278
1aadb3312828 New User Mission: That Sinking Feeling
mikade
parents:
diff changeset
    31
-- allow skipping of the intro via hitting precise key
15007
3ed1cbd31754 Backed out changeset 4596357d002d (onPreciseLocal causes desyncs)
Wuzzy <Wuzzy2@mail.ru>
parents: 14937
diff changeset
    32
function onPrecise()
5278
1aadb3312828 New User Mission: That Sinking Feeling
mikade
parents:
diff changeset
    33
	if introStage < 100 then
1aadb3312828 New User Mission: That Sinking Feeling
mikade
parents:
diff changeset
    34
		introStage = 110
1aadb3312828 New User Mission: That Sinking Feeling
mikade
parents:
diff changeset
    35
		genCounter = 0
1aadb3312828 New User Mission: That Sinking Feeling
mikade
parents:
diff changeset
    36
		FollowGear(CurrentHedgehog)
1aadb3312828 New User Mission: That Sinking Feeling
mikade
parents:
diff changeset
    37
		AddCaption(loc("Good luck out there!"))
14480
2113296b7a29 Keep track of singleplayer high scores in challenges
Wuzzy <Wuzzy2@mail.ru>
parents: 14469
diff changeset
    38
		printMission()
11009
5b37f240edf8 update for "that sinking feeling"
wuzzy
parents: 8043
diff changeset
    39
		SetInputMask(0xFFFFFFFF)
5278
1aadb3312828 New User Mission: That Sinking Feeling
mikade
parents:
diff changeset
    40
	end
1aadb3312828 New User Mission: That Sinking Feeling
mikade
parents:
diff changeset
    41
end
1aadb3312828 New User Mission: That Sinking Feeling
mikade
parents:
diff changeset
    42
1aadb3312828 New User Mission: That Sinking Feeling
mikade
parents:
diff changeset
    43
function onGameInit()
1aadb3312828 New User Mission: That Sinking Feeling
mikade
parents:
diff changeset
    44
1aadb3312828 New User Mission: That Sinking Feeling
mikade
parents:
diff changeset
    45
	Seed = 0
11009
5b37f240edf8 update for "that sinking feeling"
wuzzy
parents: 8043
diff changeset
    46
	GameFlags = gfInfAttack + gfInvulnerable + gfOneClanMode
5278
1aadb3312828 New User Mission: That Sinking Feeling
mikade
parents:
diff changeset
    47
	TurnTime = 90000
1aadb3312828 New User Mission: That Sinking Feeling
mikade
parents:
diff changeset
    48
	CaseFreq = 0
1aadb3312828 New User Mission: That Sinking Feeling
mikade
parents:
diff changeset
    49
	MinesNum = 0
1aadb3312828 New User Mission: That Sinking Feeling
mikade
parents:
diff changeset
    50
	MinesTime  = 3000
1aadb3312828 New User Mission: That Sinking Feeling
mikade
parents:
diff changeset
    51
	Explosives = 0
1aadb3312828 New User Mission: That Sinking Feeling
mikade
parents:
diff changeset
    52
	Map = "Islands"
1aadb3312828 New User Mission: That Sinking Feeling
mikade
parents:
diff changeset
    53
	Theme = "City"
14408
8af01d65ccda Properly disable SD in That Sinking Feeling
Wuzzy <Wuzzy2@mail.ru>
parents: 14406
diff changeset
    54
	HealthDecrease = 0
8af01d65ccda Properly disable SD in That Sinking Feeling
Wuzzy <Wuzzy2@mail.ru>
parents: 14406
diff changeset
    55
	WaterRise = 0
5278
1aadb3312828 New User Mission: That Sinking Feeling
mikade
parents:
diff changeset
    56
14937
ff4003a90ff8 Enable automatic voicepack language selection for all missions
Wuzzy <Wuzzy2@mail.ru>
parents: 14933
diff changeset
    57
	haplessTeamName = AddTeam(loc("Hapless Hogs"), -1, "Simple", "Island", "Default_qau")
5823
mikade
parents: 5278
diff changeset
    58
	hh[0] = AddHog(loc("Sinky"), 1, 100, "fr_lemon")
mikade
parents: 5278
diff changeset
    59
	hh[1] = AddHog(loc("Drowner"), 1, 100, "fr_orange")
mikade
parents: 5278
diff changeset
    60
	hh[2] = AddHog(loc("Heavy"), 1, 100, "dish_Teapot")
mikade
parents: 5278
diff changeset
    61
	hh[3] = AddHog(loc("Clumsy"), 1, 100, "dish_SauceBoatSilver")
mikade
parents: 5278
diff changeset
    62
	hh[4] = AddHog(loc("Silly"), 1, 100, "dish_Ladle")
5278
1aadb3312828 New User Mission: That Sinking Feeling
mikade
parents:
diff changeset
    63
	hh[5] = AddHog(loc("Careless"), 1, 100, "StrawHatEyes")
5823
mikade
parents: 5278
diff changeset
    64
	hh[6] = AddHog(loc("Sponge"), 1, 100, "sf_chunli")
mikade
parents: 5278
diff changeset
    65
	hh[7] = AddHog(loc("Deadweight"), 1, 100, "dish_Teacup")
5278
1aadb3312828 New User Mission: That Sinking Feeling
mikade
parents:
diff changeset
    66
14497
6c62f7ebea45 Fix 2 team name mistakes in missions
Wuzzy <Wuzzy2@mail.ru>
parents: 14489
diff changeset
    67
	playerTeamName = AddMissionTeam(-1)
14487
d4aa64f51c9f Use player-chosen team identity for most challenges and scenarios
Wuzzy <Wuzzy2@mail.ru>
parents: 14480
diff changeset
    68
	player = AddMissionHog(1)
14653
be8af70adf2c Tweak hog spawn height and facing direction in challenges
Wuzzy <Wuzzy2@mail.ru>
parents: 14595
diff changeset
    69
	HogTurnLeft(player, false)
11009
5b37f240edf8 update for "that sinking feeling"
wuzzy
parents: 8043
diff changeset
    70
5278
1aadb3312828 New User Mission: That Sinking Feeling
mikade
parents:
diff changeset
    71
	SetGearPosition(player, 3992, 733)
1aadb3312828 New User Mission: That Sinking Feeling
mikade
parents:
diff changeset
    72
	SetGearPosition(hh[0], 938, 1369)
1aadb3312828 New User Mission: That Sinking Feeling
mikade
parents:
diff changeset
    73
	SetGearPosition(hh[1], 1301, 1439)
1aadb3312828 New User Mission: That Sinking Feeling
mikade
parents:
diff changeset
    74
	SetGearPosition(hh[2], 2093, 447)
1aadb3312828 New User Mission: That Sinking Feeling
mikade
parents:
diff changeset
    75
	SetGearPosition(hh[3], 2971, 926)
1aadb3312828 New User Mission: That Sinking Feeling
mikade
parents:
diff changeset
    76
	SetGearPosition(hh[4], 719, 545)
1aadb3312828 New User Mission: That Sinking Feeling
mikade
parents:
diff changeset
    77
	SetGearPosition(hh[5], 1630, 821)
1aadb3312828 New User Mission: That Sinking Feeling
mikade
parents:
diff changeset
    78
	SetGearPosition(hh[6], 2191, 810)
1aadb3312828 New User Mission: That Sinking Feeling
mikade
parents:
diff changeset
    79
	SetGearPosition(hh[7], 3799, 945)
1aadb3312828 New User Mission: That Sinking Feeling
mikade
parents:
diff changeset
    80
11009
5b37f240edf8 update for "that sinking feeling"
wuzzy
parents: 8043
diff changeset
    81
	-- Disable all input except [Precise] for the intro
5b37f240edf8 update for "that sinking feeling"
wuzzy
parents: 8043
diff changeset
    82
	SetInputMask(gmPrecise)
5278
1aadb3312828 New User Mission: That Sinking Feeling
mikade
parents:
diff changeset
    83
end
1aadb3312828 New User Mission: That Sinking Feeling
mikade
parents:
diff changeset
    84
1aadb3312828 New User Mission: That Sinking Feeling
mikade
parents:
diff changeset
    85
1aadb3312828 New User Mission: That Sinking Feeling
mikade
parents:
diff changeset
    86
function onGameStart()
14480
2113296b7a29 Keep track of singleplayer high scores in challenges
Wuzzy <Wuzzy2@mail.ru>
parents: 14469
diff changeset
    87
	cinematic = true
2113296b7a29 Keep track of singleplayer high scores in challenges
Wuzzy <Wuzzy2@mail.ru>
parents: 14469
diff changeset
    88
	SetCinematicMode(true)
11009
5b37f240edf8 update for "that sinking feeling"
wuzzy
parents: 8043
diff changeset
    89
	SendHealthStatsOff()
5278
1aadb3312828 New User Mission: That Sinking Feeling
mikade
parents:
diff changeset
    90
14480
2113296b7a29 Keep track of singleplayer high scores in challenges
Wuzzy <Wuzzy2@mail.ru>
parents: 14469
diff changeset
    91
	printMission()
2113296b7a29 Keep track of singleplayer high scores in challenges
Wuzzy <Wuzzy2@mail.ru>
parents: 14469
diff changeset
    92
	HideMission()
5278
1aadb3312828 New User Mission: That Sinking Feeling
mikade
parents:
diff changeset
    93
1aadb3312828 New User Mission: That Sinking Feeling
mikade
parents:
diff changeset
    94
	HogTurnLeft(hh[0], false)
1aadb3312828 New User Mission: That Sinking Feeling
mikade
parents:
diff changeset
    95
	HogTurnLeft(hh[1], true)
1aadb3312828 New User Mission: That Sinking Feeling
mikade
parents:
diff changeset
    96
12938
e65aa3c3d4e6 Refactor scripts to use SpawnSupplyCrate (where it makes sense)
Wuzzy <Wuzzy2@mail.ru>
parents: 12351
diff changeset
    97
	SpawnSupplyCrate(148,265,amLowGravity)
e65aa3c3d4e6 Refactor scripts to use SpawnSupplyCrate (where it makes sense)
Wuzzy <Wuzzy2@mail.ru>
parents: 12351
diff changeset
    98
	SpawnSupplyCrate(2124,1516,amJetpack)
5278
1aadb3312828 New User Mission: That Sinking Feeling
mikade
parents:
diff changeset
    99
1aadb3312828 New User Mission: That Sinking Feeling
mikade
parents:
diff changeset
   100
end
1aadb3312828 New User Mission: That Sinking Feeling
mikade
parents:
diff changeset
   101
1aadb3312828 New User Mission: That Sinking Feeling
mikade
parents:
diff changeset
   102
1aadb3312828 New User Mission: That Sinking Feeling
mikade
parents:
diff changeset
   103
function onNewTurn()
13755
110d6c1e817f Lua: Rename globals: NoPointX→NO_CURSOR, cMaxTurnTime→MAX_TURN_TIME, cMaxHogHealth→MAX_HOG_HEALTH
Wuzzy <Wuzzy2@mail.ru>
parents: 13745
diff changeset
   104
	SetTurnTimeLeft(MAX_TURN_TIME)
5278
1aadb3312828 New User Mission: That Sinking Feeling
mikade
parents:
diff changeset
   105
end
1aadb3312828 New User Mission: That Sinking Feeling
mikade
parents:
diff changeset
   106
1aadb3312828 New User Mission: That Sinking Feeling
mikade
parents:
diff changeset
   107
function onGameTick()
1aadb3312828 New User Mission: That Sinking Feeling
mikade
parents:
diff changeset
   108
1aadb3312828 New User Mission: That Sinking Feeling
mikade
parents:
diff changeset
   109
	-- intro sequence
1aadb3312828 New User Mission: That Sinking Feeling
mikade
parents:
diff changeset
   110
	if introStage < 100 then
1aadb3312828 New User Mission: That Sinking Feeling
mikade
parents:
diff changeset
   111
5823
mikade
parents: 5278
diff changeset
   112
		frig = frig + 1
mikade
parents: 5278
diff changeset
   113
		if frig == 50 then
mikade
parents: 5278
diff changeset
   114
			frig = 0			
mikade
parents: 5278
diff changeset
   115
			AddCaption(loc("Press [Precise] to skip intro"))
mikade
parents: 5278
diff changeset
   116
			if watGear ~= nil then			
mikade
parents: 5278
diff changeset
   117
				FollowGear(watGear)
mikade
parents: 5278
diff changeset
   118
			end
mikade
parents: 5278
diff changeset
   119
		end
5278
1aadb3312828 New User Mission: That Sinking Feeling
mikade
parents:
diff changeset
   120
5823
mikade
parents: 5278
diff changeset
   121
		
mikade
parents: 5278
diff changeset
   122
		--AddCaption(loc("Press [Precise] to skip intro"))
5278
1aadb3312828 New User Mission: That Sinking Feeling
mikade
parents:
diff changeset
   123
		genCounter = genCounter + 1
1aadb3312828 New User Mission: That Sinking Feeling
mikade
parents:
diff changeset
   124
1aadb3312828 New User Mission: That Sinking Feeling
mikade
parents:
diff changeset
   125
		if introStage == 0 then
1aadb3312828 New User Mission: That Sinking Feeling
mikade
parents:
diff changeset
   126
5823
mikade
parents: 5278
diff changeset
   127
						
mikade
parents: 5278
diff changeset
   128
			--FollowGear(hh[0])
5278
1aadb3312828 New User Mission: That Sinking Feeling
mikade
parents:
diff changeset
   129
1aadb3312828 New User Mission: That Sinking Feeling
mikade
parents:
diff changeset
   130
			if genCounter == 2000 then
5823
mikade
parents: 5278
diff changeset
   131
				watGear = hh[0]
5278
1aadb3312828 New User Mission: That Sinking Feeling
mikade
parents:
diff changeset
   132
				HogSay(hh[0], loc("This rain is really something..."), SAY_SAY,2)
1aadb3312828 New User Mission: That Sinking Feeling
mikade
parents:
diff changeset
   133
			elseif genCounter == 5000 then
1aadb3312828 New User Mission: That Sinking Feeling
mikade
parents:
diff changeset
   134
				introStage = 1
1aadb3312828 New User Mission: That Sinking Feeling
mikade
parents:
diff changeset
   135
				genCounter = 0
1aadb3312828 New User Mission: That Sinking Feeling
mikade
parents:
diff changeset
   136
			end
1aadb3312828 New User Mission: That Sinking Feeling
mikade
parents:
diff changeset
   137
1aadb3312828 New User Mission: That Sinking Feeling
mikade
parents:
diff changeset
   138
		elseif introStage == 1 then
5823
mikade
parents: 5278
diff changeset
   139
						
mikade
parents: 5278
diff changeset
   140
			--FollowGear(hh[1])
5278
1aadb3312828 New User Mission: That Sinking Feeling
mikade
parents:
diff changeset
   141
1aadb3312828 New User Mission: That Sinking Feeling
mikade
parents:
diff changeset
   142
			if genCounter == 2000 then
5823
mikade
parents: 5278
diff changeset
   143
				watGear = hh[1]
5278
1aadb3312828 New User Mission: That Sinking Feeling
mikade
parents:
diff changeset
   144
				HogSay(hh[1], loc("Heh, it's not that bad."), SAY_SAY,2)
1aadb3312828 New User Mission: That Sinking Feeling
mikade
parents:
diff changeset
   145
			elseif genCounter == 5000 then
1aadb3312828 New User Mission: That Sinking Feeling
mikade
parents:
diff changeset
   146
				introStage = 2
1aadb3312828 New User Mission: That Sinking Feeling
mikade
parents:
diff changeset
   147
				genCounter = 0
1aadb3312828 New User Mission: That Sinking Feeling
mikade
parents:
diff changeset
   148
			end
1aadb3312828 New User Mission: That Sinking Feeling
mikade
parents:
diff changeset
   149
1aadb3312828 New User Mission: That Sinking Feeling
mikade
parents:
diff changeset
   150
		elseif introStage == 2 then
1aadb3312828 New User Mission: That Sinking Feeling
mikade
parents:
diff changeset
   151
5823
mikade
parents: 5278
diff changeset
   152
			--FollowGear(hh[0])
5278
1aadb3312828 New User Mission: That Sinking Feeling
mikade
parents:
diff changeset
   153
1aadb3312828 New User Mission: That Sinking Feeling
mikade
parents:
diff changeset
   154
			if genCounter == 2000 then
5823
mikade
parents: 5278
diff changeset
   155
				watGear = hh[0]
5278
1aadb3312828 New User Mission: That Sinking Feeling
mikade
parents:
diff changeset
   156
				HogSay(hh[0], loc("You'd almost swear the water was rising!"), SAY_SHOUT,2)
1aadb3312828 New User Mission: That Sinking Feeling
mikade
parents:
diff changeset
   157
			elseif genCounter == 6000 then
1aadb3312828 New User Mission: That Sinking Feeling
mikade
parents:
diff changeset
   158
				introStage = 3
1aadb3312828 New User Mission: That Sinking Feeling
mikade
parents:
diff changeset
   159
				genCounter = 0
1aadb3312828 New User Mission: That Sinking Feeling
mikade
parents:
diff changeset
   160
			end
1aadb3312828 New User Mission: That Sinking Feeling
mikade
parents:
diff changeset
   161
1aadb3312828 New User Mission: That Sinking Feeling
mikade
parents:
diff changeset
   162
		elseif introStage == 3 then
1aadb3312828 New User Mission: That Sinking Feeling
mikade
parents:
diff changeset
   163
5823
mikade
parents: 5278
diff changeset
   164
			--FollowGear(hh[1])
5278
1aadb3312828 New User Mission: That Sinking Feeling
mikade
parents:
diff changeset
   165
1aadb3312828 New User Mission: That Sinking Feeling
mikade
parents:
diff changeset
   166
			if genCounter == 2000 then
5823
mikade
parents: 5278
diff changeset
   167
				watGear = hh[1]
5278
1aadb3312828 New User Mission: That Sinking Feeling
mikade
parents:
diff changeset
   168
				HogSay(hh[1], loc("Haha, now THAT would be something!"), SAY_SAY,2)
1aadb3312828 New User Mission: That Sinking Feeling
mikade
parents:
diff changeset
   169
			elseif genCounter == 6000 then
1aadb3312828 New User Mission: That Sinking Feeling
mikade
parents:
diff changeset
   170
				introStage = 4
1aadb3312828 New User Mission: That Sinking Feeling
mikade
parents:
diff changeset
   171
				genCounter = 0
1aadb3312828 New User Mission: That Sinking Feeling
mikade
parents:
diff changeset
   172
			end
1aadb3312828 New User Mission: That Sinking Feeling
mikade
parents:
diff changeset
   173
1aadb3312828 New User Mission: That Sinking Feeling
mikade
parents:
diff changeset
   174
		elseif introStage == 4 then
1aadb3312828 New User Mission: That Sinking Feeling
mikade
parents:
diff changeset
   175
5823
mikade
parents: 5278
diff changeset
   176
			--FollowGear(hh[0])
5278
1aadb3312828 New User Mission: That Sinking Feeling
mikade
parents:
diff changeset
   177
1aadb3312828 New User Mission: That Sinking Feeling
mikade
parents:
diff changeset
   178
			if genCounter == 2000 then
5823
mikade
parents: 5278
diff changeset
   179
				watGear = hh[0]
5278
1aadb3312828 New User Mission: That Sinking Feeling
mikade
parents:
diff changeset
   180
				HogSay(hh[0], loc("Hahahaha!"), SAY_SHOUT,2)
1aadb3312828 New User Mission: That Sinking Feeling
mikade
parents:
diff changeset
   181
				HogSay(hh[1], loc("Hahahaha!"), SAY_SHOUT,2)
1aadb3312828 New User Mission: That Sinking Feeling
mikade
parents:
diff changeset
   182
			elseif genCounter == 3000 then
1aadb3312828 New User Mission: That Sinking Feeling
mikade
parents:
diff changeset
   183
				introStage = 5
1aadb3312828 New User Mission: That Sinking Feeling
mikade
parents:
diff changeset
   184
				genCounter = 0
1aadb3312828 New User Mission: That Sinking Feeling
mikade
parents:
diff changeset
   185
			end
1aadb3312828 New User Mission: That Sinking Feeling
mikade
parents:
diff changeset
   186
1aadb3312828 New User Mission: That Sinking Feeling
mikade
parents:
diff changeset
   187
		elseif introStage == 5 then
1aadb3312828 New User Mission: That Sinking Feeling
mikade
parents:
diff changeset
   188
5823
mikade
parents: 5278
diff changeset
   189
			--FollowGear(hh[1])
5278
1aadb3312828 New User Mission: That Sinking Feeling
mikade
parents:
diff changeset
   190
1aadb3312828 New User Mission: That Sinking Feeling
mikade
parents:
diff changeset
   191
			if genCounter == 2000 then
5823
mikade
parents: 5278
diff changeset
   192
				watGear = hh[1]
5278
1aadb3312828 New User Mission: That Sinking Feeling
mikade
parents:
diff changeset
   193
				HogSay(hh[0], loc("..."), SAY_THINK,2)
1aadb3312828 New User Mission: That Sinking Feeling
mikade
parents:
diff changeset
   194
				HogSay(hh[1], loc("..."), SAY_THINK,2)
1aadb3312828 New User Mission: That Sinking Feeling
mikade
parents:
diff changeset
   195
			elseif genCounter == 5000 then
1aadb3312828 New User Mission: That Sinking Feeling
mikade
parents:
diff changeset
   196
				introStage = 6
1aadb3312828 New User Mission: That Sinking Feeling
mikade
parents:
diff changeset
   197
				genCounter = 0
1aadb3312828 New User Mission: That Sinking Feeling
mikade
parents:
diff changeset
   198
			end
1aadb3312828 New User Mission: That Sinking Feeling
mikade
parents:
diff changeset
   199
1aadb3312828 New User Mission: That Sinking Feeling
mikade
parents:
diff changeset
   200
		elseif introStage == 6 then
1aadb3312828 New User Mission: That Sinking Feeling
mikade
parents:
diff changeset
   201
5823
mikade
parents: 5278
diff changeset
   202
			--FollowGear(hh[0])
5278
1aadb3312828 New User Mission: That Sinking Feeling
mikade
parents:
diff changeset
   203
1aadb3312828 New User Mission: That Sinking Feeling
mikade
parents:
diff changeset
   204
			if genCounter == 2000 then
5823
mikade
parents: 5278
diff changeset
   205
				watGear = hh[0]
5278
1aadb3312828 New User Mission: That Sinking Feeling
mikade
parents:
diff changeset
   206
				HogSay(hh[0], loc("It's a good thing SUDDEN DEATH is 99 turns away..."), SAY_THINK,2)
1aadb3312828 New User Mission: That Sinking Feeling
mikade
parents:
diff changeset
   207
			elseif genCounter == 6000 then
1aadb3312828 New User Mission: That Sinking Feeling
mikade
parents:
diff changeset
   208
				introStage = 7
1aadb3312828 New User Mission: That Sinking Feeling
mikade
parents:
diff changeset
   209
				genCounter = 0
1aadb3312828 New User Mission: That Sinking Feeling
mikade
parents:
diff changeset
   210
			end
1aadb3312828 New User Mission: That Sinking Feeling
mikade
parents:
diff changeset
   211
1aadb3312828 New User Mission: That Sinking Feeling
mikade
parents:
diff changeset
   212
1aadb3312828 New User Mission: That Sinking Feeling
mikade
parents:
diff changeset
   213
		elseif introStage == 7 then
1aadb3312828 New User Mission: That Sinking Feeling
mikade
parents:
diff changeset
   214
1aadb3312828 New User Mission: That Sinking Feeling
mikade
parents:
diff changeset
   215
			if genCounter == 2000 then
1aadb3312828 New User Mission: That Sinking Feeling
mikade
parents:
diff changeset
   216
				introStage = 110
1aadb3312828 New User Mission: That Sinking Feeling
mikade
parents:
diff changeset
   217
				FollowGear(CurrentHedgehog)
15073
6f51c75994a4 Semi-standardize usage of icons in many mission panels
Wuzzy <Wuzzy2@mail.ru>
parents: 15007
diff changeset
   218
				ShowMission(loc("That Sinking Feeling"), loc("User Challenge"), loc("Save as many hogs as possible!"), 10, 0)
11009
5b37f240edf8 update for "that sinking feeling"
wuzzy
parents: 8043
diff changeset
   219
				SetInputMask(0xFFFFFFFF)
5278
1aadb3312828 New User Mission: That Sinking Feeling
mikade
parents:
diff changeset
   220
			end
1aadb3312828 New User Mission: That Sinking Feeling
mikade
parents:
diff changeset
   221
1aadb3312828 New User Mission: That Sinking Feeling
mikade
parents:
diff changeset
   222
		end
1aadb3312828 New User Mission: That Sinking Feeling
mikade
parents:
diff changeset
   223
1aadb3312828 New User Mission: That Sinking Feeling
mikade
parents:
diff changeset
   224
	end
1aadb3312828 New User Mission: That Sinking Feeling
mikade
parents:
diff changeset
   225
1aadb3312828 New User Mission: That Sinking Feeling
mikade
parents:
diff changeset
   226
	-- start the water rising when the intro is finished
1aadb3312828 New User Mission: That Sinking Feeling
mikade
parents:
diff changeset
   227
	if introStage == 110 then
1aadb3312828 New User Mission: That Sinking Feeling
mikade
parents:
diff changeset
   228
11526
dc36fad455f4 add cinematic effect to "sinking feeling" intro sequence
sheepluva
parents: 11266
diff changeset
   229
        if cinematic then
dc36fad455f4 add cinematic effect to "sinking feeling" intro sequence
sheepluva
parents: 11266
diff changeset
   230
            SetCinematicMode(false)
dc36fad455f4 add cinematic effect to "sinking feeling" intro sequence
sheepluva
parents: 11266
diff changeset
   231
            cinematic = false
dc36fad455f4 add cinematic effect to "sinking feeling" intro sequence
sheepluva
parents: 11266
diff changeset
   232
        end
dc36fad455f4 add cinematic effect to "sinking feeling" intro sequence
sheepluva
parents: 11266
diff changeset
   233
5278
1aadb3312828 New User Mission: That Sinking Feeling
mikade
parents:
diff changeset
   234
		waterCounter = waterCounter + 1
1aadb3312828 New User Mission: That Sinking Feeling
mikade
parents:
diff changeset
   235
		if (waterCounter == 100) and (waterPix < 1615) then
1aadb3312828 New User Mission: That Sinking Feeling
mikade
parents:
diff changeset
   236
			waterCounter = 0
1aadb3312828 New User Mission: That Sinking Feeling
mikade
parents:
diff changeset
   237
			SetTag(AddGear(0, 0, gtWaterUp, 0, 0, 0, 0), 1)
1aadb3312828 New User Mission: That Sinking Feeling
mikade
parents:
diff changeset
   238
			waterPix = waterPix +1
1aadb3312828 New User Mission: That Sinking Feeling
mikade
parents:
diff changeset
   239
			--AddCaption(waterPix)
1aadb3312828 New User Mission: That Sinking Feeling
mikade
parents:
diff changeset
   240
1aadb3312828 New User Mission: That Sinking Feeling
mikade
parents:
diff changeset
   241
			if (waterPix >= 1615) and (GameOver == false) then
1aadb3312828 New User Mission: That Sinking Feeling
mikade
parents:
diff changeset
   242
				GameOver = true
11266
6e1aa1144a2b - Finally added rus localization for all User Missions
antonc27 <antonc27@mail.ru>
parents: 11009
diff changeset
   243
				AddCaption(loc("The flood has stopped! Challenge over."))
11009
5b37f240edf8 update for "that sinking feeling"
wuzzy
parents: 8043
diff changeset
   244
				SendStat(siGameResult, loc("Challenge completed!"))
14583
50f511588635 Outsource commonly used words in siPointType to QTfrontend
Wuzzy <Wuzzy2@mail.ru>
parents: 14497
diff changeset
   245
				SendStat(siPointType, "!POINTS")
14487
d4aa64f51c9f Use player-chosen team identity for most challenges and scenarios
Wuzzy <Wuzzy2@mail.ru>
parents: 14480
diff changeset
   246
				SendStat(siPlayerKills, tostring(hhCount), playerTeamName)
5823
mikade
parents: 5278
diff changeset
   247
11009
5b37f240edf8 update for "that sinking feeling"
wuzzy
parents: 8043
diff changeset
   248
				-- Do not count drowning hedgehogs
5b37f240edf8 update for "that sinking feeling"
wuzzy
parents: 8043
diff changeset
   249
				local hhLeft = hhCount
5b37f240edf8 update for "that sinking feeling"
wuzzy
parents: 8043
diff changeset
   250
				for i=1,#hh do
5b37f240edf8 update for "that sinking feeling"
wuzzy
parents: 8043
diff changeset
   251
					local isDrowning = band(GetState(hh[i]),gstDrowning) ~= 0
5b37f240edf8 update for "that sinking feeling"
wuzzy
parents: 8043
diff changeset
   252
					if isDrowning then
5b37f240edf8 update for "that sinking feeling"
wuzzy
parents: 8043
diff changeset
   253
						hhLeft = hhLeft - 1
5b37f240edf8 update for "that sinking feeling"
wuzzy
parents: 8043
diff changeset
   254
					end
5823
mikade
parents: 5278
diff changeset
   255
				end
mikade
parents: 5278
diff changeset
   256
14487
d4aa64f51c9f Use player-chosen team identity for most challenges and scenarios
Wuzzy <Wuzzy2@mail.ru>
parents: 14480
diff changeset
   257
				SendStat(siCustomAchievement, string.format(loc("You saved %d of 8 hegehogs."), hhLeft))
11009
5b37f240edf8 update for "that sinking feeling"
wuzzy
parents: 8043
diff changeset
   258
14480
2113296b7a29 Keep track of singleplayer high scores in challenges
Wuzzy <Wuzzy2@mail.ru>
parents: 14469
diff changeset
   259
				-- Update highscore
2113296b7a29 Keep track of singleplayer high scores in challenges
Wuzzy <Wuzzy2@mail.ru>
parents: 14469
diff changeset
   260
				updateChallengeRecord("Highscore", hhLeft)
2113296b7a29 Keep track of singleplayer high scores in challenges
Wuzzy <Wuzzy2@mail.ru>
parents: 14469
diff changeset
   261
11009
5b37f240edf8 update for "that sinking feeling"
wuzzy
parents: 8043
diff changeset
   262
				if hhLeft == 8 then
14469
ead8928a59f8 Report mission victory for most missions
Wuzzy <Wuzzy2@mail.ru>
parents: 14408
diff changeset
   263
					SaveMissionVar("Won", "true")
13501
cbda0f842364 Standardize hidden mission achievement in new Lua library "Achievements"
Wuzzy <Wuzzy2@mail.ru>
parents: 12938
diff changeset
   264
					awardAchievement(loc("Lively Lifeguard"))
11009
5b37f240edf8 update for "that sinking feeling"
wuzzy
parents: 8043
diff changeset
   265
				end
5b37f240edf8 update for "that sinking feeling"
wuzzy
parents: 8043
diff changeset
   266
				EndGame()
14933
4c5fb1ee75b7 Add winner animation for missions that didn't have it
Wuzzy <Wuzzy2@mail.ru>
parents: 14903
diff changeset
   267
				for _, hog in pairs(hh) do
4c5fb1ee75b7 Add winner animation for missions that didn't have it
Wuzzy <Wuzzy2@mail.ru>
parents: 14903
diff changeset
   268
					SetState(hog, gstWinner)
4c5fb1ee75b7 Add winner animation for missions that didn't have it
Wuzzy <Wuzzy2@mail.ru>
parents: 14903
diff changeset
   269
				end
11009
5b37f240edf8 update for "that sinking feeling"
wuzzy
parents: 8043
diff changeset
   270
5278
1aadb3312828 New User Mission: That Sinking Feeling
mikade
parents:
diff changeset
   271
			end
1aadb3312828 New User Mission: That Sinking Feeling
mikade
parents:
diff changeset
   272
1aadb3312828 New User Mission: That Sinking Feeling
mikade
parents:
diff changeset
   273
		end
1aadb3312828 New User Mission: That Sinking Feeling
mikade
parents:
diff changeset
   274
1aadb3312828 New User Mission: That Sinking Feeling
mikade
parents:
diff changeset
   275
	end
1aadb3312828 New User Mission: That Sinking Feeling
mikade
parents:
diff changeset
   276
end
1aadb3312828 New User Mission: That Sinking Feeling
mikade
parents:
diff changeset
   277
1aadb3312828 New User Mission: That Sinking Feeling
mikade
parents:
diff changeset
   278
1aadb3312828 New User Mission: That Sinking Feeling
mikade
parents:
diff changeset
   279
function onAmmoStoreInit()
1aadb3312828 New User Mission: That Sinking Feeling
mikade
parents:
diff changeset
   280
1aadb3312828 New User Mission: That Sinking Feeling
mikade
parents:
diff changeset
   281
	SetAmmo(amBazooka, 9, 0, 0, 0)
1aadb3312828 New User Mission: That Sinking Feeling
mikade
parents:
diff changeset
   282
1aadb3312828 New User Mission: That Sinking Feeling
mikade
parents:
diff changeset
   283
	SetAmmo(amRope, 9, 0, 0, 0)
1aadb3312828 New User Mission: That Sinking Feeling
mikade
parents:
diff changeset
   284
	SetAmmo(amParachute, 9, 0, 0, 0)
1aadb3312828 New User Mission: That Sinking Feeling
mikade
parents:
diff changeset
   285
	SetAmmo(amJetpack, 2, 0, 0, 2)
1aadb3312828 New User Mission: That Sinking Feeling
mikade
parents:
diff changeset
   286
1aadb3312828 New User Mission: That Sinking Feeling
mikade
parents:
diff changeset
   287
	SetAmmo(amGirder, 9, 0, 0, 0)
1aadb3312828 New User Mission: That Sinking Feeling
mikade
parents:
diff changeset
   288
	SetAmmo(amBaseballBat, 9, 0, 0, 0)
1aadb3312828 New User Mission: That Sinking Feeling
mikade
parents:
diff changeset
   289
1aadb3312828 New User Mission: That Sinking Feeling
mikade
parents:
diff changeset
   290
	SetAmmo(amTeleport, 1, 0, 0, 1)
1aadb3312828 New User Mission: That Sinking Feeling
mikade
parents:
diff changeset
   291
	SetAmmo(amPortalGun, 3, 0, 0, 1)
1aadb3312828 New User Mission: That Sinking Feeling
mikade
parents:
diff changeset
   292
1aadb3312828 New User Mission: That Sinking Feeling
mikade
parents:
diff changeset
   293
	SetAmmo(amLowGravity, 0, 0, 0, 1)
1aadb3312828 New User Mission: That Sinking Feeling
mikade
parents:
diff changeset
   294
1aadb3312828 New User Mission: That Sinking Feeling
mikade
parents:
diff changeset
   295
end
1aadb3312828 New User Mission: That Sinking Feeling
mikade
parents:
diff changeset
   296
1aadb3312828 New User Mission: That Sinking Feeling
mikade
parents:
diff changeset
   297
function onGearDelete(gear)
1aadb3312828 New User Mission: That Sinking Feeling
mikade
parents:
diff changeset
   298
1aadb3312828 New User Mission: That Sinking Feeling
mikade
parents:
diff changeset
   299
	if GetGearType(gear) == gtHedgehog then
14487
d4aa64f51c9f Use player-chosen team identity for most challenges and scenarios
Wuzzy <Wuzzy2@mail.ru>
parents: 14480
diff changeset
   300
		if GetHogTeamName(gear) == haplessTeamName then
5278
1aadb3312828 New User Mission: That Sinking Feeling
mikade
parents:
diff changeset
   301
			hhCount = hhCount - 1
14487
d4aa64f51c9f Use player-chosen team identity for most challenges and scenarios
Wuzzy <Wuzzy2@mail.ru>
parents: 14480
diff changeset
   302
			AddCaption(string.format(loc("Hedgehogs left: %d"), hhCount))
5278
1aadb3312828 New User Mission: That Sinking Feeling
mikade
parents:
diff changeset
   303
		end
1aadb3312828 New User Mission: That Sinking Feeling
mikade
parents:
diff changeset
   304
	end
1aadb3312828 New User Mission: That Sinking Feeling
mikade
parents:
diff changeset
   305
1aadb3312828 New User Mission: That Sinking Feeling
mikade
parents:
diff changeset
   306
	if ((gear == player) or (hhCount == 0)) and (GameOver == false) then
1aadb3312828 New User Mission: That Sinking Feeling
mikade
parents:
diff changeset
   307
		SetHealth(player, 0)
14595
c5f18710a184 Remove "loser" messages in challenges
Wuzzy <Wuzzy2@mail.ru>
parents: 14583
diff changeset
   308
		AddCaption(loc("Challenge failed!"))
11009
5b37f240edf8 update for "that sinking feeling"
wuzzy
parents: 8043
diff changeset
   309
		if gear == player then
5b37f240edf8 update for "that sinking feeling"
wuzzy
parents: 8043
diff changeset
   310
			SendStat(siCustomAchievement, loc("Your hedgehog died!"))
5b37f240edf8 update for "that sinking feeling"
wuzzy
parents: 8043
diff changeset
   311
			SendStat(siCustomAchievement, loc("You must survive the flood in order to score."))
5b37f240edf8 update for "that sinking feeling"
wuzzy
parents: 8043
diff changeset
   312
		else
5b37f240edf8 update for "that sinking feeling"
wuzzy
parents: 8043
diff changeset
   313
			SendStat(siCustomAchievement, loc("You haven't rescued anyone."))
5b37f240edf8 update for "that sinking feeling"
wuzzy
parents: 8043
diff changeset
   314
		end
14583
50f511588635 Outsource commonly used words in siPointType to QTfrontend
Wuzzy <Wuzzy2@mail.ru>
parents: 14497
diff changeset
   315
		SendStat(siPointType, "!POINTS")
14487
d4aa64f51c9f Use player-chosen team identity for most challenges and scenarios
Wuzzy <Wuzzy2@mail.ru>
parents: 14480
diff changeset
   316
		SendStat(siPlayerKills, "0", playerTeamName)
14480
2113296b7a29 Keep track of singleplayer high scores in challenges
Wuzzy <Wuzzy2@mail.ru>
parents: 14469
diff changeset
   317
		local highscore = tonumber(GetMissionVar("Highscore"))
2113296b7a29 Keep track of singleplayer high scores in challenges
Wuzzy <Wuzzy2@mail.ru>
parents: 14469
diff changeset
   318
		show = (type(highscore) == "number") and (highscore > 0)
2113296b7a29 Keep track of singleplayer high scores in challenges
Wuzzy <Wuzzy2@mail.ru>
parents: 14469
diff changeset
   319
		updateChallengeRecord("Highscore", 0, show)
11009
5b37f240edf8 update for "that sinking feeling"
wuzzy
parents: 8043
diff changeset
   320
14595
c5f18710a184 Remove "loser" messages in challenges
Wuzzy <Wuzzy2@mail.ru>
parents: 14583
diff changeset
   321
		SendStat(siGameResult, loc("Challenge failed!"))
5278
1aadb3312828 New User Mission: That Sinking Feeling
mikade
parents:
diff changeset
   322
		GameOver = true
11009
5b37f240edf8 update for "that sinking feeling"
wuzzy
parents: 8043
diff changeset
   323
		EndGame()
5278
1aadb3312828 New User Mission: That Sinking Feeling
mikade
parents:
diff changeset
   324
	end
1aadb3312828 New User Mission: That Sinking Feeling
mikade
parents:
diff changeset
   325
1aadb3312828 New User Mission: That Sinking Feeling
mikade
parents:
diff changeset
   326
end