author | Wuzzy <Wuzzy2@mail.ru> |
Mon, 13 May 2019 21:23:25 +0200 | |
changeset 14949 | 4c5fb1ee75b7 |
parent 14611 | c5f18710a184 |
child 14961 | 8b848c2939da |
permissions | -rw-r--r-- |
10413 | 1 |
HedgewarsScriptLoad("/Scripts/Locale.lua") |
2 |
HedgewarsScriptLoad("/Scripts/Utils.lua") |
|
10810
931dd8f42763
add some config params - speed,accel,delaytime,delayheight,nocake. water rise speed, water rise acceleration, time delay from start of turn for water rise, height delay for same, and disable cake. also set start boulder to indestructible
nemo
parents:
10697
diff
changeset
|
3 |
HedgewarsScriptLoad("/Scripts/Params.lua") |
10413 | 4 |
|
5 |
local hTag = nil |
|
6 |
local hTagHeight = 33000 |
|
7 |
local tTag = nil |
|
8 |
local rTag = nil |
|
9 |
local startTime = 0 |
|
10 |
local MaxHeight = 32640 |
|
11 |
local RecordHeight = 33000 |
|
10581 | 12 |
local RecordHeightHogName = nil |
10413 | 13 |
local Fire = {} |
14 |
--local BoomFire = nil |
|
15 |
local HH = {} |
|
10581 | 16 |
local totalHedgehogs = 0 |
17 |
local deadHedgehogs = 0 |
|
10632
5ae7ba0b2849
pretty sure the other teams need stats at 0 for the graph to look right
nemo
parents:
10598
diff
changeset
|
18 |
local currTeam = '' |
5ae7ba0b2849
pretty sure the other teams need stats at 0 for the graph to look right
nemo
parents:
10598
diff
changeset
|
19 |
local teams = {} |
10581 | 20 |
local teamScoreStats = {} |
21 |
local teamBests = {} |
|
11635 | 22 |
local teamTimes = {} |
10413 | 23 |
local MrMine -- in honour of sparkle's first arrival in the cabin |
24 |
local YouWon = false |
|
10581 | 25 |
local YouLost = false |
10580
17560eb73b4c
Reset max team health after script may have screwed with it on start. Maybe a script max health reset function could be useful too. Set climbhome hogs to invulnerable while not their turn if needed to avoid accidental mine/dead hog damage. Tweak cake fire boom a bit.
nemo
parents:
10413
diff
changeset
|
26 |
local HogsAreInvulnerable = false |
10413 | 27 |
local WaterRise = nil |
28 |
local Cake = nil |
|
13155
25de976a7b9a
ClimeHome: Show messages when cake is nearby and when reaching home
Wuzzy <Wuzzy2@mail.ru>
parents:
13023
diff
changeset
|
29 |
local CakeWarning = false |
25de976a7b9a
ClimeHome: Show messages when cake is nearby and when reaching home
Wuzzy <Wuzzy2@mail.ru>
parents:
13023
diff
changeset
|
30 |
local CakeFireWarning = false |
10413 | 31 |
local CakeTries = 0 |
10810
931dd8f42763
add some config params - speed,accel,delaytime,delayheight,nocake. water rise speed, water rise acceleration, time delay from start of turn for water rise, height delay for same, and disable cake. also set start boulder to indestructible
nemo
parents:
10697
diff
changeset
|
32 |
local addCake = true |
13155
25de976a7b9a
ClimeHome: Show messages when cake is nearby and when reaching home
Wuzzy <Wuzzy2@mail.ru>
parents:
13023
diff
changeset
|
33 |
local takeASeat = false |
10413 | 34 |
local Stars = {} |
10581 | 35 |
local tauntNoo = false |
36 |
local jokeAwardNavy = nil |
|
37 |
local jokeAwardSpeed = nil |
|
38 |
local jokeAwardDamage = nil |
|
39 |
local recordBroken = false |
|
40 |
local dummyHog = nil |
|
10592 | 41 |
local dummySkip = 0 |
10810
931dd8f42763
add some config params - speed,accel,delaytime,delayheight,nocake. water rise speed, water rise acceleration, time delay from start of turn for water rise, height delay for same, and disable cake. also set start boulder to indestructible
nemo
parents:
10697
diff
changeset
|
42 |
local baseWaterSpeed = 2 |
931dd8f42763
add some config params - speed,accel,delaytime,delayheight,nocake. water rise speed, water rise acceleration, time delay from start of turn for water rise, height delay for same, and disable cake. also set start boulder to indestructible
nemo
parents:
10697
diff
changeset
|
43 |
local waterSpeed = 0 |
931dd8f42763
add some config params - speed,accel,delaytime,delayheight,nocake. water rise speed, water rise acceleration, time delay from start of turn for water rise, height delay for same, and disable cake. also set start boulder to indestructible
nemo
parents:
10697
diff
changeset
|
44 |
local waterAccel = 0 |
931dd8f42763
add some config params - speed,accel,delaytime,delayheight,nocake. water rise speed, water rise acceleration, time delay from start of turn for water rise, height delay for same, and disable cake. also set start boulder to indestructible
nemo
parents:
10697
diff
changeset
|
45 |
local delayHeight = 32000 |
931dd8f42763
add some config params - speed,accel,delaytime,delayheight,nocake. water rise speed, water rise acceleration, time delay from start of turn for water rise, height delay for same, and disable cake. also set start boulder to indestructible
nemo
parents:
10697
diff
changeset
|
46 |
local delayTime = 0 |
10824 | 47 |
local airMineX = {} |
48 |
local airMineY = {} |
|
49 |
local airMine = {} |
|
50 |
local init = true |
|
12653
1215fd246e08
Climb Home: Fix game getting stuck when player reaches home
Wuzzy <almikes@aol.com>
parents:
12424
diff
changeset
|
51 |
local multiplayerVictoryDelay = -1 |
1215fd246e08
Climb Home: Fix game getting stuck when player reaches home
Wuzzy <almikes@aol.com>
parents:
12424
diff
changeset
|
52 |
local multiplayerWinningHogs = {} |
1215fd246e08
Climb Home: Fix game getting stuck when player reaches home
Wuzzy <almikes@aol.com>
parents:
12424
diff
changeset
|
53 |
local multiplayerWins = 0 |
12754
c7224d202e8b
2nd try... just shortcircuit most of onGameTick20 when we are between turns.
nemo
parents:
12753
diff
changeset
|
54 |
local racing = false |
12653
1215fd246e08
Climb Home: Fix game getting stuck when player reaches home
Wuzzy <almikes@aol.com>
parents:
12424
diff
changeset
|
55 |
|
1215fd246e08
Climb Home: Fix game getting stuck when player reaches home
Wuzzy <almikes@aol.com>
parents:
12424
diff
changeset
|
56 |
-- Placement positions of winning hogs |
1215fd246e08
Climb Home: Fix game getting stuck when player reaches home
Wuzzy <almikes@aol.com>
parents:
12424
diff
changeset
|
57 |
local victoryPosses = { } |
1215fd246e08
Climb Home: Fix game getting stuck when player reaches home
Wuzzy <almikes@aol.com>
parents:
12424
diff
changeset
|
58 |
do |
1215fd246e08
Climb Home: Fix game getting stuck when player reaches home
Wuzzy <almikes@aol.com>
parents:
12424
diff
changeset
|
59 |
local m = 0 |
1215fd246e08
Climb Home: Fix game getting stuck when player reaches home
Wuzzy <almikes@aol.com>
parents:
12424
diff
changeset
|
60 |
for y=108, 39, -32 do |
1215fd246e08
Climb Home: Fix game getting stuck when player reaches home
Wuzzy <almikes@aol.com>
parents:
12424
diff
changeset
|
61 |
for x=1820+m, 1972-m, 22 do |
1215fd246e08
Climb Home: Fix game getting stuck when player reaches home
Wuzzy <almikes@aol.com>
parents:
12424
diff
changeset
|
62 |
table.insert(victoryPosses, {x=x, y=y}) |
1215fd246e08
Climb Home: Fix game getting stuck when player reaches home
Wuzzy <almikes@aol.com>
parents:
12424
diff
changeset
|
63 |
end |
1215fd246e08
Climb Home: Fix game getting stuck when player reaches home
Wuzzy <almikes@aol.com>
parents:
12424
diff
changeset
|
64 |
m = m + 32 |
1215fd246e08
Climb Home: Fix game getting stuck when player reaches home
Wuzzy <almikes@aol.com>
parents:
12424
diff
changeset
|
65 |
end |
1215fd246e08
Climb Home: Fix game getting stuck when player reaches home
Wuzzy <almikes@aol.com>
parents:
12424
diff
changeset
|
66 |
end |
10810
931dd8f42763
add some config params - speed,accel,delaytime,delayheight,nocake. water rise speed, water rise acceleration, time delay from start of turn for water rise, height delay for same, and disable cake. also set start boulder to indestructible
nemo
parents:
10697
diff
changeset
|
67 |
|
931dd8f42763
add some config params - speed,accel,delaytime,delayheight,nocake. water rise speed, water rise acceleration, time delay from start of turn for water rise, height delay for same, and disable cake. also set start boulder to indestructible
nemo
parents:
10697
diff
changeset
|
68 |
function onParameters() |
931dd8f42763
add some config params - speed,accel,delaytime,delayheight,nocake. water rise speed, water rise acceleration, time delay from start of turn for water rise, height delay for same, and disable cake. also set start boulder to indestructible
nemo
parents:
10697
diff
changeset
|
69 |
parseParams() |
931dd8f42763
add some config params - speed,accel,delaytime,delayheight,nocake. water rise speed, water rise acceleration, time delay from start of turn for water rise, height delay for same, and disable cake. also set start boulder to indestructible
nemo
parents:
10697
diff
changeset
|
70 |
|
10811 | 71 |
if params["speed"] ~= nil then |
72 |
baseWaterSpeed = params["speed"] |
|
73 |
end |
|
10812 | 74 |
if params["accel"] ~= nil then |
10811 | 75 |
waterAccel = params["accel"] |
76 |
if waterAccel ~= 0 then waterAccel = div(32640000,waterAccel) end |
|
77 |
end |
|
78 |
if params["delaytime"] ~= nil then |
|
79 |
delayTime = params["delaytime"] |
|
80 |
end |
|
11613 | 81 |
if params["delayheight"] ~= nil then |
10811 | 82 |
delayHeight = 32768-params["delayheight"] |
83 |
end |
|
10810
931dd8f42763
add some config params - speed,accel,delaytime,delayheight,nocake. water rise speed, water rise acceleration, time delay from start of turn for water rise, height delay for same, and disable cake. also set start boulder to indestructible
nemo
parents:
10697
diff
changeset
|
84 |
if params["nocake"] ~= nil then addCake = false end |
931dd8f42763
add some config params - speed,accel,delaytime,delayheight,nocake. water rise speed, water rise acceleration, time delay from start of turn for water rise, height delay for same, and disable cake. also set start boulder to indestructible
nemo
parents:
10697
diff
changeset
|
85 |
end |
10413 | 86 |
|
87 |
function onGameInit() |
|
88 |
-- Ensure people get same map for same theme |
|
13752
110d6c1e817f
Lua: Rename globals: NoPointX→NO_CURSOR, cMaxTurnTime→MAX_TURN_TIME, cMaxHogHealth→MAX_HOG_HEALTH
Wuzzy <Wuzzy2@mail.ru>
parents:
13686
diff
changeset
|
89 |
TurnTime = MAX_TURN_TIME |
10413 | 90 |
CaseFreq = 0 |
91 |
Explosives = 0 |
|
92 |
MineDudPercent = 0 |
|
10598
9dd0f41d3244
This should probably fix multiplayer desync, but is the result of fiddling while pretty sick/feverish so, needs testing, and the water/scaling stuff is disabled.
nemo
parents:
10593
diff
changeset
|
93 |
EnableGameFlags(gfOneClanMode) |
10413 | 94 |
DisableGameFlags(gfBottomBorder+gfBorder) |
95 |
--This reduced startup time by only about 15% and looked ugly |
|
96 |
--EnableGameFlags(gfDisableLandObjects) |
|
97 |
-- force seed instead. Some themes will still be easier, but at least you won't luck out on the same theme |
|
98 |
Seed = ClimbHome |
|
12079
8f222872d432
Disable SD for a couple of scripts and mission maps
Wuzzy <almikes@aol.com>
parents:
12077
diff
changeset
|
99 |
-- Disable Sudden Death |
8f222872d432
Disable SD for a couple of scripts and mission maps
Wuzzy <almikes@aol.com>
parents:
12077
diff
changeset
|
100 |
WaterRise = 0 |
8f222872d432
Disable SD for a couple of scripts and mission maps
Wuzzy <almikes@aol.com>
parents:
12077
diff
changeset
|
101 |
HealthDecrease = 0 |
10413 | 102 |
end |
103 |
||
104 |
function onGearAdd(gear) |
|
105 |
if GetGearType(gear) == gtHedgehog then |
|
106 |
HH[gear] = 1 |
|
10581 | 107 |
totalHedgehogs = totalHedgehogs + 1 |
10632
5ae7ba0b2849
pretty sure the other teams need stats at 0 for the graph to look right
nemo
parents:
10598
diff
changeset
|
108 |
teams[GetHogTeamName(gear)] = 1 |
10824 | 109 |
elseif init and GetGearType(gear) == gtAirMine then |
110 |
airMine[gear] = 1 |
|
10413 | 111 |
end |
112 |
end |
|
113 |
||
114 |
function onGearDelete(gear) |
|
115 |
if gear == MrMine then |
|
13643 | 116 |
AddCaption(loc("Once you set off the proximity trigger, Mr. Mine is not your friend"), capcolDefault, capgrpMessage2) |
10413 | 117 |
MrMine = nil |
12827
b7453ae2c44d
Fix incorrect check for cake gear type in ClimbHome
Wuzzy <Wuzzy2@mail.ru>
parents:
12826
diff
changeset
|
118 |
elseif GetGearType(gear) == gtCake then |
10413 | 119 |
Cake = nil |
13155
25de976a7b9a
ClimeHome: Show messages when cake is nearby and when reaching home
Wuzzy <Wuzzy2@mail.ru>
parents:
13023
diff
changeset
|
120 |
CakeWarning = false |
10581 | 121 |
elseif GetGearType(gear) == gtHedgehog then |
11067
c632b47b8ff0
Trying to get these scripts to behave properly, still WIP though.
nemo
parents:
10824
diff
changeset
|
122 |
onGameTick20() |
c632b47b8ff0
Trying to get these scripts to behave properly, still WIP though.
nemo
parents:
10824
diff
changeset
|
123 |
onGearDamage(gear, 0) |
10581 | 124 |
HH[gear] = nil |
10413 | 125 |
end |
126 |
end |
|
127 |
||
128 |
function onGameStart() |
|
10581 | 129 |
--SetClanColor(ClansCount-1, 0x0000ffff) appears to be broken |
130 |
SendHealthStatsOff() |
|
14496
2113296b7a29
Keep track of singleplayer high scores in challenges
Wuzzy <Wuzzy2@mail.ru>
parents:
14485
diff
changeset
|
131 |
local recordInfo = "" |
2113296b7a29
Keep track of singleplayer high scores in challenges
Wuzzy <Wuzzy2@mail.ru>
parents:
14485
diff
changeset
|
132 |
if isSinglePlayer then |
2113296b7a29
Keep track of singleplayer high scores in challenges
Wuzzy <Wuzzy2@mail.ru>
parents:
14485
diff
changeset
|
133 |
recordInfo = getReadableChallengeRecord("Highscore") |
2113296b7a29
Keep track of singleplayer high scores in challenges
Wuzzy <Wuzzy2@mail.ru>
parents:
14485
diff
changeset
|
134 |
end |
10413 | 135 |
ShowMission(loc("Climb Home"), |
12077
ce3860c82c8b
Rewrite 2nd line of mission panel of most missions for consistency
Wuzzy <almikes@aol.com>
parents:
11889
diff
changeset
|
136 |
loc("Challenge"), |
14496
2113296b7a29
Keep track of singleplayer high scores in challenges
Wuzzy <Wuzzy2@mail.ru>
parents:
14485
diff
changeset
|
137 |
loc("You are far from home, and the water is rising, climb up as high as you can!|Your score will be based on your height.") |
2113296b7a29
Keep track of singleplayer high scores in challenges
Wuzzy <Wuzzy2@mail.ru>
parents:
14485
diff
changeset
|
138 |
.. "|" .. recordInfo, |
10413 | 139 |
-amRope, 0) |
140 |
local x = 1818 |
|
141 |
for h,i in pairs(HH) do |
|
10598
9dd0f41d3244
This should probably fix multiplayer desync, but is the result of fiddling while pretty sick/feverish so, needs testing, and the water/scaling stuff is disabled.
nemo
parents:
10593
diff
changeset
|
142 |
if h ~= nil then |
9dd0f41d3244
This should probably fix multiplayer desync, but is the result of fiddling while pretty sick/feverish so, needs testing, and the water/scaling stuff is disabled.
nemo
parents:
10593
diff
changeset
|
143 |
-- SetGearPosition(h,x,32549) |
9dd0f41d3244
This should probably fix multiplayer desync, but is the result of fiddling while pretty sick/feverish so, needs testing, and the water/scaling stuff is disabled.
nemo
parents:
10593
diff
changeset
|
144 |
SetGearPosition(h,x,108) |
9dd0f41d3244
This should probably fix multiplayer desync, but is the result of fiddling while pretty sick/feverish so, needs testing, and the water/scaling stuff is disabled.
nemo
parents:
10593
diff
changeset
|
145 |
SetHealth(h,1) |
9dd0f41d3244
This should probably fix multiplayer desync, but is the result of fiddling while pretty sick/feverish so, needs testing, and the water/scaling stuff is disabled.
nemo
parents:
10593
diff
changeset
|
146 |
if x < 1978 then x = x+32 else x = 1818 end |
9dd0f41d3244
This should probably fix multiplayer desync, but is the result of fiddling while pretty sick/feverish so, needs testing, and the water/scaling stuff is disabled.
nemo
parents:
10593
diff
changeset
|
147 |
if GetEffect(h,heInvulnerable) == 0 then |
9dd0f41d3244
This should probably fix multiplayer desync, but is the result of fiddling while pretty sick/feverish so, needs testing, and the water/scaling stuff is disabled.
nemo
parents:
10593
diff
changeset
|
148 |
SetEffect(h,heInvulnerable,1) |
9dd0f41d3244
This should probably fix multiplayer desync, but is the result of fiddling while pretty sick/feverish so, needs testing, and the water/scaling stuff is disabled.
nemo
parents:
10593
diff
changeset
|
149 |
else |
9dd0f41d3244
This should probably fix multiplayer desync, but is the result of fiddling while pretty sick/feverish so, needs testing, and the water/scaling stuff is disabled.
nemo
parents:
10593
diff
changeset
|
150 |
HogsAreInvulnerable = true |
9dd0f41d3244
This should probably fix multiplayer desync, but is the result of fiddling while pretty sick/feverish so, needs testing, and the water/scaling stuff is disabled.
nemo
parents:
10593
diff
changeset
|
151 |
end |
9dd0f41d3244
This should probably fix multiplayer desync, but is the result of fiddling while pretty sick/feverish so, needs testing, and the water/scaling stuff is disabled.
nemo
parents:
10593
diff
changeset
|
152 |
SetState(h,bor(GetState(h),gstInvisible)) |
9dd0f41d3244
This should probably fix multiplayer desync, but is the result of fiddling while pretty sick/feverish so, needs testing, and the water/scaling stuff is disabled.
nemo
parents:
10593
diff
changeset
|
153 |
end |
10413 | 154 |
end |
155 |
-- 1925,263 - Mr. Mine position |
|
156 |
MrMine = AddGear(1925,263,gtMine,0,0,0,0) |
|
13023
acba432d34b1
ClimbHome: Show best team heights next to team name
Wuzzy <Wuzzy2@mail.ru>
parents:
12913
diff
changeset
|
157 |
for i=0, TeamsCount-1 do |
acba432d34b1
ClimbHome: Show best team heights next to team name
Wuzzy <Wuzzy2@mail.ru>
parents:
12913
diff
changeset
|
158 |
SetTeamLabel(GetTeamName(i), "0") |
acba432d34b1
ClimbHome: Show best team heights next to team name
Wuzzy <Wuzzy2@mail.ru>
parents:
12913
diff
changeset
|
159 |
end |
10413 | 160 |
end |
10581 | 161 |
|
10413 | 162 |
function onAmmoStoreInit() |
163 |
SetAmmo(amRope, 9, 0, 0, 0) |
|
164 |
end |
|
165 |
||
166 |
function onNewTurn() |
|
10824 | 167 |
if init then |
168 |
init = false |
|
169 |
for a,i in pairs(airMine) do |
|
170 |
x,y = GetGearPosition(a) |
|
171 |
airMineX[a] = x |
|
172 |
airMineY[a] = y |
|
173 |
end |
|
174 |
else |
|
175 |
for a,i in pairs(airMine) do |
|
176 |
local x,y = GetGearPosition(a) |
|
177 |
if not x or airMineX[a] ~= x or airMineY[a] ~= y then |
|
178 |
DeleteGear(a) |
|
179 |
AddGear(airMineX[a],airMineY[a], gtAirMine, gsttmpFlag, 0, 0, 0) |
|
180 |
end |
|
181 |
end |
|
182 |
end |
|
183 |
||
10413 | 184 |
startTime = GameTime |
185 |
--disable to preserve highest over multiple turns |
|
186 |
--will need to change water check too ofc |
|
187 |
MaxHeight = 32640 |
|
188 |
hTagHeight = 33000 |
|
189 |
SetWaterLine(32768) |
|
10581 | 190 |
YouWon = false |
191 |
YouLost = false |
|
192 |
tauntNoo = false |
|
13155
25de976a7b9a
ClimeHome: Show messages when cake is nearby and when reaching home
Wuzzy <Wuzzy2@mail.ru>
parents:
13023
diff
changeset
|
193 |
takeASeat = false |
10581 | 194 |
recordBroken = false |
10632
5ae7ba0b2849
pretty sure the other teams need stats at 0 for the graph to look right
nemo
parents:
10598
diff
changeset
|
195 |
currTeam = GetHogTeamName(CurrentHedgehog) |
10592 | 196 |
if CurrentHedgehog ~= nil then |
12653
1215fd246e08
Climb Home: Fix game getting stuck when player reaches home
Wuzzy <almikes@aol.com>
parents:
12424
diff
changeset
|
197 |
if CurrentHedgehog ~= dummyHog or multiplayerWinningHogs[CurrentHedgehog] == true then |
10592 | 198 |
SetGearPosition(CurrentHedgehog, 1951,32640) |
12654
26b0d3b76dea
ClimbHome: Make sure hog faces left on turn start
Wuzzy <almikes@aol.com>
parents:
12653
diff
changeset
|
199 |
HogTurnLeft(CurrentHedgehog, true) |
10592 | 200 |
if not HogsAreInvulnerable then SetEffect(CurrentHedgehog,heInvulnerable,0) end |
10598
9dd0f41d3244
This should probably fix multiplayer desync, but is the result of fiddling while pretty sick/feverish so, needs testing, and the water/scaling stuff is disabled.
nemo
parents:
10593
diff
changeset
|
201 |
AddVisualGear(1951,32640,vgtExplosion,0,false) |
10592 | 202 |
SetState(CurrentHedgehog,band(GetState(CurrentHedgehog),bnot(gstInvisible))) |
203 |
SetWeapon(amRope) |
|
204 |
else |
|
205 |
dummySkip = GameTime+1 |
|
206 |
end |
|
10413 | 207 |
end |
12653
1215fd246e08
Climb Home: Fix game getting stuck when player reaches home
Wuzzy <almikes@aol.com>
parents:
12424
diff
changeset
|
208 |
for hog, _ in pairs(multiplayerWinningHogs) do |
1215fd246e08
Climb Home: Fix game getting stuck when player reaches home
Wuzzy <almikes@aol.com>
parents:
12424
diff
changeset
|
209 |
SetEffect(hog, heInvulnerable, 1) |
1215fd246e08
Climb Home: Fix game getting stuck when player reaches home
Wuzzy <almikes@aol.com>
parents:
12424
diff
changeset
|
210 |
end |
10413 | 211 |
for f,i in pairs(Fire) do |
212 |
DeleteGear(f) |
|
213 |
end |
|
214 |
for s,i in pairs(Stars) do |
|
215 |
DeleteVisualGear(s) |
|
216 |
Stars[s] = nil |
|
217 |
end |
|
218 |
||
10581 | 219 |
if CurrentHedgehog ~= dummyHog then |
220 |
for i = 0,12 do |
|
221 |
flame = AddGear(2000+i*2,308, gtFlame, gsttmpFlag, 0, 0, 0) |
|
222 |
SetTag(flame, 999999+i) |
|
223 |
Fire[flame]=1 |
|
224 |
end |
|
10413 | 225 |
end |
226 |
if Cake ~= nil then DeleteGear(Cake) end |
|
227 |
CakeTries = 0 |
|
228 |
end |
|
229 |
||
230 |
--function onGearDelete(gear) |
|
231 |
-- if gear == WaterRise and MaxHeight > 500 and CurrentHedgehog ~= nil and band(GetState(CurrentHedgehog),gstHHDriven) ~= 0 then |
|
232 |
-- WaterRise = AddGear(0,0,gtWaterUp, 0, 0, 0, 0) |
|
233 |
-- end |
|
234 |
--end |
|
235 |
||
236 |
function FireBoom(x,y,d) -- going to add for rockets too |
|
13155
25de976a7b9a
ClimeHome: Show messages when cake is nearby and when reaching home
Wuzzy <Wuzzy2@mail.ru>
parents:
13023
diff
changeset
|
237 |
PlaySound(sndExplosion) |
10413 | 238 |
AddVisualGear(x,y,vgtExplosion,0,false) |
10580
17560eb73b4c
Reset max team health after script may have screwed with it on start. Maybe a script max health reset function could be useful too. Set climbhome hogs to invulnerable while not their turn if needed to avoid accidental mine/dead hog damage. Tweak cake fire boom a bit.
nemo
parents:
10413
diff
changeset
|
239 |
-- should approximate circle by removing corners |
10581 | 240 |
--if BoomFire == nil then BoomFire = {} end |
10413 | 241 |
for i = 0,50 do |
10580
17560eb73b4c
Reset max team health after script may have screwed with it on start. Maybe a script max health reset function could be useful too. Set climbhome hogs to invulnerable while not their turn if needed to avoid accidental mine/dead hog damage. Tweak cake fire boom a bit.
nemo
parents:
10413
diff
changeset
|
242 |
fx = GetRandom(d)-div(d,2) |
17560eb73b4c
Reset max team health after script may have screwed with it on start. Maybe a script max health reset function could be useful too. Set climbhome hogs to invulnerable while not their turn if needed to avoid accidental mine/dead hog damage. Tweak cake fire boom a bit.
nemo
parents:
10413
diff
changeset
|
243 |
fy = GetRandom(d)-div(d,2) |
17560eb73b4c
Reset max team health after script may have screwed with it on start. Maybe a script max health reset function could be useful too. Set climbhome hogs to invulnerable while not their turn if needed to avoid accidental mine/dead hog damage. Tweak cake fire boom a bit.
nemo
parents:
10413
diff
changeset
|
244 |
if fx<0 then |
17560eb73b4c
Reset max team health after script may have screwed with it on start. Maybe a script max health reset function could be useful too. Set climbhome hogs to invulnerable while not their turn if needed to avoid accidental mine/dead hog damage. Tweak cake fire boom a bit.
nemo
parents:
10413
diff
changeset
|
245 |
fdx = -5000-GetRandom(3000) |
17560eb73b4c
Reset max team health after script may have screwed with it on start. Maybe a script max health reset function could be useful too. Set climbhome hogs to invulnerable while not their turn if needed to avoid accidental mine/dead hog damage. Tweak cake fire boom a bit.
nemo
parents:
10413
diff
changeset
|
246 |
else |
17560eb73b4c
Reset max team health after script may have screwed with it on start. Maybe a script max health reset function could be useful too. Set climbhome hogs to invulnerable while not their turn if needed to avoid accidental mine/dead hog damage. Tweak cake fire boom a bit.
nemo
parents:
10413
diff
changeset
|
247 |
fdx = 5000+GetRandom(3000) |
17560eb73b4c
Reset max team health after script may have screwed with it on start. Maybe a script max health reset function could be useful too. Set climbhome hogs to invulnerable while not their turn if needed to avoid accidental mine/dead hog damage. Tweak cake fire boom a bit.
nemo
parents:
10413
diff
changeset
|
248 |
end |
17560eb73b4c
Reset max team health after script may have screwed with it on start. Maybe a script max health reset function could be useful too. Set climbhome hogs to invulnerable while not their turn if needed to avoid accidental mine/dead hog damage. Tweak cake fire boom a bit.
nemo
parents:
10413
diff
changeset
|
249 |
if fy<0 then |
17560eb73b4c
Reset max team health after script may have screwed with it on start. Maybe a script max health reset function could be useful too. Set climbhome hogs to invulnerable while not their turn if needed to avoid accidental mine/dead hog damage. Tweak cake fire boom a bit.
nemo
parents:
10413
diff
changeset
|
250 |
fdy = -5000-GetRandom(3000) |
17560eb73b4c
Reset max team health after script may have screwed with it on start. Maybe a script max health reset function could be useful too. Set climbhome hogs to invulnerable while not their turn if needed to avoid accidental mine/dead hog damage. Tweak cake fire boom a bit.
nemo
parents:
10413
diff
changeset
|
251 |
else |
17560eb73b4c
Reset max team health after script may have screwed with it on start. Maybe a script max health reset function could be useful too. Set climbhome hogs to invulnerable while not their turn if needed to avoid accidental mine/dead hog damage. Tweak cake fire boom a bit.
nemo
parents:
10413
diff
changeset
|
252 |
fdy = 5000+GetRandom(3000) |
17560eb73b4c
Reset max team health after script may have screwed with it on start. Maybe a script max health reset function could be useful too. Set climbhome hogs to invulnerable while not their turn if needed to avoid accidental mine/dead hog damage. Tweak cake fire boom a bit.
nemo
parents:
10413
diff
changeset
|
253 |
end |
17560eb73b4c
Reset max team health after script may have screwed with it on start. Maybe a script max health reset function could be useful too. Set climbhome hogs to invulnerable while not their turn if needed to avoid accidental mine/dead hog damage. Tweak cake fire boom a bit.
nemo
parents:
10413
diff
changeset
|
254 |
flame = AddGear(x+fx, y+fy, gtFlame, gsttmpFlag, fdx, fdy, 0) |
10413 | 255 |
SetTag(flame, 999999+i) |
10589
98ea597e5cd9
expose FlightTime to lua, disable in-air flame harming moving hogs ☹ aaaand override that in ClimbHome ☺
nemo
parents:
10587
diff
changeset
|
256 |
SetFlightTime(flame, 0) |
10413 | 257 |
Fire[flame]=1 |
258 |
-- BoomFire[flame]=1 |
|
259 |
end |
|
260 |
end |
|
261 |
||
262 |
||
263 |
function onGameTick20() |
|
10824 | 264 |
local x,y |
12753
327f71313e04
this should probably sidestep that thing unc0rr keeps bringing up. untested. but then, I've never had it happen. I think what happens is onGameTick20 is called in same tick as onNewTurn and before it...
nemo
parents:
12655
diff
changeset
|
265 |
|
10581 | 266 |
if math.random(20) == 1 then AddVisualGear(2012,56,vgtSmoke,0,false) end |
10592 | 267 |
if CurrentHedgehog == dummyHog and dummySkip ~= 0 and dummySkip < GameTime then |
13170
98a0edb4bb5a
Lua API: Add SkipTurn() to replace ParseCommand("skip")
Wuzzy <Wuzzy2@mail.ru>
parents:
13155
diff
changeset
|
268 |
SkipTurn() |
10592 | 269 |
dummySkip = 0 |
10585 | 270 |
end |
10581 | 271 |
|
10413 | 272 |
--if BoomFire ~= nil then |
273 |
-- for f,i in pairs(BoomFire) do |
|
274 |
-- if band(GetState(f),gstCollision~=0) then DeleteGear(f) end |
|
275 |
-- end |
|
276 |
-- BoomFire = nil |
|
277 |
--end |
|
278 |
||
279 |
for s,i in pairs(Stars) do |
|
13686
3651c63f3c84
Clean up legacy visual gear stuff in ClimbHome, fix star despawn, make stars non-critical
Wuzzy <Wuzzy2@mail.ru>
parents:
13664
diff
changeset
|
280 |
local _, Y = GetVisualGearValues(s) |
3651c63f3c84
Clean up legacy visual gear stuff in ClimbHome, fix star despawn, make stars non-critical
Wuzzy <Wuzzy2@mail.ru>
parents:
13664
diff
changeset
|
281 |
if Y ~= nil and Y > WaterLine + 500 then |
10413 | 282 |
DeleteVisualGear(s) |
283 |
Stars[s] = nil |
|
13686
3651c63f3c84
Clean up legacy visual gear stuff in ClimbHome, fix star despawn, make stars non-critical
Wuzzy <Wuzzy2@mail.ru>
parents:
13664
diff
changeset
|
284 |
elseif Y == nil then |
3651c63f3c84
Clean up legacy visual gear stuff in ClimbHome, fix star despawn, make stars non-critical
Wuzzy <Wuzzy2@mail.ru>
parents:
13664
diff
changeset
|
285 |
Stars[s] = nil |
10413 | 286 |
end |
287 |
end |
|
288 |
||
12653
1215fd246e08
Climb Home: Fix game getting stuck when player reaches home
Wuzzy <almikes@aol.com>
parents:
12424
diff
changeset
|
289 |
-- This will be executed if a player reached home in multiplayer |
1215fd246e08
Climb Home: Fix game getting stuck when player reaches home
Wuzzy <almikes@aol.com>
parents:
12424
diff
changeset
|
290 |
if multiplayerVictoryDelay > 0 then |
1215fd246e08
Climb Home: Fix game getting stuck when player reaches home
Wuzzy <almikes@aol.com>
parents:
12424
diff
changeset
|
291 |
multiplayerVictoryDelay = multiplayerVictoryDelay - 20 |
1215fd246e08
Climb Home: Fix game getting stuck when player reaches home
Wuzzy <almikes@aol.com>
parents:
12424
diff
changeset
|
292 |
if multiplayerVictoryDelay <= 0 then |
1215fd246e08
Climb Home: Fix game getting stuck when player reaches home
Wuzzy <almikes@aol.com>
parents:
12424
diff
changeset
|
293 |
-- If delay's over, the game will continue with the next hog |
1215fd246e08
Climb Home: Fix game getting stuck when player reaches home
Wuzzy <almikes@aol.com>
parents:
12424
diff
changeset
|
294 |
if CurrentHedgehog then |
1215fd246e08
Climb Home: Fix game getting stuck when player reaches home
Wuzzy <almikes@aol.com>
parents:
12424
diff
changeset
|
295 |
|
1215fd246e08
Climb Home: Fix game getting stuck when player reaches home
Wuzzy <almikes@aol.com>
parents:
12424
diff
changeset
|
296 |
multiplayerWinningHogs[CurrentHedgehog] = true |
1215fd246e08
Climb Home: Fix game getting stuck when player reaches home
Wuzzy <almikes@aol.com>
parents:
12424
diff
changeset
|
297 |
multiplayerWins = multiplayerWins + 1 |
1215fd246e08
Climb Home: Fix game getting stuck when player reaches home
Wuzzy <almikes@aol.com>
parents:
12424
diff
changeset
|
298 |
|
1215fd246e08
Climb Home: Fix game getting stuck when player reaches home
Wuzzy <almikes@aol.com>
parents:
12424
diff
changeset
|
299 |
local victoryX, victoryY |
1215fd246e08
Climb Home: Fix game getting stuck when player reaches home
Wuzzy <almikes@aol.com>
parents:
12424
diff
changeset
|
300 |
if multiplayerWins <= #victoryPosses then |
1215fd246e08
Climb Home: Fix game getting stuck when player reaches home
Wuzzy <almikes@aol.com>
parents:
12424
diff
changeset
|
301 |
victoryX, victoryY = victoryPosses[multiplayerWins].x, victoryPosses[multiplayerWins].y |
1215fd246e08
Climb Home: Fix game getting stuck when player reaches home
Wuzzy <almikes@aol.com>
parents:
12424
diff
changeset
|
302 |
else |
1215fd246e08
Climb Home: Fix game getting stuck when player reaches home
Wuzzy <almikes@aol.com>
parents:
12424
diff
changeset
|
303 |
victoryX, victoryY = victoryPosses[#victoryPosses].x, victoryPosses[#victoryPosses].y |
1215fd246e08
Climb Home: Fix game getting stuck when player reaches home
Wuzzy <almikes@aol.com>
parents:
12424
diff
changeset
|
304 |
end |
1215fd246e08
Climb Home: Fix game getting stuck when player reaches home
Wuzzy <almikes@aol.com>
parents:
12424
diff
changeset
|
305 |
SetGearPosition(CurrentHedgehog, victoryX, victoryY) |
1215fd246e08
Climb Home: Fix game getting stuck when player reaches home
Wuzzy <almikes@aol.com>
parents:
12424
diff
changeset
|
306 |
SetEffect(CurrentHedgehog, heInvulnerable, 1) |
1215fd246e08
Climb Home: Fix game getting stuck when player reaches home
Wuzzy <almikes@aol.com>
parents:
12424
diff
changeset
|
307 |
SetHealth(CurrentHedgehog, 1) |
1215fd246e08
Climb Home: Fix game getting stuck when player reaches home
Wuzzy <almikes@aol.com>
parents:
12424
diff
changeset
|
308 |
|
1215fd246e08
Climb Home: Fix game getting stuck when player reaches home
Wuzzy <almikes@aol.com>
parents:
12424
diff
changeset
|
309 |
if (deadHedgehogs + multiplayerWins) >= totalHedgehogs then |
1215fd246e08
Climb Home: Fix game getting stuck when player reaches home
Wuzzy <almikes@aol.com>
parents:
12424
diff
changeset
|
310 |
makeFinalMultiPlayerStats() |
1215fd246e08
Climb Home: Fix game getting stuck when player reaches home
Wuzzy <almikes@aol.com>
parents:
12424
diff
changeset
|
311 |
EndGame() |
1215fd246e08
Climb Home: Fix game getting stuck when player reaches home
Wuzzy <almikes@aol.com>
parents:
12424
diff
changeset
|
312 |
onAchievementsDeclaration() |
1215fd246e08
Climb Home: Fix game getting stuck when player reaches home
Wuzzy <almikes@aol.com>
parents:
12424
diff
changeset
|
313 |
else |
1215fd246e08
Climb Home: Fix game getting stuck when player reaches home
Wuzzy <almikes@aol.com>
parents:
12424
diff
changeset
|
314 |
EndTurn(true) |
1215fd246e08
Climb Home: Fix game getting stuck when player reaches home
Wuzzy <almikes@aol.com>
parents:
12424
diff
changeset
|
315 |
SetInputMask(0xFFFFFFFF) |
1215fd246e08
Climb Home: Fix game getting stuck when player reaches home
Wuzzy <almikes@aol.com>
parents:
12424
diff
changeset
|
316 |
end |
1215fd246e08
Climb Home: Fix game getting stuck when player reaches home
Wuzzy <almikes@aol.com>
parents:
12424
diff
changeset
|
317 |
return |
1215fd246e08
Climb Home: Fix game getting stuck when player reaches home
Wuzzy <almikes@aol.com>
parents:
12424
diff
changeset
|
318 |
end |
1215fd246e08
Climb Home: Fix game getting stuck when player reaches home
Wuzzy <almikes@aol.com>
parents:
12424
diff
changeset
|
319 |
end |
1215fd246e08
Climb Home: Fix game getting stuck when player reaches home
Wuzzy <almikes@aol.com>
parents:
12424
diff
changeset
|
320 |
end |
1215fd246e08
Climb Home: Fix game getting stuck when player reaches home
Wuzzy <almikes@aol.com>
parents:
12424
diff
changeset
|
321 |
|
12825 | 322 |
if CurrentHedgehog ~= nil then |
323 |
x,y = GetGearPosition(CurrentHedgehog) |
|
324 |
if Cake ~= nil then |
|
325 |
local cx,cy = GetGearPosition(Cake) |
|
12826
42003e235a46
remove some more test redundancy and restore a missing and important nil check
nemo
parents:
12825
diff
changeset
|
326 |
if y < cy-1500 then DeleteGear(Cake) end |
12825 | 327 |
|
13155
25de976a7b9a
ClimeHome: Show messages when cake is nearby and when reaching home
Wuzzy <Wuzzy2@mail.ru>
parents:
13023
diff
changeset
|
328 |
if Cake ~= nil and GetHealth(Cake) < 999980 then |
25de976a7b9a
ClimeHome: Show messages when cake is nearby and when reaching home
Wuzzy <Wuzzy2@mail.ru>
parents:
13023
diff
changeset
|
329 |
if not CakeWarning and gearIsInCircle(CurrentHedgehog,cx,cy,1350) then |
25de976a7b9a
ClimeHome: Show messages when cake is nearby and when reaching home
Wuzzy <Wuzzy2@mail.ru>
parents:
13023
diff
changeset
|
330 |
AddCaption(loc("Warning: Fire cake detected")) |
25de976a7b9a
ClimeHome: Show messages when cake is nearby and when reaching home
Wuzzy <Wuzzy2@mail.ru>
parents:
13023
diff
changeset
|
331 |
CakeWarning = true |
25de976a7b9a
ClimeHome: Show messages when cake is nearby and when reaching home
Wuzzy <Wuzzy2@mail.ru>
parents:
13023
diff
changeset
|
332 |
end |
25de976a7b9a
ClimeHome: Show messages when cake is nearby and when reaching home
Wuzzy <Wuzzy2@mail.ru>
parents:
13023
diff
changeset
|
333 |
if gearIsInCircle(CurrentHedgehog,cx,cy,450) then |
25de976a7b9a
ClimeHome: Show messages when cake is nearby and when reaching home
Wuzzy <Wuzzy2@mail.ru>
parents:
13023
diff
changeset
|
334 |
if not CakeFireWarning then |
25de976a7b9a
ClimeHome: Show messages when cake is nearby and when reaching home
Wuzzy <Wuzzy2@mail.ru>
parents:
13023
diff
changeset
|
335 |
AddCaption(loc("Don't touch the flames!")) |
25de976a7b9a
ClimeHome: Show messages when cake is nearby and when reaching home
Wuzzy <Wuzzy2@mail.ru>
parents:
13023
diff
changeset
|
336 |
CakeFireWarning = true |
25de976a7b9a
ClimeHome: Show messages when cake is nearby and when reaching home
Wuzzy <Wuzzy2@mail.ru>
parents:
13023
diff
changeset
|
337 |
end |
25de976a7b9a
ClimeHome: Show messages when cake is nearby and when reaching home
Wuzzy <Wuzzy2@mail.ru>
parents:
13023
diff
changeset
|
338 |
FireBoom(cx,cy,200) -- todo animate |
25de976a7b9a
ClimeHome: Show messages when cake is nearby and when reaching home
Wuzzy <Wuzzy2@mail.ru>
parents:
13023
diff
changeset
|
339 |
DeleteGear(Cake) |
25de976a7b9a
ClimeHome: Show messages when cake is nearby and when reaching home
Wuzzy <Wuzzy2@mail.ru>
parents:
13023
diff
changeset
|
340 |
end |
12826
42003e235a46
remove some more test redundancy and restore a missing and important nil check
nemo
parents:
12825
diff
changeset
|
341 |
end |
42003e235a46
remove some more test redundancy and restore a missing and important nil check
nemo
parents:
12825
diff
changeset
|
342 |
end |
42003e235a46
remove some more test redundancy and restore a missing and important nil check
nemo
parents:
12825
diff
changeset
|
343 |
if band(GetState(CurrentHedgehog),gstHHDriven) == 0 then |
42003e235a46
remove some more test redundancy and restore a missing and important nil check
nemo
parents:
12825
diff
changeset
|
344 |
for f,i in pairs(Fire) do -- takes too long to fall otherwise |
42003e235a46
remove some more test redundancy and restore a missing and important nil check
nemo
parents:
12825
diff
changeset
|
345 |
DeleteGear(f) |
42003e235a46
remove some more test redundancy and restore a missing and important nil check
nemo
parents:
12825
diff
changeset
|
346 |
end |
42003e235a46
remove some more test redundancy and restore a missing and important nil check
nemo
parents:
12825
diff
changeset
|
347 |
if Cake ~= nil then |
42003e235a46
remove some more test redundancy and restore a missing and important nil check
nemo
parents:
12825
diff
changeset
|
348 |
DeleteGear(Cake) |
12825 | 349 |
end |
10413 | 350 |
end |
12825 | 351 |
end |
12760
5acf6b91df76
you know what... I think everything would have been fine if we'd simply required all this hog stuff to be in the same block...
nemo
parents:
12754
diff
changeset
|
352 |
|
10413 | 353 |
|
354 |
if CurrentHedgehog ~= nil and TurnTimeLeft > 0 and band(GetState(CurrentHedgehog),gstHHDriven) ~= 0 then |
|
10810
931dd8f42763
add some config params - speed,accel,delaytime,delayheight,nocake. water rise speed, water rise acceleration, time delay from start of turn for water rise, height delay for same, and disable cake. also set start boulder to indestructible
nemo
parents:
10697
diff
changeset
|
355 |
if MaxHeight < delayHeight and |
13752
110d6c1e817f
Lua: Rename globals: NoPointX→NO_CURSOR, cMaxTurnTime→MAX_TURN_TIME, cMaxHogHealth→MAX_HOG_HEALTH
Wuzzy <Wuzzy2@mail.ru>
parents:
13686
diff
changeset
|
356 |
TurnTimeLeft<(MAX_TURN_TIME-delayTime) and |
10810
931dd8f42763
add some config params - speed,accel,delaytime,delayheight,nocake. water rise speed, water rise acceleration, time delay from start of turn for water rise, height delay for same, and disable cake. also set start boulder to indestructible
nemo
parents:
10697
diff
changeset
|
357 |
MaxHeight > 286 and WaterLine > 286 then |
931dd8f42763
add some config params - speed,accel,delaytime,delayheight,nocake. water rise speed, water rise acceleration, time delay from start of turn for water rise, height delay for same, and disable cake. also set start boulder to indestructible
nemo
parents:
10697
diff
changeset
|
358 |
if waterAccel ~= 0 then |
931dd8f42763
add some config params - speed,accel,delaytime,delayheight,nocake. water rise speed, water rise acceleration, time delay from start of turn for water rise, height delay for same, and disable cake. also set start boulder to indestructible
nemo
parents:
10697
diff
changeset
|
359 |
SetWaterLine(WaterLine-(baseWaterSpeed+div(getActualHeight(MaxHeight)*100,waterAccel))) |
931dd8f42763
add some config params - speed,accel,delaytime,delayheight,nocake. water rise speed, water rise acceleration, time delay from start of turn for water rise, height delay for same, and disable cake. also set start boulder to indestructible
nemo
parents:
10697
diff
changeset
|
360 |
else |
931dd8f42763
add some config params - speed,accel,delaytime,delayheight,nocake. water rise speed, water rise acceleration, time delay from start of turn for water rise, height delay for same, and disable cake. also set start boulder to indestructible
nemo
parents:
10697
diff
changeset
|
361 |
SetWaterLine(WaterLine-baseWaterSpeed) |
931dd8f42763
add some config params - speed,accel,delaytime,delayheight,nocake. water rise speed, water rise acceleration, time delay from start of turn for water rise, height delay for same, and disable cake. also set start boulder to indestructible
nemo
parents:
10697
diff
changeset
|
362 |
end |
931dd8f42763
add some config params - speed,accel,delaytime,delayheight,nocake. water rise speed, water rise acceleration, time delay from start of turn for water rise, height delay for same, and disable cake. also set start boulder to indestructible
nemo
parents:
10697
diff
changeset
|
363 |
end |
10413 | 364 |
if y > 0 and y < 30000 and MaxHeight > 286 and math.random(y) < 500 then |
13686
3651c63f3c84
Clean up legacy visual gear stuff in ClimbHome, fix star despawn, make stars non-critical
Wuzzy <Wuzzy2@mail.ru>
parents:
13664
diff
changeset
|
365 |
local s = AddVisualGear(0, 0, vgtStraightShot, 0, false) |
3651c63f3c84
Clean up legacy visual gear stuff in ClimbHome, fix star despawn, make stars non-critical
Wuzzy <Wuzzy2@mail.ru>
parents:
13664
diff
changeset
|
366 |
if s then |
3651c63f3c84
Clean up legacy visual gear stuff in ClimbHome, fix star despawn, make stars non-critical
Wuzzy <Wuzzy2@mail.ru>
parents:
13664
diff
changeset
|
367 |
local c = div(250000,y) |
3651c63f3c84
Clean up legacy visual gear stuff in ClimbHome, fix star despawn, make stars non-critical
Wuzzy <Wuzzy2@mail.ru>
parents:
13664
diff
changeset
|
368 |
if c > 255 then c = 255 end |
3651c63f3c84
Clean up legacy visual gear stuff in ClimbHome, fix star despawn, make stars non-critical
Wuzzy <Wuzzy2@mail.ru>
parents:
13664
diff
changeset
|
369 |
c = c * 0x10000 + 0xFF0000FF |
3651c63f3c84
Clean up legacy visual gear stuff in ClimbHome, fix star despawn, make stars non-critical
Wuzzy <Wuzzy2@mail.ru>
parents:
13664
diff
changeset
|
370 |
SetVisualGearValues(s, |
3651c63f3c84
Clean up legacy visual gear stuff in ClimbHome, fix star despawn, make stars non-critical
Wuzzy <Wuzzy2@mail.ru>
parents:
13664
diff
changeset
|
371 |
math.random(2048), -5000, 0, -1-(1/y*1000), |
3651c63f3c84
Clean up legacy visual gear stuff in ClimbHome, fix star despawn, make stars non-critical
Wuzzy <Wuzzy2@mail.ru>
parents:
13664
diff
changeset
|
372 |
math.random(360), |
3651c63f3c84
Clean up legacy visual gear stuff in ClimbHome, fix star despawn, make stars non-critical
Wuzzy <Wuzzy2@mail.ru>
parents:
13664
diff
changeset
|
373 |
0, |
3651c63f3c84
Clean up legacy visual gear stuff in ClimbHome, fix star despawn, make stars non-critical
Wuzzy <Wuzzy2@mail.ru>
parents:
13664
diff
changeset
|
374 |
999999999, -- frameticks |
3651c63f3c84
Clean up legacy visual gear stuff in ClimbHome, fix star despawn, make stars non-critical
Wuzzy <Wuzzy2@mail.ru>
parents:
13664
diff
changeset
|
375 |
sprStar, -- star |
3651c63f3c84
Clean up legacy visual gear stuff in ClimbHome, fix star despawn, make stars non-critical
Wuzzy <Wuzzy2@mail.ru>
parents:
13664
diff
changeset
|
376 |
0, c) |
3651c63f3c84
Clean up legacy visual gear stuff in ClimbHome, fix star despawn, make stars non-critical
Wuzzy <Wuzzy2@mail.ru>
parents:
13664
diff
changeset
|
377 |
--, 0xFFCC00FF) -- could be fun to make colour shift as you rise... |
3651c63f3c84
Clean up legacy visual gear stuff in ClimbHome, fix star despawn, make stars non-critical
Wuzzy <Wuzzy2@mail.ru>
parents:
13664
diff
changeset
|
378 |
Stars[s] = 1 |
3651c63f3c84
Clean up legacy visual gear stuff in ClimbHome, fix star despawn, make stars non-critical
Wuzzy <Wuzzy2@mail.ru>
parents:
13664
diff
changeset
|
379 |
end |
10413 | 380 |
end |
381 |
||
10581 | 382 |
local vx, vy = GetGearVelocity(CurrentHedgehog) |
12760
5acf6b91df76
you know what... I think everything would have been fine if we'd simply required all this hog stuff to be in the same block...
nemo
parents:
12754
diff
changeset
|
383 |
local distanceFromWater = WaterLine - y |
10581 | 384 |
|
385 |
--[[ check joke awards ]] |
|
386 |
-- navy award: when distance from main map is over 1000 |
|
387 |
local navyDistance = 1250 |
|
388 |
if x < -navyDistance or x > LAND_WIDTH+navyDistance then |
|
389 |
local awarded = false |
|
390 |
local dist = 0 |
|
391 |
if jokeAwardNavy == nil then |
|
392 |
awarded = true |
|
393 |
else |
|
394 |
if x < 0 then |
|
395 |
dist = math.abs(x) |
|
396 |
else |
|
397 |
dist = x - LAND_WIDTH |
|
398 |
end |
|
399 |
if dist > jokeAwardNavy.distance then |
|
400 |
awarded = true |
|
401 |
end |
|
402 |
end |
|
403 |
if awarded == true then |
|
404 |
jokeAwardNavy = { |
|
405 |
hogName = GetHogName(CurrentHedgehog), |
|
406 |
teamName = GetHogTeamName(CurrentHedgehog), |
|
407 |
distance = dist |
|
408 |
} |
|
409 |
end |
|
410 |
end |
|
411 |
||
412 |
-- Speed award for largest distance from water |
|
413 |
if distanceFromWater > 3000 and WaterLine < 32000 then |
|
414 |
local awarded = false |
|
415 |
if jokeAwardSpeed == nil or distanceFromWater > jokeAwardSpeed.distance then |
|
416 |
awarded = true |
|
417 |
end |
|
418 |
if awarded == true then |
|
419 |
jokeAwardSpeed = { |
|
420 |
hogName = GetHogName(CurrentHedgehog), |
|
421 |
teamName = GetHogTeamName(CurrentHedgehog), |
|
422 |
distance = distanceFromWater |
|
423 |
} |
|
424 |
end |
|
10413 | 425 |
end |
10581 | 426 |
|
14496
2113296b7a29
Keep track of singleplayer high scores in challenges
Wuzzy <Wuzzy2@mail.ru>
parents:
14485
diff
changeset
|
427 |
local rawFinishTime = GameTime-startTime |
2113296b7a29
Keep track of singleplayer high scores in challenges
Wuzzy <Wuzzy2@mail.ru>
parents:
14485
diff
changeset
|
428 |
local finishTime = rawFinishTime/1000 |
12760
5acf6b91df76
you know what... I think everything would have been fine if we'd simply required all this hog stuff to be in the same block...
nemo
parents:
12754
diff
changeset
|
429 |
local roundedFinishTime = math.ceil(math.floor(finishTime+0.5)) |
5acf6b91df76
you know what... I think everything would have been fine if we'd simply required all this hog stuff to be in the same block...
nemo
parents:
12754
diff
changeset
|
430 |
if isSinglePlayer then |
5acf6b91df76
you know what... I think everything would have been fine if we'd simply required all this hog stuff to be in the same block...
nemo
parents:
12754
diff
changeset
|
431 |
if distanceFromWater < 0 and not YouLost and not YouWon then |
5acf6b91df76
you know what... I think everything would have been fine if we'd simply required all this hog stuff to be in the same block...
nemo
parents:
12754
diff
changeset
|
432 |
makeSinglePlayerLoserStats() |
5acf6b91df76
you know what... I think everything would have been fine if we'd simply required all this hog stuff to be in the same block...
nemo
parents:
12754
diff
changeset
|
433 |
YouLost = true |
5acf6b91df76
you know what... I think everything would have been fine if we'd simply required all this hog stuff to be in the same block...
nemo
parents:
12754
diff
changeset
|
434 |
end |
5acf6b91df76
you know what... I think everything would have been fine if we'd simply required all this hog stuff to be in the same block...
nemo
parents:
12754
diff
changeset
|
435 |
-- FIXME: Hog is also in winning box if it just walks into the chair from the left, touching it. Intentional? |
5acf6b91df76
you know what... I think everything would have been fine if we'd simply required all this hog stuff to be in the same block...
nemo
parents:
12754
diff
changeset
|
436 |
if not YouWon and not YouLost and gearIsInBox(CurrentHedgehog, 1920, 252, 50, 50) then |
14485
ead8928a59f8
Report mission victory for most missions
Wuzzy <Wuzzy2@mail.ru>
parents:
13752
diff
changeset
|
437 |
SaveMissionVar("Won", "true") |
13643 | 438 |
AddCaption(loc("Victory!"), capcolDefault, capgrpGameState) |
12760
5acf6b91df76
you know what... I think everything would have been fine if we'd simply required all this hog stuff to be in the same block...
nemo
parents:
12754
diff
changeset
|
439 |
ShowMission(loc("Climb Home"), |
5acf6b91df76
you know what... I think everything would have been fine if we'd simply required all this hog stuff to be in the same block...
nemo
parents:
12754
diff
changeset
|
440 |
loc("Made it!"), |
5acf6b91df76
you know what... I think everything would have been fine if we'd simply required all this hog stuff to be in the same block...
nemo
parents:
12754
diff
changeset
|
441 |
string.format(loc("Ahhh, home, sweet home. Made it in %d seconds."), roundedFinishTime), |
5acf6b91df76
you know what... I think everything would have been fine if we'd simply required all this hog stuff to be in the same block...
nemo
parents:
12754
diff
changeset
|
442 |
-amRope, 0) |
5acf6b91df76
you know what... I think everything would have been fine if we'd simply required all this hog stuff to be in the same block...
nemo
parents:
12754
diff
changeset
|
443 |
PlaySound(sndVictory,CurrentHedgehog) |
5acf6b91df76
you know what... I think everything would have been fine if we'd simply required all this hog stuff to be in the same block...
nemo
parents:
12754
diff
changeset
|
444 |
SendStat(siGameResult, loc("You have beaten the challenge!")) |
5acf6b91df76
you know what... I think everything would have been fine if we'd simply required all this hog stuff to be in the same block...
nemo
parents:
12754
diff
changeset
|
445 |
SendStat(siGraphTitle, loc("Your height over time")) |
5acf6b91df76
you know what... I think everything would have been fine if we'd simply required all this hog stuff to be in the same block...
nemo
parents:
12754
diff
changeset
|
446 |
SendStat(siCustomAchievement, string.format(loc("%s reached home in %.3f seconds. Congratulations!"), GetHogName(CurrentHedgehog), finishTime)) |
14496
2113296b7a29
Keep track of singleplayer high scores in challenges
Wuzzy <Wuzzy2@mail.ru>
parents:
14485
diff
changeset
|
447 |
updateChallengeRecord("TimeRecord", rawFinishTime, false) |
12760
5acf6b91df76
you know what... I think everything would have been fine if we'd simply required all this hog stuff to be in the same block...
nemo
parents:
12754
diff
changeset
|
448 |
SendStat(siCustomAchievement, string.format(loc("%s bravely climbed up to a dizzy height of %d to reach home."), GetHogName(CurrentHedgehog), getActualHeight(RecordHeight))) |
14496
2113296b7a29
Keep track of singleplayer high scores in challenges
Wuzzy <Wuzzy2@mail.ru>
parents:
14485
diff
changeset
|
449 |
updateChallengeRecord("Highscore", getActualHeight(RecordHeight)) |
14599
50f511588635
Outsource commonly used words in siPointType to QTfrontend
Wuzzy <Wuzzy2@mail.ru>
parents:
14496
diff
changeset
|
450 |
SendStat(siPointType, "!TIME") |
50f511588635
Outsource commonly used words in siPointType to QTfrontend
Wuzzy <Wuzzy2@mail.ru>
parents:
14496
diff
changeset
|
451 |
SendStat(siPlayerKills, tostring(rawFinishTime), GetHogTeamName(CurrentHedgehog)) |
12760
5acf6b91df76
you know what... I think everything would have been fine if we'd simply required all this hog stuff to be in the same block...
nemo
parents:
12754
diff
changeset
|
452 |
|
5acf6b91df76
you know what... I think everything would have been fine if we'd simply required all this hog stuff to be in the same block...
nemo
parents:
12754
diff
changeset
|
453 |
EndGame() |
14949
4c5fb1ee75b7
Add winner animation for missions that didn't have it
Wuzzy <Wuzzy2@mail.ru>
parents:
14611
diff
changeset
|
454 |
SetState(CurrentHedgehog, gstWinner) |
12760
5acf6b91df76
you know what... I think everything would have been fine if we'd simply required all this hog stuff to be in the same block...
nemo
parents:
12754
diff
changeset
|
455 |
onAchievementsDeclaration() |
5acf6b91df76
you know what... I think everything would have been fine if we'd simply required all this hog stuff to be in the same block...
nemo
parents:
12754
diff
changeset
|
456 |
YouWon = true |
5acf6b91df76
you know what... I think everything would have been fine if we'd simply required all this hog stuff to be in the same block...
nemo
parents:
12754
diff
changeset
|
457 |
end |
5acf6b91df76
you know what... I think everything would have been fine if we'd simply required all this hog stuff to be in the same block...
nemo
parents:
12754
diff
changeset
|
458 |
else |
5acf6b91df76
you know what... I think everything would have been fine if we'd simply required all this hog stuff to be in the same block...
nemo
parents:
12754
diff
changeset
|
459 |
if distanceFromWater < 0 and not YouLost and not YouWon then |
5acf6b91df76
you know what... I think everything would have been fine if we'd simply required all this hog stuff to be in the same block...
nemo
parents:
12754
diff
changeset
|
460 |
makeMultiPlayerLoserStat(CurrentHedgehog) |
5acf6b91df76
you know what... I think everything would have been fine if we'd simply required all this hog stuff to be in the same block...
nemo
parents:
12754
diff
changeset
|
461 |
deadHedgehogs = deadHedgehogs + 1 |
5acf6b91df76
you know what... I think everything would have been fine if we'd simply required all this hog stuff to be in the same block...
nemo
parents:
12754
diff
changeset
|
462 |
YouLost = true |
5acf6b91df76
you know what... I think everything would have been fine if we'd simply required all this hog stuff to be in the same block...
nemo
parents:
12754
diff
changeset
|
463 |
if deadHedgehogs >= totalHedgehogs then |
5acf6b91df76
you know what... I think everything would have been fine if we'd simply required all this hog stuff to be in the same block...
nemo
parents:
12754
diff
changeset
|
464 |
makeFinalMultiPlayerStats() |
10581 | 465 |
EndGame() |
11623
515d2d38ab8b
Declare achievements alongwith EndGame call, since it would skip SendStats
unc0rr
parents:
11615
diff
changeset
|
466 |
onAchievementsDeclaration() |
10581 | 467 |
end |
468 |
end |
|
12760
5acf6b91df76
you know what... I think everything would have been fine if we'd simply required all this hog stuff to be in the same block...
nemo
parents:
12754
diff
changeset
|
469 |
-- Check victory |
5acf6b91df76
you know what... I think everything would have been fine if we'd simply required all this hog stuff to be in the same block...
nemo
parents:
12754
diff
changeset
|
470 |
if not YouWon and not YouLost and gearIsInBox(CurrentHedgehog, 1920, 252, 50, 50) and |
5acf6b91df76
you know what... I think everything would have been fine if we'd simply required all this hog stuff to be in the same block...
nemo
parents:
12754
diff
changeset
|
471 |
-- Delay victory if MrMine is triggered |
5acf6b91df76
you know what... I think everything would have been fine if we'd simply required all this hog stuff to be in the same block...
nemo
parents:
12754
diff
changeset
|
472 |
(not MrMine or (MrMine and band(GetState(MrMine), gstAttacking) == 0)) then |
5acf6b91df76
you know what... I think everything would have been fine if we'd simply required all this hog stuff to be in the same block...
nemo
parents:
12754
diff
changeset
|
473 |
-- Player managed to reach home in multiplayer. |
5acf6b91df76
you know what... I think everything would have been fine if we'd simply required all this hog stuff to be in the same block...
nemo
parents:
12754
diff
changeset
|
474 |
-- Stop hog, disable controls, celebrate victory and continue the game after 4 seconds. |
13643 | 475 |
AddCaption(string.format(loc("%s climbed home in %d seconds!"), GetHogName(CurrentHedgehog), roundedFinishTime), capcolDefault, capgrpGameState) |
12760
5acf6b91df76
you know what... I think everything would have been fine if we'd simply required all this hog stuff to be in the same block...
nemo
parents:
12754
diff
changeset
|
476 |
SendStat(siCustomAchievement, string.format(loc("%s (%s) reached home in %.3f seconds."), GetHogName(CurrentHedgehog), GetHogTeamName(CurrentHedgehog), finishTime)) |
5acf6b91df76
you know what... I think everything would have been fine if we'd simply required all this hog stuff to be in the same block...
nemo
parents:
12754
diff
changeset
|
477 |
makeMultiPlayerWinnerStat(CurrentHedgehog) |
5acf6b91df76
you know what... I think everything would have been fine if we'd simply required all this hog stuff to be in the same block...
nemo
parents:
12754
diff
changeset
|
478 |
PlaySound(sndVictory, CurrentHedgehog) |
12913
20e627c1ac20
ClimbHome, Sniper Rifle training: Unselect weapon after victory
Wuzzy <Wuzzy2@mail.ru>
parents:
12827
diff
changeset
|
479 |
SetWeapon(amNothing) |
12760
5acf6b91df76
you know what... I think everything would have been fine if we'd simply required all this hog stuff to be in the same block...
nemo
parents:
12754
diff
changeset
|
480 |
SetGearMessage(CurrentHedgehog, band(GetGearMessage(CurrentHedgehog), bnot(gmLeft+gmRight+gmUp+gmDown+gmHJump+gmLJump+gmPrecise))) |
5acf6b91df76
you know what... I think everything would have been fine if we'd simply required all this hog stuff to be in the same block...
nemo
parents:
12754
diff
changeset
|
481 |
SetInputMask(0x00) |
5acf6b91df76
you know what... I think everything would have been fine if we'd simply required all this hog stuff to be in the same block...
nemo
parents:
12754
diff
changeset
|
482 |
-- TODO: Add stupid winner grin. |
5acf6b91df76
you know what... I think everything would have been fine if we'd simply required all this hog stuff to be in the same block...
nemo
parents:
12754
diff
changeset
|
483 |
multiplayerVictoryDelay = 4000 |
5acf6b91df76
you know what... I think everything would have been fine if we'd simply required all this hog stuff to be in the same block...
nemo
parents:
12754
diff
changeset
|
484 |
YouWon = true |
5acf6b91df76
you know what... I think everything would have been fine if we'd simply required all this hog stuff to be in the same block...
nemo
parents:
12754
diff
changeset
|
485 |
end |
5acf6b91df76
you know what... I think everything would have been fine if we'd simply required all this hog stuff to be in the same block...
nemo
parents:
12754
diff
changeset
|
486 |
end |
10598
9dd0f41d3244
This should probably fix multiplayer desync, but is the result of fiddling while pretty sick/feverish so, needs testing, and the water/scaling stuff is disabled.
nemo
parents:
10593
diff
changeset
|
487 |
|
9dd0f41d3244
This should probably fix multiplayer desync, but is the result of fiddling while pretty sick/feverish so, needs testing, and the water/scaling stuff is disabled.
nemo
parents:
10593
diff
changeset
|
488 |
if GameTime % 500 == 0 then |
11889
c8979eeb73fa
Fix ClimbHome mission bugs (broken teams, broken graph)
Wuzzy <almikes@aol.com>
parents:
11635
diff
changeset
|
489 |
if not isSinglePlayer then |
c8979eeb73fa
Fix ClimbHome mission bugs (broken teams, broken graph)
Wuzzy <almikes@aol.com>
parents:
11635
diff
changeset
|
490 |
for t,i in pairs(teams) do |
c8979eeb73fa
Fix ClimbHome mission bugs (broken teams, broken graph)
Wuzzy <almikes@aol.com>
parents:
11635
diff
changeset
|
491 |
if currTeam == t then |
c8979eeb73fa
Fix ClimbHome mission bugs (broken teams, broken graph)
Wuzzy <almikes@aol.com>
parents:
11635
diff
changeset
|
492 |
SendStat(siClanHealth, tostring(getActualHeight(y)), t) |
c8979eeb73fa
Fix ClimbHome mission bugs (broken teams, broken graph)
Wuzzy <almikes@aol.com>
parents:
11635
diff
changeset
|
493 |
else |
c8979eeb73fa
Fix ClimbHome mission bugs (broken teams, broken graph)
Wuzzy <almikes@aol.com>
parents:
11635
diff
changeset
|
494 |
SendStat(siClanHealth, '0', t) |
c8979eeb73fa
Fix ClimbHome mission bugs (broken teams, broken graph)
Wuzzy <almikes@aol.com>
parents:
11635
diff
changeset
|
495 |
end |
10632
5ae7ba0b2849
pretty sure the other teams need stats at 0 for the graph to look right
nemo
parents:
10598
diff
changeset
|
496 |
end |
12760
5acf6b91df76
you know what... I think everything would have been fine if we'd simply required all this hog stuff to be in the same block...
nemo
parents:
12754
diff
changeset
|
497 |
else |
11889
c8979eeb73fa
Fix ClimbHome mission bugs (broken teams, broken graph)
Wuzzy <almikes@aol.com>
parents:
11635
diff
changeset
|
498 |
SendStat(siClanHealth, tostring(getActualHeight(y)), GetHogTeamName(CurrentHedgehog)) |
10632
5ae7ba0b2849
pretty sure the other teams need stats at 0 for the graph to look right
nemo
parents:
10598
diff
changeset
|
499 |
end |
13155
25de976a7b9a
ClimeHome: Show messages when cake is nearby and when reaching home
Wuzzy <Wuzzy2@mail.ru>
parents:
13023
diff
changeset
|
500 |
-- If player is inside home, tell player to take a seat. |
25de976a7b9a
ClimeHome: Show messages when cake is nearby and when reaching home
Wuzzy <Wuzzy2@mail.ru>
parents:
13023
diff
changeset
|
501 |
if not takeASeat and gearIsInBox(CurrentHedgehog, 1765, 131, 244, 189) then |
25de976a7b9a
ClimeHome: Show messages when cake is nearby and when reaching home
Wuzzy <Wuzzy2@mail.ru>
parents:
13023
diff
changeset
|
502 |
AddCaption(loc("Welcome home! Please take a seat")) |
25de976a7b9a
ClimeHome: Show messages when cake is nearby and when reaching home
Wuzzy <Wuzzy2@mail.ru>
parents:
13023
diff
changeset
|
503 |
takeASeat = true |
25de976a7b9a
ClimeHome: Show messages when cake is nearby and when reaching home
Wuzzy <Wuzzy2@mail.ru>
parents:
13023
diff
changeset
|
504 |
end |
10581 | 505 |
|
506 |
-- play taunts |
|
507 |
if not YouWon and not YouLost then |
|
508 |
local nooDistance = 500 |
|
509 |
if ((x < -nooDistance and vx < 0) or (x > LAND_WIDTH+nooDistance and vx > 0)) then |
|
510 |
if (tauntNoo == false and distanceFromWater > 80) then |
|
511 |
PlaySound(sndNooo, CurrentHedgehog) |
|
512 |
tauntNoo = true |
|
513 |
end |
|
514 |
end |
|
515 |
end |
|
516 |
||
12826
42003e235a46
remove some more test redundancy and restore a missing and important nil check
nemo
parents:
12825
diff
changeset
|
517 |
if addCake and CakeTries < 10 and y < 32600 and y > 3000 and Cake == nil then |
10581 | 518 |
-- doing this just after the start the first time to take advantage of randomness sources |
519 |
-- Pick a clear y to start with |
|
520 |
if y > 31000 then cy = 24585 elseif |
|
521 |
y > 28000 then cy = 21500 elseif |
|
522 |
y > 24000 then cy = 19000 elseif |
|
523 |
y > 21500 then cy = 16000 elseif |
|
524 |
y > 19000 then cy = 12265 elseif |
|
525 |
y > 16000 then cy = 8800 elseif |
|
526 |
y > 12000 then cy = 5700 else |
|
527 |
cy = 400 end |
|
528 |
Cake = AddGear(GetRandom(2048), cy, gtCake, 0, 0, 0, 0) |
|
529 |
SetHealth(Cake,999999) |
|
530 |
CakeTries = CakeTries + 1 |
|
531 |
end |
|
532 |
||
533 |
if (y > 286) or (y < 286 and MaxHeight > 286) then |
|
11635 | 534 |
if MaxHeight > 286 and y <= 286 then |
535 |
-- wow, reached top |
|
536 |
local teamName = GetHogTeamName(CurrentHedgehog) |
|
537 |
if teamTimes[teamName] == nil or teamTimes[teamName] > GameTime - startTime then |
|
538 |
teamTimes[teamName] = GameTime - startTime |
|
539 |
end |
|
540 |
MaxHeight = 286 |
|
541 |
end |
|
10581 | 542 |
if y < MaxHeight and y > 286 then MaxHeight = y end |
13023
acba432d34b1
ClimbHome: Show best team heights next to team name
Wuzzy <Wuzzy2@mail.ru>
parents:
12913
diff
changeset
|
543 |
-- New maximum height of this turn? |
10581 | 544 |
if MaxHeight < hTagHeight then |
545 |
hTagHeight = MaxHeight |
|
546 |
if hTag ~= nil then DeleteVisualGear(hTag) end |
|
547 |
hTag = AddVisualGear(0, 0, vgtHealthTag, 0, true) |
|
13023
acba432d34b1
ClimbHome: Show best team heights next to team name
Wuzzy <Wuzzy2@mail.ru>
parents:
12913
diff
changeset
|
548 |
local score = 32640-hTagHeight |
10581 | 549 |
-- snagged from space invasion |
550 |
SetVisualGearValues ( |
|
551 |
hTag, --id |
|
552 |
-(ScreenWidth/2) + 40, --xoffset |
|
553 |
ScreenHeight - 60, --yoffset |
|
554 |
0, --dx |
|
555 |
0, --dy |
|
556 |
1.1, --zoom |
|
557 |
1, --~= 0 means align to screen |
|
13686
3651c63f3c84
Clean up legacy visual gear stuff in ClimbHome, fix star despawn, make stars non-critical
Wuzzy <Wuzzy2@mail.ru>
parents:
13664
diff
changeset
|
558 |
nil, --frameticks |
10581 | 559 |
-- 116px off bottom for lowest rock, 286 or so off top for position of chair |
560 |
-- 32650 is "0" |
|
13023
acba432d34b1
ClimbHome: Show best team heights next to team name
Wuzzy <Wuzzy2@mail.ru>
parents:
12913
diff
changeset
|
561 |
score, --value |
10581 | 562 |
99999999999,--timer |
563 |
GetClanColor(GetHogClan(CurrentHedgehog)) |
|
564 |
) |
|
13023
acba432d34b1
ClimbHome: Show best team heights next to team name
Wuzzy <Wuzzy2@mail.ru>
parents:
12913
diff
changeset
|
565 |
local team = GetHogTeamName(CurrentHedgehog) |
acba432d34b1
ClimbHome: Show best team heights next to team name
Wuzzy <Wuzzy2@mail.ru>
parents:
12913
diff
changeset
|
566 |
SetTeamLabel(team, math.max(score, teamBests[team] or 0)) |
10581 | 567 |
end |
568 |
||
13023
acba432d34b1
ClimbHome: Show best team heights next to team name
Wuzzy <Wuzzy2@mail.ru>
parents:
12913
diff
changeset
|
569 |
-- New record height? |
10581 | 570 |
if MaxHeight < RecordHeight then |
571 |
RecordHeight = MaxHeight |
|
572 |
local oldName = RecordHeightHogName |
|
573 |
RecordHeightHogName = GetHogName(CurrentHedgehog) |
|
574 |
if oldName == nil then recordBroken = true end |
|
575 |
if not isSinglePlayer and RecordHeight > 1500 and not recordBroken then |
|
576 |
recordBroken = true |
|
577 |
AddCaption(string.format(loc("%s has passed the best height of %s!"), RecordHeightHogName, oldName)) |
|
578 |
end |
|
579 |
if not isSinglePlayer then |
|
580 |
if rTag ~= nil then DeleteVisualGear(rTag) end |
|
581 |
rTag = AddVisualGear(0, 0, vgtHealthTag, 0, true) |
|
582 |
-- snagged from space invasion |
|
583 |
SetVisualGearValues ( |
|
584 |
rTag, --id |
|
585 |
-(ScreenWidth/2) + 100, --xoffset |
|
586 |
ScreenHeight - 60, --yoffset |
|
587 |
0, --dx |
|
588 |
0, --dy |
|
589 |
1.1, --zoom |
|
590 |
1, --~= 0 means align to screen |
|
13686
3651c63f3c84
Clean up legacy visual gear stuff in ClimbHome, fix star despawn, make stars non-critical
Wuzzy <Wuzzy2@mail.ru>
parents:
13664
diff
changeset
|
591 |
nil, --frameticks |
10581 | 592 |
-- 116px off bottom for lowest rock, 286 or so off top for position of chair |
593 |
-- 32650 is "0" |
|
594 |
getActualHeight(RecordHeight), --value |
|
595 |
99999999999,--timer |
|
596 |
GetClanColor(GetHogClan(CurrentHedgehog)) |
|
597 |
) |
|
598 |
end |
|
599 |
end |
|
600 |
end |
|
601 |
if MaxHeight > 286 then |
|
602 |
if tTag ~= nil then DeleteVisualGear(tTag) end |
|
603 |
tTag = AddVisualGear(0, 0, vgtHealthTag, 0, true) |
|
10413 | 604 |
-- snagged from space invasion |
605 |
SetVisualGearValues ( |
|
606 |
tTag, --id |
|
607 |
-(ScreenWidth/2) + 40, --xoffset |
|
608 |
ScreenHeight - 100, --yoffset |
|
609 |
0, --dx |
|
610 |
0, --dy |
|
611 |
1.1, --zoom |
|
612 |
1, --~= 0 means align to screen |
|
13686
3651c63f3c84
Clean up legacy visual gear stuff in ClimbHome, fix star despawn, make stars non-critical
Wuzzy <Wuzzy2@mail.ru>
parents:
13664
diff
changeset
|
613 |
nil, --frameticks |
10413 | 614 |
(GameTime-startTime)/1000, --value |
615 |
99999999999,--timer |
|
616 |
0xffffffff |
|
617 |
) |
|
10581 | 618 |
end |
10413 | 619 |
end |
620 |
end |
|
621 |
end |
|
10581 | 622 |
|
623 |
function onGearDamage(gear, damage) |
|
624 |
if GetGearType(gear) == gtHedgehog and not YouLost and not YouWon then |
|
625 |
-- Joke award for largest damage to hog |
|
626 |
local qualifyDamage = 50 |
|
627 |
if (damage >= qualifyDamage) then |
|
628 |
local awarded = false |
|
629 |
if jokeAwardDamage == nil or damage > jokeAwardDamage.damage then |
|
630 |
awarded = true |
|
631 |
end |
|
632 |
if awarded == true then |
|
633 |
jokeAwardDamage = { |
|
634 |
hogName = GetHogName(CurrentHedgehog), |
|
635 |
teamName = GetHogTeamName(CurrentHedgehog), |
|
636 |
damage = damage |
|
637 |
} |
|
638 |
end |
|
639 |
end |
|
640 |
||
641 |
if isSinglePlayer then |
|
642 |
makeSinglePlayerLoserStats() |
|
643 |
else |
|
644 |
deadHedgehogs = deadHedgehogs + 1 |
|
12655
913d25669131
ClimbHome: Fix final team scoring 0 if hog took damage
Wuzzy <almikes@aol.com>
parents:
12654
diff
changeset
|
645 |
makeMultiPlayerLoserStat(gear) |
12653
1215fd246e08
Climb Home: Fix game getting stuck when player reaches home
Wuzzy <almikes@aol.com>
parents:
12424
diff
changeset
|
646 |
if (deadHedgehogs + multiplayerWins) >= totalHedgehogs then |
10581 | 647 |
makeFinalMultiPlayerStats() |
648 |
EndGame() |
|
11623
515d2d38ab8b
Declare achievements alongwith EndGame call, since it would skip SendStats
unc0rr
parents:
11615
diff
changeset
|
649 |
onAchievementsDeclaration() |
10581 | 650 |
end |
651 |
end |
|
652 |
YouLost = true |
|
653 |
end |
|
654 |
end |
|
655 |
||
656 |
function makeLoserComment() |
|
657 |
local m |
|
658 |
if isSinglePlayer then m = 10 else m = 6 end |
|
659 |
local r = math.random(1,m) |
|
660 |
if r == 1 then text = loc("%s never got the ninja diploma.") |
|
661 |
elseif r == 2 then text = loc("You have to move upwards, not downwards, %s!") |
|
662 |
elseif r == 3 then text = loc("%s never wanted to reach for the sky in the first place.") |
|
663 |
elseif r == 4 then text = loc("%s should try the rope training mission first.") |
|
664 |
elseif r == 5 then text = loc("%s skipped ninja classes.") |
|
665 |
elseif r == 6 then text = loc("%s doesn’t really know how to handle a rope properly.") |
|
666 |
elseif r == 7 then text = loc("Better luck next time!") |
|
667 |
elseif r == 8 then text = loc("It was all just bad luck!") |
|
668 |
elseif r == 9 then text = loc("Well, that escalated quickly!") |
|
669 |
elseif r == 10 then text = loc("What? Is it over already?") end |
|
670 |
return text |
|
671 |
end |
|
672 |
||
673 |
function makeSinglePlayerLoserStats() |
|
674 |
local actualHeight = getActualHeight(RecordHeight) |
|
14611
c5f18710a184
Remove "loser" messages in challenges
Wuzzy <Wuzzy2@mail.ru>
parents:
14599
diff
changeset
|
675 |
SendStat(siGameResult, loc("Challenge over!")) |
10581 | 676 |
SendStat(siGraphTitle, loc("Your height over time")) |
677 |
local text |
|
678 |
if actualHeight > 30000 then text = loc("%s was damn close to home.") |
|
679 |
elseif actualHeight > 28000 then text = loc("%s was close to home.") |
|
680 |
elseif actualHeight > 24265 then text = loc("%s was good, but not good enough.") |
|
681 |
elseif actualHeight > 16177 then text = loc("%s managed to pass half of the distance towards home.") |
|
682 |
elseif actualHeight > 8088 then text = loc("%s went over a quarter of the way towards home.") |
|
683 |
elseif actualHeight > 5100 then text = loc("%s still had a long way to go.") |
|
684 |
elseif actualHeight > 2000 then text = loc("%s made it past the hogosphere.") |
|
685 |
elseif actualHeight > 1500 then text = loc("%s barely made it past the hogosphere.") |
|
686 |
else |
|
687 |
text = makeLoserComment() |
|
688 |
end |
|
689 |
if actualHeight > 1500 then |
|
690 |
SendStat(siCustomAchievement, string.format(text, RecordHeightHogName, actualHeight)) |
|
691 |
else |
|
692 |
SendStat(siCustomAchievement, string.format(text, RecordHeightHogName)) |
|
693 |
end |
|
14496
2113296b7a29
Keep track of singleplayer high scores in challenges
Wuzzy <Wuzzy2@mail.ru>
parents:
14485
diff
changeset
|
694 |
|
2113296b7a29
Keep track of singleplayer high scores in challenges
Wuzzy <Wuzzy2@mail.ru>
parents:
14485
diff
changeset
|
695 |
updateChallengeRecord("Highscore", actualHeight) |
14599
50f511588635
Outsource commonly used words in siPointType to QTfrontend
Wuzzy <Wuzzy2@mail.ru>
parents:
14496
diff
changeset
|
696 |
SendStat(siPointType, "!POINTS") |
12424
b9cc405541c1
Fix various loc() syntax errors in scripts
Wuzzy <almikes@aol.com>
parents:
12392
diff
changeset
|
697 |
SendStat(siPlayerKills, actualHeight, GetHogTeamName(CurrentHedgehog)) |
10581 | 698 |
EndGame() |
11623
515d2d38ab8b
Declare achievements alongwith EndGame call, since it would skip SendStats
unc0rr
parents:
11615
diff
changeset
|
699 |
onAchievementsDeclaration() |
10581 | 700 |
end |
701 |
||
702 |
function makeMultiPlayerLoserStat(gear) |
|
703 |
local teamName = GetHogTeamName(gear) |
|
704 |
local actualHeight = getActualHeight(MaxHeight) |
|
705 |
if teamBests[teamName] == nil then teamBests[teamName] = actualHeight end |
|
706 |
if teamBests[teamName] < actualHeight then teamBests[teamName] = actualHeight end |
|
707 |
if teamScoreStats[teamName] == nil then teamScoreStats[teamName] = {} end |
|
708 |
table.insert(teamScoreStats[teamName], actualHeight) |
|
10598
9dd0f41d3244
This should probably fix multiplayer desync, but is the result of fiddling while pretty sick/feverish so, needs testing, and the water/scaling stuff is disabled.
nemo
parents:
10593
diff
changeset
|
709 |
--SendStat(siClanHealth, tostring(teamBests[teamName]), teamName) |
10581 | 710 |
end |
711 |
||
12653
1215fd246e08
Climb Home: Fix game getting stuck when player reaches home
Wuzzy <almikes@aol.com>
parents:
12424
diff
changeset
|
712 |
function makeMultiPlayerWinnerStat(gear) |
1215fd246e08
Climb Home: Fix game getting stuck when player reaches home
Wuzzy <almikes@aol.com>
parents:
12424
diff
changeset
|
713 |
return makeMultiPlayerLoserStat(gear) |
1215fd246e08
Climb Home: Fix game getting stuck when player reaches home
Wuzzy <almikes@aol.com>
parents:
12424
diff
changeset
|
714 |
end |
1215fd246e08
Climb Home: Fix game getting stuck when player reaches home
Wuzzy <almikes@aol.com>
parents:
12424
diff
changeset
|
715 |
|
10581 | 716 |
function makeFinalMultiPlayerStats() |
717 |
local ranking = {} |
|
718 |
for k,v in pairs(teamBests) do |
|
719 |
table.insert(ranking, {name=k, score=v}) |
|
720 |
end |
|
721 |
local comp = function(table1, table2) |
|
722 |
if table1.score < table2.score then |
|
723 |
return true |
|
724 |
else |
|
725 |
return false |
|
726 |
end |
|
727 |
end |
|
728 |
table.sort(ranking, comp) |
|
729 |
||
730 |
local winner = ranking[#ranking] |
|
731 |
local loser = ranking[1] |
|
732 |
SendStat(siGameResult, string.format(loc("%s wins!"), winner.name)) |
|
11889
c8979eeb73fa
Fix ClimbHome mission bugs (broken teams, broken graph)
Wuzzy <almikes@aol.com>
parents:
11635
diff
changeset
|
733 |
SendStat(siGraphTitle, string.format(loc("Height over time"))) |
10581 | 734 |
|
735 |
if winner.score < 1500 then |
|
11067
c632b47b8ff0
Trying to get these scripts to behave properly, still WIP though.
nemo
parents:
10824
diff
changeset
|
736 |
SendStat(siCustomAchievement, string.format(loc("This round’s award for ultimate disappointment goes to: Everyone!"))) |
10581 | 737 |
else |
738 |
if winner.score > 30000 then text = loc("%s (%s) reached for the sky and beyond with a height of %d!") |
|
739 |
elseif winner.score > 24750 then text = loc("%s (%s) was certainly not afraid of heights: Peak height of %d!") |
|
740 |
elseif winner.score > 16500 then text = loc("%s (%s) does not have to feel ashamed for their best height of %d.") |
|
741 |
elseif winner.score > 8250 then text = loc("%s (%s) reached a decent peak height of %d.") |
|
742 |
else text = loc("%s (%s) reached a peak height of %d.") end |
|
743 |
SendStat(siCustomAchievement, string.format(text, RecordHeightHogName, winner.name, winner.score)) |
|
744 |
||
745 |
if loser.score < 1500 then |
|
746 |
text = makeLoserComment() |
|
747 |
SendStat(siCustomAchievement, string.format(text, loser.name)) |
|
748 |
end |
|
749 |
end |
|
750 |
checkAwards() |
|
751 |
for i = #ranking, 1, -1 do |
|
14599
50f511588635
Outsource commonly used words in siPointType to QTfrontend
Wuzzy <Wuzzy2@mail.ru>
parents:
14496
diff
changeset
|
752 |
SendStat(siPointType, "!POINTS") |
10581 | 753 |
SendStat(siPlayerKills, tostring(ranking[i].score), ranking[i].name) |
754 |
end |
|
755 |
end |
|
756 |
||
757 |
function checkAwards() |
|
758 |
if jokeAwardNavy ~= nil then |
|
759 |
if isSinglePlayer then |
|
760 |
SendStat(siCustomAchievement, string.format(loc("The Navy greets %s for managing to get in a distance of %d away from the mainland!"), jokeAwardNavy.hogName, jokeAwardNavy.distance)) |
|
761 |
else |
|
762 |
SendStat(siCustomAchievement, string.format(loc("Greetings from the Navy, %s (%s), for being a distance of %d away from the mainland!"), jokeAwardNavy.hogName, jokeAwardNavy.teamName, jokeAwardNavy.distance)) |
|
763 |
end |
|
764 |
end |
|
765 |
if jokeAwardSpeed ~= nil then |
|
766 |
if isSinglePlayer then |
|
767 |
SendStat(siCustomAchievement, string.format(loc("Your hedgehog was panicly afraid of the water and decided to go in a safe distance of %d from it."), jokeAwardSpeed.distance)) |
|
768 |
else |
|
769 |
SendStat(siCustomAchievement, string.format(loc("%s (%s) was panicly afraid of the water and decided to get in a safe distance of %d from it."), jokeAwardSpeed.hogName, jokeAwardSpeed.teamName, jokeAwardSpeed.distance)) |
|
770 |
end |
|
771 |
end |
|
772 |
if jokeAwardDamage ~= nil then |
|
773 |
if isSinglePlayer then |
|
774 |
SendStat(siCustomAchievement, string.format(loc("Ouch! That must have hurt. You mutilated your poor hedgehog hog with %d damage."), jokeAwardDamage.damage)) |
|
775 |
else |
|
776 |
SendStat(siCustomAchievement, string.format(loc("Ouch! That must have hurt. %s (%s) hit the ground with %d damage points."), jokeAwardDamage.hogName, jokeAwardDamage.teamName, jokeAwardDamage.damage)) |
|
777 |
end |
|
778 |
end |
|
779 |
end |
|
780 |
||
781 |
function getActualHeight(height) |
|
782 |
return 32640-height |
|
783 |
end |
|
11615 | 784 |
|
785 |
function onAchievementsDeclaration() |
|
786 |
for teamname, score in pairs(teamBests) do |
|
11627 | 787 |
DeclareAchievement("height reached", teamname, "ClimbHome", -score) |
11615 | 788 |
end |
11635 | 789 |
for teamname, score in pairs(teamTimes) do |
790 |
DeclareAchievement("rope race", teamname, "ClimbHome", score) |
|
791 |
end |
|
11615 | 792 |
end |