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