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