author | unc0rr |
Sat, 15 Jun 2013 23:45:53 +0400 | |
branch | webgl |
changeset 9166 | 3774ac58e65e |
parent 9160 | fc46e75f6b72 |
child 9521 | 8054d9d775fd |
permissions | -rw-r--r-- |
6581 | 1 |
(* |
2 |
* Hedgewars, a free turn based strategy game |
|
9080 | 3 |
* Copyright (c) 2004-2013 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; |
8330 | 26 |
procedure doMakeExplosion(X, Y, Radius: LongInt; AttackingHog: PHedgehog; Mask: Longword; const Tint: LongWord); |
6986
409dd3851309
add support for default pascal mode by removing default arguments value (maybe this also helps the parser)
koda
parents:
6888
diff
changeset
|
27 |
|
6581 | 28 |
function ModifyDamage(dmg: Longword; Gear: PGear): Longword; |
29 |
procedure ApplyDamage(Gear: PGear; AttackerHog: PHedgehog; Damage: Longword; Source: TDamageSource); |
|
30 |
procedure spawnHealthTagForHH(HHGear: PGear; dmg: Longword); |
|
31 |
procedure HHHurt(Hedgehog: PHedgehog; Source: TDamageSource); |
|
32 |
procedure CheckHHDamage(Gear: PGear); |
|
33 |
procedure CalcRotationDirAngle(Gear: PGear); |
|
8947
e906ebd59612
CheckGearDrowning could delete hedgehogs gear! (CheckGearDrowning -> ResurrectHedgehog -> FindPlace). Fixes bug 620.
unc0rr
parents:
8763
diff
changeset
|
34 |
procedure ResurrectHedgehog(var gear: PGear); |
6986
409dd3851309
add support for default pascal mode by removing default arguments value (maybe this also helps the parser)
koda
parents:
6888
diff
changeset
|
35 |
|
409dd3851309
add support for default pascal mode by removing default arguments value (maybe this also helps the parser)
koda
parents:
6888
diff
changeset
|
36 |
procedure FindPlace(var Gear: PGear; withFall: boolean; Left, Right: LongInt); inline; |
409dd3851309
add support for default pascal mode by removing default arguments value (maybe this also helps the parser)
koda
parents:
6888
diff
changeset
|
37 |
procedure FindPlace(var Gear: PGear; withFall: boolean; Left, Right: LongInt; skipProximity: boolean); |
409dd3851309
add support for default pascal mode by removing default arguments value (maybe this also helps the parser)
koda
parents:
6888
diff
changeset
|
38 |
|
6581 | 39 |
function CheckGearNear(Gear: PGear; Kind: TGearType; rX, rY: LongInt): PGear; |
8947
e906ebd59612
CheckGearDrowning could delete hedgehogs gear! (CheckGearDrowning -> ResurrectHedgehog -> FindPlace). Fixes bug 620.
unc0rr
parents:
8763
diff
changeset
|
40 |
function CheckGearDrowning(var Gear: PGear): boolean; |
7592 | 41 |
procedure CheckCollision(Gear: PGear); inline; |
42 |
procedure CheckCollisionWithLand(Gear: PGear); inline; |
|
6581 | 43 |
|
7719
eeae1cb6b6bf
Move hedgehog's step routine into separate function, use it in both hedgehog and ai code
unc0rr
parents:
7627
diff
changeset
|
44 |
function MakeHedgehogsStep(Gear: PGear) : boolean; |
eeae1cb6b6bf
Move hedgehog's step routine into separate function, use it in both hedgehog and ai code
unc0rr
parents:
7627
diff
changeset
|
45 |
|
6581 | 46 |
var doStepHandlers: array[TGearType] of TGearStepProcedure; |
47 |
||
48 |
||
49 |
implementation |
|
50 |
uses uFloat, uSound, uCollisions, uUtils, uConsts, uVisualGears, uAIMisc, |
|
51 |
uVariables, uLandGraphics, uScript, uStats, uCaptions, uTeams, uStore, |
|
52 |
uLocale, uTextures, uRenderUtils, uRandom, SDLh, uDebug, uGears, |
|
7066
12cc2bd84b0b
Make pas2c even more happier with uGears.c, allow assigning arrays in some cases
unc0rr
parents:
7053
diff
changeset
|
53 |
uGearsList, Math; |
6581 | 54 |
|
6986
409dd3851309
add support for default pascal mode by removing default arguments value (maybe this also helps the parser)
koda
parents:
6888
diff
changeset
|
55 |
procedure doMakeExplosion(X, Y, Radius: LongInt; AttackingHog: PHedgehog; Mask: Longword); inline; |
409dd3851309
add support for default pascal mode by removing default arguments value (maybe this also helps the parser)
koda
parents:
6888
diff
changeset
|
56 |
begin |
409dd3851309
add support for default pascal mode by removing default arguments value (maybe this also helps the parser)
koda
parents:
6888
diff
changeset
|
57 |
doMakeExplosion(X, Y, Radius, AttackingHog, Mask, $FFFFFFFF); |
409dd3851309
add support for default pascal mode by removing default arguments value (maybe this also helps the parser)
koda
parents:
6888
diff
changeset
|
58 |
end; |
409dd3851309
add support for default pascal mode by removing default arguments value (maybe this also helps the parser)
koda
parents:
6888
diff
changeset
|
59 |
|
6581 | 60 |
procedure doMakeExplosion(X, Y, Radius: LongInt; AttackingHog: PHedgehog; Mask: Longword; const Tint: LongWord); |
61 |
var Gear: PGear; |
|
6769
44ad49a3a126
Add drowning to grenade too, try some little optimisations
nemo
parents:
6765
diff
changeset
|
62 |
dmg, dmgBase: LongInt; |
6765 | 63 |
fX, fY, tdX, tdY: hwFloat; |
6581 | 64 |
vg: PVisualGear; |
65 |
i, cnt: LongInt; |
|
66 |
begin |
|
67 |
if Radius > 4 then AddFileLog('Explosion: at (' + inttostr(x) + ',' + inttostr(y) + ')'); |
|
68 |
if Radius > 25 then KickFlakes(Radius, X, Y); |
|
69 |
||
70 |
if ((Mask and EXPLNoGfx) = 0) then |
|
71 |
begin |
|
72 |
vg:= nil; |
|
73 |
if Radius > 50 then vg:= AddVisualGear(X, Y, vgtBigExplosion) |
|
74 |
else if Radius > 10 then vg:= AddVisualGear(X, Y, vgtExplosion); |
|
75 |
if vg <> nil then |
|
76 |
vg^.Tint:= Tint; |
|
77 |
end; |
|
78 |
if (Mask and EXPLAutoSound) <> 0 then PlaySound(sndExplosion); |
|
79 |
||
6765 | 80 |
(*if (Mask and EXPLAllDamageInRadius) = 0 then |
6581 | 81 |
dmgRadius:= Radius shl 1 |
82 |
else |
|
83 |
dmgRadius:= Radius; |
|
6765 | 84 |
dmgBase:= dmgRadius + cHHRadius div 2;*) |
85 |
dmgBase:= Radius shl 1 + cHHRadius div 2; |
|
6581 | 86 |
fX:= int2hwFloat(X); |
87 |
fY:= int2hwFloat(Y); |
|
88 |
Gear:= GearsList; |
|
89 |
while Gear <> nil do |
|
90 |
begin |
|
91 |
dmg:= 0; |
|
92 |
//dmg:= dmgRadius + cHHRadius div 2 - hwRound(Distance(Gear^.X - int2hwFloat(X), Gear^.Y - int2hwFloat(Y))); |
|
93 |
//if (dmg > 1) and |
|
94 |
if (Gear^.State and gstNoDamage) = 0 then |
|
95 |
begin |
|
96 |
case Gear^.Kind of |
|
97 |
gtHedgehog, |
|
98 |
gtMine, |
|
99 |
gtBall, |
|
100 |
gtMelonPiece, |
|
101 |
gtGrenade, |
|
102 |
gtClusterBomb, |
|
103 |
// gtCluster, too game breaking I think |
|
104 |
gtSMine, |
|
105 |
gtCase, |
|
106 |
gtTarget, |
|
107 |
gtFlame, |
|
7754 | 108 |
gtKnife, |
8161 | 109 |
gtExplosives: begin //, |
110 |
//gtStructure: begin |
|
6581 | 111 |
// Run the calcs only once we know we have a type that will need damage |
6765 | 112 |
tdX:= Gear^.X-fX; |
113 |
tdY:= Gear^.Y-fY; |
|
7721 | 114 |
if LongInt(tdX.Round + tdY.Round + 2) < dmgBase then |
7272
71df899c4163
Second part of the change. Make collision check use the new mask bit.
nemo
parents:
7190
diff
changeset
|
115 |
dmg:= dmgBase - hwRound(Distance(tdX, tdY)); |
6581 | 116 |
if dmg > 1 then |
117 |
begin |
|
118 |
dmg:= ModifyDamage(min(dmg div 2, Radius), Gear); |
|
119 |
//AddFileLog('Damage: ' + inttostr(dmg)); |
|
120 |
if (Mask and EXPLNoDamage) = 0 then |
|
121 |
begin |
|
122 |
if not Gear^.Invulnerable then |
|
123 |
ApplyDamage(Gear, AttackingHog, dmg, dsExplosion) |
|
124 |
else |
|
125 |
Gear^.State:= Gear^.State or gstWinner; |
|
126 |
end; |
|
127 |
if ((Mask and EXPLDoNotTouchAny) = 0) and (((Mask and EXPLDoNotTouchHH) = 0) or (Gear^.Kind <> gtHedgehog)) then |
|
128 |
begin |
|
129 |
DeleteCI(Gear); |
|
6765 | 130 |
Gear^.dX:= Gear^.dX + SignAs(_0_005 * dmg + cHHKick, tdX)/(Gear^.Density/_3); |
131 |
Gear^.dY:= Gear^.dY + SignAs(_0_005 * dmg + cHHKick, tdY)/(Gear^.Density/_3); |
|
6581 | 132 |
|
133 |
Gear^.State:= (Gear^.State or gstMoving) and (not gstLoser); |
|
7767 | 134 |
if Gear^.Kind = gtKnife then Gear^.State:= Gear^.State and (not gstCollision); |
6581 | 135 |
if not Gear^.Invulnerable then |
136 |
Gear^.State:= (Gear^.State or gstMoving) and (not gstWinner); |
|
137 |
Gear^.Active:= true; |
|
138 |
if Gear^.Kind <> gtFlame then FollowGear:= Gear |
|
139 |
end; |
|
8763 | 140 |
if ((Mask and EXPLPoisoned) <> 0) and (Gear^.Kind = gtHedgehog) and (not Gear^.Invulnerable) and ((Gear^.State and gstHHDeath) = 0) then |
7010
10a0a31804f3
Switch effects to longint for convenience of tracking ice states. I could add a new Hedgehog value, but since we have this effects list being all useless as booleans anyway...
nemo
parents:
6990
diff
changeset
|
141 |
Gear^.Hedgehog^.Effects[hePoisoned] := 1; |
6581 | 142 |
end; |
143 |
||
144 |
end; |
|
145 |
gtGrave: begin |
|
146 |
// Run the calcs only once we know we have a type that will need damage |
|
6765 | 147 |
tdX:= Gear^.X-fX; |
148 |
tdY:= Gear^.Y-fY; |
|
7721 | 149 |
if LongInt(tdX.Round + tdY.Round + 2) < dmgBase then |
6765 | 150 |
dmg:= dmgBase - hwRound(Distance(tdX, tdY)); |
6581 | 151 |
if dmg > 1 then |
152 |
begin |
|
153 |
dmg:= ModifyDamage(min(dmg div 2, Radius), Gear); |
|
154 |
Gear^.dY:= - _0_004 * dmg; |
|
155 |
Gear^.Active:= true |
|
156 |
end |
|
157 |
end; |
|
158 |
end; |
|
159 |
end; |
|
160 |
Gear:= Gear^.NextGear |
|
161 |
end; |
|
162 |
||
163 |
if (Mask and EXPLDontDraw) = 0 then |
|
164 |
if (GameFlags and gfSolidLand) = 0 then |
|
165 |
begin |
|
166 |
cnt:= DrawExplosion(X, Y, Radius) div 1608; // approx 2 16x16 circles to erase per chunk |
|
167 |
if (cnt > 0) and (SpritesData[sprChunk].Texture <> nil) then |
|
168 |
for i:= 0 to cnt do |
|
169 |
AddVisualGear(X, Y, vgtChunk) |
|
170 |
end; |
|
171 |
||
172 |
uAIMisc.AwareOfExplosion(0, 0, 0) |
|
173 |
end; |
|
174 |
||
175 |
function ModifyDamage(dmg: Longword; Gear: PGear): Longword; |
|
176 |
var i: hwFloat; |
|
177 |
begin |
|
178 |
(* Invulnerability cannot be placed in here due to still needing kicks |
|
179 |
Not without a new damage machine. |
|
180 |
King check should be in here instead of ApplyDamage since Tiy wants them kicked less |
|
181 |
*) |
|
182 |
i:= _1; |
|
183 |
if (CurrentHedgehog <> nil) and CurrentHedgehog^.King then |
|
184 |
i:= _1_5; |
|
8632
b5ed76d2a1f9
Make hogs thaw only on enemy turns, make timebox counter decrement only on your turn, adjust knock for frozen hogs, increase damage on frozen hogs, make freezer fuel only reduce when not adjusting angle.
nemo
parents:
8560
diff
changeset
|
185 |
if (Gear^.Hedgehog <> nil) and (Gear^.Hedgehog^.King or (Gear^.Hedgehog^.Effects[heFrozen] > 0)) then |
9148
78c699d8fdfd
move 0.01 to the end to avoid increase damage fail on small values like fire. thanks to hedgewars wiki for noting this for fire damage.
nemo
parents:
9080
diff
changeset
|
186 |
ModifyDamage:= hwRound(cDamageModifier * dmg * i * cDamagePercent * _0_5 * _0_01) |
9149 | 187 |
else |
9148
78c699d8fdfd
move 0.01 to the end to avoid increase damage fail on small values like fire. thanks to hedgewars wiki for noting this for fire damage.
nemo
parents:
9080
diff
changeset
|
188 |
ModifyDamage:= hwRound(cDamageModifier * dmg * i * cDamagePercent * _0_01) |
6581 | 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; |
|
8330 | 236 |
if ((GameFlags and gfKarma) <> 0) and |
6581 | 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; |
|
8330 | 244 |
uStats.HedgehogDamaged(Gear, AttackerHog, Damage, false); |
6581 | 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); |
|
8330 | 250 |
|
6581 | 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; |
|
8330 | 263 |
|
6581 | 264 |
procedure HHHurt(Hedgehog: PHedgehog; Source: TDamageSource); |
265 |
begin |
|
9071 | 266 |
if Hedgehog^.Effects[heFrozen] <> 0 then exit; |
6581 | 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); |
|
8330 | 288 |
var |
6581 | 289 |
dmg: Longword; |
8003 | 290 |
i: LongWord; |
6581 | 291 |
particle: PVisualGear; |
292 |
begin |
|
9071 | 293 |
if _0_4 < Gear^.dY then |
294 |
begin |
|
295 |
dmg := ModifyDamage(1 + hwRound((Gear^.dY - _0_4) * 70), Gear); |
|
296 |
if Gear^.Hedgehog^.Effects[heFrozen] = 0 then |
|
297 |
PlaySound(sndBump) |
|
298 |
else PlaySound(sndFrozenHogImpact); |
|
299 |
if dmg < 1 then |
|
300 |
exit; |
|
6581 | 301 |
|
9071 | 302 |
for i:= min(12, (3 + dmg div 10)) downto 0 do |
303 |
begin |
|
304 |
particle := AddVisualGear(hwRound(Gear^.X) - 5 + Random(10), hwRound(Gear^.Y) + 12, vgtDust); |
|
305 |
if particle <> nil then |
|
306 |
particle^.dX := particle^.dX + (Gear^.dX.QWordValue / 21474836480); |
|
307 |
end; |
|
6581 | 308 |
|
9071 | 309 |
if (Gear^.Invulnerable) then |
310 |
exit; |
|
6581 | 311 |
|
9071 | 312 |
//if _0_6 < Gear^.dY then |
313 |
// PlaySound(sndOw4, Gear^.Hedgehog^.Team^.voicepack) |
|
314 |
//else |
|
315 |
// PlaySound(sndOw1, Gear^.Hedgehog^.Team^.voicepack); |
|
6581 | 316 |
|
9071 | 317 |
if Gear^.LastDamage <> nil then |
318 |
ApplyDamage(Gear, Gear^.LastDamage, dmg, dsFall) |
|
319 |
else |
|
320 |
ApplyDamage(Gear, CurrentHedgehog, dmg, dsFall); |
|
6581 | 321 |
end |
322 |
end; |
|
323 |
||
324 |
||
325 |
procedure CalcRotationDirAngle(Gear: PGear); |
|
8330 | 326 |
var |
6581 | 327 |
dAngle: real; |
328 |
begin |
|
7825 | 329 |
// Frac/Round to be kind to JS as of 2012-08-27 where there is yet no int64/uint64 |
330 |
//dAngle := (Gear^.dX.QWordValue + Gear^.dY.QWordValue) / $80000000; |
|
331 |
dAngle := (Gear^.dX.Round + Gear^.dY.Round) / 2 + (Gear^.dX.Frac/$100000000+Gear^.dY.Frac/$100000000); |
|
6581 | 332 |
if not Gear^.dX.isNegative then |
333 |
Gear^.DirAngle := Gear^.DirAngle + dAngle |
|
334 |
else |
|
335 |
Gear^.DirAngle := Gear^.DirAngle - dAngle; |
|
336 |
||
337 |
if Gear^.DirAngle < 0 then |
|
338 |
Gear^.DirAngle := Gear^.DirAngle + 360 |
|
339 |
else if 360 < Gear^.DirAngle then |
|
340 |
Gear^.DirAngle := Gear^.DirAngle - 360 |
|
341 |
end; |
|
342 |
||
8947
e906ebd59612
CheckGearDrowning could delete hedgehogs gear! (CheckGearDrowning -> ResurrectHedgehog -> FindPlace). Fixes bug 620.
unc0rr
parents:
8763
diff
changeset
|
343 |
function CheckGearDrowning(var Gear: PGear): boolean; |
6581 | 344 |
var |
345 |
skipSpeed, skipAngle, skipDecay: hwFloat; |
|
346 |
i, maxDrops, X, Y: LongInt; |
|
347 |
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
|
348 |
particle, splash: PVisualGear; |
6581 | 349 |
isSubmersible: boolean; |
350 |
begin |
|
351 |
// probably needs tweaking. might need to be in a case statement based upon gear type |
|
352 |
Y:= hwRound(Gear^.Y); |
|
353 |
if cWaterLine < Y + Gear^.Radius then |
|
354 |
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
|
355 |
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
|
356 |
begin |
7406
1fe2c821f9bf
Try avoiding spamming the log by retaining the gears. untested.
nemo
parents:
7389
diff
changeset
|
357 |
if Gear^.Kind = gtGenericFaller then |
1fe2c821f9bf
Try avoiding spamming the log by retaining the gears. untested.
nemo
parents:
7389
diff
changeset
|
358 |
begin |
1fe2c821f9bf
Try avoiding spamming the log by retaining the gears. untested.
nemo
parents:
7389
diff
changeset
|
359 |
Gear^.X:= int2hwFloat(GetRandom(rightX-leftX)+leftX); |
1fe2c821f9bf
Try avoiding spamming the log by retaining the gears. untested.
nemo
parents:
7389
diff
changeset
|
360 |
Gear^.Y:= int2hwFloat(GetRandom(LAND_HEIGHT-topY)+topY); |
1fe2c821f9bf
Try avoiding spamming the log by retaining the gears. untested.
nemo
parents:
7389
diff
changeset
|
361 |
Gear^.dX:= _90-(GetRandomf*_360); |
1fe2c821f9bf
Try avoiding spamming the log by retaining the gears. untested.
nemo
parents:
7389
diff
changeset
|
362 |
Gear^.dY:= _90-(GetRandomf*_360) |
1fe2c821f9bf
Try avoiding spamming the log by retaining the gears. untested.
nemo
parents:
7389
diff
changeset
|
363 |
end |
1fe2c821f9bf
Try avoiding spamming the log by retaining the gears. untested.
nemo
parents:
7389
diff
changeset
|
364 |
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
|
365 |
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
|
366 |
end; |
8992
5b0be812dcdb
Rename submersible state, increase getaway time for attack underwater, slow down gear dx/dy underwater to simulate water resistance
nemo
parents:
8991
diff
changeset
|
367 |
isSubmersible:= ((Gear = CurrentHedgehog^.Gear) and (CurAmmoGear <> nil) and (CurAmmoGear^.State and gstSubmersible <> 0)) or (Gear^.State and gstSubmersible <> 0); |
6581 | 368 |
skipSpeed := _0_25; |
369 |
skipAngle := _1_9; |
|
370 |
skipDecay := _0_87; |
|
371 |
X:= hwRound(Gear^.X); |
|
372 |
vdX:= hwFloat2Float(Gear^.dX); |
|
373 |
vdY:= hwFloat2Float(Gear^.dY); |
|
374 |
// this could perhaps be a tiny bit higher. |
|
8990 | 375 |
if (cWaterLine + 64 + Gear^.Radius > Y) and (hwSqr(Gear^.dX) + hwSqr(Gear^.dY) > skipSpeed) |
6581 | 376 |
and (hwAbs(Gear^.dX) > skipAngle * hwAbs(Gear^.dY)) then |
377 |
begin |
|
378 |
Gear^.dY.isNegative := true; |
|
379 |
Gear^.dY := Gear^.dY * skipDecay; |
|
380 |
Gear^.dX := Gear^.dX * skipDecay; |
|
381 |
CheckGearDrowning := false; |
|
382 |
PlaySound(sndSkip) |
|
383 |
end |
|
384 |
else |
|
385 |
begin |
|
386 |
if not isSubmersible then |
|
387 |
begin |
|
388 |
CheckGearDrowning := true; |
|
389 |
Gear^.State := gstDrowning; |
|
390 |
Gear^.RenderTimer := false; |
|
391 |
if (Gear^.Kind <> gtSniperRifleShot) and (Gear^.Kind <> gtShotgunShot) |
|
392 |
and (Gear^.Kind <> gtDEagleShot) and (Gear^.Kind <> gtSineGunShot) then |
|
393 |
if Gear^.Kind = gtHedgehog then |
|
394 |
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
|
395 |
if Gear^.Hedgehog^.Effects[heResurrectable] <> 0 then |
8947
e906ebd59612
CheckGearDrowning could delete hedgehogs gear! (CheckGearDrowning -> ResurrectHedgehog -> FindPlace). Fixes bug 620.
unc0rr
parents:
8763
diff
changeset
|
396 |
begin |
e906ebd59612
CheckGearDrowning could delete hedgehogs gear! (CheckGearDrowning -> ResurrectHedgehog -> FindPlace). Fixes bug 620.
unc0rr
parents:
8763
diff
changeset
|
397 |
// Gear could become nil after this, just exit to skip splashes |
e906ebd59612
CheckGearDrowning could delete hedgehogs gear! (CheckGearDrowning -> ResurrectHedgehog -> FindPlace). Fixes bug 620.
unc0rr
parents:
8763
diff
changeset
|
398 |
ResurrectHedgehog(Gear); |
e906ebd59612
CheckGearDrowning could delete hedgehogs gear! (CheckGearDrowning -> ResurrectHedgehog -> FindPlace). Fixes bug 620.
unc0rr
parents:
8763
diff
changeset
|
399 |
exit |
e906ebd59612
CheckGearDrowning could delete hedgehogs gear! (CheckGearDrowning -> ResurrectHedgehog -> FindPlace). Fixes bug 620.
unc0rr
parents:
8763
diff
changeset
|
400 |
end |
6581 | 401 |
else |
402 |
begin |
|
403 |
Gear^.doStep := @doStepDrowningGear; |
|
404 |
Gear^.State := Gear^.State and (not gstHHDriven); |
|
405 |
AddCaption(Format(GetEventString(eidDrowned), Gear^.Hedgehog^.Name), cWhiteColor, capgrpMessage); |
|
406 |
end |
|
407 |
end |
|
408 |
else |
|
409 |
Gear^.doStep := @doStepDrowningGear; |
|
410 |
if Gear^.Kind = gtFlake then |
|
411 |
exit // skip splashes |
|
8990 | 412 |
end |
8991
82e3a6e5d51b
Actually, let's use *4 since could be fired from lower down
nemo
parents:
8990
diff
changeset
|
413 |
else if (Y > cWaterLine + cVisibleWater*4) and |
8992
5b0be812dcdb
Rename submersible state, increase getaway time for attack underwater, slow down gear dx/dy underwater to simulate water resistance
nemo
parents:
8991
diff
changeset
|
414 |
((Gear <> CurrentHedgehog^.Gear) or (CurAmmoGear = nil) or (CurAmmoGear^.State and gstSubmersible = 0)) then |
8990 | 415 |
Gear^.doStep:= @doStepDrowningGear; |
6581 | 416 |
if ((not isSubmersible) and (Y < cWaterLine + 64 + Gear^.Radius)) |
8989 | 417 |
or (isSubmersible and (Y < cWaterLine + 2 + Gear^.Radius) and (Gear = CurAmmoGear) and ((CurAmmoGear^.Pos = 0) |
6581 | 418 |
and (CurAmmoGear^.dY < _0_01))) then |
6804 | 419 |
if Gear^.Density * Gear^.dY > _1 then |
420 |
PlaySound(sndSplash) |
|
8330 | 421 |
else if Gear^.Density * Gear^.dY > _0_5 then |
6804 | 422 |
PlaySound(sndSkip) |
423 |
else |
|
424 |
PlaySound(sndDroplet2); |
|
6581 | 425 |
end; |
426 |
||
427 |
if ((cReducedQuality and rqPlainSplash) = 0) |
|
428 |
and (((not isSubmersible) and (Y < cWaterLine + 64 + Gear^.Radius)) |
|
8989 | 429 |
or (isSubmersible and (Y < cWaterLine + 2 + Gear^.Radius) and (Gear = CurAmmoGear) and ((CurAmmoGear^.Pos = 0) |
6581 | 430 |
and (CurAmmoGear^.dY < _0_01)))) then |
431 |
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
|
432 |
splash:= AddVisualGear(X, cWaterLine, vgtSplash); |
8330 | 433 |
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
|
434 |
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
|
435 |
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
|
436 |
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
|
437 |
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
|
438 |
else Scale:= Scale + ((1-Scale) / 2); |
7420 | 439 |
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
|
440 |
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
|
441 |
// 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
|
442 |
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
|
443 |
end; |
6581 | 444 |
|
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 |
maxDrops := (hwRound(Gear^.Density) * 3) div 2 + round(vdX * hwRound(Gear^.Density) * 6) + round(vdY * hwRound(Gear^.Density) * 6); |
6581 | 446 |
for i:= max(maxDrops div 3, min(32, Random(maxDrops))) downto 0 do |
447 |
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
|
448 |
particle := AddVisualGear(X - 3 + Random(7), cWaterLine, vgtDroplet); |
6581 | 449 |
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
|
450 |
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
|
451 |
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
|
452 |
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
|
453 |
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
|
454 |
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
|
455 |
begin |
8330 | 456 |
if splash^.Scale > 1 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
|
457 |
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
|
458 |
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
|
459 |
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
|
460 |
end |
8330 | 461 |
else |
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
|
462 |
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
|
463 |
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
|
464 |
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
|
465 |
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
|
466 |
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
|
467 |
end |
6581 | 468 |
end |
469 |
end; |
|
8989 | 470 |
if isSubmersible and (Gear = CurAmmoGear) and (CurAmmoGear^.Pos = 0) then |
6581 | 471 |
CurAmmoGear^.Pos := 1000 |
472 |
end |
|
473 |
else |
|
474 |
CheckGearDrowning := false; |
|
475 |
end; |
|
476 |
||
477 |
||
8947
e906ebd59612
CheckGearDrowning could delete hedgehogs gear! (CheckGearDrowning -> ResurrectHedgehog -> FindPlace). Fixes bug 620.
unc0rr
parents:
8763
diff
changeset
|
478 |
procedure ResurrectHedgehog(var gear: PGear); |
6581 | 479 |
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
|
480 |
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
|
481 |
gX, gY: LongInt; |
6581 | 482 |
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
|
483 |
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
|
484 |
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
|
485 |
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
|
486 |
uStats.HedgehogDamaged(Gear, CurrentHedgehog, 0, true); |
6581 | 487 |
AttackBar:= 0; |
488 |
gear^.dX := _0; |
|
489 |
gear^.dY := _0; |
|
490 |
gear^.Damage := 0; |
|
491 |
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
|
492 |
gear^.Hedgehog^.Effects[hePoisoned] := 0; |
7176
fb4b0c6dfdbd
Make watching AI v AI on ai survival a bit more entertaining
nemo
parents:
7168
diff
changeset
|
493 |
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
|
494 |
and (Gear^.Hedgehog^.Team^.Clan <> CurrentHedgehog^.Team^.Clan)) then |
8330 | 495 |
with CurrentHedgehog^ do |
6581 | 496 |
begin |
497 |
inc(Team^.stats.AIKills); |
|
498 |
FreeTexture(Team^.AIKillsTex); |
|
499 |
Team^.AIKillsTex := RenderStringTex(inttostr(Team^.stats.AIKills), Team^.Clan^.Color, fnt16); |
|
500 |
end; |
|
501 |
tempTeam := gear^.Hedgehog^.Team; |
|
502 |
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
|
503 |
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
|
504 |
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
|
505 |
// 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
|
506 |
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
|
507 |
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
|
508 |
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
|
509 |
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
|
510 |
//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
|
511 |
end; |
8330 | 512 |
FindPlace(gear, false, 0, LAND_WIDTH, true); |
6581 | 513 |
if gear <> nil then |
514 |
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
|
515 |
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
|
516 |
PlaySound(sndWarp); |
6581 | 517 |
RenderHealth(gear^.Hedgehog^); |
518 |
ScriptCall('onGearResurrect', gear^.uid); |
|
519 |
gear^.State := gstWait; |
|
8947
e906ebd59612
CheckGearDrowning could delete hedgehogs gear! (CheckGearDrowning -> ResurrectHedgehog -> FindPlace). Fixes bug 620.
unc0rr
parents:
8763
diff
changeset
|
520 |
end; |
6581 | 521 |
RecountTeamHealth(tempTeam); |
522 |
end; |
|
523 |
||
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
|
524 |
function CountNonZeroz(x, y, r, c: LongInt; mask: LongWord): LongInt; |
6581 | 525 |
var i: LongInt; |
526 |
count: LongInt = 0; |
|
527 |
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
|
528 |
if (y and LAND_HEIGHT_MASK) = 0 then |
7509 | 529 |
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
|
530 |
if Land[y, i] and mask <> 0 then |
6581 | 531 |
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
|
532 |
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
|
533 |
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
|
534 |
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
|
535 |
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
|
536 |
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
|
537 |
end; |
6581 | 538 |
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
|
539 |
CountNonZeroz:= count; |
6581 | 540 |
end; |
541 |
||
6888 | 542 |
|
543 |
function NoGearsToAvoid(mX, mY: LongInt; rX, rY: LongInt): boolean; |
|
544 |
var t: PGear; |
|
545 |
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
|
546 |
NoGearsToAvoid:= false; |
6888 | 547 |
t:= GearsList; |
548 |
rX:= sqr(rX); |
|
549 |
rY:= sqr(rY); |
|
550 |
while t <> nil do |
|
551 |
begin |
|
552 |
if t^.Kind <= gtExplosives then |
|
553 |
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
|
554 |
exit; |
6888 | 555 |
t:= t^.NextGear |
556 |
end; |
|
557 |
NoGearsToAvoid:= true |
|
558 |
end; |
|
559 |
||
6986
409dd3851309
add support for default pascal mode by removing default arguments value (maybe this also helps the parser)
koda
parents:
6888
diff
changeset
|
560 |
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
|
561 |
begin |
409dd3851309
add support for default pascal mode by removing default arguments value (maybe this also helps the parser)
koda
parents:
6888
diff
changeset
|
562 |
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
|
563 |
end; |
6888 | 564 |
|
6581 | 565 |
procedure FindPlace(var Gear: PGear; withFall: boolean; Left, Right: LongInt; skipProximity: boolean); |
566 |
var x: LongInt; |
|
567 |
y, sy: LongInt; |
|
8007 | 568 |
ar: array[0..1023] of TPoint; |
569 |
ar2: array[0..2047] of TPoint; |
|
8026
4a4f21070479
merge xymeng's gsoc engine with a few updates (and further checks on symbol definitions)
koda
parents:
8007
diff
changeset
|
570 |
temp: TPoint; |
6581 | 571 |
cnt, cnt2: Longword; |
572 |
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
|
573 |
ignoreNearObjects, ignoreOverlap, tryAgain: boolean; |
6581 | 574 |
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
|
575 |
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
|
576 |
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 | 577 |
tryAgain:= true; |
578 |
while tryAgain do |
|
579 |
begin |
|
8007 | 580 |
delta:= LAND_WIDTH div 16; |
6581 | 581 |
cnt2:= 0; |
582 |
repeat |
|
8007 | 583 |
x:= Left + max(LAND_WIDTH div 2048, LongInt(GetRandom(Delta))); |
6581 | 584 |
repeat |
585 |
inc(x, Delta); |
|
586 |
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
|
587 |
y:= min(1024, topY) - 2 * Gear^.Radius; |
6581 | 588 |
while y < cWaterLine do |
589 |
begin |
|
590 |
repeat |
|
591 |
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
|
592 |
until (y >= cWaterLine) or |
8833 | 593 |
((not ignoreOverlap) and (CountNonZeroz(x, y, Gear^.Radius - 1, 1, $FFFF) = 0)) or |
8751
4609823efc94
More flagging of Land values. Also use less than for tests of non-terrain, instead of "and $FF00 = 0". Saves a couple of ops, which actually matters a small amount in a few places.
nemo
parents:
8632
diff
changeset
|
594 |
(ignoreOverlap and (CountNonZeroz(x, y, Gear^.Radius - 1, 1, lfLandMask) = 0)); |
6581 | 595 |
|
596 |
sy:= y; |
|
597 |
||
598 |
repeat |
|
599 |
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
|
600 |
until (y >= cWaterLine) or |
8833 | 601 |
((not ignoreOverlap) and (CountNonZeroz(x, y, Gear^.Radius - 1, 1, $FFFF) <> 0)) or |
8751
4609823efc94
More flagging of Land values. Also use less than for tests of non-terrain, instead of "and $FF00 = 0". Saves a couple of ops, which actually matters a small amount in a few places.
nemo
parents:
8632
diff
changeset
|
602 |
(ignoreOverlap and (CountNonZeroz(x, y, Gear^.Radius - 1, 1, lfLandMask) <> 0)); |
6581 | 603 |
|
604 |
if (y - sy > Gear^.Radius * 2) |
|
605 |
and (((Gear^.Kind = gtExplosives) |
|
606 |
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
|
607 |
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
|
608 |
and (CountNonZeroz(x, y+1, Gear^.Radius - 1, Gear^.Radius+1, $FFFF) > Gear^.Radius)) |
6581 | 609 |
or |
610 |
((Gear^.Kind <> gtExplosives) |
|
611 |
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
|
612 |
and (ignoreNearObjects or NoGearsToAvoid(x, y - Gear^.Radius, 110, 110)) |
6888 | 613 |
)) then |
614 |
begin |
|
6581 | 615 |
ar[cnt].X:= x; |
616 |
if withFall then |
|
617 |
ar[cnt].Y:= sy + Gear^.Radius |
|
618 |
else |
|
619 |
ar[cnt].Y:= y - Gear^.Radius; |
|
620 |
inc(cnt) |
|
621 |
end; |
|
622 |
||
7603
e9c3c67b5dfd
reducing this value is sufficient to ensure crates drop just below top border or a girder
nemo
parents:
7599
diff
changeset
|
623 |
inc(y, 10) |
6581 | 624 |
end; |
625 |
||
626 |
if cnt > 0 then |
|
8330 | 627 |
begin |
628 |
temp := ar[GetRandom(cnt)]; |
|
8026
4a4f21070479
merge xymeng's gsoc engine with a few updates (and further checks on symbol definitions)
koda
parents:
8007
diff
changeset
|
629 |
with temp do |
6581 | 630 |
begin |
631 |
ar2[cnt2].x:= x; |
|
632 |
ar2[cnt2].y:= y; |
|
633 |
inc(cnt2) |
|
8330 | 634 |
end |
635 |
end |
|
6581 | 636 |
until (x + Delta > Right); |
637 |
||
638 |
dec(Delta, 60) |
|
639 |
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
|
640 |
// 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
|
641 |
if (cnt2 = 0) and skipProximity and (not ignoreOverlap) then |
6581 | 642 |
tryAgain:= true |
643 |
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
|
644 |
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
|
645 |
ignoreNearObjects:= true; |
6581 | 646 |
end; |
647 |
||
648 |
if cnt2 > 0 then |
|
8026
4a4f21070479
merge xymeng's gsoc engine with a few updates (and further checks on symbol definitions)
koda
parents:
8007
diff
changeset
|
649 |
begin |
4a4f21070479
merge xymeng's gsoc engine with a few updates (and further checks on symbol definitions)
koda
parents:
8007
diff
changeset
|
650 |
temp := ar2[GetRandom(cnt2)]; |
4a4f21070479
merge xymeng's gsoc engine with a few updates (and further checks on symbol definitions)
koda
parents:
8007
diff
changeset
|
651 |
with temp do |
6581 | 652 |
begin |
653 |
Gear^.X:= int2hwFloat(x); |
|
654 |
Gear^.Y:= int2hwFloat(y); |
|
655 |
AddFileLog('Assigned Gear coordinates (' + inttostr(x) + ',' + inttostr(y) + ')'); |
|
656 |
end |
|
8026
4a4f21070479
merge xymeng's gsoc engine with a few updates (and further checks on symbol definitions)
koda
parents:
8007
diff
changeset
|
657 |
end |
6581 | 658 |
else |
659 |
begin |
|
660 |
OutError('Can''t find place for Gear', false); |
|
661 |
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
|
662 |
Gear^.Hedgehog^.Effects[heResurrectable] := 0; |
6581 | 663 |
DeleteGear(Gear); |
664 |
Gear:= nil |
|
665 |
end |
|
666 |
end; |
|
667 |
||
668 |
function CheckGearNear(Gear: PGear; Kind: TGearType; rX, rY: LongInt): PGear; |
|
669 |
var t: PGear; |
|
670 |
begin |
|
671 |
t:= GearsList; |
|
672 |
rX:= sqr(rX); |
|
673 |
rY:= sqr(rY); |
|
674 |
||
675 |
while t <> nil do |
|
676 |
begin |
|
677 |
if (t <> Gear) and (t^.Kind = Kind) then |
|
678 |
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
|
679 |
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
|
680 |
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
|
681 |
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
|
682 |
end; |
6581 | 683 |
t:= t^.NextGear |
684 |
end; |
|
685 |
||
686 |
CheckGearNear:= nil |
|
687 |
end; |
|
688 |
||
7592 | 689 |
procedure CheckCollision(Gear: PGear); inline; |
690 |
begin |
|
691 |
if TestCollisionXwithGear(Gear, hwSign(Gear^.dX)) |
|
692 |
or (TestCollisionYwithGear(Gear, hwSign(Gear^.dY)) <> 0) then |
|
693 |
Gear^.State := Gear^.State or gstCollision |
|
694 |
else |
|
695 |
Gear^.State := Gear^.State and (not gstCollision) |
|
696 |
end; |
|
697 |
||
698 |
procedure CheckCollisionWithLand(Gear: PGear); inline; |
|
699 |
begin |
|
700 |
if TestCollisionX(Gear, hwSign(Gear^.dX)) |
|
701 |
or TestCollisionY(Gear, hwSign(Gear^.dY)) then |
|
702 |
Gear^.State := Gear^.State or gstCollision |
|
8330 | 703 |
else |
7592 | 704 |
Gear^.State := Gear^.State and (not gstCollision) |
705 |
end; |
|
706 |
||
7719
eeae1cb6b6bf
Move hedgehog's step routine into separate function, use it in both hedgehog and ai code
unc0rr
parents:
7627
diff
changeset
|
707 |
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
|
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 |
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
|
710 |
begin |
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 - _1; |
eeae1cb6b6bf
Move hedgehog's step routine into separate function, use it in both hedgehog and ai code
unc0rr
parents:
7627
diff
changeset
|
712 |
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
|
713 |
begin |
eeae1cb6b6bf
Move hedgehog's step routine into separate function, use it in both hedgehog and ai code
unc0rr
parents:
7627
diff
changeset
|
714 |
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
|
715 |
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
|
716 |
begin |
eeae1cb6b6bf
Move hedgehog's step routine into separate function, use it in both hedgehog and ai code
unc0rr
parents:
7627
diff
changeset
|
717 |
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 |
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
|
719 |
begin |
eeae1cb6b6bf
Move hedgehog's step routine into separate function, use it in both hedgehog and ai code
unc0rr
parents:
7627
diff
changeset
|
720 |
Gear^.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
|
721 |
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
|
722 |
begin |
eeae1cb6b6bf
Move hedgehog's step routine into separate function, use it in both hedgehog and ai code
unc0rr
parents:
7627
diff
changeset
|
723 |
Gear^.Y:= Gear^.Y - _1; |
eeae1cb6b6bf
Move hedgehog's step routine into separate function, use it in both hedgehog and ai code
unc0rr
parents:
7627
diff
changeset
|
724 |
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
|
725 |
begin |
eeae1cb6b6bf
Move hedgehog's step routine into separate function, use it in both hedgehog and ai code
unc0rr
parents:
7627
diff
changeset
|
726 |
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
|
727 |
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
|
728 |
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
|
729 |
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
|
730 |
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
|
731 |
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
|
732 |
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
|
733 |
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
|
734 |
end; |
eeae1cb6b6bf
Move hedgehog's step routine into separate function, use it in both hedgehog and ai code
unc0rr
parents:
7627
diff
changeset
|
735 |
|
eeae1cb6b6bf
Move hedgehog's step routine into separate function, use it in both hedgehog and ai code
unc0rr
parents:
7627
diff
changeset
|
736 |
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
|
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^.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
|
739 |
MakeHedgehogsStep:= true |
eeae1cb6b6bf
Move hedgehog's step routine into separate function, use it in both hedgehog and ai code
unc0rr
parents:
7627
diff
changeset
|
740 |
end else |
eeae1cb6b6bf
Move hedgehog's step routine into separate function, use it in both hedgehog and ai code
unc0rr
parents:
7627
diff
changeset
|
741 |
MakeHedgehogsStep:= false; |
eeae1cb6b6bf
Move hedgehog's step routine into separate function, use it in both hedgehog and ai code
unc0rr
parents:
7627
diff
changeset
|
742 |
|
eeae1cb6b6bf
Move hedgehog's step routine into separate function, use it in both hedgehog and ai code
unc0rr
parents:
7627
diff
changeset
|
743 |
if TestCollisionYwithGear(Gear, 1) = 0 then |
eeae1cb6b6bf
Move hedgehog's step routine into separate function, use it in both hedgehog and ai code
unc0rr
parents:
7627
diff
changeset
|
744 |
begin |
eeae1cb6b6bf
Move hedgehog's step routine into separate function, use it in both hedgehog and ai code
unc0rr
parents:
7627
diff
changeset
|
745 |
Gear^.Y:= Gear^.Y + _1; |
eeae1cb6b6bf
Move hedgehog's step routine into separate function, use it in both hedgehog and ai code
unc0rr
parents:
7627
diff
changeset
|
746 |
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
|
747 |
begin |
eeae1cb6b6bf
Move hedgehog's step routine into separate function, use it in both hedgehog and ai code
unc0rr
parents:
7627
diff
changeset
|
748 |
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
|
749 |
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
|
750 |
begin |
eeae1cb6b6bf
Move hedgehog's step routine into separate function, use it in both hedgehog and ai code
unc0rr
parents:
7627
diff
changeset
|
751 |
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
|
752 |
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
|
753 |
begin |
eeae1cb6b6bf
Move hedgehog's step routine into separate function, use it in both hedgehog and ai code
unc0rr
parents:
7627
diff
changeset
|
754 |
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
|
755 |
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
|
756 |
begin |
eeae1cb6b6bf
Move hedgehog's step routine into separate function, use it in both hedgehog and ai code
unc0rr
parents:
7627
diff
changeset
|
757 |
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
|
758 |
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
|
759 |
begin |
eeae1cb6b6bf
Move hedgehog's step routine into separate function, use it in both hedgehog and ai code
unc0rr
parents:
7627
diff
changeset
|
760 |
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
|
761 |
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
|
762 |
begin |
eeae1cb6b6bf
Move hedgehog's step routine into separate function, use it in both hedgehog and ai code
unc0rr
parents:
7627
diff
changeset
|
763 |
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
|
764 |
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
|
765 |
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
|
766 |
exit |
eeae1cb6b6bf
Move hedgehog's step routine into separate function, use it in both hedgehog and ai code
unc0rr
parents:
7627
diff
changeset
|
767 |
end; |
eeae1cb6b6bf
Move hedgehog's step routine into separate function, use it in both hedgehog and ai code
unc0rr
parents:
7627
diff
changeset
|
768 |
end |
eeae1cb6b6bf
Move hedgehog's step routine into separate function, use it in both hedgehog and ai code
unc0rr
parents:
7627
diff
changeset
|
769 |
end |
eeae1cb6b6bf
Move hedgehog's step routine into separate function, use it in both hedgehog and ai code
unc0rr
parents:
7627
diff
changeset
|
770 |
end |
eeae1cb6b6bf
Move hedgehog's step routine into separate function, use it in both hedgehog and ai code
unc0rr
parents:
7627
diff
changeset
|
771 |
end |
eeae1cb6b6bf
Move hedgehog's step routine into separate function, use it in both hedgehog and ai code
unc0rr
parents:
7627
diff
changeset
|
772 |
end |
eeae1cb6b6bf
Move hedgehog's step routine into separate function, use it in both hedgehog and ai code
unc0rr
parents:
7627
diff
changeset
|
773 |
end; |
eeae1cb6b6bf
Move hedgehog's step routine into separate function, use it in both hedgehog and ai code
unc0rr
parents:
7627
diff
changeset
|
774 |
end; |
eeae1cb6b6bf
Move hedgehog's step routine into separate function, use it in both hedgehog and ai code
unc0rr
parents:
7627
diff
changeset
|
775 |
|
6581 | 776 |
end. |