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