author | nemo |
Tue, 14 May 2013 07:16:14 -0400 | |
changeset 8991 | 82e3a6e5d51b |
parent 8990 | e64a1a851b69 |
child 8992 | 5b0be812dcdb |
permissions | -rw-r--r-- |
6581 | 1 |
(* |
2 |
* Hedgewars, a free turn based strategy game |
|
6700 | 3 |
* Copyright (c) 2004-2012 Andrey Korotaev <unC0Rr@gmail.com> |
6581 | 4 |
* |
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 |
|
8 |
* |
|
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. |
|
13 |
* |
|
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 02111-1307, USA |
|
17 |
*) |
|
18 |
||
19 |
{$INCLUDE "options.inc"} |
|
20 |
||
21 |
unit uGearsUtils; |
|
22 |
interface |
|
7066
12cc2bd84b0b
Make pas2c even more happier with uGears.c, allow assigning arrays in some cases
unc0rr
parents:
7053
diff
changeset
|
23 |
uses uTypes; |
6581 | 24 |
|
6986
409dd3851309
add support for default pascal mode by removing default arguments value (maybe this also helps the parser)
koda
parents:
6888
diff
changeset
|
25 |
procedure doMakeExplosion(X, Y, Radius: LongInt; AttackingHog: PHedgehog; Mask: Longword); inline; |
409dd3851309
add support for default pascal mode by removing default arguments value (maybe this also helps the parser)
koda
parents:
6888
diff
changeset
|
26 |
procedure doMakeExplosion(X, Y, Radius: LongInt; AttackingHog: PHedgehog; Mask: Longword; const Tint: LongWord); |
409dd3851309
add support for default pascal mode by removing default arguments value (maybe this also helps the parser)
koda
parents:
6888
diff
changeset
|
27 |
|
6581 | 28 |
function ModifyDamage(dmg: Longword; Gear: PGear): Longword; |
29 |
procedure ApplyDamage(Gear: PGear; AttackerHog: PHedgehog; Damage: Longword; Source: TDamageSource); |
|
30 |
procedure spawnHealthTagForHH(HHGear: PGear; dmg: Longword); |
|
31 |
procedure HHHurt(Hedgehog: PHedgehog; Source: TDamageSource); |
|
32 |
procedure CheckHHDamage(Gear: PGear); |
|
33 |
procedure CalcRotationDirAngle(Gear: PGear); |
|
8947
e906ebd59612
CheckGearDrowning could delete hedgehogs gear! (CheckGearDrowning -> ResurrectHedgehog -> FindPlace). Fixes bug 620.
unc0rr
parents:
8763
diff
changeset
|
34 |
procedure ResurrectHedgehog(var gear: PGear); |
6986
409dd3851309
add support for default pascal mode by removing default arguments value (maybe this also helps the parser)
koda
parents:
6888
diff
changeset
|
35 |
|
409dd3851309
add support for default pascal mode by removing default arguments value (maybe this also helps the parser)
koda
parents:
6888
diff
changeset
|
36 |
procedure FindPlace(var Gear: PGear; withFall: boolean; Left, Right: LongInt); inline; |
409dd3851309
add support for default pascal mode by removing default arguments value (maybe this also helps the parser)
koda
parents:
6888
diff
changeset
|
37 |
procedure FindPlace(var Gear: PGear; withFall: boolean; Left, Right: LongInt; skipProximity: boolean); |
409dd3851309
add support for default pascal mode by removing default arguments value (maybe this also helps the parser)
koda
parents:
6888
diff
changeset
|
38 |
|
6581 | 39 |
function CheckGearNear(Gear: PGear; Kind: TGearType; rX, rY: LongInt): PGear; |
8947
e906ebd59612
CheckGearDrowning could delete hedgehogs gear! (CheckGearDrowning -> ResurrectHedgehog -> FindPlace). Fixes bug 620.
unc0rr
parents:
8763
diff
changeset
|
40 |
function CheckGearDrowning(var Gear: PGear): boolean; |
7592 | 41 |
procedure CheckCollision(Gear: PGear); inline; |
42 |
procedure CheckCollisionWithLand(Gear: PGear); inline; |
|
6581 | 43 |
|
7719
eeae1cb6b6bf
Move hedgehog's step routine into separate function, use it in both hedgehog and ai code
unc0rr
parents:
7627
diff
changeset
|
44 |
function MakeHedgehogsStep(Gear: PGear) : boolean; |
eeae1cb6b6bf
Move hedgehog's step routine into separate function, use it in both hedgehog and ai code
unc0rr
parents:
7627
diff
changeset
|
45 |
|
6581 | 46 |
var doStepHandlers: array[TGearType] of TGearStepProcedure; |
47 |
||
48 |
||
49 |
implementation |
|
50 |
uses uFloat, uSound, uCollisions, uUtils, uConsts, uVisualGears, uAIMisc, |
|
51 |
uVariables, uLandGraphics, uScript, uStats, uCaptions, uTeams, uStore, |
|
52 |
uLocale, uTextures, uRenderUtils, uRandom, SDLh, uDebug, uGears, |
|
7066
12cc2bd84b0b
Make pas2c even more happier with uGears.c, allow assigning arrays in some cases
unc0rr
parents:
7053
diff
changeset
|
53 |
uGearsList, Math; |
6581 | 54 |
|
6986
409dd3851309
add support for default pascal mode by removing default arguments value (maybe this also helps the parser)
koda
parents:
6888
diff
changeset
|
55 |
procedure doMakeExplosion(X, Y, Radius: LongInt; AttackingHog: PHedgehog; Mask: Longword); inline; |
409dd3851309
add support for default pascal mode by removing default arguments value (maybe this also helps the parser)
koda
parents:
6888
diff
changeset
|
56 |
begin |
409dd3851309
add support for default pascal mode by removing default arguments value (maybe this also helps the parser)
koda
parents:
6888
diff
changeset
|
57 |
doMakeExplosion(X, Y, Radius, AttackingHog, Mask, $FFFFFFFF); |
409dd3851309
add support for default pascal mode by removing default arguments value (maybe this also helps the parser)
koda
parents:
6888
diff
changeset
|
58 |
end; |
409dd3851309
add support for default pascal mode by removing default arguments value (maybe this also helps the parser)
koda
parents:
6888
diff
changeset
|
59 |
|
6581 | 60 |
procedure doMakeExplosion(X, Y, Radius: LongInt; AttackingHog: PHedgehog; Mask: Longword; const Tint: LongWord); |
61 |
var Gear: PGear; |
|
6769
44ad49a3a126
Add drowning to grenade too, try some little optimisations
nemo
parents:
6765
diff
changeset
|
62 |
dmg, dmgBase: LongInt; |
6765 | 63 |
fX, fY, tdX, tdY: hwFloat; |
6581 | 64 |
vg: PVisualGear; |
65 |
i, cnt: LongInt; |
|
66 |
begin |
|
67 |
if Radius > 4 then AddFileLog('Explosion: at (' + inttostr(x) + ',' + inttostr(y) + ')'); |
|
68 |
if Radius > 25 then KickFlakes(Radius, X, Y); |
|
69 |
||
70 |
if ((Mask and EXPLNoGfx) = 0) then |
|
71 |
begin |
|
72 |
vg:= nil; |
|
73 |
if Radius > 50 then vg:= AddVisualGear(X, Y, vgtBigExplosion) |
|
74 |
else if Radius > 10 then vg:= AddVisualGear(X, Y, vgtExplosion); |
|
75 |
if vg <> nil then |
|
76 |
vg^.Tint:= Tint; |
|
77 |
end; |
|
78 |
if (Mask and EXPLAutoSound) <> 0 then PlaySound(sndExplosion); |
|
79 |
||
6765 | 80 |
(*if (Mask and EXPLAllDamageInRadius) = 0 then |
6581 | 81 |
dmgRadius:= Radius shl 1 |
82 |
else |
|
83 |
dmgRadius:= Radius; |
|
6765 | 84 |
dmgBase:= dmgRadius + cHHRadius div 2;*) |
85 |
dmgBase:= Radius shl 1 + cHHRadius div 2; |
|
6581 | 86 |
fX:= int2hwFloat(X); |
87 |
fY:= int2hwFloat(Y); |
|
88 |
Gear:= GearsList; |
|
89 |
while Gear <> nil do |
|
90 |
begin |
|
91 |
dmg:= 0; |
|
92 |
//dmg:= dmgRadius + cHHRadius div 2 - hwRound(Distance(Gear^.X - int2hwFloat(X), Gear^.Y - int2hwFloat(Y))); |
|
93 |
//if (dmg > 1) and |
|
94 |
if (Gear^.State and gstNoDamage) = 0 then |
|
95 |
begin |
|
96 |
case Gear^.Kind of |
|
97 |
gtHedgehog, |
|
98 |
gtMine, |
|
99 |
gtBall, |
|
100 |
gtMelonPiece, |
|
101 |
gtGrenade, |
|
102 |
gtClusterBomb, |
|
103 |
// gtCluster, too game breaking I think |
|
104 |
gtSMine, |
|
105 |
gtCase, |
|
106 |
gtTarget, |
|
107 |
gtFlame, |
|
7754 | 108 |
gtKnife, |
8161 | 109 |
gtExplosives: begin //, |
110 |
//gtStructure: begin |
|
6581 | 111 |
// Run the calcs only once we know we have a type that will need damage |
6765 | 112 |
tdX:= Gear^.X-fX; |
113 |
tdY:= Gear^.Y-fY; |
|
7721 | 114 |
if LongInt(tdX.Round + tdY.Round + 2) < dmgBase then |
7272
71df899c4163
Second part of the change. Make collision check use the new mask bit.
nemo
parents:
7190
diff
changeset
|
115 |
dmg:= dmgBase - hwRound(Distance(tdX, tdY)); |
6581 | 116 |
if dmg > 1 then |
117 |
begin |
|
118 |
dmg:= ModifyDamage(min(dmg div 2, Radius), Gear); |
|
119 |
//AddFileLog('Damage: ' + inttostr(dmg)); |
|
120 |
if (Mask and EXPLNoDamage) = 0 then |
|
121 |
begin |
|
122 |
if not Gear^.Invulnerable then |
|
123 |
ApplyDamage(Gear, AttackingHog, dmg, dsExplosion) |
|
124 |
else |
|
125 |
Gear^.State:= Gear^.State or gstWinner; |
|
126 |
end; |
|
127 |
if ((Mask and EXPLDoNotTouchAny) = 0) and (((Mask and EXPLDoNotTouchHH) = 0) or (Gear^.Kind <> gtHedgehog)) then |
|
128 |
begin |
|
129 |
DeleteCI(Gear); |
|
6765 | 130 |
Gear^.dX:= Gear^.dX + SignAs(_0_005 * dmg + cHHKick, tdX)/(Gear^.Density/_3); |
131 |
Gear^.dY:= Gear^.dY + SignAs(_0_005 * dmg + cHHKick, tdY)/(Gear^.Density/_3); |
|
6581 | 132 |
|
133 |
Gear^.State:= (Gear^.State or gstMoving) and (not gstLoser); |
|
7767 | 134 |
if Gear^.Kind = gtKnife then Gear^.State:= Gear^.State and (not gstCollision); |
6581 | 135 |
if not Gear^.Invulnerable then |
136 |
Gear^.State:= (Gear^.State or gstMoving) and (not gstWinner); |
|
137 |
Gear^.Active:= true; |
|
138 |
if Gear^.Kind <> gtFlame then FollowGear:= Gear |
|
139 |
end; |
|
8763 | 140 |
if ((Mask and EXPLPoisoned) <> 0) and (Gear^.Kind = gtHedgehog) and (not Gear^.Invulnerable) and ((Gear^.State and gstHHDeath) = 0) then |
7010
10a0a31804f3
Switch effects to longint for convenience of tracking ice states. I could add a new Hedgehog value, but since we have this effects list being all useless as booleans anyway...
nemo
parents:
6990
diff
changeset
|
141 |
Gear^.Hedgehog^.Effects[hePoisoned] := 1; |
6581 | 142 |
end; |
143 |
||
144 |
end; |
|
145 |
gtGrave: begin |
|
146 |
// Run the calcs only once we know we have a type that will need damage |
|
6765 | 147 |
tdX:= Gear^.X-fX; |
148 |
tdY:= Gear^.Y-fY; |
|
7721 | 149 |
if LongInt(tdX.Round + tdY.Round + 2) < dmgBase then |
6765 | 150 |
dmg:= dmgBase - hwRound(Distance(tdX, tdY)); |
6581 | 151 |
if dmg > 1 then |
152 |
begin |
|
153 |
dmg:= ModifyDamage(min(dmg div 2, Radius), Gear); |
|
154 |
Gear^.dY:= - _0_004 * dmg; |
|
155 |
Gear^.Active:= true |
|
156 |
end |
|
157 |
end; |
|
158 |
end; |
|
159 |
end; |
|
160 |
Gear:= Gear^.NextGear |
|
161 |
end; |
|
162 |
||
163 |
if (Mask and EXPLDontDraw) = 0 then |
|
164 |
if (GameFlags and gfSolidLand) = 0 then |
|
165 |
begin |
|
166 |
cnt:= DrawExplosion(X, Y, Radius) div 1608; // approx 2 16x16 circles to erase per chunk |
|
167 |
if (cnt > 0) and (SpritesData[sprChunk].Texture <> nil) then |
|
168 |
for i:= 0 to cnt do |
|
169 |
AddVisualGear(X, Y, vgtChunk) |
|
170 |
end; |
|
171 |
||
172 |
uAIMisc.AwareOfExplosion(0, 0, 0) |
|
173 |
end; |
|
174 |
||
175 |
function ModifyDamage(dmg: Longword; Gear: PGear): Longword; |
|
176 |
var i: hwFloat; |
|
177 |
begin |
|
178 |
(* Invulnerability cannot be placed in here due to still needing kicks |
|
179 |
Not without a new damage machine. |
|
180 |
King check should be in here instead of ApplyDamage since Tiy wants them kicked less |
|
181 |
*) |
|
182 |
i:= _1; |
|
183 |
if (CurrentHedgehog <> nil) and CurrentHedgehog^.King then |
|
184 |
i:= _1_5; |
|
8632
b5ed76d2a1f9
Make hogs thaw only on enemy turns, make timebox counter decrement only on your turn, adjust knock for frozen hogs, increase damage on frozen hogs, make freezer fuel only reduce when not adjusting angle.
nemo
parents:
8560
diff
changeset
|
185 |
if (Gear^.Hedgehog <> nil) and (Gear^.Hedgehog^.King or (Gear^.Hedgehog^.Effects[heFrozen] > 0)) then |
6581 | 186 |
ModifyDamage:= hwRound(_0_01 * cDamageModifier * dmg * i * cDamagePercent * _0_5) |
187 |
else |
|
188 |
ModifyDamage:= hwRound(_0_01 * cDamageModifier * dmg * i * cDamagePercent) |
|
189 |
end; |
|
190 |
||
191 |
procedure ApplyDamage(Gear: PGear; AttackerHog: PHedgehog; Damage: Longword; Source: TDamageSource); |
|
192 |
var s: shortstring; |
|
193 |
vampDmg, tmpDmg, i: Longword; |
|
194 |
vg: PVisualGear; |
|
195 |
begin |
|
196 |
if Damage = 0 then |
|
197 |
exit; // nothing to apply |
|
198 |
||
199 |
if (Gear^.Kind = gtHedgehog) then |
|
200 |
begin |
|
201 |
Gear^.LastDamage := AttackerHog; |
|
202 |
||
203 |
Gear^.Hedgehog^.Team^.Clan^.Flawless:= false; |
|
204 |
HHHurt(Gear^.Hedgehog, Source); |
|
205 |
AddDamageTag(hwRound(Gear^.X), hwRound(Gear^.Y), Damage, Gear^.Hedgehog^.Team^.Clan^.Color); |
|
206 |
tmpDmg:= min(Damage, max(0,Gear^.Health-Gear^.Damage)); |
|
207 |
if (Gear <> CurrentHedgehog^.Gear) and (CurrentHedgehog^.Gear <> nil) and (tmpDmg >= 1) then |
|
208 |
begin |
|
209 |
if cVampiric then |
|
210 |
begin |
|
211 |
vampDmg:= hwRound(int2hwFloat(tmpDmg)*_0_8); |
|
212 |
if vampDmg >= 1 then |
|
213 |
begin |
|
214 |
// was considering pulsing on attack, Tiy thinks it should be permanent while in play |
|
215 |
//CurrentHedgehog^.Gear^.State:= CurrentHedgehog^.Gear^.State or gstVampiric; |
|
216 |
inc(CurrentHedgehog^.Gear^.Health,vampDmg); |
|
217 |
str(vampDmg, s); |
|
218 |
s:= '+' + s; |
|
219 |
AddCaption(s, CurrentHedgehog^.Team^.Clan^.Color, capgrpAmmoinfo); |
|
220 |
RenderHealth(CurrentHedgehog^); |
|
221 |
RecountTeamHealth(CurrentHedgehog^.Team); |
|
222 |
i:= 0; |
|
223 |
while i < vampDmg do |
|
224 |
begin |
|
225 |
vg:= AddVisualGear(hwRound(CurrentHedgehog^.Gear^.X), hwRound(CurrentHedgehog^.Gear^.Y), vgtStraightShot); |
|
226 |
if vg <> nil then |
|
227 |
with vg^ do |
|
228 |
begin |
|
229 |
Tint:= $FF0000FF; |
|
230 |
State:= ord(sprHealth) |
|
231 |
end; |
|
232 |
inc(i, 5); |
|
233 |
end; |
|
234 |
end |
|
235 |
end; |
|
236 |
if ((GameFlags and gfKarma) <> 0) and |
|
237 |
((GameFlags and gfInvulnerable) = 0) |
|
238 |
and (not CurrentHedgehog^.Gear^.Invulnerable) then |
|
239 |
begin // this cannot just use Damage or it interrupts shotgun and gets you called stupid |
|
240 |
inc(CurrentHedgehog^.Gear^.Karma, tmpDmg); |
|
241 |
CurrentHedgehog^.Gear^.LastDamage := CurrentHedgehog; |
|
242 |
spawnHealthTagForHH(CurrentHedgehog^.Gear, tmpDmg); |
|
243 |
end; |
|
244 |
uStats.HedgehogDamaged(Gear, AttackerHog, Damage, false); |
|
245 |
end; |
|
8199
886ed135665b
Fix crashes and wtf behaviour introduced in r0b8beacff8a5
unc0rr
parents:
8161
diff
changeset
|
246 |
end else |
8161 | 247 |
//else if Gear^.Kind <> gtStructure then // not gtHedgehog nor gtStructure |
6581 | 248 |
Gear^.Hedgehog:= AttackerHog; |
249 |
inc(Gear^.Damage, Damage); |
|
250 |
||
251 |
ScriptCall('onGearDamage', Gear^.UID, Damage); |
|
252 |
end; |
|
253 |
||
254 |
procedure spawnHealthTagForHH(HHGear: PGear; dmg: Longword); |
|
255 |
var tag: PVisualGear; |
|
256 |
begin |
|
257 |
tag:= AddVisualGear(hwRound(HHGear^.X), hwRound(HHGear^.Y), vgtHealthTag, dmg); |
|
258 |
if (tag <> nil) then |
|
259 |
tag^.Hedgehog:= HHGear^.Hedgehog; // the tag needs the tag to determine the text color |
|
260 |
AllInactive:= false; |
|
261 |
HHGear^.Active:= true; |
|
262 |
end; |
|
263 |
||
264 |
procedure HHHurt(Hedgehog: PHedgehog; Source: TDamageSource); |
|
265 |
begin |
|
266 |
if (Source = dsFall) or (Source = dsExplosion) then |
|
267 |
case random(3) of |
|
7053 | 268 |
0: PlaySoundV(sndOoff1, Hedgehog^.Team^.voicepack); |
269 |
1: PlaySoundV(sndOoff2, Hedgehog^.Team^.voicepack); |
|
270 |
2: PlaySoundV(sndOoff3, Hedgehog^.Team^.voicepack); |
|
6581 | 271 |
end |
272 |
else if (Source = dsPoison) then |
|
273 |
case random(2) of |
|
7053 | 274 |
0: PlaySoundV(sndPoisonCough, Hedgehog^.Team^.voicepack); |
275 |
1: PlaySoundV(sndPoisonMoan, Hedgehog^.Team^.voicepack); |
|
6581 | 276 |
end |
277 |
else |
|
278 |
case random(4) of |
|
7053 | 279 |
0: PlaySoundV(sndOw1, Hedgehog^.Team^.voicepack); |
280 |
1: PlaySoundV(sndOw2, Hedgehog^.Team^.voicepack); |
|
281 |
2: PlaySoundV(sndOw3, Hedgehog^.Team^.voicepack); |
|
282 |
3: PlaySoundV(sndOw4, Hedgehog^.Team^.voicepack); |
|
6581 | 283 |
end |
284 |
end; |
|
285 |
||
286 |
procedure CheckHHDamage(Gear: PGear); |
|
287 |
var |
|
288 |
dmg: Longword; |
|
8003 | 289 |
i: LongWord; |
6581 | 290 |
particle: PVisualGear; |
291 |
begin |
|
292 |
if _0_4 < Gear^.dY then |
|
293 |
begin |
|
8966
5ab59d79bc9a
remove redundant abs, and some incorrect 1+ to damage
nemo
parents:
8947
diff
changeset
|
294 |
dmg := ModifyDamage(1 + hwRound((Gear^.dY - _0_4) * 70), Gear); |
6581 | 295 |
PlaySound(sndBump); |
296 |
if dmg < 1 then |
|
297 |
exit; |
|
298 |
||
299 |
for i:= min(12, (3 + dmg div 10)) downto 0 do |
|
300 |
begin |
|
301 |
particle := AddVisualGear(hwRound(Gear^.X) - 5 + Random(10), hwRound(Gear^.Y) + 12, vgtDust); |
|
302 |
if particle <> nil then |
|
303 |
particle^.dX := particle^.dX + (Gear^.dX.QWordValue / 21474836480); |
|
304 |
end; |
|
305 |
||
306 |
if (Gear^.Invulnerable) then |
|
307 |
exit; |
|
308 |
||
309 |
//if _0_6 < Gear^.dY then |
|
310 |
// PlaySound(sndOw4, Gear^.Hedgehog^.Team^.voicepack) |
|
311 |
//else |
|
312 |
// PlaySound(sndOw1, Gear^.Hedgehog^.Team^.voicepack); |
|
313 |
||
314 |
if Gear^.LastDamage <> nil then |
|
315 |
ApplyDamage(Gear, Gear^.LastDamage, dmg, dsFall) |
|
316 |
else |
|
317 |
ApplyDamage(Gear, CurrentHedgehog, dmg, dsFall); |
|
318 |
end |
|
319 |
end; |
|
320 |
||
321 |
||
322 |
procedure CalcRotationDirAngle(Gear: PGear); |
|
323 |
var |
|
324 |
dAngle: real; |
|
325 |
begin |
|
7825 | 326 |
// Frac/Round to be kind to JS as of 2012-08-27 where there is yet no int64/uint64 |
327 |
//dAngle := (Gear^.dX.QWordValue + Gear^.dY.QWordValue) / $80000000; |
|
328 |
dAngle := (Gear^.dX.Round + Gear^.dY.Round) / 2 + (Gear^.dX.Frac/$100000000+Gear^.dY.Frac/$100000000); |
|
6581 | 329 |
if not Gear^.dX.isNegative then |
330 |
Gear^.DirAngle := Gear^.DirAngle + dAngle |
|
331 |
else |
|
332 |
Gear^.DirAngle := Gear^.DirAngle - dAngle; |
|
333 |
||
334 |
if Gear^.DirAngle < 0 then |
|
335 |
Gear^.DirAngle := Gear^.DirAngle + 360 |
|
336 |
else if 360 < Gear^.DirAngle then |
|
337 |
Gear^.DirAngle := Gear^.DirAngle - 360 |
|
338 |
end; |
|
339 |
||
8947
e906ebd59612
CheckGearDrowning could delete hedgehogs gear! (CheckGearDrowning -> ResurrectHedgehog -> FindPlace). Fixes bug 620.
unc0rr
parents:
8763
diff
changeset
|
340 |
function CheckGearDrowning(var Gear: PGear): boolean; |
6581 | 341 |
var |
342 |
skipSpeed, skipAngle, skipDecay: hwFloat; |
|
343 |
i, maxDrops, X, Y: LongInt; |
|
344 |
vdX, vdY: real; |
|
6803
0e70f3ea3bf8
bit of an experiment in variable splash sizes based on object/speed. not sure if it looks good yet. need to drown more stuff.
nemo
parents:
6769
diff
changeset
|
345 |
particle, splash: PVisualGear; |
6581 | 346 |
isSubmersible: boolean; |
347 |
begin |
|
348 |
// probably needs tweaking. might need to be in a case statement based upon gear type |
|
349 |
Y:= hwRound(Gear^.Y); |
|
350 |
if cWaterLine < Y + Gear^.Radius then |
|
351 |
begin |
|
7389
15c3fb4882df
Sorry about the slight delay in pickup. You can blame a few lame cheaters. This is to make their cheating a bit harder.
nemo
parents:
7372
diff
changeset
|
352 |
if Gear^.State and gstInvisible <> 0 then |
15c3fb4882df
Sorry about the slight delay in pickup. You can blame a few lame cheaters. This is to make their cheating a bit harder.
nemo
parents:
7372
diff
changeset
|
353 |
begin |
7406
1fe2c821f9bf
Try avoiding spamming the log by retaining the gears. untested.
nemo
parents:
7389
diff
changeset
|
354 |
if Gear^.Kind = gtGenericFaller then |
1fe2c821f9bf
Try avoiding spamming the log by retaining the gears. untested.
nemo
parents:
7389
diff
changeset
|
355 |
begin |
1fe2c821f9bf
Try avoiding spamming the log by retaining the gears. untested.
nemo
parents:
7389
diff
changeset
|
356 |
Gear^.X:= int2hwFloat(GetRandom(rightX-leftX)+leftX); |
1fe2c821f9bf
Try avoiding spamming the log by retaining the gears. untested.
nemo
parents:
7389
diff
changeset
|
357 |
Gear^.Y:= int2hwFloat(GetRandom(LAND_HEIGHT-topY)+topY); |
1fe2c821f9bf
Try avoiding spamming the log by retaining the gears. untested.
nemo
parents:
7389
diff
changeset
|
358 |
Gear^.dX:= _90-(GetRandomf*_360); |
1fe2c821f9bf
Try avoiding spamming the log by retaining the gears. untested.
nemo
parents:
7389
diff
changeset
|
359 |
Gear^.dY:= _90-(GetRandomf*_360) |
1fe2c821f9bf
Try avoiding spamming the log by retaining the gears. untested.
nemo
parents:
7389
diff
changeset
|
360 |
end |
1fe2c821f9bf
Try avoiding spamming the log by retaining the gears. untested.
nemo
parents:
7389
diff
changeset
|
361 |
else DeleteGear(Gear); |
7389
15c3fb4882df
Sorry about the slight delay in pickup. You can blame a few lame cheaters. This is to make their cheating a bit harder.
nemo
parents:
7372
diff
changeset
|
362 |
exit |
15c3fb4882df
Sorry about the slight delay in pickup. You can blame a few lame cheaters. This is to make their cheating a bit harder.
nemo
parents:
7372
diff
changeset
|
363 |
end; |
8987
47cf32305d99
some saucer thing for firing weps underwater and aiming and such. bit drunk and sleepy so testing I guess
nemo
parents:
8966
diff
changeset
|
364 |
isSubmersible:= ((Gear = CurrentHedgehog^.Gear) and (CurAmmoGear <> nil) and (CurAmmoGear^.AmmoType = amJetpack)) or (Gear^.State and gstNoDrown <> 0); |
6581 | 365 |
skipSpeed := _0_25; |
366 |
skipAngle := _1_9; |
|
367 |
skipDecay := _0_87; |
|
368 |
X:= hwRound(Gear^.X); |
|
369 |
vdX:= hwFloat2Float(Gear^.dX); |
|
370 |
vdY:= hwFloat2Float(Gear^.dY); |
|
371 |
// this could perhaps be a tiny bit higher. |
|
8990 | 372 |
if (cWaterLine + 64 + Gear^.Radius > Y) and (hwSqr(Gear^.dX) + hwSqr(Gear^.dY) > skipSpeed) |
6581 | 373 |
and (hwAbs(Gear^.dX) > skipAngle * hwAbs(Gear^.dY)) then |
374 |
begin |
|
375 |
Gear^.dY.isNegative := true; |
|
376 |
Gear^.dY := Gear^.dY * skipDecay; |
|
377 |
Gear^.dX := Gear^.dX * skipDecay; |
|
378 |
CheckGearDrowning := false; |
|
379 |
PlaySound(sndSkip) |
|
380 |
end |
|
381 |
else |
|
382 |
begin |
|
383 |
if not isSubmersible then |
|
384 |
begin |
|
385 |
CheckGearDrowning := true; |
|
386 |
Gear^.State := gstDrowning; |
|
387 |
Gear^.RenderTimer := false; |
|
388 |
if (Gear^.Kind <> gtSniperRifleShot) and (Gear^.Kind <> gtShotgunShot) |
|
389 |
and (Gear^.Kind <> gtDEagleShot) and (Gear^.Kind <> gtSineGunShot) then |
|
390 |
if Gear^.Kind = gtHedgehog then |
|
391 |
begin |
|
7010
10a0a31804f3
Switch effects to longint for convenience of tracking ice states. I could add a new Hedgehog value, but since we have this effects list being all useless as booleans anyway...
nemo
parents:
6990
diff
changeset
|
392 |
if Gear^.Hedgehog^.Effects[heResurrectable] <> 0 then |
8947
e906ebd59612
CheckGearDrowning could delete hedgehogs gear! (CheckGearDrowning -> ResurrectHedgehog -> FindPlace). Fixes bug 620.
unc0rr
parents:
8763
diff
changeset
|
393 |
begin |
e906ebd59612
CheckGearDrowning could delete hedgehogs gear! (CheckGearDrowning -> ResurrectHedgehog -> FindPlace). Fixes bug 620.
unc0rr
parents:
8763
diff
changeset
|
394 |
// Gear could become nil after this, just exit to skip splashes |
e906ebd59612
CheckGearDrowning could delete hedgehogs gear! (CheckGearDrowning -> ResurrectHedgehog -> FindPlace). Fixes bug 620.
unc0rr
parents:
8763
diff
changeset
|
395 |
ResurrectHedgehog(Gear); |
e906ebd59612
CheckGearDrowning could delete hedgehogs gear! (CheckGearDrowning -> ResurrectHedgehog -> FindPlace). Fixes bug 620.
unc0rr
parents:
8763
diff
changeset
|
396 |
exit |
e906ebd59612
CheckGearDrowning could delete hedgehogs gear! (CheckGearDrowning -> ResurrectHedgehog -> FindPlace). Fixes bug 620.
unc0rr
parents:
8763
diff
changeset
|
397 |
end |
6581 | 398 |
else |
399 |
begin |
|
400 |
Gear^.doStep := @doStepDrowningGear; |
|
401 |
Gear^.State := Gear^.State and (not gstHHDriven); |
|
402 |
AddCaption(Format(GetEventString(eidDrowned), Gear^.Hedgehog^.Name), cWhiteColor, capgrpMessage); |
|
403 |
end |
|
404 |
end |
|
405 |
else |
|
406 |
Gear^.doStep := @doStepDrowningGear; |
|
407 |
if Gear^.Kind = gtFlake then |
|
408 |
exit // skip splashes |
|
8990 | 409 |
end |
8991
82e3a6e5d51b
Actually, let's use *4 since could be fired from lower down
nemo
parents:
8990
diff
changeset
|
410 |
else if (Y > cWaterLine + cVisibleWater*4) and |
8990 | 411 |
((Gear <> CurrentHedgehog^.Gear) or (CurAmmoGear = nil) or (CurAmmoGear^.AmmoType <> amJetpack)) then |
412 |
Gear^.doStep:= @doStepDrowningGear; |
|
6581 | 413 |
if ((not isSubmersible) and (Y < cWaterLine + 64 + Gear^.Radius)) |
8989 | 414 |
or (isSubmersible and (Y < cWaterLine + 2 + Gear^.Radius) and (Gear = CurAmmoGear) and ((CurAmmoGear^.Pos = 0) |
6581 | 415 |
and (CurAmmoGear^.dY < _0_01))) then |
6804 | 416 |
if Gear^.Density * Gear^.dY > _1 then |
417 |
PlaySound(sndSplash) |
|
418 |
else if Gear^.Density * Gear^.dY > _0_5 then |
|
419 |
PlaySound(sndSkip) |
|
420 |
else |
|
421 |
PlaySound(sndDroplet2); |
|
6581 | 422 |
end; |
423 |
||
424 |
if ((cReducedQuality and rqPlainSplash) = 0) |
|
425 |
and (((not isSubmersible) and (Y < cWaterLine + 64 + Gear^.Radius)) |
|
8989 | 426 |
or (isSubmersible and (Y < cWaterLine + 2 + Gear^.Radius) and (Gear = CurAmmoGear) and ((CurAmmoGear^.Pos = 0) |
6581 | 427 |
and (CurAmmoGear^.dY < _0_01)))) then |
428 |
begin |
|
6803
0e70f3ea3bf8
bit of an experiment in variable splash sizes based on object/speed. not sure if it looks good yet. need to drown more stuff.
nemo
parents:
6769
diff
changeset
|
429 |
splash:= AddVisualGear(X, cWaterLine, vgtSplash); |
0e70f3ea3bf8
bit of an experiment in variable splash sizes based on object/speed. not sure if it looks good yet. need to drown more stuff.
nemo
parents:
6769
diff
changeset
|
430 |
if splash <> nil then |
7372
fcc002658832
Spread the droplets around more so it looks less square (looked especially bad with piano). Slow down large splashes a bit for dramatic purposes, also taking low-g into account. Small splashes you can't really tell anyway.
nemo
parents:
7357
diff
changeset
|
431 |
with splash^ do |
6803
0e70f3ea3bf8
bit of an experiment in variable splash sizes based on object/speed. not sure if it looks good yet. need to drown more stuff.
nemo
parents:
6769
diff
changeset
|
432 |
begin |
7372
fcc002658832
Spread the droplets around more so it looks less square (looked especially bad with piano). Slow down large splashes a bit for dramatic purposes, also taking low-g into account. Small splashes you can't really tell anyway.
nemo
parents:
7357
diff
changeset
|
433 |
Scale:= hwFloat2Float(Gear^.Density / _3 * Gear^.dY); |
fcc002658832
Spread the droplets around more so it looks less square (looked especially bad with piano). Slow down large splashes a bit for dramatic purposes, also taking low-g into account. Small splashes you can't really tell anyway.
nemo
parents:
7357
diff
changeset
|
434 |
if Scale > 1 then Scale:= power(Scale,0.3333) |
fcc002658832
Spread the droplets around more so it looks less square (looked especially bad with piano). Slow down large splashes a bit for dramatic purposes, also taking low-g into account. Small splashes you can't really tell anyway.
nemo
parents:
7357
diff
changeset
|
435 |
else Scale:= Scale + ((1-Scale) / 2); |
7420 | 436 |
if Scale > 1 then Timer:= round(min(Scale*0.0005/cGravityf,4)) |
7372
fcc002658832
Spread the droplets around more so it looks less square (looked especially bad with piano). Slow down large splashes a bit for dramatic purposes, also taking low-g into account. Small splashes you can't really tell anyway.
nemo
parents:
7357
diff
changeset
|
437 |
else Timer:= 1; |
fcc002658832
Spread the droplets around more so it looks less square (looked especially bad with piano). Slow down large splashes a bit for dramatic purposes, also taking low-g into account. Small splashes you can't really tell anyway.
nemo
parents:
7357
diff
changeset
|
438 |
// Low Gravity |
fcc002658832
Spread the droplets around more so it looks less square (looked especially bad with piano). Slow down large splashes a bit for dramatic purposes, also taking low-g into account. Small splashes you can't really tell anyway.
nemo
parents:
7357
diff
changeset
|
439 |
FrameTicks:= FrameTicks*Timer; |
6803
0e70f3ea3bf8
bit of an experiment in variable splash sizes based on object/speed. not sure if it looks good yet. need to drown more stuff.
nemo
parents:
6769
diff
changeset
|
440 |
end; |
6581 | 441 |
|
6803
0e70f3ea3bf8
bit of an experiment in variable splash sizes based on object/speed. not sure if it looks good yet. need to drown more stuff.
nemo
parents:
6769
diff
changeset
|
442 |
maxDrops := (hwRound(Gear^.Density) * 3) div 2 + round(vdX * hwRound(Gear^.Density) * 6) + round(vdY * hwRound(Gear^.Density) * 6); |
6581 | 443 |
for i:= max(maxDrops div 3, min(32, Random(maxDrops))) downto 0 do |
444 |
begin |
|
7372
fcc002658832
Spread the droplets around more so it looks less square (looked especially bad with piano). Slow down large splashes a bit for dramatic purposes, also taking low-g into account. Small splashes you can't really tell anyway.
nemo
parents:
7357
diff
changeset
|
445 |
particle := AddVisualGear(X - 3 + Random(7), cWaterLine, vgtDroplet); |
6581 | 446 |
if particle <> nil then |
7372
fcc002658832
Spread the droplets around more so it looks less square (looked especially bad with piano). Slow down large splashes a bit for dramatic purposes, also taking low-g into account. Small splashes you can't really tell anyway.
nemo
parents:
7357
diff
changeset
|
447 |
with particle^ do |
6803
0e70f3ea3bf8
bit of an experiment in variable splash sizes based on object/speed. not sure if it looks good yet. need to drown more stuff.
nemo
parents:
6769
diff
changeset
|
448 |
begin |
7372
fcc002658832
Spread the droplets around more so it looks less square (looked especially bad with piano). Slow down large splashes a bit for dramatic purposes, also taking low-g into account. Small splashes you can't really tell anyway.
nemo
parents:
7357
diff
changeset
|
449 |
dX := dX - vdX / 10; |
fcc002658832
Spread the droplets around more so it looks less square (looked especially bad with piano). Slow down large splashes a bit for dramatic purposes, also taking low-g into account. Small splashes you can't really tell anyway.
nemo
parents:
7357
diff
changeset
|
450 |
dY := dY - vdY / 5; |
fcc002658832
Spread the droplets around more so it looks less square (looked especially bad with piano). Slow down large splashes a bit for dramatic purposes, also taking low-g into account. Small splashes you can't really tell anyway.
nemo
parents:
7357
diff
changeset
|
451 |
if splash <> nil then |
6803
0e70f3ea3bf8
bit of an experiment in variable splash sizes based on object/speed. not sure if it looks good yet. need to drown more stuff.
nemo
parents:
6769
diff
changeset
|
452 |
begin |
7372
fcc002658832
Spread the droplets around more so it looks less square (looked especially bad with piano). Slow down large splashes a bit for dramatic purposes, also taking low-g into account. Small splashes you can't really tell anyway.
nemo
parents:
7357
diff
changeset
|
453 |
if splash^.Scale > 1 then |
fcc002658832
Spread the droplets around more so it looks less square (looked especially bad with piano). Slow down large splashes a bit for dramatic purposes, also taking low-g into account. Small splashes you can't really tell anyway.
nemo
parents:
7357
diff
changeset
|
454 |
begin |
fcc002658832
Spread the droplets around more so it looks less square (looked especially bad with piano). Slow down large splashes a bit for dramatic purposes, also taking low-g into account. Small splashes you can't really tell anyway.
nemo
parents:
7357
diff
changeset
|
455 |
dX:= dX * power(splash^.Scale,0.3333); // tone down the droplet height further |
fcc002658832
Spread the droplets around more so it looks less square (looked especially bad with piano). Slow down large splashes a bit for dramatic purposes, also taking low-g into account. Small splashes you can't really tell anyway.
nemo
parents:
7357
diff
changeset
|
456 |
dY:= dY * power(splash^.Scale, 0.3333) |
fcc002658832
Spread the droplets around more so it looks less square (looked especially bad with piano). Slow down large splashes a bit for dramatic purposes, also taking low-g into account. Small splashes you can't really tell anyway.
nemo
parents:
7357
diff
changeset
|
457 |
end |
fcc002658832
Spread the droplets around more so it looks less square (looked especially bad with piano). Slow down large splashes a bit for dramatic purposes, also taking low-g into account. Small splashes you can't really tell anyway.
nemo
parents:
7357
diff
changeset
|
458 |
else |
fcc002658832
Spread the droplets around more so it looks less square (looked especially bad with piano). Slow down large splashes a bit for dramatic purposes, also taking low-g into account. Small splashes you can't really tell anyway.
nemo
parents:
7357
diff
changeset
|
459 |
begin |
fcc002658832
Spread the droplets around more so it looks less square (looked especially bad with piano). Slow down large splashes a bit for dramatic purposes, also taking low-g into account. Small splashes you can't really tell anyway.
nemo
parents:
7357
diff
changeset
|
460 |
dX:= dX * splash^.Scale; |
fcc002658832
Spread the droplets around more so it looks less square (looked especially bad with piano). Slow down large splashes a bit for dramatic purposes, also taking low-g into account. Small splashes you can't really tell anyway.
nemo
parents:
7357
diff
changeset
|
461 |
dY:= dY * splash^.Scale |
fcc002658832
Spread the droplets around more so it looks less square (looked especially bad with piano). Slow down large splashes a bit for dramatic purposes, also taking low-g into account. Small splashes you can't really tell anyway.
nemo
parents:
7357
diff
changeset
|
462 |
end |
6803
0e70f3ea3bf8
bit of an experiment in variable splash sizes based on object/speed. not sure if it looks good yet. need to drown more stuff.
nemo
parents:
6769
diff
changeset
|
463 |
end |
0e70f3ea3bf8
bit of an experiment in variable splash sizes based on object/speed. not sure if it looks good yet. need to drown more stuff.
nemo
parents:
6769
diff
changeset
|
464 |
end |
6581 | 465 |
end |
466 |
end; |
|
8989 | 467 |
if isSubmersible and (Gear = CurAmmoGear) and (CurAmmoGear^.Pos = 0) then |
6581 | 468 |
CurAmmoGear^.Pos := 1000 |
469 |
end |
|
470 |
else |
|
471 |
CheckGearDrowning := false; |
|
472 |
end; |
|
473 |
||
474 |
||
8947
e906ebd59612
CheckGearDrowning could delete hedgehogs gear! (CheckGearDrowning -> ResurrectHedgehog -> FindPlace). Fixes bug 620.
unc0rr
parents:
8763
diff
changeset
|
475 |
procedure ResurrectHedgehog(var gear: PGear); |
6581 | 476 |
var tempTeam : PTeam; |
7092
c9ca770fd7fc
Add an emergency return to the timebox in the case of death of rest of team. Also add a small visual effect to AI survival
nemo
parents:
7066
diff
changeset
|
477 |
sparkles: PVisualGear; |
c9ca770fd7fc
Add an emergency return to the timebox in the case of death of rest of team. Also add a small visual effect to AI survival
nemo
parents:
7066
diff
changeset
|
478 |
gX, gY: LongInt; |
6581 | 479 |
begin |
7357
06454899d0d2
Score AI resurrection as a kill. These values will not be the same as the in-game scoring, since in-game scoring doesn't count friendlies.
nemo
parents:
7272
diff
changeset
|
480 |
if (Gear^.LastDamage <> nil) then |
06454899d0d2
Score AI resurrection as a kill. These values will not be the same as the in-game scoring, since in-game scoring doesn't count friendlies.
nemo
parents:
7272
diff
changeset
|
481 |
uStats.HedgehogDamaged(Gear, Gear^.LastDamage, 0, true) |
06454899d0d2
Score AI resurrection as a kill. These values will not be the same as the in-game scoring, since in-game scoring doesn't count friendlies.
nemo
parents:
7272
diff
changeset
|
482 |
else |
06454899d0d2
Score AI resurrection as a kill. These values will not be the same as the in-game scoring, since in-game scoring doesn't count friendlies.
nemo
parents:
7272
diff
changeset
|
483 |
uStats.HedgehogDamaged(Gear, CurrentHedgehog, 0, true); |
6581 | 484 |
AttackBar:= 0; |
485 |
gear^.dX := _0; |
|
486 |
gear^.dY := _0; |
|
487 |
gear^.Damage := 0; |
|
488 |
gear^.Health := gear^.Hedgehog^.InitialHealth; |
|
7010
10a0a31804f3
Switch effects to longint for convenience of tracking ice states. I could add a new Hedgehog value, but since we have this effects list being all useless as booleans anyway...
nemo
parents:
6990
diff
changeset
|
489 |
gear^.Hedgehog^.Effects[hePoisoned] := 0; |
7176
fb4b0c6dfdbd
Make watching AI v AI on ai survival a bit more entertaining
nemo
parents:
7168
diff
changeset
|
490 |
if (CurrentHedgehog^.Effects[heResurrectable] = 0) or ((CurrentHedgehog^.Effects[heResurrectable] <> 0) |
fb4b0c6dfdbd
Make watching AI v AI on ai survival a bit more entertaining
nemo
parents:
7168
diff
changeset
|
491 |
and (Gear^.Hedgehog^.Team^.Clan <> CurrentHedgehog^.Team^.Clan)) then |
6581 | 492 |
with CurrentHedgehog^ do |
493 |
begin |
|
494 |
inc(Team^.stats.AIKills); |
|
495 |
FreeTexture(Team^.AIKillsTex); |
|
496 |
Team^.AIKillsTex := RenderStringTex(inttostr(Team^.stats.AIKills), Team^.Clan^.Color, fnt16); |
|
497 |
end; |
|
498 |
tempTeam := gear^.Hedgehog^.Team; |
|
499 |
DeleteCI(gear); |
|
7092
c9ca770fd7fc
Add an emergency return to the timebox in the case of death of rest of team. Also add a small visual effect to AI survival
nemo
parents:
7066
diff
changeset
|
500 |
gX := hwRound(gear^.X); |
c9ca770fd7fc
Add an emergency return to the timebox in the case of death of rest of team. Also add a small visual effect to AI survival
nemo
parents:
7066
diff
changeset
|
501 |
gY := hwRound(gear^.Y); |
c9ca770fd7fc
Add an emergency return to the timebox in the case of death of rest of team. Also add a small visual effect to AI survival
nemo
parents:
7066
diff
changeset
|
502 |
// might need more sparkles for a column |
c9ca770fd7fc
Add an emergency return to the timebox in the case of death of rest of team. Also add a small visual effect to AI survival
nemo
parents:
7066
diff
changeset
|
503 |
sparkles:= AddVisualGear(gX, gY, vgtDust, 1); |
c9ca770fd7fc
Add an emergency return to the timebox in the case of death of rest of team. Also add a small visual effect to AI survival
nemo
parents:
7066
diff
changeset
|
504 |
if sparkles <> nil then |
c9ca770fd7fc
Add an emergency return to the timebox in the case of death of rest of team. Also add a small visual effect to AI survival
nemo
parents:
7066
diff
changeset
|
505 |
begin |
c9ca770fd7fc
Add an emergency return to the timebox in the case of death of rest of team. Also add a small visual effect to AI survival
nemo
parents:
7066
diff
changeset
|
506 |
sparkles^.Tint:= tempTeam^.Clan^.Color shl 8 or $FF; |
c9ca770fd7fc
Add an emergency return to the timebox in the case of death of rest of team. Also add a small visual effect to AI survival
nemo
parents:
7066
diff
changeset
|
507 |
//sparkles^.Angle:= random(360); |
c9ca770fd7fc
Add an emergency return to the timebox in the case of death of rest of team. Also add a small visual effect to AI survival
nemo
parents:
7066
diff
changeset
|
508 |
end; |
6581 | 509 |
FindPlace(gear, false, 0, LAND_WIDTH, true); |
510 |
if gear <> nil then |
|
511 |
begin |
|
7092
c9ca770fd7fc
Add an emergency return to the timebox in the case of death of rest of team. Also add a small visual effect to AI survival
nemo
parents:
7066
diff
changeset
|
512 |
AddVisualGear(hwRound(gear^.X), hwRound(gear^.Y), vgtExplosion); |
7168
8defaabce92e
warp sound when AI survival hog respawns. attempt at a bit of a crate spawn animation (moar sparkles and a quick fadein)
nemo
parents:
7092
diff
changeset
|
513 |
PlaySound(sndWarp); |
6581 | 514 |
RenderHealth(gear^.Hedgehog^); |
515 |
ScriptCall('onGearResurrect', gear^.uid); |
|
516 |
gear^.State := gstWait; |
|
8947
e906ebd59612
CheckGearDrowning could delete hedgehogs gear! (CheckGearDrowning -> ResurrectHedgehog -> FindPlace). Fixes bug 620.
unc0rr
parents:
8763
diff
changeset
|
517 |
end; |
6581 | 518 |
RecountTeamHealth(tempTeam); |
519 |
end; |
|
520 |
||
7190
aa8d68817c32
Make it AI survival almost definitely impossible by adding a 3rd pass to FindGear. 1st pass normal, 2nd pass allow close to objects, 3rd pass, allow overlapping objects.
nemo
parents:
7176
diff
changeset
|
521 |
function CountNonZeroz(x, y, r, c: LongInt; mask: LongWord): LongInt; |
6581 | 522 |
var i: LongInt; |
523 |
count: LongInt = 0; |
|
524 |
begin |
|
6990
40e5af28d026
change every return value into a more pascal-ish form, using the name of the fucntion (helps the parser and macpas compaitilibity)
koda
parents:
6986
diff
changeset
|
525 |
if (y and LAND_HEIGHT_MASK) = 0 then |
7509 | 526 |
for i:= max(x - r, 0) to min(x + r, LAND_WIDTH - 4) do |
7190
aa8d68817c32
Make it AI survival almost definitely impossible by adding a 3rd pass to FindGear. 1st pass normal, 2nd pass allow close to objects, 3rd pass, allow overlapping objects.
nemo
parents:
7176
diff
changeset
|
527 |
if Land[y, i] and mask <> 0 then |
6581 | 528 |
begin |
6990
40e5af28d026
change every return value into a more pascal-ish form, using the name of the fucntion (helps the parser and macpas compaitilibity)
koda
parents:
6986
diff
changeset
|
529 |
inc(count); |
40e5af28d026
change every return value into a more pascal-ish form, using the name of the fucntion (helps the parser and macpas compaitilibity)
koda
parents:
6986
diff
changeset
|
530 |
if count = c then |
40e5af28d026
change every return value into a more pascal-ish form, using the name of the fucntion (helps the parser and macpas compaitilibity)
koda
parents:
6986
diff
changeset
|
531 |
begin |
40e5af28d026
change every return value into a more pascal-ish form, using the name of the fucntion (helps the parser and macpas compaitilibity)
koda
parents:
6986
diff
changeset
|
532 |
CountNonZeroz:= count; |
40e5af28d026
change every return value into a more pascal-ish form, using the name of the fucntion (helps the parser and macpas compaitilibity)
koda
parents:
6986
diff
changeset
|
533 |
exit |
40e5af28d026
change every return value into a more pascal-ish form, using the name of the fucntion (helps the parser and macpas compaitilibity)
koda
parents:
6986
diff
changeset
|
534 |
end; |
6581 | 535 |
end; |
6990
40e5af28d026
change every return value into a more pascal-ish form, using the name of the fucntion (helps the parser and macpas compaitilibity)
koda
parents:
6986
diff
changeset
|
536 |
CountNonZeroz:= count; |
6581 | 537 |
end; |
538 |
||
6888 | 539 |
|
540 |
function NoGearsToAvoid(mX, mY: LongInt; rX, rY: LongInt): boolean; |
|
541 |
var t: PGear; |
|
542 |
begin |
|
6990
40e5af28d026
change every return value into a more pascal-ish form, using the name of the fucntion (helps the parser and macpas compaitilibity)
koda
parents:
6986
diff
changeset
|
543 |
NoGearsToAvoid:= false; |
6888 | 544 |
t:= GearsList; |
545 |
rX:= sqr(rX); |
|
546 |
rY:= sqr(rY); |
|
547 |
while t <> nil do |
|
548 |
begin |
|
549 |
if t^.Kind <= gtExplosives then |
|
550 |
if not (hwSqr(int2hwFloat(mX) - t^.X) / rX + hwSqr(int2hwFloat(mY) - t^.Y) / rY > _1) then |
|
6990
40e5af28d026
change every return value into a more pascal-ish form, using the name of the fucntion (helps the parser and macpas compaitilibity)
koda
parents:
6986
diff
changeset
|
551 |
exit; |
6888 | 552 |
t:= t^.NextGear |
553 |
end; |
|
554 |
NoGearsToAvoid:= true |
|
555 |
end; |
|
556 |
||
6986
409dd3851309
add support for default pascal mode by removing default arguments value (maybe this also helps the parser)
koda
parents:
6888
diff
changeset
|
557 |
procedure FindPlace(var Gear: PGear; withFall: boolean; Left, Right: LongInt); inline; |
409dd3851309
add support for default pascal mode by removing default arguments value (maybe this also helps the parser)
koda
parents:
6888
diff
changeset
|
558 |
begin |
409dd3851309
add support for default pascal mode by removing default arguments value (maybe this also helps the parser)
koda
parents:
6888
diff
changeset
|
559 |
FindPlace(Gear, withFall, Left, Right, false); |
409dd3851309
add support for default pascal mode by removing default arguments value (maybe this also helps the parser)
koda
parents:
6888
diff
changeset
|
560 |
end; |
6888 | 561 |
|
6581 | 562 |
procedure FindPlace(var Gear: PGear; withFall: boolean; Left, Right: LongInt; skipProximity: boolean); |
563 |
var x: LongInt; |
|
564 |
y, sy: LongInt; |
|
8007 | 565 |
ar: array[0..1023] of TPoint; |
566 |
ar2: array[0..2047] of TPoint; |
|
6581 | 567 |
cnt, cnt2: Longword; |
568 |
delta: LongInt; |
|
7190
aa8d68817c32
Make it AI survival almost definitely impossible by adding a 3rd pass to FindGear. 1st pass normal, 2nd pass allow close to objects, 3rd pass, allow overlapping objects.
nemo
parents:
7176
diff
changeset
|
569 |
ignoreNearObjects, ignoreOverlap, tryAgain: boolean; |
6581 | 570 |
begin |
7190
aa8d68817c32
Make it AI survival almost definitely impossible by adding a 3rd pass to FindGear. 1st pass normal, 2nd pass allow close to objects, 3rd pass, allow overlapping objects.
nemo
parents:
7176
diff
changeset
|
571 |
ignoreNearObjects:= false; // try not skipping proximity at first |
aa8d68817c32
Make it AI survival almost definitely impossible by adding a 3rd pass to FindGear. 1st pass normal, 2nd pass allow close to objects, 3rd pass, allow overlapping objects.
nemo
parents:
7176
diff
changeset
|
572 |
ignoreOverlap:= false; // this not only skips proximity, but allows overlapping objects (barrels, mines, hogs, crates). Saving it for a 3rd pass. With this active, winning AI Survival goes back to virtual impossibility |
6581 | 573 |
tryAgain:= true; |
574 |
while tryAgain do |
|
575 |
begin |
|
8007 | 576 |
delta:= LAND_WIDTH div 16; |
6581 | 577 |
cnt2:= 0; |
578 |
repeat |
|
8007 | 579 |
x:= Left + max(LAND_WIDTH div 2048, LongInt(GetRandom(Delta))); |
6581 | 580 |
repeat |
581 |
inc(x, Delta); |
|
582 |
cnt:= 0; |
|
7603
e9c3c67b5dfd
reducing this value is sufficient to ensure crates drop just below top border or a girder
nemo
parents:
7599
diff
changeset
|
583 |
y:= min(1024, topY) - 2 * Gear^.Radius; |
6581 | 584 |
while y < cWaterLine do |
585 |
begin |
|
586 |
repeat |
|
587 |
inc(y, 2); |
|
7190
aa8d68817c32
Make it AI survival almost definitely impossible by adding a 3rd pass to FindGear. 1st pass normal, 2nd pass allow close to objects, 3rd pass, allow overlapping objects.
nemo
parents:
7176
diff
changeset
|
588 |
until (y >= cWaterLine) or |
aa8d68817c32
Make it AI survival almost definitely impossible by adding a 3rd pass to FindGear. 1st pass normal, 2nd pass allow close to objects, 3rd pass, allow overlapping objects.
nemo
parents:
7176
diff
changeset
|
589 |
(not ignoreOverlap and (CountNonZeroz(x, y, Gear^.Radius - 1, 1, $FFFF) = 0)) or |
8751
4609823efc94
More flagging of Land values. Also use less than for tests of non-terrain, instead of "and $FF00 = 0". Saves a couple of ops, which actually matters a small amount in a few places.
nemo
parents:
8632
diff
changeset
|
590 |
(ignoreOverlap and (CountNonZeroz(x, y, Gear^.Radius - 1, 1, lfLandMask) = 0)); |
6581 | 591 |
|
592 |
sy:= y; |
|
593 |
||
594 |
repeat |
|
595 |
inc(y); |
|
7190
aa8d68817c32
Make it AI survival almost definitely impossible by adding a 3rd pass to FindGear. 1st pass normal, 2nd pass allow close to objects, 3rd pass, allow overlapping objects.
nemo
parents:
7176
diff
changeset
|
596 |
until (y >= cWaterLine) or |
aa8d68817c32
Make it AI survival almost definitely impossible by adding a 3rd pass to FindGear. 1st pass normal, 2nd pass allow close to objects, 3rd pass, allow overlapping objects.
nemo
parents:
7176
diff
changeset
|
597 |
(not ignoreOverlap and (CountNonZeroz(x, y, Gear^.Radius - 1, 1, $FFFF) <> 0)) or |
8751
4609823efc94
More flagging of Land values. Also use less than for tests of non-terrain, instead of "and $FF00 = 0". Saves a couple of ops, which actually matters a small amount in a few places.
nemo
parents:
8632
diff
changeset
|
598 |
(ignoreOverlap and (CountNonZeroz(x, y, Gear^.Radius - 1, 1, lfLandMask) <> 0)); |
6581 | 599 |
|
600 |
if (y - sy > Gear^.Radius * 2) |
|
601 |
and (((Gear^.Kind = gtExplosives) |
|
602 |
and (y < cWaterLine) |
|
7190
aa8d68817c32
Make it AI survival almost definitely impossible by adding a 3rd pass to FindGear. 1st pass normal, 2nd pass allow close to objects, 3rd pass, allow overlapping objects.
nemo
parents:
7176
diff
changeset
|
603 |
and (ignoreNearObjects or NoGearsToAvoid(x, y - Gear^.Radius, 60, 60)) |
aa8d68817c32
Make it AI survival almost definitely impossible by adding a 3rd pass to FindGear. 1st pass normal, 2nd pass allow close to objects, 3rd pass, allow overlapping objects.
nemo
parents:
7176
diff
changeset
|
604 |
and (CountNonZeroz(x, y+1, Gear^.Radius - 1, Gear^.Radius+1, $FFFF) > Gear^.Radius)) |
6581 | 605 |
or |
606 |
((Gear^.Kind <> gtExplosives) |
|
607 |
and (y < cWaterLine) |
|
7190
aa8d68817c32
Make it AI survival almost definitely impossible by adding a 3rd pass to FindGear. 1st pass normal, 2nd pass allow close to objects, 3rd pass, allow overlapping objects.
nemo
parents:
7176
diff
changeset
|
608 |
and (ignoreNearObjects or NoGearsToAvoid(x, y - Gear^.Radius, 110, 110)) |
6888 | 609 |
)) then |
610 |
begin |
|
6581 | 611 |
ar[cnt].X:= x; |
612 |
if withFall then |
|
613 |
ar[cnt].Y:= sy + Gear^.Radius |
|
614 |
else |
|
615 |
ar[cnt].Y:= y - Gear^.Radius; |
|
616 |
inc(cnt) |
|
617 |
end; |
|
618 |
||
7603
e9c3c67b5dfd
reducing this value is sufficient to ensure crates drop just below top border or a girder
nemo
parents:
7599
diff
changeset
|
619 |
inc(y, 10) |
6581 | 620 |
end; |
621 |
||
622 |
if cnt > 0 then |
|
623 |
with ar[GetRandom(cnt)] do |
|
624 |
begin |
|
625 |
ar2[cnt2].x:= x; |
|
626 |
ar2[cnt2].y:= y; |
|
627 |
inc(cnt2) |
|
628 |
end |
|
629 |
until (x + Delta > Right); |
|
630 |
||
631 |
dec(Delta, 60) |
|
632 |
until (cnt2 > 0) or (Delta < 70); |
|
7190
aa8d68817c32
Make it AI survival almost definitely impossible by adding a 3rd pass to FindGear. 1st pass normal, 2nd pass allow close to objects, 3rd pass, allow overlapping objects.
nemo
parents:
7176
diff
changeset
|
633 |
// if either of these has not been tried, do another pass |
aa8d68817c32
Make it AI survival almost definitely impossible by adding a 3rd pass to FindGear. 1st pass normal, 2nd pass allow close to objects, 3rd pass, allow overlapping objects.
nemo
parents:
7176
diff
changeset
|
634 |
if (cnt2 = 0) and skipProximity and (not ignoreOverlap) then |
6581 | 635 |
tryAgain:= true |
636 |
else tryAgain:= false; |
|
7190
aa8d68817c32
Make it AI survival almost definitely impossible by adding a 3rd pass to FindGear. 1st pass normal, 2nd pass allow close to objects, 3rd pass, allow overlapping objects.
nemo
parents:
7176
diff
changeset
|
637 |
if ignoreNearObjects then ignoreOverlap:= true; |
aa8d68817c32
Make it AI survival almost definitely impossible by adding a 3rd pass to FindGear. 1st pass normal, 2nd pass allow close to objects, 3rd pass, allow overlapping objects.
nemo
parents:
7176
diff
changeset
|
638 |
ignoreNearObjects:= true; |
6581 | 639 |
end; |
640 |
||
641 |
if cnt2 > 0 then |
|
642 |
with ar2[GetRandom(cnt2)] do |
|
643 |
begin |
|
644 |
Gear^.X:= int2hwFloat(x); |
|
645 |
Gear^.Y:= int2hwFloat(y); |
|
646 |
AddFileLog('Assigned Gear coordinates (' + inttostr(x) + ',' + inttostr(y) + ')'); |
|
647 |
end |
|
648 |
else |
|
649 |
begin |
|
650 |
OutError('Can''t find place for Gear', false); |
|
651 |
if Gear^.Kind = gtHedgehog then |
|
7010
10a0a31804f3
Switch effects to longint for convenience of tracking ice states. I could add a new Hedgehog value, but since we have this effects list being all useless as booleans anyway...
nemo
parents:
6990
diff
changeset
|
652 |
Gear^.Hedgehog^.Effects[heResurrectable] := 0; |
6581 | 653 |
DeleteGear(Gear); |
654 |
Gear:= nil |
|
655 |
end |
|
656 |
end; |
|
657 |
||
658 |
function CheckGearNear(Gear: PGear; Kind: TGearType; rX, rY: LongInt): PGear; |
|
659 |
var t: PGear; |
|
660 |
begin |
|
661 |
t:= GearsList; |
|
662 |
rX:= sqr(rX); |
|
663 |
rY:= sqr(rY); |
|
664 |
||
665 |
while t <> nil do |
|
666 |
begin |
|
667 |
if (t <> Gear) and (t^.Kind = Kind) then |
|
668 |
if not((hwSqr(Gear^.X - t^.X) / rX + hwSqr(Gear^.Y - t^.Y) / rY) > _1) then |
|
6990
40e5af28d026
change every return value into a more pascal-ish form, using the name of the fucntion (helps the parser and macpas compaitilibity)
koda
parents:
6986
diff
changeset
|
669 |
begin |
40e5af28d026
change every return value into a more pascal-ish form, using the name of the fucntion (helps the parser and macpas compaitilibity)
koda
parents:
6986
diff
changeset
|
670 |
CheckGearNear:= t; |
40e5af28d026
change every return value into a more pascal-ish form, using the name of the fucntion (helps the parser and macpas compaitilibity)
koda
parents:
6986
diff
changeset
|
671 |
exit; |
40e5af28d026
change every return value into a more pascal-ish form, using the name of the fucntion (helps the parser and macpas compaitilibity)
koda
parents:
6986
diff
changeset
|
672 |
end; |
6581 | 673 |
t:= t^.NextGear |
674 |
end; |
|
675 |
||
676 |
CheckGearNear:= nil |
|
677 |
end; |
|
678 |
||
7592 | 679 |
procedure CheckCollision(Gear: PGear); inline; |
680 |
begin |
|
681 |
if TestCollisionXwithGear(Gear, hwSign(Gear^.dX)) |
|
682 |
or (TestCollisionYwithGear(Gear, hwSign(Gear^.dY)) <> 0) then |
|
683 |
Gear^.State := Gear^.State or gstCollision |
|
684 |
else |
|
685 |
Gear^.State := Gear^.State and (not gstCollision) |
|
686 |
end; |
|
687 |
||
688 |
procedure CheckCollisionWithLand(Gear: PGear); inline; |
|
689 |
begin |
|
690 |
if TestCollisionX(Gear, hwSign(Gear^.dX)) |
|
691 |
or TestCollisionY(Gear, hwSign(Gear^.dY)) then |
|
692 |
Gear^.State := Gear^.State or gstCollision |
|
693 |
else |
|
694 |
Gear^.State := Gear^.State and (not gstCollision) |
|
695 |
end; |
|
696 |
||
7719
eeae1cb6b6bf
Move hedgehog's step routine into separate function, use it in both hedgehog and ai code
unc0rr
parents:
7627
diff
changeset
|
697 |
function MakeHedgehogsStep(Gear: PGear) : boolean; |
eeae1cb6b6bf
Move hedgehog's step routine into separate function, use it in both hedgehog and ai code
unc0rr
parents:
7627
diff
changeset
|
698 |
begin |
eeae1cb6b6bf
Move hedgehog's step routine into separate function, use it in both hedgehog and ai code
unc0rr
parents:
7627
diff
changeset
|
699 |
if TestCollisionXwithGear(Gear, hwSign(Gear^.dX)) then if (TestCollisionYwithGear(Gear, -1) = 0) then |
eeae1cb6b6bf
Move hedgehog's step routine into separate function, use it in both hedgehog and ai code
unc0rr
parents:
7627
diff
changeset
|
700 |
begin |
eeae1cb6b6bf
Move hedgehog's step routine into separate function, use it in both hedgehog and ai code
unc0rr
parents:
7627
diff
changeset
|
701 |
Gear^.Y:= Gear^.Y - _1; |
eeae1cb6b6bf
Move hedgehog's step routine into separate function, use it in both hedgehog and ai code
unc0rr
parents:
7627
diff
changeset
|
702 |
if TestCollisionXwithGear(Gear, hwSign(Gear^.dX)) then if (TestCollisionYwithGear(Gear, -1) = 0) then |
eeae1cb6b6bf
Move hedgehog's step routine into separate function, use it in both hedgehog and ai code
unc0rr
parents:
7627
diff
changeset
|
703 |
begin |
eeae1cb6b6bf
Move hedgehog's step routine into separate function, use it in both hedgehog and ai code
unc0rr
parents:
7627
diff
changeset
|
704 |
Gear^.Y:= Gear^.Y - _1; |
eeae1cb6b6bf
Move hedgehog's step routine into separate function, use it in both hedgehog and ai code
unc0rr
parents:
7627
diff
changeset
|
705 |
if TestCollisionXwithGear(Gear, hwSign(Gear^.dX)) then if (TestCollisionYwithGear(Gear, -1) = 0) then |
eeae1cb6b6bf
Move hedgehog's step routine into separate function, use it in both hedgehog and ai code
unc0rr
parents:
7627
diff
changeset
|
706 |
begin |
eeae1cb6b6bf
Move hedgehog's step routine into separate function, use it in both hedgehog and ai code
unc0rr
parents:
7627
diff
changeset
|
707 |
Gear^.Y:= Gear^.Y - _1; |
eeae1cb6b6bf
Move hedgehog's step routine into separate function, use it in both hedgehog and ai code
unc0rr
parents:
7627
diff
changeset
|
708 |
if TestCollisionXwithGear(Gear, hwSign(Gear^.dX)) then if (TestCollisionYwithGear(Gear, -1) = 0) then |
eeae1cb6b6bf
Move hedgehog's step routine into separate function, use it in both hedgehog and ai code
unc0rr
parents:
7627
diff
changeset
|
709 |
begin |
eeae1cb6b6bf
Move hedgehog's step routine into separate function, use it in both hedgehog and ai code
unc0rr
parents:
7627
diff
changeset
|
710 |
Gear^.Y:= Gear^.Y - _1; |
eeae1cb6b6bf
Move hedgehog's step routine into separate function, use it in both hedgehog and ai code
unc0rr
parents:
7627
diff
changeset
|
711 |
if TestCollisionXwithGear(Gear, hwSign(Gear^.dX)) then if (TestCollisionYwithGear(Gear, -1) = 0) then |
eeae1cb6b6bf
Move hedgehog's step routine into separate function, use it in both hedgehog and ai code
unc0rr
parents:
7627
diff
changeset
|
712 |
begin |
eeae1cb6b6bf
Move hedgehog's step routine into separate function, use it in both hedgehog and ai code
unc0rr
parents:
7627
diff
changeset
|
713 |
Gear^.Y:= Gear^.Y - _1; |
eeae1cb6b6bf
Move hedgehog's step routine into separate function, use it in both hedgehog and ai code
unc0rr
parents:
7627
diff
changeset
|
714 |
if TestCollisionXwithGear(Gear, hwSign(Gear^.dX)) then if (TestCollisionYwithGear(Gear, -1) = 0) then |
eeae1cb6b6bf
Move hedgehog's step routine into separate function, use it in both hedgehog and ai code
unc0rr
parents:
7627
diff
changeset
|
715 |
begin |
eeae1cb6b6bf
Move hedgehog's step routine into separate function, use it in both hedgehog and ai code
unc0rr
parents:
7627
diff
changeset
|
716 |
Gear^.Y:= Gear^.Y - _1; |
eeae1cb6b6bf
Move hedgehog's step routine into separate function, use it in both hedgehog and ai code
unc0rr
parents:
7627
diff
changeset
|
717 |
if TestCollisionXwithGear(Gear, hwSign(Gear^.dX)) then |
eeae1cb6b6bf
Move hedgehog's step routine into separate function, use it in both hedgehog and ai code
unc0rr
parents:
7627
diff
changeset
|
718 |
Gear^.Y:= Gear^.Y + _6 |
eeae1cb6b6bf
Move hedgehog's step routine into separate function, use it in both hedgehog and ai code
unc0rr
parents:
7627
diff
changeset
|
719 |
end else Gear^.Y:= Gear^.Y + _5 else |
eeae1cb6b6bf
Move hedgehog's step routine into separate function, use it in both hedgehog and ai code
unc0rr
parents:
7627
diff
changeset
|
720 |
end else Gear^.Y:= Gear^.Y + _4 else |
eeae1cb6b6bf
Move hedgehog's step routine into separate function, use it in both hedgehog and ai code
unc0rr
parents:
7627
diff
changeset
|
721 |
end else Gear^.Y:= Gear^.Y + _3 else |
eeae1cb6b6bf
Move hedgehog's step routine into separate function, use it in both hedgehog and ai code
unc0rr
parents:
7627
diff
changeset
|
722 |
end else Gear^.Y:= Gear^.Y + _2 else |
eeae1cb6b6bf
Move hedgehog's step routine into separate function, use it in both hedgehog and ai code
unc0rr
parents:
7627
diff
changeset
|
723 |
end else Gear^.Y:= Gear^.Y + _1 |
eeae1cb6b6bf
Move hedgehog's step routine into separate function, use it in both hedgehog and ai code
unc0rr
parents:
7627
diff
changeset
|
724 |
end; |
eeae1cb6b6bf
Move hedgehog's step routine into separate function, use it in both hedgehog and ai code
unc0rr
parents:
7627
diff
changeset
|
725 |
|
eeae1cb6b6bf
Move hedgehog's step routine into separate function, use it in both hedgehog and ai code
unc0rr
parents:
7627
diff
changeset
|
726 |
if not TestCollisionXwithGear(Gear, hwSign(Gear^.dX)) then |
eeae1cb6b6bf
Move hedgehog's step routine into separate function, use it in both hedgehog and ai code
unc0rr
parents:
7627
diff
changeset
|
727 |
begin |
eeae1cb6b6bf
Move hedgehog's step routine into separate function, use it in both hedgehog and ai code
unc0rr
parents:
7627
diff
changeset
|
728 |
Gear^.X:= Gear^.X + SignAs(_1, Gear^.dX); |
eeae1cb6b6bf
Move hedgehog's step routine into separate function, use it in both hedgehog and ai code
unc0rr
parents:
7627
diff
changeset
|
729 |
MakeHedgehogsStep:= true |
eeae1cb6b6bf
Move hedgehog's step routine into separate function, use it in both hedgehog and ai code
unc0rr
parents:
7627
diff
changeset
|
730 |
end else |
eeae1cb6b6bf
Move hedgehog's step routine into separate function, use it in both hedgehog and ai code
unc0rr
parents:
7627
diff
changeset
|
731 |
MakeHedgehogsStep:= false; |
eeae1cb6b6bf
Move hedgehog's step routine into separate function, use it in both hedgehog and ai code
unc0rr
parents:
7627
diff
changeset
|
732 |
|
eeae1cb6b6bf
Move hedgehog's step routine into separate function, use it in both hedgehog and ai code
unc0rr
parents:
7627
diff
changeset
|
733 |
if TestCollisionYwithGear(Gear, 1) = 0 then |
eeae1cb6b6bf
Move hedgehog's step routine into separate function, use it in both hedgehog and ai code
unc0rr
parents:
7627
diff
changeset
|
734 |
begin |
eeae1cb6b6bf
Move hedgehog's step routine into separate function, use it in both hedgehog and ai code
unc0rr
parents:
7627
diff
changeset
|
735 |
Gear^.Y:= Gear^.Y + _1; |
eeae1cb6b6bf
Move hedgehog's step routine into separate function, use it in both hedgehog and ai code
unc0rr
parents:
7627
diff
changeset
|
736 |
if TestCollisionYwithGear(Gear, 1) = 0 then |
eeae1cb6b6bf
Move hedgehog's step routine into separate function, use it in both hedgehog and ai code
unc0rr
parents:
7627
diff
changeset
|
737 |
begin |
eeae1cb6b6bf
Move hedgehog's step routine into separate function, use it in both hedgehog and ai code
unc0rr
parents:
7627
diff
changeset
|
738 |
Gear^.Y:= Gear^.Y + _1; |
eeae1cb6b6bf
Move hedgehog's step routine into separate function, use it in both hedgehog and ai code
unc0rr
parents:
7627
diff
changeset
|
739 |
if TestCollisionYwithGear(Gear, 1) = 0 then |
eeae1cb6b6bf
Move hedgehog's step routine into separate function, use it in both hedgehog and ai code
unc0rr
parents:
7627
diff
changeset
|
740 |
begin |
eeae1cb6b6bf
Move hedgehog's step routine into separate function, use it in both hedgehog and ai code
unc0rr
parents:
7627
diff
changeset
|
741 |
Gear^.Y:= Gear^.Y + _1; |
eeae1cb6b6bf
Move hedgehog's step routine into separate function, use it in both hedgehog and ai code
unc0rr
parents:
7627
diff
changeset
|
742 |
if TestCollisionYwithGear(Gear, 1) = 0 then |
eeae1cb6b6bf
Move hedgehog's step routine into separate function, use it in both hedgehog and ai code
unc0rr
parents:
7627
diff
changeset
|
743 |
begin |
eeae1cb6b6bf
Move hedgehog's step routine into separate function, use it in both hedgehog and ai code
unc0rr
parents:
7627
diff
changeset
|
744 |
Gear^.Y:= Gear^.Y + _1; |
eeae1cb6b6bf
Move hedgehog's step routine into separate function, use it in both hedgehog and ai code
unc0rr
parents:
7627
diff
changeset
|
745 |
if TestCollisionYwithGear(Gear, 1) = 0 then |
eeae1cb6b6bf
Move hedgehog's step routine into separate function, use it in both hedgehog and ai code
unc0rr
parents:
7627
diff
changeset
|
746 |
begin |
eeae1cb6b6bf
Move hedgehog's step routine into separate function, use it in both hedgehog and ai code
unc0rr
parents:
7627
diff
changeset
|
747 |
Gear^.Y:= Gear^.Y + _1; |
eeae1cb6b6bf
Move hedgehog's step routine into separate function, use it in both hedgehog and ai code
unc0rr
parents:
7627
diff
changeset
|
748 |
if TestCollisionYwithGear(Gear, 1) = 0 then |
eeae1cb6b6bf
Move hedgehog's step routine into separate function, use it in both hedgehog and ai code
unc0rr
parents:
7627
diff
changeset
|
749 |
begin |
eeae1cb6b6bf
Move hedgehog's step routine into separate function, use it in both hedgehog and ai code
unc0rr
parents:
7627
diff
changeset
|
750 |
Gear^.Y:= Gear^.Y + _1; |
eeae1cb6b6bf
Move hedgehog's step routine into separate function, use it in both hedgehog and ai code
unc0rr
parents:
7627
diff
changeset
|
751 |
if TestCollisionYwithGear(Gear, 1) = 0 then |
eeae1cb6b6bf
Move hedgehog's step routine into separate function, use it in both hedgehog and ai code
unc0rr
parents:
7627
diff
changeset
|
752 |
begin |
eeae1cb6b6bf
Move hedgehog's step routine into separate function, use it in both hedgehog and ai code
unc0rr
parents:
7627
diff
changeset
|
753 |
Gear^.Y:= Gear^.Y - _6; |
eeae1cb6b6bf
Move hedgehog's step routine into separate function, use it in both hedgehog and ai code
unc0rr
parents:
7627
diff
changeset
|
754 |
Gear^.dY:= _0; |
eeae1cb6b6bf
Move hedgehog's step routine into separate function, use it in both hedgehog and ai code
unc0rr
parents:
7627
diff
changeset
|
755 |
Gear^.State:= Gear^.State or gstMoving; |
eeae1cb6b6bf
Move hedgehog's step routine into separate function, use it in both hedgehog and ai code
unc0rr
parents:
7627
diff
changeset
|
756 |
exit |
eeae1cb6b6bf
Move hedgehog's step routine into separate function, use it in both hedgehog and ai code
unc0rr
parents:
7627
diff
changeset
|
757 |
end; |
eeae1cb6b6bf
Move hedgehog's step routine into separate function, use it in both hedgehog and ai code
unc0rr
parents:
7627
diff
changeset
|
758 |
end |
eeae1cb6b6bf
Move hedgehog's step routine into separate function, use it in both hedgehog and ai code
unc0rr
parents:
7627
diff
changeset
|
759 |
end |
eeae1cb6b6bf
Move hedgehog's step routine into separate function, use it in both hedgehog and ai code
unc0rr
parents:
7627
diff
changeset
|
760 |
end |
eeae1cb6b6bf
Move hedgehog's step routine into separate function, use it in both hedgehog and ai code
unc0rr
parents:
7627
diff
changeset
|
761 |
end |
eeae1cb6b6bf
Move hedgehog's step routine into separate function, use it in both hedgehog and ai code
unc0rr
parents:
7627
diff
changeset
|
762 |
end |
eeae1cb6b6bf
Move hedgehog's step routine into separate function, use it in both hedgehog and ai code
unc0rr
parents:
7627
diff
changeset
|
763 |
end; |
eeae1cb6b6bf
Move hedgehog's step routine into separate function, use it in both hedgehog and ai code
unc0rr
parents:
7627
diff
changeset
|
764 |
end; |
eeae1cb6b6bf
Move hedgehog's step routine into separate function, use it in both hedgehog and ai code
unc0rr
parents:
7627
diff
changeset
|
765 |
|
6581 | 766 |
end. |