author  nemo 
Thu, 24 Nov 2011 16:40:17 0500  
changeset 6419  6a464d0a5c13 
parent 6389  9acbf54e9379 
child 6450  14224c9b4594 
permissions  rwrr 
4  1 
(* 
1066  2 
* Hedgewars, a free turn based strategy game 
4976  3 
* Copyright (c) 20042011 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 
3569  56 
else 
4578  57 
begin 
3569  58 
sX:= dX; 
59 
sY:= dY; 

4578  60 
end; 
3569  61 

62 
caller:= Gear^.doStep; 

63 

64 
for i:= 1 to steps do 

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

68 
step(Gear); 

69 
if (Gear^.doStep <> caller) 

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

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

72 
break; 

4578  73 
end; 
3569  74 
end; 
75 

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

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

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

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

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

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

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

86 
d := r  hwRound(Distance(gi^.X  x, gi^.Y  y)); 
a9bef74bd6e0
Code restlyling: experimental restyling of one module
mbait
parents:
3440
diff
changeset

87 
if (d > 1) and not gi^.Invulnerable and (GetRandom(2) = 0) then 
4578  88 
begin 
3143  89 
if (CurrentHedgehog^.Gear = gi) then 
4372  90 
PlaySound(sndOops, gi^.Hedgehog^.Team^.voicepack) 
2948
3f21a9dc93d0
Replace tabs with spaces using 'expand t 4' command
unc0rr
parents:
2944
diff
changeset

91 
else 
4578  92 
begin 
3143  93 
if (gi^.State and gstMoving) = 0 then 
3454
a9bef74bd6e0
Code restlyling: experimental restyling of one module
mbait
parents:
3440
diff
changeset

94 
gi^.State := gi^.State or gstLoser; 
3143  95 
if d > r div 2 then 
4372  96 
PlaySound(sndNooo, gi^.Hedgehog^.Team^.voicepack) 
3143  97 
else 
4372  98 
PlaySound(sndUhOh, gi^.Hedgehog^.Team^.voicepack); 
4578  99 
end; 
2948
3f21a9dc93d0
Replace tabs with spaces using 'expand t 4' command
unc0rr
parents:
2944
diff
changeset

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

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

103 
end; 
2647  104 
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

105 

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

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

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

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

109 
DeleteCI(HH^.Gear); 
5c8fe58dead5
Define 2 script callbacks to notify of hog vanishment
nemo
parents:
5806
diff
changeset

110 
if FollowGear = HH^.Gear then FollowGear:= nil; 
5c8fe58dead5
Define 2 script callbacks to notify of hog vanishment
nemo
parents:
5806
diff
changeset

111 
if lastGearByUID = HH^.Gear then lastGearByUID := nil; 
5c8fe58dead5
Define 2 script callbacks to notify of hog vanishment
nemo
parents:
5806
diff
changeset

112 
RemoveGearFromList(HH^.Gear); 
5c8fe58dead5
Define 2 script callbacks to notify of hog vanishment
nemo
parents:
5806
diff
changeset

113 
with HH^.Gear^ do 
5c8fe58dead5
Define 2 script callbacks to notify of hog vanishment
nemo
parents:
5806
diff
changeset

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

115 
Z := cHHZ; 
5c8fe58dead5
Define 2 script callbacks to notify of hog vanishment
nemo
parents:
5806
diff
changeset

116 
Active := false; 
5c8fe58dead5
Define 2 script callbacks to notify of hog vanishment
nemo
parents:
5806
diff
changeset

117 
State:= State and not (gstHHDriven or gstAttacking or gstAttacked); 
5c8fe58dead5
Define 2 script callbacks to notify of hog vanishment
nemo
parents:
5806
diff
changeset

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

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

120 
HH^.GearHidden:= HH^.Gear; 
5977
0b1bfdd95310
Disable a bit of code from revision 4 that I'm pretty sure is not hit anymore, or we'd end up with plenty of doubled graves at a minimum. Also, clear gstWinner/gstLoser along with gstWait  still need to figure out why exactly those aren't rendering anymore though.
nemo
parents:
5972
diff
changeset

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

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

123 

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

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

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

126 
HH^.Gear:=HH^.GearHidden; 
5c8fe58dead5
Define 2 script callbacks to notify of hog vanishment
nemo
parents:
5806
diff
changeset

127 
HH^.GearHidden:= nil; 
5c8fe58dead5
Define 2 script callbacks to notify of hog vanishment
nemo
parents:
5806
diff
changeset

128 
InsertGearToList(HH^.Gear); 
5c8fe58dead5
Define 2 script callbacks to notify of hog vanishment
nemo
parents:
5806
diff
changeset

129 
HH^.Gear^.State:= (HH^.Gear^.State and not (gstHHDriven or gstInvisible or gstAttacking)) or gstAttacked; 
5c8fe58dead5
Define 2 script callbacks to notify of hog vanishment
nemo
parents:
5806
diff
changeset

130 
AddGearCI(HH^.Gear); 
5c8fe58dead5
Define 2 script callbacks to notify of hog vanishment
nemo
parents:
5806
diff
changeset

131 
HH^.Gear^.Active:= true; 
5c8fe58dead5
Define 2 script callbacks to notify of hog vanishment
nemo
parents:
5806
diff
changeset

132 
ScriptCall('onHogRestore', HH^.Gear^.Uid) 
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 

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

136 
procedure doStepDrowningGear(Gear: PGear); 
a9bef74bd6e0
Code restlyling: experimental restyling of one module
mbait
parents:
3440
diff
changeset

137 
forward; 
4  138 

139 
function CheckGearDrowning(Gear: PGear): boolean; 

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

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

141 
skipSpeed, skipAngle, skipDecay: hwFloat; 
5336
174734adc06b
Store gear X/Y/dX/dY for use in splash/droplets. Also saves a few hwRound calls.
nemo
parents:
5313
diff
changeset

142 
i, maxDrops, X, Y: LongInt; 
174734adc06b
Store gear X/Y/dX/dY for use in splash/droplets. Also saves a few hwRound calls.
nemo
parents:
5313
diff
changeset

143 
vdX, vdY: real; 
2982  144 
particle: PVisualGear; 
3907
5b516f0d9957
Allow UFO to go underwater. Keep UFO active if it runs out of fuel in the air/water, just disable controls.
nemo
parents:
3894
diff
changeset

145 
isSubmersible: boolean; 
4  146 
begin 
3907
5b516f0d9957
Allow UFO to go underwater. Keep UFO active if it runs out of fuel in the air/water, just disable controls.
nemo
parents:
3894
diff
changeset

147 
isSubmersible:= (Gear = CurrentHedgehog^.Gear) and (CurAmmoGear <> nil) and (CurAmmoGear^.AmmoType = amJetpack); 
3454
a9bef74bd6e0
Code restlyling: experimental restyling of one module
mbait
parents:
3440
diff
changeset

148 
// probably needs tweaking. might need to be in a case statement based upon gear type 
5336
174734adc06b
Store gear X/Y/dX/dY for use in splash/droplets. Also saves a few hwRound calls.
nemo
parents:
5313
diff
changeset

149 
Y:= hwRound(Gear^.Y); 
174734adc06b
Store gear X/Y/dX/dY for use in splash/droplets. Also saves a few hwRound calls.
nemo
parents:
5313
diff
changeset

150 
if cWaterLine < Y + Gear^.Radius then 
4578  151 
begin 
3454
a9bef74bd6e0
Code restlyling: experimental restyling of one module
mbait
parents:
3440
diff
changeset

152 
skipSpeed := _0_25; 
a9bef74bd6e0
Code restlyling: experimental restyling of one module
mbait
parents:
3440
diff
changeset

153 
skipAngle := _1_9; 
a9bef74bd6e0
Code restlyling: experimental restyling of one module
mbait
parents:
3440
diff
changeset

154 
skipDecay := _0_87; 
5336
174734adc06b
Store gear X/Y/dX/dY for use in splash/droplets. Also saves a few hwRound calls.
nemo
parents:
5313
diff
changeset

155 
X:= hwRound(Gear^.X); 
174734adc06b
Store gear X/Y/dX/dY for use in splash/droplets. Also saves a few hwRound calls.
nemo
parents:
5313
diff
changeset

156 
vdX:= hwFloat2Float(Gear^.dX); 
174734adc06b
Store gear X/Y/dX/dY for use in splash/droplets. Also saves a few hwRound calls.
nemo
parents:
5313
diff
changeset

157 
vdY:= hwFloat2Float(Gear^.dY); 
3454
a9bef74bd6e0
Code restlyling: experimental restyling of one module
mbait
parents:
3440
diff
changeset

158 
// this could perhaps be a tiny bit higher. 
a9bef74bd6e0
Code restlyling: experimental restyling of one module
mbait
parents:
3440
diff
changeset

159 
if (hwSqr(Gear^.dX) + hwSqr(Gear^.dY) > skipSpeed) and 
a9bef74bd6e0
Code restlyling: experimental restyling of one module
mbait
parents:
3440
diff
changeset

160 
(hwAbs(Gear^.dX) > skipAngle * hwAbs(Gear^.dY)) then 
4578  161 
begin 
3454
a9bef74bd6e0
Code restlyling: experimental restyling of one module
mbait
parents:
3440
diff
changeset

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

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

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

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

166 
PlaySound(sndSkip) 
4578  167 
end 
3454
a9bef74bd6e0
Code restlyling: experimental restyling of one module
mbait
parents:
3440
diff
changeset

168 
else 
4578  169 
begin 
3907
5b516f0d9957
Allow UFO to go underwater. Keep UFO active if it runs out of fuel in the air/water, just disable controls.
nemo
parents:
3894
diff
changeset

170 
if not isSubmersible then 
4578  171 
begin 
3907
5b516f0d9957
Allow UFO to go underwater. Keep UFO active if it runs out of fuel in the air/water, just disable controls.
nemo
parents:
3894
diff
changeset

172 
CheckGearDrowning := true; 
5b516f0d9957
Allow UFO to go underwater. Keep UFO active if it runs out of fuel in the air/water, just disable controls.
nemo
parents:
3894
diff
changeset

173 
Gear^.State := gstDrowning; 
5b516f0d9957
Allow UFO to go underwater. Keep UFO active if it runs out of fuel in the air/water, just disable controls.
nemo
parents:
3894
diff
changeset

174 
Gear^.RenderTimer := false; 
4578  175 
if (Gear^.Kind <> gtSniperRifleShot) and (Gear^.Kind <> gtShotgunShot) and 
176 
(Gear^.Kind <> gtDEagleShot) and (Gear^.Kind <> gtSineGunShot) then 

6131  177 
if Gear^.Kind = gtHedgehog then 
3907
5b516f0d9957
Allow UFO to go underwater. Keep UFO active if it runs out of fuel in the air/water, just disable controls.
nemo
parents:
3894
diff
changeset

178 
begin 
4365  179 
if Gear^.Hedgehog^.Effects[heResurrectable] then 
3907
5b516f0d9957
Allow UFO to go underwater. Keep UFO active if it runs out of fuel in the air/water, just disable controls.
nemo
parents:
3894
diff
changeset

180 
ResurrectHedgehog(Gear) 
5b516f0d9957
Allow UFO to go underwater. Keep UFO active if it runs out of fuel in the air/water, just disable controls.
nemo
parents:
3894
diff
changeset

181 
else 
5b516f0d9957
Allow UFO to go underwater. Keep UFO active if it runs out of fuel in the air/water, just disable controls.
nemo
parents:
3894
diff
changeset

182 
begin 
5b516f0d9957
Allow UFO to go underwater. Keep UFO active if it runs out of fuel in the air/water, just disable controls.
nemo
parents:
3894
diff
changeset

183 
Gear^.doStep := @doStepDrowningGear; 
5b516f0d9957
Allow UFO to go underwater. Keep UFO active if it runs out of fuel in the air/water, just disable controls.
nemo
parents:
3894
diff
changeset

184 
Gear^.State := Gear^.State and (not gstHHDriven); 
4365  185 
AddCaption(Format(GetEventString(eidDrowned), Gear^.Hedgehog^.Name), cWhiteColor, capgrpMessage); 
3907
5b516f0d9957
Allow UFO to go underwater. Keep UFO active if it runs out of fuel in the air/water, just disable controls.
nemo
parents:
3894
diff
changeset

186 
end 
5b516f0d9957
Allow UFO to go underwater. Keep UFO active if it runs out of fuel in the air/water, just disable controls.
nemo
parents:
3894
diff
changeset

187 
end 
5474  188 
else Gear^.doStep := @doStepDrowningGear; 
189 
if Gear^.Kind = gtFlake then exit // skip splashes 

5336
174734adc06b
Store gear X/Y/dX/dY for use in splash/droplets. Also saves a few hwRound calls.
nemo
parents:
5313
diff
changeset

190 
end; 
174734adc06b
Store gear X/Y/dX/dY for use in splash/droplets. Also saves a few hwRound calls.
nemo
parents:
5313
diff
changeset

191 
if ((not isSubmersible) and (Y < cWaterLine + 64 + Gear^.Radius)) or 
174734adc06b
Store gear X/Y/dX/dY for use in splash/droplets. Also saves a few hwRound calls.
nemo
parents:
5313
diff
changeset

192 
(isSubmersible and (Y < cWaterLine + 2 + Gear^.Radius) and ((CurAmmoGear^.Pos = 0) and (CurAmmoGear^.dY < _0_01))) then 
3454
a9bef74bd6e0
Code restlyling: experimental restyling of one module
mbait
parents:
3440
diff
changeset

193 
// don't play splash if they are already way past the surface 
a9bef74bd6e0
Code restlyling: experimental restyling of one module
mbait
parents:
3440
diff
changeset

194 
PlaySound(sndSplash) 
5336
174734adc06b
Store gear X/Y/dX/dY for use in splash/droplets. Also saves a few hwRound calls.
nemo
parents:
5313
diff
changeset

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

196 

3907
5b516f0d9957
Allow UFO to go underwater. Keep UFO active if it runs out of fuel in the air/water, just disable controls.
nemo
parents:
3894
diff
changeset

197 
if ((cReducedQuality and rqPlainSplash) = 0) and 
5336
174734adc06b
Store gear X/Y/dX/dY for use in splash/droplets. Also saves a few hwRound calls.
nemo
parents:
5313
diff
changeset

198 
(((not isSubmersible) and (Y < cWaterLine + 64 + Gear^.Radius)) or 
174734adc06b
Store gear X/Y/dX/dY for use in splash/droplets. Also saves a few hwRound calls.
nemo
parents:
5313
diff
changeset

199 
(isSubmersible and (Y < cWaterLine + 2 + Gear^.Radius) and ((CurAmmoGear^.Pos = 0) and (CurAmmoGear^.dY < _0_01)))) then 
4578  200 
begin 
5336
174734adc06b
Store gear X/Y/dX/dY for use in splash/droplets. Also saves a few hwRound calls.
nemo
parents:
5313
diff
changeset

201 
AddVisualGear(X, cWaterLine, vgtSplash); 
174734adc06b
Store gear X/Y/dX/dY for use in splash/droplets. Also saves a few hwRound calls.
nemo
parents:
5313
diff
changeset

202 

174734adc06b
Store gear X/Y/dX/dY for use in splash/droplets. Also saves a few hwRound calls.
nemo
parents:
5313
diff
changeset

203 
maxDrops := (Gear^.Radius div 2) + round(vdX * Gear^.Radius * 2) + round(vdY * Gear^.Radius * 2); 
3454
a9bef74bd6e0
Code restlyling: experimental restyling of one module
mbait
parents:
3440
diff
changeset

204 
for i:= max(maxDrops div 3, min(32, Random(maxDrops))) downto 0 do 
4578  205 
begin 
5336
174734adc06b
Store gear X/Y/dX/dY for use in splash/droplets. Also saves a few hwRound calls.
nemo
parents:
5313
diff
changeset

206 
particle := AddVisualGear(X  3 + Random(6), cWaterLine, vgtDroplet); 
3454
a9bef74bd6e0
Code restlyling: experimental restyling of one module
mbait
parents:
3440
diff
changeset

207 
if particle <> nil then 
4578  208 
begin 
5336
174734adc06b
Store gear X/Y/dX/dY for use in splash/droplets. Also saves a few hwRound calls.
nemo
parents:
5313
diff
changeset

209 
particle^.dX := particle^.dX  vdX / 10; 
174734adc06b
Store gear X/Y/dX/dY for use in splash/droplets. Also saves a few hwRound calls.
nemo
parents:
5313
diff
changeset

210 
particle^.dY := particle^.dY  vdY / 5; 
4578  211 
end 
2982  212 
end 
4578  213 
end; 
3907
5b516f0d9957
Allow UFO to go underwater. Keep UFO active if it runs out of fuel in the air/water, just disable controls.
nemo
parents:
3894
diff
changeset

214 
if isSubmersible and (CurAmmoGear^.Pos = 0) then CurAmmoGear^.Pos := 1000 
5336
174734adc06b
Store gear X/Y/dX/dY for use in splash/droplets. Also saves a few hwRound calls.
nemo
parents:
5313
diff
changeset

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

216 
else 
3907
5b516f0d9957
Allow UFO to go underwater. Keep UFO active if it runs out of fuel in the air/water, just disable controls.
nemo
parents:
3894
diff
changeset

217 
CheckGearDrowning := false; 
4  218 
end; 
219 

4397
ab577db125c4
Disable rope attach to hogs/crates/barrels etc. Should fix a bug in collision according to unc0rr
nemo
parents:
4396
diff
changeset

220 
procedure CheckCollision(Gear: PGear); inline; 
4  221 
begin 
6131  222 
if TestCollisionXwithGear(Gear, hwSign(Gear^.dX)) or (TestCollisionYwithGear(Gear, hwSign(Gear^.dY)) <> 0) then 
223 
Gear^.State := Gear^.State or gstCollision 

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

224 
else Gear^.State := Gear^.State and not gstCollision 
4  225 
end; 
226 

4798  227 
procedure CheckCollisionWithLand(Gear: PGear); inline; 
228 
begin 

4802
4c1041eef577
fix very ancient typo in CheckCollision() that would cause check for collision at bottom and right instead of movement direction
sheepluva
parents:
4801
diff
changeset

229 
if TestCollisionX(Gear, hwSign(Gear^.dX)) or TestCollisionY(Gear, hwSign(Gear^.dY) 
4798  230 
) 
231 
then Gear^.State := Gear^.State or gstCollision 

232 
else Gear^.State := Gear^.State and not gstCollision 

233 
end; 

234 

4  235 
procedure CheckHHDamage(Gear: PGear); 
2848  236 
var 
2948
3f21a9dc93d0
Replace tabs with spaces using 'expand t 4' command
unc0rr
parents:
2944
diff
changeset

237 
dmg: Longword; 
3f21a9dc93d0
Replace tabs with spaces using 'expand t 4' command
unc0rr
parents:
2944
diff
changeset

238 
i: LongInt; 
3f21a9dc93d0
Replace tabs with spaces using 'expand t 4' command
unc0rr
parents:
2944
diff
changeset

239 
particle: PVisualGear; 
4  240 
begin 
3454
a9bef74bd6e0
Code restlyling: experimental restyling of one module
mbait
parents:
3440
diff
changeset

241 
if _0_4 < Gear^.dY then 
4578  242 
begin 
3454
a9bef74bd6e0
Code restlyling: experimental restyling of one module
mbait
parents:
3440
diff
changeset

243 
dmg := ModifyDamage(1 + hwRound((hwAbs(Gear^.dY)  _0_4) * 70), Gear); 
3851  244 
PlaySound(sndBump); 
3454
a9bef74bd6e0
Code restlyling: experimental restyling of one module
mbait
parents:
3440
diff
changeset

245 
if dmg < 1 then exit; 
a9bef74bd6e0
Code restlyling: experimental restyling of one module
mbait
parents:
3440
diff
changeset

246 

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

247 
for i:= min(12, (3 + dmg div 10)) downto 0 do 
4578  248 
begin 
249 
particle := AddVisualGear(hwRound(Gear^.X)  5 + Random(10), hwRound(Gear^.Y) + 12, vgtDust); 

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

250 
if particle <> nil then particle^.dX := particle^.dX + (Gear^.dX.QWordValue / 21474836480); 
4578  251 
end; 
2871
eec42a0b7014
rearrange fall damage a bit so invulnerability still causes dust
nemo
parents:
2859
diff
changeset

252 

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

253 
if (Gear^.Invulnerable) then exit; 
a9bef74bd6e0
Code restlyling: experimental restyling of one module
mbait
parents:
3440
diff
changeset

254 

3682  255 
//if _0_6 < Gear^.dY then 
4365  256 
// PlaySound(sndOw4, Gear^.Hedgehog^.Team^.voicepack) 
3682  257 
//else 
4365  258 
// PlaySound(sndOw1, Gear^.Hedgehog^.Team^.voicepack); 
3682  259 

5063  260 
if Gear^.LastDamage <> nil then 
261 
ApplyDamage(Gear, Gear^.LastDamage, dmg, dsFall) 

262 
else 

263 
ApplyDamage(Gear, CurrentHedgehog, dmg, dsFall); 

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

264 
end 
4  265 
end; 
266 

267 
//////////////////////////////////////////////////////////////////////////////// 

268 
procedure CalcRotationDirAngle(Gear: PGear); 

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

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

270 
dAngle: real; 
4  271 
begin 
3454
a9bef74bd6e0
Code restlyling: experimental restyling of one module
mbait
parents:
3440
diff
changeset

272 
dAngle := (Gear^.dX.QWordValue + Gear^.dY.QWordValue) / $80000000; 
a9bef74bd6e0
Code restlyling: experimental restyling of one module
mbait
parents:
3440
diff
changeset

273 
if not Gear^.dX.isNegative then 
a9bef74bd6e0
Code restlyling: experimental restyling of one module
mbait
parents:
3440
diff
changeset

274 
Gear^.DirAngle := Gear^.DirAngle + dAngle 
a9bef74bd6e0
Code restlyling: experimental restyling of one module
mbait
parents:
3440
diff
changeset

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

276 
Gear^.DirAngle := Gear^.DirAngle  dAngle; 
a9bef74bd6e0
Code restlyling: experimental restyling of one module
mbait
parents:
3440
diff
changeset

277 

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

278 
if Gear^.DirAngle < 0 then Gear^.DirAngle := Gear^.DirAngle + 360 
a9bef74bd6e0
Code restlyling: experimental restyling of one module
mbait
parents:
3440
diff
changeset

279 
else if 360 < Gear^.DirAngle then Gear^.DirAngle := Gear^.DirAngle  360 
4  280 
end; 
281 

282 
//////////////////////////////////////////////////////////////////////////////// 

283 
procedure doStepDrowningGear(Gear: PGear); 

284 
begin 

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

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

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

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

288 
// Create some bubbles (0.5% might be better but causes too few bubbles sometimes) 
4792
68f9b331014a
sudden death changes: only change visual bit on health decrease and support for water transparancy change and clouds number change
Henek
parents:
4791
diff
changeset

289 
if ((not SuddenDeathDmg and (cWaterOpacity < $FF)) or (SuddenDeathDmg and (cSDWaterOpacity < $FF))) and ((GameTicks and $1F) = 0) then 
3454
a9bef74bd6e0
Code restlyling: experimental restyling of one module
mbait
parents:
3440
diff
changeset

290 
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

291 
AddVisualGear(hwRound(Gear^.X)  Gear^.Radius, hwRound(Gear^.Y)  Gear^.Radius, vgtBubble) 
2225  292 
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

293 
AddVisualGear(hwRound(Gear^.X)  Gear^.Radius, hwRound(Gear^.Y)  Gear^.Radius, vgtBubble); 
5f55e9202122
Fix crasher. thanks to dagni for the demo file that tracked it down.
nemo
parents:
5480
diff
changeset

294 
if (not SuddenDeathDmg and (cWaterOpacity > $FE)) or (SuddenDeathDmg and (cSDWaterOpacity > $FE)) or (hwRound(Gear^.Y) > Gear^.Radius + cWaterLine + cVisibleWater) then 
5f55e9202122
Fix crasher. thanks to dagni for the demo file that tracked it down.
nemo
parents:
5480
diff
changeset

295 
DeleteGear(Gear); 
4  296 
end; 
297 

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

299 
procedure doStepFallingGear(Gear: PGear); 

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

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

301 
isFalling: boolean; 
3020  302 
//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

303 
tdX, tdY: hwFloat; 
3001  304 
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

305 
land: word; 
4  306 
begin 
3915
c05855146440
Correct bug in flight ceiling for birdy as well, increase clip on velocity to 1.9 (shouldn't cause problems with most collision checks still), apply clip to both + and 
nemo
parents:
3909
diff
changeset

307 
// clip velocity at 1.9  over 1 per pixel, but really shouldn't cause many actual problems. 
c05855146440
Correct bug in flight ceiling for birdy as well, increase clip on velocity to 1.9 (shouldn't cause problems with most collision checks still), apply clip to both + and 
nemo
parents:
3909
diff
changeset

308 
if Gear^.dX.QWordValue > 8160437862 then Gear^.dX.QWordValue:= 8160437862; 
c05855146440
Correct bug in flight ceiling for birdy as well, increase clip on velocity to 1.9 (shouldn't cause problems with most collision checks still), apply clip to both + and 
nemo
parents:
3909
diff
changeset

309 
if Gear^.dY.QWordValue > 8160437862 then Gear^.dY.QWordValue:= 8160437862; 
3454
a9bef74bd6e0
Code restlyling: experimental restyling of one module
mbait
parents:
3440
diff
changeset

310 
Gear^.State := Gear^.State and not gstCollision; 
a9bef74bd6e0
Code restlyling: experimental restyling of one module
mbait
parents:
3440
diff
changeset

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

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

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

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

315 

503  316 

3359  317 
// might need some testing/adjustments  just to avoid projectiles to fly forever (accelerated by wind/skips) 
3609
bc63ed514b70
Minor fire tweak for readability and lethalness, remove exit condition that was hanging game (identified by jaylittle)
nemo
parents:
3603
diff
changeset

318 
if (hwRound(Gear^.X) < LAND_WIDTH div 2) or (hwRound(Gear^.X) > LAND_WIDTH * 3 div 2) then Gear^.State := Gear^.State or gstCollision; 
3359  319 

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

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

322 
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

323 
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

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

326 
collV := 1; 
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

327 
if land and lfIce <> 0 then Gear^.dX := Gear^.dX * (_1  (_1  Gear^.Friction) / _10) 
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

328 
else Gear^.dX := Gear^.dX * Gear^.Friction; 
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

329 

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

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

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

333 
else if (Gear^.AdvBounce=1) and (TestCollisionYwithGear(Gear, 1) <> 0) then collV := 1; 
4578  334 
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

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

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

337 
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

338 
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

339 
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

340 
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

341 
isFalling := false; 
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

342 
if land and lfIce <> 0 then Gear^.dX := Gear^.dX * (_1  (_1  Gear^.Friction) / _10) 
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

343 
else Gear^.dX := Gear^.dX * Gear^.Friction; 
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

344 

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

345 
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

346 
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

347 
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

348 
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

349 
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

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

351 
if (Gear^.AdvBounce=1) and not Gear^.dY.isNegative and (TestCollisionYwithGear(Gear, 1) <> 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

352 
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

353 
end 
4578  354 
end; 
503  355 

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

356 

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

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

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

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

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

362 
Gear^.State := Gear^.State or gstCollision 
4578  363 
end 
6131  364 
else if (Gear^.AdvBounce=1) and TestCollisionXwithGear(Gear, hwSign(Gear^.dX)) then 
3454
a9bef74bd6e0
Code restlyling: experimental restyling of one module
mbait
parents:
3440
diff
changeset

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

366 
//if Gear^.AdvBounce and (collV <>0) and (collH <> 0) and (hwSqr(tdX) + hwSqr(tdY) > _0_08) then 
a9bef74bd6e0
Code restlyling: experimental restyling of one module
mbait
parents:
3440
diff
changeset

367 
if (Gear^.AdvBounce=1) and (collV <>0) and (collH <> 0) and ((collV=1) or ((tdX.QWordValue + 
a9bef74bd6e0
Code restlyling: experimental restyling of one module
mbait
parents:
3440
diff
changeset

368 
tdY.QWordValue) > _0_2.QWordValue)) then 
4578  369 
begin 
3454
a9bef74bd6e0
Code restlyling: experimental restyling of one module
mbait
parents:
3440
diff
changeset

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

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

372 
//*Gear^.Friction; 
a9bef74bd6e0
Code restlyling: experimental restyling of one module
mbait
parents:
3440
diff
changeset

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

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

375 
Gear^.AdvBounce := 10; 
4578  376 
end; 
503  377 

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

378 
if Gear^.AdvBounce > 1 then dec(Gear^.AdvBounce); 
a9bef74bd6e0
Code restlyling: experimental restyling of one module
mbait
parents:
3440
diff
changeset

379 

6131  380 
if isFalling then 
4299  381 
begin 
382 
Gear^.dY := Gear^.dY + cGravity; 

4602
ec84fb564bab
added density for gears used in gfMoreWind, needs alot of tweaking
Henek
parents:
4582
diff
changeset

383 
if (GameFlags and gfMoreWind) <> 0 then Gear^.dX := Gear^.dX + cWindSpeed / Gear^.Density 
4299  384 
end; 
3454
a9bef74bd6e0
Code restlyling: experimental restyling of one module
mbait
parents:
3440
diff
changeset

385 

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

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

387 
Gear^.Y := Gear^.Y + Gear^.dY; 
6251  388 
if Gear^.Kind <> gtBee then 
389 
CheckGearDrowning(Gear); 

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

390 
//if (hwSqr(Gear^.dX) + hwSqr(Gear^.dY) < _0_0002) and 
a9bef74bd6e0
Code restlyling: experimental restyling of one module
mbait
parents:
3440
diff
changeset

391 
if ((Gear^.dX.QWordValue + Gear^.dY.QWordValue) < _0_02.QWordValue) and 
a9bef74bd6e0
Code restlyling: experimental restyling of one module
mbait
parents:
3440
diff
changeset

392 
(not isFalling) then 
a9bef74bd6e0
Code restlyling: experimental restyling of one module
mbait
parents:
3440
diff
changeset

393 
Gear^.State := Gear^.State and not gstMoving 
a9bef74bd6e0
Code restlyling: experimental restyling of one module
mbait
parents:
3440
diff
changeset

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

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

396 

5470  397 
if (Gear^.nImpactSounds > 0) and 
5688
fba59d6b5b6c
Correctly check for failure to look up ammo, check for damaged mines
nemo
parents:
5684
diff
changeset

398 
(((Gear^.Kind <> gtMine) and (Gear^.Damage <> 0)) or 
5461  399 
((Gear^.State and (gstCollision or gstMoving)) = (gstCollision or gstMoving))) and 
5606
75916086afa3
Special case small radius gears to try and prevent repeated collisions.
nemo
parents:
5594
diff
changeset

400 
(((Gear^.Radius < 3) and (Gear^.dY < _0_1)) or 
75916086afa3
Special case small radius gears to try and prevent repeated collisions.
nemo
parents:
5594
diff
changeset

401 
((Gear^.Radius >= 3) and ((Gear^.dX.QWordValue > _0_1.QWordValue) or 
75916086afa3
Special case small radius gears to try and prevent repeated collisions.
nemo
parents:
5594
diff
changeset

402 
(Gear^.dY.QWordValue > _0_1.QWordValue)))) then 
5461  403 
PlaySound(TSound(ord(Gear^.ImpactSound) + LongInt(GetRandom(Gear^.nImpactSounds))), true); 
4  404 
end; 
405 

406 
//////////////////////////////////////////////////////////////////////////////// 

407 
procedure doStepBomb(Gear: PGear); 

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

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

409 
i, x, y: LongInt; 
919  410 
dX, dY: hwFloat; 
3475  411 
vg: PVisualGear; 
4  412 
begin 
3454
a9bef74bd6e0
Code restlyling: experimental restyling of one module
mbait
parents:
3440
diff
changeset

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

414 

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

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

416 

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

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

418 
if Gear^.Timer = 1000 then // might need adjustments 
a9bef74bd6e0
Code restlyling: experimental restyling of one module
mbait
parents:
3440
diff
changeset

419 
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

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

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

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

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

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

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

426 

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

427 
if (Gear^.Kind = gtBall) and ((Gear^.State and gstTmpFlag) <> 0) then 
a9bef74bd6e0
Code restlyling: experimental restyling of one module
mbait
parents:
3440
diff
changeset

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

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

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

431 
doMakeExplosion(hwRound(Gear^.X), hwRound(Gear^.Y), 20, Gear^.Hedgehog, EXPLDontDraw or EXPLNoGfx); 
2948
3f21a9dc93d0
Replace tabs with spaces using 'expand t 4' command
unc0rr
parents:
2944
diff
changeset

432 
end; 
3004  433 

3475  434 
if (Gear^.Kind = gtGasBomb) and ((GameTicks mod 200) = 0) then 
435 
begin 

436 
vg:= AddVisualGear(hwRound(Gear^.X), hwRound(Gear^.Y), vgtSmokeWhite); 

437 
if vg <> nil then 

438 
vg^.Tint:= $FFC0C000; 

439 
end; 

440 

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

441 
if Gear^.Timer = 0 then 
2948
3f21a9dc93d0
Replace tabs with spaces using 'expand t 4' command
unc0rr
parents:
2944
diff
changeset

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

443 
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

444 
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

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

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

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

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

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

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

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

452 
begin 
3505  453 
dX := rndSign(GetRandom * _0_1) + Gear^.dX / 5; 
3476
1ec68b8d3bd1
Henek adds a flamethrower, updates some translations, and tweaks how fire works.
nemo
parents:
3475
diff
changeset

454 
dY := (GetRandom  _3) * _0_08; 
6120  455 
FollowGear := AddGear(x, y, gtCluster, 0, dX, dY, 25) 
3476
1ec68b8d3bd1
Henek adds a flamethrower, updates some translations, and tweaks how fire works.
nemo
parents:
3475
diff
changeset

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

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

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

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

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

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

462 
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

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

464 
begin 
3505  465 
dX := rndSign(GetRandom * _0_1) + Gear^.dX / 5; 
3476
1ec68b8d3bd1
Henek adds a flamethrower, updates some translations, and tweaks how fire works.
nemo
parents:
3475
diff
changeset

466 
dY := (GetRandom  _1_5) * _0_3; 
6120  467 
FollowGear:= AddGear(x, y, gtMelonPiece, 0, dX, dY, 75); 
468 
FollowGear^.DirAngle := i * 60 

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

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

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

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

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

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

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

475 
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

476 

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

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

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

479 
dX := AngleCos(i * 16) * _0_5 * (GetRandom + _1); 
1ec68b8d3bd1
Henek adds a flamethrower, updates some translations, and tweaks how fire works.
nemo
parents:
3475
diff
changeset

480 
dY := AngleSin(i * 16) * _0_5 * (GetRandom + _1); 
6131  481 
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

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

483 
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

484 
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

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

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

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

488 
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

489 
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

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

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

492 
end; 
3712  493 
gtGasBomb: 
494 
begin 

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

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

497 
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

498 
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

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

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

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

504 
DeleteGear(Gear); 
1ec68b8d3bd1
Henek adds a flamethrower, updates some translations, and tweaks how fire works.
nemo
parents:
3475
diff
changeset

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

506 
end; 
1263  507 

4  508 
CalcRotationDirAngle(Gear); 
1263  509 

510 
if Gear^.Kind = gtHellishBomb then 

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

511 
begin 
3118  512 

513 
if Gear^.Timer = 3000 then 

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

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

515 
Gear^.nImpactSounds := 0; 
3118  516 
PlaySound(sndHellish); 
3454
a9bef74bd6e0
Code restlyling: experimental restyling of one module
mbait
parents:
3440
diff
changeset

517 
end; 
1279  518 

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

519 
if (GameTicks and $3F) = 0 then 
3f21a9dc93d0
Replace tabs with spaces using 'expand t 4' command
unc0rr
parents:
2944
diff
changeset

520 
if (Gear^.State and gstCollision) = 0 then 
3440
dee31c5149e0
* gtHealthTag, gtSmokeTrace, gtEvilTrace, gtExplosion and gtBigExplosion are visual gears now (vgt*)
sheepluva
parents:
3431
diff
changeset

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

522 
end; 
4  523 
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

524 

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

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

526 
procedure doStepMolotov(Gear: PGear); 
3454
a9bef74bd6e0
Code restlyling: experimental restyling of one module
mbait
parents:
3440
diff
changeset

527 
var 
6011
519f8a58c021
Fix a bunch of warnings (also improves speed a bit in 32 bit code)
unC0Rr
parents:
6002
diff
changeset

528 
s: Longword; 
3454
a9bef74bd6e0
Code restlyling: experimental restyling of one module
mbait
parents:
3440
diff
changeset

529 
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

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

531 
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

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

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

534 

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

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

536 
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

537 

5870  538 
// let's add some smoke depending on speed 
6011
519f8a58c021
Fix a bunch of warnings (also improves speed a bit in 32 bit code)
unC0Rr
parents:
6002
diff
changeset

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

540 
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

541 
begin 
5873  542 
// adjust angle to match the texture 
543 
if Gear^.dX.isNegative then i:= 130 else i:= 50; 

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

5871
09daa06191d7
Since we are tweaking molotov. make the flame flickery and add a drowning frame
nemo
parents:
5870
diff
changeset

545 
if smoke <> nil then smoke^.Scale:= 0.75; 
09daa06191d7
Since we are tweaking molotov. make the flame flickery and add a drowning frame
nemo
parents:
5870
diff
changeset

546 
end; 
5870  547 

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

548 
if (Gear^.State and gstCollision) <> 0 then 
a9bef74bd6e0
Code restlyling: experimental restyling of one module
mbait
parents:
3440
diff
changeset

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

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

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

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

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

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

555 
(*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

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

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

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

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

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

561 
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

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

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

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

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

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

568 
Tint:= $41B83ED0  i * $10081000; 
82fc26c53d2a
Tweak sparkles, glass. Left glass commented out in case he prefers old behaviour.
nemo
parents:
5922
diff
changeset

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

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

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

572 
if random(2) = 0 then dx := dx; 
82fc26c53d2a
Tweak sparkles, glass. Left glass commented out in case he prefers old behaviour.
nemo
parents:
5922
diff
changeset

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

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

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

576 
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

577 
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

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

579 
dX := AngleCos(i * 2) * ((_0_15*(i div 5))) * (GetRandom + _1); 
3454
a9bef74bd6e0
Code restlyling: experimental restyling of one module
mbait
parents:
3440
diff
changeset

580 
dY := AngleSin(i * 8) * _0_5 * (GetRandom + _1); 
6126
61c1161ee32f
Remove unnecessary assignments postcreation. Simplifies Lua manipulation of these adds as well as just being tidier.
nemo
parents:
6122
diff
changeset

581 
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

582 
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

583 
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

584 
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

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

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

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

588 
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

589 
end; 
4  590 

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

591 
//////////////////////////////////////////////////////////////////////////////// 
1279  592 

78  593 
procedure doStepCluster(Gear: PGear); 
594 
begin 

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

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

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

597 
if (Gear^.State and gstCollision) <> 0 then 
2948
3f21a9dc93d0
Replace tabs with spaces using 'expand t 4' command
unc0rr
parents:
2944
diff
changeset

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

599 
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

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

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

602 
end; 
1262  603 

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

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

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

606 
else if (GameTicks and $1F) = 0 then 
3440
dee31c5149e0
* gtHealthTag, gtSmokeTrace, gtEvilTrace, gtExplosion and gtBigExplosion are visual gears now (vgt*)
sheepluva
parents:
3431
diff
changeset

607 
AddVisualGear(hwRound(Gear^.X), hwRound(Gear^.Y), vgtSmokeTrace) 
78  608 
end; 
609 

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

613 
AllInactive := false; 
4272
cf18de7ea3d4
engine side of a more wind patch. no frontend hook. just want to check it in to pull it from another machine
nemo
parents:
4265
diff
changeset

614 
if (GameFlags and gfMoreWind) = 0 then Gear^.dX := Gear^.dX + cWindSpeed; 
3454
a9bef74bd6e0
Code restlyling: experimental restyling of one module
mbait
parents:
3440
diff
changeset

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

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

618 
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

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

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

622 
if (GameTicks and $3F) = 0 then 
a9bef74bd6e0
Code restlyling: experimental restyling of one module
mbait
parents:
3440
diff
changeset

623 
AddVisualGear(hwRound(Gear^.X), hwRound(Gear^.Y), vgtSmokeTrace); 
95  624 
end; 
625 

4  626 
//////////////////////////////////////////////////////////////////////////////// 
4578  627 
procedure doStepSnowball(Gear: PGear); 
628 
var kick, i: LongInt; 

629 
particle: PVisualGear; 

630 
begin 

631 
AllInactive := false; 

632 
if (GameFlags and gfMoreWind) = 0 then Gear^.dX := Gear^.dX + cWindSpeed; 

633 
doStepFallingGear(Gear); 

634 
CalcRotationDirAngle(Gear); 

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

636 
begin 

637 
kick:= hwRound((hwAbs(Gear^.dX)+hwAbs(Gear^.dY)) * _20); 

638 
Gear^.dY.isNegative:= not Gear^.dY.isNegative; 

639 
Gear^.dX.isNegative:= not Gear^.dX.isNegative; 

640 
AmmoShove(Gear, 1, kick); 

641 
for i:= 15 + kick div 10 downto 0 do 

642 
begin 

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

644 
if particle <> nil then particle^.dX := particle^.dX + (Gear^.dX.QWordValue / 21474836480) 

645 
end; 

646 
DeleteGear(Gear); 

647 
exit 

648 
end; 

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

650 
begin 

4582  651 
particle:= AddVisualGear(hwRound(Gear^.X), hwRound(Gear^.Y), vgtDust); 
4578  652 
if particle <> nil then particle^.dX := particle^.dX + (Gear^.dX.QWordValue / 21474836480) 
653 
end 

654 
end; 

655 

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

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

658 
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

659 
move, draw, allpx, gun: Boolean; 
4611  660 
s: PSDL_Surface; 
661 
p: PLongwordArray; 

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

665 
gun:= (Gear^.State and gstTmpFlag) <> 0; 
5024  666 
move:= false; 
667 
draw:= false; 

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

668 
if gun then 
5024  669 
begin 
5461  670 
Gear^.State:= Gear^.State and not gstInvisible; 
5024  671 
doStepFallingGear(Gear); 
672 
CheckCollision(Gear); 

673 
if ((Gear^.State and gstCollision) <> 0) or ((Gear^.State and gstMoving) = 0) then draw:= true; 

674 
xx:= hwRound(Gear^.X); 

675 
yy:= hwRound(Gear^.Y); 

676 
end 

677 
else if GameTicks and $7 = 0 then 

4611  678 
begin 
679 
with Gear^ do 

680 
begin 

5348
0bc81de36e08
Don't draw snow flakes spawned in land, introduce gstInvisible flag
unc0rr
parents:
5342
diff
changeset

681 
State:= State and not gstInvisible; 
5355  682 
X:= X + cWindSpeed * 3200 + dX; 
4611  683 
Y:= Y + dY + cGravity * vobFallSpeed * 8; // using same value as flakes to try and get similar results 
684 
xx:= hwRound(X); 

685 
yy:= hwRound(Y); 

686 
if vobVelocity <> 0 then 

687 
begin 

4621  688 
DirAngle := DirAngle + (Angle / 1250000000); 
4611  689 
if DirAngle < 0 then DirAngle := DirAngle + 360 
690 
else if 360 < DirAngle then DirAngle := DirAngle  360; 

691 
end; 

692 

693 
inc(Health, 8); 

5186  694 
if longword(Health) > vobFrameTicks then 
4611  695 
begin 
696 
dec(Health, vobFrameTicks); 

697 
inc(Timer); 

698 
if Timer = vobFramesCount then Timer:= 0 

699 
end; 

700 
// move back to cloud layer 

701 
if yy > cWaterLine then move:= true 

5340
6963e37f2dd2
 Allow snow to drop a bit outside the map, where it already is allowed to spawn
unc0rr
parents:
5336
diff
changeset

702 
else if ((yy and LAND_HEIGHT_MASK) <> 0) or (xx > LAND_WIDTH + 512) or (xx < 512) then move:=true 
4791  703 
// Solid pixel encountered 
5342  704 
else if ((xx and LAND_WIDTH_MASK) = 0) and (Land[yy, xx] <> 0) then 
4611  705 
begin 
5693  706 
lf:= Land[yy, xx] and (lfObject or lfBasic); 
4791  707 
// If there's room below keep falling 
708 
if (((yy1) and LAND_HEIGHT_MASK) = 0) and (Land[yy1, xx] = 0) then 

709 
begin 

710 
X:= X  cWindSpeed * 1600  dX; 

711 
end 

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

713 
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 

714 
begin 

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

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

717 
end 

718 
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 

719 
begin 

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

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

722 
end 

723 
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 

724 
begin 

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

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

727 
end 

728 
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 

729 
begin 

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

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

732 
end 

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

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

734 
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

735 
then move:=true 
5024  736 
else draw:= true 
737 
end 

738 
end 

739 
end; 

6131  740 
if draw then 
5024  741 
with Gear^ do 
742 
begin 

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

744 
move:= true; 

5695  745 
if (Pos > 20) and ((CurAmmoGear = nil) or (CurAmmoGear^.Kind <> gtRope)) then 
5024  746 
begin 
747 
////////////////////////////////// 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

748 
if not gun then 
5024  749 
begin 
750 
dec(yy,3); 

751 
dec(xx,1) 

752 
end; 

753 
s:= SpritesData[sprSnow].Surface; 

754 
p:= s^.pixels; 

755 
allpx:= true; 

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

757 
begin 

758 
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

759 
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

760 
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

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

763 
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

764 
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

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

766 
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

767 
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

768 
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

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

770 
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

771 
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

772 
LandDirty[yy div 32, xx div 32]:= 1; 
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

773 
if LandPixels[ry, rx] = 0 then Land[ly, lx]:= lfDamaged or lfObject 
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

774 
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

775 
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

776 
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

777 
if gun then 
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

778 
LandPixels[ry, rx]:= (cExplosionBorderColor and not AMask) or (p^[px] and AMask) 
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

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

781 
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

782 
end; 
5024  783 
p:= @(p^[s^.pitch shr 2]) 
784 
end; 

785 

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

786 
// Why is this here. For one thing, there's no test on +1 being safe. 
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

787 
//Land[py, px+1]:= lfBasic; 
5024  788 

789 
if allpx then UpdateLandTexture(xx, Pred(s^.h), yy, Pred(s^.w)) 

4791  790 
else 
4611  791 
begin 
5024  792 
UpdateLandTexture( 
793 
max(0, min(LAND_WIDTH, xx)), 

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

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

796 
min(LAND_HEIGHT  yy, Pred(s^.h)) 

797 
); 

4791  798 
end; 
5024  799 
////////////////////////////////// TODO  ASK UNC0RR FOR A GOOD HOME FOR THIS //////////////////////////////////// 
4611  800 
end 
5024  801 
end; 
802 

803 
if move then 

804 
begin 

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

805 
if gun then 
5024  806 
begin 
807 
DeleteGear(Gear); 

808 
exit 

809 
end; 

5695  810 
Gear^.Pos:= 0; 
5024  811 
Gear^.X:= int2hwFloat(GetRandom(LAND_WIDTH+1024)512); 
5413  812 
Gear^.Y:= int2hwFloat(750+(GetRandom(50)25)); 
813 
Gear^.State:= Gear^.State or gstInvisible; 

4611  814 
end 
815 
end; 

816 

4578  817 
//////////////////////////////////////////////////////////////////////////////// 
4  818 
procedure doStepGrave(Gear: PGear); 
819 
begin 

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

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

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

822 
if TestCollisionY(Gear, 1) then Gear^.dY := _0; 
a9bef74bd6e0
Code restlyling: experimental restyling of one module
mbait
parents:
3440
diff
changeset

823 

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

824 
if not Gear^.dY.isNegative then 
a9bef74bd6e0
Code restlyling: experimental restyling of one module
mbait
parents:
3440
diff
changeset

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

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

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

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

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

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

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

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

833 
else if Gear^.dY <  _0_03 then PlaySound(Gear^.ImpactSound) 
a9bef74bd6e0
Code restlyling: experimental restyling of one module
mbait
parents:
3440
diff
changeset

834 
end; 
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 
Gear^.Y := Gear^.Y + Gear^.dY; 
a9bef74bd6e0
Code restlyling: experimental restyling of one module
mbait
parents:
3440
diff
changeset

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

838 
Gear^.dY := Gear^.dY + cGravity 
4  839 
end; 
840 

841 
//////////////////////////////////////////////////////////////////////////////// 

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

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

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

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

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

848 

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

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

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

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

855 

856 
// if water entered or left 

857 
if nuw <> uw then 

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

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

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

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

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

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

864 
StopSound(Gear^.SoundChannel); 
6251  865 
if nuw then 
3454
a9bef74bd6e0
Code restlyling: experimental restyling of one module
mbait
parents:
3440
diff
changeset

866 
begin 
6251  867 
Gear^.SoundChannel := LoopSound(sndBeeWater); 
868 
Gear^.Tag := 1; 

869 
end 

870 
else 

871 
begin 

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

872 
Gear^.SoundChannel := LoopSound(sndBee); 
6251  873 
Gear^.Tag := 0; 
3454
a9bef74bd6e0
Code restlyling: experimental restyling of one module
mbait
parents:
3440
diff
changeset

874 
end; 
6251  875 
end; 
876 

877 

878 
if Gear^.Timer = 0 then 

879 
Gear^.RenderTimer:= false 

880 
else 

3591  881 
begin 
6251  882 
if (GameTicks and $F) = 0 then 
883 
begin 

884 
if (GameTicks and $30) = 0 then 

885 
AddVisualGear(gX, gY, vgtBeeTrace); 

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

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

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

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

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

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

892 
end; 

893 

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

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

896 

3591  897 
end; 
898 

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

899 

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

900 
CheckCollision(Gear); 
6251  901 
if ((Gear^.State and gstCollision) <> 0) then 
3454
a9bef74bd6e0
Code restlyling: experimental restyling of one module
mbait
parents:
3440
diff
changeset

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

903 
StopSound(Gear^.SoundChannel); 
4837
2ea0a152c319
Pass PHedgehog instead of PGear to stats. Fixes crash.
unc0rr
parents:
4824
diff
changeset

904 
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

905 
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

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

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

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

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

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

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

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

914 
if random(2) = 0 then dx := dx; 
70d7f8e40f53
Just for fun. Flowers! Also, use a less blatant image in ammo menu.
nemo
parents:
5738
diff
changeset

915 
if random(2) = 0 then dy := dy; 
70d7f8e40f53
Just for fun. Flowers! Also, use a less blatant image in ammo menu.
nemo
parents:
5738
diff
changeset

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

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

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

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

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

921 
end; 
6251  922 

923 
if (Gear^.Timer > 0) then 

924 
dec(Gear^.Timer) 

925 
else 

926 
begin 

927 
if nuw then 

928 
begin 

929 
StopSound(Gear^.SoundChannel); 

930 
CheckGearDrowning(Gear); 

931 
end 

932 
else 

933 
doStepFallingGear(Gear); 

934 
end; 

4  935 
end; 
936 

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

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

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

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

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

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

944 
if (Gear^.State and gstCollision) <> 0 then 
a9bef74bd6e0
Code restlyling: experimental restyling of one module
mbait
parents:
3440
diff
changeset

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

946 
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

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

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

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

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

951 
if Gear^.Timer = 0 then 
a9bef74bd6e0
Code restlyling: experimental restyling of one module
mbait
parents:
3440
diff
changeset

952 
begin 
4365  953 
Gear^.Hedgehog^.Gear^.Message:= Gear^.Hedgehog^.Gear^.Message and not gmAttack; 
954 
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

955 
AttackBar:= 0; 
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

956 

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

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

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

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

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

962 
end; 
4  963 
end; 
964 

965 
//////////////////////////////////////////////////////////////////////////////// 

876  966 
procedure doStepShotIdle(Gear: PGear); 
967 
begin 

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

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

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

970 
if Gear^.Timer > 75 then 
2948
3f21a9dc93d0
Replace tabs with spaces using 'expand t 4' command
unc0rr
parents:
2944
diff
changeset

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

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

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

974 
end 
876  975 
end; 
976 

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

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

979 
i: LongWord; 
2828  980 
shell: PVisualGear; 
4  981 
begin 
3454
a9bef74bd6e0
Code restlyling: experimental restyling of one module
mbait
parents:
3440
diff
changeset

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

983 

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

984 
if ((Gear^.State and gstAnimation) = 0) then 
2948
3f21a9dc93d0
Replace tabs with spaces using 'expand t 4' command
unc0rr
parents:
2944
diff
changeset

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

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

987 
if Gear^.Timer = 0 then 
2948
3f21a9dc93d0
Replace tabs with spaces using 'expand t 4' command
unc0rr
parents:
2944
diff
changeset

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

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

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

991 
if shell <> nil then 
a9bef74bd6e0
Code restlyling: experimental restyling of one module
mbait
parents:
3440
diff
changeset

992 
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

993 
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

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

995 
shell^.Frame := 0 
a9bef74bd6e0
Code restlyling: experimental restyling of one module
mbait
parents:
3440
diff
changeset

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

997 
Gear^.State := Gear^.State or gstAnimation 
2858  998 
end; 
3454
a9bef74bd6e0
Code restlyling: experimental restyling of one module
mbait
parents:
3440
diff
changeset

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

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

1001 
else inc(Gear^.Timer); 
876  1002 

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

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

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

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

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

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

1008 
if (Gear^.State and gstCollision) <> 0 then 
a9bef74bd6e0
Code restlyling: experimental restyling of one module
mbait
parents:
3440
diff
changeset

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

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

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

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

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

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

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

1016 

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

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

1018 
if (Gear^.State and gstDrowning) <> 0 then 
a9bef74bd6e0
Code restlyling: experimental restyling of one module
mbait
parents:
3440
diff
changeset

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

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

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

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

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

1024 
until i = 0; 
a9bef74bd6e0
Code restlyling: experimental restyling of one module
mbait
parents:
3440
diff
changeset

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

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

1027 
Gear^.doStep := @doStepShotIdle 
4  1028 
end; 
1029 

1030 
//////////////////////////////////////////////////////////////////////////////// 

5841  1031 
procedure spawnBulletTrail(Bullet: PGear); 
1032 
var oX, oY: hwFloat; 

1033 
VGear: PVisualGear; 

1034 
begin 

1035 
if Bullet^.PortalCounter = 0 then 

1036 
begin 

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

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

1039 
end 

1040 
else 

1041 
begin 

1042 
ox:= Bullet^.Elasticity; 

1043 
oy:= Bullet^.Friction; 

1044 
end; 

1045 

1046 
// Bullet trail 

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

1048 
if VGear <> nil then 

1049 
begin 

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

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

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

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

1054 

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

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

1057 
or (hwRound(Bullet^.Y) and LAND_HEIGHT_MASK <> 0) then 

1058 
// only extend if not under water 

1059 
if hwRound(Bullet^.Y) < cWaterLine then 

1060 
begin 

1061 
VGear^.dX := VGear^.dX + LAND_WIDTH * (VGear^.dX  VGear^.X); 

1062 
VGear^.dY := VGear^.dY + LAND_WIDTH * (VGear^.dY  VGear^.Y); 

1063 
end; 

1064 

1065 
VGear^.Timer := 200; 

1066 
end; 

1067 
end; 

1068 

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

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

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

1071 
i, x, y: LongWord; 
351  1072 
oX, oY: hwFloat; 
4327  1073 
VGear: PVisualGear; 
38  1074 
begin 
3454
a9bef74bd6e0
Code restlyling: experimental restyling of one module
mbait
parents:
3440
diff
changeset

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

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

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

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

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

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

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

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

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

1084 
y := hwRound(Gear^.Y); 
a9bef74bd6e0
Code restlyling: experimental restyling of one module
mbait
parents:
3440
diff
changeset

1085 
if ((y and LAND_HEIGHT_MASK) = 0) and ((x and LAND_WIDTH_MASK) = 0) 
a9bef74bd6e0
Code restlyling: experimental restyling of one module
mbait
parents:
3440
diff
changeset

1086 
and (Land[y, x] <> 0) then inc(Gear^.Damage); 
5841  1087 
// let's interrupt before a collision to give portals a chance to catch the bullet 
1088 
if (Gear^.Damage = 1) and (Gear^.Tag = 0) and (Land[y, x] > 255) then 

1089 
begin 

1090 
Gear^.Tag := 1; 

1091 
Gear^.Damage := 0; 

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

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

1094 
CheckGearDrowning(Gear); 

1095 
break; 

1096 
end 

1097 
else 

1098 
Gear^.Tag := 0; 

1099 

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

1100 
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

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

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

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

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

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

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

1107 
until (i = 0) or (Gear^.Damage > Gear^.Health) or ((Gear^.State and gstDrowning) <> 0); 
a9bef74bd6e0
Code restlyling: experimental restyling of one module
mbait
parents:
3440
diff
changeset

1108 
if Gear^.Damage > 0 then 
2994
7ae3067546f2
Palewolf adds bubbles and splashes when firing bullets into the water
nemo
parents:
2989
diff
changeset

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

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

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

1112 
Gear^.Damage := 0 
a9bef74bd6e0
Code restlyling: experimental restyling of one module
mbait
parents:
3440
diff
changeset

1113 
end; 
4792
68f9b331014a
sudden death changes: only change visual bit on health decrease and support for water transparancy change and clouds number change
Henek
parents:
4791
diff
changeset

1114 
if ((Gear^.State and gstDrowning) <> 0) and (Gear^.Damage < Gear^.Health) and ((not SuddenDeathDmg and (cWaterOpacity < $FF)) or (SuddenDeathDmg and (cSDWaterOpacity < $FF))) then 
3454
a9bef74bd6e0
Code restlyling: experimental restyling of one module
mbait
parents:
3440
diff
changeset

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

1116 
for i:=(Gear^.Health  Gear^.Damage) * 4 downto 0 do 
2994
7ae3067546f2
Palewolf adds bubbles and splashes when firing bullets into the water
nemo
parents:
2989
diff
changeset

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

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

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

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

1121 
Gear^.Y := Gear^.Y + Gear^.dY; 
2994
7ae3067546f2
Palewolf adds bubbles and splashes when firing bullets into the water
nemo
parents:
2989
diff
changeset

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

1123 
end; 
1760  1124 

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

1125 
if (Gear^.Health <= 0) 
a9bef74bd6e0
Code restlyling: experimental restyling of one module
mbait
parents:
3440
diff
changeset

1126 
or (hwRound(Gear^.X) and LAND_WIDTH_MASK <> 0) 
a9bef74bd6e0
Code restlyling: experimental restyling of one module
mbait
parents:
3440
diff
changeset

1127 
or (hwRound(Gear^.Y) and LAND_HEIGHT_MASK <> 0) then 
2031
b6f3e56fb100
david_ac's game scheme options for mine delay/quantity, tweaks to sniper rifle
nemo
parents:
2029
diff
changeset

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

1129 
if (Gear^.Kind = gtSniperRifleShot) and ((GameFlags and gfLaserSight) = 0) then 
a9bef74bd6e0
Code restlyling: experimental restyling of one module
mbait
parents:
3440
diff
changeset

1130 
cLaserSighting := false; 
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

1131 
if (Ammoz[Gear^.AmmoType].Ammo.NumPerTurn <= CurrentHedgehog^.MultiShootAttacks) and 
3454
a9bef74bd6e0
Code restlyling: experimental restyling of one module
mbait
parents:
3440
diff
changeset

1132 
((GameFlags and gfArtillery) = 0) then cArtillery := false; 
4279  1133 

4327  1134 
// Bullet Hit 
1135 
if (hwRound(Gear^.X) and LAND_WIDTH_MASK = 0) 

1136 
and (hwRound(Gear^.Y) and LAND_HEIGHT_MASK = 0) then 

1137 
begin 

1138 
VGear := AddVisualGear(hwRound(Gear^.X), hwRound(Gear^.Y), vgtBulletHit); 

1139 
if VGear <> nil then 

1140 
begin 

1141 
VGear^.Angle := DxDy2Angle(Gear^.dX, Gear^.dY); 

1142 
end; 

1143 
end; 

5076
b3bb27f4ba6b
workaround. disable drawing shot after passing through portal. proper fix would need to use the portal position
nemo
parents:
5067
diff
changeset

1144 

5841  1145 
spawnBulletTrail(Gear); 
3454
a9bef74bd6e0
Code restlyling: experimental restyling of one module
mbait
parents:
3440
diff
changeset

1146 
Gear^.doStep := @doStepShotIdle 
2031
b6f3e56fb100
david_ac's game scheme options for mine delay/quantity, tweaks to sniper rifle
nemo
parents:
2029
diff
changeset

1147 
end; 
37  1148 
end; 
1149 

559  1150 
procedure doStepDEagleShot(Gear: PGear); 
1151 
begin 

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

1152 
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

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

1154 
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

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

1156 
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

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

1158 

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

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

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

1161 
HHGear: PGear; 
2828  1162 
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

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

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

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

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

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

1169 
// game does not have default laser sight. turn it on and give them a chance to aim 
2023
41d3afaa20c7
Artillery mode, sniper rifle, speech bubble tweaks, fix of rope bug introduced by enabling hats in jump
nemo
parents:
2017
diff
changeset

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

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

1172 
HHGear^.Message := 0; 
a9bef74bd6e0
Code restlyling: experimental restyling of one module
mbait
parents:
3440
diff
changeset

1173 
if (HHGear^.Angle  32 >= 0) then dec(HHGear^.Angle,32) 
2031
b6f3e56fb100
david_ac's game scheme options for mine delay/quantity, tweaks to sniper rifle
nemo
parents:
2029
diff
changeset

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

1175 

3894  1176 
if (HHGear^.Message and gmAttack) <> 0 then 
2031
b6f3e56fb100
david_ac's game scheme options for mine delay/quantity, tweaks to sniper rifle
nemo
parents:
2029
diff
changeset

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

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

1179 
if shell <> nil then 
a9bef74bd6e0
Code restlyling: experimental restyling of one module
mbait
parents:
3440
diff
changeset

1180 
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

1181 
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

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

1183 
shell^.Frame := 1 
a9bef74bd6e0
Code restlyling: experimental restyling of one module
mbait
parents:
3440
diff
changeset

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

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

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

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

1188 
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

1189 
// add 3 initial steps to avoid problem with ammoshove related to calculation of radius + 1 radius as gear widths, and also just 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

1190 
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

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

1192 
Gear^.doStep := @doStepBulletWork; 
2024
2985f3bd18b7
Disable long jump in artillery mode, make snipre rifle single shot
nemo
parents:
2023
diff
changeset

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

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

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

1196 
if (GameTicks mod 4096) < 2048 then 
2052  1197 
begin 
3454
a9bef74bd6e0
Code restlyling: experimental restyling of one module
mbait
parents:
3440
diff
changeset

1198 
if (HHGear^.Angle + 1 <= cMaxAngle) then inc(HHGear^.Angle) 
2052  1199 
end 
3454
a9bef74bd6e0
Code restlyling: experimental restyling of one module
mbait
parents:
3440
diff
changeset

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

1201 
if (HHGear^.Angle  1 >= 0) then dec(HHGear^.Angle); 
a9bef74bd6e0
Code restlyling: experimental restyling of one module
mbait
parents:
3440
diff
changeset

1202 

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

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

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

1205 
else 
2058  1206 
begin 
3454
a9bef74bd6e0
Code restlyling: experimental restyling of one module
mbait
parents:
3440
diff
changeset

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

1208 
AfterAttack 
2058  1209 
end; 
559  1210 
end; 
1211 

37  1212 
//////////////////////////////////////////////////////////////////////////////// 
4  1213 
procedure doStepActionTimer(Gear: PGear); 
1214 
begin 

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

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

1216 
case Gear^.Kind of 
a9bef74bd6e0
Code restlyling: experimental restyling of one module
mbait
parents:
3440
diff
changeset

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

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

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

1220 
if Gear^.Timer = 0 then 
a9bef74bd6e0
Code restlyling: experimental restyling of one module
mbait
parents:
3440
diff
changeset

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

1222 
AddCaption(trmsg[sidStartFight], cWhiteColor, capgrpGameState); 
a9bef74bd6e0
Code restlyling: experimental restyling of one module
mbait
parents:
3440
diff
changeset

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

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

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

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

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

1228 
if Gear^.Timer = 1000 then 
a66d5141a3ba
fix build. seems like a indentationrelated mergeoopsy dragged deleted code back in.
sheepluva
parents:
5366
diff
changeset

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

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

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

1232 
ScreenFadeSpeed := 1; 
a66d5141a3ba
fix build. seems like a indentationrelated mergeoopsy dragged deleted code back in.
sheepluva
parents:
5366
diff
changeset

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

1234 
if Gear^.Timer = 0 then 
a66d5141a3ba
fix build. seems like a indentationrelated mergeoopsy dragged deleted code back in.
sheepluva
parents:
5366
diff
changeset

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

1236 
SendIPC('N'); 
a66d5141a3ba
fix build. seems like a indentationrelated mergeoopsy dragged deleted code back in.
sheepluva
parents:
5366
diff
changeset

1237 
SendIPC('q'); 
a66d5141a3ba
fix build. seems like a indentationrelated mergeoopsy dragged deleted code back in.
sheepluva
parents:
5366
diff
changeset

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

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

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

1241 
end; 
351  1242 
if Gear^.Timer = 0 then DeleteGear(Gear) 
4  1243 
end; 
1244 

1245 
//////////////////////////////////////////////////////////////////////////////// 

1246 
procedure doStepPickHammerWork(Gear: PGear); 

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

1247 
var 
4578  1248 
i, ei, x, y: LongInt; 
4  1249 
HHGear: PGear; 
1250 
begin 

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

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

1253 
dec(Gear^.Timer); 
5774
8512b9758f67
make pickhammer and blowtorch burn time for infinite attack mode
nemo
parents:
5750
diff
changeset

1254 
if ((GameFlags and gfInfAttack) <> 0) and (TurnTimeLeft > 0) then dec(TurnTimeLeft); 
5786  1255 
if (TurnTimeLeft = 0) or (Gear^.Timer = 0)or((Gear^.Message and gmDestroy) <> 0)or((HHGear^.State and gstHHDriven) = 
3454
a9bef74bd6e0
Code restlyling: experimental restyling of one module
mbait
parents:
3440
diff
changeset

1256 
0) then 
4578  1257 
begin 
3454
a9bef74bd6e0
Code restlyling: experimental restyling of one module
mbait
parents:
3440
diff
changeset

1258 
StopSound(Gear^.SoundChannel); 
a9bef74bd6e0
Code restlyling: experimental restyling of one module
mbait
parents:
3440
diff
changeset

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

1260 
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

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

1262 
exit 
4578  1263 
end; 
1264 

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

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

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

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

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

1270 
doMakeExplosion(x, y + 7, 6, Gear^.Hedgehog, EXPLDontDraw); 
3454
a9bef74bd6e0
Code restlyling: experimental restyling of one module
mbait
parents:
3440
diff
changeset

1271 
HHGear^.State := HHGear^.State and not gstNoDamage 
4578  1272 
end; 
422  1273 

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

1274 
if (Gear^.Timer mod 47) = 0 then 
4578  1275 
begin 
1276 
// 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  1277 
if (( (y + 12) and LAND_HEIGHT_MASK) = 0) and ((x and LAND_WIDTH_MASK) = 0) and (Land[y + 12, x] > 255) then 
4578  1278 
for i:= 0 to 1 do 
1279 
AddVisualGear(x  5 + Random(10), y + 12, vgtDust); 

1280 

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

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

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

1283 
while i <= ei do 
4578  1284 
begin 
1285 
DrawExplosion(i, y + 3, 3); 

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

1286 
inc(i, 1) 
4578  1287 
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

1288 

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

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

1292 
Gear^.Y := Gear^.Y + _1_9; 
4578  1293 
end; 
3454
a9bef74bd6e0
Code restlyling: experimental restyling of one module
mbait
parents:
3440
diff
changeset

1294 
SetAllHHToActive; 
4578  1295 
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

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

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

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

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

1302 
else 
4578  1303 
begin 
6389  1304 
if CheckLandValue(hwRound(Gear^.X), hwRound(Gear^.Y + Gear^.dY + cGravity), $FF00) then 
6314  1305 
begin 
1306 
Gear^.dY := Gear^.dY + cGravity; 

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

1308 
end; 

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

1309 
if hwRound(Gear^.Y) > cWaterLine then Gear^.Timer := 1 
4578  1310 
end; 
4  1311 

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

1312 
Gear^.X := Gear^.X + HHGear^.dX; 
6389  1313 
if CheckLandValue(hwRound(Gear^.X), hwRound(Gear^.Y)cHHRadius, $FF00) then 
6314  1314 
begin 
1315 
HHGear^.X := Gear^.X; 

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

1317 
end; 

3454 