author | Wuzzy <almikes@aol.com> |
Wed, 11 Oct 2017 18:39:19 +0200 | |
changeset 12694 | 5b135c26f320 |
parent 12229 | d62d6f8ebef1 |
child 13039 | fe9c12209f15 |
permissions | -rw-r--r-- |
11034
a9bafac12634
Add Wuzzy's SpeedShoppa challenges.
mikade <redgrinner@gmail.com>
parents:
diff
changeset
|
1 |
--[=[ |
a9bafac12634
Add Wuzzy's SpeedShoppa challenges.
mikade <redgrinner@gmail.com>
parents:
diff
changeset
|
2 |
Speed Shoppa Mission Framework for Hedgewars |
a9bafac12634
Add Wuzzy's SpeedShoppa challenges.
mikade <redgrinner@gmail.com>
parents:
diff
changeset
|
3 |
|
a9bafac12634
Add Wuzzy's SpeedShoppa challenges.
mikade <redgrinner@gmail.com>
parents:
diff
changeset
|
4 |
This is a simple library intended to make setting up simple training missions a trivial |
a9bafac12634
Add Wuzzy's SpeedShoppa challenges.
mikade <redgrinner@gmail.com>
parents:
diff
changeset
|
5 |
task. The library has been created to reduce redundancy in Lua scripts. |
a9bafac12634
Add Wuzzy's SpeedShoppa challenges.
mikade <redgrinner@gmail.com>
parents:
diff
changeset
|
6 |
|
a9bafac12634
Add Wuzzy's SpeedShoppa challenges.
mikade <redgrinner@gmail.com>
parents:
diff
changeset
|
7 |
The framework generates complete and fully Speed Shoppa missions by just |
a9bafac12634
Add Wuzzy's SpeedShoppa challenges.
mikade <redgrinner@gmail.com>
parents:
diff
changeset
|
8 |
one function call. |
a9bafac12634
Add Wuzzy's SpeedShoppa challenges.
mikade <redgrinner@gmail.com>
parents:
diff
changeset
|
9 |
|
a9bafac12634
Add Wuzzy's SpeedShoppa challenges.
mikade <redgrinner@gmail.com>
parents:
diff
changeset
|
10 |
The missions generated by this script are all the same: |
a9bafac12634
Add Wuzzy's SpeedShoppa challenges.
mikade <redgrinner@gmail.com>
parents:
diff
changeset
|
11 |
- The player will get a team with a single hedgehog. |
a9bafac12634
Add Wuzzy's SpeedShoppa challenges.
mikade <redgrinner@gmail.com>
parents:
diff
changeset
|
12 |
- The team gets infinite ropes. |
a9bafac12634
Add Wuzzy's SpeedShoppa challenges.
mikade <redgrinner@gmail.com>
parents:
diff
changeset
|
13 |
- A fixed set of crates will spawn at predefined positions. |
a9bafac12634
Add Wuzzy's SpeedShoppa challenges.
mikade <redgrinner@gmail.com>
parents:
diff
changeset
|
14 |
- The mission ends successfully when all crates have been collected |
a9bafac12634
Add Wuzzy's SpeedShoppa challenges.
mikade <redgrinner@gmail.com>
parents:
diff
changeset
|
15 |
- The mission ends unsuccessfully when the time runs out or the hedgehog dies |
a9bafac12634
Add Wuzzy's SpeedShoppa challenges.
mikade <redgrinner@gmail.com>
parents:
diff
changeset
|
16 |
- When the mission ends, the time it took to finish the mission is shown |
a9bafac12634
Add Wuzzy's SpeedShoppa challenges.
mikade <redgrinner@gmail.com>
parents:
diff
changeset
|
17 |
|
a9bafac12634
Add Wuzzy's SpeedShoppa challenges.
mikade <redgrinner@gmail.com>
parents:
diff
changeset
|
18 |
To use this library, you first have to load it and to call SpeedShoppaMission once with |
a9bafac12634
Add Wuzzy's SpeedShoppa challenges.
mikade <redgrinner@gmail.com>
parents:
diff
changeset
|
19 |
the appropriate parameters. Really, that’s all! |
a9bafac12634
Add Wuzzy's SpeedShoppa challenges.
mikade <redgrinner@gmail.com>
parents:
diff
changeset
|
20 |
See the comment of SpeedShoppaMission for a specification of all parameters. |
a9bafac12634
Add Wuzzy's SpeedShoppa challenges.
mikade <redgrinner@gmail.com>
parents:
diff
changeset
|
21 |
|
a9bafac12634
Add Wuzzy's SpeedShoppa challenges.
mikade <redgrinner@gmail.com>
parents:
diff
changeset
|
22 |
]=] |
a9bafac12634
Add Wuzzy's SpeedShoppa challenges.
mikade <redgrinner@gmail.com>
parents:
diff
changeset
|
23 |
|
a9bafac12634
Add Wuzzy's SpeedShoppa challenges.
mikade <redgrinner@gmail.com>
parents:
diff
changeset
|
24 |
HedgewarsScriptLoad("/Scripts/Locale.lua") |
a9bafac12634
Add Wuzzy's SpeedShoppa challenges.
mikade <redgrinner@gmail.com>
parents:
diff
changeset
|
25 |
|
a9bafac12634
Add Wuzzy's SpeedShoppa challenges.
mikade <redgrinner@gmail.com>
parents:
diff
changeset
|
26 |
--[[ |
a9bafac12634
Add Wuzzy's SpeedShoppa challenges.
mikade <redgrinner@gmail.com>
parents:
diff
changeset
|
27 |
SpeedShoppaMission(params) |
a9bafac12634
Add Wuzzy's SpeedShoppa challenges.
mikade <redgrinner@gmail.com>
parents:
diff
changeset
|
28 |
|
a9bafac12634
Add Wuzzy's SpeedShoppa challenges.
mikade <redgrinner@gmail.com>
parents:
diff
changeset
|
29 |
This function sets up the *entire* mission and needs one argument: params. |
a9bafac12634
Add Wuzzy's SpeedShoppa challenges.
mikade <redgrinner@gmail.com>
parents:
diff
changeset
|
30 |
The argument “params” is a table containing fields which describe the training mission. |
a9bafac12634
Add Wuzzy's SpeedShoppa challenges.
mikade <redgrinner@gmail.com>
parents:
diff
changeset
|
31 |
mandatory fields: |
a9bafac12634
Add Wuzzy's SpeedShoppa challenges.
mikade <redgrinner@gmail.com>
parents:
diff
changeset
|
32 |
- map: the name of the map to be used |
a9bafac12634
Add Wuzzy's SpeedShoppa challenges.
mikade <redgrinner@gmail.com>
parents:
diff
changeset
|
33 |
- theme: the name of the theme (does not need to be a standalone theme) |
a9bafac12634
Add Wuzzy's SpeedShoppa challenges.
mikade <redgrinner@gmail.com>
parents:
diff
changeset
|
34 |
- time: the time limit in milliseconds |
a9bafac12634
Add Wuzzy's SpeedShoppa challenges.
mikade <redgrinner@gmail.com>
parents:
diff
changeset
|
35 |
- crates: The coordinates of where the crates will be spawned. |
a9bafac12634
Add Wuzzy's SpeedShoppa challenges.
mikade <redgrinner@gmail.com>
parents:
diff
changeset
|
36 |
It is a table containing tables containing coordinates of format |
a9bafac12634
Add Wuzzy's SpeedShoppa challenges.
mikade <redgrinner@gmail.com>
parents:
diff
changeset
|
37 |
{ x=value, y=value }. Example: |
a9bafac12634
Add Wuzzy's SpeedShoppa challenges.
mikade <redgrinner@gmail.com>
parents:
diff
changeset
|
38 |
crates = { |
a9bafac12634
Add Wuzzy's SpeedShoppa challenges.
mikade <redgrinner@gmail.com>
parents:
diff
changeset
|
39 |
{ x = 324, y = 43 }, |
a9bafac12634
Add Wuzzy's SpeedShoppa challenges.
mikade <redgrinner@gmail.com>
parents:
diff
changeset
|
40 |
{ x = 123, y = 56 }, |
a9bafac12634
Add Wuzzy's SpeedShoppa challenges.
mikade <redgrinner@gmail.com>
parents:
diff
changeset
|
41 |
{ x = 6, y = 0 }, |
a9bafac12634
Add Wuzzy's SpeedShoppa challenges.
mikade <redgrinner@gmail.com>
parents:
diff
changeset
|
42 |
} |
a9bafac12634
Add Wuzzy's SpeedShoppa challenges.
mikade <redgrinner@gmail.com>
parents:
diff
changeset
|
43 |
There must be at least 1 crate. |
a9bafac12634
Add Wuzzy's SpeedShoppa challenges.
mikade <redgrinner@gmail.com>
parents:
diff
changeset
|
44 |
|
a9bafac12634
Add Wuzzy's SpeedShoppa challenges.
mikade <redgrinner@gmail.com>
parents:
diff
changeset
|
45 |
optional fields: |
a9bafac12634
Add Wuzzy's SpeedShoppa challenges.
mikade <redgrinner@gmail.com>
parents:
diff
changeset
|
46 |
- missionTitle: the name of the mission (optional but highly recommended) (default: "Speed Shoppa") |
a9bafac12634
Add Wuzzy's SpeedShoppa challenges.
mikade <redgrinner@gmail.com>
parents:
diff
changeset
|
47 |
- hogHat: hat of the hedgehog (default: "NoHat") |
a9bafac12634
Add Wuzzy's SpeedShoppa challenges.
mikade <redgrinner@gmail.com>
parents:
diff
changeset
|
48 |
- hogName: name of the hedgehog (default: "Roper") |
a9bafac12634
Add Wuzzy's SpeedShoppa challenges.
mikade <redgrinner@gmail.com>
parents:
diff
changeset
|
49 |
- teamName: name of the hedgehog’s team (default: "Shoppers") |
a9bafac12634
Add Wuzzy's SpeedShoppa challenges.
mikade <redgrinner@gmail.com>
parents:
diff
changeset
|
50 |
- teamGrave: name of the hedgehog’s grave (default: "Statue") |
a9bafac12634
Add Wuzzy's SpeedShoppa challenges.
mikade <redgrinner@gmail.com>
parents:
diff
changeset
|
51 |
- teamFlag: name of the team’s flag (default: "cm_shoppa") |
a9bafac12634
Add Wuzzy's SpeedShoppa challenges.
mikade <redgrinner@gmail.com>
parents:
diff
changeset
|
52 |
- clanColor: color of the (only) clan (default: 0xFF0204, which is a red tone) |
a9bafac12634
Add Wuzzy's SpeedShoppa challenges.
mikade <redgrinner@gmail.com>
parents:
diff
changeset
|
53 |
- goalText: A short string explaining the goal of the mission |
a9bafac12634
Add Wuzzy's SpeedShoppa challenges.
mikade <redgrinner@gmail.com>
parents:
diff
changeset
|
54 |
(default: "Use your rope to collect all crates as fast as possible.") |
a9bafac12634
Add Wuzzy's SpeedShoppa challenges.
mikade <redgrinner@gmail.com>
parents:
diff
changeset
|
55 |
- faceLeft: If true, the hog faces to the left initially, if false, it faces to the right. |
a9bafac12634
Add Wuzzy's SpeedShoppa challenges.
mikade <redgrinner@gmail.com>
parents:
diff
changeset
|
56 |
(default: false (=right)) |
a9bafac12634
Add Wuzzy's SpeedShoppa challenges.
mikade <redgrinner@gmail.com>
parents:
diff
changeset
|
57 |
- crateType Specify the type of crate (this has no gameplay effect), pick one of |
a9bafac12634
Add Wuzzy's SpeedShoppa challenges.
mikade <redgrinner@gmail.com>
parents:
diff
changeset
|
58 |
"ammo", "utility", "health". Default: "ammo" |
a9bafac12634
Add Wuzzy's SpeedShoppa challenges.
mikade <redgrinner@gmail.com>
parents:
diff
changeset
|
59 |
- extra_onGameStart: A function which is called at the end of this script's onGameStart. It takes no parameters. |
a9bafac12634
Add Wuzzy's SpeedShoppa challenges.
mikade <redgrinner@gmail.com>
parents:
diff
changeset
|
60 |
You could use this to spawn additional gears like girders or mines. |
a9bafac12634
Add Wuzzy's SpeedShoppa challenges.
mikade <redgrinner@gmail.com>
parents:
diff
changeset
|
61 |
- extra_onGameInit: A function which is called at the end of this script's onGameInit. |
a9bafac12634
Add Wuzzy's SpeedShoppa challenges.
mikade <redgrinner@gmail.com>
parents:
diff
changeset
|
62 |
]] |
a9bafac12634
Add Wuzzy's SpeedShoppa challenges.
mikade <redgrinner@gmail.com>
parents:
diff
changeset
|
63 |
|
a9bafac12634
Add Wuzzy's SpeedShoppa challenges.
mikade <redgrinner@gmail.com>
parents:
diff
changeset
|
64 |
|
a9bafac12634
Add Wuzzy's SpeedShoppa challenges.
mikade <redgrinner@gmail.com>
parents:
diff
changeset
|
65 |
local playerHog |
a9bafac12634
Add Wuzzy's SpeedShoppa challenges.
mikade <redgrinner@gmail.com>
parents:
diff
changeset
|
66 |
local gameStarted = false |
a9bafac12634
Add Wuzzy's SpeedShoppa challenges.
mikade <redgrinner@gmail.com>
parents:
diff
changeset
|
67 |
local cratesCollected = 0 |
a9bafac12634
Add Wuzzy's SpeedShoppa challenges.
mikade <redgrinner@gmail.com>
parents:
diff
changeset
|
68 |
local gameEnded = false |
a9bafac12634
Add Wuzzy's SpeedShoppa challenges.
mikade <redgrinner@gmail.com>
parents:
diff
changeset
|
69 |
local timeOut = false |
a9bafac12634
Add Wuzzy's SpeedShoppa challenges.
mikade <redgrinner@gmail.com>
parents:
diff
changeset
|
70 |
local hogHurt = false |
a9bafac12634
Add Wuzzy's SpeedShoppa challenges.
mikade <redgrinner@gmail.com>
parents:
diff
changeset
|
71 |
local endTime |
a9bafac12634
Add Wuzzy's SpeedShoppa challenges.
mikade <redgrinner@gmail.com>
parents:
diff
changeset
|
72 |
|
a9bafac12634
Add Wuzzy's SpeedShoppa challenges.
mikade <redgrinner@gmail.com>
parents:
diff
changeset
|
73 |
local crates |
a9bafac12634
Add Wuzzy's SpeedShoppa challenges.
mikade <redgrinner@gmail.com>
parents:
diff
changeset
|
74 |
|
a9bafac12634
Add Wuzzy's SpeedShoppa challenges.
mikade <redgrinner@gmail.com>
parents:
diff
changeset
|
75 |
function SpeedShoppaMission(params) |
a9bafac12634
Add Wuzzy's SpeedShoppa challenges.
mikade <redgrinner@gmail.com>
parents:
diff
changeset
|
76 |
if params.hogHat == nil then params.hogHat = "NoHat" end |
a9bafac12634
Add Wuzzy's SpeedShoppa challenges.
mikade <redgrinner@gmail.com>
parents:
diff
changeset
|
77 |
if params.hogName == nil then params.hogName = loc("Roper") end |
a9bafac12634
Add Wuzzy's SpeedShoppa challenges.
mikade <redgrinner@gmail.com>
parents:
diff
changeset
|
78 |
if params.teamName == nil then params.teamName = loc("Shoppers") end |
a9bafac12634
Add Wuzzy's SpeedShoppa challenges.
mikade <redgrinner@gmail.com>
parents:
diff
changeset
|
79 |
if params.goalText == nil then params.goalText = loc("Use your rope to collect all crates as fast as possible.") end |
a9bafac12634
Add Wuzzy's SpeedShoppa challenges.
mikade <redgrinner@gmail.com>
parents:
diff
changeset
|
80 |
if params.missionTitle == nil then params.missionTitle = loc("Speed Shoppa") end |
a9bafac12634
Add Wuzzy's SpeedShoppa challenges.
mikade <redgrinner@gmail.com>
parents:
diff
changeset
|
81 |
if params.clanColor == nil then params.clanColor = 0xFF0204 end |
a9bafac12634
Add Wuzzy's SpeedShoppa challenges.
mikade <redgrinner@gmail.com>
parents:
diff
changeset
|
82 |
if params.teamGrave == nil then params.teamGrave = "Statue" end |
a9bafac12634
Add Wuzzy's SpeedShoppa challenges.
mikade <redgrinner@gmail.com>
parents:
diff
changeset
|
83 |
if params.teamFlag == nil then params.teamFlag = "cm_shoppa" end |
a9bafac12634
Add Wuzzy's SpeedShoppa challenges.
mikade <redgrinner@gmail.com>
parents:
diff
changeset
|
84 |
if params.extra_onGameInit == nil then params.extra_onGameInit = function() end end |
a9bafac12634
Add Wuzzy's SpeedShoppa challenges.
mikade <redgrinner@gmail.com>
parents:
diff
changeset
|
85 |
if params.extra_onGameStart == nil then params.extra_onGameStart = function() end end |
a9bafac12634
Add Wuzzy's SpeedShoppa challenges.
mikade <redgrinner@gmail.com>
parents:
diff
changeset
|
86 |
if params.faceLeft == nil then params.faceLeft = false end |
a9bafac12634
Add Wuzzy's SpeedShoppa challenges.
mikade <redgrinner@gmail.com>
parents:
diff
changeset
|
87 |
|
a9bafac12634
Add Wuzzy's SpeedShoppa challenges.
mikade <redgrinner@gmail.com>
parents:
diff
changeset
|
88 |
crates = params.crates |
a9bafac12634
Add Wuzzy's SpeedShoppa challenges.
mikade <redgrinner@gmail.com>
parents:
diff
changeset
|
89 |
startTime = params.time |
a9bafac12634
Add Wuzzy's SpeedShoppa challenges.
mikade <redgrinner@gmail.com>
parents:
diff
changeset
|
90 |
|
a9bafac12634
Add Wuzzy's SpeedShoppa challenges.
mikade <redgrinner@gmail.com>
parents:
diff
changeset
|
91 |
_G.onGameInit = function() |
a9bafac12634
Add Wuzzy's SpeedShoppa challenges.
mikade <redgrinner@gmail.com>
parents:
diff
changeset
|
92 |
GameFlags = gfDisableWind + gfOneClanMode + gfBorder + gfSolidLand |
a9bafac12634
Add Wuzzy's SpeedShoppa challenges.
mikade <redgrinner@gmail.com>
parents:
diff
changeset
|
93 |
TurnTime = startTime |
a9bafac12634
Add Wuzzy's SpeedShoppa challenges.
mikade <redgrinner@gmail.com>
parents:
diff
changeset
|
94 |
CaseFreq = 0 |
a9bafac12634
Add Wuzzy's SpeedShoppa challenges.
mikade <redgrinner@gmail.com>
parents:
diff
changeset
|
95 |
MinesNum = 0 |
a9bafac12634
Add Wuzzy's SpeedShoppa challenges.
mikade <redgrinner@gmail.com>
parents:
diff
changeset
|
96 |
Explosives = 0 |
a9bafac12634
Add Wuzzy's SpeedShoppa challenges.
mikade <redgrinner@gmail.com>
parents:
diff
changeset
|
97 |
Delay = 10 |
a9bafac12634
Add Wuzzy's SpeedShoppa challenges.
mikade <redgrinner@gmail.com>
parents:
diff
changeset
|
98 |
Theme = params.theme |
a9bafac12634
Add Wuzzy's SpeedShoppa challenges.
mikade <redgrinner@gmail.com>
parents:
diff
changeset
|
99 |
Map = params.map |
12229
d62d6f8ebef1
Disable Sudden Death consistently in all missions which don't require it
Wuzzy <almikes@aol.com>
parents:
11034
diff
changeset
|
100 |
-- Disable Sudden Death |
d62d6f8ebef1
Disable Sudden Death consistently in all missions which don't require it
Wuzzy <almikes@aol.com>
parents:
11034
diff
changeset
|
101 |
WaterRise = 0 |
d62d6f8ebef1
Disable Sudden Death consistently in all missions which don't require it
Wuzzy <almikes@aol.com>
parents:
11034
diff
changeset
|
102 |
HealthDecrease = 0 |
11034
a9bafac12634
Add Wuzzy's SpeedShoppa challenges.
mikade <redgrinner@gmail.com>
parents:
diff
changeset
|
103 |
|
a9bafac12634
Add Wuzzy's SpeedShoppa challenges.
mikade <redgrinner@gmail.com>
parents:
diff
changeset
|
104 |
AddTeam(params.teamName, params.clanColor, params.teamGrave, "Castle", "Default", params.teamFlag) |
a9bafac12634
Add Wuzzy's SpeedShoppa challenges.
mikade <redgrinner@gmail.com>
parents:
diff
changeset
|
105 |
playerHog = AddHog(params.hogName, 0, 1, params.hogHat) |
a9bafac12634
Add Wuzzy's SpeedShoppa challenges.
mikade <redgrinner@gmail.com>
parents:
diff
changeset
|
106 |
HogTurnLeft(playerHog, params.faceLeft) |
a9bafac12634
Add Wuzzy's SpeedShoppa challenges.
mikade <redgrinner@gmail.com>
parents:
diff
changeset
|
107 |
|
a9bafac12634
Add Wuzzy's SpeedShoppa challenges.
mikade <redgrinner@gmail.com>
parents:
diff
changeset
|
108 |
SetGearPosition(playerHog, params.hog_x, params.hog_y) |
a9bafac12634
Add Wuzzy's SpeedShoppa challenges.
mikade <redgrinner@gmail.com>
parents:
diff
changeset
|
109 |
|
a9bafac12634
Add Wuzzy's SpeedShoppa challenges.
mikade <redgrinner@gmail.com>
parents:
diff
changeset
|
110 |
params.extra_onGameInit() |
a9bafac12634
Add Wuzzy's SpeedShoppa challenges.
mikade <redgrinner@gmail.com>
parents:
diff
changeset
|
111 |
end |
a9bafac12634
Add Wuzzy's SpeedShoppa challenges.
mikade <redgrinner@gmail.com>
parents:
diff
changeset
|
112 |
|
a9bafac12634
Add Wuzzy's SpeedShoppa challenges.
mikade <redgrinner@gmail.com>
parents:
diff
changeset
|
113 |
_G.onAmmoStoreInit = function() |
a9bafac12634
Add Wuzzy's SpeedShoppa challenges.
mikade <redgrinner@gmail.com>
parents:
diff
changeset
|
114 |
SetAmmo(amRope, 9, 0, 0, 1) |
a9bafac12634
Add Wuzzy's SpeedShoppa challenges.
mikade <redgrinner@gmail.com>
parents:
diff
changeset
|
115 |
end |
a9bafac12634
Add Wuzzy's SpeedShoppa challenges.
mikade <redgrinner@gmail.com>
parents:
diff
changeset
|
116 |
|
a9bafac12634
Add Wuzzy's SpeedShoppa challenges.
mikade <redgrinner@gmail.com>
parents:
diff
changeset
|
117 |
_G.onGameStart = function() |
a9bafac12634
Add Wuzzy's SpeedShoppa challenges.
mikade <redgrinner@gmail.com>
parents:
diff
changeset
|
118 |
SendHealthStatsOff() |
a9bafac12634
Add Wuzzy's SpeedShoppa challenges.
mikade <redgrinner@gmail.com>
parents:
diff
changeset
|
119 |
ShowMission(params.missionTitle, loc("Challenge"), params.goalText, -amRope, 5000) |
a9bafac12634
Add Wuzzy's SpeedShoppa challenges.
mikade <redgrinner@gmail.com>
parents:
diff
changeset
|
120 |
for i=1,#crates do |
a9bafac12634
Add Wuzzy's SpeedShoppa challenges.
mikade <redgrinner@gmail.com>
parents:
diff
changeset
|
121 |
spawnCrate(crates[i].x, crates[i].y) |
a9bafac12634
Add Wuzzy's SpeedShoppa challenges.
mikade <redgrinner@gmail.com>
parents:
diff
changeset
|
122 |
end |
a9bafac12634
Add Wuzzy's SpeedShoppa challenges.
mikade <redgrinner@gmail.com>
parents:
diff
changeset
|
123 |
params.extra_onGameStart() |
a9bafac12634
Add Wuzzy's SpeedShoppa challenges.
mikade <redgrinner@gmail.com>
parents:
diff
changeset
|
124 |
end |
a9bafac12634
Add Wuzzy's SpeedShoppa challenges.
mikade <redgrinner@gmail.com>
parents:
diff
changeset
|
125 |
|
a9bafac12634
Add Wuzzy's SpeedShoppa challenges.
mikade <redgrinner@gmail.com>
parents:
diff
changeset
|
126 |
_G.onNewTurn = function() |
a9bafac12634
Add Wuzzy's SpeedShoppa challenges.
mikade <redgrinner@gmail.com>
parents:
diff
changeset
|
127 |
SetWeapon(amRope) |
a9bafac12634
Add Wuzzy's SpeedShoppa challenges.
mikade <redgrinner@gmail.com>
parents:
diff
changeset
|
128 |
gameStarted = true |
a9bafac12634
Add Wuzzy's SpeedShoppa challenges.
mikade <redgrinner@gmail.com>
parents:
diff
changeset
|
129 |
end |
a9bafac12634
Add Wuzzy's SpeedShoppa challenges.
mikade <redgrinner@gmail.com>
parents:
diff
changeset
|
130 |
_G.onGearDelete = function(gear) |
a9bafac12634
Add Wuzzy's SpeedShoppa challenges.
mikade <redgrinner@gmail.com>
parents:
diff
changeset
|
131 |
if GetGearType(gear) == gtCase and not hogHurt and not timeOut then |
a9bafac12634
Add Wuzzy's SpeedShoppa challenges.
mikade <redgrinner@gmail.com>
parents:
diff
changeset
|
132 |
cratesCollected = cratesCollected + 1 |
a9bafac12634
Add Wuzzy's SpeedShoppa challenges.
mikade <redgrinner@gmail.com>
parents:
diff
changeset
|
133 |
PlaySound(sndShotgunReload) |
a9bafac12634
Add Wuzzy's SpeedShoppa challenges.
mikade <redgrinner@gmail.com>
parents:
diff
changeset
|
134 |
if cratesCollected == #crates then |
a9bafac12634
Add Wuzzy's SpeedShoppa challenges.
mikade <redgrinner@gmail.com>
parents:
diff
changeset
|
135 |
endTime = TurnTimeLeft |
a9bafac12634
Add Wuzzy's SpeedShoppa challenges.
mikade <redgrinner@gmail.com>
parents:
diff
changeset
|
136 |
finalize() |
a9bafac12634
Add Wuzzy's SpeedShoppa challenges.
mikade <redgrinner@gmail.com>
parents:
diff
changeset
|
137 |
else |
a9bafac12634
Add Wuzzy's SpeedShoppa challenges.
mikade <redgrinner@gmail.com>
parents:
diff
changeset
|
138 |
AddCaption(string.format(loc("%d crate(s) remaining"), #crates - cratesCollected)) |
a9bafac12634
Add Wuzzy's SpeedShoppa challenges.
mikade <redgrinner@gmail.com>
parents:
diff
changeset
|
139 |
end |
a9bafac12634
Add Wuzzy's SpeedShoppa challenges.
mikade <redgrinner@gmail.com>
parents:
diff
changeset
|
140 |
elseif gear == playerHog then |
a9bafac12634
Add Wuzzy's SpeedShoppa challenges.
mikade <redgrinner@gmail.com>
parents:
diff
changeset
|
141 |
finalize() |
a9bafac12634
Add Wuzzy's SpeedShoppa challenges.
mikade <redgrinner@gmail.com>
parents:
diff
changeset
|
142 |
end |
a9bafac12634
Add Wuzzy's SpeedShoppa challenges.
mikade <redgrinner@gmail.com>
parents:
diff
changeset
|
143 |
end |
a9bafac12634
Add Wuzzy's SpeedShoppa challenges.
mikade <redgrinner@gmail.com>
parents:
diff
changeset
|
144 |
|
a9bafac12634
Add Wuzzy's SpeedShoppa challenges.
mikade <redgrinner@gmail.com>
parents:
diff
changeset
|
145 |
_G.onGearDamage = function(gear) |
a9bafac12634
Add Wuzzy's SpeedShoppa challenges.
mikade <redgrinner@gmail.com>
parents:
diff
changeset
|
146 |
if gear == playerHog then |
a9bafac12634
Add Wuzzy's SpeedShoppa challenges.
mikade <redgrinner@gmail.com>
parents:
diff
changeset
|
147 |
hogHurt = true |
a9bafac12634
Add Wuzzy's SpeedShoppa challenges.
mikade <redgrinner@gmail.com>
parents:
diff
changeset
|
148 |
end |
a9bafac12634
Add Wuzzy's SpeedShoppa challenges.
mikade <redgrinner@gmail.com>
parents:
diff
changeset
|
149 |
end |
a9bafac12634
Add Wuzzy's SpeedShoppa challenges.
mikade <redgrinner@gmail.com>
parents:
diff
changeset
|
150 |
|
a9bafac12634
Add Wuzzy's SpeedShoppa challenges.
mikade <redgrinner@gmail.com>
parents:
diff
changeset
|
151 |
|
a9bafac12634
Add Wuzzy's SpeedShoppa challenges.
mikade <redgrinner@gmail.com>
parents:
diff
changeset
|
152 |
_G.onGameTick20 = function() |
a9bafac12634
Add Wuzzy's SpeedShoppa challenges.
mikade <redgrinner@gmail.com>
parents:
diff
changeset
|
153 |
if TurnTimeLeft < 40 and TurnTimeLeft > 0 and gameStarted and not timeOut and not gameEnded then |
a9bafac12634
Add Wuzzy's SpeedShoppa challenges.
mikade <redgrinner@gmail.com>
parents:
diff
changeset
|
154 |
timeOut = true |
a9bafac12634
Add Wuzzy's SpeedShoppa challenges.
mikade <redgrinner@gmail.com>
parents:
diff
changeset
|
155 |
AddCaption(loc("Time's up!")) |
a9bafac12634
Add Wuzzy's SpeedShoppa challenges.
mikade <redgrinner@gmail.com>
parents:
diff
changeset
|
156 |
SetHealth(playerHog, 0) |
a9bafac12634
Add Wuzzy's SpeedShoppa challenges.
mikade <redgrinner@gmail.com>
parents:
diff
changeset
|
157 |
hogHurt = true |
a9bafac12634
Add Wuzzy's SpeedShoppa challenges.
mikade <redgrinner@gmail.com>
parents:
diff
changeset
|
158 |
end |
a9bafac12634
Add Wuzzy's SpeedShoppa challenges.
mikade <redgrinner@gmail.com>
parents:
diff
changeset
|
159 |
end |
a9bafac12634
Add Wuzzy's SpeedShoppa challenges.
mikade <redgrinner@gmail.com>
parents:
diff
changeset
|
160 |
|
a9bafac12634
Add Wuzzy's SpeedShoppa challenges.
mikade <redgrinner@gmail.com>
parents:
diff
changeset
|
161 |
_G.finalize = function() |
a9bafac12634
Add Wuzzy's SpeedShoppa challenges.
mikade <redgrinner@gmail.com>
parents:
diff
changeset
|
162 |
if not gameEnded then |
a9bafac12634
Add Wuzzy's SpeedShoppa challenges.
mikade <redgrinner@gmail.com>
parents:
diff
changeset
|
163 |
if cratesCollected == #crates then |
a9bafac12634
Add Wuzzy's SpeedShoppa challenges.
mikade <redgrinner@gmail.com>
parents:
diff
changeset
|
164 |
PlaySound(sndVictory, playerHog) |
a9bafac12634
Add Wuzzy's SpeedShoppa challenges.
mikade <redgrinner@gmail.com>
parents:
diff
changeset
|
165 |
SetState(playerHog, bor(GetState(playerHog), gstWinner)) |
a9bafac12634
Add Wuzzy's SpeedShoppa challenges.
mikade <redgrinner@gmail.com>
parents:
diff
changeset
|
166 |
SetState(playerHog, band(GetState(playerHog), bnot(gstHHDriven))) |
a9bafac12634
Add Wuzzy's SpeedShoppa challenges.
mikade <redgrinner@gmail.com>
parents:
diff
changeset
|
167 |
AddCaption(loc("Challenge completed!")) |
a9bafac12634
Add Wuzzy's SpeedShoppa challenges.
mikade <redgrinner@gmail.com>
parents:
diff
changeset
|
168 |
SendStat(siGameResult, loc("Challenge completed!")) |
a9bafac12634
Add Wuzzy's SpeedShoppa challenges.
mikade <redgrinner@gmail.com>
parents:
diff
changeset
|
169 |
SendStat(siPointType, loc("milliseconds")) |
a9bafac12634
Add Wuzzy's SpeedShoppa challenges.
mikade <redgrinner@gmail.com>
parents:
diff
changeset
|
170 |
local time = startTime - endTime |
a9bafac12634
Add Wuzzy's SpeedShoppa challenges.
mikade <redgrinner@gmail.com>
parents:
diff
changeset
|
171 |
SendStat(siPlayerKills, tostring(time), params.teamName) |
a9bafac12634
Add Wuzzy's SpeedShoppa challenges.
mikade <redgrinner@gmail.com>
parents:
diff
changeset
|
172 |
SendStat(siCustomAchievement, string.format(loc("You have finished the challenge in %.3f s."), (time/1000))) |
a9bafac12634
Add Wuzzy's SpeedShoppa challenges.
mikade <redgrinner@gmail.com>
parents:
diff
changeset
|
173 |
TurnTimeLeft = 0 |
a9bafac12634
Add Wuzzy's SpeedShoppa challenges.
mikade <redgrinner@gmail.com>
parents:
diff
changeset
|
174 |
else |
a9bafac12634
Add Wuzzy's SpeedShoppa challenges.
mikade <redgrinner@gmail.com>
parents:
diff
changeset
|
175 |
SendStat(siGameResult, loc("Challenge failed!")) |
a9bafac12634
Add Wuzzy's SpeedShoppa challenges.
mikade <redgrinner@gmail.com>
parents:
diff
changeset
|
176 |
SendStat(siPointType, loc("crate(s)")) |
a9bafac12634
Add Wuzzy's SpeedShoppa challenges.
mikade <redgrinner@gmail.com>
parents:
diff
changeset
|
177 |
SendStat(siPlayerKills, tostring(cratesCollected), params.teamName) |
a9bafac12634
Add Wuzzy's SpeedShoppa challenges.
mikade <redgrinner@gmail.com>
parents:
diff
changeset
|
178 |
SendStat(siCustomAchievement, string.format(loc("You have collected %d out of %d crate(s)."), cratesCollected, #crates)) |
a9bafac12634
Add Wuzzy's SpeedShoppa challenges.
mikade <redgrinner@gmail.com>
parents:
diff
changeset
|
179 |
end |
a9bafac12634
Add Wuzzy's SpeedShoppa challenges.
mikade <redgrinner@gmail.com>
parents:
diff
changeset
|
180 |
gameEnded = true |
a9bafac12634
Add Wuzzy's SpeedShoppa challenges.
mikade <redgrinner@gmail.com>
parents:
diff
changeset
|
181 |
EndGame() |
a9bafac12634
Add Wuzzy's SpeedShoppa challenges.
mikade <redgrinner@gmail.com>
parents:
diff
changeset
|
182 |
end |
a9bafac12634
Add Wuzzy's SpeedShoppa challenges.
mikade <redgrinner@gmail.com>
parents:
diff
changeset
|
183 |
end |
a9bafac12634
Add Wuzzy's SpeedShoppa challenges.
mikade <redgrinner@gmail.com>
parents:
diff
changeset
|
184 |
|
a9bafac12634
Add Wuzzy's SpeedShoppa challenges.
mikade <redgrinner@gmail.com>
parents:
diff
changeset
|
185 |
_G.spawnCrate = function(x, y) |
a9bafac12634
Add Wuzzy's SpeedShoppa challenges.
mikade <redgrinner@gmail.com>
parents:
diff
changeset
|
186 |
if params.crateType == "utility" then |
a9bafac12634
Add Wuzzy's SpeedShoppa challenges.
mikade <redgrinner@gmail.com>
parents:
diff
changeset
|
187 |
SpawnFakeUtilityCrate(x, y, false, false) |
a9bafac12634
Add Wuzzy's SpeedShoppa challenges.
mikade <redgrinner@gmail.com>
parents:
diff
changeset
|
188 |
elseif params.crateType == "ammo" then |
a9bafac12634
Add Wuzzy's SpeedShoppa challenges.
mikade <redgrinner@gmail.com>
parents:
diff
changeset
|
189 |
SpawnFakeAmmoCrate(x, y, false, false) |
a9bafac12634
Add Wuzzy's SpeedShoppa challenges.
mikade <redgrinner@gmail.com>
parents:
diff
changeset
|
190 |
elseif params.crateType == "health" then |
a9bafac12634
Add Wuzzy's SpeedShoppa challenges.
mikade <redgrinner@gmail.com>
parents:
diff
changeset
|
191 |
SpawnFakeHealthCrate(x, y, false, false) |
a9bafac12634
Add Wuzzy's SpeedShoppa challenges.
mikade <redgrinner@gmail.com>
parents:
diff
changeset
|
192 |
else |
a9bafac12634
Add Wuzzy's SpeedShoppa challenges.
mikade <redgrinner@gmail.com>
parents:
diff
changeset
|
193 |
SpawnFakeAmmoCrate(x, y, false, false) |
a9bafac12634
Add Wuzzy's SpeedShoppa challenges.
mikade <redgrinner@gmail.com>
parents:
diff
changeset
|
194 |
end |
a9bafac12634
Add Wuzzy's SpeedShoppa challenges.
mikade <redgrinner@gmail.com>
parents:
diff
changeset
|
195 |
end |
a9bafac12634
Add Wuzzy's SpeedShoppa challenges.
mikade <redgrinner@gmail.com>
parents:
diff
changeset
|
196 |
|
a9bafac12634
Add Wuzzy's SpeedShoppa challenges.
mikade <redgrinner@gmail.com>
parents:
diff
changeset
|
197 |
end |