author | nemo |
Sun, 21 Oct 2012 22:34:20 -0400 | |
changeset 7785 | 9b5dceaea976 |
parent 7767 | d1ea9b3f543e |
child 7825 | 1b96361a7ef4 |
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); |
|
34 |
procedure ResurrectHedgehog(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; |
40 |
function CheckGearDrowning(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, |
6581 | 109 |
gtExplosives, |
110 |
gtStructure: begin |
|
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; |
|
140 |
if ((Mask and EXPLPoisoned) <> 0) and (Gear^.Kind = gtHedgehog) and (not Gear^.Invulnerable) 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; |
|
185 |
if (Gear^.Hedgehog <> nil) and (Gear^.Hedgehog^.King) then |
|
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; |
|
246 |
end |
|
247 |
else if Gear^.Kind <> gtStructure then // not gtHedgehog nor gtStructure |
|
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; |
|
289 |
i: LongInt; |
|
290 |
particle: PVisualGear; |
|
291 |
begin |
|
292 |
if _0_4 < Gear^.dY then |
|
293 |
begin |
|
294 |
dmg := ModifyDamage(1 + hwRound((hwAbs(Gear^.dY) - _0_4) * 70), Gear); |
|
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 |
|
7614
3ae60c8a15f2
Starting to rewrite uFloat routines to avoid QWordValue - in the interests of JS which may get uint64/int64 in the spec in the future but does not have it now.
nemo
parents:
7603
diff
changeset
|
326 |
// Frac/Round to be kind to JS as of 2012-08-27 where there is yet no int64/uint64 |
3ae60c8a15f2
Starting to rewrite uFloat routines to avoid QWordValue - in the interests of JS which may get uint64/int64 in the spec in the future but does not have it now.
nemo
parents:
7603
diff
changeset
|
327 |
dAngle := (Gear^.dX.Round + Gear^.dY.Round) / 2 + (Gear^.dX.Frac+Gear^.dY.Frac) / $80000000; |
6581 | 328 |
if not Gear^.dX.isNegative then |
329 |
Gear^.DirAngle := Gear^.DirAngle + dAngle |
|
330 |
else |
|
331 |
Gear^.DirAngle := Gear^.DirAngle - dAngle; |
|
332 |
||
333 |
if Gear^.DirAngle < 0 then |
|
334 |
Gear^.DirAngle := Gear^.DirAngle + 360 |
|
335 |
else if 360 < Gear^.DirAngle then |
|
336 |
Gear^.DirAngle := Gear^.DirAngle - 360 |
|
337 |
end; |
|
338 |
||
339 |
function CheckGearDrowning(Gear: PGear): boolean; |
|
340 |
var |
|
341 |
skipSpeed, skipAngle, skipDecay: hwFloat; |
|
342 |
i, maxDrops, X, Y: LongInt; |
|
343 |
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
|
344 |
particle, splash: PVisualGear; |
6581 | 345 |
isSubmersible: boolean; |
346 |
begin |
|
347 |
// probably needs tweaking. might need to be in a case statement based upon gear type |
|
348 |
Y:= hwRound(Gear^.Y); |
|
349 |
if cWaterLine < Y + Gear^.Radius then |
|
350 |
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
|
351 |
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
|
352 |
begin |
7406
1fe2c821f9bf
Try avoiding spamming the log by retaining the gears. untested.
nemo
parents:
7389
diff
changeset
|
353 |
if Gear^.Kind = gtGenericFaller then |
1fe2c821f9bf
Try avoiding spamming the log by retaining the gears. untested.
nemo
parents:
7389
diff
changeset
|
354 |
begin |
1fe2c821f9bf
Try avoiding spamming the log by retaining the gears. untested.
nemo
parents:
7389
diff
changeset
|
355 |
Gear^.X:= int2hwFloat(GetRandom(rightX-leftX)+leftX); |
1fe2c821f9bf
Try avoiding spamming the log by retaining the gears. untested.
nemo
parents:
7389
diff
changeset
|
356 |
Gear^.Y:= int2hwFloat(GetRandom(LAND_HEIGHT-topY)+topY); |
1fe2c821f9bf
Try avoiding spamming the log by retaining the gears. untested.
nemo
parents:
7389
diff
changeset
|
357 |
Gear^.dX:= _90-(GetRandomf*_360); |
1fe2c821f9bf
Try avoiding spamming the log by retaining the gears. untested.
nemo
parents:
7389
diff
changeset
|
358 |
Gear^.dY:= _90-(GetRandomf*_360) |
1fe2c821f9bf
Try avoiding spamming the log by retaining the gears. untested.
nemo
parents:
7389
diff
changeset
|
359 |
end |
1fe2c821f9bf
Try avoiding spamming the log by retaining the gears. untested.
nemo
parents:
7389
diff
changeset
|
360 |
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
|
361 |
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
|
362 |
end; |
6581 | 363 |
isSubmersible:= (Gear = CurrentHedgehog^.Gear) and (CurAmmoGear <> nil) and (CurAmmoGear^.AmmoType = amJetpack); |
364 |
skipSpeed := _0_25; |
|
365 |
skipAngle := _1_9; |
|
366 |
skipDecay := _0_87; |
|
367 |
X:= hwRound(Gear^.X); |
|
368 |
vdX:= hwFloat2Float(Gear^.dX); |
|
369 |
vdY:= hwFloat2Float(Gear^.dY); |
|
370 |
// this could perhaps be a tiny bit higher. |
|
371 |
if (hwSqr(Gear^.dX) + hwSqr(Gear^.dY) > skipSpeed) |
|
372 |
and (hwAbs(Gear^.dX) > skipAngle * hwAbs(Gear^.dY)) then |
|
373 |
begin |
|
374 |
Gear^.dY.isNegative := true; |
|
375 |
Gear^.dY := Gear^.dY * skipDecay; |
|
376 |
Gear^.dX := Gear^.dX * skipDecay; |
|
377 |
CheckGearDrowning := false; |
|
378 |
PlaySound(sndSkip) |
|
379 |
end |
|
380 |
else |
|
381 |
begin |
|
382 |
if not isSubmersible then |
|
383 |
begin |
|
384 |
CheckGearDrowning := true; |
|
385 |
Gear^.State := gstDrowning; |
|
386 |
Gear^.RenderTimer := false; |
|
387 |
if (Gear^.Kind <> gtSniperRifleShot) and (Gear^.Kind <> gtShotgunShot) |
|
388 |
and (Gear^.Kind <> gtDEagleShot) and (Gear^.Kind <> gtSineGunShot) then |
|
389 |
if Gear^.Kind = gtHedgehog then |
|
390 |
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
|
391 |
if Gear^.Hedgehog^.Effects[heResurrectable] <> 0 then |
6581 | 392 |
ResurrectHedgehog(Gear) |
393 |
else |
|
394 |
begin |
|
395 |
Gear^.doStep := @doStepDrowningGear; |
|
396 |
Gear^.State := Gear^.State and (not gstHHDriven); |
|
397 |
AddCaption(Format(GetEventString(eidDrowned), Gear^.Hedgehog^.Name), cWhiteColor, capgrpMessage); |
|
398 |
end |
|
399 |
end |
|
400 |
else |
|
401 |
Gear^.doStep := @doStepDrowningGear; |
|
402 |
if Gear^.Kind = gtFlake then |
|
403 |
exit // skip splashes |
|
404 |
end; |
|
405 |
if ((not isSubmersible) and (Y < cWaterLine + 64 + Gear^.Radius)) |
|
406 |
or (isSubmersible and (Y < cWaterLine + 2 + Gear^.Radius) and ((CurAmmoGear^.Pos = 0) |
|
407 |
and (CurAmmoGear^.dY < _0_01))) then |
|
6804 | 408 |
if Gear^.Density * Gear^.dY > _1 then |
409 |
PlaySound(sndSplash) |
|
410 |
else if Gear^.Density * Gear^.dY > _0_5 then |
|
411 |
PlaySound(sndSkip) |
|
412 |
else |
|
413 |
PlaySound(sndDroplet2); |
|
6581 | 414 |
end; |
415 |
||
416 |
if ((cReducedQuality and rqPlainSplash) = 0) |
|
417 |
and (((not isSubmersible) and (Y < cWaterLine + 64 + Gear^.Radius)) |
|
418 |
or (isSubmersible and (Y < cWaterLine + 2 + Gear^.Radius) and ((CurAmmoGear^.Pos = 0) |
|
419 |
and (CurAmmoGear^.dY < _0_01)))) then |
|
420 |
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
|
421 |
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
|
422 |
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
|
423 |
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
|
424 |
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
|
425 |
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
|
426 |
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
|
427 |
else Scale:= Scale + ((1-Scale) / 2); |
7420 | 428 |
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
|
429 |
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
|
430 |
// 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
|
431 |
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
|
432 |
end; |
6581 | 433 |
|
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
|
434 |
maxDrops := (hwRound(Gear^.Density) * 3) div 2 + round(vdX * hwRound(Gear^.Density) * 6) + round(vdY * hwRound(Gear^.Density) * 6); |
6581 | 435 |
for i:= max(maxDrops div 3, min(32, Random(maxDrops))) downto 0 do |
436 |
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
|
437 |
particle := AddVisualGear(X - 3 + Random(7), cWaterLine, vgtDroplet); |
6581 | 438 |
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
|
439 |
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
|
440 |
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
|
441 |
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
|
442 |
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
|
443 |
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
|
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 |
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
|
446 |
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
|
447 |
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
|
448 |
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
|
449 |
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
|
450 |
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
|
451 |
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
|
452 |
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
|
453 |
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
|
454 |
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
|
455 |
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
|
456 |
end |
6581 | 457 |
end |
458 |
end; |
|
459 |
if isSubmersible and (CurAmmoGear^.Pos = 0) then |
|
460 |
CurAmmoGear^.Pos := 1000 |
|
461 |
end |
|
462 |
else |
|
463 |
CheckGearDrowning := false; |
|
464 |
end; |
|
465 |
||
466 |
||
467 |
procedure ResurrectHedgehog(gear: PGear); |
|
468 |
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
|
469 |
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
|
470 |
gX, gY: LongInt; |
6581 | 471 |
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
|
472 |
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
|
473 |
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
|
474 |
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
|
475 |
uStats.HedgehogDamaged(Gear, CurrentHedgehog, 0, true); |
6581 | 476 |
AttackBar:= 0; |
477 |
gear^.dX := _0; |
|
478 |
gear^.dY := _0; |
|
479 |
gear^.Damage := 0; |
|
480 |
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
|
481 |
gear^.Hedgehog^.Effects[hePoisoned] := 0; |
7176
fb4b0c6dfdbd
Make watching AI v AI on ai survival a bit more entertaining
nemo
parents:
7168
diff
changeset
|
482 |
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
|
483 |
and (Gear^.Hedgehog^.Team^.Clan <> CurrentHedgehog^.Team^.Clan)) then |
6581 | 484 |
with CurrentHedgehog^ do |
485 |
begin |
|
486 |
inc(Team^.stats.AIKills); |
|
487 |
FreeTexture(Team^.AIKillsTex); |
|
488 |
Team^.AIKillsTex := RenderStringTex(inttostr(Team^.stats.AIKills), Team^.Clan^.Color, fnt16); |
|
489 |
end; |
|
490 |
tempTeam := gear^.Hedgehog^.Team; |
|
491 |
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
|
492 |
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
|
493 |
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
|
494 |
// 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
|
495 |
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
|
496 |
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
|
497 |
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
|
498 |
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
|
499 |
//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
|
500 |
end; |
6581 | 501 |
FindPlace(gear, false, 0, LAND_WIDTH, true); |
502 |
if gear <> nil then |
|
503 |
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
|
504 |
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
|
505 |
PlaySound(sndWarp); |
6581 | 506 |
RenderHealth(gear^.Hedgehog^); |
507 |
ScriptCall('onGearResurrect', gear^.uid); |
|
508 |
gear^.State := gstWait; |
|
509 |
end; |
|
510 |
RecountTeamHealth(tempTeam); |
|
511 |
end; |
|
512 |
||
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
|
513 |
function CountNonZeroz(x, y, r, c: LongInt; mask: LongWord): LongInt; |
6581 | 514 |
var i: LongInt; |
515 |
count: LongInt = 0; |
|
516 |
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
|
517 |
if (y and LAND_HEIGHT_MASK) = 0 then |
7509 | 518 |
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
|
519 |
if Land[y, i] and mask <> 0 then |
6581 | 520 |
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
|
521 |
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
|
522 |
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
|
523 |
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
|
524 |
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
|
525 |
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
|
526 |
end; |
6581 | 527 |
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
|
528 |
CountNonZeroz:= count; |
6581 | 529 |
end; |
530 |
||
6888 | 531 |
|
532 |
function NoGearsToAvoid(mX, mY: LongInt; rX, rY: LongInt): boolean; |
|
533 |
var t: PGear; |
|
534 |
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
|
535 |
NoGearsToAvoid:= false; |
6888 | 536 |
t:= GearsList; |
537 |
rX:= sqr(rX); |
|
538 |
rY:= sqr(rY); |
|
539 |
while t <> nil do |
|
540 |
begin |
|
541 |
if t^.Kind <= gtExplosives then |
|
542 |
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
|
543 |
exit; |
6888 | 544 |
t:= t^.NextGear |
545 |
end; |
|
546 |
NoGearsToAvoid:= true |
|
547 |
end; |
|
548 |
||
6986
409dd3851309
add support for default pascal mode by removing default arguments value (maybe this also helps the parser)
koda
parents:
6888
diff
changeset
|
549 |
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
|
550 |
begin |
409dd3851309
add support for default pascal mode by removing default arguments value (maybe this also helps the parser)
koda
parents:
6888
diff
changeset
|
551 |
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
|
552 |
end; |
6888 | 553 |
|
6581 | 554 |
procedure FindPlace(var Gear: PGear; withFall: boolean; Left, Right: LongInt; skipProximity: boolean); |
555 |
var x: LongInt; |
|
556 |
y, sy: LongInt; |
|
557 |
ar: array[0..511] of TPoint; |
|
558 |
ar2: array[0..1023] of TPoint; |
|
559 |
cnt, cnt2: Longword; |
|
560 |
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
|
561 |
ignoreNearObjects, ignoreOverlap, tryAgain: boolean; |
6581 | 562 |
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
|
563 |
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
|
564 |
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 | 565 |
tryAgain:= true; |
566 |
while tryAgain do |
|
567 |
begin |
|
568 |
delta:= 250; |
|
569 |
cnt2:= 0; |
|
570 |
repeat |
|
571 |
x:= Left + LongInt(GetRandom(Delta)); |
|
572 |
repeat |
|
573 |
inc(x, Delta); |
|
574 |
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
|
575 |
y:= min(1024, topY) - 2 * Gear^.Radius; |
6581 | 576 |
while y < cWaterLine do |
577 |
begin |
|
578 |
repeat |
|
579 |
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
|
580 |
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
|
581 |
(not ignoreOverlap and (CountNonZeroz(x, y, Gear^.Radius - 1, 1, $FFFF) = 0)) 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
|
582 |
(ignoreOverlap and (CountNonZeroz(x, y, Gear^.Radius - 1, 1, $FF00) = 0)); |
6581 | 583 |
|
584 |
sy:= y; |
|
585 |
||
586 |
repeat |
|
587 |
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
|
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 |
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
|
590 |
(ignoreOverlap and (CountNonZeroz(x, y, Gear^.Radius - 1, 1, $FF00) <> 0)); |
6581 | 591 |
|
592 |
if (y - sy > Gear^.Radius * 2) |
|
593 |
and (((Gear^.Kind = gtExplosives) |
|
594 |
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
|
595 |
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
|
596 |
and (CountNonZeroz(x, y+1, Gear^.Radius - 1, Gear^.Radius+1, $FFFF) > Gear^.Radius)) |
6581 | 597 |
or |
598 |
((Gear^.Kind <> gtExplosives) |
|
599 |
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
|
600 |
and (ignoreNearObjects or NoGearsToAvoid(x, y - Gear^.Radius, 110, 110)) |
6888 | 601 |
)) then |
602 |
begin |
|
6581 | 603 |
ar[cnt].X:= x; |
604 |
if withFall then |
|
605 |
ar[cnt].Y:= sy + Gear^.Radius |
|
606 |
else |
|
607 |
ar[cnt].Y:= y - Gear^.Radius; |
|
608 |
inc(cnt) |
|
609 |
end; |
|
610 |
||
7603
e9c3c67b5dfd
reducing this value is sufficient to ensure crates drop just below top border or a girder
nemo
parents:
7599
diff
changeset
|
611 |
inc(y, 10) |
6581 | 612 |
end; |
613 |
||
614 |
if cnt > 0 then |
|
615 |
with ar[GetRandom(cnt)] do |
|
616 |
begin |
|
617 |
ar2[cnt2].x:= x; |
|
618 |
ar2[cnt2].y:= y; |
|
619 |
inc(cnt2) |
|
620 |
end |
|
621 |
until (x + Delta > Right); |
|
622 |
||
623 |
dec(Delta, 60) |
|
624 |
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
|
625 |
// 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
|
626 |
if (cnt2 = 0) and skipProximity and (not ignoreOverlap) then |
6581 | 627 |
tryAgain:= true |
628 |
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
|
629 |
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
|
630 |
ignoreNearObjects:= true; |
6581 | 631 |
end; |
632 |
||
633 |
if cnt2 > 0 then |
|
634 |
with ar2[GetRandom(cnt2)] do |
|
635 |
begin |
|
636 |
Gear^.X:= int2hwFloat(x); |
|
637 |
Gear^.Y:= int2hwFloat(y); |
|
638 |
AddFileLog('Assigned Gear coordinates (' + inttostr(x) + ',' + inttostr(y) + ')'); |
|
639 |
end |
|
640 |
else |
|
641 |
begin |
|
642 |
OutError('Can''t find place for Gear', false); |
|
643 |
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
|
644 |
Gear^.Hedgehog^.Effects[heResurrectable] := 0; |
6581 | 645 |
DeleteGear(Gear); |
646 |
Gear:= nil |
|
647 |
end |
|
648 |
end; |
|
649 |
||
650 |
function CheckGearNear(Gear: PGear; Kind: TGearType; rX, rY: LongInt): PGear; |
|
651 |
var t: PGear; |
|
652 |
begin |
|
653 |
t:= GearsList; |
|
654 |
rX:= sqr(rX); |
|
655 |
rY:= sqr(rY); |
|
656 |
||
657 |
while t <> nil do |
|
658 |
begin |
|
659 |
if (t <> Gear) and (t^.Kind = Kind) then |
|
660 |
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
|
661 |
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
|
662 |
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
|
663 |
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
|
664 |
end; |
6581 | 665 |
t:= t^.NextGear |
666 |
end; |
|
667 |
||
668 |
CheckGearNear:= nil |
|
669 |
end; |
|
670 |
||
7592 | 671 |
procedure CheckCollision(Gear: PGear); inline; |
672 |
begin |
|
673 |
if TestCollisionXwithGear(Gear, hwSign(Gear^.dX)) |
|
674 |
or (TestCollisionYwithGear(Gear, hwSign(Gear^.dY)) <> 0) then |
|
675 |
Gear^.State := Gear^.State or gstCollision |
|
676 |
else |
|
677 |
Gear^.State := Gear^.State and (not gstCollision) |
|
678 |
end; |
|
679 |
||
680 |
procedure CheckCollisionWithLand(Gear: PGear); inline; |
|
681 |
begin |
|
682 |
if TestCollisionX(Gear, hwSign(Gear^.dX)) |
|
683 |
or TestCollisionY(Gear, hwSign(Gear^.dY)) then |
|
684 |
Gear^.State := Gear^.State or gstCollision |
|
685 |
else |
|
686 |
Gear^.State := Gear^.State and (not gstCollision) |
|
687 |
end; |
|
688 |
||
7719
eeae1cb6b6bf
Move hedgehog's step routine into separate function, use it in both hedgehog and ai code
unc0rr
parents:
7627
diff
changeset
|
689 |
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
|
690 |
begin |
eeae1cb6b6bf
Move hedgehog's step routine into separate function, use it in both hedgehog and ai code
unc0rr
parents:
7627
diff
changeset
|
691 |
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
|
692 |
begin |
eeae1cb6b6bf
Move hedgehog's step routine into separate function, use it in both hedgehog and ai code
unc0rr
parents:
7627
diff
changeset
|
693 |
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
|
694 |
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
|
695 |
begin |
eeae1cb6b6bf
Move hedgehog's step routine into separate function, use it in both hedgehog and ai code
unc0rr
parents:
7627
diff
changeset
|
696 |
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
|
697 |
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
|
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 |
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
|
700 |
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
|
701 |
begin |
eeae1cb6b6bf
Move hedgehog's step routine into separate function, use it in both hedgehog and ai code
unc0rr
parents:
7627
diff
changeset
|
702 |
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
|
703 |
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
|
704 |
begin |
eeae1cb6b6bf
Move hedgehog's step routine into separate function, use it in both hedgehog and ai code
unc0rr
parents:
7627
diff
changeset
|
705 |
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
|
706 |
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
|
707 |
begin |
eeae1cb6b6bf
Move hedgehog's step routine into separate function, use it in both hedgehog and ai code
unc0rr
parents:
7627
diff
changeset
|
708 |
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
|
709 |
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
|
710 |
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
|
711 |
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
|
712 |
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
|
713 |
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
|
714 |
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
|
715 |
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
|
716 |
end; |
eeae1cb6b6bf
Move hedgehog's step routine into separate function, use it in both hedgehog and ai code
unc0rr
parents:
7627
diff
changeset
|
717 |
|
eeae1cb6b6bf
Move hedgehog's step routine into separate function, use it in both hedgehog and ai code
unc0rr
parents:
7627
diff
changeset
|
718 |
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
|
719 |
begin |
eeae1cb6b6bf
Move hedgehog's step routine into separate function, use it in both hedgehog and ai code
unc0rr
parents:
7627
diff
changeset
|
720 |
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
|
721 |
MakeHedgehogsStep:= true |
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 |
eeae1cb6b6bf
Move hedgehog's step routine into separate function, use it in both hedgehog and ai code
unc0rr
parents:
7627
diff
changeset
|
723 |
MakeHedgehogsStep:= false; |
eeae1cb6b6bf
Move hedgehog's step routine into separate function, use it in both hedgehog and ai code
unc0rr
parents:
7627
diff
changeset
|
724 |
|
eeae1cb6b6bf
Move hedgehog's step routine into separate function, use it in both hedgehog and ai code
unc0rr
parents:
7627
diff
changeset
|
725 |
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
|
726 |
begin |
eeae1cb6b6bf
Move hedgehog's step routine into separate function, use it in both hedgehog and ai code
unc0rr
parents:
7627
diff
changeset
|
727 |
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
|
728 |
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
|
729 |
begin |
eeae1cb6b6bf
Move hedgehog's step routine into separate function, use it in both hedgehog and ai code
unc0rr
parents:
7627
diff
changeset
|
730 |
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
|
731 |
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
|
732 |
begin |
eeae1cb6b6bf
Move hedgehog's step routine into separate function, use it in both hedgehog and ai code
unc0rr
parents:
7627
diff
changeset
|
733 |
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
|
734 |
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
|
735 |
begin |
eeae1cb6b6bf
Move hedgehog's step routine into separate function, use it in both hedgehog and ai code
unc0rr
parents:
7627
diff
changeset
|
736 |
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
|
737 |
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
|
738 |
begin |
eeae1cb6b6bf
Move hedgehog's step routine into separate function, use it in both hedgehog and ai code
unc0rr
parents:
7627
diff
changeset
|
739 |
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
|
740 |
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
|
741 |
begin |
eeae1cb6b6bf
Move hedgehog's step routine into separate function, use it in both hedgehog and ai code
unc0rr
parents:
7627
diff
changeset
|
742 |
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
|
743 |
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
|
744 |
begin |
eeae1cb6b6bf
Move hedgehog's step routine into separate function, use it in both hedgehog and ai code
unc0rr
parents:
7627
diff
changeset
|
745 |
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
|
746 |
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
|
747 |
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
|
748 |
exit |
eeae1cb6b6bf
Move hedgehog's step routine into separate function, use it in both hedgehog and ai code
unc0rr
parents:
7627
diff
changeset
|
749 |
end; |
eeae1cb6b6bf
Move hedgehog's step routine into separate function, use it in both hedgehog and ai code
unc0rr
parents:
7627
diff
changeset
|
750 |
end |
eeae1cb6b6bf
Move hedgehog's step routine into separate function, use it in both hedgehog and ai code
unc0rr
parents:
7627
diff
changeset
|
751 |
end |
eeae1cb6b6bf
Move hedgehog's step routine into separate function, use it in both hedgehog and ai code
unc0rr
parents:
7627
diff
changeset
|
752 |
end |
eeae1cb6b6bf
Move hedgehog's step routine into separate function, use it in both hedgehog and ai code
unc0rr
parents:
7627
diff
changeset
|
753 |
end |
eeae1cb6b6bf
Move hedgehog's step routine into separate function, use it in both hedgehog and ai code
unc0rr
parents:
7627
diff
changeset
|
754 |
end |
eeae1cb6b6bf
Move hedgehog's step routine into separate function, use it in both hedgehog and ai code
unc0rr
parents:
7627
diff
changeset
|
755 |
end; |
eeae1cb6b6bf
Move hedgehog's step routine into separate function, use it in both hedgehog and ai code
unc0rr
parents:
7627
diff
changeset
|
756 |
end; |
eeae1cb6b6bf
Move hedgehog's step routine into separate function, use it in both hedgehog and ai code
unc0rr
parents:
7627
diff
changeset
|
757 |
|
6581 | 758 |
end. |