author | unc0rr |
Sat, 23 Feb 2013 23:23:02 +0400 | |
changeset 8569 | 62f4e903fddc |
parent 8199 | 886ed135665b |
child 8330 | aaefa587e277 |
child 8560 | 134a098235fa |
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; |
|
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; |
|
8199
886ed135665b
Fix crashes and wtf behaviour introduced in r0b8beacff8a5
unc0rr
parents:
8161
diff
changeset
|
246 |
end else |
8161 | 247 |
//else if Gear^.Kind <> gtStructure then // not gtHedgehog nor gtStructure |
6581 | 248 |
Gear^.Hedgehog:= AttackerHog; |
249 |
inc(Gear^.Damage, Damage); |
|
250 |
||
251 |
ScriptCall('onGearDamage', Gear^.UID, Damage); |
|
252 |
end; |
|
253 |
||
254 |
procedure spawnHealthTagForHH(HHGear: PGear; dmg: Longword); |
|
255 |
var tag: PVisualGear; |
|
256 |
begin |
|
257 |
tag:= AddVisualGear(hwRound(HHGear^.X), hwRound(HHGear^.Y), vgtHealthTag, dmg); |
|
258 |
if (tag <> nil) then |
|
259 |
tag^.Hedgehog:= HHGear^.Hedgehog; // the tag needs the tag to determine the text color |
|
260 |
AllInactive:= false; |
|
261 |
HHGear^.Active:= true; |
|
262 |
end; |
|
263 |
||
264 |
procedure HHHurt(Hedgehog: PHedgehog; Source: TDamageSource); |
|
265 |
begin |
|
266 |
if (Source = dsFall) or (Source = dsExplosion) then |
|
267 |
case random(3) of |
|
7053 | 268 |
0: PlaySoundV(sndOoff1, Hedgehog^.Team^.voicepack); |
269 |
1: PlaySoundV(sndOoff2, Hedgehog^.Team^.voicepack); |
|
270 |
2: PlaySoundV(sndOoff3, Hedgehog^.Team^.voicepack); |
|
6581 | 271 |
end |
272 |
else if (Source = dsPoison) then |
|
273 |
case random(2) of |
|
7053 | 274 |
0: PlaySoundV(sndPoisonCough, Hedgehog^.Team^.voicepack); |
275 |
1: PlaySoundV(sndPoisonMoan, Hedgehog^.Team^.voicepack); |
|
6581 | 276 |
end |
277 |
else |
|
278 |
case random(4) of |
|
7053 | 279 |
0: PlaySoundV(sndOw1, Hedgehog^.Team^.voicepack); |
280 |
1: PlaySoundV(sndOw2, Hedgehog^.Team^.voicepack); |
|
281 |
2: PlaySoundV(sndOw3, Hedgehog^.Team^.voicepack); |
|
282 |
3: PlaySoundV(sndOw4, Hedgehog^.Team^.voicepack); |
|
6581 | 283 |
end |
284 |
end; |
|
285 |
||
286 |
procedure CheckHHDamage(Gear: PGear); |
|
287 |
var |
|
288 |
dmg: Longword; |
|
8003 | 289 |
i: LongWord; |
6581 | 290 |
particle: PVisualGear; |
291 |
begin |
|
292 |
if _0_4 < Gear^.dY then |
|
293 |
begin |
|
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 |
|
7825 | 326 |
// Frac/Round to be kind to JS as of 2012-08-27 where there is yet no int64/uint64 |
327 |
//dAngle := (Gear^.dX.QWordValue + Gear^.dY.QWordValue) / $80000000; |
|
328 |
dAngle := (Gear^.dX.Round + Gear^.dY.Round) / 2 + (Gear^.dX.Frac/$100000000+Gear^.dY.Frac/$100000000); |
|
6581 | 329 |
if not Gear^.dX.isNegative then |
330 |
Gear^.DirAngle := Gear^.DirAngle + dAngle |
|
331 |
else |
|
332 |
Gear^.DirAngle := Gear^.DirAngle - dAngle; |
|
333 |
||
334 |
if Gear^.DirAngle < 0 then |
|
335 |
Gear^.DirAngle := Gear^.DirAngle + 360 |
|
336 |
else if 360 < Gear^.DirAngle then |
|
337 |
Gear^.DirAngle := Gear^.DirAngle - 360 |
|
338 |
end; |
|
339 |
||
340 |
function CheckGearDrowning(Gear: PGear): boolean; |
|
341 |
var |
|
342 |
skipSpeed, skipAngle, skipDecay: hwFloat; |
|
343 |
i, maxDrops, X, Y: LongInt; |
|
344 |
vdX, vdY: real; |
|
6803
0e70f3ea3bf8
bit of an experiment in variable splash sizes based on object/speed. not sure if it looks good yet. need to drown more stuff.
nemo
parents:
6769
diff
changeset
|
345 |
particle, splash: PVisualGear; |
6581 | 346 |
isSubmersible: boolean; |
347 |
begin |
|
348 |
// probably needs tweaking. might need to be in a case statement based upon gear type |
|
349 |
Y:= hwRound(Gear^.Y); |
|
350 |
if cWaterLine < Y + Gear^.Radius then |
|
351 |
begin |
|
7389
15c3fb4882df
Sorry about the slight delay in pickup. You can blame a few lame cheaters. This is to make their cheating a bit harder.
nemo
parents:
7372
diff
changeset
|
352 |
if Gear^.State and gstInvisible <> 0 then |
15c3fb4882df
Sorry about the slight delay in pickup. You can blame a few lame cheaters. This is to make their cheating a bit harder.
nemo
parents:
7372
diff
changeset
|
353 |
begin |
7406
1fe2c821f9bf
Try avoiding spamming the log by retaining the gears. untested.
nemo
parents:
7389
diff
changeset
|
354 |
if Gear^.Kind = gtGenericFaller then |
1fe2c821f9bf
Try avoiding spamming the log by retaining the gears. untested.
nemo
parents:
7389
diff
changeset
|
355 |
begin |
1fe2c821f9bf
Try avoiding spamming the log by retaining the gears. untested.
nemo
parents:
7389
diff
changeset
|
356 |
Gear^.X:= int2hwFloat(GetRandom(rightX-leftX)+leftX); |
1fe2c821f9bf
Try avoiding spamming the log by retaining the gears. untested.
nemo
parents:
7389
diff
changeset
|
357 |
Gear^.Y:= int2hwFloat(GetRandom(LAND_HEIGHT-topY)+topY); |
1fe2c821f9bf
Try avoiding spamming the log by retaining the gears. untested.
nemo
parents:
7389
diff
changeset
|
358 |
Gear^.dX:= _90-(GetRandomf*_360); |
1fe2c821f9bf
Try avoiding spamming the log by retaining the gears. untested.
nemo
parents:
7389
diff
changeset
|
359 |
Gear^.dY:= _90-(GetRandomf*_360) |
1fe2c821f9bf
Try avoiding spamming the log by retaining the gears. untested.
nemo
parents:
7389
diff
changeset
|
360 |
end |
1fe2c821f9bf
Try avoiding spamming the log by retaining the gears. untested.
nemo
parents:
7389
diff
changeset
|
361 |
else DeleteGear(Gear); |
7389
15c3fb4882df
Sorry about the slight delay in pickup. You can blame a few lame cheaters. This is to make their cheating a bit harder.
nemo
parents:
7372
diff
changeset
|
362 |
exit |
15c3fb4882df
Sorry about the slight delay in pickup. You can blame a few lame cheaters. This is to make their cheating a bit harder.
nemo
parents:
7372
diff
changeset
|
363 |
end; |
6581 | 364 |
isSubmersible:= (Gear = CurrentHedgehog^.Gear) and (CurAmmoGear <> nil) and (CurAmmoGear^.AmmoType = amJetpack); |
365 |
skipSpeed := _0_25; |
|
366 |
skipAngle := _1_9; |
|
367 |
skipDecay := _0_87; |
|
368 |
X:= hwRound(Gear^.X); |
|
369 |
vdX:= hwFloat2Float(Gear^.dX); |
|
370 |
vdY:= hwFloat2Float(Gear^.dY); |
|
371 |
// this could perhaps be a tiny bit higher. |
|
372 |
if (hwSqr(Gear^.dX) + hwSqr(Gear^.dY) > skipSpeed) |
|
373 |
and (hwAbs(Gear^.dX) > skipAngle * hwAbs(Gear^.dY)) then |
|
374 |
begin |
|
375 |
Gear^.dY.isNegative := true; |
|
376 |
Gear^.dY := Gear^.dY * skipDecay; |
|
377 |
Gear^.dX := Gear^.dX * skipDecay; |
|
378 |
CheckGearDrowning := false; |
|
379 |
PlaySound(sndSkip) |
|
380 |
end |
|
381 |
else |
|
382 |
begin |
|
383 |
if not isSubmersible then |
|
384 |
begin |
|
385 |
CheckGearDrowning := true; |
|
386 |
Gear^.State := gstDrowning; |
|
387 |
Gear^.RenderTimer := false; |
|
388 |
if (Gear^.Kind <> gtSniperRifleShot) and (Gear^.Kind <> gtShotgunShot) |
|
389 |
and (Gear^.Kind <> gtDEagleShot) and (Gear^.Kind <> gtSineGunShot) then |
|
390 |
if Gear^.Kind = gtHedgehog then |
|
391 |
begin |
|
7010
10a0a31804f3
Switch effects to longint for convenience of tracking ice states. I could add a new Hedgehog value, but since we have this effects list being all useless as booleans anyway...
nemo
parents:
6990
diff
changeset
|
392 |
if Gear^.Hedgehog^.Effects[heResurrectable] <> 0 then |
6581 | 393 |
ResurrectHedgehog(Gear) |
394 |
else |
|
395 |
begin |
|
396 |
Gear^.doStep := @doStepDrowningGear; |
|
397 |
Gear^.State := Gear^.State and (not gstHHDriven); |
|
398 |
AddCaption(Format(GetEventString(eidDrowned), Gear^.Hedgehog^.Name), cWhiteColor, capgrpMessage); |
|
399 |
end |
|
400 |
end |
|
401 |
else |
|
402 |
Gear^.doStep := @doStepDrowningGear; |
|
403 |
if Gear^.Kind = gtFlake then |
|
404 |
exit // skip splashes |
|
405 |
end; |
|
406 |
if ((not isSubmersible) and (Y < cWaterLine + 64 + Gear^.Radius)) |
|
407 |
or (isSubmersible and (Y < cWaterLine + 2 + Gear^.Radius) and ((CurAmmoGear^.Pos = 0) |
|
408 |
and (CurAmmoGear^.dY < _0_01))) then |
|
6804 | 409 |
if Gear^.Density * Gear^.dY > _1 then |
410 |
PlaySound(sndSplash) |
|
411 |
else if Gear^.Density * Gear^.dY > _0_5 then |
|
412 |
PlaySound(sndSkip) |
|
413 |
else |
|
414 |
PlaySound(sndDroplet2); |
|
6581 | 415 |
end; |
416 |
||
417 |
if ((cReducedQuality and rqPlainSplash) = 0) |
|
418 |
and (((not isSubmersible) and (Y < cWaterLine + 64 + Gear^.Radius)) |
|
419 |
or (isSubmersible and (Y < cWaterLine + 2 + Gear^.Radius) and ((CurAmmoGear^.Pos = 0) |
|
420 |
and (CurAmmoGear^.dY < _0_01)))) then |
|
421 |
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
|
422 |
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
|
423 |
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
|
424 |
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
|
425 |
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
|
426 |
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
|
427 |
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
|
428 |
else Scale:= Scale + ((1-Scale) / 2); |
7420 | 429 |
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
|
430 |
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
|
431 |
// 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
|
432 |
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
|
433 |
end; |
6581 | 434 |
|
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
|
435 |
maxDrops := (hwRound(Gear^.Density) * 3) div 2 + round(vdX * hwRound(Gear^.Density) * 6) + round(vdY * hwRound(Gear^.Density) * 6); |
6581 | 436 |
for i:= max(maxDrops div 3, min(32, Random(maxDrops))) downto 0 do |
437 |
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
|
438 |
particle := AddVisualGear(X - 3 + Random(7), cWaterLine, vgtDroplet); |
6581 | 439 |
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
|
440 |
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
|
441 |
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
|
442 |
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
|
443 |
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
|
444 |
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
|
445 |
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
|
446 |
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
|
447 |
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
|
448 |
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
|
449 |
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
|
450 |
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
|
451 |
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
|
452 |
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
|
453 |
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
|
454 |
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
|
455 |
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
|
456 |
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
|
457 |
end |
6581 | 458 |
end |
459 |
end; |
|
460 |
if isSubmersible and (CurAmmoGear^.Pos = 0) then |
|
461 |
CurAmmoGear^.Pos := 1000 |
|
462 |
end |
|
463 |
else |
|
464 |
CheckGearDrowning := false; |
|
465 |
end; |
|
466 |
||
467 |
||
468 |
procedure ResurrectHedgehog(gear: PGear); |
|
469 |
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
|
470 |
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
|
471 |
gX, gY: LongInt; |
6581 | 472 |
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
|
473 |
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
|
474 |
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
|
475 |
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
|
476 |
uStats.HedgehogDamaged(Gear, CurrentHedgehog, 0, true); |
6581 | 477 |
AttackBar:= 0; |
478 |
gear^.dX := _0; |
|
479 |
gear^.dY := _0; |
|
480 |
gear^.Damage := 0; |
|
481 |
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
|
482 |
gear^.Hedgehog^.Effects[hePoisoned] := 0; |
7176
fb4b0c6dfdbd
Make watching AI v AI on ai survival a bit more entertaining
nemo
parents:
7168
diff
changeset
|
483 |
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
|
484 |
and (Gear^.Hedgehog^.Team^.Clan <> CurrentHedgehog^.Team^.Clan)) then |
6581 | 485 |
with CurrentHedgehog^ do |
486 |
begin |
|
487 |
inc(Team^.stats.AIKills); |
|
488 |
FreeTexture(Team^.AIKillsTex); |
|
489 |
Team^.AIKillsTex := RenderStringTex(inttostr(Team^.stats.AIKills), Team^.Clan^.Color, fnt16); |
|
490 |
end; |
|
491 |
tempTeam := gear^.Hedgehog^.Team; |
|
492 |
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
|
493 |
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
|
494 |
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
|
495 |
// 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
|
496 |
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
|
497 |
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
|
498 |
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
|
499 |
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
|
500 |
//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
|
501 |
end; |
6581 | 502 |
FindPlace(gear, false, 0, LAND_WIDTH, true); |
503 |
if gear <> nil then |
|
504 |
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
|
505 |
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
|
506 |
PlaySound(sndWarp); |
6581 | 507 |
RenderHealth(gear^.Hedgehog^); |
508 |
ScriptCall('onGearResurrect', gear^.uid); |
|
509 |
gear^.State := gstWait; |
|
510 |
end; |
|
511 |
RecountTeamHealth(tempTeam); |
|
512 |
end; |
|
513 |
||
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
|
514 |
function CountNonZeroz(x, y, r, c: LongInt; mask: LongWord): LongInt; |
6581 | 515 |
var i: LongInt; |
516 |
count: LongInt = 0; |
|
517 |
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
|
518 |
if (y and LAND_HEIGHT_MASK) = 0 then |
7509 | 519 |
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
|
520 |
if Land[y, i] and mask <> 0 then |
6581 | 521 |
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
|
522 |
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
|
523 |
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
|
524 |
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
|
525 |
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
|
526 |
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
|
527 |
end; |
6581 | 528 |
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
|
529 |
CountNonZeroz:= count; |
6581 | 530 |
end; |
531 |
||
6888 | 532 |
|
533 |
function NoGearsToAvoid(mX, mY: LongInt; rX, rY: LongInt): boolean; |
|
534 |
var t: PGear; |
|
535 |
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
|
536 |
NoGearsToAvoid:= false; |
6888 | 537 |
t:= GearsList; |
538 |
rX:= sqr(rX); |
|
539 |
rY:= sqr(rY); |
|
540 |
while t <> nil do |
|
541 |
begin |
|
542 |
if t^.Kind <= gtExplosives then |
|
543 |
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
|
544 |
exit; |
6888 | 545 |
t:= t^.NextGear |
546 |
end; |
|
547 |
NoGearsToAvoid:= true |
|
548 |
end; |
|
549 |
||
6986
409dd3851309
add support for default pascal mode by removing default arguments value (maybe this also helps the parser)
koda
parents:
6888
diff
changeset
|
550 |
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
|
551 |
begin |
409dd3851309
add support for default pascal mode by removing default arguments value (maybe this also helps the parser)
koda
parents:
6888
diff
changeset
|
552 |
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
|
553 |
end; |
6888 | 554 |
|
6581 | 555 |
procedure FindPlace(var Gear: PGear; withFall: boolean; Left, Right: LongInt; skipProximity: boolean); |
556 |
var x: LongInt; |
|
557 |
y, sy: LongInt; |
|
8007 | 558 |
ar: array[0..1023] of TPoint; |
559 |
ar2: array[0..2047] of TPoint; |
|
6581 | 560 |
cnt, cnt2: Longword; |
561 |
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
|
562 |
ignoreNearObjects, ignoreOverlap, tryAgain: boolean; |
6581 | 563 |
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
|
564 |
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
|
565 |
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 | 566 |
tryAgain:= true; |
567 |
while tryAgain do |
|
568 |
begin |
|
8007 | 569 |
delta:= LAND_WIDTH div 16; |
6581 | 570 |
cnt2:= 0; |
571 |
repeat |
|
8007 | 572 |
x:= Left + max(LAND_WIDTH div 2048, LongInt(GetRandom(Delta))); |
6581 | 573 |
repeat |
574 |
inc(x, Delta); |
|
575 |
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
|
576 |
y:= min(1024, topY) - 2 * Gear^.Radius; |
6581 | 577 |
while y < cWaterLine do |
578 |
begin |
|
579 |
repeat |
|
580 |
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
|
581 |
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
|
582 |
(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
|
583 |
(ignoreOverlap and (CountNonZeroz(x, y, Gear^.Radius - 1, 1, $FF00) = 0)); |
6581 | 584 |
|
585 |
sy:= y; |
|
586 |
||
587 |
repeat |
|
588 |
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
|
589 |
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
|
590 |
(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
|
591 |
(ignoreOverlap and (CountNonZeroz(x, y, Gear^.Radius - 1, 1, $FF00) <> 0)); |
6581 | 592 |
|
593 |
if (y - sy > Gear^.Radius * 2) |
|
594 |
and (((Gear^.Kind = gtExplosives) |
|
595 |
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
|
596 |
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
|
597 |
and (CountNonZeroz(x, y+1, Gear^.Radius - 1, Gear^.Radius+1, $FFFF) > Gear^.Radius)) |
6581 | 598 |
or |
599 |
((Gear^.Kind <> gtExplosives) |
|
600 |
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
|
601 |
and (ignoreNearObjects or NoGearsToAvoid(x, y - Gear^.Radius, 110, 110)) |
6888 | 602 |
)) then |
603 |
begin |
|
6581 | 604 |
ar[cnt].X:= x; |
605 |
if withFall then |
|
606 |
ar[cnt].Y:= sy + Gear^.Radius |
|
607 |
else |
|
608 |
ar[cnt].Y:= y - Gear^.Radius; |
|
609 |
inc(cnt) |
|
610 |
end; |
|
611 |
||
7603
e9c3c67b5dfd
reducing this value is sufficient to ensure crates drop just below top border or a girder
nemo
parents:
7599
diff
changeset
|
612 |
inc(y, 10) |
6581 | 613 |
end; |
614 |
||
615 |
if cnt > 0 then |
|
616 |
with ar[GetRandom(cnt)] do |
|
617 |
begin |
|
618 |
ar2[cnt2].x:= x; |
|
619 |
ar2[cnt2].y:= y; |
|
620 |
inc(cnt2) |
|
621 |
end |
|
622 |
until (x + Delta > Right); |
|
623 |
||
624 |
dec(Delta, 60) |
|
625 |
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
|
626 |
// 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
|
627 |
if (cnt2 = 0) and skipProximity and (not ignoreOverlap) then |
6581 | 628 |
tryAgain:= true |
629 |
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
|
630 |
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
|
631 |
ignoreNearObjects:= true; |
6581 | 632 |
end; |
633 |
||
634 |
if cnt2 > 0 then |
|
635 |
with ar2[GetRandom(cnt2)] do |
|
636 |
begin |
|
637 |
Gear^.X:= int2hwFloat(x); |
|
638 |
Gear^.Y:= int2hwFloat(y); |
|
639 |
AddFileLog('Assigned Gear coordinates (' + inttostr(x) + ',' + inttostr(y) + ')'); |
|
640 |
end |
|
641 |
else |
|
642 |
begin |
|
643 |
OutError('Can''t find place for Gear', false); |
|
644 |
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
|
645 |
Gear^.Hedgehog^.Effects[heResurrectable] := 0; |
6581 | 646 |
DeleteGear(Gear); |
647 |
Gear:= nil |
|
648 |
end |
|
649 |
end; |
|
650 |
||
651 |
function CheckGearNear(Gear: PGear; Kind: TGearType; rX, rY: LongInt): PGear; |
|
652 |
var t: PGear; |
|
653 |
begin |
|
654 |
t:= GearsList; |
|
655 |
rX:= sqr(rX); |
|
656 |
rY:= sqr(rY); |
|
657 |
||
658 |
while t <> nil do |
|
659 |
begin |
|
660 |
if (t <> Gear) and (t^.Kind = Kind) then |
|
661 |
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
|
662 |
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
|
663 |
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
|
664 |
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
|
665 |
end; |
6581 | 666 |
t:= t^.NextGear |
667 |
end; |
|
668 |
||
669 |
CheckGearNear:= nil |
|
670 |
end; |
|
671 |
||
7592 | 672 |
procedure CheckCollision(Gear: PGear); inline; |
673 |
begin |
|
674 |
if TestCollisionXwithGear(Gear, hwSign(Gear^.dX)) |
|
675 |
or (TestCollisionYwithGear(Gear, hwSign(Gear^.dY)) <> 0) then |
|
676 |
Gear^.State := Gear^.State or gstCollision |
|
677 |
else |
|
678 |
Gear^.State := Gear^.State and (not gstCollision) |
|
679 |
end; |
|
680 |
||
681 |
procedure CheckCollisionWithLand(Gear: PGear); inline; |
|
682 |
begin |
|
683 |
if TestCollisionX(Gear, hwSign(Gear^.dX)) |
|
684 |
or TestCollisionY(Gear, hwSign(Gear^.dY)) then |
|
685 |
Gear^.State := Gear^.State or gstCollision |
|
686 |
else |
|
687 |
Gear^.State := Gear^.State and (not gstCollision) |
|
688 |
end; |
|
689 |
||
7719
eeae1cb6b6bf
Move hedgehog's step routine into separate function, use it in both hedgehog and ai code
unc0rr
parents:
7627
diff
changeset
|
690 |
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
|
691 |
begin |
eeae1cb6b6bf
Move hedgehog's step routine into separate function, use it in both hedgehog and ai code
unc0rr
parents:
7627
diff
changeset
|
692 |
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
|
693 |
begin |
eeae1cb6b6bf
Move hedgehog's step routine into separate function, use it in both hedgehog and ai code
unc0rr
parents:
7627
diff
changeset
|
694 |
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
|
695 |
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
|
696 |
begin |
eeae1cb6b6bf
Move hedgehog's step routine into separate function, use it in both hedgehog and ai code
unc0rr
parents:
7627
diff
changeset
|
697 |
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
|
698 |
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
|
699 |
begin |
eeae1cb6b6bf
Move hedgehog's step routine into separate function, use it in both hedgehog and ai code
unc0rr
parents:
7627
diff
changeset
|
700 |
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
|
701 |
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
|
702 |
begin |
eeae1cb6b6bf
Move hedgehog's step routine into separate function, use it in both hedgehog and ai code
unc0rr
parents:
7627
diff
changeset
|
703 |
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
|
704 |
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
|
705 |
begin |
eeae1cb6b6bf
Move hedgehog's step routine into separate function, use it in both hedgehog and ai code
unc0rr
parents:
7627
diff
changeset
|
706 |
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
|
707 |
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
|
708 |
begin |
eeae1cb6b6bf
Move hedgehog's step routine into separate function, use it in both hedgehog and ai code
unc0rr
parents:
7627
diff
changeset
|
709 |
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
|
710 |
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
|
711 |
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
|
712 |
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
|
713 |
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
|
714 |
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
|
715 |
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
|
716 |
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
|
717 |
end; |
eeae1cb6b6bf
Move hedgehog's step routine into separate function, use it in both hedgehog and ai code
unc0rr
parents:
7627
diff
changeset
|
718 |
|
eeae1cb6b6bf
Move hedgehog's step routine into separate function, use it in both hedgehog and ai code
unc0rr
parents:
7627
diff
changeset
|
719 |
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
|
720 |
begin |
eeae1cb6b6bf
Move hedgehog's step routine into separate function, use it in both hedgehog and ai code
unc0rr
parents:
7627
diff
changeset
|
721 |
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
|
722 |
MakeHedgehogsStep:= true |
eeae1cb6b6bf
Move hedgehog's step routine into separate function, use it in both hedgehog and ai code
unc0rr
parents:
7627
diff
changeset
|
723 |
end else |
eeae1cb6b6bf
Move hedgehog's step routine into separate function, use it in both hedgehog and ai code
unc0rr
parents:
7627
diff
changeset
|
724 |
MakeHedgehogsStep:= false; |
eeae1cb6b6bf
Move hedgehog's step routine into separate function, use it in both hedgehog and ai code
unc0rr
parents:
7627
diff
changeset
|
725 |
|
eeae1cb6b6bf
Move hedgehog's step routine into separate function, use it in both hedgehog and ai code
unc0rr
parents:
7627
diff
changeset
|
726 |
if 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
|
727 |
begin |
eeae1cb6b6bf
Move hedgehog's step routine into separate function, use it in both hedgehog and ai code
unc0rr
parents:
7627
diff
changeset
|
728 |
Gear^.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
|
729 |
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
|
730 |
begin |
eeae1cb6b6bf
Move hedgehog's step routine into separate function, use it in both hedgehog and ai code
unc0rr
parents:
7627
diff
changeset
|
731 |
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
|
732 |
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
|
733 |
begin |
eeae1cb6b6bf
Move hedgehog's step routine into separate function, use it in both hedgehog and ai code
unc0rr
parents:
7627
diff
changeset
|
734 |
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
|
735 |
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
|
736 |
begin |
eeae1cb6b6bf
Move hedgehog's step routine into separate function, use it in both hedgehog and ai code
unc0rr
parents:
7627
diff
changeset
|
737 |
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
|
738 |
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
|
739 |
begin |
eeae1cb6b6bf
Move hedgehog's step routine into separate function, use it in both hedgehog and ai code
unc0rr
parents:
7627
diff
changeset
|
740 |
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
|
741 |
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
|
742 |
begin |
eeae1cb6b6bf
Move hedgehog's step routine into separate function, use it in both hedgehog and ai code
unc0rr
parents:
7627
diff
changeset
|
743 |
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
|
744 |
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
|
745 |
begin |
eeae1cb6b6bf
Move hedgehog's step routine into separate function, use it in both hedgehog and ai code
unc0rr
parents:
7627
diff
changeset
|
746 |
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
|
747 |
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
|
748 |
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
|
749 |
exit |
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 |
end; |
eeae1cb6b6bf
Move hedgehog's step routine into separate function, use it in both hedgehog and ai code
unc0rr
parents:
7627
diff
changeset
|
758 |
|
6581 | 759 |
end. |