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