author  unc0rr 
Sat, 15 Jun 2013 23:45:53 +0400  
branch  webgl 
changeset 9166  3774ac58e65e 
parent 9160  fc46e75f6b72 
child 9168  20ff80421736 
permissions  rwrr 
4  1 
(* 
1066  2 
* Hedgewars, a free turn based strategy game 
9080  3 
* Copyright (c) 20042013 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 

16 
* Foundation, Inc., 59 Temple Place  Suite 330, Boston, MA 021111307, 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 
*) 
2d34ec60992c
added some comments in order to confuse the GSoC students as much as possible ;D
sheepluva
parents:
5076
diff
changeset

27 

3569  28 
procedure doStepPerPixel(Gear: PGear; step: TGearStepProcedure; onlyCheckIfChanged: boolean); 
29 
var 

30 
dX, dY, sX, sY: hwFloat; 

31 
i, steps: LongWord; 

32 
caller: TGearStepProcedure; 

33 
begin 

34 
dX:= Gear^.dX; 

35 
dY:= Gear^.dY; 

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

37 

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

39 
if steps < 1 then 

4578  40 
begin 
3569  41 
if onlyCheckIfChanged then 
4578  42 
begin 
3569  43 
Gear^.X := Gear^.X + dX; 
44 
Gear^.Y := Gear^.Y + dY; 

45 
EXIT; 

4578  46 
end 
3569  47 
else 
48 
steps := 1; 

4578  49 
end; 
3569  50 

51 
if steps > 1 then 

4578  52 
begin 
3569  53 
sX:= dX / steps; 
54 
sY:= dY / steps; 

4578  55 
end 
8795  56 

3569  57 
else 
4578  58 
begin 
3569  59 
sX:= dX; 
60 
sY:= dY; 

4578  61 
end; 
3569  62 

63 
caller:= Gear^.doStep; 

64 

65 
for i:= 1 to steps do 

4578  66 
begin 
3569  67 
Gear^.X := Gear^.X + sX; 
68 
Gear^.Y := Gear^.Y + sY; 

69 
step(Gear); 

70 
if (Gear^.doStep <> caller) 

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

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

73 
break; 

4578  74 
end; 
3569  75 
end; 
76 

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

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

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

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

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

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

87 
d := r  hwRound(Distance(gi^.X  x, gi^.Y  y)); 
6450  88 
if (d > 1) and (not gi^.Invulnerable) and (GetRandom(2) = 0) then 
4578  89 
begin 
3143  90 
if (CurrentHedgehog^.Gear = gi) then 
7053  91 
PlaySoundV(sndOops, gi^.Hedgehog^.Team^.voicepack) 
8795  92 

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

93 
else 
4578  94 
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

95 
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

96 
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

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

98 
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

99 
end; 
8795  100 

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

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

107 
end; 
8795  108 

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

110 
end; 
2647  111 
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

112 

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

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

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

115 
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

116 
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

117 
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

118 
FollowGear:= nil; 
8795  119 

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

120 
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

121 
lastGearByUID := nil; 
8795  122 

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

123 
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

124 
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

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

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

127 
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

128 
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

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

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

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

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

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

134 

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

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

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

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

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

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

140 
HH^.Gear^.State:= (HH^.Gear^.State and (not (gstHHDriven or gstInvisible 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

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

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

143 
ScriptCall('onHogRestore', HH^.Gear^.Uid) 
5807
5c8fe58dead5
Define 2 script callbacks to notify of hog vanishment
nemo
parents:
5806
diff
changeset

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

145 

4  146 

147 
//////////////////////////////////////////////////////////////////////////////// 

148 
procedure doStepDrowningGear(Gear: PGear); 

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

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

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

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

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

153 
// Create some bubbles (0.5% might be better but causes too few bubbles sometimes) 
8105  154 
if (((not SuddenDeathDmg) and (WaterOpacity < $FF)) 
6982  155 
or (SuddenDeathDmg and (SDWaterOpacity < $FF))) and ((GameTicks and $1F) = 0) then 
3454
a9bef74bd6e0
Code restlyling: experimental restyling of one module
mbait
parents:
3440
diff
changeset

156 
if (Gear^.Kind = gtHedgehog) and (Random(4) = 0) then 
5494
5f55e9202122
Fix crasher. thanks to dagni for the demo file that tracked it down.
nemo
parents:
5480
diff
changeset

157 
AddVisualGear(hwRound(Gear^.X)  Gear^.Radius, hwRound(Gear^.Y)  Gear^.Radius, vgtBubble) 
2225  158 
else if Random(12) = 0 then 
5494
5f55e9202122
Fix crasher. thanks to dagni for the demo file that tracked it down.
nemo
parents:
5480
diff
changeset

159 
AddVisualGear(hwRound(Gear^.X)  Gear^.Radius, hwRound(Gear^.Y)  Gear^.Radius, vgtBubble); 
8105  160 
if ((not SuddenDeathDmg) and (WaterOpacity > $FE)) 
6982  161 
or (SuddenDeathDmg and (SDWaterOpacity > $FE)) 
6580
6155187bf599
A partial reformatting of the pascal code to have consistent syntax. Things that are still inconsistent.
lovelacer
parents:
6556
diff
changeset

162 
or (hwRound(Gear^.Y) > Gear^.Radius + cWaterLine + cVisibleWater) then 
5494
5f55e9202122
Fix crasher. thanks to dagni for the demo file that tracked it down.
nemo
parents:
5480
diff
changeset

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

164 
end; 
4  165 

166 
//////////////////////////////////////////////////////////////////////////////// 

167 
procedure doStepFallingGear(Gear: PGear); 

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

169 
isFalling: boolean; 
3020  170 
//tmp: QWord; 
2998
5b74906c14bb
Slightly better behaved bounce, assuming we can make this 45 deg thing work, calcs could stand some optimisation.
nemo
parents:
2995
diff
changeset

171 
tdX, tdY: hwFloat; 
3001  172 
collV, collH: LongInt; 
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

173 
land: word; 
4  174 
begin 
7627  175 
// clip velocity at 2  over 1 per pixel, but really shouldn't cause many actual problems. 
8026
4a4f21070479
merge xymeng's gsoc engine with a few updates (and further checks on symbol definitions)
koda
parents:
8003
diff
changeset

176 
{$IFNDEF WEBGL} 
7627  177 
if Gear^.dX.Round > 2 then 
178 
Gear^.dX.QWordValue:= 8589934592; 

179 
if Gear^.dY.Round > 2 then 

180 
Gear^.dY.QWordValue:= 8589934592; 

181 
{$ELSE} 

182 
if Gear^.dX.Round > 2 then 

183 
begin 

184 
Gear^.dX.Round:= 2; 

185 
Gear^.dX.Frac:= 0 

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

186 
end; 
7627  187 
if Gear^.dY.QWordValue > 2 then 
188 
begin 

189 
Gear^.dY.Round:= 2; 

190 
Gear^.dY.Frac:= 0 

191 
end; 

192 
{$ENDIF} 

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

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

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

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

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

198 

503  199 

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

200 

3359  201 
// might need some testing/adjustments  just to avoid projectiles to fly forever (accelerated by wind/skips) 
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

202 
if (hwRound(Gear^.X) < min(LAND_WIDTH div 2, 2048)) 
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

203 
or (hwRound(Gear^.X) > max(LAND_WIDTH * 3 div 2, 6144)) then 
6580
6155187bf599
A partial reformatting of the pascal code to have consistent syntax. Things that are still inconsistent.
lovelacer
parents:
6556
diff
changeset

204 
Gear^.State := Gear^.State or gstCollision; 
3359  205 

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

206 
if Gear^.dY.isNegative then 
4578  207 
begin 
3454
a9bef74bd6e0
Code restlyling: experimental restyling of one module
mbait
parents:
3440
diff
changeset

208 
isFalling := true; 
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

209 
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

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

212 
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

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

214 
Gear^.dX := Gear^.dX * (_0_9 + Gear^.Friction * _0_1) 
6155187bf599
A partial reformatting of the pascal code to have consistent syntax. Things that are still inconsistent.
lovelacer
parents:
6556
diff
changeset

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

216 
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

217 

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

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

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

221 
else if (Gear^.AdvBounce=1) and (TestCollisionYwithGear(Gear, 1) <> 0) then 
6155187bf599
A partial reformatting of the pascal code to have consistent syntax. Things that are still inconsistent.
lovelacer
parents:
6556
diff
changeset

222 
collV := 1; 
4578  223 
end 
8795  224 
else 
6498  225 
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

226 
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

227 
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

228 
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

229 
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

230 
isFalling := false; 
8795  231 
if land and lfIce <> 0 then 
6498  232 
Gear^.dX := Gear^.dX * (_0_9 + Gear^.Friction * _0_1) 
8795  233 
else 
6498  234 
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

235 

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

236 
Gear^.dY :=  Gear^.dY * Gear^.Elasticity; 
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

237 
Gear^.State := Gear^.State or gstCollision 
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

238 
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

239 
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

240 
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

241 
isFalling := true; 
6498  242 
if (Gear^.AdvBounce=1) and (TestCollisionYwithGear(Gear, 1) <> 0) then 
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

243 
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

244 
end 
4578  245 
end; 
503  246 

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

247 

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

248 
if TestCollisionXwithGear(Gear, hwSign(Gear^.dX)) then 
4578  249 
begin 
3454
a9bef74bd6e0
Code restlyling: experimental restyling of one module
mbait
parents:
3440
diff
changeset

250 
collH := hwSign(Gear^.dX); 
a9bef74bd6e0
Code restlyling: experimental restyling of one module
mbait
parents:
3440
diff
changeset

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

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

253 
Gear^.State := Gear^.State or gstCollision 
4578  254 
end 
6131  255 
else if (Gear^.AdvBounce=1) and TestCollisionXwithGear(Gear, hwSign(Gear^.dX)) then 
8795  256 
collH := hwSign(Gear^.dX); 
3454
a9bef74bd6e0
Code restlyling: experimental restyling of one module
mbait
parents:
3440
diff
changeset

257 
//if Gear^.AdvBounce and (collV <>0) and (collH <> 0) and (hwSqr(tdX) + hwSqr(tdY) > _0_08) then 
6580
6155187bf599
A partial reformatting of the pascal code to have consistent syntax. Things that are still inconsistent.
lovelacer
parents:
6556
diff
changeset

258 
if (Gear^.AdvBounce=1) and (collV <>0) and (collH <> 0) and ((collV=1) 
6155187bf599
A partial reformatting of the pascal code to have consistent syntax. Things that are still inconsistent.
lovelacer
parents:
6556
diff
changeset

259 
or ((tdX.QWordValue + tdY.QWordValue) > _0_2.QWordValue)) then 
4578  260 
begin 
3454
a9bef74bd6e0
Code restlyling: experimental restyling of one module
mbait
parents:
3440
diff
changeset

261 
Gear^.dX := tdY*Gear^.Elasticity*Gear^.Friction; 
a9bef74bd6e0
Code restlyling: experimental restyling of one module
mbait
parents:
3440
diff
changeset

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

263 
//*Gear^.Friction; 
8105  264 
Gear^.dY.isNegative := (not tdY.isNegative); 
3454
a9bef74bd6e0
Code restlyling: experimental restyling of one module
mbait
parents:
3440
diff
changeset

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

266 
Gear^.AdvBounce := 10; 
4578  267 
end; 
503  268 

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

269 
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

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

271 

6131  272 
if isFalling then 
4299  273 
begin 
274 
Gear^.dY := Gear^.dY + cGravity; 

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

275 
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

276 
Gear^.dX := Gear^.dX + cWindSpeed / Gear^.Density 
6155187bf599
A partial reformatting of the pascal code to have consistent syntax. Things that are still inconsistent.
lovelacer
parents:
6556
diff
changeset

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

278 

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

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

280 
Gear^.Y := Gear^.Y + Gear^.dY; 
6251  281 
if Gear^.Kind <> gtBee then 
282 
CheckGearDrowning(Gear); 

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

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

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

287 
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

288 

8795  289 
if (Gear^.nImpactSounds > 0) and 
7777  290 
(Gear^.State and gstCollision <> 0) and 
291 
(((Gear^.Kind <> gtMine) and (Gear^.Damage <> 0)) or (Gear^.State and gstMoving <> 0)) and 

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

8795  293 
((Gear^.Radius >= 3) and 
7777  294 
((Gear^.dX.QWordValue > _0_1.QWordValue) or (Gear^.dY.QWordValue > _0_1.QWordValue)))) then 
5461  295 
PlaySound(TSound(ord(Gear^.ImpactSound) + LongInt(GetRandom(Gear^.nImpactSounds))), true); 
4  296 
end; 
297 

298 
//////////////////////////////////////////////////////////////////////////////// 

299 
procedure doStepBomb(Gear: PGear); 

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

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

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

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

306 

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

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

308 

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

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

310 
if Gear^.Timer = 1000 then // might need adjustments 
8795  311 
case Gear^.Kind of 
5139
090a8b8d1083
grenade back to old damage, but from now on explosions assume they are not closer to a gear's center than the gear's radius
sheepluva
parents:
5137
diff
changeset

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

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

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

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

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

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

318 

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

319 
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

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

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

322 
if (Gear^.State and gstCollision) <> 0 then 
4837
2ea0a152c319
Pass PHedgehog instead of PGear to stats. Fixes crash.
unc0rr
parents:
4824
diff
changeset

323 
doMakeExplosion(hwRound(Gear^.X), hwRound(Gear^.Y), 20, 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

324 
end; 
3004  325 

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

327 
begin 
3475  328 
vg:= AddVisualGear(hwRound(Gear^.X), hwRound(Gear^.Y), vgtSmokeWhite); 
329 
if vg <> nil then 

330 
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

331 
end; 
3475  332 

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

333 
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

334 
begin 
8795  335 
case Gear^.Kind of 
5139
090a8b8d1083
grenade back to old damage, but from now on explosions assume they are not closer to a gear's center than the gear's radius
sheepluva
parents:
5137
diff
changeset

336 
gtGrenade: doMakeExplosion(hwRound(Gear^.X), hwRound(Gear^.Y), 50, Gear^.Hedgehog, EXPLAutoSound); 
4837
2ea0a152c319
Pass PHedgehog instead of PGear to stats. Fixes crash.
unc0rr
parents:
4824
diff
changeset

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

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

340 
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

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

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

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

344 
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

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

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

348 
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

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

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

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

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

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

355 
gdX:= Gear^.dX; 
4837
2ea0a152c319
Pass PHedgehog instead of PGear to stats. Fixes crash.
unc0rr
parents:
4824
diff
changeset

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

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

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

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

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

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

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

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

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

368 
y := hwRound(Gear^.Y); 
4837
2ea0a152c319
Pass PHedgehog instead of PGear to stats. Fixes crash.
unc0rr
parents:
4824
diff
changeset

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

370 

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

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

372 
begin 
7001  373 
dX := AngleCos(i * 16) * _0_5 * (GetRandomf + _1); 
374 
dY := AngleSin(i * 16) * _0_5 * (GetRandomf + _1); 

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

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

377 
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

378 
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

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

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

382 
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

383 
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

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

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

386 
end; 
3712  387 
gtGasBomb: 
388 
begin 

4837
2ea0a152c319
Pass PHedgehog instead of PGear to stats. Fixes crash.
unc0rr
parents:
4824
diff
changeset

389 
doMakeExplosion(hwRound(Gear^.X), hwRound(Gear^.Y), 20, Gear^.Hedgehog, EXPLAutoSound); 
3712  390 
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

391 
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

392 
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

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

395 
end 
3712  396 
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

397 
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

398 
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

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

400 
end; 
6498  401 

402 
CalcRotationDirAngle(Gear); 

403 

404 
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

405 
begin 
6498  406 

407 
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

408 
begin 
6498  409 
Gear^.nImpactSounds := 0; 
410 
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

411 
end; 
6498  412 

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

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

415 
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

416 
end; 
4  417 
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

418 

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

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

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

423 
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

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

425 
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

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

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

428 

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

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

430 
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

431 

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

433 
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

434 
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

435 
begin 
5873  436 
// 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

437 
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

438 
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

439 
else i:= 50; 
8795  440 

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

442 
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

443 
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

444 
end; 
5870  445 

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

446 
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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

470 
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

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

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

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

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

475 
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

476 
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

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

480 
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

481 
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

482 
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

483 
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

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

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

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

487 
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

488 
end; 
4  489 

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

490 
//////////////////////////////////////////////////////////////////////////////// 
1279  491 

78  492 
procedure doStepCluster(Gear: PGear); 
493 
begin 

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

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

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

496 
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

497 
begin 
4837
2ea0a152c319
Pass PHedgehog instead of PGear to stats. Fixes crash.
unc0rr
parents:
4824
diff
changeset

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

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

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

501 
end; 
1262  502 

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

503 
if (Gear^.Kind = gtMelonPiece) 
6155187bf599
A partial reformatting of the pascal code to have consistent syntax. Things that are still inconsistent.
lovelacer
parents:
6556
diff
changeset

504 
or (Gear^.Kind = gtBall) then 
3454
a9bef74bd6e0
Code restlyling: experimental restyling of one module
mbait
parents:
3440
diff
changeset

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

506 
else if (GameTicks and $1F) = 0 then 
8993  507 
begin 
508 
if hwRound(Gear^.Y) > cWaterLine then 

509 
AddVisualGear(hwRound(Gear^.X), hwRound(Gear^.Y), vgtBubble) 

510 
else AddVisualGear(hwRound(Gear^.X), hwRound(Gear^.Y), vgtSmokeTrace) 

511 
end 

78  512 
end; 
513 

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

517 
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

518 
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

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

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

521 
if (Gear^.State and gstCollision) <> 0 then 
4578  522 
begin 
4837
2ea0a152c319
Pass PHedgehog instead of PGear to stats. Fixes crash.
unc0rr
parents:
4824
diff
changeset

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

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

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

527 
if (GameTicks and $3F) = 0 then 
8993  528 
begin 
529 
if hwRound(Gear^.Y) > cWaterLine then 

530 
AddVisualGear(hwRound(Gear^.X), hwRound(Gear^.Y), vgtBubble) 

531 
else AddVisualGear(hwRound(Gear^.X), hwRound(Gear^.Y), vgtSmokeTrace) 

532 
end 

95  533 
end; 
534 

4  535 
//////////////////////////////////////////////////////////////////////////////// 
4578  536 
procedure doStepSnowball(Gear: PGear); 
537 
var kick, i: LongInt; 

538 
particle: PVisualGear; 

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

539 
gdX, gdY: hwFloat; 
4578  540 
begin 
541 
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

542 
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

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

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

545 
gdY := Gear^.dY; 
4578  546 
doStepFallingGear(Gear); 
547 
CalcRotationDirAngle(Gear); 

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

549 
begin 

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

550 
kick:= hwRound((hwAbs(gdX)+hwAbs(gdY)) * _20); 
145bf64a9579
this should improve consistency of mortar cluster spread and snowball knocks
nemo
parents:
8934
diff
changeset

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

552 
Gear^.dY:= gdY; 
7621  553 
AmmoShove(Gear, 0, kick); 
4578  554 
for i:= 15 + kick div 10 downto 0 do 
555 
begin 

556 
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

557 
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

558 
particle^.dX := particle^.dX + (Gear^.dX.QWordValue / 21474836480) 
4578  559 
end; 
560 
DeleteGear(Gear); 

561 
exit 

562 
end; 

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

564 
begin 

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

566 
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

567 
particle^.dX := particle^.dX + (Gear^.dX.QWordValue / 21474836480) 
4578  568 
end 
569 
end; 

570 

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

571 
//////////////////////////////////////////////////////////////////////////////// 
4611  572 
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

573 
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

574 
move, draw, allpx, gun: Boolean; 
4611  575 
s: PSDL_Surface; 
576 
p: PLongwordArray; 

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

580 
gun:= (Gear^.State and gstTmpFlag) <> 0; 
5024  581 
move:= false; 
582 
draw:= false; 

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

583 
if gun then 
5024  584 
begin 
6450  585 
Gear^.State:= Gear^.State and (not gstInvisible); 
5024  586 
doStepFallingGear(Gear); 
587 
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

588 
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

589 
draw:= true; 
5024  590 
xx:= hwRound(Gear^.X); 
591 
yy:= hwRound(Gear^.Y); 

592 
end 

593 
else if GameTicks and $7 = 0 then 

4611  594 
begin 
595 
with Gear^ do 

596 
begin 

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

601 
yy:= hwRound(Y); 

602 
if vobVelocity <> 0 then 

603 
begin 

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

605 
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

606 
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

607 
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

608 
DirAngle := DirAngle  360; 
4611  609 
end; 
7649  610 
(* 
611 
We aren't using frametick right now, so just a waste of cycles. 

4611  612 
inc(Health, 8); 
5186  613 
if longword(Health) > vobFrameTicks then 
4611  614 
begin 
615 
dec(Health, vobFrameTicks); 

616 
inc(Timer); 

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

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

618 
Timer:= 0 
4611  619 
end; 
7649  620 
*) 
4611  621 
// move back to cloud layer 
6580
6155187bf599
A partial reformatting of the pascal code to have consistent syntax. Things that are still inconsistent.
lovelacer
parents:
6556
diff
changeset

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

623 
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

624 
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

625 
move:=true 
4791  626 
// 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

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

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

633 
begin 

634 
X:= X  cWindSpeed * 1600  dX; 

635 
end 

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

637 
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 

638 
begin 

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

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

641 
end 

642 
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 

643 
begin 

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

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

646 
end 

647 
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 

648 
begin 

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

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

651 
end 

652 
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 

653 
begin 

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

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

656 
end 

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

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

658 
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

659 
then move:=true 
5024  660 
else draw:= true 
661 
end 

662 
end 

663 
end; 

6131  664 
if draw then 
5024  665 
with Gear^ do 
666 
begin 

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

668 
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

669 
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

670 
or (CurAmmoGear^.Kind <> gtRope)) then 
5024  671 
begin 
672 
////////////////////////////////// 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

673 
if not gun then 
5024  674 
begin 
675 
dec(yy,3); 

676 
dec(xx,1) 

677 
end; 

678 
s:= SpritesData[sprSnow].Surface; 

679 
p:= s^.pixels; 

680 
allpx:= true; 

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

682 
begin 

683 
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

684 
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

685 
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

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

688 
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

689 
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

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

691 
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

692 
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

693 
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

694 
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

695 
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

696 
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

697 
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

698 
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

699 
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

700 
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

701 
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

702 
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

703 
if gun then 
6982  704 
LandPixels[ry, rx]:= (ExplosionBorderColor and (not AMask)) or (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

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

707 
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

708 
end; 
5024  709 
p:= @(p^[s^.pitch shr 2]) 
710 
end; 

8795  711 

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

713 
//Land[py, px+1]:= lfBasic; 
8795  714 

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

716 
UpdateLandTexture(xx, Pred(s^.h), yy, Pred(s^.w), true) 
4791  717 
else 
4611  718 
begin 
5024  719 
UpdateLandTexture( 
720 
max(0, min(LAND_WIDTH, xx)), 

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

722 
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

723 
min(LAND_HEIGHT  yy, Pred(s^.h)), false // could this be true without unnecessarily creating blanks? 
5024  724 
); 
4791  725 
end; 
5024  726 
////////////////////////////////// TODO  ASK UNC0RR FOR A GOOD HOME FOR THIS //////////////////////////////////// 
4611  727 
end 
5024  728 
end; 
729 

730 
if move then 

731 
begin 

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

732 
if gun then 
5024  733 
begin 
734 
DeleteGear(Gear); 

735 
exit 

736 
end; 

5695  737 
Gear^.Pos:= 0; 
7721  738 
Gear^.X:= int2hwFloat(LongInt(GetRandom(snowRight  snowLeft)) + snowLeft); 
8003  739 
Gear^.Y:= int2hwFloat(LAND_HEIGHT + LongInt(GetRandom(50))  1325); 
5413  740 
Gear^.State:= Gear^.State or gstInvisible; 
4611  741 
end 
742 
end; 

743 

4578  744 
//////////////////////////////////////////////////////////////////////////////// 
4  745 
procedure doStepGrave(Gear: PGear); 
746 
begin 

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

748 
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

749 
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

750 
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

751 
end; 
7394  752 

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

753 
AllInactive := false; 
7394  754 

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

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

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

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

758 

8105  759 
if (not Gear^.dY.isNegative) then 
3454
a9bef74bd6e0
Code restlyling: experimental restyling of one module
mbait
parents:
3440
diff
changeset

760 
if TestCollisionY(Gear, 1) then 
a9bef74bd6e0
Code restlyling: experimental restyling of one module
mbait
parents:
3440
diff
changeset

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

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

763 
if Gear^.dY >  _1div1024 then 
a9bef74bd6e0
Code restlyling: experimental restyling of one module
mbait
parents:
3440
diff
changeset

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

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

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

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

768 
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

769 
PlaySound(Gear^.ImpactSound) 
3454
a9bef74bd6e0
Code restlyling: experimental restyling of one module
mbait
parents:
3440
diff
changeset

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

771 

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

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

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

774 
Gear^.dY := Gear^.dY + cGravity 
4  775 
end; 
776 

777 
//////////////////////////////////////////////////////////////////////////////// 

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

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

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

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

784 

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

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

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

788 
gY := hwRound(Gear^.Y); 
6251  789 
uw := (Gear^.Tag <> 0); // was bee underwater last tick? 
790 
nuw := (cWaterLine < gy + Gear^.Radius); // is bee underwater now? 

791 

792 
// if water entered or left 

793 
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

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

795 
AddVisualGear(gX, cWaterLine, vgtSplash); 
a9bef74bd6e0
Code restlyling: experimental restyling of one module
mbait
parents:
3440
diff
changeset

796 
AddVisualGear(gX  3 + Random(6), cWaterLine, vgtDroplet); 
a9bef74bd6e0
Code restlyling: experimental restyling of one module
mbait
parents:
3440
diff
changeset

797 
AddVisualGear(gX  3 + Random(6), cWaterLine, vgtDroplet); 
a9bef74bd6e0
Code restlyling: experimental restyling of one module
mbait
parents:
3440
diff
changeset

798 
AddVisualGear(gX  3 + Random(6), cWaterLine, vgtDroplet); 
a9bef74bd6e0
Code restlyling: experimental restyling of one module
mbait
parents:
3440
diff
changeset

799 
AddVisualGear(gX  3 + Random(6), cWaterLine, vgtDroplet); 
7053  800 
StopSoundChan(Gear^.SoundChannel); 
6251  801 
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

802 
begin 
6251  803 
Gear^.SoundChannel := LoopSound(sndBeeWater); 
804 
Gear^.Tag := 1; 

805 
end 

806 
else 

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

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

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

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

811 
end; 
6251  812 

813 

814 
if Gear^.Timer = 0 then 

815 
Gear^.RenderTimer:= false 

816 
else 

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

817 
begin 
6251  818 
if (GameTicks 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

819 
begin 
6251  820 
if (GameTicks and $30) = 0 then 
821 
AddVisualGear(gX, gY, vgtBeeTrace); 

822 
Gear^.dX := Gear^.Elasticity * (Gear^.dX + _0_000064 * (Gear^.Target.X  gX)); 

823 
Gear^.dY := Gear^.Elasticity * (Gear^.dY + _0_000064 * (Gear^.Target.Y  gY)); 

824 
// make sure new speed isn't higher than original one (which we stored in Friction variable) 

825 
t := Gear^.Friction / Distance(Gear^.dX, Gear^.dY); 

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

827 
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

828 
end; 
6251  829 

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

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

832 

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

833 
end; 
3591  834 

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

835 

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

836 
CheckCollision(Gear); 
6251  837 
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

838 
begin 
7053  839 
StopSoundChan(Gear^.SoundChannel); 
4837
2ea0a152c319
Pass PHedgehog instead of PGear to stats. Fixes crash.
unc0rr
parents:
4824
diff
changeset

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

841 
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

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

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

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

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

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

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

849 
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

850 
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

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

852 
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

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

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

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

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

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

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

859 
end; 
6251  860 

861 
if (Gear^.Timer > 0) then 

862 
dec(Gear^.Timer) 

863 
else 

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

864 
begin 
6251  865 
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

866 
begin 
7053  867 
StopSoundChan(Gear^.SoundChannel); 
6251  868 
CheckGearDrowning(Gear); 
6580
6155187bf599
A partial reformatting of the pascal code to have consistent syntax. Things that are still inconsistent.
lovelacer
parents:
6556
diff
changeset

869 
end 
6251  870 
else 
871 
doStepFallingGear(Gear); 

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

872 
end; 
4  873 
end; 
874 

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

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

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

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

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

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

882 
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

883 
begin 
4837
2ea0a152c319
Pass PHedgehog instead of PGear to stats. Fixes crash.
unc0rr
parents:
4824
diff
changeset

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

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

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

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

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

889 
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

890 
begin 
6450  891 
Gear^.Hedgehog^.Gear^.Message:= Gear^.Hedgehog^.Gear^.Message and (not gmAttack); 
892 
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

893 
AttackBar:= 0; 
8795  894 

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

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

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

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

899 
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

900 
end; 
4  901 
end; 
902 

903 
//////////////////////////////////////////////////////////////////////////////// 

876  904 
procedure doStepShotIdle(Gear: PGear); 
905 
begin 

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

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

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

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

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

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

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

912 
end 
876  913 
end; 
914 

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

917 
i: LongWord; 
2828  918 
shell: PVisualGear; 
4  919 
begin 
3454
a9bef74bd6e0
Code restlyling: experimental restyling of one module
mbait
parents:
3440
diff
changeset

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

921 

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

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

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

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

925 
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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

947 

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

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

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

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

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

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

953 
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

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

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

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

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

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

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

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

961 

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

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

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

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

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

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

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

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

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

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

971 
Gear^.doStep := @doStepShotIdle 
4  972 
end; 
973 

974 
//////////////////////////////////////////////////////////////////////////////// 

5841  975 
procedure spawnBulletTrail(Bullet: PGear); 
976 
var oX, oY: hwFloat; 

977 
VGear: PVisualGear; 

978 
begin 

979 
if Bullet^.PortalCounter = 0 then 

980 
begin 

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

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

983 
end 

984 
else 

985 
begin 

986 
ox:= Bullet^.Elasticity; 

987 
oy:= Bullet^.Friction; 

988 
end; 

989 

990 
// Bullet trail 

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

8795  992 

5841  993 
if VGear <> nil then 
994 
begin 

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

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

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

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

999 

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

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

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

1002 
or (hwRound(Bullet^.Y) and LAND_HEIGHT_MASK <> 0) then 
5841  1003 
// only extend if not under water 
1004 
if hwRound(Bullet^.Y) < cWaterLine then 

1005 
begin 

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

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

1007 
VGear^.dY := VGear^.dY + max(LAND_WIDTH,4096) * (VGear^.dY  VGear^.Y); 
5841  1008 
end; 
1009 

1010 
VGear^.Timer := 200; 

1011 
end; 

1012 
end; 

1013 

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

1014 
procedure doStepBulletWork(Gear: PGear); 
8795  1015 
var 
8026
4a4f21070479
merge xymeng's gsoc engine with a few updates (and further checks on symbol definitions)
koda
parents:
8003
diff
changeset

1016 
i: LongInt; 
4a4f21070479
merge xymeng's gsoc engine with a few updates (and further checks on symbol definitions)
koda
parents:
8003
diff
changeset

1017 
x, y: LongWord; 
351  1018 
oX, oY: hwFloat; 
4327  1019 
VGear: PVisualGear; 
38  1020 
begin 
3454
a9bef74bd6e0
Code restlyling: experimental restyling of one module
mbait
parents:
3440
diff
changeset

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

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

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

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

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

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

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

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

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

1030 
y := hwRound(Gear^.Y); 
8795  1031 

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

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

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

1036 
begin 
5841  1037 
Gear^.Tag := 1; 
1038 
Gear^.Damage := 0; 

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

1040 
Gear^.Y := Gear^.Y  Gear^.dY; 

1041 
CheckGearDrowning(Gear); 

1042 
break; 

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

1043 
end 
5841  1044 
else 
1045 
Gear^.Tag := 0; 

1046 

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

1047 
if Gear^.Damage > 5 then 
3836
833c0f32e326
Change all use of curslot/idx to CurAmmoType to try and avoid some bugs with use of last weapon.
nemo
parents:
3821
diff
changeset

1048 
if Gear^.AmmoType = amDEagle then 
3454
a9bef74bd6e0
Code restlyling: experimental restyling of one module
mbait
parents:
3440
diff
changeset

1049 
AmmoShove(Gear, 7, 20) 
a9bef74bd6e0
Code restlyling: experimental restyling of one module
mbait
parents:
3440
diff
changeset

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

1051 
AmmoShove(Gear, Gear^.Timer, 20); 
a9bef74bd6e0
Code restlyling: experimental restyling of one module
mbait
parents:
3440
diff
changeset

1052 
CheckGearDrowning(Gear); 
8795  1053 
dec(i) 
7204
522f165cd2e7
 Fix damage calculation in TestSniperRifle, aim a bit lower to compensate initial angle shift in sniper rifle. As a result, AI seems to never fail sniper rifle shots.
unc0rr
parents:
7195
diff
changeset

1054 
until (i = 0) or (Gear^.Damage > Gear^.Health) or ((Gear^.State and gstDrowning) <> 0); 
522f165cd2e7
 Fix damage calculation in TestSniperRifle, aim a bit lower to compensate initial angle shift in sniper rifle. As a result, AI seems to never fail sniper rifle shots.
unc0rr
parents:
7195
diff
changeset

1055 

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

1056 
if Gear^.Damage > 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

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

1058 
DrawTunnel(oX, oY, Gear^.dX, Gear^.dY, 82  i, 1); 
a9bef74bd6e0
Code restlyling: experimental restyling of one module
mbait
parents:
3440
diff
changeset

1059 
dec(Gear^.Health, Gear^.Damage); 
a9bef74bd6e0
Code restlyling: experimental restyling of one module
mbait
parents:
3440
diff
changeset

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

1061 
end; 
8105  1062 
if ((Gear^.State and gstDrowning) <> 0) and (Gear^.Damage < Gear^.Health) and (((not SuddenDeathDmg) and (WaterOpacity < $FF)) or (SuddenDeathDmg and (SDWaterOpacity < $FF))) then 
6580
6155187bf599
A partial reformatting of the pascal code to have consistent syntax. Things that are still inconsistent.
lovelacer
parents:
6556
diff
changeset

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

1064 
for i:=(Gear^.Health  Gear^.Damage) * 4 downto 0 do 
6580
6155187bf599
A partial reformatting of the pascal code to have consistent syntax. Things that are still inconsistent.
lovelacer
parents:
6556
diff
changeset

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

1066 
if Random(6) = 0 then 
a9bef74bd6e0
Code restlyling: experimental restyling of one module
mbait
parents:
3440
diff
changeset

1067 
AddVisualGear(hwRound(Gear^.X), hwRound(Gear^.Y), vgtBubble); 
a9bef74bd6e0
Code restlyling: experimental restyling of one module
mbait
parents:
3440
diff
changeset

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

1069 
Gear^.Y := Gear^.Y + Gear^.dY; 
6580
6155187bf599
A partial reformatting of the pascal code to have consistent syntax. Things that are still inconsistent.
lovelacer
parents:
6556
diff
changeset

1070 
end; 
2994
7ae3067546f2
Palewolf adds bubbles and splashes when firing bullets into the water
nemo
parents:
2989
diff
changeset

1071 
end; 
1760  1072 

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

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

1074 
or (hwRound(Gear^.X) and LAND_WIDTH_MASK <> 0) 
6155187bf599
A partial reformatting of the pascal code to have consistent syntax. Things that are still inconsistent.
lovelacer
parents:
6556
diff
changeset

1075 
or (hwRound(Gear^.Y) and LAND_HEIGHT_MASK <> 0) then 
6155187bf599
A partial reformatting of the pascal code to have consistent syntax. Things that are still inconsistent.
lovelacer
parents:
6556
diff
changeset

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

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

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

1079 
if (Ammoz[Gear^.AmmoType].Ammo.NumPerTurn <= CurrentHedgehog^.MultiShootAttacks) and ((GameFlags and gfArtillery) = 0) then 
6155187bf599
A partial reformatting of the pascal code to have consistent syntax. Things that are still inconsistent.
lovelacer
parents:
6556
diff
changeset

1080 
cArtillery := false; 
8795  1081 

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

1083 
if (hwRound(Gear^.X) and LAND_WIDTH_MASK = 0) and (hwRound(Gear^.Y) and LAND_HEIGHT_MASK = 0) then 
6155187bf599
A partial reformatting of the pascal code to have consistent syntax. Things that are still inconsistent.
lovelacer
parents:
6556
diff
changeset

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

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

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

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

1088 
VGear^.Angle := DxDy2Angle(Gear^.dX, Gear^.dY); 
6155187bf599
A partial reformatting of the pascal code to have consistent syntax. Things that are still inconsistent.
lovelacer
parents:
6556
diff
changeset

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

1090 
end; 
8795  1091 

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

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

1093 
Gear^.doStep := @doStepShotIdle 
4327  1094 
end; 
37  1095 
end; 
1096 

559  1097 
procedure doStepDEagleShot(Gear: PGear); 
1098 
begin 

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

1099 
PlaySound(sndGun); 
5926
09bbc7b88714
2 extra steps was still occasionally causing problems w/ edge cases. hopefully 3 should do the trick
nemo
parents:
5924
diff
changeset

1100 
// add 3 initial steps to avoid problem with ammoshove related to calculation of radius + 1 radius as gear widths, and also just plain old weird angles 
09bbc7b88714
2 extra steps was still occasionally causing problems w/ edge cases. hopefully 3 should do the trick
nemo
parents:
5924
diff
changeset

1101 
Gear^.X := Gear^.X + Gear^.dX * 3; 
09bbc7b88714
2 extra steps was still occasionally causing problems w/ edge cases. hopefully 3 should do the trick
nemo
parents:
5924
diff
changeset

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

1103 
Gear^.doStep := @doStepBulletWork 
2023
41d3afaa20c7
Artillery mode, sniper rifle, speech bubble tweaks, fix of rope bug introduced by enabling hats in jump
nemo
parents:
2017
diff
changeset

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

1105 

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

1106 
procedure doStepSniperRifleShot(Gear: PGear); 
8795  1107 
var 
3454
a9bef74bd6e0
Code restlyling: experimental restyling of one module
mbait
parents:
3440
diff
changeset

1108 
HHGear: PGear; 
2828  1109 
shell: PVisualGear; 
2023
41d3afaa20c7
Artillery mode, sniper rifle, speech bubble tweaks, fix of rope bug introduced by enabling hats in jump
nemo
parents:
2017
diff
changeset

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

1111 
cArtillery := true; 
4365  1112 
HHGear := Gear^.Hedgehog^.Gear; 
3454
a9bef74bd6e0
Code restlyling: experimental restyling of one module
mbait
parents:
3440
diff
changeset

1113 
HHGear^.State := HHGear^.State or gstNotKickable; 
a9bef74bd6e0
Code restlyling: experimental restyling of one module
mbait
parents:
3440
diff
changeset

1114 
HedgehogChAngle(HHGear); 
a9bef74bd6e0
Code restlyling: experimental restyling of one module
mbait
parents:
3440
diff
changeset

1115 
if not cLaserSighting then 
a9bef74bd6e0
Code restlyling: experimental restyling of one module
mbait
parents:
3440
diff
changeset

1116 
// game does not have default laser sight. turn it on and give them a chance to aim 
6580
6155187bf599
A partial reformatting of the pascal code to have consistent syntax. Things that are still inconsistent.
lovelacer
parents:
6556
diff
changeset

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

1118 
cLaserSighting := true; 
a9bef74bd6e0
Code restlyling: experimental restyling of one module
mbait
parents:
3440
diff
changeset

1119 
HHGear^.Message := 0; 
7066
12cc2bd84b0b
Make pas2c even more happier with uGears.c, allow assigning arrays in some cases
unc0rr
parents:
7062
diff
changeset

1120 
if (HHGear^.Angle >= 32) then 
6580
6155187bf599
A partial reformatting of the pascal code to have consistent syntax. Things that are still inconsistent.
lovelacer
parents:
6556
diff
changeset

1121 
dec(HHGear^.Angle,32) 
6155187bf599
A partial reformatting of the pascal code to have consistent syntax. Things that are still inconsistent.
lovelacer
parents:
6556
diff
changeset

1122 
end; 
2031
b6f3e56fb100
david_ac's game scheme options for mine delay/quantity, tweaks to sniper rifle
nemo
parents:
2029
diff
changeset

1123 

3894  1124 
if (HHGear^.Message and gmAttack) <> 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

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

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

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

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

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

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

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

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

1133 
Gear^.State := Gear^.State or gstAnimation; 
a9bef74bd6e0
Code restlyling: experimental restyling of one module
mbait
parents:
3440
diff
changeset

1134 
Gear^.dX := SignAs(AngleSin(HHGear^.Angle), HHGear^.dX) * _0_5; 
a9bef74bd6e0
Code restlyling: experimental restyling of one module
mbait
parents:
3440
diff
changeset

1135 
Gear^.dY := AngleCos(HHGear^.Angle) * _0_5; 
a9bef74bd6e0
Code restlyling: experimental restyling of one module
mbait
parents:
3440
diff
changeset

1136 
PlaySound(sndGun); 
5926
09bbc7b88714
2 extra steps was still occasionally causing problems w/ edge cases. hopefully 3 should do the trick
nemo
parents:
5924
diff
changeset

1137 
// add 3 initial steps to avoid problem with ammoshove related to calculation of radius + 1 radius as gear widths, and also just weird angles 
8795  1138 
Gear^.X := Gear^.X + Gear^.dX * 3; 
5926
09bbc7b88714
2 extra steps was still occasionally causing problems w/ edge cases. hopefully 3 should do the trick
nemo
parents:
5924
diff
changeset

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

1140 
Gear^.doStep := @doStepBulletWork; 
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 
3454
a9bef74bd6e0
Code restlyling: experimental restyling of one module
mbait
parents:
3440
diff
changeset

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

1143 
if (GameTicks mod 32) = 0 then 
a9bef74bd6e0
Code restlyling: experimental restyling of one module
mbait
parents:
3440
diff
changeset

1144 
if (GameTicks mod 4096) < 2048 then 
6580
6155187bf599
A partial reformatting of the pascal code to have consistent syntax. Things that are still inconsistent.
lovelacer
parents:
6556
diff
changeset

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

1146 
if (HHGear^.Angle + 1 <= cMaxAngle) then 
6155187bf599
A partial reformatting of the pascal code to have consistent syntax. Things that are still inconsistent.
lovelacer
parents:
6556
diff
changeset

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

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

1149 
else 
7066
12cc2bd84b0b
Make pas2c even more happier with uGears.c, allow assigning arrays in some cases
unc0rr
parents:
7062
diff
changeset

1150 
if (HHGear^.Angle >= 1) then 
6580
6155187bf599
A partial reformatting of the pascal code to have consistent syntax. Things that are still inconsistent.
lovelacer
parents:
6556
diff
changeset

1151 
dec(HHGear^.Angle); 
3454
a9bef74bd6e0
Code restlyling: experimental restyling of one module
mbait
parents:
3440
diff
changeset

1152 

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

1153 
if (TurnTimeLeft > 0) then 
a9bef74bd6e0
Code restlyling: experimental restyling of one module
mbait
parents:
3440
diff
changeset

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

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

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

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

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

1159 
end; 
559  1160 
end; 
1161 

37  1162 
//////////////////////////////////////////////////////////////////////////////// 
4  1163 
procedure doStepActionTimer(Gear: PGear); 
1164 
begin 

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

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

1166 
case Gear^.Kind of 
8795  1167 
gtATStartGame: 
8679  1168 
begin 
3454
a9bef74bd6e0
Code restlyling: experimental restyling of one module
mbait
parents:
3440
diff
changeset

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

1170 
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

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

1172 
AddCaption(trmsg[sidStartFight], cWhiteColor, capgrpGameState); 
6580
6155187bf599
A partial reformatting of the pascal code to have consistent syntax. Things that are still inconsistent.
lovelacer
parents:
6556
diff
changeset

1173 
end 
8679  1174 
end; 
8795  1175 
gtATFinishGame: 
8679  1176 
begin 
5368
a66d5141a3ba
fix build. seems like a indentationrelated mergeoopsy dragged deleted code back in.
sheepluva
parents:
5366
diff
changeset

1177 
AllInactive := false; 
a66d5141a3ba
fix build. seems like a indentationrelated mergeoopsy dragged deleted code back in.
sheepluva
parents:
5366
diff
changeset

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

1179 
begin 
5368
a66d5141a3ba
fix build. seems like a indentationrelated mergeoopsy dragged deleted code back in.
sheepluva
parents:
5366
diff
changeset

1180 
ScreenFade := sfToBlack; 
a66d5141a3ba
fix build. seems like a indentationrelated mergeoopsy dragged deleted code back in.
sheepluva
parents:
5366
diff
changeset

1181 
ScreenFadeValue := 0; 
a66d5141a3ba
fix build. seems like a indentationrelated mergeoopsy dragged deleted code back in.
sheepluva
parents:
5366
diff
changeset

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

1183 
end; 
5368
a66d5141a3ba
fix build. seems like a indentationrelated mergeoopsy dragged deleted code back in.
sheepluva
parents:
5366
diff
changeset

1184 
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

1185 
begin 
7068  1186 
SendIPC(_S'N'); 
1187 
SendIPC(_S'q'); 

5368
a66d5141a3ba
fix build. seems like a indentationrelated mergeoopsy dragged deleted code back in.
sheepluva
parents:
5366
diff
changeset

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

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

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

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

1193 
DeleteGear(Gear) 
4  1194 
end; 
1195 

1196 
//////////////////////////////////////////////////////////////////////////////// 

1197 
procedure doStepPickHammerWork(Gear: PGear); 

8795  1198 
var 
4578  1199 
i, ei, x, y: LongInt; 
4  1200 
HHGear: PGear; 
1201 
begin 

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

1202 
AllInactive := false; 
4365  1203 
HHGear := Gear^.Hedgehog^.Gear; 
3454
a9bef74bd6e0
Code restlyling: experimental restyling of one module
mbait
parents:
3440
diff
changeset

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

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

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

1207 
if (TurnTimeLeft = 0) or (Gear^.Timer = 0) 
6155187bf599
A partial reformatting of the pascal code to have consistent syntax. Things that are still inconsistent.
lovelacer
parents:
6556
diff
changeset

1208 
or((Gear^.Message and gmDestroy) <> 0) 
6155187bf599
A partial reformatting of the pascal code to have consistent syntax. Things that are still inconsistent.
lovelacer
parents:
6556
diff
changeset

1209 
or((HHGear^.State and gstHHDriven) =0) then 
4578  1210 
begin 
7053  1211 
StopSoundChan(Gear^.SoundChannel); 
3454
a9bef74bd6e0
Code restlyling: experimental restyling of one module
mbait
parents:
3440
diff
changeset

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

1213 
AfterAttack; 
3954
ae3583ad6ea9
Hopefully fix the last of the more obvious weapon bugs w/ infinite attack mode, add a depixeling sweep every 5s too.
nemo
parents:
3953
diff
changeset

1214 
doStepHedgehogMoving(HHGear); // for gfInfAttack 
3454
a9bef74bd6e0
Code restlyling: experimental restyling of one module
mbait
parents:
3440
diff
changeset

1215 
exit 
4578  1216 
end; 
1217 

1218 
x:= hwRound(Gear^.X); 

1219 
y:= hwRound(Gear^.Y); 

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

1220 
if (Gear^.Timer mod 33) = 0 then 
4578  1221 
begin 
3454
a9bef74bd6e0
Code restlyling: experimental restyling of one module
mbait
parents:
3440
diff
changeset

1222 
HHGear^.State := HHGear^.State or gstNoDamage; 
4837
2ea0a152c319
Pass PHedgehog instead of PGear to stats. Fixes crash.
unc0rr
parents:
4824
diff
changeset

1223 
doMakeExplosion(x, y + 7, 6, Gear^.Hedgehog, EXPLDontDraw); 
6450  1224 
HHGear^.State := HHGear^.State and (not gstNoDamage) 
4578  1225 
end; 
422  1226 

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

1227 
if (Gear^.Timer mod 47) = 0 then 
4578  1228 
begin 
1229 
// ok. this was an attempt to turn off dust if not actually drilling land. I have no idea why it isn't working as expected 

6131  1230 
if (( (y + 12) and LAND_HEIGHT_MASK) = 0) and ((x and LAND_WIDTH_MASK) = 0) and (Land[y + 12, x] > 255) then 
4578  1231 
for i:= 0 to 1 do 
1232 
AddVisualGear(x  5 + Random(10), y + 12, vgtDust); 

1233 

1234 
i := x  Gear^.Radius  LongInt(GetRandom(2)); 

1235 
ei := x + Gear^.Radius + LongInt(GetRandom(2)); 

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

1236 
while i <= ei do 
4578  1237 
begin 
1238 
DrawExplosion(i, y + 3, 3); 

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

1239 
inc(i, 1) 
4578  1240 
end; 
2331
e4941a7986d6
Another try at keeping blowtorch/firepunch/jackhammer from going through indestructible stuff. Shame these routines don't use hedgehog movement
nemo
parents:
2329
diff
changeset

1241 

6314  1242 
if CheckLandValue(hwRound(Gear^.X + Gear^.dX + SignAs(_6,Gear^.dX)), hwRound(Gear^.Y + _1_9), lfIndestructible) then 
4578  1243 
begin 
3454
a9bef74bd6e0
Code restlyling: experimental restyling of one module
mbait
parents:
3440
diff
changeset

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

1245 
Gear^.Y := Gear^.Y + _1_9; 
4578  1246 
end; 
8850
ae8a957c69fd
engine to c now compiles with some manual intervention (as of bug 596)
koda
parents:
8847
diff
changeset

1247 
SetAllHHToActive(true); 
4578  1248 
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

1249 
if TestCollisionYwithGear(Gear, 1) <> 0 then 
4578  1250 
begin 
3454
a9bef74bd6e0
Code restlyling: experimental restyling of one module
mbait
parents:
3440
diff
changeset

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

1252 
SetLittle(HHGear^.dX); 
a9bef74bd6e0
Code restlyling: experimental restyling of one module
mbait
parents:
3440
diff
changeset

1253 
HHGear^.dY := _0; 
4578  1254 
end 
3454
a9bef74bd6e0
Code restlyling: experimental restyling of one module
mbait
parents:
3440
diff
changeset

1255 
else 
4578  1256 
begin 
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

1257 
if CheckLandValue(hwRound(Gear^.X), hwRound(Gear^.Y + Gear^.dY + cGravity), lfLandMask) then 
6314  1258 
begin 
1259 
Gear^.dY := Gear^.dY + cGravity; 

1260 
Gear^.Y := Gear^.Y + Gear^.dY 

1261 
end; 

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

1262 
if hwRound(Gear^.Y) > cWaterLine then 
6155187bf599
A partial reformatting of the pascal code to have consistent syntax. Things that are still inconsistent.
lovelacer
parents:
6556
diff
changeset

1263 
Gear^.Timer := 1 
4578  1264 
end; 
4  1265 

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

1266 
Gear^.X := Gear^.X + HHGear^.dX; 
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

1267 
if CheckLandValue(hwRound(Gear^.X), hwRound(Gear^.Y)cHHRadius, lfLandMask) then 
6314  1268 
begin 
1269 
HHGear^.X := Gear^.X; 

1270 
HHGear^.Y := Gear^.Y  int2hwFloat(cHHRadius) 

1271 
end; 

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

1272 

3894  1273 
if (Gear^.Message and gmAttack) <> 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

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

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

1276 
else //there would be a mistake. 
3454
a9bef74bd6e0
Code restlyling: experimental restyling of one module
mbait
parents:
3440
diff
changeset

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

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

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

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

1281 
Gear^.dX :=  _0_3 
3454
a9bef74bd6e0
Code restlyling: experimental restyling of one module
mbait
parents:
3440
diff
changeset

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

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

1284 