author | sheepluva |
Sat, 22 Nov 2014 04:15:16 +0100 | |
changeset 10525 | 019b4fbb21d4 |
parent 10512 | 25021aac078e |
child 10526 | b43d175d1577 |
permissions | -rw-r--r-- |
6581 | 1 |
(* |
2 |
* Hedgewars, a free turn based strategy game |
|
9998 | 3 |
* Copyright (c) 2004-2014 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 |
|
10108
c68cf030eded
update FSF address. note: two sdl include files (by Sam Lantinga) still have the old FSF address in their copyright - but I ain't gonna touch their copyright headers
sheepluva
parents:
10105
diff
changeset
|
16 |
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA |
6581 | 17 |
*) |
18 |
||
19 |
{$INCLUDE "options.inc"} |
|
20 |
||
21 |
unit uGearsUtils; |
|
22 |
interface |
|
9285 | 23 |
uses uTypes, uFloat; |
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); |
10363 | 27 |
procedure AddSplashForGear(Gear: PGear; justSkipping: boolean); |
10508 | 28 |
procedure AddBounceEffectForGear(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
|
29 |
|
6581 | 30 |
function ModifyDamage(dmg: Longword; Gear: PGear): Longword; |
31 |
procedure ApplyDamage(Gear: PGear; AttackerHog: PHedgehog; Damage: Longword; Source: TDamageSource); |
|
32 |
procedure spawnHealthTagForHH(HHGear: PGear; dmg: Longword); |
|
33 |
procedure HHHurt(Hedgehog: PHedgehog; Source: TDamageSource); |
|
34 |
procedure CheckHHDamage(Gear: PGear); |
|
35 |
procedure CalcRotationDirAngle(Gear: PGear); |
|
8947
e906ebd59612
CheckGearDrowning could delete hedgehogs gear! (CheckGearDrowning -> ResurrectHedgehog -> FindPlace). Fixes bug 620.
unc0rr
parents:
8763
diff
changeset
|
36 |
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
|
37 |
|
409dd3851309
add support for default pascal mode by removing default arguments value (maybe this also helps the parser)
koda
parents:
6888
diff
changeset
|
38 |
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
|
39 |
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
|
40 |
|
6581 | 41 |
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
|
42 |
function CheckGearDrowning(var Gear: PGear): boolean; |
7592 | 43 |
procedure CheckCollision(Gear: PGear); inline; |
44 |
procedure CheckCollisionWithLand(Gear: PGear); inline; |
|
6581 | 45 |
|
9285 | 46 |
procedure AmmoShove(Ammo: PGear; Damage, Power: LongInt); |
47 |
function GearsNear(X, Y: hwFloat; Kind: TGearType; r: LongInt): PGearArrayS; |
|
48 |
procedure SpawnBoxOfSmth; |
|
49 |
procedure ShotgunShot(Gear: PGear); |
|
50 |
||
51 |
procedure SetAllToActive; |
|
52 |
procedure SetAllHHToActive(Ice: boolean); |
|
9954 | 53 |
procedure SetAllHHToActive(); inline; |
9285 | 54 |
|
55 |
function GetAmmo(Hedgehog: PHedgehog): TAmmoType; |
|
56 |
function GetUtility(Hedgehog: PHedgehog): TAmmoType; |
|
57 |
||
9473
a51a69094c24
partial implementation of non-infinite world (edge wrap/warp/bounce)
nemo
parents:
9285
diff
changeset
|
58 |
function WorldWrap(var Gear: PGear): boolean; |
a51a69094c24
partial implementation of non-infinite world (edge wrap/warp/bounce)
nemo
parents:
9285
diff
changeset
|
59 |
|
9285 | 60 |
|
61 |
||
7719
eeae1cb6b6bf
Move hedgehog's step routine into separate function, use it in both hedgehog and ai code
unc0rr
parents:
7627
diff
changeset
|
62 |
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
|
63 |
|
6581 | 64 |
var doStepHandlers: array[TGearType] of TGearStepProcedure; |
65 |
||
66 |
implementation |
|
9285 | 67 |
uses uSound, uCollisions, uUtils, uConsts, uVisualGears, uAIMisc, |
6581 | 68 |
uVariables, uLandGraphics, uScript, uStats, uCaptions, uTeams, uStore, |
10015 | 69 |
uLocale, uTextures, uRenderUtils, uRandom, SDLh, uDebug, |
9285 | 70 |
uGearsList, Math, uVisualGearsList, uGearsHandlersMess, |
71 |
uGearsHedgehog; |
|
6581 | 72 |
|
6986
409dd3851309
add support for default pascal mode by removing default arguments value (maybe this also helps the parser)
koda
parents:
6888
diff
changeset
|
73 |
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
|
74 |
begin |
409dd3851309
add support for default pascal mode by removing default arguments value (maybe this also helps the parser)
koda
parents:
6888
diff
changeset
|
75 |
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
|
76 |
end; |
409dd3851309
add support for default pascal mode by removing default arguments value (maybe this also helps the parser)
koda
parents:
6888
diff
changeset
|
77 |
|
6581 | 78 |
procedure doMakeExplosion(X, Y, Radius: LongInt; AttackingHog: PHedgehog; Mask: Longword; const Tint: LongWord); |
79 |
var Gear: PGear; |
|
6769
44ad49a3a126
Add drowning to grenade too, try some little optimisations
nemo
parents:
6765
diff
changeset
|
80 |
dmg, dmgBase: LongInt; |
6765 | 81 |
fX, fY, tdX, tdY: hwFloat; |
6581 | 82 |
vg: PVisualGear; |
83 |
i, cnt: LongInt; |
|
84 |
begin |
|
85 |
if Radius > 4 then AddFileLog('Explosion: at (' + inttostr(x) + ',' + inttostr(y) + ')'); |
|
86 |
if Radius > 25 then KickFlakes(Radius, X, Y); |
|
87 |
||
88 |
if ((Mask and EXPLNoGfx) = 0) then |
|
89 |
begin |
|
90 |
vg:= nil; |
|
91 |
if Radius > 50 then vg:= AddVisualGear(X, Y, vgtBigExplosion) |
|
92 |
else if Radius > 10 then vg:= AddVisualGear(X, Y, vgtExplosion); |
|
93 |
if vg <> nil then |
|
94 |
vg^.Tint:= Tint; |
|
95 |
end; |
|
96 |
if (Mask and EXPLAutoSound) <> 0 then PlaySound(sndExplosion); |
|
97 |
||
6765 | 98 |
(*if (Mask and EXPLAllDamageInRadius) = 0 then |
6581 | 99 |
dmgRadius:= Radius shl 1 |
100 |
else |
|
101 |
dmgRadius:= Radius; |
|
6765 | 102 |
dmgBase:= dmgRadius + cHHRadius div 2;*) |
103 |
dmgBase:= Radius shl 1 + cHHRadius div 2; |
|
6581 | 104 |
fX:= int2hwFloat(X); |
105 |
fY:= int2hwFloat(Y); |
|
106 |
Gear:= GearsList; |
|
107 |
while Gear <> nil do |
|
108 |
begin |
|
109 |
dmg:= 0; |
|
110 |
//dmg:= dmgRadius + cHHRadius div 2 - hwRound(Distance(Gear^.X - int2hwFloat(X), Gear^.Y - int2hwFloat(Y))); |
|
111 |
//if (dmg > 1) and |
|
112 |
if (Gear^.State and gstNoDamage) = 0 then |
|
113 |
begin |
|
114 |
case Gear^.Kind of |
|
115 |
gtHedgehog, |
|
116 |
gtMine, |
|
117 |
gtBall, |
|
118 |
gtMelonPiece, |
|
119 |
gtGrenade, |
|
120 |
gtClusterBomb, |
|
121 |
// gtCluster, too game breaking I think |
|
122 |
gtSMine, |
|
123 |
gtCase, |
|
124 |
gtTarget, |
|
125 |
gtFlame, |
|
7754 | 126 |
gtKnife, |
8161 | 127 |
gtExplosives: begin //, |
128 |
//gtStructure: begin |
|
6581 | 129 |
// Run the calcs only once we know we have a type that will need damage |
6765 | 130 |
tdX:= Gear^.X-fX; |
131 |
tdY:= Gear^.Y-fY; |
|
7721 | 132 |
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
|
133 |
dmg:= dmgBase - hwRound(Distance(tdX, tdY)); |
6581 | 134 |
if dmg > 1 then |
135 |
begin |
|
136 |
dmg:= ModifyDamage(min(dmg div 2, Radius), Gear); |
|
137 |
//AddFileLog('Damage: ' + inttostr(dmg)); |
|
138 |
if (Mask and EXPLNoDamage) = 0 then |
|
139 |
begin |
|
10011
ead5e4b21671
Add check for gear kind of hedgehog on invulnerability effect. This probably fixes bug #766, is similar to change in previous r2a1483d91977 and was introduced by r7d925e82e572
nemo
parents:
10010
diff
changeset
|
140 |
if (Gear^.Kind <> gtHedgehog) or (Gear^.Hedgehog^.Effects[heInvulnerable] = 0) then |
6581 | 141 |
ApplyDamage(Gear, AttackingHog, dmg, dsExplosion) |
142 |
else |
|
143 |
Gear^.State:= Gear^.State or gstWinner; |
|
144 |
end; |
|
145 |
if ((Mask and EXPLDoNotTouchAny) = 0) and (((Mask and EXPLDoNotTouchHH) = 0) or (Gear^.Kind <> gtHedgehog)) then |
|
146 |
begin |
|
147 |
DeleteCI(Gear); |
|
6765 | 148 |
Gear^.dX:= Gear^.dX + SignAs(_0_005 * dmg + cHHKick, tdX)/(Gear^.Density/_3); |
149 |
Gear^.dY:= Gear^.dY + SignAs(_0_005 * dmg + cHHKick, tdY)/(Gear^.Density/_3); |
|
6581 | 150 |
|
151 |
Gear^.State:= (Gear^.State or gstMoving) and (not gstLoser); |
|
7767 | 152 |
if Gear^.Kind = gtKnife then Gear^.State:= Gear^.State and (not gstCollision); |
10011
ead5e4b21671
Add check for gear kind of hedgehog on invulnerability effect. This probably fixes bug #766, is similar to change in previous r2a1483d91977 and was introduced by r7d925e82e572
nemo
parents:
10010
diff
changeset
|
153 |
if (Gear^.Kind = gtHedgehog) and (Gear^.Hedgehog^.Effects[heInvulnerable] = 0) then |
6581 | 154 |
Gear^.State:= (Gear^.State or gstMoving) and (not gstWinner); |
155 |
Gear^.Active:= true; |
|
156 |
if Gear^.Kind <> gtFlame then FollowGear:= Gear |
|
157 |
end; |
|
9685
7d925e82e572
Tweak trophyrace to work better w/ skip (probably, needs testing), drop Invulnerable in favour of effects - heInvulnerable is already in effects,
nemo
parents:
9561
diff
changeset
|
158 |
if ((Mask and EXPLPoisoned) <> 0) and (Gear^.Kind = gtHedgehog) and (Gear^.Hedgehog^.Effects[heInvulnerable] = 0) and (Gear^.State and gstHHDeath = 0) then |
10012
82dd9f0c88f7
Make poison damage possibly variable (might as well since effects is a count). Scripts might find it handy.
nemo
parents:
10011
diff
changeset
|
159 |
Gear^.Hedgehog^.Effects[hePoisoned] := 5; |
6581 | 160 |
end; |
161 |
||
162 |
end; |
|
9814 | 163 |
gtGrave: if Mask and EXPLDoNotTouchAny = 0 then |
6581 | 164 |
// Run the calcs only once we know we have a type that will need damage |
165 |
begin |
|
9814 | 166 |
tdX:= Gear^.X-fX; |
167 |
tdY:= Gear^.Y-fY; |
|
168 |
if LongInt(tdX.Round + tdY.Round + 2) < dmgBase then |
|
169 |
dmg:= dmgBase - hwRound(Distance(tdX, tdY)); |
|
170 |
if dmg > 1 then |
|
171 |
begin |
|
172 |
dmg:= ModifyDamage(min(dmg div 2, Radius), Gear); |
|
173 |
Gear^.dY:= - _0_004 * dmg; |
|
174 |
Gear^.Active:= true |
|
175 |
end |
|
176 |
end; |
|
6581 | 177 |
end; |
178 |
end; |
|
179 |
Gear:= Gear^.NextGear |
|
180 |
end; |
|
181 |
||
182 |
if (Mask and EXPLDontDraw) = 0 then |
|
183 |
if (GameFlags and gfSolidLand) = 0 then |
|
184 |
begin |
|
185 |
cnt:= DrawExplosion(X, Y, Radius) div 1608; // approx 2 16x16 circles to erase per chunk |
|
186 |
if (cnt > 0) and (SpritesData[sprChunk].Texture <> nil) then |
|
187 |
for i:= 0 to cnt do |
|
188 |
AddVisualGear(X, Y, vgtChunk) |
|
189 |
end; |
|
190 |
||
191 |
uAIMisc.AwareOfExplosion(0, 0, 0) |
|
192 |
end; |
|
193 |
||
194 |
function ModifyDamage(dmg: Longword; Gear: PGear): Longword; |
|
195 |
var i: hwFloat; |
|
196 |
begin |
|
197 |
(* Invulnerability cannot be placed in here due to still needing kicks |
|
198 |
Not without a new damage machine. |
|
199 |
King check should be in here instead of ApplyDamage since Tiy wants them kicked less |
|
200 |
*) |
|
201 |
i:= _1; |
|
202 |
if (CurrentHedgehog <> nil) and CurrentHedgehog^.King then |
|
203 |
i:= _1_5; |
|
10015 | 204 |
if (Gear^.Kind = gtHedgehog) and (Gear^.Hedgehog <> nil) and |
10010
2a1483d91977
well. let's fix this at least - only apply to gears that are actually hedgehogs, not just ones associated with a hedgehog (which can be pretty much any gear since damage tracking was added)
nemo
parents:
9998
diff
changeset
|
205 |
(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
|
206 |
ModifyDamage:= hwRound(cDamageModifier * dmg * i * cDamagePercent * _0_5 * _0_01) |
9149 | 207 |
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
|
208 |
ModifyDamage:= hwRound(cDamageModifier * dmg * i * cDamagePercent * _0_01) |
6581 | 209 |
end; |
210 |
||
211 |
procedure ApplyDamage(Gear: PGear; AttackerHog: PHedgehog; Damage: Longword; Source: TDamageSource); |
|
212 |
var s: shortstring; |
|
213 |
vampDmg, tmpDmg, i: Longword; |
|
214 |
vg: PVisualGear; |
|
215 |
begin |
|
216 |
if Damage = 0 then |
|
217 |
exit; // nothing to apply |
|
218 |
||
219 |
if (Gear^.Kind = gtHedgehog) then |
|
220 |
begin |
|
221 |
Gear^.LastDamage := AttackerHog; |
|
222 |
||
223 |
Gear^.Hedgehog^.Team^.Clan^.Flawless:= false; |
|
224 |
HHHurt(Gear^.Hedgehog, Source); |
|
225 |
AddDamageTag(hwRound(Gear^.X), hwRound(Gear^.Y), Damage, Gear^.Hedgehog^.Team^.Clan^.Color); |
|
226 |
tmpDmg:= min(Damage, max(0,Gear^.Health-Gear^.Damage)); |
|
227 |
if (Gear <> CurrentHedgehog^.Gear) and (CurrentHedgehog^.Gear <> nil) and (tmpDmg >= 1) then |
|
228 |
begin |
|
229 |
if cVampiric then |
|
230 |
begin |
|
231 |
vampDmg:= hwRound(int2hwFloat(tmpDmg)*_0_8); |
|
232 |
if vampDmg >= 1 then |
|
233 |
begin |
|
234 |
// was considering pulsing on attack, Tiy thinks it should be permanent while in play |
|
235 |
//CurrentHedgehog^.Gear^.State:= CurrentHedgehog^.Gear^.State or gstVampiric; |
|
236 |
inc(CurrentHedgehog^.Gear^.Health,vampDmg); |
|
237 |
str(vampDmg, s); |
|
238 |
s:= '+' + s; |
|
10124
aabd1b75d5a3
Even more explicit type conversions and other stuff to help pas2c use ansistrings
unc0rr
parents:
10116
diff
changeset
|
239 |
AddCaption(ansistring(s), CurrentHedgehog^.Team^.Clan^.Color, capgrpAmmoinfo); |
6581 | 240 |
RenderHealth(CurrentHedgehog^); |
241 |
RecountTeamHealth(CurrentHedgehog^.Team); |
|
242 |
i:= 0; |
|
243 |
while i < vampDmg do |
|
244 |
begin |
|
245 |
vg:= AddVisualGear(hwRound(CurrentHedgehog^.Gear^.X), hwRound(CurrentHedgehog^.Gear^.Y), vgtStraightShot); |
|
246 |
if vg <> nil then |
|
247 |
with vg^ do |
|
248 |
begin |
|
249 |
Tint:= $FF0000FF; |
|
250 |
State:= ord(sprHealth) |
|
251 |
end; |
|
252 |
inc(i, 5); |
|
253 |
end; |
|
254 |
end |
|
255 |
end; |
|
10015 | 256 |
if (GameFlags and gfKarma <> 0) and (GameFlags and gfInvulnerable = 0) and |
9685
7d925e82e572
Tweak trophyrace to work better w/ skip (probably, needs testing), drop Invulnerable in favour of effects - heInvulnerable is already in effects,
nemo
parents:
9561
diff
changeset
|
257 |
(CurrentHedgehog^.Effects[heInvulnerable] = 0) then |
6581 | 258 |
begin // this cannot just use Damage or it interrupts shotgun and gets you called stupid |
259 |
inc(CurrentHedgehog^.Gear^.Karma, tmpDmg); |
|
260 |
CurrentHedgehog^.Gear^.LastDamage := CurrentHedgehog; |
|
261 |
spawnHealthTagForHH(CurrentHedgehog^.Gear, tmpDmg); |
|
262 |
end; |
|
8330 | 263 |
uStats.HedgehogDamaged(Gear, AttackerHog, Damage, false); |
6581 | 264 |
end; |
8199
886ed135665b
Fix crashes and wtf behaviour introduced in r0b8beacff8a5
unc0rr
parents:
8161
diff
changeset
|
265 |
end else |
8161 | 266 |
//else if Gear^.Kind <> gtStructure then // not gtHedgehog nor gtStructure |
6581 | 267 |
Gear^.Hedgehog:= AttackerHog; |
268 |
inc(Gear^.Damage, Damage); |
|
8330 | 269 |
|
6581 | 270 |
ScriptCall('onGearDamage', Gear^.UID, Damage); |
271 |
end; |
|
272 |
||
273 |
procedure spawnHealthTagForHH(HHGear: PGear; dmg: Longword); |
|
274 |
var tag: PVisualGear; |
|
275 |
begin |
|
276 |
tag:= AddVisualGear(hwRound(HHGear^.X), hwRound(HHGear^.Y), vgtHealthTag, dmg); |
|
277 |
if (tag <> nil) then |
|
278 |
tag^.Hedgehog:= HHGear^.Hedgehog; // the tag needs the tag to determine the text color |
|
279 |
AllInactive:= false; |
|
280 |
HHGear^.Active:= true; |
|
281 |
end; |
|
8330 | 282 |
|
6581 | 283 |
procedure HHHurt(Hedgehog: PHedgehog; Source: TDamageSource); |
284 |
begin |
|
9071 | 285 |
if Hedgehog^.Effects[heFrozen] <> 0 then exit; |
6581 | 286 |
if (Source = dsFall) or (Source = dsExplosion) then |
287 |
case random(3) of |
|
7053 | 288 |
0: PlaySoundV(sndOoff1, Hedgehog^.Team^.voicepack); |
289 |
1: PlaySoundV(sndOoff2, Hedgehog^.Team^.voicepack); |
|
290 |
2: PlaySoundV(sndOoff3, Hedgehog^.Team^.voicepack); |
|
6581 | 291 |
end |
292 |
else if (Source = dsPoison) then |
|
293 |
case random(2) of |
|
7053 | 294 |
0: PlaySoundV(sndPoisonCough, Hedgehog^.Team^.voicepack); |
295 |
1: PlaySoundV(sndPoisonMoan, Hedgehog^.Team^.voicepack); |
|
6581 | 296 |
end |
297 |
else |
|
298 |
case random(4) of |
|
7053 | 299 |
0: PlaySoundV(sndOw1, Hedgehog^.Team^.voicepack); |
300 |
1: PlaySoundV(sndOw2, Hedgehog^.Team^.voicepack); |
|
301 |
2: PlaySoundV(sndOw3, Hedgehog^.Team^.voicepack); |
|
302 |
3: PlaySoundV(sndOw4, Hedgehog^.Team^.voicepack); |
|
6581 | 303 |
end |
304 |
end; |
|
305 |
||
306 |
procedure CheckHHDamage(Gear: PGear); |
|
10015 | 307 |
var |
9809 | 308 |
dmg: LongInt; |
8003 | 309 |
i: LongWord; |
6581 | 310 |
particle: PVisualGear; |
311 |
begin |
|
9071 | 312 |
if _0_4 < Gear^.dY then |
313 |
begin |
|
314 |
dmg := ModifyDamage(1 + hwRound((Gear^.dY - _0_4) * 70), Gear); |
|
315 |
if Gear^.Hedgehog^.Effects[heFrozen] = 0 then |
|
316 |
PlaySound(sndBump) |
|
317 |
else PlaySound(sndFrozenHogImpact); |
|
318 |
if dmg < 1 then |
|
319 |
exit; |
|
6581 | 320 |
|
9809 | 321 |
for i:= min(12, 3 + dmg div 10) downto 0 do |
9071 | 322 |
begin |
323 |
particle := AddVisualGear(hwRound(Gear^.X) - 5 + Random(10), hwRound(Gear^.Y) + 12, vgtDust); |
|
324 |
if particle <> nil then |
|
325 |
particle^.dX := particle^.dX + (Gear^.dX.QWordValue / 21474836480); |
|
326 |
end; |
|
6581 | 327 |
|
9685
7d925e82e572
Tweak trophyrace to work better w/ skip (probably, needs testing), drop Invulnerable in favour of effects - heInvulnerable is already in effects,
nemo
parents:
9561
diff
changeset
|
328 |
if ((Gear^.Hedgehog^.Effects[heInvulnerable] <> 0)) then |
9071 | 329 |
exit; |
6581 | 330 |
|
9071 | 331 |
//if _0_6 < Gear^.dY then |
332 |
// PlaySound(sndOw4, Gear^.Hedgehog^.Team^.voicepack) |
|
333 |
//else |
|
334 |
// PlaySound(sndOw1, Gear^.Hedgehog^.Team^.voicepack); |
|
6581 | 335 |
|
9071 | 336 |
if Gear^.LastDamage <> nil then |
337 |
ApplyDamage(Gear, Gear^.LastDamage, dmg, dsFall) |
|
338 |
else |
|
339 |
ApplyDamage(Gear, CurrentHedgehog, dmg, dsFall); |
|
6581 | 340 |
end |
341 |
end; |
|
342 |
||
343 |
||
344 |
procedure CalcRotationDirAngle(Gear: PGear); |
|
8330 | 345 |
var |
6581 | 346 |
dAngle: real; |
347 |
begin |
|
7825 | 348 |
// Frac/Round to be kind to JS as of 2012-08-27 where there is yet no int64/uint64 |
349 |
//dAngle := (Gear^.dX.QWordValue + Gear^.dY.QWordValue) / $80000000; |
|
350 |
dAngle := (Gear^.dX.Round + Gear^.dY.Round) / 2 + (Gear^.dX.Frac/$100000000+Gear^.dY.Frac/$100000000); |
|
6581 | 351 |
if not Gear^.dX.isNegative then |
352 |
Gear^.DirAngle := Gear^.DirAngle + dAngle |
|
353 |
else |
|
354 |
Gear^.DirAngle := Gear^.DirAngle - dAngle; |
|
355 |
||
356 |
if Gear^.DirAngle < 0 then |
|
357 |
Gear^.DirAngle := Gear^.DirAngle + 360 |
|
358 |
else if 360 < Gear^.DirAngle then |
|
359 |
Gear^.DirAngle := Gear^.DirAngle - 360 |
|
360 |
end; |
|
361 |
||
10363 | 362 |
procedure AddSplashForGear(Gear: PGear; justSkipping: boolean); |
363 |
var x, y, i, distL, distR, distB, minDist, maxDrops: LongInt; |
|
364 |
splash, particle: PVisualGear; |
|
365 |
speed, hwTmp: hwFloat; |
|
366 |
vi, vs, tmp: real; // impact speed and sideways speed |
|
367 |
isImpactH, isImpactRight: boolean; |
|
10419 | 368 |
const dist2surf = 4; |
10363 | 369 |
begin |
370 |
x:= hwRound(Gear^.X); |
|
371 |
y:= hwRound(Gear^.Y); |
|
372 |
||
10419 | 373 |
// find position for splash and impact speed |
10363 | 374 |
|
375 |
distB:= cWaterline - y; |
|
376 |
||
377 |
if WorldEdge <> weSea then |
|
378 |
minDist:= distB |
|
379 |
else |
|
380 |
begin |
|
381 |
distL:= x - leftX; |
|
382 |
distR:= rightX - x; |
|
383 |
minDist:= min(distB, min(distL, distR)); |
|
384 |
end; |
|
385 |
||
386 |
isImpactH:= (minDist <> distB); |
|
387 |
||
388 |
if not isImpactH then |
|
389 |
begin |
|
10417 | 390 |
y:= cWaterline - dist2surf; |
10363 | 391 |
speed:= hwAbs(Gear^.dY); |
392 |
end |
|
393 |
else |
|
394 |
begin |
|
395 |
isImpactRight := minDist = distR; |
|
396 |
if isImpactRight then |
|
10419 | 397 |
x:= rightX - dist2surf |
10363 | 398 |
else |
10419 | 399 |
x:= leftX + dist2surf; |
10363 | 400 |
speed:= hwAbs(Gear^.dX); |
401 |
end; |
|
402 |
||
403 |
// splash sound |
|
404 |
||
405 |
if justSkipping then |
|
406 |
PlaySound(sndSkip) |
|
407 |
else |
|
408 |
begin |
|
409 |
// adjust water impact sound based on gear speed and density |
|
410 |
hwTmp:= hwAbs(Gear^.Density * speed); |
|
411 |
||
412 |
if hwTmp > _1 then |
|
413 |
PlaySound(sndSplash) |
|
414 |
else if hwTmp > _0_5 then |
|
415 |
PlaySound(sndSkip) |
|
416 |
else |
|
417 |
PlaySound(sndDroplet2); |
|
418 |
end; |
|
419 |
||
10419 | 420 |
|
421 |
// splash visuals |
|
422 |
||
423 |
if ((cReducedQuality and rqPlainSplash) <> 0) then |
|
424 |
exit; |
|
425 |
||
426 |
splash:= AddVisualGear(x, y, vgtSplash); |
|
427 |
if splash = nil then |
|
428 |
exit; |
|
429 |
||
430 |
if not isImpactH then |
|
431 |
vs:= abs(hwFloat2Float(Gear^.dX)) |
|
432 |
else |
|
433 |
begin |
|
434 |
if isImpactRight then |
|
435 |
splash^.Angle:= -90 |
|
436 |
else |
|
437 |
splash^.Angle:= 90; |
|
438 |
vs:= abs(hwFloat2Float(Gear^.dY)); |
|
439 |
end; |
|
440 |
||
441 |
||
442 |
vi:= hwFloat2Float(speed); |
|
443 |
||
10363 | 444 |
with splash^ do |
445 |
begin |
|
446 |
Scale:= abs(hwFloat2Float(Gear^.Density / _3 * speed)); |
|
447 |
if Scale > 1 then Scale:= power(Scale,0.3333) |
|
448 |
else Scale:= Scale + ((1-Scale) / 2); |
|
449 |
if Scale > 1 then Timer:= round(min(Scale*0.0005/cGravityf,4)) |
|
450 |
else Timer:= 1; |
|
451 |
// Low Gravity |
|
452 |
FrameTicks:= FrameTicks*Timer; |
|
453 |
end; |
|
454 |
||
455 |
||
456 |
// eject water drops |
|
457 |
||
458 |
maxDrops := (hwRound(Gear^.Density) * 3) div 2 + round((vi + vs) * hwRound(Gear^.Density) * 6); |
|
459 |
for i:= max(maxDrops div 3, min(32, Random(maxDrops))) downto 0 do |
|
460 |
begin |
|
461 |
if isImpactH then |
|
462 |
particle := AddVisualGear(x, y - 3 + Random(7), vgtDroplet) |
|
463 |
else |
|
464 |
particle := AddVisualGear(x - 3 + Random(7), y, vgtDroplet); |
|
465 |
||
466 |
if particle <> nil then |
|
467 |
with particle^ do |
|
468 |
begin |
|
469 |
// dX and dY were initialized to have a random value on creation (see uVisualGearsList) |
|
470 |
if isImpactH then |
|
471 |
begin |
|
472 |
tmp:= dX; |
|
473 |
if isImpactRight then |
|
474 |
dX:= dY - vi / 5 |
|
475 |
else |
|
476 |
dX:= -dy + vi / 5; |
|
477 |
dY:= tmp * (1 + vs / 10); |
|
478 |
end |
|
479 |
else |
|
480 |
begin |
|
481 |
dX:= dX * (1 + vs / 10); |
|
482 |
dY:= dY - vi / 5; |
|
483 |
end; |
|
484 |
||
485 |
if splash <> nil then |
|
486 |
begin |
|
487 |
if splash^.Scale > 1 then |
|
488 |
begin |
|
489 |
dX:= dX * power(splash^.Scale, 0.3333); // tone down the droplet height further |
|
490 |
dY:= dY * power(splash^.Scale, 0.3333); |
|
491 |
end |
|
492 |
else |
|
493 |
begin |
|
494 |
dX:= dX * splash^.Scale; |
|
495 |
dY:= dY * splash^.Scale; |
|
496 |
end; |
|
497 |
end; |
|
498 |
end |
|
499 |
end; |
|
500 |
||
501 |
end; |
|
502 |
||
10354 | 503 |
procedure DrownGear(Gear: PGear); |
504 |
begin |
|
505 |
Gear^.doStep := @doStepDrowningGear; |
|
506 |
||
507 |
Gear^.Timer := 5000; // how long game should wait |
|
508 |
end; |
|
509 |
||
8947
e906ebd59612
CheckGearDrowning could delete hedgehogs gear! (CheckGearDrowning -> ResurrectHedgehog -> FindPlace). Fixes bug 620.
unc0rr
parents:
8763
diff
changeset
|
510 |
function CheckGearDrowning(var Gear: PGear): boolean; |
10015 | 511 |
var |
10363 | 512 |
skipSpeed, skipAngle, skipDecay: hwFloat; |
513 |
tmp, X, Y, dist2Water: LongInt; |
|
514 |
isSubmersible, isDirH, isImpact, isSkip: boolean; |
|
10124
aabd1b75d5a3
Even more explicit type conversions and other stuff to help pas2c use ansistrings
unc0rr
parents:
10116
diff
changeset
|
515 |
s: ansistring; |
6581 | 516 |
begin |
517 |
// probably needs tweaking. might need to be in a case statement based upon gear type |
|
10354 | 518 |
X:= hwRound(Gear^.X); |
6581 | 519 |
Y:= hwRound(Gear^.Y); |
10354 | 520 |
|
521 |
dist2Water:= cWaterLine - (Y + Gear^.Radius); |
|
10363 | 522 |
isDirH:= false; |
10354 | 523 |
|
524 |
if WorldEdge = weSea then |
|
6581 | 525 |
begin |
10363 | 526 |
tmp:= dist2Water; |
10494 | 527 |
dist2Water:= min(dist2Water, min(X - Gear^.Radius - LongInt(leftX), LongInt(rightX) - (X + Gear^.Radius))); |
10363 | 528 |
// if water on sides is closer than on bottom -> horizontal direction |
529 |
isDirH:= tmp <> dist2Water; |
|
10354 | 530 |
end; |
531 |
||
10363 | 532 |
isImpact:= false; |
533 |
||
10354 | 534 |
if dist2Water < 0 then |
535 |
begin |
|
536 |
// invisible gears will just be deleted |
|
537 |
// unless they are generic fallers, then they will be "respawned" |
|
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
|
538 |
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
|
539 |
begin |
7406
1fe2c821f9bf
Try avoiding spamming the log by retaining the gears. untested.
nemo
parents:
7389
diff
changeset
|
540 |
if Gear^.Kind = gtGenericFaller then |
1fe2c821f9bf
Try avoiding spamming the log by retaining the gears. untested.
nemo
parents:
7389
diff
changeset
|
541 |
begin |
1fe2c821f9bf
Try avoiding spamming the log by retaining the gears. untested.
nemo
parents:
7389
diff
changeset
|
542 |
Gear^.X:= int2hwFloat(GetRandom(rightX-leftX)+leftX); |
1fe2c821f9bf
Try avoiding spamming the log by retaining the gears. untested.
nemo
parents:
7389
diff
changeset
|
543 |
Gear^.Y:= int2hwFloat(GetRandom(LAND_HEIGHT-topY)+topY); |
1fe2c821f9bf
Try avoiding spamming the log by retaining the gears. untested.
nemo
parents:
7389
diff
changeset
|
544 |
Gear^.dX:= _90-(GetRandomf*_360); |
1fe2c821f9bf
Try avoiding spamming the log by retaining the gears. untested.
nemo
parents:
7389
diff
changeset
|
545 |
Gear^.dY:= _90-(GetRandomf*_360) |
1fe2c821f9bf
Try avoiding spamming the log by retaining the gears. untested.
nemo
parents:
7389
diff
changeset
|
546 |
end |
1fe2c821f9bf
Try avoiding spamming the log by retaining the gears. untested.
nemo
parents:
7389
diff
changeset
|
547 |
else DeleteGear(Gear); |
10245 | 548 |
exit(true) |
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
|
549 |
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
|
550 |
isSubmersible:= ((Gear = CurrentHedgehog^.Gear) and (CurAmmoGear <> nil) and (CurAmmoGear^.State and gstSubmersible <> 0)) or (Gear^.State and gstSubmersible <> 0); |
10363 | 551 |
|
6581 | 552 |
skipSpeed := _0_25; |
553 |
skipAngle := _1_9; |
|
554 |
skipDecay := _0_87; |
|
10363 | 555 |
|
10354 | 556 |
|
557 |
// skipping |
|
558 |
||
10512
25021aac078e
fix underwater-skipping bug and make air-strike missiles submersible when fired from within weSea
sheepluva
parents:
10508
diff
changeset
|
559 |
if (not isSubmersible) and (hwSqr(Gear^.dX) + hwSqr(Gear^.dY) > skipSpeed) |
10363 | 560 |
and ( ((not isDirH) and (hwAbs(Gear^.dX) > skipAngle * hwAbs(Gear^.dY))) |
561 |
or (isDirH and (hwAbs(Gear^.dY) > skipAngle * hwAbs(Gear^.dX))) ) then |
|
6581 | 562 |
begin |
10363 | 563 |
isSkip:= true; |
10354 | 564 |
// if skipping we move the gear out of water |
10363 | 565 |
if isDirH then |
10354 | 566 |
begin |
567 |
Gear^.dX.isNegative := (not Gear^.dX.isNegative); |
|
568 |
Gear^.X:= Gear^.X + Gear^.dX; |
|
569 |
end |
|
570 |
else |
|
571 |
begin |
|
572 |
Gear^.dY.isNegative := (not Gear^.dY.isNegative); |
|
573 |
Gear^.Y:= Gear^.Y + Gear^.dY; |
|
574 |
end; |
|
6581 | 575 |
Gear^.dY := Gear^.dY * skipDecay; |
576 |
Gear^.dX := Gear^.dX * skipDecay; |
|
577 |
CheckGearDrowning := false; |
|
578 |
end |
|
10354 | 579 |
else // not skipping |
6581 | 580 |
begin |
10363 | 581 |
isImpact:= true; |
582 |
isSkip:= false; |
|
6581 | 583 |
if not isSubmersible then |
584 |
begin |
|
585 |
CheckGearDrowning := true; |
|
586 |
Gear^.State := gstDrowning; |
|
587 |
Gear^.RenderTimer := false; |
|
588 |
if (Gear^.Kind <> gtSniperRifleShot) and (Gear^.Kind <> gtShotgunShot) |
|
589 |
and (Gear^.Kind <> gtDEagleShot) and (Gear^.Kind <> gtSineGunShot) then |
|
590 |
if Gear^.Kind = gtHedgehog then |
|
591 |
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
|
592 |
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
|
593 |
begin |
e906ebd59612
CheckGearDrowning could delete hedgehogs gear! (CheckGearDrowning -> ResurrectHedgehog -> FindPlace). Fixes bug 620.
unc0rr
parents:
8763
diff
changeset
|
594 |
// 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
|
595 |
ResurrectHedgehog(Gear); |
10245 | 596 |
exit(true) |
8947
e906ebd59612
CheckGearDrowning could delete hedgehogs gear! (CheckGearDrowning -> ResurrectHedgehog -> FindPlace). Fixes bug 620.
unc0rr
parents:
8763
diff
changeset
|
597 |
end |
6581 | 598 |
else |
599 |
begin |
|
10354 | 600 |
DrownGear(Gear); |
6581 | 601 |
Gear^.State := Gear^.State and (not gstHHDriven); |
10124
aabd1b75d5a3
Even more explicit type conversions and other stuff to help pas2c use ansistrings
unc0rr
parents:
10116
diff
changeset
|
602 |
s:= ansistring(Gear^.Hedgehog^.Name); |
aabd1b75d5a3
Even more explicit type conversions and other stuff to help pas2c use ansistrings
unc0rr
parents:
10116
diff
changeset
|
603 |
AddCaption(FormatA(GetEventString(eidDrowned), s), cWhiteColor, capgrpMessage); |
6581 | 604 |
end |
605 |
end |
|
606 |
else |
|
10354 | 607 |
DrownGear(Gear); |
10419 | 608 |
if Gear^.Kind = gtFlake then |
10354 | 609 |
exit(true); // skip splashes |
8990 | 610 |
end |
10363 | 611 |
else // submersible |
612 |
begin |
|
613 |
// drown submersible grears if far below map |
|
614 |
if (Y > cWaterLine + cVisibleWater*4) then |
|
615 |
begin |
|
616 |
DrownGear(Gear); |
|
617 |
exit(true); // no splashes needed |
|
618 |
end; |
|
10354 | 619 |
|
10363 | 620 |
CheckGearDrowning := false; |
621 |
||
622 |
// check if surface was penetrated |
|
10354 | 623 |
|
10363 | 624 |
// no penetration if center's water distance not smaller than radius |
625 |
if abs(dist2Water + Gear^.Radius) >= Gear^.Radius then |
|
626 |
isImpact:= false |
|
6804 | 627 |
else |
10354 | 628 |
begin |
10363 | 629 |
// get distance to water of last tick |
630 |
if isDirH then |
|
631 |
begin |
|
632 |
tmp:= hwRound(Gear^.X - Gear^.dX); |
|
633 |
tmp:= abs(min(tmp - leftX, rightX - tmp)); |
|
634 |
end |
|
10354 | 635 |
else |
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
|
636 |
begin |
10363 | 637 |
tmp:= hwRound(Gear^.Y - Gear^.dY); |
638 |
tmp:= abs(cWaterLine - tmp); |
|
639 |
end; |
|
10354 | 640 |
|
10419 | 641 |
// there was an impact if distance was >= radius |
642 |
isImpact:= (tmp >= Gear^.Radius) |
|
10363 | 643 |
end; |
644 |
end; // end of submersible |
|
645 |
end; // end of not skipping |
|
646 |
||
647 |
// splash sound animation and droplets |
|
648 |
if isImpact or isSkip then |
|
649 |
addSplashForGear(Gear, isSkip); |
|
650 |
||
6581 | 651 |
end |
652 |
else |
|
9473
a51a69094c24
partial implementation of non-infinite world (edge wrap/warp/bounce)
nemo
parents:
9285
diff
changeset
|
653 |
begin |
9521
8054d9d775fd
merge with latest defaul, fixing compiling with fpc, parsing and rendering with pas2c, some minor problems with compiling with clang
koda
diff
changeset
|
654 |
if (not ((Gear^.Kind = gtJetpack) or (Gear^.Kind = gtBee))) then |
8054d9d775fd
merge with latest defaul, fixing compiling with fpc, parsing and rendering with pas2c, some minor problems with compiling with clang
koda
diff
changeset
|
655 |
Gear^.State:= (Gear^.State and (not gstSubmersible)); // making it temporary for most gears is more attractive I think |
9473
a51a69094c24
partial implementation of non-infinite world (edge wrap/warp/bounce)
nemo
parents:
9285
diff
changeset
|
656 |
CheckGearDrowning := false |
a51a69094c24
partial implementation of non-infinite world (edge wrap/warp/bounce)
nemo
parents:
9285
diff
changeset
|
657 |
end |
6581 | 658 |
end; |
659 |
||
660 |
||
8947
e906ebd59612
CheckGearDrowning could delete hedgehogs gear! (CheckGearDrowning -> ResurrectHedgehog -> FindPlace). Fixes bug 620.
unc0rr
parents:
8763
diff
changeset
|
661 |
procedure ResurrectHedgehog(var gear: PGear); |
6581 | 662 |
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
|
663 |
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
|
664 |
gX, gY: LongInt; |
6581 | 665 |
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
|
666 |
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
|
667 |
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
|
668 |
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
|
669 |
uStats.HedgehogDamaged(Gear, CurrentHedgehog, 0, true); |
6581 | 670 |
AttackBar:= 0; |
671 |
gear^.dX := _0; |
|
672 |
gear^.dY := _0; |
|
673 |
gear^.Damage := 0; |
|
674 |
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
|
675 |
gear^.Hedgehog^.Effects[hePoisoned] := 0; |
7176
fb4b0c6dfdbd
Make watching AI v AI on ai survival a bit more entertaining
nemo
parents:
7168
diff
changeset
|
676 |
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
|
677 |
and (Gear^.Hedgehog^.Team^.Clan <> CurrentHedgehog^.Team^.Clan)) then |
8330 | 678 |
with CurrentHedgehog^ do |
6581 | 679 |
begin |
680 |
inc(Team^.stats.AIKills); |
|
681 |
FreeTexture(Team^.AIKillsTex); |
|
10124
aabd1b75d5a3
Even more explicit type conversions and other stuff to help pas2c use ansistrings
unc0rr
parents:
10116
diff
changeset
|
682 |
Team^.AIKillsTex := RenderStringTex(ansistring(inttostr(Team^.stats.AIKills)), Team^.Clan^.Color, fnt16); |
6581 | 683 |
end; |
684 |
tempTeam := gear^.Hedgehog^.Team; |
|
685 |
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
|
686 |
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
|
687 |
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
|
688 |
// 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
|
689 |
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
|
690 |
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
|
691 |
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
|
692 |
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
|
693 |
//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
|
694 |
end; |
8330 | 695 |
FindPlace(gear, false, 0, LAND_WIDTH, true); |
6581 | 696 |
if gear <> nil then |
697 |
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
|
698 |
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
|
699 |
PlaySound(sndWarp); |
6581 | 700 |
RenderHealth(gear^.Hedgehog^); |
701 |
ScriptCall('onGearResurrect', gear^.uid); |
|
702 |
gear^.State := gstWait; |
|
8947
e906ebd59612
CheckGearDrowning could delete hedgehogs gear! (CheckGearDrowning -> ResurrectHedgehog -> FindPlace). Fixes bug 620.
unc0rr
parents:
8763
diff
changeset
|
703 |
end; |
6581 | 704 |
RecountTeamHealth(tempTeam); |
705 |
end; |
|
706 |
||
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
|
707 |
function CountNonZeroz(x, y, r, c: LongInt; mask: LongWord): LongInt; |
6581 | 708 |
var i: LongInt; |
709 |
count: LongInt = 0; |
|
710 |
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
|
711 |
if (y and LAND_HEIGHT_MASK) = 0 then |
10272
31ee88c9b4d0
Allow barrels to spawn in U-shaped pits in stable position
unc0rr
parents:
10245
diff
changeset
|
712 |
for i:= max(x - r, 0) to min(x + r, LAND_WIDTH - 1) 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
|
713 |
if Land[y, i] and mask <> 0 then |
6581 | 714 |
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
|
715 |
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
|
716 |
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
|
717 |
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
|
718 |
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
|
719 |
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
|
720 |
end; |
6581 | 721 |
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
|
722 |
CountNonZeroz:= count; |
6581 | 723 |
end; |
724 |
||
10272
31ee88c9b4d0
Allow barrels to spawn in U-shaped pits in stable position
unc0rr
parents:
10245
diff
changeset
|
725 |
function isSteadyPosition(x, y, r, c: LongInt; mask: Longword): boolean; |
31ee88c9b4d0
Allow barrels to spawn in U-shaped pits in stable position
unc0rr
parents:
10245
diff
changeset
|
726 |
var cnt, i: LongInt; |
31ee88c9b4d0
Allow barrels to spawn in U-shaped pits in stable position
unc0rr
parents:
10245
diff
changeset
|
727 |
begin |
31ee88c9b4d0
Allow barrels to spawn in U-shaped pits in stable position
unc0rr
parents:
10245
diff
changeset
|
728 |
cnt:= 0; |
31ee88c9b4d0
Allow barrels to spawn in U-shaped pits in stable position
unc0rr
parents:
10245
diff
changeset
|
729 |
isSteadyPosition:= false; |
31ee88c9b4d0
Allow barrels to spawn in U-shaped pits in stable position
unc0rr
parents:
10245
diff
changeset
|
730 |
|
31ee88c9b4d0
Allow barrels to spawn in U-shaped pits in stable position
unc0rr
parents:
10245
diff
changeset
|
731 |
if ((y and LAND_HEIGHT_MASK) = 0) and (x - r >= 0) and (x + r < LAND_WIDTH) then |
31ee88c9b4d0
Allow barrels to spawn in U-shaped pits in stable position
unc0rr
parents:
10245
diff
changeset
|
732 |
begin |
31ee88c9b4d0
Allow barrels to spawn in U-shaped pits in stable position
unc0rr
parents:
10245
diff
changeset
|
733 |
for i:= r - c + 2 to r do |
31ee88c9b4d0
Allow barrels to spawn in U-shaped pits in stable position
unc0rr
parents:
10245
diff
changeset
|
734 |
begin |
31ee88c9b4d0
Allow barrels to spawn in U-shaped pits in stable position
unc0rr
parents:
10245
diff
changeset
|
735 |
if (Land[y, x - i] and mask <> 0) then inc(cnt); |
31ee88c9b4d0
Allow barrels to spawn in U-shaped pits in stable position
unc0rr
parents:
10245
diff
changeset
|
736 |
if (Land[y, x + i] and mask <> 0) then inc(cnt); |
31ee88c9b4d0
Allow barrels to spawn in U-shaped pits in stable position
unc0rr
parents:
10245
diff
changeset
|
737 |
|
31ee88c9b4d0
Allow barrels to spawn in U-shaped pits in stable position
unc0rr
parents:
10245
diff
changeset
|
738 |
if cnt >= c then |
31ee88c9b4d0
Allow barrels to spawn in U-shaped pits in stable position
unc0rr
parents:
10245
diff
changeset
|
739 |
begin |
31ee88c9b4d0
Allow barrels to spawn in U-shaped pits in stable position
unc0rr
parents:
10245
diff
changeset
|
740 |
isSteadyPosition:= true; |
31ee88c9b4d0
Allow barrels to spawn in U-shaped pits in stable position
unc0rr
parents:
10245
diff
changeset
|
741 |
exit |
31ee88c9b4d0
Allow barrels to spawn in U-shaped pits in stable position
unc0rr
parents:
10245
diff
changeset
|
742 |
end; |
31ee88c9b4d0
Allow barrels to spawn in U-shaped pits in stable position
unc0rr
parents:
10245
diff
changeset
|
743 |
end; |
31ee88c9b4d0
Allow barrels to spawn in U-shaped pits in stable position
unc0rr
parents:
10245
diff
changeset
|
744 |
end; |
31ee88c9b4d0
Allow barrels to spawn in U-shaped pits in stable position
unc0rr
parents:
10245
diff
changeset
|
745 |
end; |
31ee88c9b4d0
Allow barrels to spawn in U-shaped pits in stable position
unc0rr
parents:
10245
diff
changeset
|
746 |
|
6888 | 747 |
|
748 |
function NoGearsToAvoid(mX, mY: LongInt; rX, rY: LongInt): boolean; |
|
749 |
var t: PGear; |
|
750 |
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
|
751 |
NoGearsToAvoid:= false; |
6888 | 752 |
t:= GearsList; |
753 |
rX:= sqr(rX); |
|
754 |
rY:= sqr(rY); |
|
755 |
while t <> nil do |
|
756 |
begin |
|
757 |
if t^.Kind <= gtExplosives then |
|
758 |
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
|
759 |
exit; |
6888 | 760 |
t:= t^.NextGear |
761 |
end; |
|
762 |
NoGearsToAvoid:= true |
|
763 |
end; |
|
764 |
||
6986
409dd3851309
add support for default pascal mode by removing default arguments value (maybe this also helps the parser)
koda
parents:
6888
diff
changeset
|
765 |
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
|
766 |
begin |
409dd3851309
add support for default pascal mode by removing default arguments value (maybe this also helps the parser)
koda
parents:
6888
diff
changeset
|
767 |
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
|
768 |
end; |
6888 | 769 |
|
6581 | 770 |
procedure FindPlace(var Gear: PGear; withFall: boolean; Left, Right: LongInt; skipProximity: boolean); |
771 |
var x: LongInt; |
|
772 |
y, sy: LongInt; |
|
8007 | 773 |
ar: array[0..1023] of TPoint; |
774 |
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
|
775 |
temp: TPoint; |
6581 | 776 |
cnt, cnt2: Longword; |
777 |
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
|
778 |
ignoreNearObjects, ignoreOverlap, tryAgain: boolean; |
6581 | 779 |
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
|
780 |
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
|
781 |
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 | 782 |
tryAgain:= true; |
10015 | 783 |
if WorldEdge <> weNone then |
9477 | 784 |
begin |
9809 | 785 |
Left:= max(Left, LongInt(leftX) + Gear^.Radius); |
9477 | 786 |
Right:= min(Right,rightX-Gear^.Radius) |
787 |
end; |
|
6581 | 788 |
while tryAgain do |
789 |
begin |
|
8007 | 790 |
delta:= LAND_WIDTH div 16; |
6581 | 791 |
cnt2:= 0; |
792 |
repeat |
|
8007 | 793 |
x:= Left + max(LAND_WIDTH div 2048, LongInt(GetRandom(Delta))); |
6581 | 794 |
repeat |
795 |
inc(x, Delta); |
|
796 |
cnt:= 0; |
|
9809 | 797 |
y:= min(1024, topY) - Gear^.Radius shl 1; |
6581 | 798 |
while y < cWaterLine do |
799 |
begin |
|
800 |
repeat |
|
801 |
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
|
802 |
until (y >= cWaterLine) or |
10015 | 803 |
((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
|
804 |
(ignoreOverlap and (CountNonZeroz(x, y, Gear^.Radius - 1, 1, lfLandMask) = 0)); |
6581 | 805 |
|
806 |
sy:= y; |
|
807 |
||
808 |
repeat |
|
809 |
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
|
810 |
until (y >= cWaterLine) or |
10015 | 811 |
((not ignoreOverlap) and (CountNonZeroz(x, y, Gear^.Radius - 1, 1, $FFFF) <> 0)) or |
812 |
(ignoreOverlap and (CountNonZeroz(x, y, Gear^.Radius - 1, 1, lfLandMask) <> 0)); |
|
6581 | 813 |
|
10272
31ee88c9b4d0
Allow barrels to spawn in U-shaped pits in stable position
unc0rr
parents:
10245
diff
changeset
|
814 |
if (y - sy > Gear^.Radius * 2) and (y < cWaterLine) |
6581 | 815 |
and (((Gear^.Kind = gtExplosives) |
10272
31ee88c9b4d0
Allow barrels to spawn in U-shaped pits in stable position
unc0rr
parents:
10245
diff
changeset
|
816 |
and (ignoreNearObjects or NoGearsToAvoid(x, y - Gear^.Radius, 60, 60)) |
10274 | 817 |
and (isSteadyPosition(x, y+1, Gear^.Radius - 1, 3, $FFFF) |
818 |
or (CountNonZeroz(x, y+1, Gear^.Radius - 1, Gear^.Radius+1, $FFFF) > Gear^.Radius) |
|
819 |
)) |
|
10272
31ee88c9b4d0
Allow barrels to spawn in U-shaped pits in stable position
unc0rr
parents:
10245
diff
changeset
|
820 |
or |
31ee88c9b4d0
Allow barrels to spawn in U-shaped pits in stable position
unc0rr
parents:
10245
diff
changeset
|
821 |
((Gear^.Kind <> gtExplosives) |
31ee88c9b4d0
Allow barrels to spawn in U-shaped pits in stable position
unc0rr
parents:
10245
diff
changeset
|
822 |
and (ignoreNearObjects or NoGearsToAvoid(x, y - Gear^.Radius, 110, 110)) |
31ee88c9b4d0
Allow barrels to spawn in U-shaped pits in stable position
unc0rr
parents:
10245
diff
changeset
|
823 |
)) then |
6888 | 824 |
begin |
6581 | 825 |
ar[cnt].X:= x; |
826 |
if withFall then |
|
827 |
ar[cnt].Y:= sy + Gear^.Radius |
|
828 |
else |
|
829 |
ar[cnt].Y:= y - Gear^.Radius; |
|
830 |
inc(cnt) |
|
831 |
end; |
|
832 |
||
7603
e9c3c67b5dfd
reducing this value is sufficient to ensure crates drop just below top border or a girder
nemo
parents:
7599
diff
changeset
|
833 |
inc(y, 10) |
6581 | 834 |
end; |
835 |
||
836 |
if cnt > 0 then |
|
10015 | 837 |
begin |
838 |
temp := ar[GetRandom(cnt)]; |
|
839 |
with temp do |
|
6581 | 840 |
begin |
841 |
ar2[cnt2].x:= x; |
|
842 |
ar2[cnt2].y:= y; |
|
843 |
inc(cnt2) |
|
844 |
end |
|
10015 | 845 |
end |
6581 | 846 |
until (x + Delta > Right); |
847 |
||
848 |
dec(Delta, 60) |
|
849 |
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
|
850 |
// 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
|
851 |
if (cnt2 = 0) and skipProximity and (not ignoreOverlap) then |
6581 | 852 |
tryAgain:= true |
853 |
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
|
854 |
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
|
855 |
ignoreNearObjects:= true; |
6581 | 856 |
end; |
857 |
||
858 |
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
|
859 |
begin |
4a4f21070479
merge xymeng's gsoc engine with a few updates (and further checks on symbol definitions)
koda
parents:
8007
diff
changeset
|
860 |
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
|
861 |
with temp do |
6581 | 862 |
begin |
863 |
Gear^.X:= int2hwFloat(x); |
|
864 |
Gear^.Y:= int2hwFloat(y); |
|
865 |
AddFileLog('Assigned Gear coordinates (' + inttostr(x) + ',' + inttostr(y) + ')'); |
|
866 |
end |
|
8026
4a4f21070479
merge xymeng's gsoc engine with a few updates (and further checks on symbol definitions)
koda
parents:
8007
diff
changeset
|
867 |
end |
6581 | 868 |
else |
869 |
begin |
|
870 |
OutError('Can''t find place for Gear', false); |
|
871 |
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
|
872 |
Gear^.Hedgehog^.Effects[heResurrectable] := 0; |
6581 | 873 |
DeleteGear(Gear); |
874 |
Gear:= nil |
|
875 |
end |
|
876 |
end; |
|
877 |
||
878 |
function CheckGearNear(Gear: PGear; Kind: TGearType; rX, rY: LongInt): PGear; |
|
879 |
var t: PGear; |
|
880 |
begin |
|
881 |
t:= GearsList; |
|
882 |
rX:= sqr(rX); |
|
883 |
rY:= sqr(rY); |
|
884 |
||
885 |
while t <> nil do |
|
886 |
begin |
|
887 |
if (t <> Gear) and (t^.Kind = Kind) then |
|
888 |
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
|
889 |
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
|
890 |
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
|
891 |
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
|
892 |
end; |
6581 | 893 |
t:= t^.NextGear |
894 |
end; |
|
895 |
||
896 |
CheckGearNear:= nil |
|
897 |
end; |
|
898 |
||
7592 | 899 |
procedure CheckCollision(Gear: PGear); inline; |
900 |
begin |
|
9706
5178d2263521
return land word from uCollisions to make decisions based on it. Should be handy for trampoline.
nemo
parents:
9685
diff
changeset
|
901 |
if (TestCollisionXwithGear(Gear, hwSign(Gear^.dX)) <> 0) |
7592 | 902 |
or (TestCollisionYwithGear(Gear, hwSign(Gear^.dY)) <> 0) then |
903 |
Gear^.State := Gear^.State or gstCollision |
|
904 |
else |
|
905 |
Gear^.State := Gear^.State and (not gstCollision) |
|
906 |
end; |
|
907 |
||
908 |
procedure CheckCollisionWithLand(Gear: PGear); inline; |
|
909 |
begin |
|
9706
5178d2263521
return land word from uCollisions to make decisions based on it. Should be handy for trampoline.
nemo
parents:
9685
diff
changeset
|
910 |
if (TestCollisionX(Gear, hwSign(Gear^.dX)) <> 0) |
5178d2263521
return land word from uCollisions to make decisions based on it. Should be handy for trampoline.
nemo
parents:
9685
diff
changeset
|
911 |
or (TestCollisionY(Gear, hwSign(Gear^.dY)) <> 0) then |
7592 | 912 |
Gear^.State := Gear^.State or gstCollision |
8330 | 913 |
else |
7592 | 914 |
Gear^.State := Gear^.State and (not gstCollision) |
915 |
end; |
|
916 |
||
7719
eeae1cb6b6bf
Move hedgehog's step routine into separate function, use it in both hedgehog and ai code
unc0rr
parents:
7627
diff
changeset
|
917 |
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
|
918 |
begin |
9706
5178d2263521
return land word from uCollisions to make decisions based on it. Should be handy for trampoline.
nemo
parents:
9685
diff
changeset
|
919 |
if TestCollisionXwithGear(Gear, hwSign(Gear^.dX)) <> 0 then if (TestCollisionYwithGear(Gear, -1) = 0) then |
7719
eeae1cb6b6bf
Move hedgehog's step routine into separate function, use it in both hedgehog and ai code
unc0rr
parents:
7627
diff
changeset
|
920 |
begin |
eeae1cb6b6bf
Move hedgehog's step routine into separate function, use it in both hedgehog and ai code
unc0rr
parents:
7627
diff
changeset
|
921 |
Gear^.Y:= Gear^.Y - _1; |
9706
5178d2263521
return land word from uCollisions to make decisions based on it. Should be handy for trampoline.
nemo
parents:
9685
diff
changeset
|
922 |
if TestCollisionXwithGear(Gear, hwSign(Gear^.dX)) <> 0 then if (TestCollisionYwithGear(Gear, -1) = 0) then |
7719
eeae1cb6b6bf
Move hedgehog's step routine into separate function, use it in both hedgehog and ai code
unc0rr
parents:
7627
diff
changeset
|
923 |
begin |
eeae1cb6b6bf
Move hedgehog's step routine into separate function, use it in both hedgehog and ai code
unc0rr
parents:
7627
diff
changeset
|
924 |
Gear^.Y:= Gear^.Y - _1; |
9706
5178d2263521
return land word from uCollisions to make decisions based on it. Should be handy for trampoline.
nemo
parents:
9685
diff
changeset
|
925 |
if TestCollisionXwithGear(Gear, hwSign(Gear^.dX)) <> 0 then if (TestCollisionYwithGear(Gear, -1) = 0) then |
7719
eeae1cb6b6bf
Move hedgehog's step routine into separate function, use it in both hedgehog and ai code
unc0rr
parents:
7627
diff
changeset
|
926 |
begin |
eeae1cb6b6bf
Move hedgehog's step routine into separate function, use it in both hedgehog and ai code
unc0rr
parents:
7627
diff
changeset
|
927 |
Gear^.Y:= Gear^.Y - _1; |
9706
5178d2263521
return land word from uCollisions to make decisions based on it. Should be handy for trampoline.
nemo
parents:
9685
diff
changeset
|
928 |
if TestCollisionXwithGear(Gear, hwSign(Gear^.dX)) <> 0 then if (TestCollisionYwithGear(Gear, -1) = 0) then |
7719
eeae1cb6b6bf
Move hedgehog's step routine into separate function, use it in both hedgehog and ai code
unc0rr
parents:
7627
diff
changeset
|
929 |
begin |
eeae1cb6b6bf
Move hedgehog's step routine into separate function, use it in both hedgehog and ai code
unc0rr
parents:
7627
diff
changeset
|
930 |
Gear^.Y:= Gear^.Y - _1; |
9706
5178d2263521
return land word from uCollisions to make decisions based on it. Should be handy for trampoline.
nemo
parents:
9685
diff
changeset
|
931 |
if TestCollisionXwithGear(Gear, hwSign(Gear^.dX)) <> 0 then if (TestCollisionYwithGear(Gear, -1) = 0) then |
7719
eeae1cb6b6bf
Move hedgehog's step routine into separate function, use it in both hedgehog and ai code
unc0rr
parents:
7627
diff
changeset
|
932 |
begin |
eeae1cb6b6bf
Move hedgehog's step routine into separate function, use it in both hedgehog and ai code
unc0rr
parents:
7627
diff
changeset
|
933 |
Gear^.Y:= Gear^.Y - _1; |
9706
5178d2263521
return land word from uCollisions to make decisions based on it. Should be handy for trampoline.
nemo
parents:
9685
diff
changeset
|
934 |
if TestCollisionXwithGear(Gear, hwSign(Gear^.dX)) <> 0 then if (TestCollisionYwithGear(Gear, -1) = 0) then |
7719
eeae1cb6b6bf
Move hedgehog's step routine into separate function, use it in both hedgehog and ai code
unc0rr
parents:
7627
diff
changeset
|
935 |
begin |
eeae1cb6b6bf
Move hedgehog's step routine into separate function, use it in both hedgehog and ai code
unc0rr
parents:
7627
diff
changeset
|
936 |
Gear^.Y:= Gear^.Y - _1; |
9706
5178d2263521
return land word from uCollisions to make decisions based on it. Should be handy for trampoline.
nemo
parents:
9685
diff
changeset
|
937 |
if TestCollisionXwithGear(Gear, hwSign(Gear^.dX)) <> 0 then |
7719
eeae1cb6b6bf
Move hedgehog's step routine into separate function, use it in both hedgehog and ai code
unc0rr
parents:
7627
diff
changeset
|
938 |
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
|
939 |
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
|
940 |
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
|
941 |
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
|
942 |
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
|
943 |
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
|
944 |
end; |
eeae1cb6b6bf
Move hedgehog's step routine into separate function, use it in both hedgehog and ai code
unc0rr
parents:
7627
diff
changeset
|
945 |
|
9706
5178d2263521
return land word from uCollisions to make decisions based on it. Should be handy for trampoline.
nemo
parents:
9685
diff
changeset
|
946 |
if TestCollisionXwithGear(Gear, hwSign(Gear^.dX)) = 0 then |
7719
eeae1cb6b6bf
Move hedgehog's step routine into separate function, use it in both hedgehog and ai code
unc0rr
parents:
7627
diff
changeset
|
947 |
begin |
eeae1cb6b6bf
Move hedgehog's step routine into separate function, use it in both hedgehog and ai code
unc0rr
parents:
7627
diff
changeset
|
948 |
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
|
949 |
MakeHedgehogsStep:= true |
eeae1cb6b6bf
Move hedgehog's step routine into separate function, use it in both hedgehog and ai code
unc0rr
parents:
7627
diff
changeset
|
950 |
end else |
eeae1cb6b6bf
Move hedgehog's step routine into separate function, use it in both hedgehog and ai code
unc0rr
parents:
7627
diff
changeset
|
951 |
MakeHedgehogsStep:= false; |
eeae1cb6b6bf
Move hedgehog's step routine into separate function, use it in both hedgehog and ai code
unc0rr
parents:
7627
diff
changeset
|
952 |
|
eeae1cb6b6bf
Move hedgehog's step routine into separate function, use it in both hedgehog and ai code
unc0rr
parents:
7627
diff
changeset
|
953 |
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
|
954 |
begin |
eeae1cb6b6bf
Move hedgehog's step routine into separate function, use it in both hedgehog and ai code
unc0rr
parents:
7627
diff
changeset
|
955 |
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
|
956 |
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
|
957 |
begin |
eeae1cb6b6bf
Move hedgehog's step routine into separate function, use it in both hedgehog and ai code
unc0rr
parents:
7627
diff
changeset
|
958 |
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
|
959 |
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
|
960 |
begin |
eeae1cb6b6bf
Move hedgehog's step routine into separate function, use it in both hedgehog and ai code
unc0rr
parents:
7627
diff
changeset
|
961 |
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
|
962 |
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
|
963 |
begin |
eeae1cb6b6bf
Move hedgehog's step routine into separate function, use it in both hedgehog and ai code
unc0rr
parents:
7627
diff
changeset
|
964 |
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
|
965 |
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
|
966 |
begin |
eeae1cb6b6bf
Move hedgehog's step routine into separate function, use it in both hedgehog and ai code
unc0rr
parents:
7627
diff
changeset
|
967 |
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
|
968 |
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
|
969 |
begin |
eeae1cb6b6bf
Move hedgehog's step routine into separate function, use it in both hedgehog and ai code
unc0rr
parents:
7627
diff
changeset
|
970 |
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
|
971 |
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
|
972 |
begin |
eeae1cb6b6bf
Move hedgehog's step routine into separate function, use it in both hedgehog and ai code
unc0rr
parents:
7627
diff
changeset
|
973 |
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
|
974 |
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
|
975 |
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
|
976 |
exit |
eeae1cb6b6bf
Move hedgehog's step routine into separate function, use it in both hedgehog and ai code
unc0rr
parents:
7627
diff
changeset
|
977 |
end; |
eeae1cb6b6bf
Move hedgehog's step routine into separate function, use it in both hedgehog and ai code
unc0rr
parents:
7627
diff
changeset
|
978 |
end |
eeae1cb6b6bf
Move hedgehog's step routine into separate function, use it in both hedgehog and ai code
unc0rr
parents:
7627
diff
changeset
|
979 |
end |
eeae1cb6b6bf
Move hedgehog's step routine into separate function, use it in both hedgehog and ai code
unc0rr
parents:
7627
diff
changeset
|
980 |
end |
eeae1cb6b6bf
Move hedgehog's step routine into separate function, use it in both hedgehog and ai code
unc0rr
parents:
7627
diff
changeset
|
981 |
end |
eeae1cb6b6bf
Move hedgehog's step routine into separate function, use it in both hedgehog and ai code
unc0rr
parents:
7627
diff
changeset
|
982 |
end |
eeae1cb6b6bf
Move hedgehog's step routine into separate function, use it in both hedgehog and ai code
unc0rr
parents:
7627
diff
changeset
|
983 |
end; |
eeae1cb6b6bf
Move hedgehog's step routine into separate function, use it in both hedgehog and ai code
unc0rr
parents:
7627
diff
changeset
|
984 |
end; |
eeae1cb6b6bf
Move hedgehog's step routine into separate function, use it in both hedgehog and ai code
unc0rr
parents:
7627
diff
changeset
|
985 |
|
9285 | 986 |
|
987 |
procedure ShotgunShot(Gear: PGear); |
|
988 |
var t: PGear; |
|
989 |
dmg, r, dist: LongInt; |
|
990 |
dx, dy: hwFloat; |
|
991 |
begin |
|
992 |
Gear^.Radius:= cShotgunRadius; |
|
993 |
t:= GearsList; |
|
994 |
while t <> nil do |
|
995 |
begin |
|
996 |
case t^.Kind of |
|
997 |
gtHedgehog, |
|
998 |
gtMine, |
|
999 |
gtSMine, |
|
1000 |
gtKnife, |
|
1001 |
gtCase, |
|
1002 |
gtTarget, |
|
1003 |
gtExplosives: begin//, |
|
1004 |
// gtStructure: begin |
|
1005 |
//addFileLog('ShotgunShot radius: ' + inttostr(Gear^.Radius) + ', t^.Radius = ' + inttostr(t^.Radius) + ', distance = ' + inttostr(dist) + ', dmg = ' + inttostr(dmg)); |
|
1006 |
dmg:= 0; |
|
1007 |
r:= Gear^.Radius + t^.Radius; |
|
1008 |
dx:= Gear^.X-t^.X; |
|
1009 |
dx.isNegative:= false; |
|
1010 |
dy:= Gear^.Y-t^.Y; |
|
1011 |
dy.isNegative:= false; |
|
1012 |
if r-hwRound(dx+dy) > 0 then |
|
1013 |
begin |
|
1014 |
dist:= hwRound(Distance(dx, dy)); |
|
1015 |
dmg:= ModifyDamage(min(r - dist, 25), t); |
|
1016 |
end; |
|
1017 |
if dmg > 0 then |
|
1018 |
begin |
|
10011
ead5e4b21671
Add check for gear kind of hedgehog on invulnerability effect. This probably fixes bug #766, is similar to change in previous r2a1483d91977 and was introduced by r7d925e82e572
nemo
parents:
10010
diff
changeset
|
1019 |
if (Gear^.Kind <> gtHedgehog) or (t^.Hedgehog^.Effects[heInvulnerable] = 0) then |
9285 | 1020 |
ApplyDamage(t, Gear^.Hedgehog, dmg, dsBullet) |
1021 |
else |
|
1022 |
Gear^.State:= Gear^.State or gstWinner; |
|
1023 |
||
1024 |
DeleteCI(t); |
|
1025 |
t^.dX:= t^.dX + Gear^.dX * dmg * _0_01 + SignAs(cHHKick, Gear^.dX); |
|
1026 |
t^.dY:= t^.dY + Gear^.dY * dmg * _0_01; |
|
1027 |
t^.State:= t^.State or gstMoving; |
|
1028 |
if t^.Kind = gtKnife then t^.State:= t^.State and (not gstCollision); |
|
1029 |
t^.Active:= true; |
|
1030 |
FollowGear:= t |
|
1031 |
end |
|
1032 |
end; |
|
1033 |
gtGrave: begin |
|
1034 |
dmg:= 0; |
|
1035 |
r:= Gear^.Radius + t^.Radius; |
|
1036 |
dx:= Gear^.X-t^.X; |
|
1037 |
dx.isNegative:= false; |
|
1038 |
dy:= Gear^.Y-t^.Y; |
|
1039 |
dy.isNegative:= false; |
|
1040 |
if r-hwRound(dx+dy) > 0 then |
|
1041 |
begin |
|
1042 |
dist:= hwRound(Distance(dx, dy)); |
|
1043 |
dmg:= ModifyDamage(min(r - dist, 25), t); |
|
1044 |
end; |
|
1045 |
if dmg > 0 then |
|
1046 |
begin |
|
1047 |
t^.dY:= - _0_1; |
|
1048 |
t^.Active:= true |
|
1049 |
end |
|
1050 |
end; |
|
1051 |
end; |
|
1052 |
t:= t^.NextGear |
|
1053 |
end; |
|
1054 |
if (GameFlags and gfSolidLand) = 0 then |
|
1055 |
DrawExplosion(hwRound(Gear^.X), hwRound(Gear^.Y), cShotgunRadius) |
|
1056 |
end; |
|
1057 |
||
1058 |
procedure AmmoShove(Ammo: PGear; Damage, Power: LongInt); |
|
1059 |
var t: PGearArray; |
|
1060 |
Gear: PGear; |
|
1061 |
i, j, tmpDmg: LongInt; |
|
1062 |
VGear: PVisualGear; |
|
1063 |
begin |
|
1064 |
t:= CheckGearsCollision(Ammo); |
|
1065 |
// Just to avoid hogs on rope dodging fire. |
|
1066 |
if (CurAmmoGear <> nil) and ((CurAmmoGear^.Kind = gtRope) or (CurAmmoGear^.Kind = gtJetpack) or (CurAmmoGear^.Kind = gtBirdy)) |
|
1067 |
and (CurrentHedgehog^.Gear <> nil) and (CurrentHedgehog^.Gear^.CollisionIndex = -1) |
|
1068 |
and (sqr(hwRound(Ammo^.X) - hwRound(CurrentHedgehog^.Gear^.X)) + sqr(hwRound(Ammo^.Y) - hwRound(CurrentHedgehog^.Gear^.Y)) <= sqr(cHHRadius + Ammo^.Radius)) then |
|
1069 |
begin |
|
1070 |
t^.ar[t^.Count]:= CurrentHedgehog^.Gear; |
|
1071 |
inc(t^.Count) |
|
1072 |
end; |
|
1073 |
||
1074 |
i:= t^.Count; |
|
1075 |
||
1076 |
if (Ammo^.Kind = gtFlame) and (i > 0) then |
|
1077 |
Ammo^.Health:= 0; |
|
1078 |
while i > 0 do |
|
1079 |
begin |
|
1080 |
dec(i); |
|
1081 |
Gear:= t^.ar[i]; |
|
10015 | 1082 |
if ((Ammo^.Kind = gtFlame) or (Ammo^.Kind = gtBlowTorch)) and |
9285 | 1083 |
(Gear^.Kind = gtHedgehog) and (Gear^.Hedgehog^.Effects[heFrozen] > 255) then |
1084 |
Gear^.Hedgehog^.Effects[heFrozen]:= max(255,Gear^.Hedgehog^.Effects[heFrozen]-10000); |
|
1085 |
tmpDmg:= ModifyDamage(Damage, Gear); |
|
1086 |
if (Gear^.State and gstNoDamage) = 0 then |
|
1087 |
begin |
|
1088 |
||
10015 | 1089 |
if (Ammo^.Kind = gtDEagleShot) or (Ammo^.Kind = gtSniperRifleShot) then |
9285 | 1090 |
begin |
1091 |
VGear := AddVisualGear(hwround(Ammo^.X), hwround(Ammo^.Y), vgtBulletHit); |
|
1092 |
if VGear <> nil then |
|
1093 |
VGear^.Angle := DxDy2Angle(-Ammo^.dX, Ammo^.dY); |
|
1094 |
end; |
|
1095 |
||
1096 |
if (Gear^.Kind = gtHedgehog) and (Ammo^.State and gsttmpFlag <> 0) and (Ammo^.Kind = gtShover) then |
|
1097 |
Gear^.FlightTime:= 1; |
|
1098 |
||
1099 |
||
1100 |
case Gear^.Kind of |
|
1101 |
gtHedgehog, |
|
1102 |
gtMine, |
|
1103 |
gtSMine, |
|
1104 |
gtKnife, |
|
1105 |
gtTarget, |
|
1106 |
gtCase, |
|
1107 |
gtExplosives: //, |
|
1108 |
//gtStructure: |
|
1109 |
begin |
|
1110 |
if (Ammo^.Kind = gtDrill) then |
|
1111 |
begin |
|
1112 |
Ammo^.Timer:= 0; |
|
1113 |
exit; |
|
1114 |
end; |
|
10011
ead5e4b21671
Add check for gear kind of hedgehog on invulnerability effect. This probably fixes bug #766, is similar to change in previous r2a1483d91977 and was introduced by r7d925e82e572
nemo
parents:
10010
diff
changeset
|
1115 |
if (Gear^.Kind <> gtHedgehog) or (Gear^.Hedgehog^.Effects[heInvulnerable] = 0) then |
9285 | 1116 |
begin |
1117 |
if (Ammo^.Kind = gtKnife) and (tmpDmg > 0) then |
|
1118 |
for j:= 1 to max(1,min(3,tmpDmg div 5)) do |
|
1119 |
begin |
|
1120 |
VGear:= AddVisualGear(hwRound(Ammo^.X-((Ammo^.X-Gear^.X)/_2)), hwRound(Ammo^.Y-((Ammo^.Y-Gear^.Y)/_2)), vgtStraightShot); |
|
1121 |
if VGear <> nil then |
|
1122 |
with VGear^ do |
|
1123 |
begin |
|
1124 |
Tint:= $FFCC00FF; |
|
1125 |
Angle:= random(360); |
|
1126 |
dx:= 0.0005 * (random(100)); |
|
1127 |
dy:= 0.0005 * (random(100)); |
|
1128 |
if random(2) = 0 then |
|
1129 |
dx := -dx; |
|
1130 |
if random(2) = 0 then |
|
1131 |
dy := -dy; |
|
1132 |
FrameTicks:= 600+random(200); |
|
1133 |
State:= ord(sprStar) |
|
1134 |
end |
|
1135 |
end; |
|
1136 |
ApplyDamage(Gear, Ammo^.Hedgehog, tmpDmg, dsShove) |
|
1137 |
end |
|
1138 |
else |
|
1139 |
Gear^.State:= Gear^.State or gstWinner; |
|
10015 | 1140 |
if (Gear^.Kind = gtExplosives) and (Ammo^.Kind = gtBlowtorch) then |
9285 | 1141 |
begin |
1142 |
if (Ammo^.Hedgehog^.Gear <> nil) then |
|
1143 |
Ammo^.Hedgehog^.Gear^.State:= Ammo^.Hedgehog^.Gear^.State and (not gstNotKickable); |
|
1144 |
ApplyDamage(Gear, Ammo^.Hedgehog, tmpDmg * 100, dsUnknown); // crank up damage for explosives + blowtorch |
|
1145 |
end; |
|
1146 |
||
1147 |
if (Gear^.Kind = gtHedgehog) and (Gear^.Hedgehog^.King or (Gear^.Hedgehog^.Effects[heFrozen] > 0)) then |
|
1148 |
begin |
|
1149 |
Gear^.dX:= Ammo^.dX * Power * _0_005; |
|
1150 |
Gear^.dY:= Ammo^.dY * Power * _0_005 |
|
1151 |
end |
|
1152 |
else if ((Ammo^.Kind <> gtFlame) or (Gear^.Kind = gtHedgehog)) and (Power <> 0) then |
|
1153 |
begin |
|
1154 |
Gear^.dX:= Ammo^.dX * Power * _0_01; |
|
1155 |
Gear^.dY:= Ammo^.dY * Power * _0_01 |
|
1156 |
end; |
|
1157 |
||
1158 |
if (not isZero(Gear^.dX)) or (not isZero(Gear^.dY)) then |
|
1159 |
begin |
|
1160 |
Gear^.Active:= true; |
|
1161 |
DeleteCI(Gear); |
|
1162 |
Gear^.State:= Gear^.State or gstMoving; |
|
1163 |
if Gear^.Kind = gtKnife then Gear^.State:= Gear^.State and (not gstCollision); |
|
1164 |
// move the gear upwards a bit to throw it over tiny obstacles at start |
|
9706
5178d2263521
return land word from uCollisions to make decisions based on it. Should be handy for trampoline.
nemo
parents:
9685
diff
changeset
|
1165 |
if TestCollisionXwithGear(Gear, hwSign(Gear^.dX)) <> 0 then |
9285 | 1166 |
begin |
9706
5178d2263521
return land word from uCollisions to make decisions based on it. Should be handy for trampoline.
nemo
parents:
9685
diff
changeset
|
1167 |
if (TestCollisionXwithXYShift(Gear, _0, -3, hwSign(Gear^.dX)) = 0) and |
5178d2263521
return land word from uCollisions to make decisions based on it. Should be handy for trampoline.
nemo
parents:
9685
diff
changeset
|
1168 |
(TestCollisionYwithGear(Gear, -1) = 0) then |
9285 | 1169 |
Gear^.Y:= Gear^.Y - _1; |
9706
5178d2263521
return land word from uCollisions to make decisions based on it. Should be handy for trampoline.
nemo
parents:
9685
diff
changeset
|
1170 |
if (TestCollisionXwithXYShift(Gear, _0, -2, hwSign(Gear^.dX)) = 0) and |
5178d2263521
return land word from uCollisions to make decisions based on it. Should be handy for trampoline.
nemo
parents:
9685
diff
changeset
|
1171 |
(TestCollisionYwithGear(Gear, -1) = 0) then |
9285 | 1172 |
Gear^.Y:= Gear^.Y - _1; |
9706
5178d2263521
return land word from uCollisions to make decisions based on it. Should be handy for trampoline.
nemo
parents:
9685
diff
changeset
|
1173 |
if (TestCollisionXwithXYShift(Gear, _0, -1, hwSign(Gear^.dX)) = 0) and |
5178d2263521
return land word from uCollisions to make decisions based on it. Should be handy for trampoline.
nemo
parents:
9685
diff
changeset
|
1174 |
(TestCollisionYwithGear(Gear, -1) = 0) then |
9285 | 1175 |
Gear^.Y:= Gear^.Y - _1; |
1176 |
end |
|
1177 |
end; |
|
1178 |
||
1179 |
||
1180 |
if (Ammo^.Kind <> gtFlame) or ((Ammo^.State and gsttmpFlag) = 0) then |
|
1181 |
FollowGear:= Gear |
|
1182 |
end; |
|
1183 |
end |
|
1184 |
end; |
|
1185 |
end; |
|
1186 |
if i <> 0 then |
|
1187 |
SetAllToActive |
|
1188 |
end; |
|
1189 |
||
1190 |
||
1191 |
function CountGears(Kind: TGearType): Longword; |
|
1192 |
var t: PGear; |
|
1193 |
count: Longword = 0; |
|
1194 |
begin |
|
1195 |
||
1196 |
t:= GearsList; |
|
1197 |
while t <> nil do |
|
1198 |
begin |
|
1199 |
if t^.Kind = Kind then |
|
1200 |
inc(count); |
|
1201 |
t:= t^.NextGear |
|
1202 |
end; |
|
1203 |
CountGears:= count; |
|
1204 |
end; |
|
1205 |
||
1206 |
procedure SetAllToActive; |
|
1207 |
var t: PGear; |
|
1208 |
begin |
|
1209 |
AllInactive:= false; |
|
1210 |
t:= GearsList; |
|
1211 |
while t <> nil do |
|
1212 |
begin |
|
1213 |
t^.Active:= true; |
|
1214 |
t:= t^.NextGear |
|
1215 |
end |
|
1216 |
end; |
|
1217 |
||
1218 |
procedure SetAllHHToActive; inline; |
|
1219 |
begin |
|
1220 |
SetAllHHToActive(true) |
|
1221 |
end; |
|
1222 |
||
1223 |
||
1224 |
procedure SetAllHHToActive(Ice: boolean); |
|
1225 |
var t: PGear; |
|
1226 |
begin |
|
1227 |
AllInactive:= false; |
|
1228 |
t:= GearsList; |
|
1229 |
while t <> nil do |
|
1230 |
begin |
|
1231 |
if (t^.Kind = gtHedgehog) or (t^.Kind = gtExplosives) then |
|
1232 |
begin |
|
1233 |
if (t^.Kind = gtHedgehog) and Ice then CheckIce(t); |
|
1234 |
t^.Active:= true |
|
1235 |
end; |
|
1236 |
t:= t^.NextGear |
|
1237 |
end |
|
1238 |
end; |
|
1239 |
||
1240 |
||
1241 |
var GearsNearArray : TPGearArray; |
|
1242 |
function GearsNear(X, Y: hwFloat; Kind: TGearType; r: LongInt): PGearArrayS; |
|
1243 |
var |
|
1244 |
t: PGear; |
|
1245 |
s: Longword; |
|
1246 |
begin |
|
1247 |
r:= r*r; |
|
1248 |
s:= 0; |
|
1249 |
SetLength(GearsNearArray, s); |
|
1250 |
t := GearsList; |
|
10015 | 1251 |
while t <> nil do |
9285 | 1252 |
begin |
10015 | 1253 |
if (t^.Kind = Kind) |
9285 | 1254 |
and ((X - t^.X)*(X - t^.X) + (Y - t^.Y)*(Y-t^.Y) < int2hwFloat(r)) then |
1255 |
begin |
|
1256 |
inc(s); |
|
1257 |
SetLength(GearsNearArray, s); |
|
1258 |
GearsNearArray[s - 1] := t; |
|
1259 |
end; |
|
1260 |
t := t^.NextGear; |
|
1261 |
end; |
|
1262 |
||
1263 |
GearsNear.size:= s; |
|
1264 |
GearsNear.ar:= @GearsNearArray |
|
1265 |
end; |
|
1266 |
||
1267 |
||
1268 |
procedure SpawnBoxOfSmth; |
|
1269 |
var t, aTot, uTot, a, h: LongInt; |
|
1270 |
i: TAmmoType; |
|
1271 |
begin |
|
1272 |
if (PlacingHogs) or |
|
1273 |
(cCaseFactor = 0) |
|
1274 |
or (CountGears(gtCase) >= 5) |
|
1275 |
or (GetRandom(cCaseFactor) <> 0) then |
|
1276 |
exit; |
|
1277 |
||
1278 |
FollowGear:= nil; |
|
1279 |
aTot:= 0; |
|
1280 |
uTot:= 0; |
|
1281 |
for i:= Low(TAmmoType) to High(TAmmoType) do |
|
1282 |
if (Ammoz[i].Ammo.Propz and ammoprop_Utility) = 0 then |
|
1283 |
inc(aTot, Ammoz[i].Probability) |
|
1284 |
else |
|
1285 |
inc(uTot, Ammoz[i].Probability); |
|
1286 |
||
1287 |
t:=0; |
|
1288 |
a:=aTot; |
|
1289 |
h:= 1; |
|
1290 |
||
1291 |
if (aTot+uTot) <> 0 then |
|
1292 |
if ((GameFlags and gfInvulnerable) = 0) then |
|
1293 |
begin |
|
1294 |
h:= cHealthCaseProb * 100; |
|
1295 |
t:= GetRandom(10000); |
|
1296 |
a:= (10000-h)*aTot div (aTot+uTot) |
|
1297 |
end |
|
1298 |
else |
|
1299 |
begin |
|
1300 |
t:= GetRandom(aTot+uTot); |
|
1301 |
h:= 0 |
|
1302 |
end; |
|
1303 |
||
1304 |
||
1305 |
if t<h then |
|
1306 |
begin |
|
1307 |
FollowGear:= AddGear(0, 0, gtCase, 0, _0, _0, 0); |
|
1308 |
FollowGear^.Health:= cHealthCaseAmount; |
|
1309 |
FollowGear^.Pos:= posCaseHealth; |
|
10506 | 1310 |
// health crate is smaller than the other crates |
1311 |
FollowGear^.Radius := cCaseHealthRadius; |
|
9285 | 1312 |
AddCaption(GetEventString(eidNewHealthPack), cWhiteColor, capgrpAmmoInfo); |
1313 |
end |
|
1314 |
else if (t<a+h) then |
|
1315 |
begin |
|
1316 |
t:= aTot; |
|
1317 |
if (t > 0) then |
|
1318 |
begin |
|
1319 |
FollowGear:= AddGear(0, 0, gtCase, 0, _0, _0, 0); |
|
1320 |
t:= GetRandom(t); |
|
1321 |
i:= Low(TAmmoType); |
|
1322 |
FollowGear^.Pos:= posCaseAmmo; |
|
1323 |
FollowGear^.AmmoType:= i; |
|
1324 |
AddCaption(GetEventString(eidNewAmmoPack), cWhiteColor, capgrpAmmoInfo); |
|
1325 |
end |
|
1326 |
end |
|
1327 |
else |
|
1328 |
begin |
|
1329 |
t:= uTot; |
|
1330 |
if (t > 0) then |
|
1331 |
begin |
|
1332 |
FollowGear:= AddGear(0, 0, gtCase, 0, _0, _0, 0); |
|
1333 |
t:= GetRandom(t); |
|
1334 |
i:= Low(TAmmoType); |
|
1335 |
FollowGear^.Pos:= posCaseUtility; |
|
1336 |
FollowGear^.AmmoType:= i; |
|
1337 |
AddCaption(GetEventString(eidNewUtilityPack), cWhiteColor, capgrpAmmoInfo); |
|
1338 |
end |
|
1339 |
end; |
|
1340 |
||
1341 |
// handles case of no ammo or utility crates - considered also placing booleans in uAmmos and altering probabilities |
|
1342 |
if (FollowGear <> nil) then |
|
1343 |
begin |
|
1344 |
FindPlace(FollowGear, true, 0, LAND_WIDTH); |
|
1345 |
||
1346 |
if (FollowGear <> nil) then |
|
1347 |
AddVoice(sndReinforce, CurrentTeam^.voicepack) |
|
1348 |
end |
|
1349 |
end; |
|
1350 |
||
1351 |
||
1352 |
function GetAmmo(Hedgehog: PHedgehog): TAmmoType; |
|
1353 |
var t, aTot: LongInt; |
|
1354 |
i: TAmmoType; |
|
1355 |
begin |
|
1356 |
Hedgehog:= Hedgehog; // avoid hint |
|
1357 |
||
1358 |
aTot:= 0; |
|
1359 |
for i:= Low(TAmmoType) to High(TAmmoType) do |
|
1360 |
if (Ammoz[i].Ammo.Propz and ammoprop_Utility) = 0 then |
|
1361 |
inc(aTot, Ammoz[i].Probability); |
|
1362 |
||
1363 |
t:= aTot; |
|
1364 |
i:= Low(TAmmoType); |
|
1365 |
if (t > 0) then |
|
1366 |
begin |
|
1367 |
t:= GetRandom(t); |
|
1368 |
while t >= 0 do |
|
1369 |
begin |
|
1370 |
inc(i); |
|
1371 |
if (Ammoz[i].Ammo.Propz and ammoprop_Utility) = 0 then |
|
1372 |
dec(t, Ammoz[i].Probability) |
|
1373 |
end |
|
1374 |
end; |
|
1375 |
GetAmmo:= i |
|
1376 |
end; |
|
1377 |
||
1378 |
function GetUtility(Hedgehog: PHedgehog): TAmmoType; |
|
1379 |
var t, uTot: LongInt; |
|
1380 |
i: TAmmoType; |
|
1381 |
begin |
|
1382 |
||
1383 |
uTot:= 0; |
|
1384 |
for i:= Low(TAmmoType) to High(TAmmoType) do |
|
1385 |
if ((Ammoz[i].Ammo.Propz and ammoprop_Utility) <> 0) |
|
1386 |
and ((Hedgehog^.Team^.HedgehogsNumber > 1) or (Ammoz[i].Ammo.AmmoType <> amSwitch)) then |
|
1387 |
inc(uTot, Ammoz[i].Probability); |
|
1388 |
||
1389 |
t:= uTot; |
|
1390 |
i:= Low(TAmmoType); |
|
1391 |
if (t > 0) then |
|
1392 |
begin |
|
1393 |
t:= GetRandom(t); |
|
1394 |
while t >= 0 do |
|
1395 |
begin |
|
1396 |
inc(i); |
|
1397 |
if ((Ammoz[i].Ammo.Propz and ammoprop_Utility) <> 0) and ((Hedgehog^.Team^.HedgehogsNumber > 1) |
|
1398 |
or (Ammoz[i].Ammo.AmmoType <> amSwitch)) then |
|
1399 |
dec(t, Ammoz[i].Probability) |
|
1400 |
end |
|
1401 |
end; |
|
1402 |
GetUtility:= i |
|
1403 |
end; |
|
1404 |
||
9473
a51a69094c24
partial implementation of non-infinite world (edge wrap/warp/bounce)
nemo
parents:
9285
diff
changeset
|
1405 |
(* |
a51a69094c24
partial implementation of non-infinite world (edge wrap/warp/bounce)
nemo
parents:
9285
diff
changeset
|
1406 |
Intended to check Gear X/Y against the map left/right edges and apply one of the world modes |
a51a69094c24
partial implementation of non-infinite world (edge wrap/warp/bounce)
nemo
parents:
9285
diff
changeset
|
1407 |
* Normal - infinite world, do nothing |
a51a69094c24
partial implementation of non-infinite world (edge wrap/warp/bounce)
nemo
parents:
9285
diff
changeset
|
1408 |
* Wrap (entering left edge exits at same height on right edge) |
a51a69094c24
partial implementation of non-infinite world (edge wrap/warp/bounce)
nemo
parents:
9285
diff
changeset
|
1409 |
* Bounce (striking edge is treated as a 100% elasticity bounce) |
a51a69094c24
partial implementation of non-infinite world (edge wrap/warp/bounce)
nemo
parents:
9285
diff
changeset
|
1410 |
* From the depths (same as from sky, but from sea, with submersible flag set) |
a51a69094c24
partial implementation of non-infinite world (edge wrap/warp/bounce)
nemo
parents:
9285
diff
changeset
|
1411 |
|
a51a69094c24
partial implementation of non-infinite world (edge wrap/warp/bounce)
nemo
parents:
9285
diff
changeset
|
1412 |
Trying to make the checks a little broader than on first pass to catch things that don't move normally. |
a51a69094c24
partial implementation of non-infinite world (edge wrap/warp/bounce)
nemo
parents:
9285
diff
changeset
|
1413 |
*) |
a51a69094c24
partial implementation of non-infinite world (edge wrap/warp/bounce)
nemo
parents:
9285
diff
changeset
|
1414 |
function WorldWrap(var Gear: PGear): boolean; |
10354 | 1415 |
//var tdx: hwFloat; |
9473
a51a69094c24
partial implementation of non-infinite world (edge wrap/warp/bounce)
nemo
parents:
9285
diff
changeset
|
1416 |
begin |
a51a69094c24
partial implementation of non-infinite world (edge wrap/warp/bounce)
nemo
parents:
9285
diff
changeset
|
1417 |
WorldWrap:= false; |
a51a69094c24
partial implementation of non-infinite world (edge wrap/warp/bounce)
nemo
parents:
9285
diff
changeset
|
1418 |
if WorldEdge = weNone then exit(false); |
10160 | 1419 |
if (hwRound(Gear^.X) < LongInt(leftX)) or |
1420 |
(hwRound(Gear^.X) > LongInt(rightX)) then |
|
9473
a51a69094c24
partial implementation of non-infinite world (edge wrap/warp/bounce)
nemo
parents:
9285
diff
changeset
|
1421 |
begin |
a51a69094c24
partial implementation of non-infinite world (edge wrap/warp/bounce)
nemo
parents:
9285
diff
changeset
|
1422 |
if WorldEdge = weWrap then |
a51a69094c24
partial implementation of non-infinite world (edge wrap/warp/bounce)
nemo
parents:
9285
diff
changeset
|
1423 |
begin |
10160 | 1424 |
if (hwRound(Gear^.X) < LongInt(leftX)) then |
1425 |
Gear^.X:= Gear^.X + int2hwfloat(rightX - leftX) |
|
1426 |
else Gear^.X:= Gear^.X - int2hwfloat(rightX - leftX); |
|
9557 | 1427 |
LeftImpactTimer:= 150; |
1428 |
RightImpactTimer:= 150 |
|
9473
a51a69094c24
partial implementation of non-infinite world (edge wrap/warp/bounce)
nemo
parents:
9285
diff
changeset
|
1429 |
end |
a51a69094c24
partial implementation of non-infinite world (edge wrap/warp/bounce)
nemo
parents:
9285
diff
changeset
|
1430 |
else if WorldEdge = weBounce then |
a51a69094c24
partial implementation of non-infinite world (edge wrap/warp/bounce)
nemo
parents:
9285
diff
changeset
|
1431 |
begin |
9809 | 1432 |
if (hwRound(Gear^.X) - Gear^.Radius < LongInt(leftX)) then |
9473
a51a69094c24
partial implementation of non-infinite world (edge wrap/warp/bounce)
nemo
parents:
9285
diff
changeset
|
1433 |
begin |
9557 | 1434 |
LeftImpactTimer:= 333; |
9473
a51a69094c24
partial implementation of non-infinite world (edge wrap/warp/bounce)
nemo
parents:
9285
diff
changeset
|
1435 |
Gear^.dX.isNegative:= false; |
9809 | 1436 |
Gear^.X:= int2hwfloat(LongInt(leftX) + Gear^.Radius) |
9473
a51a69094c24
partial implementation of non-infinite world (edge wrap/warp/bounce)
nemo
parents:
9285
diff
changeset
|
1437 |
end |
10015 | 1438 |
else |
9473
a51a69094c24
partial implementation of non-infinite world (edge wrap/warp/bounce)
nemo
parents:
9285
diff
changeset
|
1439 |
begin |
9557 | 1440 |
RightImpactTimer:= 333; |
9473
a51a69094c24
partial implementation of non-infinite world (edge wrap/warp/bounce)
nemo
parents:
9285
diff
changeset
|
1441 |
Gear^.dX.isNegative:= true; |
9485
3dee8a3b0406
add shotgun wrap, revert 100px offset. Problematic w/ things that rely on Land.
nemo
parents:
9479
diff
changeset
|
1442 |
Gear^.X:= int2hwfloat(rightX-Gear^.Radius) |
9557 | 1443 |
end; |
9561 | 1444 |
if (Gear^.Radius > 2) and (Gear^.dX.QWordValue > _0_001.QWordValue) then |
10508 | 1445 |
AddBounceEffectForGear(Gear); |
10354 | 1446 |
end{ |
9473
a51a69094c24
partial implementation of non-infinite world (edge wrap/warp/bounce)
nemo
parents:
9285
diff
changeset
|
1447 |
else if WorldEdge = weSea then |
a51a69094c24
partial implementation of non-infinite world (edge wrap/warp/bounce)
nemo
parents:
9285
diff
changeset
|
1448 |
begin |
a51a69094c24
partial implementation of non-infinite world (edge wrap/warp/bounce)
nemo
parents:
9285
diff
changeset
|
1449 |
if (hwRound(Gear^.Y) > cWaterLine) and (Gear^.State and gstSubmersible <> 0) then |
9521
8054d9d775fd
merge with latest defaul, fixing compiling with fpc, parsing and rendering with pas2c, some minor problems with compiling with clang
koda
diff
changeset
|
1450 |
Gear^.State:= Gear^.State and (not gstSubmersible) |
9473
a51a69094c24
partial implementation of non-infinite world (edge wrap/warp/bounce)
nemo
parents:
9285
diff
changeset
|
1451 |
else |
a51a69094c24
partial implementation of non-infinite world (edge wrap/warp/bounce)
nemo
parents:
9285
diff
changeset
|
1452 |
begin |
a51a69094c24
partial implementation of non-infinite world (edge wrap/warp/bounce)
nemo
parents:
9285
diff
changeset
|
1453 |
Gear^.State:= Gear^.State or gstSubmersible; |
a51a69094c24
partial implementation of non-infinite world (edge wrap/warp/bounce)
nemo
parents:
9285
diff
changeset
|
1454 |
Gear^.X:= int2hwFloat(PlayWidth)*int2hwFloat(min(max(0,hwRound(Gear^.Y)),PlayHeight))/PlayHeight; |
a51a69094c24
partial implementation of non-infinite world (edge wrap/warp/bounce)
nemo
parents:
9285
diff
changeset
|
1455 |
Gear^.Y:= int2hwFloat(cWaterLine+cVisibleWater+Gear^.Radius*2); |
a51a69094c24
partial implementation of non-infinite world (edge wrap/warp/bounce)
nemo
parents:
9285
diff
changeset
|
1456 |
tdx:= Gear^.dX; |
9522 | 1457 |
Gear^.dX:= -Gear^.dY; |
9473
a51a69094c24
partial implementation of non-infinite world (edge wrap/warp/bounce)
nemo
parents:
9285
diff
changeset
|
1458 |
Gear^.dY:= tdx; |
a51a69094c24
partial implementation of non-infinite world (edge wrap/warp/bounce)
nemo
parents:
9285
diff
changeset
|
1459 |
Gear^.dY.isNegative:= true |
a51a69094c24
partial implementation of non-infinite world (edge wrap/warp/bounce)
nemo
parents:
9285
diff
changeset
|
1460 |
end |
10354 | 1461 |
end}; |
9473
a51a69094c24
partial implementation of non-infinite world (edge wrap/warp/bounce)
nemo
parents:
9285
diff
changeset
|
1462 |
(* |
a51a69094c24
partial implementation of non-infinite world (edge wrap/warp/bounce)
nemo
parents:
9285
diff
changeset
|
1463 |
* Window in the sky (Gear moved high into the sky, Y is used to determine X) [unfortunately, not a safe thing to do. shame, I thought aerial bombardment would be kinda neat |
a51a69094c24
partial implementation of non-infinite world (edge wrap/warp/bounce)
nemo
parents:
9285
diff
changeset
|
1464 |
This one would be really easy to freeze game unless it was flagged unfortunately. |
a51a69094c24
partial implementation of non-infinite world (edge wrap/warp/bounce)
nemo
parents:
9285
diff
changeset
|
1465 |
|
10015 | 1466 |
else |
9473
a51a69094c24
partial implementation of non-infinite world (edge wrap/warp/bounce)
nemo
parents:
9285
diff
changeset
|
1467 |
begin |
a51a69094c24
partial implementation of non-infinite world (edge wrap/warp/bounce)
nemo
parents:
9285
diff
changeset
|
1468 |
Gear^.X:= int2hwFloat(PlayWidth)*int2hwFloat(min(max(0,hwRound(Gear^.Y)),PlayHeight))/PlayHeight; |
a51a69094c24
partial implementation of non-infinite world (edge wrap/warp/bounce)
nemo
parents:
9285
diff
changeset
|
1469 |
Gear^.Y:= -_2048-_256-_256; |
a51a69094c24
partial implementation of non-infinite world (edge wrap/warp/bounce)
nemo
parents:
9285
diff
changeset
|
1470 |
tdx:= Gear^.dX; |
a51a69094c24
partial implementation of non-infinite world (edge wrap/warp/bounce)
nemo
parents:
9285
diff
changeset
|
1471 |
Gear^.dX:= Gear^.dY; |
a51a69094c24
partial implementation of non-infinite world (edge wrap/warp/bounce)
nemo
parents:
9285
diff
changeset
|
1472 |
Gear^.dY:= tdx; |
a51a69094c24
partial implementation of non-infinite world (edge wrap/warp/bounce)
nemo
parents:
9285
diff
changeset
|
1473 |
Gear^.dY.isNegative:= false |
a51a69094c24
partial implementation of non-infinite world (edge wrap/warp/bounce)
nemo
parents:
9285
diff
changeset
|
1474 |
end |
a51a69094c24
partial implementation of non-infinite world (edge wrap/warp/bounce)
nemo
parents:
9285
diff
changeset
|
1475 |
*) |
a51a69094c24
partial implementation of non-infinite world (edge wrap/warp/bounce)
nemo
parents:
9285
diff
changeset
|
1476 |
WorldWrap:= true |
a51a69094c24
partial implementation of non-infinite world (edge wrap/warp/bounce)
nemo
parents:
9285
diff
changeset
|
1477 |
end; |
a51a69094c24
partial implementation of non-infinite world (edge wrap/warp/bounce)
nemo
parents:
9285
diff
changeset
|
1478 |
end; |
9285 | 1479 |
|
10508 | 1480 |
procedure AddBounceEffectForGear(Gear: PGear); |
1481 |
var boing: PVisualGear; |
|
1482 |
begin |
|
1483 |
boing:= AddVisualGear(hwRound(Gear^.X), hwRound(Gear^.Y), vgtStraightShot, 0, false, 1); |
|
1484 |
if boing <> nil then |
|
1485 |
with boing^ do |
|
1486 |
begin |
|
1487 |
Angle:= random(360); |
|
1488 |
dx:= 0; |
|
1489 |
dy:= 0; |
|
1490 |
FrameTicks:= 200; |
|
1491 |
Scale:= hwFloat2Float(Gear^.Density * hwAbs(Gear^.dY) + hwAbs(Gear^.dX)) / 1.5; |
|
1492 |
State:= ord(sprBoing) |
|
1493 |
end; |
|
1494 |
PlaySound(sndMelonImpact, true) |
|
1495 |
end; |
|
1496 |
||
6581 | 1497 |
end. |