author | Wuzzy <Wuzzy2@mail.ru> |
Fri, 31 May 2019 21:39:47 +0200 | |
changeset 15096 | 5c8c729a16ce |
parent 15073 | 6f51c75994a4 |
permissions | -rw-r--r-- |
5278 | 1 |
|
2 |
||
8043 | 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 | 6 |
|
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 | 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 |
|
11526
dc36fad455f4
add cinematic effect to "sinking feeling" intro sequence
sheepluva
parents:
11266
diff
changeset
|
18 |
local cinematic = false |
5278 | 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 | 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 | 33 |
if introStage < 100 then |
34 |
introStage = 110 |
|
35 |
genCounter = 0 |
|
36 |
FollowGear(CurrentHedgehog) |
|
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 | 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" |
|
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 | 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 | 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 |
|
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 | 70 |
|
5278 | 71 |
SetGearPosition(player, 3992, 733) |
72 |
SetGearPosition(hh[0], 938, 1369) |
|
73 |
SetGearPosition(hh[1], 1301, 1439) |
|
74 |
SetGearPosition(hh[2], 2093, 447) |
|
75 |
SetGearPosition(hh[3], 2971, 926) |
|
76 |
SetGearPosition(hh[4], 719, 545) |
|
77 |
SetGearPosition(hh[5], 1630, 821) |
|
78 |
SetGearPosition(hh[6], 2191, 810) |
|
79 |
SetGearPosition(hh[7], 3799, 945) |
|
80 |
||
11009 | 81 |
-- Disable all input except [Precise] for the intro |
82 |
SetInputMask(gmPrecise) |
|
5278 | 83 |
end |
84 |
||
85 |
||
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 | 89 |
SendHealthStatsOff() |
5278 | 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 | 93 |
|
94 |
HogTurnLeft(hh[0], false) |
|
95 |
HogTurnLeft(hh[1], true) |
|
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 | 99 |
|
100 |
end |
|
101 |
||
102 |
||
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 | 105 |
end |
106 |
||
107 |
function onGameTick() |
|
108 |
||
109 |
-- intro sequence |
|
110 |
if introStage < 100 then |
|
111 |
||
5823 | 112 |
frig = frig + 1 |
113 |
if frig == 50 then |
|
114 |
frig = 0 |
|
115 |
AddCaption(loc("Press [Precise] to skip intro")) |
|
116 |
if watGear ~= nil then |
|
117 |
FollowGear(watGear) |
|
118 |
end |
|
119 |
end |
|
5278 | 120 |
|
5823 | 121 |
|
122 |
--AddCaption(loc("Press [Precise] to skip intro")) |
|
5278 | 123 |
genCounter = genCounter + 1 |
124 |
||
125 |
if introStage == 0 then |
|
126 |
||
5823 | 127 |
|
128 |
--FollowGear(hh[0]) |
|
5278 | 129 |
|
130 |
if genCounter == 2000 then |
|
5823 | 131 |
watGear = hh[0] |
5278 | 132 |
HogSay(hh[0], loc("This rain is really something..."), SAY_SAY,2) |
133 |
elseif genCounter == 5000 then |
|
134 |
introStage = 1 |
|
135 |
genCounter = 0 |
|
136 |
end |
|
137 |
||
138 |
elseif introStage == 1 then |
|
5823 | 139 |
|
140 |
--FollowGear(hh[1]) |
|
5278 | 141 |
|
142 |
if genCounter == 2000 then |
|
5823 | 143 |
watGear = hh[1] |
5278 | 144 |
HogSay(hh[1], loc("Heh, it's not that bad."), SAY_SAY,2) |
145 |
elseif genCounter == 5000 then |
|
146 |
introStage = 2 |
|
147 |
genCounter = 0 |
|
148 |
end |
|
149 |
||
150 |
elseif introStage == 2 then |
|
151 |
||
5823 | 152 |
--FollowGear(hh[0]) |
5278 | 153 |
|
154 |
if genCounter == 2000 then |
|
5823 | 155 |
watGear = hh[0] |
5278 | 156 |
HogSay(hh[0], loc("You'd almost swear the water was rising!"), SAY_SHOUT,2) |
157 |
elseif genCounter == 6000 then |
|
158 |
introStage = 3 |
|
159 |
genCounter = 0 |
|
160 |
end |
|
161 |
||
162 |
elseif introStage == 3 then |
|
163 |
||
5823 | 164 |
--FollowGear(hh[1]) |
5278 | 165 |
|
166 |
if genCounter == 2000 then |
|
5823 | 167 |
watGear = hh[1] |
5278 | 168 |
HogSay(hh[1], loc("Haha, now THAT would be something!"), SAY_SAY,2) |
169 |
elseif genCounter == 6000 then |
|
170 |
introStage = 4 |
|
171 |
genCounter = 0 |
|
172 |
end |
|
173 |
||
174 |
elseif introStage == 4 then |
|
175 |
||
5823 | 176 |
--FollowGear(hh[0]) |
5278 | 177 |
|
178 |
if genCounter == 2000 then |
|
5823 | 179 |
watGear = hh[0] |
5278 | 180 |
HogSay(hh[0], loc("Hahahaha!"), SAY_SHOUT,2) |
181 |
HogSay(hh[1], loc("Hahahaha!"), SAY_SHOUT,2) |
|
182 |
elseif genCounter == 3000 then |
|
183 |
introStage = 5 |
|
184 |
genCounter = 0 |
|
185 |
end |
|
186 |
||
187 |
elseif introStage == 5 then |
|
188 |
||
5823 | 189 |
--FollowGear(hh[1]) |
5278 | 190 |
|
191 |
if genCounter == 2000 then |
|
5823 | 192 |
watGear = hh[1] |
5278 | 193 |
HogSay(hh[0], loc("..."), SAY_THINK,2) |
194 |
HogSay(hh[1], loc("..."), SAY_THINK,2) |
|
195 |
elseif genCounter == 5000 then |
|
196 |
introStage = 6 |
|
197 |
genCounter = 0 |
|
198 |
end |
|
199 |
||
200 |
elseif introStage == 6 then |
|
201 |
||
5823 | 202 |
--FollowGear(hh[0]) |
5278 | 203 |
|
204 |
if genCounter == 2000 then |
|
5823 | 205 |
watGear = hh[0] |
5278 | 206 |
HogSay(hh[0], loc("It's a good thing SUDDEN DEATH is 99 turns away..."), SAY_THINK,2) |
207 |
elseif genCounter == 6000 then |
|
208 |
introStage = 7 |
|
209 |
genCounter = 0 |
|
210 |
end |
|
211 |
||
212 |
||
213 |
elseif introStage == 7 then |
|
214 |
||
215 |
if genCounter == 2000 then |
|
216 |
introStage = 110 |
|
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 | 219 |
SetInputMask(0xFFFFFFFF) |
5278 | 220 |
end |
221 |
||
222 |
end |
|
223 |
||
224 |
end |
|
225 |
||
226 |
-- start the water rising when the intro is finished |
|
227 |
if introStage == 110 then |
|
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 | 234 |
waterCounter = waterCounter + 1 |
235 |
if (waterCounter == 100) and (waterPix < 1615) then |
|
236 |
waterCounter = 0 |
|
237 |
SetTag(AddGear(0, 0, gtWaterUp, 0, 0, 0, 0), 1) |
|
238 |
waterPix = waterPix +1 |
|
239 |
--AddCaption(waterPix) |
|
240 |
||
241 |
if (waterPix >= 1615) and (GameOver == false) then |
|
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 | 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 | 247 |
|
11009 | 248 |
-- Do not count drowning hedgehogs |
249 |
local hhLeft = hhCount |
|
250 |
for i=1,#hh do |
|
251 |
local isDrowning = band(GetState(hh[i]),gstDrowning) ~= 0 |
|
252 |
if isDrowning then |
|
253 |
hhLeft = hhLeft - 1 |
|
254 |
end |
|
5823 | 255 |
end |
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 | 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 | 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 | 265 |
end |
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 | 270 |
|
5278 | 271 |
end |
272 |
||
273 |
end |
|
274 |
||
275 |
end |
|
276 |
end |
|
277 |
||
278 |
||
279 |
function onAmmoStoreInit() |
|
280 |
||
281 |
SetAmmo(amBazooka, 9, 0, 0, 0) |
|
282 |
||
283 |
SetAmmo(amRope, 9, 0, 0, 0) |
|
284 |
SetAmmo(amParachute, 9, 0, 0, 0) |
|
285 |
SetAmmo(amJetpack, 2, 0, 0, 2) |
|
286 |
||
287 |
SetAmmo(amGirder, 9, 0, 0, 0) |
|
288 |
SetAmmo(amBaseballBat, 9, 0, 0, 0) |
|
289 |
||
290 |
SetAmmo(amTeleport, 1, 0, 0, 1) |
|
291 |
SetAmmo(amPortalGun, 3, 0, 0, 1) |
|
292 |
||
293 |
SetAmmo(amLowGravity, 0, 0, 0, 1) |
|
294 |
||
295 |
end |
|
296 |
||
297 |
function onGearDelete(gear) |
|
298 |
||
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 | 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 | 303 |
end |
304 |
end |
|
305 |
||
306 |
if ((gear == player) or (hhCount == 0)) and (GameOver == false) then |
|
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 | 309 |
if gear == player then |
310 |
SendStat(siCustomAchievement, loc("Your hedgehog died!")) |
|
311 |
SendStat(siCustomAchievement, loc("You must survive the flood in order to score.")) |
|
312 |
else |
|
313 |
SendStat(siCustomAchievement, loc("You haven't rescued anyone.")) |
|
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 | 320 |
|
14595
c5f18710a184
Remove "loser" messages in challenges
Wuzzy <Wuzzy2@mail.ru>
parents:
14583
diff
changeset
|
321 |
SendStat(siGameResult, loc("Challenge failed!")) |
5278 | 322 |
GameOver = true |
11009 | 323 |
EndGame() |
5278 | 324 |
end |
325 |
||
326 |
end |