author  alfadur 
Thu, 16 Jul 2020 22:30:32 +0300  
changeset 15724  ff7291bc811f 
parent 15723  4e65fd69f58c 
child 15731  26247a74d823 
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); 

14011
3c40754f6cfe
Add Grenade taunt when grenade close to hog is about to blow up
Wuzzy <Wuzzy2@mail.ru>
parents:
14009
diff
changeset

35 
procedure makeHogsWorry(x, y: hwFloat; r: LongInt; gearType: TGearType); 
9285  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); 

13151
deab88f1f6f7
Improve appearance of bullet trails, slight fade out at beginning
alfadur
parents:
13147
diff
changeset

50 
procedure spawnBulletTrail(Bullet: PGear; bulletX, bulletY: hwFloat; fadeIn: Boolean); 
9285  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); 

14566
85921db6f7c3
Disallow placement of piano beyond bounce world edge
Wuzzy <Wuzzy2@mail.ru>
parents:
14565
diff
changeset

118 
procedure doStepPianoWork(Gear: PGear); 
9285  119 
procedure doStepSineGunShotWork(Gear: PGear); 
120 
procedure doStepSineGunShot(Gear: PGear); 

121 
procedure doStepFlamethrowerWork(Gear: PGear); 

122 
procedure doStepFlamethrower(Gear: PGear); 

123 
procedure doStepLandGunWork(Gear: PGear); 

124 
procedure doStepLandGun(Gear: PGear); 

125 
procedure doStepPoisonCloud(Gear: PGear); 

126 
procedure doStepHammer(Gear: PGear); 

127 
procedure doStepHammerHitWork(Gear: PGear); 

128 
procedure doStepHammerHit(Gear: PGear); 

129 
procedure doStepResurrectorWork(Gear: PGear); 

130 
procedure doStepResurrector(Gear: PGear); 

131 
procedure doStepNapalmBomb(Gear: PGear); 

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); 

13605
422d6062620a
hijack the duck for an attempted resurrection of the creeper. initial pass.
nemo
parents:
13604
diff
changeset

139 
procedure doStepCreeper(Gear: PGear); 
9285  140 
procedure doStepKnife(Gear: PGear); 
12898  141 
procedure doStepMinigunWork(Gear: PGear); 
142 
procedure doStepMinigun(Gear: PGear); 

143 
procedure doStepMinigunBullet(Gear: PGear); 

15715  144 
procedure doStepSentryDeploy(Gear: PGear); 
9285  145 

146 
var 

147 
upd: Longword; 

148 
snowLeft,snowRight: LongInt; 

149 

150 
implementation 

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

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

15221
bf11546c1920
Remove excessive console output of gtAirAttack
Wuzzy <Wuzzy2@mail.ru>
parents:
15204
diff
changeset

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

154 
, 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

155 

3569  156 
procedure doStepPerPixel(Gear: PGear; step: TGearStepProcedure; onlyCheckIfChanged: boolean); 
157 
var 

158 
dX, dY, sX, sY: hwFloat; 

159 
i, steps: LongWord; 

160 
caller: TGearStepProcedure; 

161 
begin 

162 
dX:= Gear^.dX; 

163 
dY:= Gear^.dY; 

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

165 

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

167 
if steps < 1 then 

4578  168 
begin 
3569  169 
if onlyCheckIfChanged then 
4578  170 
begin 
3569  171 
Gear^.X := Gear^.X + dX; 
172 
Gear^.Y := Gear^.Y + dY; 

173 
EXIT; 

4578  174 
end 
3569  175 
else 
176 
steps := 1; 

4578  177 
end; 
3569  178 

179 
if steps > 1 then 

4578  180 
begin 
3569  181 
sX:= dX / steps; 
182 
sY:= dY / steps; 

4578  183 
end 
8795  184 

3569  185 
else 
4578  186 
begin 
3569  187 
sX:= dX; 
188 
sY:= dY; 

4578  189 
end; 
3569  190 

191 
caller:= Gear^.doStep; 

192 

193 
for i:= 1 to steps do 

4578  194 
begin 
3569  195 
Gear^.X := Gear^.X + sX; 
196 
Gear^.Y := Gear^.Y + sY; 

197 
step(Gear); 

198 
if (Gear^.doStep <> caller) 

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

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

201 
break; 

4578  202 
end; 
3569  203 
end; 
204 

14011
3c40754f6cfe
Add Grenade taunt when grenade close to hog is about to blow up
Wuzzy <Wuzzy2@mail.ru>
parents:
14009
diff
changeset

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

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

208 
d: LongInt; 
14011
3c40754f6cfe
Add Grenade taunt when grenade close to hog is about to blow up
Wuzzy <Wuzzy2@mail.ru>
parents:
14009
diff
changeset

209 
grenadeTaunt: boolean; 
2647  210 
begin 
3454
a9bef74bd6e0
Code restlyling: experimental restyling of one module
mbait
parents:
3440
diff
changeset

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

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

214 
if (gi^.Kind = gtHedgehog) then 
4578  215 
begin 
12805  216 
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

217 
if (d > 1) and (gi^.Hedgehog^.Effects[heInvulnerable] = 0) and (GetRandom(2) = 0) then 
4578  218 
begin 
3143  219 
if (CurrentHedgehog^.Gear = gi) then 
14019
1effb8b72b11
New taunt: Runaway, when something is about to blow up near current hog
Wuzzy <Wuzzy2@mail.ru>
parents:
14014
diff
changeset

220 
if (CurrentHedgehog^.Gear^.FlightTime = 0) then 
1effb8b72b11
New taunt: Runaway, when something is about to blow up near current hog
Wuzzy <Wuzzy2@mail.ru>
parents:
14014
diff
changeset

221 
case random(4) of 
1effb8b72b11
New taunt: Runaway, when something is about to blow up near current hog
Wuzzy <Wuzzy2@mail.ru>
parents:
14014
diff
changeset

222 
0: PlaySoundV(sndWhatThe, gi^.Hedgehog^.Team^.voicepack); 
1effb8b72b11
New taunt: Runaway, when something is about to blow up near current hog
Wuzzy <Wuzzy2@mail.ru>
parents:
14014
diff
changeset

223 
1: PlaySoundV(sndOops, gi^.Hedgehog^.Team^.voicepack); 
1effb8b72b11
New taunt: Runaway, when something is about to blow up near current hog
Wuzzy <Wuzzy2@mail.ru>
parents:
14014
diff
changeset

224 
2: PlaySoundV(sndRunAway, gi^.Hedgehog^.Team^.voicepack); 
1effb8b72b11
New taunt: Runaway, when something is about to blow up near current hog
Wuzzy <Wuzzy2@mail.ru>
parents:
14014
diff
changeset

225 
3: PlaySoundV(sndRunAway, gi^.Hedgehog^.Team^.voicepack); 
1effb8b72b11
New taunt: Runaway, when something is about to blow up near current hog
Wuzzy <Wuzzy2@mail.ru>
parents:
14014
diff
changeset

226 
end 
14014  227 
else 
14019
1effb8b72b11
New taunt: Runaway, when something is about to blow up near current hog
Wuzzy <Wuzzy2@mail.ru>
parents:
14014
diff
changeset

228 
if random(4) = 0 then 
1effb8b72b11
New taunt: Runaway, when something is about to blow up near current hog
Wuzzy <Wuzzy2@mail.ru>
parents:
14014
diff
changeset

229 
PlaySoundV(sndWhatThe, gi^.Hedgehog^.Team^.voicepack) 
1effb8b72b11
New taunt: Runaway, when something is about to blow up near current hog
Wuzzy <Wuzzy2@mail.ru>
parents:
14014
diff
changeset

230 
else 
1effb8b72b11
New taunt: Runaway, when something is about to blow up near current hog
Wuzzy <Wuzzy2@mail.ru>
parents:
14014
diff
changeset

231 
PlaySoundV(sndOops, gi^.Hedgehog^.Team^.voicepack) 
8795  232 

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

233 
else 
4578  234 
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

235 
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

236 
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

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

238 
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

239 
end; 
8795  240 

14011
3c40754f6cfe
Add Grenade taunt when grenade close to hog is about to blow up
Wuzzy <Wuzzy2@mail.ru>
parents:
14009
diff
changeset

241 
grenadeTaunt:= false; 
3c40754f6cfe
Add Grenade taunt when grenade close to hog is about to blow up
Wuzzy <Wuzzy2@mail.ru>
parents:
14009
diff
changeset

242 
if (gearType = gtGrenade) then 
3c40754f6cfe
Add Grenade taunt when grenade close to hog is about to blow up
Wuzzy <Wuzzy2@mail.ru>
parents:
14009
diff
changeset

243 
grenadeTaunt:= random(2) = 0; 
3c40754f6cfe
Add Grenade taunt when grenade close to hog is about to blow up
Wuzzy <Wuzzy2@mail.ru>
parents:
14009
diff
changeset

244 

3c40754f6cfe
Add Grenade taunt when grenade close to hog is about to blow up
Wuzzy <Wuzzy2@mail.ru>
parents:
14009
diff
changeset

245 
if grenadeTaunt then 
3c40754f6cfe
Add Grenade taunt when grenade close to hog is about to blow up
Wuzzy <Wuzzy2@mail.ru>
parents:
14009
diff
changeset

246 
PlaySoundV(sndGrenade, gi^.Hedgehog^.Team^.voicepack) 
3143  247 
else 
14011
3c40754f6cfe
Add Grenade taunt when grenade close to hog is about to blow up
Wuzzy <Wuzzy2@mail.ru>
parents:
14009
diff
changeset

248 
if d > r div 2 then 
14014  249 
if random(3) = 0 then 
250 
PlaySoundV(sndWhatThe, gi^.Hedgehog^.Team^.voicepack) 

251 
else 

252 
PlaySoundV(sndNooo, gi^.Hedgehog^.Team^.voicepack) 

14011
3c40754f6cfe
Add Grenade taunt when grenade close to hog is about to blow up
Wuzzy <Wuzzy2@mail.ru>
parents:
14009
diff
changeset

253 
else 
3c40754f6cfe
Add Grenade taunt when grenade close to hog is about to blow up
Wuzzy <Wuzzy2@mail.ru>
parents:
14009
diff
changeset

254 
PlaySoundV(sndUhOh, gi^.Hedgehog^.Team^.voicepack); 
3c40754f6cfe
Add Grenade taunt when grenade close to hog is about to blow up
Wuzzy <Wuzzy2@mail.ru>
parents:
14009
diff
changeset

255 

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

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

258 
end; 
8795  259 

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

261 
end; 
2647  262 
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

263 

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

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

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

266 
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

267 
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

268 
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

269 
FollowGear:= nil; 
8795  270 

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

271 
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

272 
lastGearByUID := nil; 
8795  273 

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

274 
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

275 
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

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

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

278 
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

279 
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

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

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

282 
HH^.GearHidden:= HH^.Gear; 
13140
e330feceb662
Hide team bar if all hedgehogs in it are hidden or dead
Wuzzy <Wuzzy2@mail.ru>
parents:
13096
diff
changeset

283 
HH^.Gear:= nil; 
e330feceb662
Hide team bar if all hedgehogs in it are hidden or dead
Wuzzy <Wuzzy2@mail.ru>
parents:
13096
diff
changeset

284 
AddVisualGear(0, 0, vgtTeamHealthSorter); 
5807
5c8fe58dead5
Define 2 script callbacks to notify of hog vanishment
nemo
parents:
5806
diff
changeset

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

286 

4  287 

288 
//////////////////////////////////////////////////////////////////////////////// 

289 
procedure doStepDrowningGear(Gear: PGear); 

12714
5a57acce9cae
Fix bubbles drawn on the wrong side when hog drowns and faces right
Wuzzy <almikes@aol.com>
parents:
12712
diff
changeset

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

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

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

293 
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

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

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

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

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

298 
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

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

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

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

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

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

305 

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

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

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

308 

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

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

310 

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

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

312 
begin 
14282
6015b74eea55
overall, using LongInt for leftX/rightX results in fewer casts, since most comparisons are against ints.
nemo
parents:
14204
diff
changeset

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

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

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

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

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

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

320 

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

321 
// Create some bubbles (0.5% might be better but causes too few bubbles sometimes) 
12714
5a57acce9cae
Fix bubbles drawn on the wrong side when hog drowns and faces right
Wuzzy <almikes@aol.com>
parents:
12712
diff
changeset

322 
if (Gear^.Kind = gtHedgehog) and (Gear^.dX.isNegative) then 
5a57acce9cae
Fix bubbles drawn on the wrong side when hog drowns and faces right
Wuzzy <almikes@aol.com>
parents:
12712
diff
changeset

323 
bubbleX:= hwRound(Gear^.X)  Gear^.Radius 
5a57acce9cae
Fix bubbles drawn on the wrong side when hog drowns and faces right
Wuzzy <almikes@aol.com>
parents:
12712
diff
changeset

324 
else 
5a57acce9cae
Fix bubbles drawn on the wrong side when hog drowns and faces right
Wuzzy <almikes@aol.com>
parents:
12712
diff
changeset

325 
bubbleX:= hwRound(Gear^.X) + Gear^.Radius; 
5a57acce9cae
Fix bubbles drawn on the wrong side when hog drowns and faces right
Wuzzy <almikes@aol.com>
parents:
12712
diff
changeset

326 
bubbleY:= hwRound(Gear^.Y)  Gear^.Radius; 
10364
9f7be3da1245
burst drowning gears into bubbles after timeout
sheepluva
parents:
10363
diff
changeset

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

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

329 
if (Gear^.Kind = gtHedgehog) and (Random(4) = 0) then 
12714
5a57acce9cae
Fix bubbles drawn on the wrong side when hog drowns and faces right
Wuzzy <almikes@aol.com>
parents:
12712
diff
changeset

330 
AddVisualGear(bubbleX, bubbleY, vgtBubble) 
10364
9f7be3da1245
burst drowning gears into bubbles after timeout
sheepluva
parents:
10363
diff
changeset

331 
else if Random(12) = 0 then 
12714
5a57acce9cae
Fix bubbles drawn on the wrong side when hog drowns and faces right
Wuzzy <almikes@aol.com>
parents:
12712
diff
changeset

332 
AddVisualGear(bubbleX, bubbleY, vgtBubble); 
13737
bbea77a8dff9
Fix damage not being displayed if hog drowns in water with 100% opacity (like in Compost theme)
Wuzzy <Wuzzy2@mail.ru>
parents:
13651
diff
changeset

333 
// Instadelete gear and skip drowning animation if water is 100% opaque 
10364
9f7be3da1245
burst drowning gears into bubbles after timeout
sheepluva
parents:
10363
diff
changeset

334 
if (not SuddenDeathDmg and (WaterOpacity > $FE)) 
13737
bbea77a8dff9
Fix damage not being displayed if hog drowns in water with 100% opacity (like in Compost theme)
Wuzzy <Wuzzy2@mail.ru>
parents:
13651
diff
changeset

335 
or (SuddenDeathDmg and (SDWaterOpacity > $FE)) then 
bbea77a8dff9
Fix damage not being displayed if hog drowns in water with 100% opacity (like in Compost theme)
Wuzzy <Wuzzy2@mail.ru>
parents:
13651
diff
changeset

336 
begin 
bbea77a8dff9
Fix damage not being displayed if hog drowns in water with 100% opacity (like in Compost theme)
Wuzzy <Wuzzy2@mail.ru>
parents:
13651
diff
changeset

337 
// Teleport gear to a suitable position for the damage tag in the water 
bbea77a8dff9
Fix damage not being displayed if hog drowns in water with 100% opacity (like in Compost theme)
Wuzzy <Wuzzy2@mail.ru>
parents:
13651
diff
changeset

338 
if (WorldEdge = weSea) and (hwRound(Gear^.X)  Gear^.Radius < leftX) then 
bbea77a8dff9
Fix damage not being displayed if hog drowns in water with 100% opacity (like in Compost theme)
Wuzzy <Wuzzy2@mail.ru>
parents:
13651
diff
changeset

339 
begin 
bbea77a8dff9
Fix damage not being displayed if hog drowns in water with 100% opacity (like in Compost theme)
Wuzzy <Wuzzy2@mail.ru>
parents:
13651
diff
changeset

340 
if (hwRound(Gear^.X)  Gear^.Radius > leftX  90) then 
bbea77a8dff9
Fix damage not being displayed if hog drowns in water with 100% opacity (like in Compost theme)
Wuzzy <Wuzzy2@mail.ru>
parents:
13651
diff
changeset

341 
Gear^.X := Gear^.X  _90 
bbea77a8dff9
Fix damage not being displayed if hog drowns in water with 100% opacity (like in Compost theme)
Wuzzy <Wuzzy2@mail.ru>
parents:
13651
diff
changeset

342 
end 
bbea77a8dff9
Fix damage not being displayed if hog drowns in water with 100% opacity (like in Compost theme)
Wuzzy <Wuzzy2@mail.ru>
parents:
13651
diff
changeset

343 
else if (WorldEdge = weSea) and (hwRound(Gear^.X) + Gear^.Radius > rightX) then 
bbea77a8dff9
Fix damage not being displayed if hog drowns in water with 100% opacity (like in Compost theme)
Wuzzy <Wuzzy2@mail.ru>
parents:
13651
diff
changeset

344 
begin 
bbea77a8dff9
Fix damage not being displayed if hog drowns in water with 100% opacity (like in Compost theme)
Wuzzy <Wuzzy2@mail.ru>
parents:
13651
diff
changeset

345 
if (hwRound(Gear^.X)  Gear^.Radius < rightX + 90) then 
bbea77a8dff9
Fix damage not being displayed if hog drowns in water with 100% opacity (like in Compost theme)
Wuzzy <Wuzzy2@mail.ru>
parents:
13651
diff
changeset

346 
Gear^.X := Gear^.X + _90 
bbea77a8dff9
Fix damage not being displayed if hog drowns in water with 100% opacity (like in Compost theme)
Wuzzy <Wuzzy2@mail.ru>
parents:
13651
diff
changeset

347 
end 
bbea77a8dff9
Fix damage not being displayed if hog drowns in water with 100% opacity (like in Compost theme)
Wuzzy <Wuzzy2@mail.ru>
parents:
13651
diff
changeset

348 
else 
bbea77a8dff9
Fix damage not being displayed if hog drowns in water with 100% opacity (like in Compost theme)
Wuzzy <Wuzzy2@mail.ru>
parents:
13651
diff
changeset

349 
Gear^.Y := int2hwFloat(Gear^.Radius + cWaterLine + cVisibleWater); 
bbea77a8dff9
Fix damage not being displayed if hog drowns in water with 100% opacity (like in Compost theme)
Wuzzy <Wuzzy2@mail.ru>
parents:
13651
diff
changeset

350 
DeleteGear(Gear); 
bbea77a8dff9
Fix damage not being displayed if hog drowns in water with 100% opacity (like in Compost theme)
Wuzzy <Wuzzy2@mail.ru>
parents:
13651
diff
changeset

351 
exit; 
bbea77a8dff9
Fix damage not being displayed if hog drowns in water with 100% opacity (like in Compost theme)
Wuzzy <Wuzzy2@mail.ru>
parents:
13651
diff
changeset

352 
end; 
15244
44533b2e4fb1
Drowning gears: Delete big gears when they're *completely* out of visible area
Wuzzy <Wuzzy2@mail.ru>
parents:
15243
diff
changeset

353 
// Delete gear normally if it is outside of visible range. 
44533b2e4fb1
Drowning gears: Delete big gears when they're *completely* out of visible area
Wuzzy <Wuzzy2@mail.ru>
parents:
15243
diff
changeset

354 
// But first determine size tolerance for big gears to make sure the gear is REALLY out of range. 
44533b2e4fb1
Drowning gears: Delete big gears when they're *completely* out of visible area
Wuzzy <Wuzzy2@mail.ru>
parents:
15243
diff
changeset

355 
if Gear^.Kind = gtPiano then 
44533b2e4fb1
Drowning gears: Delete big gears when they're *completely* out of visible area
Wuzzy <Wuzzy2@mail.ru>
parents:
15243
diff
changeset

356 
d:= SpritesData[sprPiano].height 
44533b2e4fb1
Drowning gears: Delete big gears when they're *completely* out of visible area
Wuzzy <Wuzzy2@mail.ru>
parents:
15243
diff
changeset

357 
else if Gear^.Kind = gtRCPlane then 
44533b2e4fb1
Drowning gears: Delete big gears when they're *completely* out of visible area
Wuzzy <Wuzzy2@mail.ru>
parents:
15243
diff
changeset

358 
d:= SpritesData[sprPlane].width 
44533b2e4fb1
Drowning gears: Delete big gears when they're *completely* out of visible area
Wuzzy <Wuzzy2@mail.ru>
parents:
15243
diff
changeset

359 
else if Gear^.Kind = gtKnife then 
44533b2e4fb1
Drowning gears: Delete big gears when they're *completely* out of visible area
Wuzzy <Wuzzy2@mail.ru>
parents:
15243
diff
changeset

360 
d:= SpritesData[sprKnife].height 
44533b2e4fb1
Drowning gears: Delete big gears when they're *completely* out of visible area
Wuzzy <Wuzzy2@mail.ru>
parents:
15243
diff
changeset

361 
else if Gear^.Kind = gtDynamite then 
44533b2e4fb1
Drowning gears: Delete big gears when they're *completely* out of visible area
Wuzzy <Wuzzy2@mail.ru>
parents:
15243
diff
changeset

362 
d:= SpritesData[sprDynamite].height 
44533b2e4fb1
Drowning gears: Delete big gears when they're *completely* out of visible area
Wuzzy <Wuzzy2@mail.ru>
parents:
15243
diff
changeset

363 
else if Gear^.Kind = gtSnowball then 
44533b2e4fb1
Drowning gears: Delete big gears when they're *completely* out of visible area
Wuzzy <Wuzzy2@mail.ru>
parents:
15243
diff
changeset

364 
d:= SpritesData[sprSnowball].height 
44533b2e4fb1
Drowning gears: Delete big gears when they're *completely* out of visible area
Wuzzy <Wuzzy2@mail.ru>
parents:
15243
diff
changeset

365 
else 
44533b2e4fb1
Drowning gears: Delete big gears when they're *completely* out of visible area
Wuzzy <Wuzzy2@mail.ru>
parents:
15243
diff
changeset

366 
d:= Gear^.Radius * 2; 
44533b2e4fb1
Drowning gears: Delete big gears when they're *completely* out of visible area
Wuzzy <Wuzzy2@mail.ru>
parents:
15243
diff
changeset

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

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

369 
end; 
4  370 

371 
//////////////////////////////////////////////////////////////////////////////// 

372 
procedure doStepFallingGear(Gear: PGear); 

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

374 
isFalling: boolean; 
9526  375 
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

376 
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

377 
land, xland: word; 
4  378 
begin 
9526  379 
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

380 
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

381 
gY:= hwRound(Gear^.Y); 
13610
f1b6070a6e14
Fix projectiles reacing incorrectly with land just behind the wrap world edge
Wuzzy <Wuzzy2@mail.ru>
parents:
13609
diff
changeset

382 
Gear^.State := Gear^.State and (not gstCollision); 
f1b6070a6e14
Fix projectiles reacing incorrectly with land just behind the wrap world edge
Wuzzy <Wuzzy2@mail.ru>
parents:
13609
diff
changeset

383 

f1b6070a6e14
Fix projectiles reacing incorrectly with land just behind the wrap world edge
Wuzzy <Wuzzy2@mail.ru>
parents:
13609
diff
changeset

384 
// World wrap 
f1b6070a6e14
Fix projectiles reacing incorrectly with land just behind the wrap world edge
Wuzzy <Wuzzy2@mail.ru>
parents:
13609
diff
changeset

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

386 
((TestCollisionXwithGear(Gear, 1) <> 0) or (TestCollisionXwithGear(Gear, 1) <> 0)) then 
9526  387 
begin 
13610
f1b6070a6e14
Fix projectiles reacing incorrectly with land just behind the wrap world edge
Wuzzy <Wuzzy2@mail.ru>
parents:
13609
diff
changeset

388 
// Collision with land that *just* behind the other side of the world wrap edge 
f1b6070a6e14
Fix projectiles reacing incorrectly with land just behind the wrap world edge
Wuzzy <Wuzzy2@mail.ru>
parents:
13609
diff
changeset

389 
if (not Gear^.Sticky) then 
f1b6070a6e14
Fix projectiles reacing incorrectly with land just behind the wrap world edge
Wuzzy <Wuzzy2@mail.ru>
parents:
13609
diff
changeset

390 
begin 
f1b6070a6e14
Fix projectiles reacing incorrectly with land just behind the wrap world edge
Wuzzy <Wuzzy2@mail.ru>
parents:
13609
diff
changeset

391 
Gear^.X:= tX; 
14282
6015b74eea55
overall, using LongInt for leftX/rightX results in fewer casts, since most comparisons are against ints.
nemo
parents:
14204
diff
changeset

392 
Gear^.dX.isNegative:= (gX > leftX + Gear^.Radius*2); 
13610
f1b6070a6e14
Fix projectiles reacing incorrectly with land just behind the wrap world edge
Wuzzy <Wuzzy2@mail.ru>
parents:
13609
diff
changeset

393 
Gear^.dX := Gear^.dX * Gear^.Friction; 
f1b6070a6e14
Fix projectiles reacing incorrectly with land just behind the wrap world edge
Wuzzy <Wuzzy2@mail.ru>
parents:
13609
diff
changeset

394 
end; 
f1b6070a6e14
Fix projectiles reacing incorrectly with land just behind the wrap world edge
Wuzzy <Wuzzy2@mail.ru>
parents:
13609
diff
changeset

395 
Gear^.State := Gear^.State or gstCollision; 
9526  396 
end; 
9473
a51a69094c24
partial implementation of noninfinite world (edge wrap/warp/bounce)
nemo
parents:
9470
diff
changeset

397 

7627  398 
// 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

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

401 
if Gear^.dY.Round > 1 then 
7627  402 
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

403 

10354  404 
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

405 
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

406 
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

407 
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

408 
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

409 

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

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

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

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

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

414 

3359  415 
// 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

416 
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

417 
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

418 
Gear^.Message := Gear^.Message or gmDestroy; 
3359  419 

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

420 
if Gear^.dY.isNegative then 
4578  421 
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

422 
land:= TestCollisionYwithGear(Gear, 1); 
9820  423 
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

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

426 
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

427 
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

428 
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

429 
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

430 
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

431 
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

432 
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

433 
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

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 Gear^.dY :=  Gear^.dY * cElastic 
4578  436 
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

437 
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

438 
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

439 
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

440 
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

441 
end 
4578  442 
end 
8795  443 
else 
6498  444 
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

445 
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

446 
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

447 
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

448 
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

449 
isFalling := false; 
8795  450 
if land and lfIce <> 0 then 
6498  451 
Gear^.dX := Gear^.dX * (_0_9 + Gear^.Friction * _0_1) 
8795  452 
else 
6498  453 
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

454 

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

455 
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

456 
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

457 
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

458 
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

459 
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

460 
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

461 
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

462 
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

463 
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

464 
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

465 
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

466 
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

467 
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

468 
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

469 
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

470 
end 
4578  471 
end; 
503  472 

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

473 

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

474 
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

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

477 
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

478 
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

479 
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

480 
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

481 
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

482 
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

483 
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

484 
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

485 
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

486 
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

487 
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

488 
end 
4578  489 
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

490 
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

491 
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

492 
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

493 
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

494 
end; 
10015  495 
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

496 
(((Gear^.AdvBounce=1) and ((collV=1) or ((tdX.QWordValue + tdY.QWordValue) > _0_2.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

497 
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

498 
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

499 
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

500 
Gear^.dX := tdY*Gear^.Elasticity*Gear^.Friction; 
9767  501 
Gear^.dY := tdX*Gear^.Elasticity; 
502 
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

503 
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

504 
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

505 
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

506 
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

507 
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

508 
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

509 

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

510 
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

511 
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

512 
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

513 
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

514 
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

515 
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

516 
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

517 
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

518 
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

519 
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

520 
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

521 
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

522 
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

523 
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

524 
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

525 
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

526 
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

527 
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

528 
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

529 

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

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

531 
Gear^.AdvBounce := 10; 
4578  532 
end; 
503  533 

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

534 
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

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

536 

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

537 
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

538 
begin 
15596
3409433a236a
Fix many gears not being affected by gfMoreWind on turn end
Wuzzy <Wuzzy2@mail.ru>
parents:
15587
diff
changeset

539 
// Apply gravity and wind 
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

540 
Gear^.dY := Gear^.dY + cGravity; 
15596
3409433a236a
Fix many gears not being affected by gfMoreWind on turn end
Wuzzy <Wuzzy2@mail.ru>
parents:
15587
diff
changeset

541 
if ((GameFlags and gfMoreWind) <> 0) and 
3409433a236a
Fix many gears not being affected by gfMoreWind on turn end
Wuzzy <Wuzzy2@mail.ru>
parents:
15587
diff
changeset

542 
// Disable gfMoreWind for land objects on turn end to prevent bouncing them forever 
15597
6e72bd61002e
Disable gfMoreWind for land objects on turn end only after a fixedtime delay
Wuzzy <Wuzzy2@mail.ru>
parents:
15596
diff
changeset

543 
// This solution is rather ugly, in that it will occassionally suddenly wind physics 
6e72bd61002e
Disable gfMoreWind for land objects on turn end only after a fixedtime delay
Wuzzy <Wuzzy2@mail.ru>
parents:
15596
diff
changeset

544 
// while a gear is moving, this can be rather confusing. 
6e72bd61002e
Disable gfMoreWind for land objects on turn end only after a fixedtime delay
Wuzzy <Wuzzy2@mail.ru>
parents:
15596
diff
changeset

545 
// TODO: Find a way to make gfMoreWindaffected land objects settle more reliably 
6e72bd61002e
Disable gfMoreWind for land objects on turn end only after a fixedtime delay
Wuzzy <Wuzzy2@mail.ru>
parents:
15596
diff
changeset

546 
// and quickler without touching wind itselvs 
15640  547 
((not (Gear^.Kind in [gtMine, gtAirMine, gtSMine, gtKnife, gtExplosives, gtSentry])) or (TimeNotInTurn < MaxMoreWindTime)) then 
6580
6155187bf599
A partial reformatting of the pascal code to have consistent syntax. Things that are still inconsistent.
lovelacer
parents:
6556
diff
changeset

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

550 

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

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

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

553 
CheckGearDrowning(Gear); 
6498  554 
if (not isFalling) and ((Gear^.dX.QWordValue + Gear^.dY.QWordValue) < _0_02.QWordValue) then 
6450  555 
Gear^.State := Gear^.State and (not gstMoving) 
3454
a9bef74bd6e0
Code restlyling: experimental restyling of one module
mbait
parents:
3440
diff
changeset

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

557 
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

558 

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

559 
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

560 
Gear^.State := Gear^.State or gstCollision; 
10015  561 

14574
6e5cda26f676
Tweak bounce effects of some gears
Wuzzy <Wuzzy2@mail.ru>
parents:
14572
diff
changeset

562 
if ((xland or land) and lfBouncy <> 0) and 
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

563 
((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

564 
begin 
10508  565 
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

566 
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

567 
else if (Gear^.nImpactSounds > 0) and 
7777  568 
(Gear^.State and gstCollision <> 0) and 
569 
(((Gear^.Kind <> gtMine) and (Gear^.Damage <> 0)) or (Gear^.State and gstMoving <> 0)) and 

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

8795  571 
((Gear^.Radius >= 3) and 
7777  572 
((Gear^.dX.QWordValue > _0_1.QWordValue) or (Gear^.dY.QWordValue > _0_1.QWordValue)))) then 
15587  573 
PlaySound(TSound(ord(Gear^.ImpactSound) + LongInt(GetRandom(Gear^.nImpactSounds))), Gear^.Kind <> gtDynamite); 
4  574 
end; 
575 

576 
//////////////////////////////////////////////////////////////////////////////// 

577 
procedure doStepBomb(Gear: PGear); 

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

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

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

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

584 

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

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

586 

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

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

588 
if Gear^.Timer = 1000 then // might need adjustments 
8795  589 
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

590 
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

591 
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

592 
gtWatermelon, 
14011
3c40754f6cfe
Add Grenade taunt when grenade close to hog is about to blow up
Wuzzy <Wuzzy2@mail.ru>
parents:
14009
diff
changeset

593 
gtHellishBomb: makeHogsWorry(Gear^.X, Gear^.Y, Gear^.Boom, Gear^.Kind); 
3c40754f6cfe
Add Grenade taunt when grenade close to hog is about to blow up
Wuzzy <Wuzzy2@mail.ru>
parents:
14009
diff
changeset

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

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

596 

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

597 
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

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

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

600 
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

601 
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

602 
end; 
3004  603 

3475  604 
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

605 
begin 
3475  606 
vg:= AddVisualGear(hwRound(Gear^.X), hwRound(Gear^.Y), vgtSmokeWhite); 
607 
if vg <> nil then 

608 
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

609 
end; 
3475  610 

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

611 
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

612 
begin 
8795  613 
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

614 
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

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

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

618 
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

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

620 
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

621 
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

622 
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

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

624 
dX := rndSign(GetRandomf * _0_1) + gdX / 5; 
7001  625 
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

626 
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

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

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

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

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

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

633 
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

634 
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

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

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

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

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

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

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

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

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

646 
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

647 
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

648 

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

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

650 
begin 
7001  651 
dX := AngleCos(i * 16) * _0_5 * (GetRandomf + _1); 
652 
dY := AngleSin(i * 16) * _0_5 * (GetRandomf + _1); 

6131  653 
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

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

655 
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

656 
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

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

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

660 
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

661 
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

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

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

664 
end; 
3712  665 
gtGasBomb: 
666 
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

667 
doMakeExplosion(hwRound(Gear^.X), hwRound(Gear^.Y), Gear^.Boom, Gear^.Hedgehog, EXPLAutoSound); 
3712  668 
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

669 
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

670 
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

671 
y:= GetRandom(40); 
6120  672 
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

673 
end 
3712  674 
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

675 
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

676 
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

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

678 
end; 
6498  679 

680 
CalcRotationDirAngle(Gear); 

681 

682 
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

683 
begin 
6498  684 

685 
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

686 
begin 
6498  687 
Gear^.nImpactSounds := 0; 
688 
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

689 
end; 
6498  690 

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

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

693 
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

694 
end; 
4  695 
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

696 

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

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

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

701 
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

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

703 
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

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

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

706 

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

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

708 
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

709 

5870  710 
// 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

711 
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

712 
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

713 
begin 
5873  714 
// 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

715 
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

716 
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

717 
else i:= 50; 
8795  718 

5873  719 
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

720 
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

721 
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

722 
end; 
5870  723 

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

724 
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

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

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

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

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

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

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

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

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

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

736 
Tint:= $41B83ED0  i * $10081000; 
15051  737 
dX:= dX + hwFloat2Float(Gear^.dX) / 2; 
7066
12cc2bd84b0b
Make pas2c even more happier with uGears.c, allow assigning arrays in some cases
unc0rr
parents:
7062
diff
changeset

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

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

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

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

742 
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

743 
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

744 
begin 
7001  745 
dX := AngleCos(i * 2) * ((_0_15*(i div 5))) * (GetRandomf + _1); 
746 
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

747 
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

748 
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

749 
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

750 
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

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

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

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

754 
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

755 
end; 
4  756 

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

757 
//////////////////////////////////////////////////////////////////////////////// 
1279  758 

78  759 
procedure doStepCluster(Gear: PGear); 
760 
begin 

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

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

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

763 
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

764 
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

765 
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

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

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

768 
end; 
1262  769 

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

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

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

772 
else if (GameTicks and $1F) = 0 then 
10352  773 
AddVisualGear(hwRound(Gear^.X), hwRound(Gear^.Y), vgtSmokeTrace); 
78  774 
end; 
775 

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

779 
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

780 
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

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

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

783 
if (Gear^.State and gstCollision) <> 0 then 
4578  784 
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

785 
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

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

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

789 
if (GameTicks and $3F) = 0 then 
10352  790 
AddVisualGear(hwRound(Gear^.X), hwRound(Gear^.Y), vgtSmokeTrace); 
95  791 
end; 
792 

4  793 
//////////////////////////////////////////////////////////////////////////////// 
4578  794 
procedure doStepSnowball(Gear: PGear); 
795 
var kick, i: LongInt; 

796 
particle: PVisualGear; 

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

797 
gdX, gdY: hwFloat; 
4578  798 
begin 
799 
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

800 
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

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

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

803 
gdY := Gear^.dY; 
4578  804 
doStepFallingGear(Gear); 
805 
CalcRotationDirAngle(Gear); 

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

807 
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

808 
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

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

810 
Gear^.dY:= gdY; 
7621  811 
AmmoShove(Gear, 0, kick); 
4578  812 
for i:= 15 + kick div 10 downto 0 do 
813 
begin 

814 
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

815 
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

816 
particle^.dX := particle^.dX + (Gear^.dX.QWordValue / 21474836480) 
4578  817 
end; 
818 
DeleteGear(Gear); 

819 
exit 

820 
end; 

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

822 
begin 

4582  823 
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

824 
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

825 
particle^.dX := particle^.dX + (Gear^.dX.QWordValue / 21474836480) 
4578  826 
end 
827 
end; 

828 

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

829 
//////////////////////////////////////////////////////////////////////////////// 
4611  830 
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

831 
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

832 
move, draw, allpx, gun: Boolean; 
4611  833 
s: PSDL_Surface; 
834 
p: PLongwordArray; 

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

838 
gun:= (Gear^.State and gstTmpFlag) <> 0; 
5024  839 
move:= false; 
840 
draw:= false; 

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

841 
if gun then 
5024  842 
begin 
6450  843 
Gear^.State:= Gear^.State and (not gstInvisible); 
5024  844 
doStepFallingGear(Gear); 
845 
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

846 
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

847 
draw:= true; 
5024  848 
xx:= hwRound(Gear^.X); 
849 
yy:= hwRound(Gear^.Y); 

14282
6015b74eea55
overall, using LongInt for leftX/rightX results in fewer casts, since most comparisons are against ints.
nemo
parents:
14204
diff
changeset

850 
if draw and (WorldEdge = weWrap) and ((xx < leftX + 3) or (xx > rightX  3)) then 
6015b74eea55
overall, using LongInt for leftX/rightX results in fewer casts, since most comparisons are against ints.
nemo
parents:
14204
diff
changeset

851 
begin 
6015b74eea55
overall, using LongInt for leftX/rightX results in fewer casts, since most comparisons are against ints.
nemo
parents:
14204
diff
changeset

852 
if xx < leftX + 3 then 
9563  853 
xx:= rightX3 
854 
else xx:= leftX+3; 

855 
Gear^.X:= int2hwFloat(xx) 

856 
end 

5024  857 
end 
858 
else if GameTicks and $7 = 0 then 

4611  859 
begin 
860 
with Gear^ do 

861 
begin 

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

866 
yy:= hwRound(Y); 

867 
if vobVelocity <> 0 then 

868 
begin 

7649  869 
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

870 
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

871 
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

872 
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

873 
DirAngle := DirAngle  360; 
4611  874 
end; 
875 
// move back to cloud layer 

10354  876 
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

877 
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

878 
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

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

880 
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

881 
move:=true 
4791  882 
// 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

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

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

889 
begin 

890 
X:= X  cWindSpeed * 1600  dX; 

891 
end 

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

893 
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 

894 
begin 

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

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

897 
end 

898 
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 

899 
begin 

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

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

902 
end 

903 
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 

904 
begin 

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

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

907 
end 

908 
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 

909 
begin 

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

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

912 
end 

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

913 
// 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

914 
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

915 
then move:=true 
5024  916 
else draw:= true 
917 
end 

918 
end 

919 
end; 

6131  920 
if draw then 
5024  921 
with Gear^ do 
922 
begin 

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

924 
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

925 
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

926 
or (CurAmmoGear^.Kind <> gtRope)) then 
5024  927 
begin 
928 
////////////////////////////////// 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

929 
if not gun then 
5024  930 
begin 
931 
dec(yy,3); 

932 
dec(xx,1) 

933 
end; 

934 
s:= SpritesData[sprSnow].Surface; 

935 
p:= s^.pixels; 

936 
allpx:= true; 

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

938 
begin 

939 
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

940 
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

941 
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

942 
if (ly and LAND_HEIGHT_MASK = 0) and (lx and LAND_WIDTH_MASK = 0) and (Land[ly, lx] and $FF = 0) then 
5024  943 
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

944 
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

945 
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

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

947 
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

948 
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

949 
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

950 
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

951 
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

952 
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

953 
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

954 
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

955 
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

956 
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

957 
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

958 
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

959 
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

960 
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

961 
(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

962 
(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

963 
(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

964 
else LandPixels[ry, rx]:= addBgColor(LandPixels[ry, rx], p^[px]); 
5024  965 
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

966 
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

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

968 
p:= PLongWordArray(@(p^[s^.pitch shr 2])) 
5024  969 
end; 
8795  970 

971 
// 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

972 
//Land[py, px+1]:= lfBasic; 
8795  973 

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

974 
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

975 
UpdateLandTexture(xx, Pred(s^.h), yy, Pred(s^.w), true) 
4791  976 
else 
4611  977 
begin 
5024  978 
UpdateLandTexture( 
979 
max(0, min(LAND_WIDTH, xx)), 

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

981 
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

982 
min(LAND_HEIGHT  yy, Pred(s^.h)), false // could this be true without unnecessarily creating blanks? 
5024  983 
); 
4791  984 
end; 
5024  985 
////////////////////////////////// TODO  ASK UNC0RR FOR A GOOD HOME FOR THIS //////////////////////////////////// 
4611  986 
end 
5024  987 
end; 
988 

989 
if move then 

990 
begin 

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

991 
if gun then 
5024  992 
begin 
993 
DeleteGear(Gear); 

994 
exit 

995 
end; 

5695  996 
Gear^.Pos:= 0; 
7721  997 
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

998 
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

999 
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

1000 
else Gear^.Y:= int2hwFloat(LAND_HEIGHT + LongInt(GetRandom(50))  1250); 
5413  1001 
Gear^.State:= Gear^.State or gstInvisible; 
4611  1002 
end 
1003 
end; 

1004 

4578  1005 
//////////////////////////////////////////////////////////////////////////////// 
4  1006 
procedure doStepGrave(Gear: PGear); 
1007 
begin 

7394  1008 
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

1009 
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

1010 
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

1011 
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

1012 
end; 
7394  1013 

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

1014 
AllInactive := false; 
7394  1015 

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

1016 
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

1017 
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

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

1019 

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

1020 
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

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

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

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

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

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

1029 
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

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

1032 

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

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

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

1035 
Gear^.dY := Gear^.dY + cGravity 
4  1036 
end; 
1037 

1038 
//////////////////////////////////////////////////////////////////////////////// 

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

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

1042 
gX,gY,i: LongInt; 
14514
5ac181cb2396
Fix bee targeting fail across wrap world edge
Wuzzy <Wuzzy2@mail.ru>
parents:
14398
diff
changeset

1043 
uw, nuw, wrapped: boolean; 
5748
70d7f8e40f53
Just for fun. Flowers! Also, use a less blatant image in ammo menu.
nemo
parents:
5738
diff
changeset

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

1045 

4  1046 
begin 
14514
5ac181cb2396
Fix bee targeting fail across wrap world edge
Wuzzy <Wuzzy2@mail.ru>
parents:
14398
diff
changeset

1047 
wrapped:= WorldWrap(Gear); 
5ac181cb2396
Fix bee targeting fail across wrap world edge
Wuzzy <Wuzzy2@mail.ru>
parents:
14398
diff
changeset

1048 
if wrapped then 
5ac181cb2396
Fix bee targeting fail across wrap world edge
Wuzzy <Wuzzy2@mail.ru>
parents:
14398
diff
changeset

1049 
HomingWrap(Gear); 
5ac181cb2396
Fix bee targeting fail across wrap world edge
Wuzzy <Wuzzy2@mail.ru>
parents:
14398
diff
changeset

1050 

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

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

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

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

1057 
// if water entered or left 

1058 
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

1059 
begin 
10363  1060 
if Gear^.Timer <> 5000 then 
1061 
AddSplashForGear(Gear, false); 

7053  1062 
StopSoundChan(Gear^.SoundChannel); 
6251  1063 
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

1064 
begin 
6251  1065 
Gear^.SoundChannel := LoopSound(sndBeeWater); 
1066 
Gear^.Tag := 1; 

1067 
end 

1068 
else 

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

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

1070 
Gear^.SoundChannel := LoopSound(sndBee); 
6251  1071 
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

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

1073 
end; 
6251  1074 

1075 

1076 
if Gear^.Timer = 0 then 

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

1077 
begin 
13593
083733ec7941
Add support for infinite fly time of jetpack and Birdy
Wuzzy <Wuzzy2@mail.ru>
parents:
13572
diff
changeset

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

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

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

1081 
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

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

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

1085 
begin 
11475  1086 
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

1087 
begin 
11475  1088 
if (Gear^.Timer and $3F) = 0 then 
10352  1089 
AddVisualGear(gX, gY, vgtBeeTrace); 
1090 

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

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

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

1096 
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

1097 
end; 
6251  1098 

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

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

1101 

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

1102 
end; 
3591  1103 

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

1104 

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

1105 
CheckCollision(Gear); 
6251  1106 
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

1107 
begin 
7053  1108 
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

1109 
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

1110 
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

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

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

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

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

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

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

1118 
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

1119 
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

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

1121 
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

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

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

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

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

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

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

1129 
end; 
6251  1130 

1131 
if (Gear^.Timer > 0) then 

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

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

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

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

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

1136 
// 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

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

1138 
// bee can drown when timer reached 0 
9954  1139 
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

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

1141 
end; 
4  1142 
end; 
1143 

3080  1144 
procedure doStepBee(Gear: PGear); 
15204
f55c1c895797
Bee: Call HomingWrap in prehoming phase, too
Wuzzy <Wuzzy2@mail.ru>
parents:
15196
diff
changeset

1145 
var wrapped: boolean; 
4  1146 
begin 
3454
a9bef74bd6e0
Code restlyling: experimental restyling of one module
mbait
parents:
3440
diff
changeset

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

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

1149 
Gear^.Y := Gear^.Y + Gear^.dY; 
15204
f55c1c895797
Bee: Call HomingWrap in prehoming phase, too
Wuzzy <Wuzzy2@mail.ru>
parents:
15196
diff
changeset

1150 
wrapped:= WorldWrap(Gear); 
f55c1c895797
Bee: Call HomingWrap in prehoming phase, too
Wuzzy <Wuzzy2@mail.ru>
parents:
15196
diff
changeset

1151 
if wrapped then 
f55c1c895797
Bee: Call HomingWrap in prehoming phase, too
Wuzzy <Wuzzy2@mail.ru>
parents:
15196
diff
changeset

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

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

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

1156 
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

1157 
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

1158 
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

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

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

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

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

1163 
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

1164 
begin 
6450  1165 
Gear^.Hedgehog^.Gear^.Message:= Gear^.Hedgehog^.Gear^.Message and (not gmAttack); 
1166 
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

1167 
AttackBar:= 0; 
8795  1168 

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

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

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

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

1173 
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

1174 
end; 
4  1175 
end; 
1176 

1177 
//////////////////////////////////////////////////////////////////////////////// 

876  1178 
procedure doStepShotIdle(Gear: PGear); 
1179 
begin 

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

1180 
AllInactive := false; 
13152  1181 
if (Gear^.Kind <> gtMinigunBullet) then 
1182 
begin 

1183 
inc(Gear^.Timer); 

1184 
if Gear^.Timer > 75 then 

1185 
begin 

1186 
DeleteGear(Gear); 

1187 
AfterAttack 

1188 
end 

1189 
end 

1190 
else 

14556  1191 
DeleteGear(Gear); 
876  1192 
end; 
1193 

13147
7040506c831f
Fix direction of dispensed bullet shells from shotgun/sniper/minigun
alfadur
parents:
13140
diff
changeset

1194 
procedure CreateShellForGear(Gear: PGear; startFrame: Longword); 
7040506c831f
Fix direction of dispensed bullet shells from shotgun/sniper/minigun
alfadur
parents:
13140
diff
changeset

1195 
var 
7040506c831f
Fix direction of dispensed bullet shells from shotgun/sniper/minigun
alfadur
parents:
13140
diff
changeset

1196 
shell: PVisualGear; 
7040506c831f
Fix direction of dispensed bullet shells from shotgun/sniper/minigun
alfadur
parents:
13140
diff
changeset

1197 
begin 
7040506c831f
Fix direction of dispensed bullet shells from shotgun/sniper/minigun
alfadur
parents:
13140
diff
changeset

1198 
shell := AddVisualGear(hwRound(Gear^.x), hwRound(Gear^.y), vgtShell); 
7040506c831f
Fix direction of dispensed bullet shells from shotgun/sniper/minigun
alfadur
parents:
13140
diff
changeset

1199 
if shell <> nil then 
7040506c831f
Fix direction of dispensed bullet shells from shotgun/sniper/minigun
alfadur
parents:
13140
diff
changeset

1200 
begin 
7040506c831f
Fix direction of dispensed bullet shells from shotgun/sniper/minigun
alfadur
parents:
13140
diff
changeset

1201 
shell^.dX := gear^.dX.QWordValue / 17179869184; 
7040506c831f
Fix direction of dispensed bullet shells from shotgun/sniper/minigun
alfadur
parents:
13140
diff
changeset

1202 
if (gear^.dX.isNegative) then 
7040506c831f
Fix direction of dispensed bullet shells from shotgun/sniper/minigun
alfadur
parents:
13140
diff
changeset

1203 
shell^.dX := shell^.dX; 
7040506c831f
Fix direction of dispensed bullet shells from shotgun/sniper/minigun
alfadur
parents:
13140
diff
changeset

1204 
shell^.dY := gear^.dY.QWordValue / 17179869184; 
7040506c831f
Fix direction of dispensed bullet shells from shotgun/sniper/minigun
alfadur
parents:
13140
diff
changeset

1205 
shell^.Frame := startFrame; 
7040506c831f
Fix direction of dispensed bullet shells from shotgun/sniper/minigun
alfadur
parents:
13140
diff
changeset

1206 
end; 
7040506c831f
Fix direction of dispensed bullet shells from shotgun/sniper/minigun
alfadur
parents:
13140
diff
changeset

1207 
end; 
7040506c831f
Fix direction of dispensed bullet shells from shotgun/sniper/minigun
alfadur
parents:
13140
diff
changeset

1208 

13407
06792533ef91
ensure shotgun works with portals and make it hit airmines
alfadur
parents:
13406
diff
changeset

1209 
function ShotgunLineHitHelp(Gear: PGear; oX, oY, tX, tY: hwFloat): Boolean; 
06792533ef91
ensure shotgun works with portals and make it hit airmines
alfadur
parents:
13406
diff
changeset

1210 
var i: LongInt; 
06792533ef91
ensure shotgun works with portals and make it hit airmines
alfadur
parents:
13406
diff
changeset

1211 
Collisions: PGearArray; 
06792533ef91
ensure shotgun works with portals and make it hit airmines
alfadur
parents:
13406
diff
changeset

1212 
begin 
06792533ef91
ensure shotgun works with portals and make it hit airmines
alfadur
parents:
13406
diff
changeset

1213 
ShotgunLineHitHelp := false; 
06792533ef91
ensure shotgun works with portals and make it hit airmines
alfadur
parents:
13406
diff
changeset

1214 
Collisions := CheckAllGearsLineCollision(Gear, oX, oY, tX, tY); 
06792533ef91
ensure shotgun works with portals and make it hit airmines
alfadur
parents:
13406
diff
changeset

1215 
i := Collisions^.Count; 
06792533ef91
ensure shotgun works with portals and make it hit airmines
alfadur
parents:
13406
diff
changeset

1216 
while i > 0 do 
06792533ef91
ensure shotgun works with portals and make it hit airmines
alfadur
parents:
13406
diff
changeset

1217 
begin 
06792533ef91
ensure shotgun works with portals and make it hit airmines
alfadur
parents:
13406
diff
changeset

1218 
dec(i); 
06792533ef91
ensure shotgun works with portals and make it hit airmines
alfadur
parents:
13406
diff
changeset

1219 
if Collisions^.ar[i]^.Kind in 
15710  1220 
[gtMine, gtSMine, gtAirMine, gtKnife, gtCase, gtTarget, gtExplosives, gtSentry] then 
13407
06792533ef91
ensure shotgun works with portals and make it hit airmines
alfadur
parents:
13406
diff
changeset

1221 
begin 
06792533ef91
ensure shotgun works with portals and make it hit airmines
alfadur
parents:
13406
diff
changeset

1222 
Gear^.X := Collisions^.ar[i]^.X; 
06792533ef91
ensure shotgun works with portals and make it hit airmines
alfadur
parents:
13406
diff
changeset

1223 
Gear^.Y := Collisions^.ar[i]^.Y; 
06792533ef91
ensure shotgun works with portals and make it hit airmines
alfadur
parents:
13406
diff
changeset

1224 
ShotgunShot(Gear); 
06792533ef91
ensure shotgun works with portals and make it hit airmines
alfadur
parents:
13406
diff
changeset

1225 
Gear^.doStep := @doStepShotIdle; 
06792533ef91
ensure shotgun works with portals and make it hit airmines
alfadur
parents:
13406
diff
changeset

1226 
ShotgunLineHitHelp := true; 
06792533ef91
ensure shotgun works with portals and make it hit airmines
alfadur
parents:
13406
diff
changeset

1227 
exit; 
06792533ef91
ensure shotgun works with portals and make it hit airmines
alfadur
parents:
13406
diff
changeset

1228 
end; 
06792533ef91
ensure shotgun works with portals and make it hit airmines
alfadur
parents:
13406
diff
changeset

1229 
end; 
06792533ef91
ensure shotgun works with portals and make it hit airmines
alfadur
parents:
13406
diff
changeset

1230 
end; 
06792533ef91
ensure shotgun works with portals and make it hit airmines
alfadur
parents:
13406
diff
changeset

1231 

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

1234 
i: LongWord; 
13407
06792533ef91
ensure shotgun works with portals and make it hit airmines
alfadur
parents:
13406
diff
changeset

1235 
oX, oY, tmpX, tmpY: hwFloat; 
4  1236 
begin 
3454
a9bef74bd6e0
Code restlyling: experimental restyling of one module
mbait
parents:
3440
diff
changeset

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

1238 

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

1239 
if ((Gear^.State and gstAnimation) = 0) then 
15723  1240 
begin 
3454
a9bef74bd6e0
Code restlyling: experimental restyling of one module
mbait
parents:
3440
diff
changeset

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

1242 
if Gear^.Timer = 0 then 
15723  1243 
begin 
3454
a9bef74bd6e0
Code restlyling: experimental restyling of one module
mbait
parents:
3440
diff
changeset

1244 
PlaySound(sndShotgunFire); 
13147
7040506c831f
Fix direction of dispensed bullet shells from shotgun/sniper/minigun
alfadur
parents:
13140
diff
changeset

1245 
CreateShellForGear(Gear, 0); 
3454
a9bef74bd6e0
Code restlyling: experimental restyling of one module
mbait
parents:
3440
diff
changeset

1246 
Gear^.State := Gear^.State or gstAnimation 
15723  1247 
end 
1248 
else if (Gear^.Hedgehog^.Gear = nil) 

1249 
or ((Gear^.Hedgehog^.Gear^.State and (gstMoving or gstHHDriven)) = gstMoving) then 

1250 
begin 

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

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

1252 
AfterAttack; 
15723  1253 
end; 
1254 
exit 

1255 
end 

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

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

1257 
inc(Gear^.Timer); 
6155187bf599
A partial reformatting of the pascal code to have consistent syntax. Things that are still inconsistent.
lo 