author  nemo 
Thu, 15 Sep 2011 22:53:47 0400  
changeset 5926  09bbc7b88714 
parent 5924  82fc26c53d2a 
child 5935  c89d5065d956 
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; 
5c8fe58dead5
Define 2 script callbacks to notify of hog vanishment
nemo
parents:
5806
diff
changeset

121 
HH^.Gear:= nil; 
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 

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

177 
if Gear^.Kind = gtHedgehog then 
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 
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

222 
if TestCollisionXwithGear(Gear, hwSign(Gear^.dX)) or TestCollisionYwithGear(Gear, hwSign(Gear^.dY) 
3454
a9bef74bd6e0
Code restlyling: experimental restyling of one module
mbait
parents:
3440
diff
changeset

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

224 
then Gear^.State := Gear^.State or gstCollision 
a9bef74bd6e0
Code restlyling: experimental restyling of one module
mbait
parents:
3440
diff
changeset

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

4798  228 
procedure CheckCollisionWithLand(Gear: PGear); inline; 
229 
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

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

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

234 
end; 

235 

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

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

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

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

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

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

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

247 

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

248 
for i:= min(12, (3 + dmg div 10)) downto 0 do 
4578  249 
begin 
250 
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

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

253 

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

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

255 

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

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

263 
else 

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

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

265 
end 
4  266 
end; 
267 

268 
//////////////////////////////////////////////////////////////////////////////// 

269 
procedure CalcRotationDirAngle(Gear: PGear); 

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

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

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

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

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

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

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

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

278 

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

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

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

283 
//////////////////////////////////////////////////////////////////////////////// 

284 
procedure doStepDrowningGear(Gear: PGear); 

285 
begin 

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

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

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

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

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

290 
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

291 
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

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

294 
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

295 
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

296 
DeleteGear(Gear); 
4  297 
end; 
298 

299 
//////////////////////////////////////////////////////////////////////////////// 

300 
procedure doStepFallingGear(Gear: PGear); 

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

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

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

304 
tdX, tdY: hwFloat; 
3001  305 
collV, collH: LongInt; 
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; 
a9bef74bd6e0
Code restlyling: experimental restyling of one module
mbait
parents:
3440
diff
changeset

323 
if TestCollisionYwithGear(Gear, 1) then 
4578  324 
begin 
3454
a9bef74bd6e0
Code restlyling: experimental restyling of one module
mbait
parents:
3440
diff
changeset

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

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

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

328 
Gear^.State := Gear^.State or gstCollision 
4578  329 
end 
3454
a9bef74bd6e0
Code restlyling: experimental restyling of one module
mbait
parents:
3440
diff
changeset

330 
else if (Gear^.AdvBounce=1) and TestCollisionYwithGear(Gear, 1) then collV := 1; 
4578  331 
end 
3454
a9bef74bd6e0
Code restlyling: experimental restyling of one module
mbait
parents:
3440
diff
changeset

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

333 
begin 
4578  334 
collV := 1; 
335 
isFalling := false; 

336 
Gear^.dX := Gear^.dX * Gear^.Friction; 

337 
Gear^.dY :=  Gear^.dY * Gear^.Elasticity; 

338 
Gear^.State := Gear^.State or gstCollision 

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

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

340 
else 
4578  341 
begin 
3454
a9bef74bd6e0
Code restlyling: experimental restyling of one module
mbait
parents:
3440
diff
changeset

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

343 
if (Gear^.AdvBounce=1) and not Gear^.dY.isNegative and TestCollisionYwithGear(Gear, 1) then 
a9bef74bd6e0
Code restlyling: experimental restyling of one module
mbait
parents:
3440
diff
changeset

344 
collV := 1; 
4578  345 
end; 
503  346 

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

347 

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

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

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

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

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

353 
Gear^.State := Gear^.State or gstCollision 
4578  354 
end 
3454
a9bef74bd6e0
Code restlyling: experimental restyling of one module
mbait
parents:
3440
diff
changeset

355 
else if (Gear^.AdvBounce=1) and TestCollisionXwithGear(Gear, hwSign(Gear^.dX)) then 
a9bef74bd6e0
Code restlyling: experimental restyling of one module
mbait
parents:
3440
diff
changeset

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

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

358 
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

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

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

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

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

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

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

366 
Gear^.AdvBounce := 10; 
4578  367 
end; 
503  368 

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

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

370 

4299  371 
if isFalling then 
372 
begin 

373 
Gear^.dY := Gear^.dY + cGravity; 

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

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

376 

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

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

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

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

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

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

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

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

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

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

386 

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

388 
(((Gear^.Kind <> gtMine) and (Gear^.Damage <> 0)) or 
5461  389 
((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

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

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

392 
(Gear^.dY.QWordValue > _0_1.QWordValue)))) then 
5461  393 
PlaySound(TSound(ord(Gear^.ImpactSound) + LongInt(GetRandom(Gear^.nImpactSounds))), true); 
4  394 
end; 
395 

396 
//////////////////////////////////////////////////////////////////////////////// 

397 
procedure doStepBomb(Gear: PGear); 

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

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

399 
i, x, y: LongInt; 
919  400 
dX, dY: hwFloat; 
2538
661079b00177
Just checking this in so prg can try it. May back it out
nemo
parents:
2524
diff
changeset

401 
Fire: PGear; 
3475  402 
vg: PVisualGear; 
4  403 
begin 
3454
a9bef74bd6e0
Code restlyling: experimental restyling of one module
mbait
parents:
3440
diff
changeset

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

405 

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

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

407 

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

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

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

410 
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

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

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

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

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

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

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

417 

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

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

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

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

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

422 
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

423 
end; 
3004  424 

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

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

428 
if vg <> nil then 

429 
vg^.Tint:= $FFC0C000; 

430 
end; 

431 

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

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

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

434 
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

435 
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

436 
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

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

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

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

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

441 
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

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

443 
begin 
3505  444 
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

445 
dY := (GetRandom  _3) * _0_08; 
1ec68b8d3bd1
Henek adds a flamethrower, updates some translations, and tweaks how fire works.
nemo
parents:
3475
diff
changeset

446 
AddGear(x, y, gtCluster, 0, dX, dY, 25); 
1ec68b8d3bd1
Henek adds a flamethrower, updates some translations, and tweaks how fire works.
nemo
parents:
3475
diff
changeset

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

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

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

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

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

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

453 
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

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

455 
begin 
3505  456 
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

457 
dY := (GetRandom  _1_5) * _0_3; 
1ec68b8d3bd1
Henek adds a flamethrower, updates some translations, and tweaks how fire works.
nemo
parents:
3475
diff
changeset

458 
AddGear(x, y, gtMelonPiece, 0, dX, dY, 75)^.DirAngle := i * 60; 
1ec68b8d3bd1
Henek adds a flamethrower, updates some translations, and tweaks how fire works.
nemo
parents:
3475
diff
changeset

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

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

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

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

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

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

465 
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

466 

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

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

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

469 
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

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

471 
Fire := AddGear(x, y, gtFlame, 0, dX, dY, 0); 
1ec68b8d3bd1
Henek adds a flamethrower, updates some translations, and tweaks how fire works.
nemo
parents:
3475
diff
changeset

472 
if i mod 2 = 0 then Fire^.State := Fire^.State or gsttmpFlag; 
1ec68b8d3bd1
Henek adds a flamethrower, updates some translations, and tweaks how fire works.
nemo
parents:
3475
diff
changeset

473 
Fire := AddGear(x, y, gtFlame, 0, dX, dY, 0); 
1ec68b8d3bd1
Henek adds a flamethrower, updates some translations, and tweaks how fire works.
nemo
parents:
3475
diff
changeset

474 
if i mod 2 <> 0 then Fire^.State := Fire^.State or gsttmpFlag; 
1ec68b8d3bd1
Henek adds a flamethrower, updates some translations, and tweaks how fire works.
nemo
parents:
3475
diff
changeset

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

476 
end; 
3712  477 
gtGasBomb: 
478 
begin 

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

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

481 
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

482 
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

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

484 
AddGear(hwRound(Gear^.X)  30 + x, hwRound(Gear^.Y)  20 + y, gtPoisonCloud, 0, _0, _0, 0); 
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

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

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

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

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

490 
end; 
1263  491 

4  492 
CalcRotationDirAngle(Gear); 
1263  493 

494 
if Gear^.Kind = gtHellishBomb then 

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

495 
begin 
3118  496 

497 
if Gear^.Timer = 3000 then 

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

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

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

501 
end; 
1279  502 

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

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

504 
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

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

506 
end; 
4  507 
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

508 

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

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

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

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

512 
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

513 
dX, dY: hwFloat; 
2948
3f21a9dc93d0
Replace tabs with spaces using 'expand t 4' command
unc0rr
parents:
2944
diff
changeset

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

515 
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

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

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

518 

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

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

520 
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

521 

5870  522 
// let's add some smoke depending on speed 
5871
09daa06191d7
Since we are tweaking molotov. make the flame flickery and add a drowning frame
nemo
parents:
5870
diff
changeset

523 
i:= max(32,152  hwRound(Distance(Gear^.dX,Gear^.dY)*120))+random(10); 
5870  524 
if (GameTicks mod i) = 0 then 
5871
09daa06191d7
Since we are tweaking molotov. make the flame flickery and add a drowning frame
nemo
parents:
5870
diff
changeset

525 
begin 
5873  526 
// adjust angle to match the texture 
527 
if Gear^.dX.isNegative then i:= 130 else i:= 50; 

528 
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

529 
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

530 
end; 
5870  531 

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

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

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

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

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

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

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

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

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

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

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

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

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

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

545 
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

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

547 
glass:= AddVisualGear(gx+random(7)3, gy+random(7)3, vgtStraightShot); 
82fc26c53d2a
Tweak sparkles, glass. Left glass commented out in case he prefers old behaviour.
nemo
parents:
5922
diff
changeset

548 
if glass <> nil then 
82fc26c53d2a
Tweak sparkles, glass. Left glass commented out in case he prefers old behaviour.
nemo
parents:
5922
diff
changeset

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

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

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

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

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

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

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

556 
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

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

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

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

560 
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

561 
for i:= 0 to 24 do 
3454
a9bef74bd6e0
Code restlyling: experimental restyling of one module
mbait
parents:
3440
diff
changeset

562 
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

563 
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

564 
dY := AngleSin(i * 8) * _0_5 * (GetRandom + _1); 
a9bef74bd6e0
Code restlyling: experimental restyling of one module
mbait
parents:
3440
diff
changeset

565 
Fire := AddGear(gX, gY, gtFlame, 0, dX, dY, 0); 
a9bef74bd6e0
Code restlyling: experimental restyling of one module
mbait
parents:
3440
diff
changeset

566 
Fire^.State := Fire^.State or gsttmpFlag; 
a9bef74bd6e0
Code restlyling: experimental restyling of one module
mbait
parents:
3440
diff
changeset

567 
Fire := AddGear(gX, gY, gtFlame, 0, dX, dY, 0); 
a9bef74bd6e0
Code restlyling: experimental restyling of one module
mbait
parents:
3440
diff
changeset

568 
Fire^.State := Fire^.State or gsttmpFlag; 
a9bef74bd6e0
Code restlyling: experimental restyling of one module
mbait
parents:
3440
diff
changeset

569 
Fire := AddGear(gX, gY, gtFlame, 0, dX, dY, 0); 
a9bef74bd6e0
Code restlyling: experimental restyling of one module
mbait
parents:
3440
diff
changeset

570 
Fire^.State := Fire^.State or gsttmpFlag; 
a9bef74bd6e0
Code restlyling: experimental restyling of one module
mbait
parents:
3440
diff
changeset

571 
Fire := AddGear(gX, gY, gtFlame, 0, dX, dY, 0); 
a9bef74bd6e0
Code restlyling: experimental restyling of one module
mbait
parents:
3440
diff
changeset

572 
Fire^.State := Fire^.State or gsttmpFlag; 
2948
3f21a9dc93d0
Replace tabs with spaces using 'expand t 4' command
unc0rr
parents:
2944
diff
changeset

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

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

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

576 
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

577 
end; 
4  578 

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

579 
//////////////////////////////////////////////////////////////////////////////// 
1279  580 

78  581 
procedure doStepCluster(Gear: PGear); 
582 
begin 

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

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

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

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

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

587 
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

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

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

590 
end; 
1262  591 

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

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

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

594 
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

595 
AddVisualGear(hwRound(Gear^.X), hwRound(Gear^.Y), vgtSmokeTrace) 
78  596 
end; 
597 

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

601 
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

602 
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

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

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

606 
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

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

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

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

611 
AddVisualGear(hwRound(Gear^.X), hwRound(Gear^.Y), vgtSmokeTrace); 
95  612 
end; 
613 

4  614 
//////////////////////////////////////////////////////////////////////////////// 
4578  615 
procedure doStepSnowball(Gear: PGear); 
616 
var kick, i: LongInt; 

617 
particle: PVisualGear; 

618 
begin 

619 
AllInactive := false; 

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

621 
doStepFallingGear(Gear); 

622 
CalcRotationDirAngle(Gear); 

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

624 
begin 

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

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

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

628 
AmmoShove(Gear, 1, kick); 

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

630 
begin 

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

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

633 
end; 

634 
DeleteGear(Gear); 

635 
exit 

636 
end; 

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

638 
begin 

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

642 
end; 

643 

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

644 
//////////////////////////////////////////////////////////////////////////////// 
4611  645 
procedure doStepSnowflake(Gear: PGear); 
5052  646 
var xx, yy, px, py: LongInt; 
5025
ac1691d35cf2
Land sprayer tweaks, make land spray and mudball not end turn
nemo
parents:
5024
diff
changeset

647 
move, draw, allpx, gun: Boolean; 
4611  648 
s: PSDL_Surface; 
649 
p: PLongwordArray; 

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

653 
gun:= (Gear^.State and gstTmpFlag) <> 0; 
5024  654 
move:= false; 
655 
draw:= false; 

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

656 
if gun then 
5024  657 
begin 
5461  658 
Gear^.State:= Gear^.State and not gstInvisible; 
5024  659 
doStepFallingGear(Gear); 
660 
CheckCollision(Gear); 

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

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

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

664 
end 

665 
else if GameTicks and $7 = 0 then 

4611  666 
begin 
667 
with Gear^ do 

668 
begin 

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

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

673 
yy:= hwRound(Y); 

674 
if vobVelocity <> 0 then 

675 
begin 

4621  676 
DirAngle := DirAngle + (Angle / 1250000000); 
4611  677 
if DirAngle < 0 then DirAngle := DirAngle + 360 
678 
else if 360 < DirAngle then DirAngle := DirAngle  360; 

679 
end; 

680 

681 
inc(Health, 8); 

5186  682 
if longword(Health) > vobFrameTicks then 
4611  683 
begin 
684 
dec(Health, vobFrameTicks); 

685 
inc(Timer); 

686 
if Timer = vobFramesCount then Timer:= 0 

687 
end; 

688 
// move back to cloud layer 

689 
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

690 
else if ((yy and LAND_HEIGHT_MASK) <> 0) or (xx > LAND_WIDTH + 512) or (xx < 512) then move:=true 
4791  691 
// Solid pixel encountered 
5342  692 
else if ((xx and LAND_WIDTH_MASK) = 0) and (Land[yy, xx] <> 0) then 
4611  693 
begin 
5693  694 
lf:= Land[yy, xx] and (lfObject or lfBasic); 
4791  695 
// If there's room below keep falling 
696 
if (((yy1) and LAND_HEIGHT_MASK) = 0) and (Land[yy1, xx] = 0) then 

697 
begin 

698 
X:= X  cWindSpeed * 1600  dX; 

699 
end 

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

701 
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 

702 
begin 

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

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

705 
end 

706 
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 

707 
begin 

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

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

710 
end 

711 
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 

712 
begin 

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

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

715 
end 

716 
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 

717 
begin 

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

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

720 
end 

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

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

722 
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

723 
then move:=true 
5024  724 
else draw:= true 
725 
end 

726 
end 

727 
end; 

728 
if draw then 

729 
with Gear^ do 

730 
begin 

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

732 
move:= true; 

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

736 
if not gun then 
5024  737 
begin 
738 
dec(yy,3); 

739 
dec(xx,1) 

740 
end; 

741 
s:= SpritesData[sprSnow].Surface; 

742 
p:= s^.pixels; 

743 
allpx:= true; 

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

745 
begin 

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

747 
if ((((yy + py) and LAND_HEIGHT_MASK) = 0) and (((xx + px) and LAND_WIDTH_MASK) = 0)) and ((Land[yy + py, xx + px] and $FF) = 0) then 

748 
begin 

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

749 
if gun then 
ac1691d35cf2
Land sprayer tweaks, make land spray and mudball not end turn
nemo
parents:
5024
diff
changeset

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

751 
// try to avoid speckles. might need disabling 
ac1691d35cf2
Land sprayer tweaks, make land spray and mudball not end turn
nemo
parents:
5024
diff
changeset

752 
LandDirty[yy div 32, xx div 32]:= 1; 
5693  753 
Land[yy + py, xx + px]:= (Land[yy + py, xx + px] or lfDamaged or lfObject) and not lfBasic; 
754 
end 

755 
else if Land[yy + py, xx + px] and $FF00 = 0 then Land[yy + py, xx + px]:= lf; 

5024  756 
if (cReducedQuality and rqBlurryLand) = 0 then 
757 
begin 

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

758 
if gun then 
5041  759 
LandPixels[yy + py, xx + px]:= (cExplosionBorderColor and not AMask) or (p^[px] and AMask) 
5024  760 
else LandPixels[yy + py, xx + px]:= addBgColor(LandPixels[yy + py, xx + px], p^[px]); 
761 
end 

762 
else 

763 
begin 

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

764 
if gun then 
5041  765 
LandPixels[(yy + py) div 2, (xx + px) div 2]:= (cExplosionBorderColor and not AMask) or (p^[px] and AMask) 
5024  766 
else LandPixels[(yy + py) div 2, (xx + px) div 2]:= addBgColor(LandPixels[(yy + py) div 2, (xx + px) div 2], p^[px]); 
767 
end; 

768 
end 

769 
else allpx:= false; 

770 
p:= @(p^[s^.pitch shr 2]) 

771 
end; 

772 

773 

774 
Land[py, px+1]:= lfBasic; 

775 

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

4791  777 
else 
4611  778 
begin 
5024  779 
UpdateLandTexture( 
780 
max(0, min(LAND_WIDTH, xx)), 

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

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

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

784 
); 

4791  785 
end; 
5024  786 
////////////////////////////////// TODO  ASK UNC0RR FOR A GOOD HOME FOR THIS //////////////////////////////////// 
4611  787 
end 
5024  788 
end; 
789 

790 
if move then 

791 
begin 

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

792 
if gun then 
5024  793 
begin 
794 
DeleteGear(Gear); 

795 
exit 

796 
end; 

5695  797 
Gear^.Pos:= 0; 
5024  798 
Gear^.X:= int2hwFloat(GetRandom(LAND_WIDTH+1024)512); 
5413  799 
Gear^.Y:= int2hwFloat(750+(GetRandom(50)25)); 
800 
Gear^.State:= Gear^.State or gstInvisible; 

4611  801 
end 
802 
end; 

803 

4578  804 
//////////////////////////////////////////////////////////////////////////////// 
4  805 
procedure doStepGrave(Gear: PGear); 
806 
begin 

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

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

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

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

810 

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

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

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

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

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

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

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

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

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

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

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

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

822 

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

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

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

825 
Gear^.dY := Gear^.dY + cGravity 
4  826 
end; 
827 

828 
//////////////////////////////////////////////////////////////////////////////// 

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

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

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

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

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

835 

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

836 
const uw: boolean = false; 
4  837 
begin 
3454
a9bef74bd6e0
Code restlyling: experimental restyling of one module
mbait
parents:
3440
diff
changeset

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

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

840 
gY := hwRound(Gear^.Y); 
3591  841 
nuw := (cWaterLine < gy + Gear^.Radius); 
3454
a9bef74bd6e0
Code restlyling: experimental restyling of one module
mbait
parents:
3440
diff
changeset

842 
if nuw and not uw then 
3139  843 
begin 
3454
a9bef74bd6e0
Code restlyling: experimental restyling of one module
mbait
parents:
3440
diff
changeset

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

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

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

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

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

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

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

851 
uw := nuw 
3139  852 
end 
3454
a9bef74bd6e0
Code restlyling: experimental restyling of one module
mbait
parents:
3440
diff
changeset

853 
else if not nuw and uw then 
a9bef74bd6e0
Code restlyling: experimental restyling of one module
mbait
parents:
3440
diff
changeset

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

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

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

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

858 
uw := nuw 
a9bef74bd6e0
Code restlyling: experimental restyling of one module
mbait
parents:
3440
diff
changeset

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

860 

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

861 

3591  862 
if (GameTicks and $F) = 0 then 
863 
begin 

864 
if (GameTicks and $30) = 0 then 

865 
AddVisualGear(gX, gY, vgtBeeTrace); 

5612
2638dec1b323
This really should have been a TPoint for consistency
nemo
parents:
5606
diff
changeset

866 
Gear^.dX := Gear^.Elasticity * (Gear^.dX + _0_000064 * (Gear^.Target.X  gX)); 
2638dec1b323
This really should have been a TPoint for consistency
nemo
parents:
5606
diff
changeset

867 
Gear^.dY := Gear^.Elasticity * (Gear^.dY + _0_000064 * (Gear^.Target.Y  gY)); 
3591  868 
// make sure new speed isn't higher than original one (which we stored in Friction variable) 
869 
t := Gear^.Friction / Distance(Gear^.dX, Gear^.dY); 

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

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

872 
end; 

873 

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

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

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

876 

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

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

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

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

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

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

882 
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

883 
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

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

885 
flower:= AddVisualGear(hwRound(Gear^.X), hwRound(Gear^.Y), vgtStraightShot); 
70d7f8e40f53
Just for fun. Flowers! Also, use a less blatant image in ammo menu.
nemo
parents:
5738
diff
changeset

886 
if flower <> nil then 
70d7f8e40f53
Just for fun. Flowers! Also, use a less blatant image in ammo menu.
nemo
parents:
5738
diff
changeset

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

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

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

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

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

892 
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

893 
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

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

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

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

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

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

899 
end; 
4  900 
end; 
901 

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

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

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

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

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

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

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

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

911 
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

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

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

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

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

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

917 
begin 
4365  918 
Gear^.Hedgehog^.Gear^.Message:= Gear^.Hedgehog^.Gear^.Message and not gmAttack; 
919 
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

920 
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

921 

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

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

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

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

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

927 
end; 
4  928 
end; 
929 

930 
//////////////////////////////////////////////////////////////////////////////// 

876  931 
procedure doStepShotIdle(Gear: PGear); 
932 
begin 

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

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

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

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

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

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

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

939 
end 
876  940 
end; 
941 

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

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

944 
i: LongWord; 
2828  945 
shell: PVisualGear; 
4  946 
begin 
3454
a9bef74bd6e0
Code restlyling: experimental restyling of one module
mbait
parents:
3440
diff
changeset

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

948 

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

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

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

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

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

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

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

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

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

957 
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

958 
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

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

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

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

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

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

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

966 
else inc(Gear^.Timer); 
876  967 

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

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

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

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

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

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

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

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

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

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

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

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

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

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

981 

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

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

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

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

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

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

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

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

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

990 
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

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

992 
Gear^.doStep := @doStepShotIdle 
4  993 
end; 
994 

995 
//////////////////////////////////////////////////////////////////////////////// 

5841  996 
procedure spawnBulletTrail(Bullet: PGear); 
997 
var oX, oY: hwFloat; 

998 
VGear: PVisualGear; 

999 
begin 

1000 
if Bullet^.PortalCounter = 0 then 

1001 
begin 

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

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

1004 
end 

1005 
else 

1006 
begin 

1007 
ox:= Bullet^.Elasticity; 

1008 
oy:= Bullet^.Friction; 

1009 
end; 

1010 

1011 
// Bullet trail 

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

1013 
if VGear <> nil then 

1014 
begin 

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

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

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

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

1019 

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

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

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

1023 
// only extend if not under water 

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

1025 
begin 

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

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

1028 
end; 

1029 

1030 
VGear^.Timer := 200; 

1031 
end; 

1032 
end; 

1033 

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

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

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

1036 
i, x, y: LongWord; 
351  1037 
oX, oY: hwFloat; 
4327  1038 
VGear: PVisualGear; 
38  1039 
begin 
3454
a9bef74bd6e0
Code restlyling: experimental restyling of one module
mbait
parents:
3440
diff
changeset

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

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

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

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

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

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

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

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

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

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

1050 
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

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

1054 
begin 

1055 
Gear^.Tag := 1; 

1056 
Gear^.Damage := 0; 

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

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

1059 
CheckGearDrowning(Gear); 

1060 
break; 

1061 
end 

1062 
else 

1063 
Gear^.Tag := 0; 

1064 

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

1065 
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

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

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

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

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

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

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

1072 
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

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

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

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

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

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

1078 
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

1079 
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

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

1081 
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

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

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

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

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

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

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

1088 
end; 
1760  1089 

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

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

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

1092 
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

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

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

1095 
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

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

1097 
((GameFlags and gfArtillery) = 0) then cArtillery := false; 
4279  1098 

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

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

1102 
begin 

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

1104 
if VGear <> nil then 

1105 
begin 

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

1107 
end; 

1108 
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

1109 

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

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

1112 
end; 
37  1113 
end; 
1114 

559  1115 
procedure doStepDEagleShot(Gear: PGear); 
1116 
begin 

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

1117 
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

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

1119 
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

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

1121 
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

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

1123 

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

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

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

1126 
HHGear: PGear; 
2828  1127 
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

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

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

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

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

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

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

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

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

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

1138 
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

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

1140 

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

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

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

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

1145 
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

1146 
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

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

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

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

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

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

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

1153 
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

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

1155 
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

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

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

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

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

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

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

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

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

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

1167 

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

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

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

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

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

1173 
AfterAttack 
2058  1174 
end; 
559  1175 
end; 
1176 

37  1177 
//////////////////////////////////////////////////////////////////////////////// 
4  1178 
procedure doStepActionTimer(Gear: PGear); 
1179 
begin 

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

1206 
end; 
351  1207 
if Gear^.Timer = 0 then DeleteGear(Gear) 
4  1208 
end; 
1209 

1210 
//////////////////////////////////////////////////////////////////////////////// 

1211 
procedure doStepPickHammerWork(Gear: PGear); 

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

1212 
var 
4578  1213 
i, ei, x, y: LongInt; 
4  1214 
HHGear: PGear; 
1215 
begin 

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

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

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

1219 
if ((GameFlags and gfInfAttack) <> 0) and (TurnTimeLeft > 0) then dec(TurnTimeLeft); 
5786  1220 
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

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

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

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

1225 
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

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

1227 
exit 
4578  1228 
end; 
1229 

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

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

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

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

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

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

1236 
HHGear^.State := HHGear^.State and not gstNoDamage 
4578  1237 
end; 
422  1238 

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

1239 
if (Gear^.Timer mod 47) = 0 then 
4578  1240 
begin 
1241 
// 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 

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

1245 

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

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

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

1248 
while i <= ei do 
4578  1249 
begin 
1250 
DrawExplosion(i, y + 3, 3); 

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

1251 
inc(i, 1) 
4578  1252 
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

1253 

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

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

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

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

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

1262 
if TestCollisionYwithGear(Gear, 1) then 
4578  1263 
begin 
3454
a9bef74bd6e0
Code restlyling: experimental restyling of one module
mbait
parents:
3440
diff
changeset

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

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

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

1268 
else 
4578  1269 
begin 
3454
a9bef74bd6e0
Code restlyling: experimental restyling of one module
mbait
parents:
3440
diff
changeset

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

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

1272 
if hwRound(Gear^.Y) > cWaterLine then Gear^.Timer := 1 
4578  1273 
end; 
4  1274 

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

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

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

1277 
HHGear^.Y := Gear^.Y  int2hwFloat(cHHRadius); 
a9bef74bd6e0
Code restlyling: experimental restyling of one module
mbait
parents:
3440
diff
changeset

1278 

3894  1279 
if (Gear^.Message and gmAttack) <> 0 then 
3454
a9bef74bd6e0
Code restlyling: experimental restyling of one module
mbait
parents:
3440
diff
changeset

1280 
if (Gear^.State and gsttmpFlag) <> 0 then Gear^.Timer := 1 
a9bef74bd6e0
Code restlyling: experimental restyling of one module
mbait
parents:
3440
diff
changeset

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

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

1283 
if (Gear^.State and gsttmpFlag) = 0 then Gear^.State := Gear^.State or gsttmpFlag; 
3894  1284 
if ((Gear^.Message and gmLeft) <> 0) then Gear^.dX :=  _0_3 
3454
a9bef74bd6e0
Code restlyling: experimental restyling of one module
mbait
parents:
3440
diff
changeset

1285 
else 
3894  1286 
if ((Gear^.Message and gmRight) <> 0) then Gear^.dX := _0_3 
3454
a9bef74bd6e0
Code restlyling: experimental restyling of one module
mbait
parents:
3440
diff
changeset

1287 
else Gear^.dX := _0; 
4  1288 
end; 
1289 

1290 
procedure doStepPickHammer(Gear: PGear); 

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

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

1292 
i, y: LongInt; 
4  1293 
ar: TRangeArray; 
911
b709fe13ed69
Fix issue with hedgehog on top of the hedgehog with pickhammer
unc0rr
parents:
883
diff
changeset

1294 
HHGear: PGear; 
4  1295 
begin 
3454
a9bef74bd6e0
Code restlyling: experimental restyling of one module
mbait
parents:
3440
diff
changeset

1296 
i := 0; 
4365  1297 
HHGear := Gear^.Hedgehog^.Gear; 
3454
a9bef74bd6e0
Code restlyling: experimental restyling of one module
mbait
parents:
3440
diff
changeset

1298 

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

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

1300 
while y < hwRound(Gear^.Y) do 
a9bef74bd6e0
Code restlyling: experimental restyling of one module
mbait
parents:
3440
diff
changeset

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

1302 
ar[i].Left := hwRound(Gear^.X)  Gear^.Radius  LongInt(GetRandom(2)); 
a9bef74bd6e0
Code restlyling: experimental restyling of one module
mbait
parents:
3440
diff
changeset

1303 
ar[i].Right := hwRound(Gear^.X) + Gear^.Radius + LongInt(GetRandom(2)); 
a9bef74bd6e0
Code restlyling: experimental restyling of one module
mbait
parents:
3440
diff
changeset

1304 
inc(y, 2); 
a9bef74bd6e0
Code restlyling: experimental restyling of one module
mbait
parents:
3440
diff
changeset

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

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

1307 

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

1308 
DrawHLinesExplosions(@ar, 3, hwRound(Gear^.Y)  cHHRadius * 2, 2, Pred(i)); 
a9bef74bd6e0
Code restlyling: experimental restyling of one module
mbait
parents:
3440
diff
changeset

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

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

1311 

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

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

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

1314 
Gear^.doStep := @doStepPickHammerWork 
4  1315 
end; 
1316 

1317 
//////////////////////////////////////////////////////////////////////////////// 

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

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

1319 
BTPrevAngle, BTSteps: LongInt; 
302  1320 

303
1659c4aad5ab
Now blow torch angle can be changed during blowing :)
unc0rr
parents:
302
diff
changeset

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

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

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

1324 
b: boolean; 
3f21a9dc93d0
Replace tabs with spaces using 'expand t 4' command
unc0rr
parents:
2944
diff
changeset

1325 
prevX: LongInt; 
302  1326 
begin 
3454
a9bef74bd6e0
Code restlyling: experimental restyling of one module
mbait
parents:
3440
diff
changeset

1327 
AllInactive := false; 