author | nemo |
Wed, 27 Feb 2013 21:30:33 -0500 | |
changeset 8598 | 9d21bab30893 |
parent 8560 | 134a098235fa |
child 8632 | b5ed76d2a1f9 |
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, |
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; |
|
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; |
|
8560 | 185 |
if (Gear^.Hedgehog <> nil) and (Gear^.Hedgehog^.Effects[heFrozen] > 0) then i:=i*_0_2; |
6581 | 186 |
if (Gear^.Hedgehog <> nil) and (Gear^.Hedgehog^.King) then |
187 |
ModifyDamage:= hwRound(_0_01 * cDamageModifier * dmg * i * cDamagePercent * _0_5) |
|
188 |
else |
|
189 |
ModifyDamage:= hwRound(_0_01 * cDamageModifier * dmg * i * cDamagePercent) |
|
190 |
end; |
|
191 |
||
192 |
procedure ApplyDamage(Gear: PGear; AttackerHog: PHedgehog; Damage: Longword; Source: TDamageSource); |
|
193 |
var s: shortstring; |
|
194 |
vampDmg, tmpDmg, i: Longword; |
|
195 |
vg: PVisualGear; |
|
196 |
begin |
|
197 |
if Damage = 0 then |
|
198 |
exit; // nothing to apply |
|
199 |
||
200 |
if (Gear^.Kind = gtHedgehog) then |
|
201 |
begin |
|
202 |
Gear^.LastDamage := AttackerHog; |
|
203 |
||
204 |
Gear^.Hedgehog^.Team^.Clan^.Flawless:= false; |
|
205 |
HHHurt(Gear^.Hedgehog, Source); |
|
206 |
AddDamageTag(hwRound(Gear^.X), hwRound(Gear^.Y), Damage, Gear^.Hedgehog^.Team^.Clan^.Color); |
|
207 |
tmpDmg:= min(Damage, max(0,Gear^.Health-Gear^.Damage)); |
|
208 |
if (Gear <> CurrentHedgehog^.Gear) and (CurrentHedgehog^.Gear <> nil) and (tmpDmg >= 1) then |
|
209 |
begin |
|
210 |
if cVampiric then |
|
211 |
begin |
|
212 |
vampDmg:= hwRound(int2hwFloat(tmpDmg)*_0_8); |
|
213 |
if vampDmg >= 1 then |
|
214 |
begin |
|
215 |
// was considering pulsing on attack, Tiy thinks it should be permanent while in play |
|
216 |
//CurrentHedgehog^.Gear^.State:= CurrentHedgehog^.Gear^.State or gstVampiric; |
|
217 |
inc(CurrentHedgehog^.Gear^.Health,vampDmg); |
|
218 |
str(vampDmg, s); |
|
219 |
s:= '+' + s; |
|
220 |
AddCaption(s, CurrentHedgehog^.Team^.Clan^.Color, capgrpAmmoinfo); |
|
221 |
RenderHealth(CurrentHedgehog^); |
|
222 |
RecountTeamHealth(CurrentHedgehog^.Team); |
|
223 |
i:= 0; |
|
224 |
while i < vampDmg do |
|
225 |
begin |
|
226 |
vg:= AddVisualGear(hwRound(CurrentHedgehog^.Gear^.X), hwRound(CurrentHedgehog^.Gear^.Y), vgtStraightShot); |
|
227 |
if vg <> nil then |
|
228 |
with vg^ do |
|
229 |
begin |
|
230 |
Tint:= $FF0000FF; |
|
231 |
State:= ord(sprHealth) |
|
232 |
end; |
|
233 |
inc(i, 5); |
|
234 |
end; |
|
235 |
end |
|
236 |
end; |
|
237 |
if ((GameFlags and gfKarma) <> 0) and |
|
238 |
((GameFlags and gfInvulnerable) = 0) |
|
239 |
and (not CurrentHedgehog^.Gear^.Invulnerable) then |
|
240 |
begin // this cannot just use Damage or it interrupts shotgun and gets you called stupid |
|
241 |
inc(CurrentHedgehog^.Gear^.Karma, tmpDmg); |
|
242 |
CurrentHedgehog^.Gear^.LastDamage := CurrentHedgehog; |
|
243 |
spawnHealthTagForHH(CurrentHedgehog^.Gear, tmpDmg); |
|
244 |
end; |
|
245 |
uStats.HedgehogDamaged(Gear, AttackerHog, Damage, false); |
|
246 |
end; |
|
8199
886ed135665b
Fix crashes and wtf behaviour introduced in r0b8beacff8a5
unc0rr
parents:
8161
diff
changeset
|
247 |
end else |
8161 | 248 |
//else if Gear^.Kind <> gtStructure then // not gtHedgehog nor gtStructure |
6581 | 249 |
Gear^.Hedgehog:= AttackerHog; |
250 |
inc(Gear^.Damage, Damage); |
|
251 |
||
252 |
ScriptCall('onGearDamage', Gear^.UID, Damage); |
|
253 |
end; |
|
254 |
||
255 |
procedure spawnHealthTagForHH(HHGear: PGear; dmg: Longword); |
|
256 |
var tag: PVisualGear; |
|
257 |
begin |
|
258 |
tag:= AddVisualGear(hwRound(HHGear^.X), hwRound(HHGear^.Y), vgtHealthTag, dmg); |
|
259 |
if (tag <> nil) then |
|
260 |
tag^.Hedgehog:= HHGear^.Hedgehog; // the tag needs the tag to determine the text color |
|
261 |
AllInactive:= false; |
|
262 |
HHGear^.Active:= true; |
|
263 |
end; |
|
264 |
||
265 |
procedure HHHurt(Hedgehog: PHedgehog; Source: TDamageSource); |
|
266 |
begin |
|
267 |
if (Source = dsFall) or (Source = dsExplosion) then |
|
268 |
case random(3) of |
|
7053 | 269 |
0: PlaySoundV(sndOoff1, Hedgehog^.Team^.voicepack); |
270 |
1: PlaySoundV(sndOoff2, Hedgehog^.Team^.voicepack); |
|
271 |
2: PlaySoundV(sndOoff3, Hedgehog^.Team^.voicepack); |
|
6581 | 272 |
end |
273 |
else if (Source = dsPoison) then |
|
274 |
case random(2) of |
|
7053 | 275 |
0: PlaySoundV(sndPoisonCough, Hedgehog^.Team^.voicepack); |
276 |
1: PlaySoundV(sndPoisonMoan, Hedgehog^.Team^.voicepack); |
|
6581 | 277 |
end |
278 |
else |
|
279 |
case random(4) of |
|
7053 | 280 |
0: PlaySoundV(sndOw1, Hedgehog^.Team^.voicepack); |
281 |
1: PlaySoundV(sndOw2, Hedgehog^.Team^.voicepack); |
|
282 |
2: PlaySoundV(sndOw3, Hedgehog^.Team^.voicepack); |
|
283 |
3: PlaySoundV(sndOw4, Hedgehog^.Team^.voicepack); |
|
6581 | 284 |
end |
285 |
end; |
|
286 |
||
287 |
procedure CheckHHDamage(Gear: PGear); |
|
288 |
var |
|
289 |
dmg: Longword; |
|
8003 | 290 |
i: LongWord; |
6581 | 291 |
particle: PVisualGear; |
292 |
begin |
|
293 |
if _0_4 < Gear^.dY then |
|
294 |
begin |
|
295 |
dmg := ModifyDamage(1 + hwRound((hwAbs(Gear^.dY) - _0_4) * 70), Gear); |
|
296 |
PlaySound(sndBump); |
|
297 |
if dmg < 1 then |
|
298 |
exit; |
|
299 |
||
300 |
for i:= min(12, (3 + dmg div 10)) downto 0 do |
|
301 |
begin |
|
302 |
particle := AddVisualGear(hwRound(Gear^.X) - 5 + Random(10), hwRound(Gear^.Y) + 12, vgtDust); |
|
303 |
if particle <> nil then |
|
304 |
particle^.dX := particle^.dX + (Gear^.dX.QWordValue / 21474836480); |
|
305 |
end; |
|
306 |
||
307 |
if (Gear^.Invulnerable) then |
|
308 |
exit; |
|
309 |
||
310 |
//if _0_6 < Gear^.dY then |
|
311 |
// PlaySound(sndOw4, Gear^.Hedgehog^.Team^.voicepack) |
|
312 |
//else |
|
313 |
// PlaySound(sndOw1, Gear^.Hedgehog^.Team^.voicepack); |
|
314 |
||
315 |
if Gear^.LastDamage <> nil then |
|
316 |
ApplyDamage(Gear, Gear^.LastDamage, dmg, dsFall) |
|
317 |
else |
|
318 |
ApplyDamage(Gear, CurrentHedgehog, dmg, dsFall); |
|
319 |
end |
|
320 |
end; |
|
321 |
||
322 |
||
323 |
procedure CalcRotationDirAngle(Gear: PGear); |
|
324 |
var |
|
325 |
dAngle: real; |
|
326 |
begin |
|
7825 | 327 |
// Frac/Round to be kind to JS as of 2012-08-27 where there is yet no int64/uint64 |
328 |
//dAngle := (Gear^.dX.QWordValue + Gear^.dY.QWordValue) / $80000000; |
|
329 |
dAngle := (Gear^.dX.Round + Gear^.dY.Round) / 2 + (Gear^.dX.Frac/$100000000+Gear^.dY.Frac/$100000000); |
|
6581 | 330 |
if not Gear^.dX.isNegative then |
331 |
Gear^.DirAngle := Gear^.DirAngle + dAngle |
|
332 |
else |
|
333 |
Gear^.DirAngle := Gear^.DirAngle - dAngle; |
|
334 |
||
335 |
if Gear^.DirAngle < 0 then |
|
336 |
Gear^.DirAngle := Gear^.DirAngle + 360 |
|
337 |
else if 360 < Gear^.DirAngle then |
|
338 |
Gear^.DirAngle := Gear^.DirAngle - 360 |
|
339 |
end; |
|
340 |
||
341 |
function CheckGearDrowning(Gear: PGear): boolean; |
|
342 |
var |
|
343 |
skipSpeed, skipAngle, skipDecay: hwFloat; |
|
344 |
i, maxDrops, X, Y: LongInt; |
|
345 |
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
|
346 |
particle, splash: PVisualGear; |
6581 | 347 |
isSubmersible: boolean; |
348 |
begin |
|
349 |
// probably needs tweaking. might need to be in a case statement based upon gear type |
|
350 |
Y:= hwRound(Gear^.Y); |
|
351 |
if cWaterLine < Y + Gear^.Radius then |
|
352 |
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
|
353 |
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
|
354 |
begin |
7406
1fe2c821f9bf
Try avoiding spamming the log by retaining the gears. untested.
nemo
parents:
7389
diff
changeset
|
355 |
if Gear^.Kind = gtGenericFaller then |
1fe2c821f9bf
Try avoiding spamming the log by retaining the gears. untested.
nemo
parents:
7389
diff
changeset
|
356 |
begin |
1fe2c821f9bf
Try avoiding spamming the log by retaining the gears. untested.
nemo
parents:
7389
diff
changeset
|
357 |
Gear^.X:= int2hwFloat(GetRandom(rightX-leftX)+leftX); |
1fe2c821f9bf
Try avoiding spamming the log by retaining the gears. untested.
nemo
parents:
7389
diff
changeset
|
358 |
Gear^.Y:= int2hwFloat(GetRandom(LAND_HEIGHT-topY)+topY); |
1fe2c821f9bf
Try avoiding spamming the log by retaining the gears. untested.
nemo
parents:
7389
diff
changeset
|
359 |
Gear^.dX:= _90-(GetRandomf*_360); |
1fe2c821f9bf
Try avoiding spamming the log by retaining the gears. untested.
nemo
parents:
7389
diff
changeset
|
360 |
Gear^.dY:= _90-(GetRandomf*_360) |
1fe2c821f9bf
Try avoiding spamming the log by retaining the gears. untested.
nemo
parents:
7389
diff
changeset
|
361 |
end |
1fe2c821f9bf
Try avoiding spamming the log by retaining the gears. untested.
nemo
parents:
7389
diff
changeset
|
362 |
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
|
363 |
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
|
364 |
end; |
6581 | 365 |
isSubmersible:= (Gear = CurrentHedgehog^.Gear) and (CurAmmoGear <> nil) and (CurAmmoGear^.AmmoType = amJetpack); |
366 |
skipSpeed := _0_25; |
|
367 |
skipAngle := _1_9; |
|
368 |
skipDecay := _0_87; |
|
369 |
X:= hwRound(Gear^.X); |
|
370 |
vdX:= hwFloat2Float(Gear^.dX); |
|
371 |
vdY:= hwFloat2Float(Gear^.dY); |
|
372 |
// this could perhaps be a tiny bit higher. |
|
373 |
if (hwSqr(Gear^.dX) + hwSqr(Gear^.dY) > skipSpeed) |
|
374 |
and (hwAbs(Gear^.dX) > skipAngle * hwAbs(Gear^.dY)) then |
|
375 |
begin |
|
376 |
Gear^.dY.isNegative := true; |
|
377 |
Gear^.dY := Gear^.dY * skipDecay; |
|
378 |
Gear^.dX := Gear^.dX * skipDecay; |
|
379 |
CheckGearDrowning := false; |
|
380 |
PlaySound(sndSkip) |
|
381 |
end |
|
382 |
else |
|
383 |
begin |
|
384 |
if not isSubmersible then |
|
385 |
begin |
|
386 |
CheckGearDrowning := true; |
|
387 |
Gear^.State := gstDrowning; |
|
388 |
Gear^.RenderTimer := false; |
|
389 |
if (Gear^.Kind <> gtSniperRifleShot) and (Gear^.Kind <> gtShotgunShot) |
|
390 |
and (Gear^.Kind <> gtDEagleShot) and (Gear^.Kind <> gtSineGunShot) then |
|
391 |
if Gear^.Kind = gtHedgehog then |
|
392 |
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
|
393 |
if Gear^.Hedgehog^.Effects[heResurrectable] <> 0 then |
6581 | 394 |
ResurrectHedgehog(Gear) |
395 |
else |
|
396 |
begin |
|
397 |
Gear^.doStep := @doStepDrowningGear; |
|
398 |
Gear^.State := Gear^.State and (not gstHHDriven); |
|
399 |
AddCaption(Format(GetEventString(eidDrowned), Gear^.Hedgehog^.Name), cWhiteColor, capgrpMessage); |
|
400 |
end |
|
401 |
end |
|
402 |
else |
|
403 |
Gear^.doStep := @doStepDrowningGear; |
|
404 |
if Gear^.Kind = gtFlake then |
|
405 |
exit // skip splashes |
|
406 |
end; |
|
407 |
if ((not isSubmersible) and (Y < cWaterLine + 64 + Gear^.Radius)) |
|
408 |
or (isSubmersible and (Y < cWaterLine + 2 + Gear^.Radius) and ((CurAmmoGear^.Pos = 0) |
|
409 |
and (CurAmmoGear^.dY < _0_01))) then |
|
6804 | 410 |
if Gear^.Density * Gear^.dY > _1 then |
411 |
PlaySound(sndSplash) |
|
412 |
else if Gear^.Density * Gear^.dY > _0_5 then |
|
413 |
PlaySound(sndSkip) |
|
414 |
else |
|
415 |
PlaySound(sndDroplet2); |
|
6581 | 416 |
end; |
417 |
||
418 |
if ((cReducedQuality and rqPlainSplash) = 0) |
|
419 |
and (((not isSubmersible) and (Y < cWaterLine + 64 + Gear^.Radius)) |
|
420 |
or (isSubmersible and (Y < cWaterLine + 2 + Gear^.Radius) and ((CurAmmoGear^.Pos = 0) |
|
421 |
and (CurAmmoGear^.dY < _0_01)))) then |
|
422 |
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
|
423 |
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
|
424 |
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
|
425 |
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
|
426 |
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
|
427 |
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
|
428 |
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
|
429 |
else Scale:= Scale + ((1-Scale) / 2); |
7420 | 430 |
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
|
431 |
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
|
432 |
// 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
|
433 |
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
|
434 |
end; |
6581 | 435 |
|
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
|
436 |
maxDrops := (hwRound(Gear^.Density) * 3) div 2 + round(vdX * hwRound(Gear^.Density) * 6) + round(vdY * hwRound(Gear^.Density) * 6); |
6581 | 437 |
for i:= max(maxDrops div 3, min(32, Random(maxDrops))) downto 0 do |
438 |
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
|
439 |
particle := AddVisualGear(X - 3 + Random(7), cWaterLine, vgtDroplet); |
6581 | 440 |
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
|
441 |
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
|
442 |
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
|
443 |
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
|
444 |
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
|
445 |
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
|
446 |
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
|
447 |
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
|
448 |
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
|
449 |
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
|
450 |
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
|
451 |
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
|
452 |
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
|
453 |
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
|
454 |
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
|
455 |
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
|
456 |
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
|
457 |
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
|
458 |
end |
6581 | 459 |
end |
460 |
end; |
|
461 |
if isSubmersible and (CurAmmoGear^.Pos = 0) then |
|
462 |
CurAmmoGear^.Pos := 1000 |
|
463 |
end |
|
464 |
else |
|
465 |
CheckGearDrowning := false; |
|
466 |
end; |
|
467 |
||
468 |
||
469 |
procedure ResurrectHedgehog(gear: PGear); |
|
470 |
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
|
471 |
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
|
472 |
gX, gY: LongInt; |
6581 | 473 |
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
|
474 |
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
|
475 |
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
|
476 |
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
|
477 |
uStats.HedgehogDamaged(Gear, CurrentHedgehog, 0, true); |
6581 | 478 |
AttackBar:= 0; |
479 |
gear^.dX := _0; |
|
480 |
gear^.dY := _0; |
|
481 |
gear^.Damage := 0; |
|
482 |
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
|
483 |
gear^.Hedgehog^.Effects[hePoisoned] := 0; |
7176
fb4b0c6dfdbd
Make watching AI v AI on ai survival a bit more entertaining
nemo
parents:
7168
diff
changeset
|
484 |
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
|
485 |
and (Gear^.Hedgehog^.Team^.Clan <> CurrentHedgehog^.Team^.Clan)) then |
6581 | 486 |
with CurrentHedgehog^ do |
487 |
begin |
|
488 |
inc(Team^.stats.AIKills); |
|
489 |
FreeTexture(Team^.AIKillsTex); |
|
490 |
Team^.AIKillsTex := RenderStringTex(inttostr(Team^.stats.AIKills), Team^.Clan^.Color, fnt16); |
|
491 |
end; |
|
492 |
tempTeam := gear^.Hedgehog^.Team; |
|
493 |
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
|
494 |
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
|
495 |
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
|
496 |
// 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
|
497 |
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
|
498 |
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
|
499 |
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
|
500 |
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
|
501 |
//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
|
502 |
end; |
6581 | 503 |
FindPlace(gear, false, 0, LAND_WIDTH, true); |
504 |
if gear <> nil then |
|
505 |
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
|
506 |
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
|
507 |
PlaySound(sndWarp); |
6581 | 508 |
RenderHealth(gear^.Hedgehog^); |
509 |
ScriptCall('onGearResurrect', gear^.uid); |
|
510 |
gear^.State := gstWait; |
|
511 |
end; |
|
512 |
RecountTeamHealth(tempTeam); |
|
513 |
end; |
|
514 |
||
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
|
515 |
function CountNonZeroz(x, y, r, c: LongInt; mask: LongWord): LongInt; |
6581 | 516 |
var i: LongInt; |
517 |
count: LongInt = 0; |
|
518 |
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
|
519 |
if (y and LAND_HEIGHT_MASK) = 0 then |
7509 | 520 |
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
|
521 |
if Land[y, i] and mask <> 0 then |
6581 | 522 |
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
|
523 |
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
|
524 |
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
|
525 |
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
|
526 |
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
|
527 |
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
|
528 |
end; |
6581 | 529 |
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
|
530 |
CountNonZeroz:= count; |
6581 | 531 |
end; |
532 |
||
6888 | 533 |
|
534 |
function NoGearsToAvoid(mX, mY: LongInt; rX, rY: LongInt): boolean; |
|
535 |
var t: PGear; |
|
536 |
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
|
537 |
NoGearsToAvoid:= false; |
6888 | 538 |
t:= GearsList; |
539 |
rX:= sqr(rX); |
|
540 |
rY:= sqr(rY); |
|
541 |
while t <> nil do |
|
542 |
begin |
|
543 |
if t^.Kind <= gtExplosives then |
|
544 |
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
|
545 |
exit; |
6888 | 546 |
t:= t^.NextGear |
547 |
end; |
|
548 |
NoGearsToAvoid:= true |
|
549 |
end; |
|
550 |
||
6986
409dd3851309
add support for default pascal mode by removing default arguments value (maybe this also helps the parser)
koda
parents:
6888
diff
changeset
|
551 |
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
|
552 |
begin |
409dd3851309
add support for default pascal mode by removing default arguments value (maybe this also helps the parser)
koda
parents:
6888
diff
changeset
|
553 |
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
|
554 |
end; |
6888 | 555 |
|
6581 | 556 |
procedure FindPlace(var Gear: PGear; withFall: boolean; Left, Right: LongInt; skipProximity: boolean); |
557 |
var x: LongInt; |
|
558 |
y, sy: LongInt; |
|
8007 | 559 |
ar: array[0..1023] of TPoint; |
560 |
ar2: array[0..2047] of TPoint; |
|
6581 | 561 |
cnt, cnt2: Longword; |
562 |
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
|
563 |
ignoreNearObjects, ignoreOverlap, tryAgain: boolean; |
6581 | 564 |
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
|
565 |
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
|
566 |
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 | 567 |
tryAgain:= true; |
568 |
while tryAgain do |
|
569 |
begin |
|
8007 | 570 |
delta:= LAND_WIDTH div 16; |
6581 | 571 |
cnt2:= 0; |
572 |
repeat |
|
8007 | 573 |
x:= Left + max(LAND_WIDTH div 2048, LongInt(GetRandom(Delta))); |
6581 | 574 |
repeat |
575 |
inc(x, Delta); |
|
576 |
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
|
577 |
y:= min(1024, topY) - 2 * Gear^.Radius; |
6581 | 578 |
while y < cWaterLine do |
579 |
begin |
|
580 |
repeat |
|
581 |
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
|
582 |
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
|
583 |
(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
|
584 |
(ignoreOverlap and (CountNonZeroz(x, y, Gear^.Radius - 1, 1, $FF00) = 0)); |
6581 | 585 |
|
586 |
sy:= y; |
|
587 |
||
588 |
repeat |
|
589 |
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
|
590 |
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
|
591 |
(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
|
592 |
(ignoreOverlap and (CountNonZeroz(x, y, Gear^.Radius - 1, 1, $FF00) <> 0)); |
6581 | 593 |
|
594 |
if (y - sy > Gear^.Radius * 2) |
|
595 |
and (((Gear^.Kind = gtExplosives) |
|
596 |
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
|
597 |
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
|
598 |
and (CountNonZeroz(x, y+1, Gear^.Radius - 1, Gear^.Radius+1, $FFFF) > Gear^.Radius)) |
6581 | 599 |
or |
600 |
((Gear^.Kind <> gtExplosives) |
|
601 |
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
|
602 |
and (ignoreNearObjects or NoGearsToAvoid(x, y - Gear^.Radius, 110, 110)) |
6888 | 603 |
)) then |
604 |
begin |
|
6581 | 605 |
ar[cnt].X:= x; |
606 |
if withFall then |
|
607 |
ar[cnt].Y:= sy + Gear^.Radius |
|
608 |
else |
|
609 |
ar[cnt].Y:= y - Gear^.Radius; |
|
610 |
inc(cnt) |
|
611 |
end; |
|
612 |
||
7603
e9c3c67b5dfd
reducing this value is sufficient to ensure crates drop just below top border or a girder
nemo
parents:
7599
diff
changeset
|
613 |
inc(y, 10) |
6581 | 614 |
end; |
615 |
||
616 |
if cnt > 0 then |
|
617 |
with ar[GetRandom(cnt)] do |
|
618 |
begin |
|
619 |
ar2[cnt2].x:= x; |
|
620 |
ar2[cnt2].y:= y; |
|
621 |
inc(cnt2) |
|
622 |
end |
|
623 |
until (x + Delta > Right); |
|
624 |
||
625 |
dec(Delta, 60) |
|
626 |
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
|
627 |
// 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
|
628 |
if (cnt2 = 0) and skipProximity and (not ignoreOverlap) then |
6581 | 629 |
tryAgain:= true |
630 |
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
|
631 |
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
|
632 |
ignoreNearObjects:= true; |
6581 | 633 |
end; |
634 |
||
635 |
if cnt2 > 0 then |
|
636 |
with ar2[GetRandom(cnt2)] do |
|
637 |
begin |
|
638 |
Gear^.X:= int2hwFloat(x); |
|
639 |
Gear^.Y:= int2hwFloat(y); |
|
640 |
AddFileLog('Assigned Gear coordinates (' + inttostr(x) + ',' + inttostr(y) + ')'); |
|
641 |
end |
|
642 |
else |
|
643 |
begin |
|
644 |
OutError('Can''t find place for Gear', false); |
|
645 |
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
|
646 |
Gear^.Hedgehog^.Effects[heResurrectable] := 0; |
6581 | 647 |
DeleteGear(Gear); |
648 |
Gear:= nil |
|
649 |
end |
|
650 |
end; |
|
651 |
||
652 |
function CheckGearNear(Gear: PGear; Kind: TGearType; rX, rY: LongInt): PGear; |
|
653 |
var t: PGear; |
|
654 |
begin |
|
655 |
t:= GearsList; |
|
656 |
rX:= sqr(rX); |
|
657 |
rY:= sqr(rY); |
|
658 |
||
659 |
while t <> nil do |
|
660 |
begin |
|
661 |
if (t <> Gear) and (t^.Kind = Kind) then |
|
662 |
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
|
663 |
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
|
664 |
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
|
665 |
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
|
666 |
end; |
6581 | 667 |
t:= t^.NextGear |
668 |
end; |
|
669 |
||
670 |
CheckGearNear:= nil |
|
671 |
end; |
|
672 |
||
7592 | 673 |
procedure CheckCollision(Gear: PGear); inline; |
674 |
begin |
|
675 |
if TestCollisionXwithGear(Gear, hwSign(Gear^.dX)) |
|
676 |
or (TestCollisionYwithGear(Gear, hwSign(Gear^.dY)) <> 0) then |
|
677 |
Gear^.State := Gear^.State or gstCollision |
|
678 |
else |
|
679 |
Gear^.State := Gear^.State and (not gstCollision) |
|
680 |
end; |
|
681 |
||
682 |
procedure CheckCollisionWithLand(Gear: PGear); inline; |
|
683 |
begin |
|
684 |
if TestCollisionX(Gear, hwSign(Gear^.dX)) |
|
685 |
or TestCollisionY(Gear, hwSign(Gear^.dY)) then |
|
686 |
Gear^.State := Gear^.State or gstCollision |
|
687 |
else |
|
688 |
Gear^.State := Gear^.State and (not gstCollision) |
|
689 |
end; |
|
690 |
||
7719
eeae1cb6b6bf
Move hedgehog's step routine into separate function, use it in both hedgehog and ai code
unc0rr
parents:
7627
diff
changeset
|
691 |
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
|
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 |
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
|
694 |
begin |
eeae1cb6b6bf
Move hedgehog's step routine into separate function, use it in both hedgehog and ai code
unc0rr
parents:
7627
diff
changeset
|
695 |
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
|
696 |
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
|
697 |
begin |
eeae1cb6b6bf
Move hedgehog's step routine into separate function, use it in both hedgehog and ai code
unc0rr
parents:
7627
diff
changeset
|
698 |
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
|
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 |
eeae1cb6b6bf
Move hedgehog's step routine into separate function, use it in both hedgehog and ai code
unc0rr
parents:
7627
diff
changeset
|
712 |
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
|
713 |
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
|
714 |
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
|
715 |
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
|
716 |
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
|
717 |
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
|
718 |
end; |
eeae1cb6b6bf
Move hedgehog's step routine into separate function, use it in both hedgehog and ai code
unc0rr
parents:
7627
diff
changeset
|
719 |
|
eeae1cb6b6bf
Move hedgehog's step routine into separate function, use it in both hedgehog and ai code
unc0rr
parents:
7627
diff
changeset
|
720 |
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
|
721 |
begin |
eeae1cb6b6bf
Move hedgehog's step routine into separate function, use it in both hedgehog and ai code
unc0rr
parents:
7627
diff
changeset
|
722 |
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
|
723 |
MakeHedgehogsStep:= true |
eeae1cb6b6bf
Move hedgehog's step routine into separate function, use it in both hedgehog and ai code
unc0rr
parents:
7627
diff
changeset
|
724 |
end else |
eeae1cb6b6bf
Move hedgehog's step routine into separate function, use it in both hedgehog and ai code
unc0rr
parents:
7627
diff
changeset
|
725 |
MakeHedgehogsStep:= false; |
eeae1cb6b6bf
Move hedgehog's step routine into separate function, use it in both hedgehog and ai code
unc0rr
parents:
7627
diff
changeset
|
726 |
|
eeae1cb6b6bf
Move hedgehog's step routine into separate function, use it in both hedgehog and ai code
unc0rr
parents:
7627
diff
changeset
|
727 |
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
|
728 |
begin |
eeae1cb6b6bf
Move hedgehog's step routine into separate function, use it in both hedgehog and ai code
unc0rr
parents:
7627
diff
changeset
|
729 |
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
|
730 |
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
|
731 |
begin |
eeae1cb6b6bf
Move hedgehog's step routine into separate function, use it in both hedgehog and ai code
unc0rr
parents:
7627
diff
changeset
|
732 |
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
|
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 - _6; |
eeae1cb6b6bf
Move hedgehog's step routine into separate function, use it in both hedgehog and ai code
unc0rr
parents:
7627
diff
changeset
|
748 |
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
|
749 |
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
|
750 |
exit |
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 |
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 |
|
6581 | 760 |
end. |