author  Wuzzy <almikes@aol.com> 
Thu, 12 May 2016 19:22:53 +0200  
changeset 12200  02f6d786627d 
parent 12199  f7c295971143 
child 12201  2c0811bbc1d9 
permissions  rwrr 
4  1 
(* 
1066  2 
* Hedgewars, a free turn based strategy game 
11046  3 
* Copyright (c) 20042015 Andrey Korotaev <unC0Rr@gmail.com> 
4  4 
* 
183  5 
* This program is free software; you can redistribute it and/or modify 
6 
* it under the terms of the GNU General Public License as published by 

7 
* the Free Software Foundation; version 2 of the License 

4  8 
* 
183  9 
* This program is distributed in the hope that it will be useful, 
10 
* but WITHOUT ANY WARRANTY; without even the implied warranty of 

11 
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 

12 
* GNU General Public License for more details. 

4  13 
* 
183  14 
* You should have received a copy of the GNU General Public License 
15 
* along with this program; if not, write to the Free Software 

10108
c68cf030eded
update FSF address. note: two sdl include files (by Sam Lantinga) still have the old FSF address in their copyright  but I ain't gonna touch their copyright headers
sheepluva
parents:
10040
diff
changeset

16 
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 021101301 USA 
4  17 
*) 
18 

5121
2d34ec60992c
added some comments in order to confuse the GSoC students as much as possible ;D
sheepluva
parents:
5076
diff
changeset

19 
(* 
2d34ec60992c
added some comments in order to confuse the GSoC students as much as possible ;D
sheepluva
parents:
5076
diff
changeset

20 
* This file contains the step handlers for gears. 
2d34ec60992c
added some comments in order to confuse the GSoC students as much as possible ;D
sheepluva
parents:
5076
diff
changeset

21 
* 
2d34ec60992c
added some comments in order to confuse the GSoC students as much as possible ;D
sheepluva
parents:
5076
diff
changeset

22 
* Important: Since gears change the course of the game, calculations that 
2d34ec60992c
added some comments in order to confuse the GSoC students as much as possible ;D
sheepluva
parents:
5076
diff
changeset

23 
* lead to different results for different clients/players/machines 
2d34ec60992c
added some comments in order to confuse the GSoC students as much as possible ;D
sheepluva
parents:
5076
diff
changeset

24 
* should NOT occur! 
2d34ec60992c
added some comments in order to confuse the GSoC students as much as possible ;D
sheepluva
parents:
5076
diff
changeset

25 
* Use safe functions and data types! (e.g. GetRandom() and hwFloat) 
2d34ec60992c
added some comments in order to confuse the GSoC students as much as possible ;D
sheepluva
parents:
5076
diff
changeset

26 
*) 
10015  27 

9285  28 
{$INCLUDE "options.inc"} 
29 

30 
unit uGearsHandlersMess; 

31 
interface 

32 
uses uTypes, uFloat; 

33 

34 
procedure doStepPerPixel(Gear: PGear; step: TGearStepProcedure; onlyCheckIfChanged: boolean); 

35 
procedure makeHogsWorry(x, y: hwFloat; r: LongInt); 

36 
procedure HideHog(HH: PHedgehog); 

37 
procedure doStepDrowningGear(Gear: PGear); 

38 
procedure doStepFallingGear(Gear: PGear); 

39 
procedure doStepBomb(Gear: PGear); 

40 
procedure doStepMolotov(Gear: PGear); 

41 
procedure doStepCluster(Gear: PGear); 

42 
procedure doStepShell(Gear: PGear); 

43 
procedure doStepSnowball(Gear: PGear); 

44 
procedure doStepSnowflake(Gear: PGear); 

45 
procedure doStepGrave(Gear: PGear); 

46 
procedure doStepBeeWork(Gear: PGear); 

47 
procedure doStepBee(Gear: PGear); 

48 
procedure doStepShotIdle(Gear: PGear); 

49 
procedure doStepShotgunShot(Gear: PGear); 

50 
procedure spawnBulletTrail(Bullet: PGear); 

51 
procedure doStepBulletWork(Gear: PGear); 

52 
procedure doStepDEagleShot(Gear: PGear); 

53 
procedure doStepSniperRifleShot(Gear: PGear); 

54 
procedure doStepActionTimer(Gear: PGear); 

55 
procedure doStepPickHammerWork(Gear: PGear); 

56 
procedure doStepPickHammer(Gear: PGear); 

57 
procedure doStepBlowTorchWork(Gear: PGear); 

58 
procedure doStepBlowTorch(Gear: PGear); 

59 
procedure doStepMine(Gear: PGear); 

10789
acbf69e2e5cf
experiment with air mines. thought they could make shoppa... interesting. ToDo: Allow mines to give up, tweak distances, real graphics, toggle for whether they can acquire a new target while they haven't given up.
nemo
parents:
10736
diff
changeset

60 
procedure doStepAirMine(Gear: PGear); 
9285  61 
procedure doStepSMine(Gear: PGear); 
62 
procedure doStepDynamite(Gear: PGear); 

63 
procedure doStepRollingBarrel(Gear: PGear); 

64 
procedure doStepCase(Gear: PGear); 

65 
procedure doStepTarget(Gear: PGear); 

66 
procedure doStepIdle(Gear: PGear); 

67 
procedure doStepShover(Gear: PGear); 

68 
procedure doStepWhip(Gear: PGear); 

69 
procedure doStepFlame(Gear: PGear); 

70 
procedure doStepFirePunchWork(Gear: PGear); 

71 
procedure doStepFirePunch(Gear: PGear); 

72 
procedure doStepParachuteWork(Gear: PGear); 

73 
procedure doStepParachute(Gear: PGear); 

74 
procedure doStepAirAttackWork(Gear: PGear); 

75 
procedure doStepAirAttack(Gear: PGear); 

76 
procedure doStepAirBomb(Gear: PGear); 

77 
procedure doStepGirder(Gear: PGear); 

78 
procedure doStepTeleportAfter(Gear: PGear); 

79 
procedure doStepTeleportAnim(Gear: PGear); 

80 
procedure doStepTeleport(Gear: PGear); 

81 
procedure doStepSwitcherWork(Gear: PGear); 

82 
procedure doStepSwitcher(Gear: PGear); 

83 
procedure doStepMortar(Gear: PGear); 

84 
procedure doStepKamikazeWork(Gear: PGear); 

85 
procedure doStepKamikazeIdle(Gear: PGear); 

86 
procedure doStepKamikaze(Gear: PGear); 

87 
procedure doStepCakeExpl(Gear: PGear); 

88 
procedure doStepCakeDown(Gear: PGear); 

11531  89 
procedure doStepCakeWalk(Gear: PGear); 
9285  90 
procedure doStepCakeUp(Gear: PGear); 
91 
procedure doStepCakeFall(Gear: PGear); 

92 
procedure doStepCake(Gear: PGear); 

93 
procedure doStepSeductionWork(Gear: PGear); 

94 
procedure doStepSeductionWear(Gear: PGear); 

95 
procedure doStepSeduction(Gear: PGear); 

96 
procedure doStepWaterUp(Gear: PGear); 

97 
procedure doStepDrillDrilling(Gear: PGear); 

98 
procedure doStepDrill(Gear: PGear); 

99 
procedure doStepBallgunWork(Gear: PGear); 

100 
procedure doStepBallgun(Gear: PGear); 

101 
procedure doStepRCPlaneWork(Gear: PGear); 

102 
procedure doStepRCPlane(Gear: PGear); 

103 
procedure doStepJetpackWork(Gear: PGear); 

104 
procedure doStepJetpack(Gear: PGear); 

105 
procedure doStepBirdyDisappear(Gear: PGear); 

106 
procedure doStepBirdyFly(Gear: PGear); 

107 
procedure doStepBirdyDescend(Gear: PGear); 

108 
procedure doStepBirdyAppear(Gear: PGear); 

109 
procedure doStepBirdy(Gear: PGear); 

110 
procedure doStepEggWork(Gear: PGear); 

111 
procedure doPortalColorSwitch(); 

112 
procedure doStepPortal(Gear: PGear); 

113 
procedure loadNewPortalBall(oldPortal: PGear; destroyGear: Boolean); 

114 
procedure doStepMovingPortal_real(Gear: PGear); 

115 
procedure doStepMovingPortal(Gear: PGear); 

116 
procedure doStepPortalShot(newPortal: PGear); 

117 
procedure doStepPiano(Gear: PGear); 

118 
procedure doStepSineGunShotWork(Gear: PGear); 

119 
procedure doStepSineGunShot(Gear: PGear); 

120 
procedure doStepFlamethrowerWork(Gear: PGear); 

121 
procedure doStepFlamethrower(Gear: PGear); 

122 
procedure doStepLandGunWork(Gear: PGear); 

123 
procedure doStepLandGun(Gear: PGear); 

124 
procedure doStepPoisonCloud(Gear: PGear); 

125 
procedure doStepHammer(Gear: PGear); 

126 
procedure doStepHammerHitWork(Gear: PGear); 

127 
procedure doStepHammerHit(Gear: PGear); 

128 
procedure doStepResurrectorWork(Gear: PGear); 

129 
procedure doStepResurrector(Gear: PGear); 

130 
procedure doStepNapalmBomb(Gear: PGear); 

11468
2f6f8baa2a97
Make weapon damage in most cases be a structure value and also expose it to lua. Needs testing/review due to conditions at time of doing this (w/ one arm, dizzy/tingling due to sodium citrate), and just number of places changed..
nemo
parents:
11391
diff
changeset

131 
//procedure doStepStructure(Gear: PGear); 
9285  132 
procedure doStepTardisWarp(Gear: PGear); 
133 
procedure doStepTardis(Gear: PGear); 

134 
procedure updateFuel(Gear: PGear); 

135 
procedure updateTarget(Gear:PGear; newX, newY:HWFloat); 

136 
procedure doStepIceGun(Gear: PGear); 

137 
procedure doStepAddAmmo(Gear: PGear); 

138 
procedure doStepGenericFaller(Gear: PGear); 

11468
2f6f8baa2a97
Make weapon damage in most cases be a structure value and also expose it to lua. Needs testing/review due to conditions at time of doing this (w/ one arm, dizzy/tingling due to sodium citrate), and just number of places changed..
nemo
parents:
11391
diff
changeset

139 
//procedure doStepCreeper(Gear: PGear); 
9285  140 
procedure doStepKnife(Gear: PGear); 
12192  141 
procedure doStepDuck(Gear: PGear); 
9285  142 

143 
var 

144 
upd: Longword; 

145 
snowLeft,snowRight: LongInt; 

146 

147 
implementation 

148 
uses uConsts, uVariables, uVisualGearsList, uRandom, uCollisions, uGearsList, uUtils, uSound 

149 
, SDLh, uScript, uGearsHedgehog, uGearsUtils, uIO, uCaptions, uLandGraphics 

150 
, uGearsHandlers, uTextures, uRenderUtils, uAmmos, uTeams, uLandTexture, uCommands 

12169
869cf5f34700
More ticker messages: Sick, king died, resurrect, time box return, timeout, kamikaze
Wuzzy <almikes@aol.com>
parents:
12120
diff
changeset

151 
, uStore, uAI, uStats, uLocale; 
5121
2d34ec60992c
added some comments in order to confuse the GSoC students as much as possible ;D
sheepluva
parents:
5076
diff
changeset

152 

3569  153 
procedure doStepPerPixel(Gear: PGear; step: TGearStepProcedure; onlyCheckIfChanged: boolean); 
154 
var 

155 
dX, dY, sX, sY: hwFloat; 

156 
i, steps: LongWord; 

157 
caller: TGearStepProcedure; 

158 
begin 

159 
dX:= Gear^.dX; 

160 
dY:= Gear^.dY; 

161 
steps:= max(abs(hwRound(Gear^.X+dX)hwRound(Gear^.X)), abs(hwRound(Gear^.Y+dY)hwRound(Gear^.Y))); 

162 

163 
// Gear is still on the same Pixel it was before 

164 
if steps < 1 then 

4578  165 
begin 
3569  166 
if onlyCheckIfChanged then 
4578  167 
begin 
3569  168 
Gear^.X := Gear^.X + dX; 
169 
Gear^.Y := Gear^.Y + dY; 

170 
EXIT; 

4578  171 
end 
3569  172 
else 
173 
steps := 1; 

4578  174 
end; 
3569  175 

176 
if steps > 1 then 

4578  177 
begin 
3569  178 
sX:= dX / steps; 
179 
sY:= dY / steps; 

4578  180 
end 
8795  181 

3569  182 
else 
4578  183 
begin 
3569  184 
sX:= dX; 
185 
sY:= dY; 

4578  186 
end; 
3569  187 

188 
caller:= Gear^.doStep; 

189 

190 
for i:= 1 to steps do 

4578  191 
begin 
3569  192 
Gear^.X := Gear^.X + sX; 
193 
Gear^.Y := Gear^.Y + sY; 

194 
step(Gear); 

195 
if (Gear^.doStep <> caller) 

196 
or ((Gear^.State and gstCollision) <> 0) 

197 
or ((Gear^.State and gstMoving) = 0) then 

198 
break; 

4578  199 
end; 
3569  200 
end; 
201 

2647  202 
procedure makeHogsWorry(x, y: hwFloat; r: LongInt); 
8795  203 
var 
3454
a9bef74bd6e0
Code restlyling: experimental restyling of one module
mbait
parents:
3440
diff
changeset

204 
gi: PGear; 
a9bef74bd6e0
Code restlyling: experimental restyling of one module
mbait
parents:
3440
diff
changeset

205 
d: LongInt; 
2647  206 
begin 
3454
a9bef74bd6e0
Code restlyling: experimental restyling of one module
mbait
parents:
3440
diff
changeset

207 
gi := GearsList; 
2948
3f21a9dc93d0
Replace tabs with spaces using 'expand t 4' command
unc0rr
parents:
2944
diff
changeset

208 
while gi <> nil do 
4578  209 
begin 
3454
a9bef74bd6e0
Code restlyling: experimental restyling of one module
mbait
parents:
3440
diff
changeset

210 
if (gi^.Kind = gtHedgehog) then 
4578  211 
begin 
3454
a9bef74bd6e0
Code restlyling: experimental restyling of one module
mbait
parents:
3440
diff
changeset

212 
d := r  hwRound(Distance(gi^.X  x, gi^.Y  y)); 
10011
ead5e4b21671
Add check for gear kind of hedgehog on invulnerability effect. This probably fixes bug #766, is similar to change in previous r2a1483d91977 and was introduced by r7d925e82e572
nemo
parents:
9998
diff
changeset

213 
if (d > 1) and (gi^.Hedgehog^.Effects[heInvulnerable] = 0) and (GetRandom(2) = 0) then 
4578  214 
begin 
3143  215 
if (CurrentHedgehog^.Gear = gi) then 
7053  216 
PlaySoundV(sndOops, gi^.Hedgehog^.Team^.voicepack) 
8795  217 

2948
3f21a9dc93d0
Replace tabs with spaces using 'expand t 4' command
unc0rr
parents:
2944
diff
changeset

218 
else 
4578  219 
begin 
8632
b5ed76d2a1f9
Make hogs thaw only on enemy turns, make timebox counter decrement only on your turn, adjust knock for frozen hogs, increase damage on frozen hogs, make freezer fuel only reduce when not adjusting angle.
nemo
parents:
8628
diff
changeset

220 
if ((gi^.State and gstMoving) = 0) and (gi^.Hedgehog^.Effects[heFrozen] = 0) then 
7829
c1dc7839d7b9
Set minimums on a few values to avoid camera zooming out past them. partly Issue #430. Might be worth defining a new constant for this.
nemo
parents:
7784
diff
changeset

221 
begin 
c1dc7839d7b9
Set minimums on a few values to avoid camera zooming out past them. partly Issue #430. Might be worth defining a new constant for this.
nemo
parents:
7784
diff
changeset

222 
gi^.dX.isNegative:= X<gi^.X; 
3454
a9bef74bd6e0
Code restlyling: experimental restyling of one module
mbait
parents:
3440
diff
changeset

223 
gi^.State := gi^.State or gstLoser; 
7829
c1dc7839d7b9
Set minimums on a few values to avoid camera zooming out past them. partly Issue #430. Might be worth defining a new constant for this.
nemo
parents:
7784
diff
changeset

224 
end; 
8795  225 

3143  226 
if d > r div 2 then 
8795  227 
PlaySoundV(sndNooo, gi^.Hedgehog^.Team^.voicepack) 
3143  228 
else 
7053  229 
PlaySoundV(sndUhOh, gi^.Hedgehog^.Team^.voicepack); 
4578  230 
end; 
2948
3f21a9dc93d0
Replace tabs with spaces using 'expand t 4' command
unc0rr
parents:
2944
diff
changeset

231 
end; 
3f21a9dc93d0
Replace tabs with spaces using 'expand t 4' command
unc0rr
parents:
2944
diff
changeset

232 
end; 
8795  233 

4578  234 
gi := gi^.NextGear 
2948
3f21a9dc93d0
Replace tabs with spaces using 'expand t 4' command
unc0rr
parents:
2944
diff
changeset

235 
end; 
2647  236 
end; 
5313
5e18eaef65d0
now scripts can create unique crates: dummy (empty) crates and booby traps. scripts can also set health crate values
Henek
parents:
5298
diff
changeset

237 

5807
5c8fe58dead5
Define 2 script callbacks to notify of hog vanishment
nemo
parents:
5806
diff
changeset

238 
procedure HideHog(HH: PHedgehog); 
5c8fe58dead5
Define 2 script callbacks to notify of hog vanishment
nemo
parents:
5806
diff
changeset

239 
begin 
6580
6155187bf599
A partial reformatting of the pascal code to have consistent syntax. Things that are still inconsistent.
lovelacer
parents:
6556
diff
changeset

240 
ScriptCall('onHogHide', HH^.Gear^.Uid); 
6155187bf599
A partial reformatting of the pascal code to have consistent syntax. Things that are still inconsistent.
lovelacer
parents:
6556
diff
changeset

241 
DeleteCI(HH^.Gear); 
6155187bf599
A partial reformatting of the pascal code to have consistent syntax. Things that are still inconsistent.
lovelacer
parents:
6556
diff
changeset

242 
if FollowGear = HH^.Gear then 
6155187bf599
A partial reformatting of the pascal code to have consistent syntax. Things that are still inconsistent.
lovelacer
parents:
6556
diff
changeset

243 
FollowGear:= nil; 
8795  244 

6580
6155187bf599
A partial reformatting of the pascal code to have consistent syntax. Things that are still inconsistent.
lovelacer
parents:
6556
diff
changeset

245 
if lastGearByUID = HH^.Gear then 
6155187bf599
A partial reformatting of the pascal code to have consistent syntax. Things that are still inconsistent.
lovelacer
parents:
6556
diff
changeset

246 
lastGearByUID := nil; 
8795  247 

7400
09427dbec1d8
Fix TARDIS, make switcher work w/ the new more stringent check.
nemo
parents:
7399
diff
changeset

248 
HH^.Gear^.Message:= HH^.Gear^.Message or gmRemoveFromList; 
6580
6155187bf599
A partial reformatting of the pascal code to have consistent syntax. Things that are still inconsistent.
lovelacer
parents:
6556
diff
changeset

249 
with HH^.Gear^ do 
6155187bf599
A partial reformatting of the pascal code to have consistent syntax. Things that are still inconsistent.
lovelacer
parents:
6556
diff
changeset

250 
begin 
6155187bf599
A partial reformatting of the pascal code to have consistent syntax. Things that are still inconsistent.
lovelacer
parents:
6556
diff
changeset

251 
Z := cHHZ; 
7400
09427dbec1d8
Fix TARDIS, make switcher work w/ the new more stringent check.
nemo
parents:
7399
diff
changeset

252 
HH^.Gear^.Active:= false; 
6580
6155187bf599
A partial reformatting of the pascal code to have consistent syntax. Things that are still inconsistent.
lovelacer
parents:
6556
diff
changeset

253 
State:= State and (not (gstHHDriven or gstAttacking or gstAttacked)); 
6155187bf599
A partial reformatting of the pascal code to have consistent syntax. Things that are still inconsistent.
lovelacer
parents:
6556
diff
changeset

254 
Message := Message and (not gmAttack); 
5807
5c8fe58dead5
Define 2 script callbacks to notify of hog vanishment
nemo
parents:
5806
diff
changeset

255 
end; 
6580
6155187bf599
A partial reformatting of the pascal code to have consistent syntax. Things that are still inconsistent.
lovelacer
parents:
6556
diff
changeset

256 
HH^.GearHidden:= HH^.Gear; 
6155187bf599
A partial reformatting of the pascal code to have consistent syntax. Things that are still inconsistent.
lovelacer
parents:
6556
diff
changeset

257 
HH^.Gear:= nil 
5807
5c8fe58dead5
Define 2 script callbacks to notify of hog vanishment
nemo
parents:
5806
diff
changeset

258 
end; 
5c8fe58dead5
Define 2 script callbacks to notify of hog vanishment
nemo
parents:
5806
diff
changeset

259 

4  260 

261 
//////////////////////////////////////////////////////////////////////////////// 

262 
procedure doStepDrowningGear(Gear: PGear); 

10364
9f7be3da1245
burst drowning gears into bubbles after timeout
sheepluva
parents:
10363
diff
changeset

263 
var i, d: LongInt; 
9f7be3da1245
burst drowning gears into bubbles after timeout
sheepluva
parents:
10363
diff
changeset

264 
bubble: PVisualGear; 
9f7be3da1245
burst drowning gears into bubbles after timeout
sheepluva
parents:
10363
diff
changeset

265 
begin 
9f7be3da1245
burst drowning gears into bubbles after timeout
sheepluva
parents:
10363
diff
changeset

266 
if Gear^.Timer = 0 then 
6580
6155187bf599
A partial reformatting of the pascal code to have consistent syntax. Things that are still inconsistent.
lovelacer
parents:
6556
diff
changeset

267 
begin 
10364
9f7be3da1245
burst drowning gears into bubbles after timeout
sheepluva
parents:
10363
diff
changeset

268 
d:= 2 * Gear^.Radius; 
9f7be3da1245
burst drowning gears into bubbles after timeout
sheepluva
parents:
10363
diff
changeset

269 
for i:= (Gear^.Radius * Gear^.Radius) div 4 downto 0 do 
9f7be3da1245
burst drowning gears into bubbles after timeout
sheepluva
parents:
10363
diff
changeset

270 
begin 
9f7be3da1245
burst drowning gears into bubbles after timeout
sheepluva
parents:
10363
diff
changeset

271 
bubble := AddVisualGear(hwRound(Gear^.X)  Gear^.Radius + random(d), hwRound(Gear^.Y)  Gear^.Radius + random(d), vgtBubble); 
9f7be3da1245
burst drowning gears into bubbles after timeout
sheepluva
parents:
10363
diff
changeset

272 
if bubble <> nil then 
9f7be3da1245
burst drowning gears into bubbles after timeout
sheepluva
parents:
10363
diff
changeset

273 
bubble^.dY:= 0.1 + random(20)/10; 
10354  274 
end; 
10364
9f7be3da1245
burst drowning gears into bubbles after timeout
sheepluva
parents:
10363
diff
changeset

275 
DeleteGear(Gear); 
9f7be3da1245
burst drowning gears into bubbles after timeout
sheepluva
parents:
10363
diff
changeset

276 
exit; 
9f7be3da1245
burst drowning gears into bubbles after timeout
sheepluva
parents:
10363
diff
changeset

277 
end; 
9f7be3da1245
burst drowning gears into bubbles after timeout
sheepluva
parents:
10363
diff
changeset

278 

9f7be3da1245
burst drowning gears into bubbles after timeout
sheepluva
parents:
10363
diff
changeset

279 
AllInactive := false; 
9f7be3da1245
burst drowning gears into bubbles after timeout
sheepluva
parents:
10363
diff
changeset

280 
dec(Gear^.Timer); 
9f7be3da1245
burst drowning gears into bubbles after timeout
sheepluva
parents:
10363
diff
changeset

281 

9f7be3da1245
burst drowning gears into bubbles after timeout
sheepluva
parents:
10363
diff
changeset

282 
Gear^.Y := Gear^.Y + cDrownSpeed; 
9f7be3da1245
burst drowning gears into bubbles after timeout
sheepluva
parents:
10363
diff
changeset

283 

9f7be3da1245
burst drowning gears into bubbles after timeout
sheepluva
parents:
10363
diff
changeset

284 
if cWaterLine > hwRound(Gear^.Y) + Gear^.Radius then 
9f7be3da1245
burst drowning gears into bubbles after timeout
sheepluva
parents:
10363
diff
changeset

285 
begin 
10494  286 
if LongInt(leftX) + Gear^.Radius > hwRound(Gear^.X) then 
10364
9f7be3da1245
burst drowning gears into bubbles after timeout
sheepluva
parents:
10363
diff
changeset

287 
Gear^.X := Gear^.X  cDrownSpeed 
10354  288 
else 
10364
9f7be3da1245
burst drowning gears into bubbles after timeout
sheepluva
parents:
10363
diff
changeset

289 
Gear^.X := Gear^.X + cDrownSpeed; 
9f7be3da1245
burst drowning gears into bubbles after timeout
sheepluva
parents:
10363
diff
changeset

290 
end 
9f7be3da1245
burst drowning gears into bubbles after timeout
sheepluva
parents:
10363
diff
changeset

291 
else 
9f7be3da1245
burst drowning gears into bubbles after timeout
sheepluva
parents:
10363
diff
changeset

292 
Gear^.X := Gear^.X + Gear^.dX * cDrownSpeed; 
9f7be3da1245
burst drowning gears into bubbles after timeout
sheepluva
parents:
10363
diff
changeset

293 

9f7be3da1245
burst drowning gears into bubbles after timeout
sheepluva
parents:
10363
diff
changeset

294 
// Create some bubbles (0.5% might be better but causes too few bubbles sometimes) 
9f7be3da1245
burst drowning gears into bubbles after timeout
sheepluva
parents:
10363
diff
changeset

295 
if ((not SuddenDeathDmg and (WaterOpacity < $FF)) 
9f7be3da1245
burst drowning gears into bubbles after timeout
sheepluva
parents:
10363
diff
changeset

296 
or (SuddenDeathDmg and (SDWaterOpacity < $FF))) and ((GameTicks and $1F) = 0) then 
9f7be3da1245
burst drowning gears into bubbles after timeout
sheepluva
parents:
10363
diff
changeset

297 
if (Gear^.Kind = gtHedgehog) and (Random(4) = 0) then 
9f7be3da1245
burst drowning gears into bubbles after timeout
sheepluva
parents:
10363
diff
changeset

298 
AddVisualGear(hwRound(Gear^.X)  Gear^.Radius, hwRound(Gear^.Y)  Gear^.Radius, vgtBubble) 
9f7be3da1245
burst drowning gears into bubbles after timeout
sheepluva
parents:
10363
diff
changeset

299 
else if Random(12) = 0 then 
9f7be3da1245
burst drowning gears into bubbles after timeout
sheepluva
parents:
10363
diff
changeset

300 
AddVisualGear(hwRound(Gear^.X)  Gear^.Radius, hwRound(Gear^.Y)  Gear^.Radius, vgtBubble); 
9f7be3da1245
burst drowning gears into bubbles after timeout
sheepluva
parents:
10363
diff
changeset

301 
if (not SuddenDeathDmg and (WaterOpacity > $FE)) 
9f7be3da1245
burst drowning gears into bubbles after timeout
sheepluva
parents:
10363
diff
changeset

302 
or (SuddenDeathDmg and (SDWaterOpacity > $FE)) 
9f7be3da1245
burst drowning gears into bubbles after timeout
sheepluva
parents:
10363
diff
changeset

303 
or (hwRound(Gear^.Y) > Gear^.Radius + cWaterLine + cVisibleWater) then 
9f7be3da1245
burst drowning gears into bubbles after timeout
sheepluva
parents:
10363
diff
changeset

304 
DeleteGear(Gear); 
9f7be3da1245
burst drowning gears into bubbles after timeout
sheepluva
parents:
10363
diff
changeset

305 
end; 
4  306 

307 
//////////////////////////////////////////////////////////////////////////////// 

308 
procedure doStepFallingGear(Gear: PGear); 

8795  309 
var 
3454
a9bef74bd6e0
Code restlyling: experimental restyling of one module
mbait
parents:
3440
diff
changeset

310 
isFalling: boolean; 
3020  311 
//tmp: QWord; 
9526  312 
tX, tdX, tdY: hwFloat; 
9769
5814e0c47c99
Experiment in adding a "boing" graphic for bouncing. It has no text right now (was thinking l10n) and colour is fixed.
nemo
parents:
9768
diff
changeset

313 
collV, collH, gX, gY: LongInt; 
9721
1833dadcebf0
Initial pass at bounciness. To try it out, or lfBouncy on girder in uLandGraphics (search for the word graphically)
nemo
parents:
9706
diff
changeset

314 
land, xland: word; 
4  315 
begin 
9526  316 
tX:= Gear^.X; 
9769
5814e0c47c99
Experiment in adding a "boing" graphic for bouncing. It has no text right now (was thinking l10n) and colour is fixed.
nemo
parents:
9768
diff
changeset

317 
gX:= hwRound(Gear^.X); 
5814e0c47c99
Experiment in adding a "boing" graphic for bouncing. It has no text right now (was thinking l10n) and colour is fixed.
nemo
parents:
9768
diff
changeset

318 
gY:= hwRound(Gear^.Y); 
9557  319 
if (Gear^.Kind <> gtGenericFaller) and WorldWrap(Gear) and (WorldEdge = weWrap) and (Gear^.AdvBounce <> 0) and 
9706
5178d2263521
return land word from uCollisions to make decisions based on it. Should be handy for trampoline.
nemo
parents:
9698
diff
changeset

320 
((TestCollisionXwithGear(Gear, 1) <> 0) or (TestCollisionXwithGear(Gear, 1) <> 0)) then 
9526  321 
begin 
322 
Gear^.X:= tX; 

9809  323 
Gear^.dX.isNegative:= (gX > LongInt(leftX) + Gear^.Radius*2) 
9526  324 
end; 
9473
a51a69094c24
partial implementation of noninfinite world (edge wrap/warp/bounce)
nemo
parents:
9470
diff
changeset

325 

7627  326 
// clip velocity at 2  over 1 per pixel, but really shouldn't cause many actual problems. 
9967
40750e72514b
keep velocity from fluttering between 2 and 3px / ms when falling...
nemo
parents:
9885
diff
changeset

327 
if Gear^.dX.Round > 1 then 
7627  328 
Gear^.dX.QWordValue:= 8589934592; 
9967
40750e72514b
keep velocity from fluttering between 2 and 3px / ms when falling...
nemo
parents:
9885
diff
changeset

329 
if Gear^.dY.Round > 1 then 
7627  330 
Gear^.dY.QWordValue:= 8589934592; 
8838
aa2ffd427f6a
strip PAS2C, old WEB symbols and outdated pas2c sources from default branch, all crelated development is done on the webgl branch
koda
parents:
8822
diff
changeset

331 

10354  332 
if (Gear^.State and gstSubmersible <> 0) and CheckCoordInWater(gX, gY) then 
8992
5b0be812dcdb
Rename submersible state, increase getaway time for attack underwater, slow down gear dx/dy underwater to simulate water resistance
nemo
parents:
8990
diff
changeset

333 
begin 
5b0be812dcdb
Rename submersible state, increase getaway time for attack underwater, slow down gear dx/dy underwater to simulate water resistance
nemo
parents:
8990
diff
changeset

334 
Gear^.dX:= Gear^.dX * _0_999; 
5b0be812dcdb
Rename submersible state, increase getaway time for attack underwater, slow down gear dx/dy underwater to simulate water resistance
nemo
parents:
8990
diff
changeset

335 
Gear^.dY:= Gear^.dY * _0_999 
5b0be812dcdb
Rename submersible state, increase getaway time for attack underwater, slow down gear dx/dy underwater to simulate water resistance
nemo
parents:
8990
diff
changeset

336 
end; 
5b0be812dcdb
Rename submersible state, increase getaway time for attack underwater, slow down gear dx/dy underwater to simulate water resistance
nemo
parents:
8990
diff
changeset

337 

6450  338 
Gear^.State := Gear^.State and (not gstCollision); 
3454
a9bef74bd6e0
Code restlyling: experimental restyling of one module
mbait
parents:
3440
diff
changeset

339 
collV := 0; 
a9bef74bd6e0
Code restlyling: experimental restyling of one module
mbait
parents:
3440
diff
changeset

340 
collH := 0; 
a9bef74bd6e0
Code restlyling: experimental restyling of one module
mbait
parents:
3440
diff
changeset

341 
tdX := Gear^.dX; 
a9bef74bd6e0
Code restlyling: experimental restyling of one module
mbait
parents:
3440
diff
changeset

342 
tdY := Gear^.dY; 
a9bef74bd6e0
Code restlyling: experimental restyling of one module
mbait
parents:
3440
diff
changeset

343 

3359  344 
// might need some testing/adjustments  just to avoid projectiles to fly forever (accelerated by wind/skips) 
9769
5814e0c47c99
Experiment in adding a "boing" graphic for bouncing. It has no text right now (was thinking l10n) and colour is fixed.
nemo
parents:
9768
diff
changeset

345 
if (gX < min(LAND_WIDTH div 2, 2048)) 
5814e0c47c99
Experiment in adding a "boing" graphic for bouncing. It has no text right now (was thinking l10n) and colour is fixed.
nemo
parents:
9768
diff
changeset

346 
or (gX > max(LAND_WIDTH * 3 div 2, 6144)) then 
11389
c93f204a5a00
Set gears that go off map to gmDestroy instead of collision, disable morewind for nogravity gears, restrict application of wind to gears that are already moving and not colliding.
nemo
parents:
11342
diff
changeset

347 
Gear^.Message := Gear^.Message or gmDestroy; 
3359  348 

3454
a9bef74bd6e0
Code restlyling: experimental restyling of one module
mbait
parents:
3440
diff
changeset

349 
if Gear^.dY.isNegative then 
4578  350 
begin 
6081
537bbd5c1a62
Basic test implementation of an ice flag. Allows for slick parts of terrain. Intended for ice gun, or "ice" mask on portions of land objects.
nemo
parents:
6011
diff
changeset

351 
land:= TestCollisionYwithGear(Gear, 1); 
9820  352 
isFalling := land = 0; 
6081
537bbd5c1a62
Basic test implementation of an ice flag. Allows for slick parts of terrain. Intended for ice gun, or "ice" mask on portions of land objects.
nemo
parents:
6011
diff
changeset

353 
if land <> 0 then 
4578  354 
begin 
3454
a9bef74bd6e0
Code restlyling: experimental restyling of one module
mbait
parents:
3440
diff
changeset

355 
collV := 1; 
6580
6155187bf599
A partial reformatting of the pascal code to have consistent syntax. Things that are still inconsistent.
lovelacer
parents:
6556
diff
changeset

356 
if land and lfIce <> 0 then 
9721
1833dadcebf0
Initial pass at bounciness. To try it out, or lfBouncy on girder in uLandGraphics (search for the word graphically)
nemo
parents:
9706
diff
changeset

357 
Gear^.dX := Gear^.dX * (_0_9 + Gear^.Friction * _0_1) 
1833dadcebf0
Initial pass at bounciness. To try it out, or lfBouncy on girder in uLandGraphics (search for the word graphically)
nemo
parents:
9706
diff
changeset

358 
else Gear^.dX := Gear^.dX * Gear^.Friction; 
9731
953197ac43d8
Make sticky mine respect lfBouncy, make hogs do same, kinda... make uCollisions return land w/ mask, restrict bouncy to advbounce gears only, which means piano doesn't bounce anymore
nemo
parents:
9724
diff
changeset

359 
if (Gear^.AdvBounce = 0) or (land and lfBouncy = 0) then 
9721
1833dadcebf0
Initial pass at bounciness. To try it out, or lfBouncy on girder in uLandGraphics (search for the word graphically)
nemo
parents:
9706
diff
changeset

360 
begin 
1833dadcebf0
Initial pass at bounciness. To try it out, or lfBouncy on girder in uLandGraphics (search for the word graphically)
nemo
parents:
9706
diff
changeset

361 
Gear^.dY :=  Gear^.dY * Gear^.Elasticity; 
1833dadcebf0
Initial pass at bounciness. To try it out, or lfBouncy on girder in uLandGraphics (search for the word graphically)
nemo
parents:
9706
diff
changeset

362 
Gear^.State := Gear^.State or gstCollision 
1833dadcebf0
Initial pass at bounciness. To try it out, or lfBouncy on girder in uLandGraphics (search for the word graphically)
nemo
parents:
9706
diff
changeset

363 
end 
1833dadcebf0
Initial pass at bounciness. To try it out, or lfBouncy on girder in uLandGraphics (search for the word graphically)
nemo
parents:
9706
diff
changeset

364 
else Gear^.dY :=  Gear^.dY * cElastic 
4578  365 
end 
9721
1833dadcebf0
Initial pass at bounciness. To try it out, or lfBouncy on girder in uLandGraphics (search for the word graphically)
nemo
parents:
9706
diff
changeset

366 
else if Gear^.AdvBounce = 1 then 
1833dadcebf0
Initial pass at bounciness. To try it out, or lfBouncy on girder in uLandGraphics (search for the word graphically)
nemo
parents:
9706
diff
changeset

367 
begin 
1833dadcebf0
Initial pass at bounciness. To try it out, or lfBouncy on girder in uLandGraphics (search for the word graphically)
nemo
parents:
9706
diff
changeset

368 
land:= TestCollisionYwithGear(Gear, 1); 
1833dadcebf0
Initial pass at bounciness. To try it out, or lfBouncy on girder in uLandGraphics (search for the word graphically)
nemo
parents:
9706
diff
changeset

369 
if land <> 0 then collV := 1 
1833dadcebf0
Initial pass at bounciness. To try it out, or lfBouncy on girder in uLandGraphics (search for the word graphically)
nemo
parents:
9706
diff
changeset

370 
end 
4578  371 
end 
8795  372 
else 
6498  373 
begin // Gear^.dY.isNegative is false 
6081
537bbd5c1a62
Basic test implementation of an ice flag. Allows for slick parts of terrain. Intended for ice gun, or "ice" mask on portions of land objects.
nemo
parents:
6011
diff
changeset

374 
land:= TestCollisionYwithGear(Gear, 1); 
537bbd5c1a62
Basic test implementation of an ice flag. Allows for slick parts of terrain. Intended for ice gun, or "ice" mask on portions of land objects.
nemo
parents:
6011
diff
changeset

375 
if land <> 0 then 
537bbd5c1a62
Basic test implementation of an ice flag. Allows for slick parts of terrain. Intended for ice gun, or "ice" mask on portions of land objects.
nemo
parents:
6011
diff
changeset

376 
begin 
537bbd5c1a62
Basic test implementation of an ice flag. Allows for slick parts of terrain. Intended for ice gun, or "ice" mask on portions of land objects.
nemo
parents:
6011
diff
changeset

377 
collV := 1; 
537bbd5c1a62
Basic test implementation of an ice flag. Allows for slick parts of terrain. Intended for ice gun, or "ice" mask on portions of land objects.
nemo
parents:
6011
diff
changeset

378 
isFalling := false; 
8795  379 
if land and lfIce <> 0 then 
6498  380 
Gear^.dX := Gear^.dX * (_0_9 + Gear^.Friction * _0_1) 
8795  381 
else 
6498  382 
Gear^.dX := Gear^.dX * Gear^.Friction; 
6081
537bbd5c1a62
Basic test implementation of an ice flag. Allows for slick parts of terrain. Intended for ice gun, or "ice" mask on portions of land objects.
nemo
parents:
6011
diff
changeset

383 

9731
953197ac43d8
Make sticky mine respect lfBouncy, make hogs do same, kinda... make uCollisions return land w/ mask, restrict bouncy to advbounce gears only, which means piano doesn't bounce anymore
nemo
parents:
9724
diff
changeset

384 
if (Gear^.AdvBounce = 0) or (land and lfBouncy = 0) then 
9721
1833dadcebf0
Initial pass at bounciness. To try it out, or lfBouncy on girder in uLandGraphics (search for the word graphically)
nemo
parents:
9706
diff
changeset

385 
begin 
1833dadcebf0
Initial pass at bounciness. To try it out, or lfBouncy on girder in uLandGraphics (search for the word graphically)
nemo
parents:
9706
diff
changeset

386 
Gear^.dY :=  Gear^.dY * Gear^.Elasticity; 
1833dadcebf0
Initial pass at bounciness. To try it out, or lfBouncy on girder in uLandGraphics (search for the word graphically)
nemo
parents:
9706
diff
changeset

387 
Gear^.State := Gear^.State or gstCollision 
1833dadcebf0
Initial pass at bounciness. To try it out, or lfBouncy on girder in uLandGraphics (search for the word graphically)
nemo
parents:
9706
diff
changeset

388 
end 
1833dadcebf0
Initial pass at bounciness. To try it out, or lfBouncy on girder in uLandGraphics (search for the word graphically)
nemo
parents:
9706
diff
changeset

389 
else Gear^.dY :=  Gear^.dY * cElastic 
6081
537bbd5c1a62
Basic test implementation of an ice flag. Allows for slick parts of terrain. Intended for ice gun, or "ice" mask on portions of land objects.
nemo
parents:
6011
diff
changeset

390 
end 
537bbd5c1a62
Basic test implementation of an ice flag. Allows for slick parts of terrain. Intended for ice gun, or "ice" mask on portions of land objects.
nemo
parents:
6011
diff
changeset

391 
else 
537bbd5c1a62
Basic test implementation of an ice flag. Allows for slick parts of terrain. Intended for ice gun, or "ice" mask on portions of land objects.
nemo
parents:
6011
diff
changeset

392 
begin 
537bbd5c1a62
Basic test implementation of an ice flag. Allows for slick parts of terrain. Intended for ice gun, or "ice" mask on portions of land objects.
nemo
parents:
6011
diff
changeset

393 
isFalling := true; 
9721
1833dadcebf0
Initial pass at bounciness. To try it out, or lfBouncy on girder in uLandGraphics (search for the word graphically)
nemo
parents:
9706
diff
changeset

394 
if Gear^.AdvBounce = 1 then 
1833dadcebf0
Initial pass at bounciness. To try it out, or lfBouncy on girder in uLandGraphics (search for the word graphically)
nemo
parents:
9706
diff
changeset

395 
begin 
1833dadcebf0
Initial pass at bounciness. To try it out, or lfBouncy on girder in uLandGraphics (search for the word graphically)
nemo
parents:
9706
diff
changeset

396 
land:= TestCollisionYwithGear(Gear, 1); 
1833dadcebf0
Initial pass at bounciness. To try it out, or lfBouncy on girder in uLandGraphics (search for the word graphically)
nemo
parents:
9706
diff
changeset

397 
if land <> 0 then collV := 1 
1833dadcebf0
Initial pass at bounciness. To try it out, or lfBouncy on girder in uLandGraphics (search for the word graphically)
nemo
parents:
9706
diff
changeset

398 
end 
6081
537bbd5c1a62
Basic test implementation of an ice flag. Allows for slick parts of terrain. Intended for ice gun, or "ice" mask on portions of land objects.
nemo
parents:
6011
diff
changeset

399 
end 
4578  400 
end; 
503  401 

2989
b49d87499398
Add back sheepluva's 45Â° patch for some weapons. Rescale Tiy's latest icons to his specifications.
nemo
parents:
2983
diff
changeset

402 

9721
1833dadcebf0
Initial pass at bounciness. To try it out, or lfBouncy on girder in uLandGraphics (search for the word graphically)
nemo
parents:
9706
diff
changeset

403 
xland:= TestCollisionXwithGear(Gear, hwSign(Gear^.dX)); 
1833dadcebf0
Initial pass at bounciness. To try it out, or lfBouncy on girder in uLandGraphics (search for the word graphically)
nemo
parents:
9706
diff
changeset

404 
if xland <> 0 then 
4578  405 
begin 
3454
a9bef74bd6e0
Code restlyling: experimental restyling of one module
mbait
parents:
3440
diff
changeset

406 
collH := hwSign(Gear^.dX); 
9731
953197ac43d8
Make sticky mine respect lfBouncy, make hogs do same, kinda... make uCollisions return land w/ mask, restrict bouncy to advbounce gears only, which means piano doesn't bounce anymore
nemo
parents:
9724
diff
changeset

407 
if (Gear^.AdvBounce = 0) or (xland and lfBouncy = 0) then 
9721
1833dadcebf0
Initial pass at bounciness. To try it out, or lfBouncy on girder in uLandGraphics (search for the word graphically)
nemo
parents:
9706
diff
changeset

408 
begin 
1833dadcebf0
Initial pass at bounciness. To try it out, or lfBouncy on girder in uLandGraphics (search for the word graphically)
nemo
parents:
9706
diff
changeset

409 
Gear^.dX :=  Gear^.dX * Gear^.Elasticity; 
1833dadcebf0
Initial pass at bounciness. To try it out, or lfBouncy on girder in uLandGraphics (search for the word graphically)
nemo
parents:
9706
diff
changeset

410 
Gear^.dY := Gear^.dY * Gear^.Elasticity; 
1833dadcebf0
Initial pass at bounciness. To try it out, or lfBouncy on girder in uLandGraphics (search for the word graphically)
nemo
parents:
9706
diff
changeset

411 
Gear^.State := Gear^.State or gstCollision 
1833dadcebf0
Initial pass at bounciness. To try it out, or lfBouncy on girder in uLandGraphics (search for the word graphically)
nemo
parents:
9706
diff
changeset

412 
end 
1833dadcebf0
Initial pass at bounciness. To try it out, or lfBouncy on girder in uLandGraphics (search for the word graphically)
nemo
parents:
9706
diff
changeset

413 
else 
1833dadcebf0
Initial pass at bounciness. To try it out, or lfBouncy on girder in uLandGraphics (search for the word graphically)
nemo
parents:
9706
diff
changeset

414 
begin 
1833dadcebf0
Initial pass at bounciness. To try it out, or lfBouncy on girder in uLandGraphics (search for the word graphically)
nemo
parents:
9706
diff
changeset

415 
Gear^.dX :=  Gear^.dX * cElastic; 
1833dadcebf0
Initial pass at bounciness. To try it out, or lfBouncy on girder in uLandGraphics (search for the word graphically)
nemo
parents:
9706
diff
changeset

416 
Gear^.dY := Gear^.dY * cElastic 
1833dadcebf0
Initial pass at bounciness. To try it out, or lfBouncy on girder in uLandGraphics (search for the word graphically)
nemo
parents:
9706
diff
changeset

417 
end 
4578  418 
end 
9721
1833dadcebf0
Initial pass at bounciness. To try it out, or lfBouncy on girder in uLandGraphics (search for the word graphically)
nemo
parents:
9706
diff
changeset

419 
else if Gear^.AdvBounce = 1 then 
1833dadcebf0
Initial pass at bounciness. To try it out, or lfBouncy on girder in uLandGraphics (search for the word graphically)
nemo
parents:
9706
diff
changeset

420 
begin 
1833dadcebf0
Initial pass at bounciness. To try it out, or lfBouncy on girder in uLandGraphics (search for the word graphically)
nemo
parents:
9706
diff
changeset

421 
xland:= TestCollisionXwithGear(Gear, hwSign(Gear^.dX)); 
1833dadcebf0
Initial pass at bounciness. To try it out, or lfBouncy on girder in uLandGraphics (search for the word graphically)
nemo
parents:
9706
diff
changeset

422 
if xland <> 0 then collH := hwSign(Gear^.dX) 
1833dadcebf0
Initial pass at bounciness. To try it out, or lfBouncy on girder in uLandGraphics (search for the word graphically)
nemo
parents:
9706
diff
changeset

423 
end; 
3454
a9bef74bd6e0
Code restlyling: experimental restyling of one module
mbait
parents:
3440
diff
changeset

424 
//if Gear^.AdvBounce and (collV <>0) and (collH <> 0) and (hwSqr(tdX) + hwSqr(tdY) > _0_08) then 
10015  425 
if (collV <> 0) and (collH <> 0) and 
9731
953197ac43d8
Make sticky mine respect lfBouncy, make hogs do same, kinda... make uCollisions return land w/ mask, restrict bouncy to advbounce gears only, which means piano doesn't bounce anymore
nemo
parents:
9724
diff
changeset

426 
(((Gear^.AdvBounce=1) and ((collV=1) or ((tdX.QWordValue + tdY.QWordValue) > _0_2.QWordValue)))) then 
953197ac43d8
Make sticky mine respect lfBouncy, make hogs do same, kinda... make uCollisions return land w/ mask, restrict bouncy to advbounce gears only, which means piano doesn't bounce anymore
nemo
parents:
9724
diff
changeset

427 
//or ((xland or land) and lfBouncy <> 0)) then 
9721
1833dadcebf0
Initial pass at bounciness. To try it out, or lfBouncy on girder in uLandGraphics (search for the word graphically)
nemo
parents:
9706
diff
changeset

428 
begin 
1833dadcebf0
Initial pass at bounciness. To try it out, or lfBouncy on girder in uLandGraphics (search for the word graphically)
nemo
parents:
9706
diff
changeset

429 
if (xland or land) and lfBouncy = 0 then 
1833dadcebf0
Initial pass at bounciness. To try it out, or lfBouncy on girder in uLandGraphics (search for the word graphically)
nemo
parents:
9706
diff
changeset

430 
begin 
1833dadcebf0
Initial pass at bounciness. To try it out, or lfBouncy on girder in uLandGraphics (search for the word graphically)
nemo
parents:
9706
diff
changeset

431 
Gear^.dX := tdY*Gear^.Elasticity*Gear^.Friction; 
9767  432 
Gear^.dY := tdX*Gear^.Elasticity; 
433 
Gear^.State := Gear^.State or gstCollision 

9721
1833dadcebf0
Initial pass at bounciness. To try it out, or lfBouncy on girder in uLandGraphics (search for the word graphically)
nemo
parents:
9706
diff
changeset

434 
end 
1833dadcebf0
Initial pass at bounciness. To try it out, or lfBouncy on girder in uLandGraphics (search for the word graphically)
nemo
parents:
9706
diff
changeset

435 
else 
1833dadcebf0
Initial pass at bounciness. To try it out, or lfBouncy on girder in uLandGraphics (search for the word graphically)
nemo
parents:
9706
diff
changeset

436 
begin 
1833dadcebf0
Initial pass at bounciness. To try it out, or lfBouncy on girder in uLandGraphics (search for the word graphically)
nemo
parents:
9706
diff
changeset

437 
Gear^.dX := tdY*cElastic*Gear^.Friction; 
1833dadcebf0
Initial pass at bounciness. To try it out, or lfBouncy on girder in uLandGraphics (search for the word graphically)
nemo
parents:
9706
diff
changeset

438 
Gear^.dY := tdX*cElastic 
1833dadcebf0
Initial pass at bounciness. To try it out, or lfBouncy on girder in uLandGraphics (search for the word graphically)
nemo
parents:
9706
diff
changeset

439 
end; 
1833dadcebf0
Initial pass at bounciness. To try it out, or lfBouncy on girder in uLandGraphics (search for the word graphically)
nemo
parents:
9706
diff
changeset

440 

10895
bce67defd804
Make bouncing a bit less wtf for various gears tested (hog, 'zooka, saucer hog, drill strike). Less hacky is another matter.
nemo
parents:
10887
diff
changeset

441 
Gear^.dX.isNegative:= tdX.isNegative; 
bce67defd804
Make bouncing a bit less wtf for various gears tested (hog, 'zooka, saucer hog, drill strike). Less hacky is another matter.
nemo
parents:
10887
diff
changeset

442 
Gear^.dY.isNegative:= tdY.isNegative; 
bce67defd804
Make bouncing a bit less wtf for various gears tested (hog, 'zooka, saucer hog, drill strike). Less hacky is another matter.
nemo
parents:
10887
diff
changeset

443 
if (collV > 0) and (collH > 0) and (not tdX.isNegative) and (not tdY.isNegative) then 
bce67defd804
Make bouncing a bit less wtf for various gears tested (hog, 'zooka, saucer hog, drill strike). Less hacky is another matter.
nemo
parents:
10887
diff
changeset

444 
begin 
bce67defd804
Make bouncing a bit less wtf for various gears tested (hog, 'zooka, saucer hog, drill strike). Less hacky is another matter.
nemo
parents:
10887
diff
changeset

445 
Gear^.dX.isNegative := true; 
bce67defd804
Make bouncing a bit less wtf for various gears tested (hog, 'zooka, saucer hog, drill strike). Less hacky is another matter.
nemo
parents:
10887
diff
changeset

446 
Gear^.dY.isNegative := true 
bce67defd804
Make bouncing a bit less wtf for various gears tested (hog, 'zooka, saucer hog, drill strike). Less hacky is another matter.
nemo
parents:
10887
diff
changeset

447 
end 
bce67defd804
Make bouncing a bit less wtf for various gears tested (hog, 'zooka, saucer hog, drill strike). Less hacky is another matter.
nemo
parents:
10887
diff
changeset

448 
else if (collV > 0) and (collH < 0) and (tdX.isNegative or tdY.isNegative) then 
bce67defd804
Make bouncing a bit less wtf for various gears tested (hog, 'zooka, saucer hog, drill strike). Less hacky is another matter.
nemo
parents:
10887
diff
changeset

449 
begin 
bce67defd804
Make bouncing a bit less wtf for various gears tested (hog, 'zooka, saucer hog, drill strike). Less hacky is another matter.
nemo
parents:
10887
diff
changeset

450 
Gear^.dY.isNegative := not tdY.isNegative; 
bce67defd804
Make bouncing a bit less wtf for various gears tested (hog, 'zooka, saucer hog, drill strike). Less hacky is another matter.
nemo
parents:
10887
diff
changeset

451 
if not tdY.isNegative then Gear^.dX.isNegative := false 
bce67defd804
Make bouncing a bit less wtf for various gears tested (hog, 'zooka, saucer hog, drill strike). Less hacky is another matter.
nemo
parents:
10887
diff
changeset

452 
end 
bce67defd804
Make bouncing a bit less wtf for various gears tested (hog, 'zooka, saucer hog, drill strike). Less hacky is another matter.
nemo
parents:
10887
diff
changeset

453 
else if (collV < 0) and (collH > 0) and (not tdX.isNegative) then 
bce67defd804
Make bouncing a bit less wtf for various gears tested (hog, 'zooka, saucer hog, drill strike). Less hacky is another matter.
nemo
parents:
10887
diff
changeset

454 
begin 
bce67defd804
Make bouncing a bit less wtf for various gears tested (hog, 'zooka, saucer hog, drill strike). Less hacky is another matter.
nemo
parents:
10887
diff
changeset

455 
Gear^.dX.isNegative := true; 
bce67defd804
Make bouncing a bit less wtf for various gears tested (hog, 'zooka, saucer hog, drill strike). Less hacky is another matter.
nemo
parents:
10887
diff
changeset

456 
Gear^.dY.isNegative := false 
bce67defd804
Make bouncing a bit less wtf for various gears tested (hog, 'zooka, saucer hog, drill strike). Less hacky is another matter.
nemo
parents:
10887
diff
changeset

457 
end 
bce67defd804
Make bouncing a bit less wtf for various gears tested (hog, 'zooka, saucer hog, drill strike). Less hacky is another matter.
nemo
parents:
10887
diff
changeset

458 
else if (collV < 0) and (collH < 0) and tdX.isNegative and tdY.isNegative then 
bce67defd804
Make bouncing a bit less wtf for various gears tested (hog, 'zooka, saucer hog, drill strike). Less hacky is another matter.
nemo
parents:
10887
diff
changeset

459 
Gear^.dX.isNegative := false; 
bce67defd804
Make bouncing a bit less wtf for various gears tested (hog, 'zooka, saucer hog, drill strike). Less hacky is another matter.
nemo
parents:
10887
diff
changeset

460 

3454
a9bef74bd6e0
Code restlyling: experimental restyling of one module
mbait
parents:
3440
diff
changeset

461 
isFalling := false; 
a9bef74bd6e0
Code restlyling: experimental restyling of one module
mbait
parents:
3440
diff
changeset

462 
Gear^.AdvBounce := 10; 
4578  463 
end; 
503  464 

6580
6155187bf599
A partial reformatting of the pascal code to have consistent syntax. Things that are still inconsistent.
lovelacer
parents:
6556
diff
changeset

465 
if Gear^.AdvBounce > 1 then 
6155187bf599
A partial reformatting of the pascal code to have consistent syntax. Things that are still inconsistent.
lovelacer
parents:
6556
diff
changeset

466 
dec(Gear^.AdvBounce); 
3454
a9bef74bd6e0
Code restlyling: experimental restyling of one module
mbait
parents:
3440
diff
changeset

467 

11389
c93f204a5a00
Set gears that go off map to gmDestroy instead of collision, disable morewind for nogravity gears, restrict application of wind to gears that are already moving and not colliding.
nemo
parents:
11342
diff
changeset

468 
if isFalling and (Gear^.State and gstNoGravity = 0) then 
c93f204a5a00
Set gears that go off map to gmDestroy instead of collision, disable morewind for nogravity gears, restrict application of wind to gears that are already moving and not colliding.
nemo
parents:
11342
diff
changeset

469 
begin 
c93f204a5a00
Set gears that go off map to gmDestroy instead of collision, disable morewind for nogravity gears, restrict application of wind to gears that are already moving and not colliding.
nemo
parents:
11342
diff
changeset

470 
Gear^.dY := Gear^.dY + cGravity; 
c93f204a5a00
Set gears that go off map to gmDestroy instead of collision, disable morewind for nogravity gears, restrict application of wind to gears that are already moving and not colliding.
nemo
parents:
11342
diff
changeset

471 
if (GameFlags and gfMoreWind <> 0) and 
c93f204a5a00
Set gears that go off map to gmDestroy instead of collision, disable morewind for nogravity gears, restrict application of wind to gears that are already moving and not colliding.
nemo
parents:
11342
diff
changeset

472 
((xland or land) = 0) and 
c93f204a5a00
Set gears that go off map to gmDestroy instead of collision, disable morewind for nogravity gears, restrict application of wind to gears that are already moving and not colliding.
nemo
parents:
11342
diff
changeset

473 
((Gear^.dX.QWordValue + Gear^.dY.QWordValue) > _0_02.QWordValue) then 
6580
6155187bf599
A partial reformatting of the pascal code to have consistent syntax. Things that are still inconsistent.
lovelacer
parents:
6556
diff
changeset

474 
Gear^.dX := Gear^.dX + cWindSpeed / Gear^.Density 
9820  475 
end; 
3454
a9bef74bd6e0
Code restlyling: experimental restyling of one module
mbait
parents:
3440
diff
changeset

476 

a9bef74bd6e0
Code restlyling: experimental restyling of one module
mbait
parents:
3440
diff
changeset

477 
Gear^.X := Gear^.X + Gear^.dX; 
a9bef74bd6e0
Code restlyling: experimental restyling of one module
mbait
parents:
3440
diff
changeset

478 
Gear^.Y := Gear^.Y + Gear^.dY; 
9479
167dea42d7d7
move border back a bit from left/right bounds, bee tweak
nemo
parents:
9477
diff
changeset

479 
CheckGearDrowning(Gear); 
3454
a9bef74bd6e0
Code restlyling: experimental restyling of one module
mbait
parents:
3440
diff
changeset

480 
//if (hwSqr(Gear^.dX) + hwSqr(Gear^.dY) < _0_0002) and 
6498  481 
if (not isFalling) and ((Gear^.dX.QWordValue + Gear^.dY.QWordValue) < _0_02.QWordValue) then 
6450  482 
Gear^.State := Gear^.State and (not gstMoving) 
3454
a9bef74bd6e0
Code restlyling: experimental restyling of one module
mbait
parents:
3440
diff
changeset

483 
else 
6580
6155187bf599
A partial reformatting of the pascal code to have consistent syntax. Things that are still inconsistent.
lovelacer
parents:
6556
diff
changeset

484 
Gear^.State := Gear^.State or gstMoving; 
6155187bf599
A partial reformatting of the pascal code to have consistent syntax. Things that are still inconsistent.
lovelacer
parents:
6556
diff
changeset

485 

9731
953197ac43d8
Make sticky mine respect lfBouncy, make hogs do same, kinda... make uCollisions return land w/ mask, restrict bouncy to advbounce gears only, which means piano doesn't bounce anymore
nemo
parents:
9724
diff
changeset

486 
if ((xland or land) and lfBouncy <> 0) and (Gear^.dX.QWordValue < _0_15.QWordValue) and (Gear^.dY.QWordValue < _0_15.QWordValue) then 
9721
1833dadcebf0
Initial pass at bounciness. To try it out, or lfBouncy on girder in uLandGraphics (search for the word graphically)
nemo
parents:
9706
diff
changeset

487 
Gear^.State := Gear^.State or gstCollision; 
10015  488 

9769
5814e0c47c99
Experiment in adding a "boing" graphic for bouncing. It has no text right now (was thinking l10n) and colour is fixed.
nemo
parents:
9768
diff
changeset

489 
if ((xland or land) and lfBouncy <> 0) and (Gear^.Radius >= 3) and 
5814e0c47c99
Experiment in adding a "boing" graphic for bouncing. It has no text right now (was thinking l10n) and colour is fixed.
nemo
parents:
9768
diff
changeset

490 
((Gear^.dX.QWordValue > _0_15.QWordValue) or (Gear^.dY.QWordValue > _0_15.QWordValue)) then 
5814e0c47c99
Experiment in adding a "boing" graphic for bouncing. It has no text right now (was thinking l10n) and colour is fixed.
nemo
parents:
9768
diff
changeset

491 
begin 
10508  492 
AddBounceEffectForGear(Gear); 
9769
5814e0c47c99
Experiment in adding a "boing" graphic for bouncing. It has no text right now (was thinking l10n) and colour is fixed.
nemo
parents:
9768
diff
changeset

493 
end 
9721
1833dadcebf0
Initial pass at bounciness. To try it out, or lfBouncy on girder in uLandGraphics (search for the word graphically)
nemo
parents:
9706
diff
changeset

494 
else if (Gear^.nImpactSounds > 0) and 
7777  495 
(Gear^.State and gstCollision <> 0) and 
496 
(((Gear^.Kind <> gtMine) and (Gear^.Damage <> 0)) or (Gear^.State and gstMoving <> 0)) and 

497 
(((Gear^.Radius < 3) and (Gear^.dY < _0_1)) or 

8795  498 
((Gear^.Radius >= 3) and 
7777  499 
((Gear^.dX.QWordValue > _0_1.QWordValue) or (Gear^.dY.QWordValue > _0_1.QWordValue)))) then 
5461  500 
PlaySound(TSound(ord(Gear^.ImpactSound) + LongInt(GetRandom(Gear^.nImpactSounds))), true); 
4  501 
end; 
502 

503 
//////////////////////////////////////////////////////////////////////////////// 

504 
procedure doStepBomb(Gear: PGear); 

8795  505 
var 
3454
a9bef74bd6e0
Code restlyling: experimental restyling of one module
mbait
parents:
3440
diff
changeset

506 
i, x, y: LongInt; 
8413
454191defee6
restore former cluster behaviour (makes the most diff for the bomb)
nemo
parents:
8370
diff
changeset

507 
dX, dY, gdX: hwFloat; 
3475  508 
vg: PVisualGear; 
4  509 
begin 
3454
a9bef74bd6e0
Code restlyling: experimental restyling of one module
mbait
parents:
3440
diff
changeset

510 
AllInactive := false; 
a9bef74bd6e0
Code restlyling: experimental restyling of one module
mbait
parents:
3440
diff
changeset

511 

a9bef74bd6e0
Code restlyling: experimental restyling of one module
mbait
parents:
3440
diff
changeset

512 
doStepFallingGear(Gear); 
a9bef74bd6e0
Code restlyling: experimental restyling of one module
mbait
parents:
3440
diff
changeset

513 

a9bef74bd6e0
Code restlyling: experimental restyling of one module
mbait
parents:
3440
diff
changeset

514 
dec(Gear^.Timer); 
a9bef74bd6e0
Code restlyling: experimental restyling of one module
mbait
parents:
3440
diff
changeset

515 
if Gear^.Timer = 1000 then // might need adjustments 
8795  516 
case Gear^.Kind of 
11468
2f6f8baa2a97
Make weapon damage in most cases be a structure value and also expose it to lua. Needs testing/review due to conditions at time of doing this (w/ one arm, dizzy/tingling due to sodium citrate), and just number of places changed..
nemo
parents:
11391
diff
changeset

517 
gtGrenade, 
2f6f8baa2a97
Make weapon damage in most cases be a structure value and also expose it to lua. Needs testing/review due to conditions at time of doing this (w/ one arm, dizzy/tingling due to sodium citrate), and just number of places changed..
nemo
parents:
11391
diff
changeset

518 
gtClusterBomb, 
2f6f8baa2a97
Make weapon damage in most cases be a structure value and also expose it to lua. Needs testing/review due to conditions at time of doing this (w/ one arm, dizzy/tingling due to sodium citrate), and just number of places changed..
nemo
parents:
11391
diff
changeset

519 
gtWatermelon, 
2f6f8baa2a97
Make weapon damage in most cases be a structure value and also expose it to lua. Needs testing/review due to conditions at time of doing this (w/ one arm, dizzy/tingling due to sodium citrate), and just number of places changed..
nemo
parents:
11391
diff
changeset

520 
gtHellishBomb: makeHogsWorry(Gear^.X, Gear^.Y, Gear^.Boom); 
3454
a9bef74bd6e0
Code restlyling: experimental restyling of one module
mbait
parents:
3440
diff
changeset

521 
gtGasBomb: makeHogsWorry(Gear^.X, Gear^.Y, 50); 
a9bef74bd6e0
Code restlyling: experimental restyling of one module
mbait
parents:
3440
diff
changeset

522 
end; 
a9bef74bd6e0
Code restlyling: experimental restyling of one module
mbait
parents:
3440
diff
changeset

523 

a9bef74bd6e0
Code restlyling: experimental restyling of one module
mbait
parents:
3440
diff
changeset

524 
if (Gear^.Kind = gtBall) and ((Gear^.State and gstTmpFlag) <> 0) then 
6580
6155187bf599
A partial reformatting of the pascal code to have consistent syntax. Things that are still inconsistent.
lovelacer
parents:
6556
diff
changeset

525 
begin 
3454
a9bef74bd6e0
Code restlyling: experimental restyling of one module
mbait
parents:
3440
diff
changeset

526 
CheckCollision(Gear); 
a9bef74bd6e0
Code restlyling: experimental restyling of one module
mbait
parents:
3440
diff
changeset

527 
if (Gear^.State and gstCollision) <> 0 then 
11468
2f6f8baa2a97
Make weapon damage in most cases be a structure value and also expose it to lua. Needs testing/review due to conditions at time of doing this (w/ one arm, dizzy/tingling due to sodium citrate), and just number of places changed..
nemo
parents:
11391
diff
changeset

528 
doMakeExplosion(hwRound(Gear^.X), hwRound(Gear^.Y), Gear^.Boom, Gear^.Hedgehog, EXPLDontDraw or EXPLNoGfx); 
7726
1137406bce12
Set default collision mask for gears at currenthedgehog X/Y to FF7F, expose mask to scripting as well. This should resolve the collision part of bug #420
nemo
parents:
7721
diff
changeset

529 
end; 
3004  530 

3475  531 
if (Gear^.Kind = gtGasBomb) and ((GameTicks mod 200) = 0) then 
6580
6155187bf599
A partial reformatting of the pascal code to have consistent syntax. Things that are still inconsistent.
lovelacer
parents:
6556
diff
changeset

532 
begin 
3475  533 
vg:= AddVisualGear(hwRound(Gear^.X), hwRound(Gear^.Y), vgtSmokeWhite); 
534 
if vg <> nil then 

535 
vg^.Tint:= $FFC0C000; 

7726
1137406bce12
Set default collision mask for gears at currenthedgehog X/Y to FF7F, expose mask to scripting as well. This should resolve the collision part of bug #420
nemo
parents:
7721
diff
changeset

536 
end; 
3475  537 

3454
a9bef74bd6e0
Code restlyling: experimental restyling of one module
mbait
parents:
3440
diff
changeset

538 
if Gear^.Timer = 0 then 
6580
6155187bf599
A partial reformatting of the pascal code to have consistent syntax. Things that are still inconsistent.
lovelacer
parents:
6556
diff
changeset

539 
begin 
8795  540 
case Gear^.Kind of 
11468
2f6f8baa2a97
Make weapon damage in most cases be a structure value and also expose it to lua. Needs testing/review due to conditions at time of doing this (w/ one arm, dizzy/tingling due to sodium citrate), and just number of places changed..
nemo
parents:
11391
diff
changeset

541 
gtGrenade: doMakeExplosion(hwRound(Gear^.X), hwRound(Gear^.Y), Gear^.Boom, Gear^.Hedgehog, EXPLAutoSound); 
2f6f8baa2a97
Make weapon damage in most cases be a structure value and also expose it to lua. Needs testing/review due to conditions at time of doing this (w/ one arm, dizzy/tingling due to sodium citrate), and just number of places changed..
nemo
parents:
11391
diff
changeset

542 
gtBall: doMakeExplosion(hwRound(Gear^.X), hwRound(Gear^.Y), Gear^.Boom, Gear^.Hedgehog, EXPLAutoSound); 
8795  543 
gtClusterBomb: 
3476
1ec68b8d3bd1
Henek adds a flamethrower, updates some translations, and tweaks how fire works.
nemo
parents:
3475
diff
changeset

544 
begin 
6580
6155187bf599
A partial reformatting of the pascal code to have consistent syntax. Things that are still inconsistent.
lovelacer
parents:
6556
diff
changeset

545 
x := hwRound(Gear^.X); 
6155187bf599
A partial reformatting of the pascal code to have consistent syntax. Things that are still inconsistent.
lovelacer
parents:
6556
diff
changeset

546 
y := hwRound(Gear^.Y); 
8413
454191defee6
restore former cluster behaviour (makes the most diff for the bomb)
nemo
parents:
8370
diff
changeset

547 
gdX:= Gear^.dX; 
11468
2f6f8baa2a97
Make weapon damage in most cases be a structure value and also expose it to lua. Needs testing/review due to conditions at time of doing this (w/ one arm, dizzy/tingling due to sodium citrate), and just number of places changed..
nemo
parents:
11391
diff
changeset

548 
doMakeExplosion(x, y, Gear^.Boom, Gear^.Hedgehog, EXPLAutoSound); 
6580
6155187bf599
A partial reformatting of the pascal code to have consistent syntax. Things that are still inconsistent.
lovelacer
parents:
6556
diff
changeset

549 
for i:= 0 to 4 do 
6155187bf599
A partial reformatting of the pascal code to have consistent syntax. Things that are still inconsistent.
lovelacer
parents:
6556
diff
changeset

550 
begin 
8413
454191defee6
restore former cluster behaviour (makes the most diff for the bomb)
nemo
parents:
8370
diff
changeset

551 
dX := rndSign(GetRandomf * _0_1) + gdX / 5; 
7001  552 
dY := (GetRandomf  _3) * _0_08; 
6580
6155187bf599
A partial reformatting of the pascal code to have consistent syntax. Things that are still inconsistent.
lovelacer
parents:
6556
diff
changeset

553 
FollowGear := AddGear(x, y, gtCluster, 0, dX, dY, 25) 
6155187bf599
A partial reformatting of the pascal code to have consistent syntax. Things that are still inconsistent.
lovelacer
parents:
6556
diff
changeset

554 
end 
3476
1ec68b8d3bd1
Henek adds a flamethrower, updates some translations, and tweaks how fire works.
nemo
parents:
3475
diff
changeset

555 
end; 
8795  556 
gtWatermelon: 
3476
1ec68b8d3bd1
Henek adds a flamethrower, updates some translations, and tweaks how fire works.
nemo
parents:
3475
diff
changeset

557 
begin 
1ec68b8d3bd1
Henek adds a flamethrower, updates some translations, and tweaks how fire works.
nemo
parents:
3475
diff
changeset

558 
x := hwRound(Gear^.X); 
1ec68b8d3bd1
Henek adds a flamethrower, updates some translations, and tweaks how fire works.
nemo
parents:
3475
diff
changeset

559 
y := hwRound(Gear^.Y); 
8413
454191defee6
restore former cluster behaviour (makes the most diff for the bomb)
nemo
parents:
8370
diff
changeset

560 
gdX:= Gear^.dX; 
11468
2f6f8baa2a97
Make weapon damage in most cases be a structure value and also expose it to lua. Needs testing/review due to conditions at time of doing this (w/ one arm, dizzy/tingling due to sodium citrate), and just number of places changed..
nemo
parents:
11391
diff
changeset

561 
doMakeExplosion(x, y, Gear^.Boom, Gear^.Hedgehog, EXPLAutoSound); 
3476
1ec68b8d3bd1
Henek adds a flamethrower, updates some translations, and tweaks how fire works.
nemo
parents:
3475
diff
changeset

562 
for i:= 0 to 5 do 
1ec68b8d3bd1
Henek adds a flamethrower, updates some translations, and tweaks how fire works.
nemo
parents:
3475
diff
changeset

563 
begin 
8413
454191defee6
restore former cluster behaviour (makes the most diff for the bomb)
nemo
parents:
8370
diff
changeset

564 
dX := rndSign(GetRandomf * _0_1) + gdX / 5; 
7001  565 
dY := (GetRandomf  _1_5) * _0_3; 
6120  566 
FollowGear:= AddGear(x, y, gtMelonPiece, 0, dX, dY, 75); 
567 
FollowGear^.DirAngle := i * 60 

3476
1ec68b8d3bd1
Henek adds a flamethrower, updates some translations, and tweaks how fire works.
nemo
parents:
3475
diff
changeset

568 
end 
1ec68b8d3bd1
Henek adds a flamethrower, updates some translations, and tweaks how fire works.
nemo
parents:
3475
diff
changeset

569 
end; 
8795  570 
gtHellishBomb: 
3476
1ec68b8d3bd1
Henek adds a flamethrower, updates some translations, and tweaks how fire works.
nemo
parents:
3475
diff
changeset

571 
begin 
1ec68b8d3bd1
Henek adds a flamethrower, updates some translations, and tweaks how fire works.
nemo
parents:
3475
diff
changeset

572 
x := hwRound(Gear^.X); 
1ec68b8d3bd1
Henek adds a flamethrower, updates some translations, and tweaks how fire works.
nemo
parents:
3475
diff
changeset

573 
y := hwRound(Gear^.Y); 
11468
2f6f8baa2a97
Make weapon damage in most cases be a structure value and also expose it to lua. Needs testing/review due to conditions at time of doing this (w/ one arm, dizzy/tingling due to sodium citrate), and just number of places changed..
nemo
parents:
11391
diff
changeset

574 
doMakeExplosion(x, y, Gear^.Boom, Gear^.Hedgehog, EXPLAutoSound); 
3476
1ec68b8d3bd1
Henek adds a flamethrower, updates some translations, and tweaks how fire works.
nemo
parents:
3475
diff
changeset

575 

1ec68b8d3bd1
Henek adds a flamethrower, updates some translations, and tweaks how fire works.
nemo
parents:
3475
diff
changeset

576 
for i:= 0 to 127 do 
1ec68b8d3bd1
Henek adds a flamethrower, updates some translations, and tweaks how fire works.
nemo
parents:
3475
diff
changeset

577 
begin 
7001  578 
dX := AngleCos(i * 16) * _0_5 * (GetRandomf + _1); 
579 
dY := AngleSin(i * 16) * _0_5 * (GetRandomf + _1); 

6131  580 
if i mod 2 = 0 then 
6126
61c1161ee32f
Remove unnecessary assignments postcreation. Simplifies Lua manipulation of these adds as well as just being tidier.
nemo
parents:
6122
diff
changeset

581 
begin 
61c1161ee32f
Remove unnecessary assignments postcreation. Simplifies Lua manipulation of these adds as well as just being tidier.
nemo
parents:
6122
diff
changeset

582 
AddGear(x, y, gtFlame, gstTmpFlag, dX, dY, 0); 
61c1161ee32f
Remove unnecessary assignments postcreation. Simplifies Lua manipulation of these adds as well as just being tidier.
nemo
parents:
6122
diff
changeset

583 
AddGear(x, y, gtFlame, 0, dX, dY, 0) 
61c1161ee32f
Remove unnecessary assignments postcreation. Simplifies Lua manipulation of these adds as well as just being tidier.
nemo
parents:
6122
diff
changeset

584 
end 
61c1161ee32f
Remove unnecessary assignments postcreation. Simplifies Lua manipulation of these adds as well as just being tidier.
nemo
parents:
6122
diff
changeset

585 
else 
8795  586 
begin 
6126
61c1161ee32f
Remove unnecessary assignments postcreation. Simplifies Lua manipulation of these adds as well as just being tidier.
nemo
parents:
6122
diff
changeset

587 
AddGear(x, y, gtFlame, 0, dX, dY, 0); 
61c1161ee32f
Remove unnecessary assignments postcreation. Simplifies Lua manipulation of these adds as well as just being tidier.
nemo
parents:
6122
diff
changeset

588 
AddGear(x, y, gtFlame, gstTmpFlag, dX, dY, 0) 
61c1161ee32f
Remove unnecessary assignments postcreation. Simplifies Lua manipulation of these adds as well as just being tidier.
nemo
parents:
6122
diff
changeset

589 
end; 
3476
1ec68b8d3bd1
Henek adds a flamethrower, updates some translations, and tweaks how fire works.
nemo
parents:
3475
diff
changeset

590 
end 
1ec68b8d3bd1
Henek adds a flamethrower, updates some translations, and tweaks how fire works.
nemo
parents:
3475
diff
changeset

591 
end; 
3712  592 
gtGasBomb: 
593 
begin 

11468
2f6f8baa2a97
Make weapon damage in most cases be a structure value and also expose it to lua. Needs testing/review due to conditions at time of doing this (w/ one arm, dizzy/tingling due to sodium citrate), and just number of places changed..
nemo
parents:
11391
diff
changeset

594 
doMakeExplosion(hwRound(Gear^.X), hwRound(Gear^.Y), Gear^.Boom, Gear^.Hedgehog, EXPLAutoSound); 
3712  595 
for i:= 0 to 2 do 
4160
043c17a8b3ca
Don't call getrandom() from parameters to a function. The order of calls is undefined, so desyncs are probable.
unc0rr
parents:
4155
diff
changeset

596 
begin 
043c17a8b3ca
Don't call getrandom() from parameters to a function. The order of calls is undefined, so desyncs are probable.
unc0rr
parents:
4155
diff
changeset

597 
x:= GetRandom(60); 
043c17a8b3ca
Don't call getrandom() from parameters to a function. The order of calls is undefined, so desyncs are probable.
unc0rr
parents:
4155
diff
changeset

598 
y:= GetRandom(40); 
6120  599 
FollowGear:= AddGear(hwRound(Gear^.X)  30 + x, hwRound(Gear^.Y)  20 + y, gtPoisonCloud, 0, _0, _0, 0); 
4160
043c17a8b3ca
Don't call getrandom() from parameters to a function. The order of calls is undefined, so desyncs are probable.
unc0rr
parents:
4155
diff
changeset

600 
end 
3712  601 
end; 
7726
1137406bce12
Set default collision mask for gears at currenthedgehog X/Y to FF7F, expose mask to scripting as well. This should resolve the collision part of bug #420
nemo
parents:
7721
diff
changeset

602 
end; 
1137406bce12
Set default collision mask for gears at currenthedgehog X/Y to FF7F, expose mask to scripting as well. This should resolve the collision part of bug #420
nemo
parents:
7721
diff
changeset

603 
DeleteGear(Gear); 
1137406bce12
Set default collision mask for gears at currenthedgehog X/Y to FF7F, expose mask to scripting as well. This should resolve the collision part of bug #420
nemo
parents:
7721
diff
changeset

604 
exit 
2948
3f21a9dc93d0
Replace tabs with spaces using 'expand t 4' command
unc0rr
parents:
2944
diff
changeset

605 
end; 
6498  606 

607 
CalcRotationDirAngle(Gear); 

608 

609 
if Gear^.Kind = gtHellishBomb then 

6580
6155187bf599
A partial reformatting of the pascal code to have consistent syntax. Things that are still inconsistent.
lovelacer
parents:
6556
diff
changeset

610 
begin 
6498  611 

612 
if Gear^.Timer = 3000 then 

6580
6155187bf599
A partial reformatting of the pascal code to have consistent syntax. Things that are still inconsistent.
lovelacer
parents:
6556
diff
changeset

613 
begin 
6498  614 
Gear^.nImpactSounds := 0; 
615 
PlaySound(sndHellish); 

6580
6155187bf599
A partial reformatting of the pascal code to have consistent syntax. Things that are still inconsistent.
lovelacer
parents:
6556
diff
changeset

616 
end; 
6498  617 

618 
if (GameTicks and $3F) = 0 then 

619 
if (Gear^.State and gstCollision) = 0 then 

620 
AddVisualGear(hwRound(Gear^.X), hwRound(Gear^.Y), vgtEvilTrace); 

6580
6155187bf599
A partial reformatting of the pascal code to have consistent syntax. Things that are still inconsistent.
lovelacer
parents:
6556
diff
changeset

621 
end; 
4  622 
end; 
5313
5e18eaef65d0
now scripts can create unique crates: dummy (empty) crates and booby traps. scripts can also set health crate values
Henek
parents:
5298
diff
changeset

623 

2457
ecf0c7e7995b
Initial molotov cocktail. Still needs graphics, tweaking of fire behaviour. Also changed probabilities for default weapon sets
nemo
parents:
2455
diff
changeset

624 
//////////////////////////////////////////////////////////////////////////////// 
ecf0c7e7995b
Initial molotov cocktail. Still needs graphics, tweaking of fire behaviour. Also changed probabilities for default weapon sets
nemo
parents:
2455
diff
changeset

625 
procedure doStepMolotov(Gear: PGear); 
8795  626 
var 
6472  627 
s: Longword; 
3454
a9bef74bd6e0
Code restlyling: experimental restyling of one module
mbait
parents:
3440
diff
changeset

628 
i, gX, gY: LongInt; 
2457
ecf0c7e7995b
Initial molotov cocktail. Still needs graphics, tweaking of fire behaviour. Also changed probabilities for default weapon sets
nemo
parents:
2455
diff
changeset

629 
dX, dY: hwFloat; 
5874
5cd329cf2460
nemo's molotov burst effect; with a slight color modification added
sheepluva
parents:
5873
diff
changeset

630 
smoke, glass: PVisualGear; 
2457
ecf0c7e7995b
Initial molotov cocktail. Still needs graphics, tweaking of fire behaviour. Also changed probabilities for default weapon sets
nemo
parents:
2455
diff
changeset

631 
begin 
3454
a9bef74bd6e0
Code restlyling: experimental restyling of one module
mbait
parents:
3440
diff
changeset

632 
AllInactive := false; 
a9bef74bd6e0
Code restlyling: experimental restyling of one module
mbait
parents:
3440
diff
changeset

633 

2948
3f21a9dc93d0
Replace tabs with spaces using 'expand t 4' command
unc0rr
parents:
2944
diff
changeset

634 
doStepFallingGear(Gear); 
3f21a9dc93d0
Replace tabs with spaces using 'expand t 4' command
unc0rr
parents:
2944
diff
changeset

635 
CalcRotationDirAngle(Gear); 
2457
ecf0c7e7995b
Initial molotov cocktail. Still needs graphics, tweaking of fire behaviour. Also changed probabilities for default weapon sets
nemo
parents:
2455
diff
changeset

636 

5870  637 
// let's add some smoke depending on speed 
8906
82756a90a343
I see no reason why a visual effect needs Distance. IMO square should look just fine. Untested. Oh. Also reduced flake count at Randi's request.
nemo
parents:
8838
diff
changeset

638 
s:= max(32,152  round((abs(hwFloat2FLoat(Gear^.dX))+abs(hwFloat2Float(Gear^.dY)))*120))+random(10); 
6011
519f8a58c021
Fix a bunch of warnings (also improves speed a bit in 32 bit code)
unC0Rr
parents:
6002
diff
changeset

639 
if (GameTicks mod s) = 0 then 
5871
09daa06191d7
Since we are tweaking molotov. make the flame flickery and add a drowning frame
nemo
parents:
5870
diff
changeset

640 
begin 
5873  641 
// adjust angle to match the texture 
6580
6155187bf599
A partial reformatting of the pascal code to have consistent syntax. Things that are still inconsistent.
lovelacer
parents:
6556
diff
changeset

642 
if Gear^.dX.isNegative then 
8906
82756a90a343
I see no reason why a visual effect needs Distance. IMO square should look just fine. Untested. Oh. Also reduced flake count at Randi's request.
nemo
parents:
8838
diff
changeset

643 
i:= 130 
82756a90a343
I see no reason why a visual effect needs Distance. IMO square should look just fine. Untested. Oh. Also reduced flake count at Randi's request.
nemo
parents:
8838
diff
changeset

644 
else i:= 50; 
8795  645 

5873  646 
smoke:= AddVisualGear(hwRound(Gear^.X)round(cos((Gear^.DirAngle+i) * pi / 180)*20), hwRound(Gear^.Y)round(sin((Gear^.DirAngle+i) * pi / 180)*20), vgtSmoke); 
6580
6155187bf599
A partial reformatting of the pascal code to have consistent syntax. Things that are still inconsistent.
lovelacer
parents:
6556
diff
changeset

647 
if smoke <> nil then 
6155187bf599
A partial reformatting of the pascal code to have consistent syntax. Things that are still inconsistent.
lovelacer
parents:
6556
diff
changeset

648 
smoke^.Scale:= 0.75; 
5871
09daa06191d7
Since we are tweaking molotov. make the flame flickery and add a drowning frame
nemo
parents:
5870
diff
changeset

649 
end; 
5870  650 

3454
a9bef74bd6e0
Code restlyling: experimental restyling of one module
mbait
parents:
3440
diff
changeset

651 
if (Gear^.State and gstCollision) <> 0 then 
6580
6155187bf599
A partial reformatting of the pascal code to have consistent syntax. Things that are still inconsistent.
lovelacer
parents:
6556
diff
changeset

652 
begin 
2948
3f21a9dc93d0
Replace tabs with spaces using 'expand t 4' command
unc0rr
parents:
2944
diff
changeset

653 
PlaySound(sndMolotov); 
3454
a9bef74bd6e0
Code restlyling: experimental restyling of one module
mbait
parents:
3440
diff
changeset

654 
gX := hwRound(Gear^.X); 
a9bef74bd6e0
Code restlyling: experimental restyling of one module
mbait
parents:
3440
diff
changeset

655 
gY := hwRound(Gear^.Y); 
5924
82fc26c53d2a
Tweak sparkles, glass. Left glass commented out in case he prefers old behaviour.
nemo
parents:
5922
diff
changeset

656 
for i:= 0 to 4 do 
5874
5cd329cf2460
nemo's molotov burst effect; with a slight color modification added
sheepluva
parents:
5873
diff
changeset

657 
begin 
5924
82fc26c53d2a
Tweak sparkles, glass. Left glass commented out in case he prefers old behaviour.
nemo
parents:
5922
diff
changeset

658 
(*glass:= AddVisualGear(gx+random(7)3, gy+random(5)2, vgtEgg); 
5874
5cd329cf2460
nemo's molotov burst effect; with a slight color modification added
sheepluva
parents:
5873
diff
changeset

659 
if glass <> nil then 
5cd329cf2460
nemo's molotov burst effect; with a slight color modification added
sheepluva
parents:
5873
diff
changeset

660 
begin 
5cd329cf2460
nemo's molotov burst effect; with a slight color modification added
sheepluva
parents:
5873
diff
changeset

661 
glass^.Frame:= 2; 
5cd329cf2460
nemo's molotov burst effect; with a slight color modification added
sheepluva
parents:
5873
diff
changeset

662 
glass^.Tint:= $41B83ED0  i * $10081000; 
5cd329cf2460
nemo's molotov burst effect; with a slight color modification added
sheepluva
parents:
5873
diff
changeset

663 
glass^.dX:= 1/(10*(random(11)5)); 
5cd329cf2460
nemo's molotov burst effect; with a slight color modification added
sheepluva
parents:
5873
diff
changeset

664 
glass^.dY:= 1/(random(4)+5); 
5924
82fc26c53d2a
Tweak sparkles, glass. Left glass commented out in case he prefers old behaviour.
nemo
parents:
5922
diff
changeset

665 
end;*) 
82fc26c53d2a
Tweak sparkles, glass. Left glass commented out in case he prefers old behaviour.
nemo
parents:
5922
diff
changeset

666 
glass:= AddVisualGear(gx+random(7)3, gy+random(7)3, vgtStraightShot); 
6131  667 
if glass <> nil then 
5924
82fc26c53d2a
Tweak sparkles, glass. Left glass commented out in case he prefers old behaviour.
nemo
parents:
5922
diff
changeset

668 
with glass^ do 
82fc26c53d2a
Tweak sparkles, glass. Left glass commented out in case he prefers old behaviour.
nemo
parents:
5922
diff
changeset

669 
begin 
82fc26c53d2a
Tweak sparkles, glass. Left glass commented out in case he prefers old behaviour.
nemo
parents:
5922
diff
changeset

670 
Frame:= 2; 
82fc26c53d2a
Tweak sparkles, glass. Left glass commented out in case he prefers old behaviour.
nemo
parents:
5922
diff
changeset

671 
Tint:= $41B83ED0  i * $10081000; 
7066
12cc2bd84b0b
Make pas2c even more happier with uGears.c, allow assigning arrays in some cases
unc0rr
parents:
7062
diff
changeset

672 
Angle:= random(360); 
5924
82fc26c53d2a
Tweak sparkles, glass. Left glass commented out in case he prefers old behaviour.
nemo
parents:
5922
diff
changeset

673 
dx:= 0.0000001; 
82fc26c53d2a
Tweak sparkles, glass. Left glass commented out in case he prefers old behaviour.
nemo
parents:
5922
diff
changeset

674 
dy:= 0; 
6580
6155187bf599
A partial reformatting of the pascal code to have consistent syntax. Things that are still inconsistent.
lovelacer
parents:
6556
diff
changeset

675 
if random(2) = 0 then 
6155187bf599
A partial reformatting of the pascal code to have consistent syntax. Things that are still inconsistent.
lovelacer
parents:
6556
diff
changeset

676 
dx := dx; 
5924
82fc26c53d2a
Tweak sparkles, glass. Left glass commented out in case he prefers old behaviour.
nemo
parents:
5922
diff
changeset

677 
FrameTicks:= 750; 
82fc26c53d2a
Tweak sparkles, glass. Left glass commented out in case he prefers old behaviour.
nemo
parents:
5922
diff
changeset

678 
State:= ord(sprEgg) 
82fc26c53d2a
Tweak sparkles, glass. Left glass commented out in case he prefers old behaviour.
nemo
parents:
5922
diff
changeset

679 
end; 
5874
5cd329cf2460
nemo's molotov burst effect; with a slight color modification added
sheepluva
parents:
5873
diff
changeset

680 
end; 
5415
94e26612e2ec
Adjust "sticky" fire (molotov) so it makes better fire pits, by making the kicks more regular, yet of random left/right. Tweak napalm slightly along same lines. Probably needs more balancing.
nemo
parents:
5413
diff
changeset

681 
for i:= 0 to 24 do 
6126
61c1161ee32f
Remove unnecessary assignments postcreation. Simplifies Lua manipulation of these adds as well as just being tidier.
nemo
parents:
6122
diff
changeset

682 
begin 
7001  683 
dX := AngleCos(i * 2) * ((_0_15*(i div 5))) * (GetRandomf + _1); 
684 
dY := AngleSin(i * 8) * _0_5 * (GetRandomf + _1); 

6126
61c1161ee32f
Remove unnecessary assignments postcreation. Simplifies Lua manipulation of these adds as well as just being tidier.
nemo
parents:
6122
diff
changeset

685 
AddGear(gX, gY, gtFlame, gstTmpFlag, dX, dY, 0); 
61c1161ee32f
Remove unnecessary assignments postcreation. Simplifies Lua manipulation of these adds as well as just being tidier.
nemo
parents:
6122
diff
changeset

686 
AddGear(gX, gY, gtFlame, gstTmpFlag, dX,dY, 0); 
61c1161ee32f
Remove unnecessary assignments postcreation. Simplifies Lua manipulation of these adds as well as just being tidier.
nemo
parents:
6122
diff
changeset

687 
AddGear(gX, gY, gtFlame, gstTmpFlag,dX, dY, 0); 
61c1161ee32f
Remove unnecessary assignments postcreation. Simplifies Lua manipulation of these adds as well as just being tidier.
nemo
parents:
6122
diff
changeset

688 
AddGear(gX, gY, gtFlame, gstTmpFlag,dX,dY, 0); 
61c1161ee32f
Remove unnecessary assignments postcreation. Simplifies Lua manipulation of these adds as well as just being tidier.
nemo
parents:
6122
diff
changeset

689 
end; 
2948
3f21a9dc93d0
Replace tabs with spaces using 'expand t 4' command
unc0rr
parents:
2944
diff
changeset

690 
DeleteGear(Gear); 
3f21a9dc93d0
Replace tabs with spaces using 'expand t 4' command
unc0rr
parents:
2944
diff
changeset

691 
exit 
6580
6155187bf599
A partial reformatting of the pascal code to have consistent syntax. Things that are still inconsistent.
lovelacer
parents:
6556
diff
changeset

692 
end; 
2457
ecf0c7e7995b
Initial molotov cocktail. Still needs graphics, tweaking of fire behaviour. Also changed probabilities for default weapon sets
nemo
parents:
2455
diff
changeset

693 
end; 
4  694 

5313
5e18eaef65d0
now scripts can create unique crates: dummy (empty) crates and booby traps. scripts can also set health crate values
Henek
parents:
5298
diff
changeset

695 
//////////////////////////////////////////////////////////////////////////////// 
1279  696 

78  697 
procedure doStepCluster(Gear: PGear); 
698 
begin 

3454
a9bef74bd6e0
Code restlyling: experimental restyling of one module
mbait
parents:
3440
diff
changeset

699 
AllInactive := false; 
a9bef74bd6e0
Code restlyling: experimental restyling of one module
mbait
parents:
3440
diff
changeset

700 
doStepFallingGear(Gear); 
a9bef74bd6e0
Code restlyling: experimental restyling of one module
mbait
parents:
3440
diff
changeset

701 
if (Gear^.State and gstCollision) <> 0 then 
6580
6155187bf599
A partial reformatting of the pascal code to have consistent syntax. Things that are still inconsistent.
lovelacer
parents:
6556
diff
changeset

702 
begin 
11468
2f6f8baa2a97
Make weapon damage in most cases be a structure value and also expose it to lua. Needs testing/review due to conditions at time of doing this (w/ one arm, dizzy/tingling due to sodium citrate), and just number of places changed..
nemo
parents:
11391
diff
changeset

703 
doMakeExplosion(hwRound(Gear^.X), hwRound(Gear^.Y), Gear^.Boom, Gear^.Hedgehog, EXPLAutoSound); 
3454
a9bef74bd6e0
Code restlyling: experimental restyling of one module
mbait
parents:
3440
diff
changeset

704 
DeleteGear(Gear); 
a9bef74bd6e0
Code restlyling: experimental restyling of one module
mbait
parents:
3440
diff
changeset

705 
exit 
2948
3f21a9dc93d0
Replace tabs with spaces using 'expand t 4' command
unc0rr
parents:
2944
diff
changeset

706 
end; 
1262  707 

11468
2f6f8baa2a97
Make weapon damage in most cases be a structure value and also expose it to lua. Needs testing/review due to conditions at time of doing this (w/ one arm, dizzy/tingling due to sodium citrate), and just number of places changed..
nemo
parents:
11391
diff
changeset

708 
if (Gear^.Kind = gtMelonPiece) then 
3454
a9bef74bd6e0
Code restlyling: experimental restyling of one module
mbait
parents:
3440
diff
changeset

709 
CalcRotationDirAngle(Gear) 
a9bef74bd6e0
Code restlyling: experimental restyling of one module
mbait
parents:
3440
diff
changeset

710 
else if (GameTicks and $1F) = 0 then 
10352  711 
AddVisualGear(hwRound(Gear^.X), hwRound(Gear^.Y), vgtSmokeTrace); 
78  712 
end; 
713 

4  714 
//////////////////////////////////////////////////////////////////////////////// 
4168  715 
procedure doStepShell(Gear: PGear); 
4  716 
begin 
3454
a9bef74bd6e0
Code restlyling: experimental restyling of one module
mbait
parents:
3440
diff
changeset

717 
AllInactive := false; 
6580
6155187bf599
A partial reformatting of the pascal code to have consistent syntax. Things that are still inconsistent.
lovelacer
parents:
6556
diff
changeset

718 
if (GameFlags and gfMoreWind) = 0 then 
6155187bf599
A partial reformatting of the pascal code to have consistent syntax. Things that are still inconsistent.
lovelacer
parents:
6556
diff
changeset

719 
Gear^.dX := Gear^.dX + cWindSpeed; 
3454
a9bef74bd6e0
Code restlyling: experimental restyling of one module
mbait
parents:
3440
diff
changeset

720 
doStepFallingGear(Gear); 
a9bef74bd6e0
Code restlyling: experimental restyling of one module
mbait
parents:
3440
diff
changeset

721 
if (Gear^.State and gstCollision) <> 0 then 
4578  722 
begin 
11468
2f6f8baa2a97
Make weapon damage in most cases be a structure value and also expose it to lua. Needs testing/review due to conditions at time of doing this (w/ one arm, dizzy/tingling due to sodium citrate), and just number of places changed..
nemo
parents:
11391
diff
changeset

723 
doMakeExplosion(hwRound(Gear^.X), hwRound(Gear^.Y), Gear^.Boom, Gear^.Hedgehog, EXPLAutoSound); 
3454
a9bef74bd6e0
Code restlyling: experimental restyling of one module
mbait
parents:
3440
diff
changeset

724 
DeleteGear(Gear); 
a9bef74bd6e0
Code restlyling: experimental restyling of one module
mbait
parents:
3440
diff
changeset

725 
exit 
4578  726 
end; 
3454
a9bef74bd6e0
Code restlyling: experimental restyling of one module
mbait
parents:
3440
diff
changeset

727 
if (GameTicks and $3F) = 0 then 
10352  728 
AddVisualGear(hwRound(Gear^.X), hwRound(Gear^.Y), vgtSmokeTrace); 
95  729 
end; 
730 

4  731 
//////////////////////////////////////////////////////////////////////////////// 
4578  732 
procedure doStepSnowball(Gear: PGear); 
733 
var kick, i: LongInt; 

734 
particle: PVisualGear; 

8945
145bf64a9579
this should improve consistency of mortar cluster spread and snowball knocks
nemo
parents:
8934
diff
changeset

735 
gdX, gdY: hwFloat; 
4578  736 
begin 
737 
AllInactive := false; 

6580
6155187bf599
A partial reformatting of the pascal code to have consistent syntax. Things that are still inconsistent.
lovelacer
parents:
6556
diff
changeset

738 
if (GameFlags and gfMoreWind) = 0 then 
6155187bf599
A partial reformatting of the pascal code to have consistent syntax. Things that are still inconsistent.
lovelacer
parents:
6556
diff
changeset

739 
Gear^.dX := Gear^.dX + cWindSpeed; 
8945
145bf64a9579
this should improve consistency of mortar cluster spread and snowball knocks
nemo
parents:
8934
diff
changeset

740 
gdX := Gear^.dX; 
145bf64a9579
this should improve consistency of mortar cluster spread and snowball knocks
nemo
parents:
8934
diff
changeset

741 
gdY := Gear^.dY; 
4578  742 
doStepFallingGear(Gear); 
743 
CalcRotationDirAngle(Gear); 

744 
if (Gear^.State and gstCollision) <> 0 then 

745 
begin 

11468
2f6f8baa2a97
Make weapon damage in most cases be a structure value and also expose it to lua. Needs testing/review due to conditions at time of doing this (w/ one arm, dizzy/tingling due to sodium citrate), and just number of places changed..
nemo
parents:
11391
diff
changeset

746 
kick:= hwRound((hwAbs(gdX)+hwAbs(gdY)) * Gear^.Boom / 10000); 
8945
145bf64a9579
this should improve consistency of mortar cluster spread and snowball knocks
nemo
parents:
8934
diff
changeset

747 
Gear^.dX:= gdX; 
145bf64a9579
this should improve consistency of mortar cluster spread and snowball knocks
nemo
parents:
8934
diff
changeset

748 
Gear^.dY:= gdY; 
7621  749 
AmmoShove(Gear, 0, kick); 
4578  750 
for i:= 15 + kick div 10 downto 0 do 
751 
begin 

752 
particle := AddVisualGear(hwRound(Gear^.X) + Random(25), hwRound(Gear^.Y) + Random(25), vgtDust); 

6580
6155187bf599
A partial reformatting of the pascal code to have consistent syntax. Things that are still inconsistent.
lovelacer
parents:
6556
diff
changeset

753 
if particle <> nil then 
6155187bf599
A partial reformatting of the pascal code to have consistent syntax. Things that are still inconsistent.
lovelacer
parents:
6556
diff
changeset

754 
particle^.dX := particle^.dX + (Gear^.dX.QWordValue / 21474836480) 
4578  755 
end; 
756 
DeleteGear(Gear); 

757 
exit 

758 
end; 

759 
if ((GameTicks and $1F) = 0) and (Random(3) = 0) then 

760 
begin 

4582  761 
particle:= AddVisualGear(hwRound(Gear^.X), hwRound(Gear^.Y), vgtDust); 
6580
6155187bf599
A partial reformatting of the pascal code to have consistent syntax. Things that are still inconsistent.
lovelacer
parents:
6556
diff
changeset

762 
if particle <> nil then 
6155187bf599
A partial reformatting of the pascal code to have consistent syntax. Things that are still inconsistent.
lovelacer
parents:
6556
diff
changeset

763 
particle^.dX := particle^.dX + (Gear^.dX.QWordValue / 21474836480) 
4578  764 
end 
765 
end; 

766 

5313
5e18eaef65d0
now scripts can create unique crates: dummy (empty) crates and booby traps. scripts can also set health crate values
Henek
parents:
5298
diff
changeset

767 
//////////////////////////////////////////////////////////////////////////////// 
4611  768 
procedure doStepSnowflake(Gear: PGear); 
6419
6a464d0a5c13
Tidy up flake land generation, to avoid ragged holes in landbacktex. Remove of one odd Land[] change forces a PROTO bump. Well, had to happen eventually.
nemo
parents:
6389
diff
changeset

769 
var xx, yy, px, py, rx, ry, lx, ly: LongInt; 
5025
ac1691d35cf2
Land sprayer tweaks, make land spray and mudball not end turn
nemo
parents:
5024
diff
changeset

770 
move, draw, allpx, gun: Boolean; 
4611  771 
s: PSDL_Surface; 
772 
p: PLongwordArray; 

5693  773 
lf: LongWord; 
4611  774 
begin 
5695  775 
inc(Gear^.Pos); 
5025
ac1691d35cf2
Land sprayer tweaks, make land spray and mudball not end turn
nemo
parents:
5024
diff
changeset

776 
gun:= (Gear^.State and gstTmpFlag) <> 0; 
5024  777 
move:= false; 
778 
draw:= false; 

5025
ac1691d35cf2
Land sprayer tweaks, make land spray and mudball not end turn
nemo
parents:
5024
diff
changeset

779 
if gun then 
5024  780 
begin 
6450  781 
Gear^.State:= Gear^.State and (not gstInvisible); 
5024  782 
doStepFallingGear(Gear); 
783 
CheckCollision(Gear); 

6580
6155187bf599
A partial reformatting of the pascal code to have consistent syntax. Things that are still inconsistent.
lovelacer
parents:
6556
diff
changeset

784 
if ((Gear^.State and gstCollision) <> 0) or ((Gear^.State and gstMoving) = 0) then 
6155187bf599
A partial reformatting of the pascal code to have consistent syntax. Things that are still inconsistent.
lovelacer
parents:
6556
diff
changeset

785 
draw:= true; 
5024  786 
xx:= hwRound(Gear^.X); 
787 
yy:= hwRound(Gear^.Y); 

9809  788 
if draw and (WorldEdge = weWrap) and ((xx < LongInt(leftX) + 3) or (xx > LongInt(rightX)  3)) then 
789 
begin 

10015  790 
if xx < LongInt(leftX) + 3 then 
9563  791 
xx:= rightX3 
792 
else xx:= leftX+3; 

793 
Gear^.X:= int2hwFloat(xx) 

794 
end 

5024  795 
end 
796 
else if GameTicks and $7 = 0 then 

4611  797 
begin 
798 
with Gear^ do 

799 
begin 

6450  800 
State:= State and (not gstInvisible); 
5355  801 
X:= X + cWindSpeed * 3200 + dX; 
4611  802 
Y:= Y + dY + cGravity * vobFallSpeed * 8; // using same value as flakes to try and get similar results 
803 
xx:= hwRound(X); 

804 
yy:= hwRound(Y); 

805 
if vobVelocity <> 0 then 

806 
begin 

7649  807 
DirAngle := DirAngle + (Damage / 1000); 
6580
6155187bf599
A partial reformatting of the pascal code to have consistent syntax. Things that are still inconsistent.
lovelacer
parents:
6556
diff
changeset

808 
if DirAngle < 0 then 
6155187bf599
A partial reformatting of the pascal code to have consistent syntax. Things that are still inconsistent.
lovelacer
parents:
6556
diff
changeset

809 
DirAngle := DirAngle + 360 
6155187bf599
A partial reformatting of the pascal code to have consistent syntax. Things that are still inconsistent.
lovelacer
parents:
6556
diff
changeset

810 
else if 360 < DirAngle then 
6155187bf599
A partial reformatting of the pascal code to have consistent syntax. Things that are still inconsistent.
lovelacer
parents:
6556
diff
changeset

811 
DirAngle := DirAngle  360; 
4611  812 
end; 
7649  813 
(* 
814 
We aren't using frametick right now, so just a waste of cycles. 

4611  815 
inc(Health, 8); 
5186  816 
if longword(Health) > vobFrameTicks then 
4611  817 
begin 
818 
dec(Health, vobFrameTicks); 

819 
inc(Timer); 

6580
6155187bf599
A partial reformatting of the pascal code to have consistent syntax. Things that are still inconsistent.
lovelacer
parents:
6556
diff
changeset

820 
if Timer = vobFramesCount then 
6155187bf599
A partial reformatting of the pascal code to have consistent syntax. Things that are still inconsistent.
lovelacer
parents:
6556
diff
changeset

821 
Timer:= 0 
4611  822 
end; 
7649  823 
*) 
4611  824 
// move back to cloud layer 
10354  825 
if CheckCoordInWater(xx, yy) then 
6580
6155187bf599
A partial reformatting of the pascal code to have consistent syntax. Things that are still inconsistent.
lovelacer
parents:
6556
diff
changeset

826 
move:= true 
7477
26706bf32ecf
First pass at variable land size. For playing a small map (forced on rqLowRes), this should save 42MiB of RAM.
nemo
parents:
7468
diff
changeset

827 
else if (xx > snowRight) or (xx < snowLeft) then 
6580
6155187bf599
A partial reformatting of the pascal code to have consistent syntax. Things that are still inconsistent.
lovelacer
parents:
6556
diff
changeset

828 
move:=true 
10736
5b7cf9fcb47e
Try to handle negative gravity w/ snow. Still needs to look nicer. Currently causes banding.
nemo
parents:
10679
diff
changeset

829 
else if (cGravity < _0) and (yy < LAND_HEIGHT1200) then 
5b7cf9fcb47e
Try to handle negative gravity w/ snow. Still needs to look nicer. Currently causes banding.
nemo
parents:
10679
diff
changeset

830 
move:=true 
4791  831 
// Solid pixel encountered 
7477
26706bf32ecf
First pass at variable land size. For playing a small map (forced on rqLowRes), this should save 42MiB of RAM.
nemo
parents:
7468
diff
changeset

832 
else if ((yy and LAND_HEIGHT_MASK) = 0) and ((xx and LAND_WIDTH_MASK) = 0) and (Land[yy, xx] <> 0) then 
4611  833 
begin 
7128
574b385ce7df
Minor freezer changes, allow snow to accumulate on indestructible terrain too.
nemo
parents:
7101
diff
changeset

834 
lf:= Land[yy, xx] and (lfObject or lfBasic or lfIndestructible); 
8602  835 
if lf = 0 then lf:= lfObject; 
4791  836 
// If there's room below keep falling 
837 
if (((yy1) and LAND_HEIGHT_MASK) = 0) and (Land[yy1, xx] = 0) then 

838 
begin 

839 
X:= X  cWindSpeed * 1600  dX; 

840 
end 

841 
// If there's room below, on the sides, fill the gaps 

842 
else if (((yy1) and LAND_HEIGHT_MASK) = 0) and (((xx(1*hwSign(cWindSpeed))) and LAND_WIDTH_MASK) = 0) and (Land[yy1, (xx(1*hwSign(cWindSpeed)))] = 0) then 

843 
begin 

844 
X:= X  _0_8 * hwSign(cWindSpeed); 

845 
Y:= Y  dY  cGravity * vobFallSpeed * 8; 

846 
end 

847 
else if (((yy1) and LAND_HEIGHT_MASK) = 0) and (((xx(2*hwSign(cWindSpeed))) and LAND_WIDTH_MASK) = 0) and (Land[yy1, (xx(2*hwSign(cWindSpeed)))] = 0) then 

848 
begin 

849 
X:= X  _0_8 * 2 * hwSign(cWindSpeed); 

850 
Y:= Y  dY  cGravity * vobFallSpeed * 8; 

851 
end 

852 
else if (((yy1) and LAND_HEIGHT_MASK) = 0) and (((xx+(1*hwSign(cWindSpeed))) and LAND_WIDTH_MASK) = 0) and (Land[yy1, (xx+(1*hwSign(cWindSpeed)))] = 0) then 

853 
begin 

854 
X:= X + _0_8 * hwSign(cWindSpeed); 

855 
Y:= Y  dY  cGravity * vobFallSpeed * 8; 

856 
end 

857 
else if (((yy1) and LAND_HEIGHT_MASK) = 0) and (((xx+(2*hwSign(cWindSpeed))) and LAND_WIDTH_MASK) = 0) and (Land[yy1, (xx+(2*hwSign(cWindSpeed)))] = 0) then 

858 
begin 

859 
X:= X + _0_8 * 2 * hwSign(cWindSpeed); 

860 
Y:= Y  dY  cGravity * vobFallSpeed * 8; 

861 
end 

4805
01332828b568
Fancier detection of hogs/objects. Hogs wont get buried even by the worst of storms.
Palewolf
parents:
4803
diff
changeset

862 
// if there's an hog/object below do nothing 
01332828b568
Fancier detection of hogs/objects. Hogs wont get buried even by the worst of storms.
Palewolf
parents:
4803
diff
changeset

863 
else if ((((yy+1) and LAND_HEIGHT_MASK) = 0) and ((Land[yy+1, xx] and $FF) <> 0)) 
01332828b568
Fancier detection of hogs/objects. Hogs wont get buried even by the worst of storms.
Palewolf
parents:
4803
diff
changeset

864 
then move:=true 
5024  865 
else draw:= true 
866 
end 

867 
end 

868 
end; 

6131  869 
if draw then 
5024  870 
with Gear^ do 
871 
begin 

872 
// we've collided with land. draw some stuff and get back into the clouds 

873 
move:= true; 

6580
6155187bf599
A partial reformatting of the pascal code to have consistent syntax. Things that are still inconsistent.
lovelacer
parents:
6556
diff
changeset

874 
if (Pos > 20) and ((CurAmmoGear = nil) 
6155187bf599
A partial reformatting of the pascal code to have consistent syntax. Things that are still inconsistent.
lovelacer
parents:
6556
diff
changeset

875 
or (CurAmmoGear^.Kind <> gtRope)) then 
5024  876 
begin 
877 
////////////////////////////////// TODO  ASK UNC0RR FOR A GOOD HOME FOR THIS //////////////////////////////////// 

5025
ac1691d35cf2
Land sprayer tweaks, make land spray and mudball not end turn
nemo
parents:
5024
diff
changeset

878 
if not gun then 
5024  879 
begin 
880 
dec(yy,3); 

881 
dec(xx,1) 

882 
end; 

883 
s:= SpritesData[sprSnow].Surface; 

884 
p:= s^.pixels; 

885 
allpx:= true; 

886 
for py:= 0 to Pred(s^.h) do 

887 
begin 

888 
for px:= 0 to Pred(s^.w) do 

6419
6a464d0a5c13
Tidy up flake land generation, to avoid ragged holes in landbacktex. Remove of one odd Land[] change forces a PROTO bump. Well, had to happen eventually.
nemo
parents:
6389
diff
changeset

889 
begin 
6a464d0a5c13
Tidy up flake land generation, to avoid ragged holes in landbacktex. Remove of one odd Land[] change forces a PROTO bump. Well, had to happen eventually.
nemo
parents:
6389
diff
changeset

890 
lx:=xx + px; ly:=yy + py; 
6a464d0a5c13
Tidy up flake land generation, to avoid ragged holes in landbacktex. Remove of one odd Land[] change forces a PROTO bump. Well, had to happen eventually.
nemo
parents:
6389
diff
changeset

891 
if (ly and LAND_HEIGHT_MASK = 0) and (lx and LAND_WIDTH_MASK = 0) and (Land[ly, lx] and $FF = 0) then 
5024  892 
begin 
6419
6a464d0a5c13
Tidy up flake land generation, to avoid ragged holes in landbacktex. Remove of one odd Land[] change forces a PROTO bump. Well, had to happen eventually.
nemo
parents:
6389
diff
changeset

893 
rx:= lx; 
6a464d0a5c13
Tidy up flake land generation, to avoid ragged holes in landbacktex. Remove of one odd Land[] change forces a PROTO bump. Well, had to happen eventually.
nemo
parents:
6389
diff
changeset

894 
ry:= ly; 
6a464d0a5c13
Tidy up flake land generation, to avoid ragged holes in landbacktex. Remove of one odd Land[] change forces a PROTO bump. Well, had to happen eventually.
nemo
parents:
6389
diff
changeset

895 
if cReducedQuality and rqBlurryLand <> 0 then 
5025
ac1691d35cf2
Land sprayer tweaks, make land spray and mudball not end turn
nemo
parents:
5024
diff
changeset

896 
begin 
6419
6a464d0a5c13
Tidy up flake land generation, to avoid ragged holes in landbacktex. Remove of one odd Land[] change forces a PROTO bump. Well, had to happen eventually.
nemo
parents:
6389
diff
changeset

897 
rx:= rx div 2;ry:= ry div 2; 
6a464d0a5c13
Tidy up flake land generation, to avoid ragged holes in landbacktex. Remove of one odd Land[] change forces a PROTO bump. Well, had to happen eventually.
nemo
parents:
6389
diff
changeset

898 
end; 
8751
4609823efc94
More flagging of Land values. Also use less than for tests of nonterrain, instead of "and $FF00 = 0". Saves a couple of ops, which actually matters a small amount in a few places.
nemo
parents:
8744
diff
changeset

899 
if Land[yy + py, xx + px] <= lfAllObjMask then 
5025
ac1691d35cf2
Land sprayer tweaks, make land spray and mudball not end turn
nemo
parents:
5024
diff
changeset

900 
if gun then 
6419
6a464d0a5c13
Tidy up flake land generation, to avoid ragged holes in landbacktex. Remove of one odd Land[] change forces a PROTO bump. Well, had to happen eventually.
nemo
parents:
6389
diff
changeset

901 
begin 
6a464d0a5c13
Tidy up flake land generation, to avoid ragged holes in landbacktex. Remove of one odd Land[] change forces a PROTO bump. Well, had to happen eventually.
nemo
parents:
6389
diff
changeset

902 
LandDirty[yy div 32, xx div 32]:= 1; 
6580
6155187bf599
A partial reformatting of the pascal code to have consistent syntax. Things that are still inconsistent.
lovelacer
parents:
6556
diff
changeset

903 
if LandPixels[ry, rx] = 0 then 
6155187bf599
A partial reformatting of the pascal code to have consistent syntax. Things that are still inconsistent.
lovelacer
parents:
6556
diff
changeset

904 
Land[ly, lx]:= lfDamaged or lfObject 
6419
6a464d0a5c13
Tidy up flake land generation, to avoid ragged holes in landbacktex. Remove of one odd Land[] change forces a PROTO bump. Well, had to happen eventually.
nemo
parents:
6389
diff
changeset

905 
else Land[ly, lx]:= lfDamaged or lfBasic 
6a464d0a5c13
Tidy up flake land generation, to avoid ragged holes in landbacktex. Remove of one odd Land[] change forces a PROTO bump. Well, had to happen eventually.
nemo
parents:
6389
diff
changeset

906 
end 
6a464d0a5c13
Tidy up flake land generation, to avoid ragged holes in landbacktex. Remove of one odd Land[] change forces a PROTO bump. Well, had to happen eventually.
nemo
parents:
6389
diff
changeset

907 
else Land[ly, lx]:= lf; 
6a464d0a5c13
Tidy up flake land generation, to avoid ragged holes in landbacktex. Remove of one odd Land[] change forces a PROTO bump. Well, had to happen eventually.
nemo
parents:
6389
diff
changeset

908 
if gun then 
10645
b8c73bacb31e
Fix inflight colouring of land spray, make it use tint when added to land too (lua might find that handy), tweak climbhome cake delay slightly
nemo
parents:
10642
diff
changeset

909 
LandPixels[ry, rx]:= (Gear^.Tint shr 24 shl RShift) or 
b8c73bacb31e
Fix inflight colouring of land spray, make it use tint when added to land too (lua might find that handy), tweak climbhome cake delay slightly
nemo
parents:
10642
diff
changeset

910 
(Gear^.Tint shr 16 and $FF shl GShift) or 
b8c73bacb31e
Fix inflight colouring of land spray, make it use tint when added to land too (lua might find that handy), tweak climbhome cake delay slightly
nemo
parents:
10642
diff
changeset

911 
(Gear^.Tint shr 8 and $FF shl BShift) or 
b8c73bacb31e
Fix inflight colouring of land spray, make it use tint when added to land too (lua might find that handy), tweak climbhome cake delay slightly
nemo
parents:
10642
diff
changeset

912 
(p^[px] and AMask) 
6419
6a464d0a5c13
Tidy up flake land generation, to avoid ragged holes in landbacktex. Remove of one odd Land[] change forces a PROTO bump. Well, had to happen eventually.
nemo
parents:
6389
diff
changeset

913 
else LandPixels[ry, rx]:= addBgColor(LandPixels[ry, rx], p^[px]); 
5024  914 
end 
6419
6a464d0a5c13
Tidy up flake land generation, to avoid ragged holes in landbacktex. Remove of one odd Land[] change forces a PROTO bump. Well, had to happen eventually.
nemo
parents:
6389
diff
changeset

915 
else allpx:= false 
6a464d0a5c13
Tidy up flake land generation, to avoid ragged holes in landbacktex. Remove of one odd Land[] change forces a PROTO bump. Well, had to happen eventually.
nemo
parents:
6389
diff
changeset

916 
end; 
10131
4b4a043111f4
 pas2c recognizes typecasts in initialization expressions
unc0rr
parents:
10125
diff
changeset

917 
p:= PLongWordArray(@(p^[s^.pitch shr 2])) 
5024  918 
end; 
8795  919 

920 
// Why is this here. For one thing, there's no test on +1 being safe. 

6419
6a464d0a5c13
Tidy up flake land generation, to avoid ragged holes in landbacktex. Remove of one odd Land[] change forces a PROTO bump. Well, had to happen eventually.
nemo
parents:
6389
diff
changeset

921 
//Land[py, px+1]:= lfBasic; 
8795  922 

6580
6155187bf599
A partial reformatting of the pascal code to have consistent syntax. Things that are still inconsistent.
lovelacer
parents:
6556
diff
changeset

923 
if allpx then 
7170
84ac6c6d2d8e
Only create textures for nonempty LandPixel chunks. This should save a fair amount of memory, especially on smaller maps, and eliminate a number of draws
nemo
parents:
7168
diff
changeset

924 
UpdateLandTexture(xx, Pred(s^.h), yy, Pred(s^.w), true) 
4791  925 
else 
4611  926 
begin 
5024  927 
UpdateLandTexture( 
928 
max(0, min(LAND_WIDTH, xx)), 

929 
min(LAND_WIDTH  xx, Pred(s^.w)), 

930 
max(0, min(LAND_WIDTH, yy)), 

7170
84ac6c6d2d8e
Only create textures for nonempty LandPixel chunks. This should save a fair amount of memory, especially on smaller maps, and eliminate a number of draws
nemo
parents:
7168
diff
changeset

931 
min(LAND_HEIGHT  yy, Pred(s^.h)), false // could this be true without unnecessarily creating blanks? 
5024  932 
); 
4791  933 
end; 
5024  934 
////////////////////////////////// TODO  ASK UNC0RR FOR A GOOD HOME FOR THIS //////////////////////////////////// 
4611  935 
end 
5024  936 
end; 
937 

938 
if move then 

939 
begin 

5025
ac1691d35cf2
Land sprayer tweaks, make land spray and mudball not end turn
nemo
parents:
5024
diff
changeset

940 
if gun then 
5024  941 
begin 
942 
DeleteGear(Gear); 

943 
exit 

944 
end; 

5695  945 
Gear^.Pos:= 0; 
7721  946 
Gear^.X:= int2hwFloat(LongInt(GetRandom(snowRight  snowLeft)) + snowLeft); 
10736
5b7cf9fcb47e
Try to handle negative gravity w/ snow. Still needs to look nicer. Currently causes banding.
nemo
parents:
10679
diff
changeset

947 
if (cGravity < _0) and (yy < LAND_HEIGHT1200) then 
5b7cf9fcb47e
Try to handle negative gravity w/ snow. Still needs to look nicer. Currently causes banding.
nemo
parents:
10679
diff
changeset

948 
Gear^.Y:= int2hwFloat(LAND_HEIGHT  50  LongInt(GetRandom(50))) 
5b7cf9fcb47e
Try to handle negative gravity w/ snow. Still needs to look nicer. Currently causes banding.
nemo
parents:
10679
diff
changeset

949 
else Gear^.Y:= int2hwFloat(LAND_HEIGHT + LongInt(GetRandom(50))  1250); 
5413  950 
Gear^.State:= Gear^.State or gstInvisible; 
4611  951 
end 
952 
end; 

953 

4578  954 
//////////////////////////////////////////////////////////////////////////////// 
4  955 
procedure doStepGrave(Gear: PGear); 
956 
begin 

7394  957 
if (Gear^.Message and gmDestroy) <> 0 then 
7393
3f203c62353b
Fix bug in resurrector deleting graves (exists in stable too), remove some unnecessary assignments due to the fillchar 0
nemo
parents:
7391
diff
changeset

958 
begin 
3f203c62353b
Fix bug in resurrector deleting graves (exists in stable too), remove some unnecessary assignments due to the fillchar 0
nemo
parents:
7391
diff
changeset

959 
DeleteGear(Gear); 
3f203c62353b
Fix bug in resurrector deleting graves (exists in stable too), remove some unnecessary assignments due to the fillchar 0
nemo
parents:
7391
diff
changeset

960 
exit 
3f203c62353b
Fix bug in resurrector deleting graves (exists in stable too), remove some unnecessary assignments due to the fillchar 0
nemo
parents:
7391
diff
changeset

961 
end; 
7394  962 

3454
a9bef74bd6e0
Code restlyling: experimental restyling of one module
mbait
parents:
3440
diff
changeset

963 
AllInactive := false; 
7394  964 

3454
a9bef74bd6e0
Code restlyling: experimental restyling of one module
mbait
parents:
3440
diff
changeset

965 
if Gear^.dY.isNegative then 
9706
5178d2263521
return land word from uCollisions to make decisions based on it. Should be handy for trampoline.
nemo
parents:
9698
diff
changeset

966 
if TestCollisionY(Gear, 1) <> 0 then 
6580
6155187bf599
A partial reformatting of the pascal code to have consistent syntax. Things that are still inconsistent.
lovelacer
parents:
6556
diff
changeset

967 
Gear^.dY := _0; 
3454
a9bef74bd6e0
Code restlyling: experimental restyling of one module
mbait
parents:
3440
diff
changeset

968 

a9bef74bd6e0
Code restlyling: experimental restyling of one module
mbait
parents:
3440
diff
changeset

969 
if not Gear^.dY.isNegative then 
9706
5178d2263521
return land word from uCollisions to make decisions based on it. Should be handy for trampoline.
nemo
parents:
9698
diff
changeset

970 
if TestCollisionY(Gear, 1) <> 0 then 
9820  971 
begin 
3454
a9bef74bd6e0
Code restlyling: experimental restyling of one module
mbait
parents:
3440
diff
changeset

972 
Gear^.dY :=  Gear^.dY * Gear^.Elasticity; 
a9bef74bd6e0
Code restlyling: experimental restyling of one module
mbait
parents:
3440
diff
changeset

973 
if Gear^.dY >  _1div1024 then 
9820  974 
begin 
3454
a9bef74bd6e0
Code restlyling: experimental restyling of one module
mbait
parents:
3440
diff
changeset

975 
Gear^.Active := false; 
a9bef74bd6e0
Code restlyling: experimental restyling of one module
mbait
parents:
3440
diff
changeset

976 
exit 
9820  977 
end 
6580
6155187bf599
A partial reformatting of the pascal code to have consistent syntax. Things that are still inconsistent.
lovelacer
parents:
6556
diff
changeset

978 
else if Gear^.dY <  _0_03 then 
6155187bf599
A partial reformatting of the pascal code to have consistent syntax. Things that are still inconsistent.
lovelacer
parents:
6556
diff
changeset

979 
PlaySound(Gear^.ImpactSound) 
9820  980 
end; 
3454
a9bef74bd6e0
Code restlyling: experimental restyling of one module
mbait
parents:
3440
diff
changeset

981 

a9bef74bd6e0
Code restlyling: experimental restyling of one module
mbait
parents:
3440
diff
changeset

982 
Gear^.Y := Gear^.Y + Gear^.dY; 
a9bef74bd6e0
Code restlyling: experimental restyling of one module
mbait
parents:
3440
diff
changeset

983 
CheckGearDrowning(Gear); 
a9bef74bd6e0
Code restlyling: experimental restyling of one module
mbait
parents:
3440
diff
changeset

984 
Gear^.dY := Gear^.dY + cGravity 
4  985 
end; 
986 

987 
//////////////////////////////////////////////////////////////////////////////// 

3080  988 
procedure doStepBeeWork(Gear: PGear); 
8795  989 
var 
3454
a9bef74bd6e0
Code restlyling: experimental restyling of one module
mbait
parents:
3440
diff
changeset

990 
t: hwFloat; 
5748
70d7f8e40f53
Just for fun. Flowers! Also, use a less blatant image in ammo menu.
nemo
parents:
5738
diff
changeset

991 
gX,gY,i: LongInt; 
6251  992 
uw, nuw: boolean; 
5748
70d7f8e40f53
Just for fun. Flowers! Also, use a less blatant image in ammo menu.
nemo
parents:
5738
diff
changeset

993 
flower: PVisualGear; 
3454
a9bef74bd6e0
Code restlyling: experimental restyling of one module
mbait
parents:
3440
diff
changeset

994 

4  995 
begin 
9473
a51a69094c24
partial implementation of noninfinite world (edge wrap/warp/bounce)
nemo
parents:
9470
diff
changeset

996 
WorldWrap(Gear); 
3454
a9bef74bd6e0
Code restlyling: experimental restyling of one module
mbait
parents:
3440
diff
changeset

997 
AllInactive := false; 
a9bef74bd6e0
Code restlyling: experimental restyling of one module
mbait
parents:
3440
diff
changeset

998 
gX := hwRound(Gear^.X); 
a9bef74bd6e0
Code restlyling: experimental restyling of one module
mbait
parents:
3440
diff
changeset

999 
gY := hwRound(Gear^.Y); 
6251  1000 
uw := (Gear^.Tag <> 0); // was bee underwater last tick? 
10354  1001 
nuw := CheckCoordInWater(gx, gy + Gear^.Radius); // is bee underwater now? 
6251  1002 

1003 
// if water entered or left 

1004 
if nuw <> uw then 

6580
6155187bf599
A partial reformatting of the pascal code to have consistent syntax. Things that are still inconsistent.
lovelacer
parents:
6556
diff
changeset

1005 
begin 
10363  1006 
if Gear^.Timer <> 5000 then 
1007 
AddSplashForGear(Gear, false); 

7053  1008 
StopSoundChan(Gear^.SoundChannel); 
6251  1009 
if nuw then 
6580
6155187bf599
A partial reformatting of the pascal code to have consistent syntax. Things that are still inconsistent.
lovelacer
parents:
6556
diff
changeset

1010 
begin 
6251  1011 
Gear^.SoundChannel := LoopSound(sndBeeWater); 
1012 
Gear^.Tag := 1; 

1013 
end 

1014 
else 

6580
6155187bf599
A partial reformatting of the pascal code to have consistent syntax. Things that are still inconsistent.
lovelacer
parents:
6556
diff
changeset

1015 
begin 
3454
a9bef74bd6e0
Code restlyling: experimental restyling of one module
mbait
parents:
3440
diff
changeset

1016 
Gear^.SoundChannel := LoopSound(sndBee); 
6251  1017 
Gear^.Tag := 0; 
6580
6155187bf599
A partial reformatting of the pascal code to have consistent syntax. Things that are still inconsistent.
lovelacer
parents:
6556
diff
changeset

1018 
end; 
3454
a9bef74bd6e0
Code restlyling: experimental restyling of one module
mbait
parents:
3440
diff
changeset

1019 
end; 
6251  1020 

1021 

1022 
if Gear^.Timer = 0 then 

9766
62c49992b049
fix Issue #724: Bee sound never stops (underwater when timer is 0)
sheepluva
parents:
9742
diff
changeset

1023 
begin 
62c49992b049
fix Issue #724: Bee sound never stops (underwater when timer is 0)
sheepluva
parents:
9742
diff
changeset

1024 
// no "fuel"? just fall 
62c49992b049
fix Issue #724: Bee sound never stops (underwater when timer is 0)
sheepluva
parents:
9742
diff
changeset

1025 
doStepFallingGear(Gear); 
62c49992b049
fix Issue #724: Bee sound never stops (underwater when timer is 0)
sheepluva
parents:
9742
diff
changeset

1026 
// if drowning, stop bee sound 
62c49992b049
fix Issue #724: Bee sound never stops (underwater when timer is 0)
sheepluva
parents:
9742
diff
changeset

1027 
if (Gear^.State and gstDrowning) <> 0 then 
62c49992b049
fix Issue #724: Bee sound never stops (underwater when timer is 0)
sheepluva
parents:
9742
diff
changeset

1028 
StopSoundChan(Gear^.SoundChannel); 
62c49992b049
fix Issue #724: Bee sound never stops (underwater when timer is 0)
sheepluva
parents:
9742
diff
changeset

1029 
end 
6251  1030 
else 
6580
6155187bf599
A partial reformatting of the pascal code to have consistent syntax. Things that are still inconsistent.
lovelacer
parents:
6556
diff
changeset

1031 
begin 
11475  1032 
if (Gear^.Timer and $F) = 0 then 
6580
6155187bf599
A partial reformatting of the pascal code to have consistent syntax. Things that are still inconsistent.
lovelacer
parents:
6556
diff
changeset

1033 
begin 
11475  1034 
if (Gear^.Timer and $3F) = 0 then 
10352  1035 
AddVisualGear(gX, gY, vgtBeeTrace); 
1036 

11475  1037 
Gear^.dX := Gear^.dX + _0_000064 * (Gear^.Target.X  gX); 
1038 
Gear^.dY := Gear^.dY + _0_000064 * (Gear^.Target.Y  gY); 

6251  1039 
// make sure new speed isn't higher than original one (which we stored in Friction variable) 
1040 
t := Gear^.Friction / Distance(Gear^.dX, Gear^.dY); 

1041 
Gear^.dX := Gear^.dX * t; 

1042 
Gear^.dY := Gear^.dY * t; 

6580
6155187bf599
A partial reformatting of the pascal code to have consistent syntax. Things that are still inconsistent.
lovelacer
parents:
6556
diff
changeset

1043 
end; 
6251  1044 

1045 
Gear^.X := Gear^.X + Gear^.dX; 

1046 
Gear^.Y := Gear^.Y + Gear^.dY; 

1047 

6580
6155187bf599
A partial reformatting of the pascal code to have consistent syntax. Things that are still inconsistent.
lovelacer
parents:
6556
diff
changeset

1048 
end; 
3591  1049 

3454
a9bef74bd6e0
Code restlyling: experimental restyling of one module
mbait
parents:
3440
diff
changeset

1050 

a9bef74bd6e0
Code restlyling: experimental restyling of one module
mbait
parents:
3440
diff
changeset

1051 
CheckCollision(Gear); 
6251  1052 
if ((Gear^.State and gstCollision) <> 0) then 
6580
6155187bf599
A partial reformatting of the pascal code to have consistent syntax. Things that are still inconsistent.
lovelacer
parents:
6556
diff
changeset

1053 
begin 
7053  1054 
StopSoundChan(Gear^.SoundChannel); 
11468
2f6f8baa2a97
Make weapon damage in most cases be a structure value and also expose it to lua. Needs testing/review due to conditions at time of doing this (w/ one arm, dizzy/tingling due to sodium citrate), and just number of places changed..
nemo
parents:
11391
diff
changeset

1055 
doMakeExplosion(hwRound(Gear^.X), hwRound(Gear^.Y), Gear^.Boom, Gear^.Hedgehog, EXPLAutoSound); 
5748
70d7f8e40f53
Just for fun. Flowers! Also, use a less blatant image in ammo menu.
nemo
parents:
5738
diff
changeset

1056 
for i:= 0 to 31 do 
70d7f8e40f53
Just for fun. Flowers! Also, use a less blatant image in ammo menu.
nemo
parents:
5738
diff
changeset

1057 
begin 
70d7f8e40f53
Just for fun. Flowers! Also, use a less blatant image in ammo menu.
nemo
parents:
5738
diff
changeset

1058 
flower:= AddVisualGear(hwRound(Gear^.X), hwRound(Gear^.Y), vgtStraightShot); 
6131  1059 
if flower <> nil then 
5748
70d7f8e40f53
Just for fun. Flowers! Also, use a less blatant image in ammo menu.
nemo
parents:
5738
diff
changeset

1060 
with flower^ do 
70d7f8e40f53
Just for fun. Flowers! Also, use a less blatant image in ammo menu.
nemo
parents:
5738
diff
changeset

1061 
begin 
70d7f8e40f53
Just for fun. Flowers! Also, use a less blatant image in ammo menu.
nemo
parents:
5738
diff
changeset

1062 
Scale:= 0.75; 
70d7f8e40f53
Just for fun. Flowers! Also, use a less blatant image in ammo menu.
nemo
parents:
5738
diff
changeset

1063 
dx:= 0.001 * (random(200)); 
70d7f8e40f53
Just for fun. Flowers! Also, use a less blatant image in ammo menu.
nemo
parents:
5738
diff
changeset

1064 
dy:= 0.001 * (random(200)); 
6580
6155187bf599
A partial reformatting of the pascal code to have consistent syntax. Things that are still inconsistent.
lovelacer
parents:
6556
diff
changeset

1065 
if random(2) = 0 then 
6155187bf599
A partial reformatting of the pascal code to have consistent syntax. Things that are still inconsistent.
lovelacer
parents:
6556
diff
changeset

1066 
dx := dx; 
6155187bf599
A partial reformatting of the pascal code to have consistent syntax. Things that are still inconsistent.
lovelacer
parents:
6556
diff
changeset

1067 
if random(2) = 0 then 
6155187bf599
A partial reformatting of the pascal code to have consistent syntax. Things that are still inconsistent.
lovelacer
parents:
6556
diff
changeset

1068 
dy := dy; 
5748
70d7f8e40f53
Just for fun. Flowers! Also, use a less blatant image in ammo menu.
nemo
parents:
5738
diff
changeset

1069 
FrameTicks:= random(250) + 250; 
70d7f8e40f53
Just for fun. Flowers! Also, use a less blatant image in ammo menu.
nemo
parents:
5738
diff
changeset

1070 
State:= ord(sprTargetBee); 
70d7f8e40f53
Just for fun. Flowers! Also, use a less blatant image in ammo menu.
nemo
parents:
5738
diff
changeset

1071 
end; 
70d7f8e40f53
Just for fun. Flowers! Also, use a less blatant image in ammo menu.
nemo
parents:
5738
diff
changeset

1072 
end; 
3454
a9bef74bd6e0
Code restlyling: experimental restyling of one module
mbait
parents:
3440
diff
changeset

1073 
DeleteGear(Gear); 
10135  1074 
exit; 
3454
a9bef74bd6e0
Code restlyling: experimental restyling of one module
mbait
parents:
3440
diff
changeset

1075 
end; 
6251  1076 

1077 
if (Gear^.Timer > 0) then 

9766
62c49992b049
fix Issue #724: Bee sound never stops (underwater when timer is 0)
sheepluva
parents:
9742
diff
changeset

1078 
begin 
62c49992b049
fix Issue #724: Bee sound never stops (underwater when timer is 0)
sheepluva
parents:
9742
diff
changeset

1079 
dec(Gear^.Timer); 
62c49992b049
fix Issue #724: Bee sound never stops (underwater when timer is 0)
sheepluva
parents:
9742
diff
changeset

1080 
if Gear^.Timer = 0 then 
62c49992b049
fix Issue #724: Bee sound never stops (underwater when timer is 0)
sheepluva
parents:
9742
diff
changeset

1081 
begin 
62c49992b049
fix Issue #724: Bee sound never stops (underwater when timer is 0)
sheepluva
parents:
9742
diff
changeset

1082 
// no need to display remaining time anymore 
62c49992b049
fix Issue #724: Bee sound never stops (underwater when timer is 0)
sheepluva
parents:
9742
diff
changeset

1083 
Gear^.RenderTimer:= false; 
62c49992b049
fix Issue #724: Bee sound never stops (underwater when timer is 0)
sheepluva
parents:
9742
diff
changeset

1084 
// bee can drown when timer reached 0 
9954  1085 
Gear^.State:= Gear^.State and (not gstSubmersible); 
9766
62c49992b049
fix Issue #724: Bee sound never stops (underwater when timer is 0)
sheepluva
parents:
9742
diff
changeset

1086 
end; 
6580
6155187bf599
A partial reformatting of the pascal code to have consistent syntax. Things that are still inconsistent.
lovelacer
parents:
6556
diff
changeset

1087 
end; 
4  1088 
end; 
1089 

3080  1090 
procedure doStepBee(Gear: PGear); 
4  1091 
begin 
3454
a9bef74bd6e0
Code restlyling: experimental restyling of one module
mbait
parents:
3440
diff
changeset

1092 
AllInactive := false; 
a9bef74bd6e0
Code restlyling: experimental restyling of one module
mbait
parents:
3440
diff
changeset

1093 
Gear^.X := Gear^.X + Gear^.dX; 
a9bef74bd6e0
Code restlyling: experimental restyling of one module
mbait
parents:
3440
diff
changeset

1094 
Gear^.Y := Gear^.Y + Gear^.dY; 
11286  1095 
WorldWrap(Gear); 
3454
a9bef74bd6e0
Code restlyling: experimental restyling of one module
mbait
parents:
3440
diff
changeset

1096 
Gear^.dY := Gear^.dY + cGravity; 
10363  1097 
CheckGearDrowning(Gear); 
3454
a9bef74bd6e0
Code restlyling: experimental restyling of one module
mbait
parents:
3440
diff
changeset

1098 
CheckCollision(Gear); 
a9bef74bd6e0
Code restlyling: experimental restyling of one module
mbait
parents:
3440
diff
changeset

1099 
if (Gear^.State and gstCollision) <> 0 then 
6580
6155187bf599
A partial reformatting of the pascal code to have consistent syntax. Things that are still inconsistent.
lovelacer
parents:
6556
diff
changeset

1100 
begin 
11468
2f6f8baa2a97
Make weapon damage in most cases be a structure value and also expose it to lua. Needs testing/review due to conditions at time of doing this (w/ one arm, dizzy/tingling due to sodium citrate), and just number of places changed..
nemo
parents:
11391
diff
changeset

1101 
doMakeExplosion(hwRound(Gear^.X), hwRound(Gear^.Y), Gear^.Boom, Gear^.Hedgehog, EXPLAutoSound); 
3454
a9bef74bd6e0
Code restlyling: experimental restyling of one module
mbait
parents:
3440
diff
changeset

1102 
DeleteGear(Gear); 
a9bef74bd6e0
Code restlyling: experimental restyling of one module
mbait
parents:
3440
diff
changeset

1103 
exit 
a9bef74bd6e0
Code restlyling: experimental restyling of one module
mbait
parents:
3440
diff
changeset

1104 
end; 
a9bef74bd6e0
Code restlyling: experimental restyling of one module
mbait
parents:
3440
diff
changeset

1105 
dec(Gear^.Timer); 
a9bef74bd6e0
Code restlyling: experimental restyling of one module
mbait
parents:
3440
diff
changeset

1106 
if Gear^.Timer = 0 then 
6580
6155187bf599
A partial reformatting of the pascal code to have consistent syntax. Things that are still inconsistent.
lovelacer
parents:
6556
diff
changeset

1107 
begin 
6450  1108 
Gear^.Hedgehog^.Gear^.Message:= Gear^.Hedgehog^.Gear^.Message and (not gmAttack); 
1109 
Gear^.Hedgehog^.Gear^.State:= Gear^.Hedgehog^.Gear^.State and (not gstAttacking); 

4135
5be798ecafdc
This should make bee and other targetted things behave more reliably in infinite attack mode. Blocks switching of weps if a target point is active.
nemo
parents:
4104
diff
changeset

1110 
AttackBar:= 0; 
8795  1111 

3454
a9bef74bd6e0
Code restlyling: experimental restyling of one module
mbait
parents:
3440
diff
changeset

1112 
Gear^.SoundChannel := LoopSound(sndBee); 
a9bef74bd6e0
Code restlyling: experimental restyling of one module
mbait
parents:
3440
diff
changeset

1113 
Gear^.Timer := 5000; 
3591  1114 
// save initial speed in otherwise unused Friction variable 
1115 
Gear^.Friction := Distance(Gear^.dX, Gear^.dY); 

3454
a9bef74bd6e0
Code restlyling: experimental restyling of one module
mbait
parents:
3440
diff
changeset

1116 
Gear^.doStep := @doStepBeeWork 
6580
6155187bf599
A partial reformatting of the pascal code to have consistent syntax. Things that are still inconsistent.
lovelacer
parents:
6556
diff
changeset

1117 
end; 
4  1118 
end; 
1119 

1120 
//////////////////////////////////////////////////////////////////////////////// 

876  1121 
procedure doStepShotIdle(Gear: PGear); 
1122 
begin 

3454
a9bef74bd6e0
Code restlyling: experimental restyling of one module
mbait
parents:
3440
diff
changeset

1123 
AllInactive := false; 
a9bef74bd6e0
Code restlyling: experimental restyling of one module
mbait
parents:
3440
diff
changeset

1124 
inc(Gear^.Timer); 
a9bef74bd6e0
Code restlyling: experimental restyling of one module
mbait
parents:
3440
diff
changeset

1125 
if Gear^.Timer > 75 then 
6580
6155187bf599
A partial reformatting of the pascal code to have consistent syntax. Things that are still inconsistent.
lovelacer
parents:
6556
diff
changeset

1126 
begin 
3454
a9bef74bd6e0
Code restlyling: experimental restyling of one module
mbait
parents:
3440
diff
changeset

1127 
DeleteGear(Gear); 
a9bef74bd6e0
Code restlyling: experimental restyling of one module
mbait
parents:
3440
diff
changeset

1128 
AfterAttack 
6580
6155187bf599
A partial reformatting of the pascal code to have consistent syntax. Things that are still inconsistent.
lovelacer
parents:
6556
diff
changeset

1129 
end 
876  1130 
end; 
1131 

4  1132 
procedure doStepShotgunShot(Gear: PGear); 
8795  1133 
var 
3454
a9bef74bd6e0
Code restlyling: experimental restyling of one module
mbait
parents:
3440
diff
changeset

1134 
i: LongWord; 
2828  1135 
shell: PVisualGear; 
4  1136 
begin 
3454
a9bef74bd6e0
Code restlyling: experimental restyling of one module
mbait
parents:
3440
diff
changeset

1137 
AllInactive := false; 
a9bef74bd6e0
Code restlyling: experimental restyling of one module
mbait
parents:
3440
diff
changeset

1138 

a9bef74bd6e0
Code restlyling: experimental restyling of one module
mbait
parents:
3440
diff
changeset

1139 
if ((Gear^.State and gstAnimation) = 0) then 
6580
6155187bf599
A partial reformatting of the pascal code to have consistent syntax. Things that are still inconsistent.
lovelacer
parents:
6556
diff
changeset

1140 
begin 
3454
a9bef74bd6e0
Code restlyling: experimental restyling of one module
mbait
parents:
3440
diff
changeset

1141 
dec(Gear^.Timer); 
a9bef74bd6e0
Code restlyling: experimental restyling of one module
mbait
parents:
3440
diff
changeset

1142 
if Gear^.Timer = 0 then 
6580
6155187bf599
A partial reformatting of the pascal code to have consistent syntax. Things that are still inconsistent.
lovelacer
parents:
6556
diff
changeset

1143 
begin 
3454
a9bef74bd6e0
Code restlyling: experimental restyling of one module
mbait
parents:
3440
diff
changeset

1144 
PlaySound(sndShotgunFire); 
a9bef74bd6e0
Code restlyling: experimental restyling of one module
mbait
parents:
3440
diff
changeset

1145 
shell := AddVisualGear(hwRound(Gear^.x), hwRound(Gear^.y), vgtShell); 
a9bef74bd6e0
Code restlyling: experimental restyling of one module
mbait
parents:
3440
diff
changeset

1146 
if shell <> nil then 
6580
6155187bf599
A partial reformatting of the pascal code to have consistent syntax. Things that are still inconsistent.
lovelacer
parents:
6556
diff
changeset

1147 
begin 
3593
ae50f63e4fa9
Remove hwFloat from VisualGears  they don't need the precision for syncing purposes, and it saves a whole lot of operations.
nemo
parents:
3591
diff
changeset

1148 
shell^.dX := gear^.dX.QWordValue / 17179869184; 
ae50f63e4fa9
Remove hwFloat from VisualGears  they don't need the precision for syncing purposes, and it saves a whole lot of operations.
nemo
parents:
3591
diff
changeset

1149 
shell^.dY := gear^.dY.QWordValue / 17179869184; 
3454
a9bef74bd6e0
Code restlyling: experimental restyling of one module
mbait
parents:
3440
diff
changeset

1150 
shell^.Frame := 0 
6580
6155187bf599
A partial reformatting of the pascal code to have consistent syntax. Things that are still inconsistent.
lovelacer
parents:
6556
diff
changeset

1151 
end; 
3454
a9bef74bd6e0
Code restlyling: experimental restyling of one module
mbait
parents:
3440
diff
changeset

1152 
Gear^.State := Gear^.State or gstAnimation 
6580
6155187bf599
A partial reformatting of the pascal code to have consistent syntax. Things that are still inconsistent.
lovelacer
parents:
6556
diff
changeset

1153 
end; 
6155187bf599
A partial reformatting of the pascal code to have consistent syntax. Things that are still inconsistent.
lovelacer
parents:
6556
diff
changeset

1154 
exit 
7564
651d56a6e568
Cancel shotgun shot if hedgehog is moved moved (by explosion)
unc0rr
parents:
7539
diff
changeset

1155 
end else 
651d56a6e568
Cancel shotgun shot if hedgehog is moved moved (by explosion)
unc0rr
parents:
7539
diff
changeset

1156 
if(Gear^.Hedgehog^.Gear = nil) or ((Gear^.Hedgehog^.Gear^.State and gstMoving) <> 0) then 
651d56a6e568
Cancel shotgun shot if hedgehog is moved moved (by explosion)
unc0rr
parents:
7539
diff
changeset

1157 
begin 
651d56a6e568
Cancel shotgun shot if hedgehog is moved moved (by explosion)
unc0rr
parents:
7539
diff
changeset

1158 
DeleteGear(Gear); 
651d56a6e568
Cancel shotgun shot if hedgehog is moved moved (by explosion)
unc0rr
parents:
7539
diff
changeset

1159 
AfterAttack; 
651d56a6e568
Cancel shotgun shot if hedgehog is moved moved (by explosion)
unc0rr
parents:
7539
diff
changeset

1160 
exit 
651d56a6e568
Cancel shotgun shot if hedgehog is moved moved (by explosion)
unc0rr
parents:
7539
diff
changeset

1161 
end 
6580
6155187bf599
A partial reformatting of the pascal code to have consistent syntax. Things that are still inconsistent.
lovelacer
parents:
6556
diff
changeset

1162 
else 
6155187bf599
A partial reformatting of the pascal code to have consistent syntax. Things that are still inconsistent.
lovelacer
parents:
6556
diff
changeset

1163 
inc(Gear^.Timer); 
6155187bf599
A partial reformatting of the pascal code to have consistent syntax. Things that are still inconsistent.
lovelacer
parents:
6556
diff
changeset

1164 

6155187bf599
A partial reformatting of the pascal code to have consistent syntax. Things that are still inconsistent.
lovelacer
parents:
6556
diff
changeset

1165 
i := 200; 
3454
a9bef74bd6e0
Code restlyling: experimental restyling of one module
mbait
parents:
3440
diff
changeset

1166 
repeat 
a9bef74bd6e0
Code restlyling: experimental restyling of one module
mbait
parents:
3440
diff
changeset

1167 
Gear^.X := Gear^.X + Gear^.dX; 
a9bef74bd6e0
Code restlyling: experimental restyling of one module
mbait
parents:
3440
diff
changeset

1168 
Gear^.Y := Gear^.Y + Gear^.dY; 
9485
3dee8a3b0406
add shotgun wrap, revert 100px offset. Problematic w/ things that rely on Land.
nemo
parents:
9479
diff
changeset

1169 
WorldWrap(Gear); 
3454
a9bef74bd6e0
Code restlyling: experimental restyling of one module
mbait
parents:
3440
diff
changeset

1170 
CheckCollision(Gear); 
a9bef74bd6e0
Code restlyling: experimental restyling of one module
mbait
parents:
3440
diff
changeset

1171 
if (Gear^.State and gstCollision) <> 0 then 
6580
6155187bf599
A partial reformatting of the pascal code to have consistent syntax. Things that are still inconsistent.
lovelacer
parents:
6556
diff
changeset

1172 
begin 
3454
a9bef74bd6e0
Code restlyling: experimental restyling of one module
mbait
parents:
3440
diff
changeset

1173 
Gear^.X := Gear^.X + Gear^.dX * 8; 
a9bef74bd6e0
Code restlyling: experimental restyling of one module
mbait
parents:
3440
diff
changeset

1174 
Gear^.Y := Gear^.Y + Gear^.dY * 8; 
a9bef74bd6e0
Code restlyling: experimental restyling of one module
mbait
parents:
3440
diff
changeset

1175 
ShotgunShot(Gear); 
a9bef74bd6e0
Code restlyling: experimental restyling of one module
mbait
parents:
3440
diff
changeset

1176 
Gear^.doStep := @doStepShotIdle; 
a9bef74bd6e0
Code restlyling: experimental restyling of one module
mbait
parents:
3440
diff
changeset

1177 
exit 
6580
6155187bf599
A partial reformatting of the pascal code to have consistent syntax. Things that are still inconsistent.
lovelacer
parents:
6556
diff
changeset

1178 
end; 
3454
a9bef74bd6e0
Code restlyling: experimental restyling of one module
mbait
parents:
3440
diff
changeset

1179 

a9bef74bd6e0
Code restlyling: experimental restyling of one module
mbait
parents:
3440
diff
changeset

1180 
CheckGearDrowning(Gear); 
a9bef74bd6e0
Code restlyling: experimental restyling of one module
mbait
parents:
3440
diff
changeset

1181 
if (Gear^.State and gstDrowning) <> 0 then 
6580
6155187bf599
A partial reformatting of the pascal code to have consistent syntax. Things that are still inconsistent.
lovelacer
parents:
6556
diff
changeset

1182 
begin 
3454
a9bef74bd6e0
Code restlyling: experimental restyling of one module
mbait
parents:
3440
diff
changeset

1183 
Gear^.doStep := @doStepShotIdle; 
a9bef74bd6e0
Code restlyling: experimental restyling of one module
mbait
parents:
3440
diff
changeset

1184 
exit 
6580
6155187bf599
A partial reformatting of the pascal code to have consistent syntax. Things that are still inconsistent.
lovelacer
parents:
6556
diff
changeset

1185 
end; 
3454
a9bef74bd6e0
Code restlyling: experimental restyling of one module
mbait
parents:
3440
diff
changeset

1186 
dec(i) 
a9bef74bd6e0
Code restlyling: experimental restyling of one module
mbait
parents:
3440
diff
changeset

1187 
until i = 0; 
6580
6155187bf599
A partial reformatting of the pascal code to have consistent syntax. Things that are still inconsistent.
lovelacer
parents:
6556
diff
changeset

1188 
if (hwRound(Gear^.X) and LAND_WIDTH_MASK <> 0) or (hwRound(Gear^.Y) and LAND_HEIGHT_MASK <> 0) then 
3454
a9bef74bd6e0
Code restlyling: experimental restyling of one module
mbait
parents:
3440
diff
changeset

1189 
Gear^.doStep := @doStepShotIdle 
4  1190 
end; 
1191 

1192 
//////////////////////////////////////////////////////////////////////////////// 

5841  1193 
procedure spawnBulletTrail(Bullet: PGear); 
1194 
var oX, oY: hwFloat; 

1195 
VGear: PVisualGear; 

1196 
begin 

1197 
if Bullet^.PortalCounter = 0 then 

1198 
begin 

1199 
ox:= CurrentHedgehog^.Gear^.X + Int2hwFloat(GetLaunchX(CurrentHedgehog^.CurAmmoType, hwSign(CurrentHedgehog^.Gear^.dX), CurrentHedgehog^.Gear^.Angle)); 

1200 
oy:= CurrentHedgehog^.Gear^.Y + Int2hwFloat(GetLaunchY(CurrentHedgehog^.CurAmmoType, CurrentHedgehog^.Gear^.Angle)); 

1201 
end 

1202 
else 

1203 
begin 

1204 
ox:= Bullet^.Elasticity; 

1205 
oy:= Bullet^.Friction; 

1206 
end; 

1207 

1208 
// Bullet trail 

1209 
VGear := AddVisualGear(hwRound(ox), hwRound(oy), vgtLineTrail); 

8795  1210 

5841  1211 
if VGear <> nil then 
1212 
begin 

1213 
VGear^.X:= hwFloat2Float(ox); 

1214 
VGear^.Y:= hwFloat2Float(oy); 

1215 
VGear^.dX:= hwFloat2Float(Bullet^.X); 

1216 
VGear^.dY:= hwFloat2Float(Bullet^.Y); 

1217 

1218 
// reached edge of land. assume infinite beam. Extend it way out past camera 

1219 
if (hwRound(Bullet^.X) and LAND_WIDTH_MASK <> 0) 

6580
6155187bf599
A partial reformatting of the pascal code to have consistent syntax. Things that are still inconsistent.
lovelacer
parents:
6556
diff
changeset

1220 
or (hwRound(Bullet^.Y) and LAND_HEIGHT_MASK <> 0) then 
5841  1221 
// only extend if not under water 
10354  1222 
if not CheckCoordInWater(hwRound(Bullet^.X), hwRound(Bullet^.Y)) then 
5841  1223 
begin 
7829
c1dc7839d7b9
Set minimums on a few values to avoid camera zooming out past them. partly Issue #430. Might be worth defining a new constant for this.
nemo
parents:
7784
diff
changeset

1224 
VGear^.dX := VGear^.dX + max(LAND_WIDTH,4096) * (VGear^.dX  VGear^.X); 
c1dc7839d7b9
Set minimums on a few values to avoid camera zooming out past them. partly Issue #430. Might be worth defining a new constant for this.
nemo
parents:
7784
diff
changeset

1225 
VGear^.dY := VGear^.dY + max(LAND_WIDTH,4096) * (VGear^.dY  VGear^.Y); 
5841  1226 
end; 
1227 

1228 
VGear^.Timer := 200; 

1229 
end; 

1230 
end; 

1231 

2023
41d3afaa20c7
Artillery mode, sniper rifle, speech bubble tweaks, fix of rope bug introduced by enabling hats in jump
nemo
parents:
2017
diff
changeset

1232 
procedure doStepBulletWork(Gear: PGear); 
8795  1233 
var 
3454
a9bef74bd6e0
Code restlyling: experimental restyling of one module
mbait
parents:
3440
diff
changeset

1234 
i, x, y: LongWord; 
9485
3dee8a3b0406
add shotgun wrap, revert 100px offset. Problematic w/ things that rely on Land.
nemo
parents:
9479
diff
changeset

1235 
oX, oY, tX, tY, cX, cY: hwFloat; 
4327  1236 
VGear: PVisualGear; 
38  1237 
begin 
3454
a9bef74bd6e0
Code restlyling: experimental restyling of one module
mbait
parents:
3440
diff
changeset

1238 
AllInactive := false; 
a9bef74bd6e0
Code restlyling: experimental restyling of one module
mbait
parents:
3440
diff
changeset

1239 
inc(Gear^.Timer); 
a9bef74bd6e0
Code restlyling: experimental restyling of one module
mbait
parents:
3440
diff
changeset

1240 
i := 80; 
a9bef74bd6e0
Code restlyling: experimental restyling of one module
mbait
parents:
3440
diff
changeset

1241 
oX := Gear^.X; 
a9bef74bd6e0
Code restlyling: experimental restyling of one module
mbait
parents:
3440
diff
changeset

1242 
oY := Gear^.Y; 
a9bef74bd6e0
Code restlyling: experimental restyling of one module
mbait
parents:
3440
diff
changeset

1243 
repeat 
a9bef74bd6e0
Code restlyling: experimental restyling of one module
mbait
parents:
3440
diff
changeset

1244 
Gear^.X := Gear^.X + Gear^.dX; 
a9bef74bd6e0
Code restlyling: experimental restyling of one module
mbait
parents:
3440
diff
changeset

1245 
Gear^.Y := Gear^.Y + Gear^.dY; 
9485
3dee8a3b0406
add shotgun wrap, revert 100px offset. Problematic w/ things that rely on Land.
nemo
parents:
9479
diff
changeset

1246 
tX:= Gear^.X; 
3dee8a3b0406
add shotgun wrap, revert 100px offset. Problematic w/ things that rely on Land.
nemo
parents:
9479
diff
changeset

1247 
tY:= Gear^.Y; 
9565  1248 
if (Gear^.PortalCounter < 30) and WorldWrap(Gear) then 
9485
3dee8a3b0406
add shotgun wrap, revert 100px offset. Problematic w/ things that rely on Land.
nemo
parents:
9479
diff
changeset

1249 
begin 
3dee8a3b0406
add shotgun wrap, revert 100px offset. Problematic w/ things that rely on Land.
nemo
parents:
9479
diff
changeset

1250 
cX:= Gear^.X; 
3dee8a3b0406
add shotgun wrap, revert 100px offset. Problematic w/ things that rely on Land.
nemo
parents:
9479
diff
changeset

1251 
cY:= Gear^.Y; 
3dee8a3b0406
add shotgun wrap, revert 100px offset. Problematic w/ things that rely on Land.
nemo
parents:
9479
diff
changeset

1252 
Gear^.X:= tX; 
3dee8a3b0406
add shotgun wrap, revert 100px offset. Problematic w/ things that rely on Land.
nemo
parents:
9479
diff
changeset

1253 
Gear^.Y:= tY; 
3dee8a3b0406
add shotgun wrap, revert 100px offset. Problematic w/ things that rely on Land.
nemo
parents:
9479
diff
changeset

1254 
SpawnBulletTrail(Gear); 
3dee8a3b0406
add shotgun wrap, revert 100px offset. Problematic w/ things that rely on Land.
nemo
parents:
9479
diff
changeset

1255 
Gear^.X:= cX; 
3dee8a3b0406
add shotgun wrap, revert 100px offset. Problematic w/ things that rely on Land.
nemo
parents:
9479
diff
changeset

1256 
Gear^.Y:= cY; 
3dee8a3b0406
add shotgun wrap, revert 100px offset. Problematic w/ things that rely on Land.
nemo
parents:
9479
diff
changeset

1257 
inc(Gear^.PortalCounter); 
3dee8a3b0406
add shotgun wrap, revert 100px offset. Problematic w/ things that rely on Land.
nemo
parents:
9479
diff
changeset

1258 
Gear^.Elasticity:= Gear^.X; 
3dee8a3b0406
add shotgun wrap, revert 100px offset. Problematic w/ things that rely on Land.
nemo
parents:
9479
diff
changeset

1259 
Gear^.Friction:= Gear^.Y; 
3dee8a3b0406
add shotgun wrap, revert 100px offset. Problematic w/ things that rely on Land.
nemo
parents:
9479
diff
changeset

1260 
SpawnBulletTrail(Gear); 
3dee8a3b0406
add shotgun wrap, revert 100px offset. Problematic w/ things that rely on Land.
nemo
parents:
9479
diff
changeset

1261 
end; 
3454
a9bef74bd6e0
Code restlyling: experimental restyling of one module
mbait
parents:
3440
diff
changeset

1262 
x := hwRound(Gear^.X); 
a9bef74bd6e0
Code restlyling: experimental restyling of one module
mbait
parents:
3440
diff
changeset

1263 
y := hwRound(Gear^.Y); 
8795  1264 

6580
6155187bf599
A partial reformatting of the pascal code to have consistent syntax. Things that are still inconsistent.
lovelacer
parents:
6556
diff
changeset

1265 
if ((y and LAND_HEIGHT_MASK) = 0) and ((x and LAND_WIDTH_MASK) = 0) and (Land[y, x] <> 0) then 
6155187bf599
A partial reformatting of the pascal code to have consistent syntax. Things that are still inconsistent.
lovelacer
parents:
6556
diff
changeset

1266 
inc(Gear^.Damage); 
5841  1267 
// let's interrupt before a collision to give portals a chance to catch the bullet 
9954  1268 
if (Gear^.Damage = 1) and (Gear^.Tag = 0) and (not CheckLandValue(x, y, lfLandMask)) then 
6580
6155187bf599
A partial reformatting of the pascal code to have consistent syntax. Things that are still inconsistent.
lovelacer
parents:
6556
diff
changeset

1269 
begin 
5841  1270 
Gear^.Tag := 1; 
1271 
Gear^.Damage := 0; 

1272 
Gear^.X := Gear^.X  Gear^.dX; 

