author | nemo |
Sun, 04 Oct 2015 16:30:55 -0400 | |
changeset 11201 | 8e0e3b79efa3 |
parent 11197 | 283b6e6cf7ea |
child 11477 | c55b3e09a04e |
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; |
|
11197
283b6e6cf7ea
Scan from right too. Not sure this is actually helpful, so committing separately.
nemo
parents:
11196
diff
changeset
|
832 |
y, sy, dir: 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 |
|
11197
283b6e6cf7ea
Scan from right too. Not sure this is actually helpful, so committing separately.
nemo
parents:
11196
diff
changeset
|
853 |
if GetRandom(2) = 0 then dir:= -1 else dir:= 1; |
283b6e6cf7ea
Scan from right too. Not sure this is actually helpful, so committing separately.
nemo
parents:
11196
diff
changeset
|
854 |
x:= max(LAND_WIDTH div 2048, LongInt(GetRandom(Delta))); |
283b6e6cf7ea
Scan from right too. Not sure this is actually helpful, so committing separately.
nemo
parents:
11196
diff
changeset
|
855 |
if dir = 1 then x:= Left + x else x:= Right - x; |
6581 | 856 |
repeat |
857 |
cnt:= 0; |
|
9809 | 858 |
y:= min(1024, topY) - Gear^.Radius shl 1; |
6581 | 859 |
while y < cWaterLine do |
860 |
begin |
|
861 |
repeat |
|
862 |
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
|
863 |
until (y >= cWaterLine) or |
10015 | 864 |
((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
|
865 |
(ignoreOverlap and (CountNonZeroz(x, y, Gear^.Radius - 1, 1, lfLandMask) = 0)); |
6581 | 866 |
|
867 |
sy:= y; |
|
868 |
||
869 |
repeat |
|
870 |
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
|
871 |
until (y >= cWaterLine) or |
10015 | 872 |
((not ignoreOverlap) and (CountNonZeroz(x, y, Gear^.Radius - 1, 1, $FFFF) <> 0)) or |
873 |
(ignoreOverlap and (CountNonZeroz(x, y, Gear^.Radius - 1, 1, lfLandMask) <> 0)); |
|
6581 | 874 |
|
10272
31ee88c9b4d0
Allow barrels to spawn in U-shaped pits in stable position
unc0rr
parents:
10245
diff
changeset
|
875 |
if (y - sy > Gear^.Radius * 2) and (y < cWaterLine) |
6581 | 876 |
and (((Gear^.Kind = gtExplosives) |
10272
31ee88c9b4d0
Allow barrels to spawn in U-shaped pits in stable position
unc0rr
parents:
10245
diff
changeset
|
877 |
and (ignoreNearObjects or NoGearsToAvoid(x, y - Gear^.Radius, 60, 60)) |
10274 | 878 |
and (isSteadyPosition(x, y+1, Gear^.Radius - 1, 3, $FFFF) |
879 |
or (CountNonZeroz(x, y+1, Gear^.Radius - 1, Gear^.Radius+1, $FFFF) > Gear^.Radius) |
|
880 |
)) |
|
10272
31ee88c9b4d0
Allow barrels to spawn in U-shaped pits in stable position
unc0rr
parents:
10245
diff
changeset
|
881 |
or |
31ee88c9b4d0
Allow barrels to spawn in U-shaped pits in stable position
unc0rr
parents:
10245
diff
changeset
|
882 |
((Gear^.Kind <> gtExplosives) |
31ee88c9b4d0
Allow barrels to spawn in U-shaped pits in stable position
unc0rr
parents:
10245
diff
changeset
|
883 |
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
|
884 |
)) then |
6888 | 885 |
begin |
6581 | 886 |
ar[cnt].X:= x; |
887 |
if withFall then |
|
888 |
ar[cnt].Y:= sy + Gear^.Radius |
|
889 |
else |
|
890 |
ar[cnt].Y:= y - Gear^.Radius; |
|
891 |
inc(cnt) |
|
892 |
end; |
|
893 |
||
7603
e9c3c67b5dfd
reducing this value is sufficient to ensure crates drop just below top border or a girder
nemo
parents:
7599
diff
changeset
|
894 |
inc(y, 10) |
6581 | 895 |
end; |
896 |
||
897 |
if cnt > 0 then |
|
10015 | 898 |
begin |
899 |
temp := ar[GetRandom(cnt)]; |
|
900 |
with temp do |
|
6581 | 901 |
begin |
902 |
ar2[cnt2].x:= x; |
|
903 |
ar2[cnt2].y:= y; |
|
904 |
inc(cnt2) |
|
11197
283b6e6cf7ea
Scan from right too. Not sure this is actually helpful, so committing separately.
nemo
parents:
11196
diff
changeset
|
905 |
end; |
11196
0f6916065849
This should probably fix feedback that hogs weren't spawning on left side of map.
nemo
parents:
11046
diff
changeset
|
906 |
end; |
11197
283b6e6cf7ea
Scan from right too. Not sure this is actually helpful, so committing separately.
nemo
parents:
11196
diff
changeset
|
907 |
inc(x, Delta*dir) |
283b6e6cf7ea
Scan from right too. Not sure this is actually helpful, so committing separately.
nemo
parents:
11196
diff
changeset
|
908 |
until ((dir = 1) and (x > Right)) or ((dir = -1) and (x < Left)); |
6581 | 909 |
|
910 |
dec(Delta, 60) |
|
911 |
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
|
912 |
// 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
|
913 |
if (cnt2 = 0) and skipProximity and (not ignoreOverlap) then |
6581 | 914 |
tryAgain:= true |
915 |
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
|
916 |
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
|
917 |
ignoreNearObjects:= true; |
6581 | 918 |
end; |
919 |
||
920 |
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
|
921 |
begin |
4a4f21070479
merge xymeng's gsoc engine with a few updates (and further checks on symbol definitions)
koda
parents:
8007
diff
changeset
|
922 |
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
|
923 |
with temp do |
6581 | 924 |
begin |
925 |
Gear^.X:= int2hwFloat(x); |
|
926 |
Gear^.Y:= int2hwFloat(y); |
|
927 |
AddFileLog('Assigned Gear coordinates (' + inttostr(x) + ',' + inttostr(y) + ')'); |
|
928 |
end |
|
8026
4a4f21070479
merge xymeng's gsoc engine with a few updates (and further checks on symbol definitions)
koda
parents:
8007
diff
changeset
|
929 |
end |
6581 | 930 |
else |
931 |
begin |
|
932 |
OutError('Can''t find place for Gear', false); |
|
933 |
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
|
934 |
Gear^.Hedgehog^.Effects[heResurrectable] := 0; |
6581 | 935 |
DeleteGear(Gear); |
936 |
Gear:= nil |
|
937 |
end |
|
938 |
end; |
|
939 |
||
940 |
function CheckGearNear(Gear: PGear; Kind: TGearType; rX, rY: LongInt): PGear; |
|
941 |
var t: PGear; |
|
942 |
begin |
|
943 |
t:= GearsList; |
|
944 |
rX:= sqr(rX); |
|
945 |
rY:= sqr(rY); |
|
946 |
||
947 |
while t <> nil do |
|
948 |
begin |
|
949 |
if (t <> Gear) and (t^.Kind = Kind) then |
|
950 |
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
|
951 |
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
|
952 |
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
|
953 |
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
|
954 |
end; |
6581 | 955 |
t:= t^.NextGear |
956 |
end; |
|
957 |
||
958 |
CheckGearNear:= nil |
|
959 |
end; |
|
960 |
||
7592 | 961 |
procedure CheckCollision(Gear: PGear); inline; |
962 |
begin |
|
9706
5178d2263521
return land word from uCollisions to make decisions based on it. Should be handy for trampoline.
nemo
parents:
9685
diff
changeset
|
963 |
if (TestCollisionXwithGear(Gear, hwSign(Gear^.dX)) <> 0) |
7592 | 964 |
or (TestCollisionYwithGear(Gear, hwSign(Gear^.dY)) <> 0) then |
965 |
Gear^.State := Gear^.State or gstCollision |
|
966 |
else |
|
967 |
Gear^.State := Gear^.State and (not gstCollision) |
|
968 |
end; |
|
969 |
||
970 |
procedure CheckCollisionWithLand(Gear: PGear); inline; |
|
971 |
begin |
|
9706
5178d2263521
return land word from uCollisions to make decisions based on it. Should be handy for trampoline.
nemo
parents:
9685
diff
changeset
|
972 |
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
|
973 |
or (TestCollisionY(Gear, hwSign(Gear^.dY)) <> 0) then |
7592 | 974 |
Gear^.State := Gear^.State or gstCollision |
8330 | 975 |
else |
7592 | 976 |
Gear^.State := Gear^.State and (not gstCollision) |
977 |
end; |
|
978 |
||
7719
eeae1cb6b6bf
Move hedgehog's step routine into separate function, use it in both hedgehog and ai code
unc0rr
parents:
7627
diff
changeset
|
979 |
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
|
980 |
begin |
9706
5178d2263521
return land word from uCollisions to make decisions based on it. Should be handy for trampoline.
nemo
parents:
9685
diff
changeset
|
981 |
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
|
982 |
begin |
eeae1cb6b6bf
Move hedgehog's step routine into separate function, use it in both hedgehog and ai code
unc0rr
parents:
7627
diff
changeset
|
983 |
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
|
984 |
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
|
985 |
begin |
eeae1cb6b6bf
Move hedgehog's step routine into separate function, use it in both hedgehog and ai code
unc0rr
parents:
7627
diff
changeset
|
986 |
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
|
987 |
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
|
988 |
begin |
eeae1cb6b6bf
Move hedgehog's step routine into separate function, use it in both hedgehog and ai code
unc0rr
parents:
7627
diff
changeset
|
989 |
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
|
990 |
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
|
991 |
begin |
eeae1cb6b6bf
Move hedgehog's step routine into separate function, use it in both hedgehog and ai code
unc0rr
parents:
7627
diff
changeset
|
992 |
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
|
993 |
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
|
994 |
begin |
eeae1cb6b6bf
Move hedgehog's step routine into separate function, use it in both hedgehog and ai code
unc0rr
parents:
7627
diff
changeset
|
995 |
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
|
996 |
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
|
997 |
begin |
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 - _1; |
9706
5178d2263521
return land word from uCollisions to make decisions based on it. Should be handy for trampoline.
nemo
parents:
9685
diff
changeset
|
999 |
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
|
1000 |
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
|
1001 |
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
|
1002 |
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
|
1003 |
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
|
1004 |
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
|
1005 |
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
|
1006 |
end; |
eeae1cb6b6bf
Move hedgehog's step routine into separate function, use it in both hedgehog and ai code
unc0rr
parents:
7627
diff
changeset
|
1007 |
|
9706
5178d2263521
return land word from uCollisions to make decisions based on it. Should be handy for trampoline.
nemo
parents:
9685
diff
changeset
|
1008 |
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
|
1009 |
begin |
eeae1cb6b6bf
Move hedgehog's step routine into separate function, use it in both hedgehog and ai code
unc0rr
parents:
7627
diff
changeset
|
1010 |
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
|
1011 |
MakeHedgehogsStep:= true |
eeae1cb6b6bf
Move hedgehog's step routine into separate function, use it in both hedgehog and ai code
unc0rr
parents:
7627
diff
changeset
|
1012 |
end else |
eeae1cb6b6bf
Move hedgehog's step routine into separate function, use it in both hedgehog and ai code
unc0rr
parents:
7627
diff
changeset
|
1013 |
MakeHedgehogsStep:= false; |
eeae1cb6b6bf
Move hedgehog's step routine into separate function, use it in both hedgehog and ai code
unc0rr
parents:
7627
diff
changeset
|
1014 |
|
eeae1cb6b6bf
Move hedgehog's step routine into separate function, use it in both hedgehog and ai code
unc0rr
parents:
7627
diff
changeset
|
1015 |
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
|
1016 |
begin |
eeae1cb6b6bf
Move hedgehog's step routine into separate function, use it in both hedgehog and ai code
unc0rr
parents:
7627
diff
changeset
|
1017 |
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
|
1018 |
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
|
1019 |
begin |
eeae1cb6b6bf
Move hedgehog's step routine into separate function, use it in both hedgehog and ai code
unc0rr
parents:
7627
diff
changeset
|
1020 |
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
|
1021 |
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
|
1022 |
begin |
eeae1cb6b6bf
Move hedgehog's step routine into separate function, use it in both hedgehog and ai code
unc0rr
parents:
7627
diff
changeset
|
1023 |
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
|
1024 |
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
|
1025 |
begin |
eeae1cb6b6bf
Move hedgehog's step routine into separate function, use it in both hedgehog and ai code
unc0rr
parents:
7627
diff
changeset
|
1026 |
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
|
1027 |
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
|
1028 |
begin |
eeae1cb6b6bf
Move hedgehog's step routine into separate function, use it in both hedgehog and ai code
unc0rr
parents:
7627
diff
changeset
|
1029 |
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
|
1030 |
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
|
1031 |
begin |
eeae1cb6b6bf
Move hedgehog's step routine into separate function, use it in both hedgehog and ai code
unc0rr
parents:
7627
diff
changeset
|
1032 |
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
|
1033 |
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
|
1034 |
begin |
eeae1cb6b6bf
Move hedgehog's step routine into separate function, use it in both hedgehog and ai code
unc0rr
parents:
7627
diff
changeset
|
1035 |
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
|
1036 |
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
|
1037 |
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
|
1038 |
exit |
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 |
end; |
eeae1cb6b6bf
Move hedgehog's step routine into separate function, use it in both hedgehog and ai code
unc0rr
parents:
7627
diff
changeset
|
1046 |
end; |
eeae1cb6b6bf
Move hedgehog's step routine into separate function, use it in both hedgehog and ai code
unc0rr
parents:
7627
diff
changeset
|
1047 |
|
9285 | 1048 |
|
1049 |
procedure ShotgunShot(Gear: PGear); |
|
1050 |
var t: PGear; |
|
1051 |
dmg, r, dist: LongInt; |
|
1052 |
dx, dy: hwFloat; |
|
1053 |
begin |
|
1054 |
Gear^.Radius:= cShotgunRadius; |
|
1055 |
t:= GearsList; |
|
1056 |
while t <> nil do |
|
1057 |
begin |
|
1058 |
case t^.Kind of |
|
1059 |
gtHedgehog, |
|
1060 |
gtMine, |
|
1061 |
gtSMine, |
|
1062 |
gtKnife, |
|
1063 |
gtCase, |
|
1064 |
gtTarget, |
|
1065 |
gtExplosives: begin//, |
|
1066 |
// gtStructure: begin |
|
1067 |
//addFileLog('ShotgunShot radius: ' + inttostr(Gear^.Radius) + ', t^.Radius = ' + inttostr(t^.Radius) + ', distance = ' + inttostr(dist) + ', dmg = ' + inttostr(dmg)); |
|
1068 |
dmg:= 0; |
|
1069 |
r:= Gear^.Radius + t^.Radius; |
|
1070 |
dx:= Gear^.X-t^.X; |
|
1071 |
dx.isNegative:= false; |
|
1072 |
dy:= Gear^.Y-t^.Y; |
|
1073 |
dy.isNegative:= false; |
|
1074 |
if r-hwRound(dx+dy) > 0 then |
|
1075 |
begin |
|
1076 |
dist:= hwRound(Distance(dx, dy)); |
|
1077 |
dmg:= ModifyDamage(min(r - dist, 25), t); |
|
1078 |
end; |
|
1079 |
if dmg > 0 then |
|
1080 |
begin |
|
10558 | 1081 |
if (t^.Kind <> gtHedgehog) or (t^.Hedgehog^.Effects[heInvulnerable] = 0) then |
9285 | 1082 |
ApplyDamage(t, Gear^.Hedgehog, dmg, dsBullet) |
1083 |
else |
|
1084 |
Gear^.State:= Gear^.State or gstWinner; |
|
1085 |
||
1086 |
DeleteCI(t); |
|
1087 |
t^.dX:= t^.dX + Gear^.dX * dmg * _0_01 + SignAs(cHHKick, Gear^.dX); |
|
1088 |
t^.dY:= t^.dY + Gear^.dY * dmg * _0_01; |
|
1089 |
t^.State:= t^.State or gstMoving; |
|
1090 |
if t^.Kind = gtKnife then t^.State:= t^.State and (not gstCollision); |
|
1091 |
t^.Active:= true; |
|
1092 |
FollowGear:= t |
|
1093 |
end |
|
1094 |
end; |
|
1095 |
gtGrave: begin |
|
1096 |
dmg:= 0; |
|
1097 |
r:= Gear^.Radius + t^.Radius; |
|
1098 |
dx:= Gear^.X-t^.X; |
|
1099 |
dx.isNegative:= false; |
|
1100 |
dy:= Gear^.Y-t^.Y; |
|
1101 |
dy.isNegative:= false; |
|
1102 |
if r-hwRound(dx+dy) > 0 then |
|
1103 |
begin |
|
1104 |
dist:= hwRound(Distance(dx, dy)); |
|
1105 |
dmg:= ModifyDamage(min(r - dist, 25), t); |
|
1106 |
end; |
|
1107 |
if dmg > 0 then |
|
1108 |
begin |
|
1109 |
t^.dY:= - _0_1; |
|
1110 |
t^.Active:= true |
|
1111 |
end |
|
1112 |
end; |
|
1113 |
end; |
|
1114 |
t:= t^.NextGear |
|
1115 |
end; |
|
1116 |
if (GameFlags and gfSolidLand) = 0 then |
|
1117 |
DrawExplosion(hwRound(Gear^.X), hwRound(Gear^.Y), cShotgunRadius) |
|
1118 |
end; |
|
1119 |
||
1120 |
procedure AmmoShove(Ammo: PGear; Damage, Power: LongInt); |
|
1121 |
var t: PGearArray; |
|
1122 |
Gear: PGear; |
|
1123 |
i, j, tmpDmg: LongInt; |
|
1124 |
VGear: PVisualGear; |
|
1125 |
begin |
|
1126 |
t:= CheckGearsCollision(Ammo); |
|
1127 |
// Just to avoid hogs on rope dodging fire. |
|
1128 |
if (CurAmmoGear <> nil) and ((CurAmmoGear^.Kind = gtRope) or (CurAmmoGear^.Kind = gtJetpack) or (CurAmmoGear^.Kind = gtBirdy)) |
|
1129 |
and (CurrentHedgehog^.Gear <> nil) and (CurrentHedgehog^.Gear^.CollisionIndex = -1) |
|
1130 |
and (sqr(hwRound(Ammo^.X) - hwRound(CurrentHedgehog^.Gear^.X)) + sqr(hwRound(Ammo^.Y) - hwRound(CurrentHedgehog^.Gear^.Y)) <= sqr(cHHRadius + Ammo^.Radius)) then |
|
1131 |
begin |
|
1132 |
t^.ar[t^.Count]:= CurrentHedgehog^.Gear; |
|
1133 |
inc(t^.Count) |
|
1134 |
end; |
|
1135 |
||
1136 |
i:= t^.Count; |
|
1137 |
||
1138 |
if (Ammo^.Kind = gtFlame) and (i > 0) then |
|
1139 |
Ammo^.Health:= 0; |
|
1140 |
while i > 0 do |
|
1141 |
begin |
|
1142 |
dec(i); |
|
1143 |
Gear:= t^.ar[i]; |
|
10015 | 1144 |
if ((Ammo^.Kind = gtFlame) or (Ammo^.Kind = gtBlowTorch)) and |
9285 | 1145 |
(Gear^.Kind = gtHedgehog) and (Gear^.Hedgehog^.Effects[heFrozen] > 255) then |
1146 |
Gear^.Hedgehog^.Effects[heFrozen]:= max(255,Gear^.Hedgehog^.Effects[heFrozen]-10000); |
|
1147 |
tmpDmg:= ModifyDamage(Damage, Gear); |
|
1148 |
if (Gear^.State and gstNoDamage) = 0 then |
|
1149 |
begin |
|
1150 |
||
10015 | 1151 |
if (Ammo^.Kind = gtDEagleShot) or (Ammo^.Kind = gtSniperRifleShot) then |
9285 | 1152 |
begin |
1153 |
VGear := AddVisualGear(hwround(Ammo^.X), hwround(Ammo^.Y), vgtBulletHit); |
|
1154 |
if VGear <> nil then |
|
1155 |
VGear^.Angle := DxDy2Angle(-Ammo^.dX, Ammo^.dY); |
|
1156 |
end; |
|
1157 |
||
1158 |
if (Gear^.Kind = gtHedgehog) and (Ammo^.State and gsttmpFlag <> 0) and (Ammo^.Kind = gtShover) then |
|
1159 |
Gear^.FlightTime:= 1; |
|
1160 |
||
1161 |
||
1162 |
case Gear^.Kind of |
|
1163 |
gtHedgehog, |
|
1164 |
gtMine, |
|
1165 |
gtSMine, |
|
1166 |
gtKnife, |
|
1167 |
gtTarget, |
|
1168 |
gtCase, |
|
1169 |
gtExplosives: //, |
|
1170 |
//gtStructure: |
|
1171 |
begin |
|
1172 |
if (Ammo^.Kind = gtDrill) then |
|
1173 |
begin |
|
1174 |
Ammo^.Timer:= 0; |
|
1175 |
exit; |
|
1176 |
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
|
1177 |
if (Gear^.Kind <> gtHedgehog) or (Gear^.Hedgehog^.Effects[heInvulnerable] = 0) then |
9285 | 1178 |
begin |
1179 |
if (Ammo^.Kind = gtKnife) and (tmpDmg > 0) then |
|
1180 |
for j:= 1 to max(1,min(3,tmpDmg div 5)) do |
|
1181 |
begin |
|
1182 |
VGear:= AddVisualGear(hwRound(Ammo^.X-((Ammo^.X-Gear^.X)/_2)), hwRound(Ammo^.Y-((Ammo^.Y-Gear^.Y)/_2)), vgtStraightShot); |
|
1183 |
if VGear <> nil then |
|
1184 |
with VGear^ do |
|
1185 |
begin |
|
1186 |
Tint:= $FFCC00FF; |
|
1187 |
Angle:= random(360); |
|
1188 |
dx:= 0.0005 * (random(100)); |
|
1189 |
dy:= 0.0005 * (random(100)); |
|
1190 |
if random(2) = 0 then |
|
1191 |
dx := -dx; |
|
1192 |
if random(2) = 0 then |
|
1193 |
dy := -dy; |
|
1194 |
FrameTicks:= 600+random(200); |
|
1195 |
State:= ord(sprStar) |
|
1196 |
end |
|
1197 |
end; |
|
1198 |
ApplyDamage(Gear, Ammo^.Hedgehog, tmpDmg, dsShove) |
|
1199 |
end |
|
1200 |
else |
|
1201 |
Gear^.State:= Gear^.State or gstWinner; |
|
10015 | 1202 |
if (Gear^.Kind = gtExplosives) and (Ammo^.Kind = gtBlowtorch) then |
9285 | 1203 |
begin |
1204 |
if (Ammo^.Hedgehog^.Gear <> nil) then |
|
1205 |
Ammo^.Hedgehog^.Gear^.State:= Ammo^.Hedgehog^.Gear^.State and (not gstNotKickable); |
|
1206 |
ApplyDamage(Gear, Ammo^.Hedgehog, tmpDmg * 100, dsUnknown); // crank up damage for explosives + blowtorch |
|
1207 |
end; |
|
1208 |
||
1209 |
if (Gear^.Kind = gtHedgehog) and (Gear^.Hedgehog^.King or (Gear^.Hedgehog^.Effects[heFrozen] > 0)) then |
|
1210 |
begin |
|
1211 |
Gear^.dX:= Ammo^.dX * Power * _0_005; |
|
1212 |
Gear^.dY:= Ammo^.dY * Power * _0_005 |
|
1213 |
end |
|
1214 |
else if ((Ammo^.Kind <> gtFlame) or (Gear^.Kind = gtHedgehog)) and (Power <> 0) then |
|
1215 |
begin |
|
1216 |
Gear^.dX:= Ammo^.dX * Power * _0_01; |
|
1217 |
Gear^.dY:= Ammo^.dY * Power * _0_01 |
|
1218 |
end; |
|
1219 |
||
1220 |
if (not isZero(Gear^.dX)) or (not isZero(Gear^.dY)) then |
|
1221 |
begin |
|
1222 |
Gear^.Active:= true; |
|
1223 |
DeleteCI(Gear); |
|
1224 |
Gear^.State:= Gear^.State or gstMoving; |
|
1225 |
if Gear^.Kind = gtKnife then Gear^.State:= Gear^.State and (not gstCollision); |
|
1226 |
// 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
|
1227 |
if TestCollisionXwithGear(Gear, hwSign(Gear^.dX)) <> 0 then |
9285 | 1228 |
begin |
9706
5178d2263521
return land word from uCollisions to make decisions based on it. Should be handy for trampoline.
nemo
parents:
9685
diff
changeset
|
1229 |
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
|
1230 |
(TestCollisionYwithGear(Gear, -1) = 0) then |
9285 | 1231 |
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
|
1232 |
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
|
1233 |
(TestCollisionYwithGear(Gear, -1) = 0) then |
9285 | 1234 |
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
|
1235 |
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
|
1236 |
(TestCollisionYwithGear(Gear, -1) = 0) then |
9285 | 1237 |
Gear^.Y:= Gear^.Y - _1; |
1238 |
end |
|
1239 |
end; |
|
1240 |
||
1241 |
||
1242 |
if (Ammo^.Kind <> gtFlame) or ((Ammo^.State and gsttmpFlag) = 0) then |
|
1243 |
FollowGear:= Gear |
|
1244 |
end; |
|
1245 |
end |
|
1246 |
end; |
|
1247 |
end; |
|
1248 |
if i <> 0 then |
|
1249 |
SetAllToActive |
|
1250 |
end; |
|
1251 |
||
1252 |
||
1253 |
function CountGears(Kind: TGearType): Longword; |
|
1254 |
var t: PGear; |
|
1255 |
count: Longword = 0; |
|
1256 |
begin |
|
1257 |
||
1258 |
t:= GearsList; |
|
1259 |
while t <> nil do |
|
1260 |
begin |
|
1261 |
if t^.Kind = Kind then |
|
1262 |
inc(count); |
|
1263 |
t:= t^.NextGear |
|
1264 |
end; |
|
1265 |
CountGears:= count; |
|
1266 |
end; |
|
1267 |
||
1268 |
procedure SetAllToActive; |
|
1269 |
var t: PGear; |
|
1270 |
begin |
|
1271 |
AllInactive:= false; |
|
1272 |
t:= GearsList; |
|
1273 |
while t <> nil do |
|
1274 |
begin |
|
1275 |
t^.Active:= true; |
|
1276 |
t:= t^.NextGear |
|
1277 |
end |
|
1278 |
end; |
|
1279 |
||
1280 |
procedure SetAllHHToActive; inline; |
|
1281 |
begin |
|
1282 |
SetAllHHToActive(true) |
|
1283 |
end; |
|
1284 |
||
1285 |
||
1286 |
procedure SetAllHHToActive(Ice: boolean); |
|
1287 |
var t: PGear; |
|
1288 |
begin |
|
1289 |
AllInactive:= false; |
|
1290 |
t:= GearsList; |
|
1291 |
while t <> nil do |
|
1292 |
begin |
|
1293 |
if (t^.Kind = gtHedgehog) or (t^.Kind = gtExplosives) then |
|
1294 |
begin |
|
1295 |
if (t^.Kind = gtHedgehog) and Ice then CheckIce(t); |
|
1296 |
t^.Active:= true |
|
1297 |
end; |
|
1298 |
t:= t^.NextGear |
|
1299 |
end |
|
1300 |
end; |
|
1301 |
||
1302 |
||
1303 |
var GearsNearArray : TPGearArray; |
|
1304 |
function GearsNear(X, Y: hwFloat; Kind: TGearType; r: LongInt): PGearArrayS; |
|
1305 |
var |
|
1306 |
t: PGear; |
|
1307 |
s: Longword; |
|
1308 |
begin |
|
1309 |
r:= r*r; |
|
1310 |
s:= 0; |
|
1311 |
SetLength(GearsNearArray, s); |
|
1312 |
t := GearsList; |
|
10015 | 1313 |
while t <> nil do |
9285 | 1314 |
begin |
10015 | 1315 |
if (t^.Kind = Kind) |
9285 | 1316 |
and ((X - t^.X)*(X - t^.X) + (Y - t^.Y)*(Y-t^.Y) < int2hwFloat(r)) then |
1317 |
begin |
|
1318 |
inc(s); |
|
1319 |
SetLength(GearsNearArray, s); |
|
1320 |
GearsNearArray[s - 1] := t; |
|
1321 |
end; |
|
1322 |
t := t^.NextGear; |
|
1323 |
end; |
|
1324 |
||
1325 |
GearsNear.size:= s; |
|
1326 |
GearsNear.ar:= @GearsNearArray |
|
1327 |
end; |
|
1328 |
||
1329 |
||
1330 |
procedure SpawnBoxOfSmth; |
|
1331 |
var t, aTot, uTot, a, h: LongInt; |
|
1332 |
i: TAmmoType; |
|
1333 |
begin |
|
1334 |
if (PlacingHogs) or |
|
1335 |
(cCaseFactor = 0) |
|
1336 |
or (CountGears(gtCase) >= 5) |
|
1337 |
or (GetRandom(cCaseFactor) <> 0) then |
|
1338 |
exit; |
|
1339 |
||
1340 |
FollowGear:= nil; |
|
1341 |
aTot:= 0; |
|
1342 |
uTot:= 0; |
|
1343 |
for i:= Low(TAmmoType) to High(TAmmoType) do |
|
1344 |
if (Ammoz[i].Ammo.Propz and ammoprop_Utility) = 0 then |
|
1345 |
inc(aTot, Ammoz[i].Probability) |
|
1346 |
else |
|
1347 |
inc(uTot, Ammoz[i].Probability); |
|
1348 |
||
1349 |
t:=0; |
|
1350 |
a:=aTot; |
|
1351 |
h:= 1; |
|
1352 |
||
1353 |
if (aTot+uTot) <> 0 then |
|
1354 |
if ((GameFlags and gfInvulnerable) = 0) then |
|
1355 |
begin |
|
1356 |
h:= cHealthCaseProb * 100; |
|
1357 |
t:= GetRandom(10000); |
|
1358 |
a:= (10000-h)*aTot div (aTot+uTot) |
|
1359 |
end |
|
1360 |
else |
|
1361 |
begin |
|
1362 |
t:= GetRandom(aTot+uTot); |
|
1363 |
h:= 0 |
|
1364 |
end; |
|
1365 |
||
1366 |
||
1367 |
if t<h then |
|
1368 |
begin |
|
1369 |
FollowGear:= AddGear(0, 0, gtCase, 0, _0, _0, 0); |
|
1370 |
FollowGear^.Health:= cHealthCaseAmount; |
|
1371 |
FollowGear^.Pos:= posCaseHealth; |
|
10506 | 1372 |
// health crate is smaller than the other crates |
1373 |
FollowGear^.Radius := cCaseHealthRadius; |
|
9285 | 1374 |
AddCaption(GetEventString(eidNewHealthPack), cWhiteColor, capgrpAmmoInfo); |
1375 |
end |
|
1376 |
else if (t<a+h) then |
|
1377 |
begin |
|
1378 |
t:= aTot; |
|
1379 |
if (t > 0) then |
|
1380 |
begin |
|
1381 |
FollowGear:= AddGear(0, 0, gtCase, 0, _0, _0, 0); |
|
1382 |
t:= GetRandom(t); |
|
1383 |
i:= Low(TAmmoType); |
|
1384 |
FollowGear^.Pos:= posCaseAmmo; |
|
1385 |
FollowGear^.AmmoType:= i; |
|
1386 |
AddCaption(GetEventString(eidNewAmmoPack), cWhiteColor, capgrpAmmoInfo); |
|
1387 |
end |
|
1388 |
end |
|
1389 |
else |
|
1390 |
begin |
|
1391 |
t:= uTot; |
|
1392 |
if (t > 0) then |
|
1393 |
begin |
|
1394 |
FollowGear:= AddGear(0, 0, gtCase, 0, _0, _0, 0); |
|
1395 |
t:= GetRandom(t); |
|
1396 |
i:= Low(TAmmoType); |
|
1397 |
FollowGear^.Pos:= posCaseUtility; |
|
1398 |
FollowGear^.AmmoType:= i; |
|
1399 |
AddCaption(GetEventString(eidNewUtilityPack), cWhiteColor, capgrpAmmoInfo); |
|
1400 |
end |
|
1401 |
end; |
|
1402 |
||
1403 |
// handles case of no ammo or utility crates - considered also placing booleans in uAmmos and altering probabilities |
|
1404 |
if (FollowGear <> nil) then |
|
1405 |
begin |
|
1406 |
FindPlace(FollowGear, true, 0, LAND_WIDTH); |
|
1407 |
||
1408 |
if (FollowGear <> nil) then |
|
1409 |
AddVoice(sndReinforce, CurrentTeam^.voicepack) |
|
1410 |
end |
|
1411 |
end; |
|
1412 |
||
1413 |
||
1414 |
function GetAmmo(Hedgehog: PHedgehog): TAmmoType; |
|
1415 |
var t, aTot: LongInt; |
|
1416 |
i: TAmmoType; |
|
1417 |
begin |
|
1418 |
Hedgehog:= Hedgehog; // avoid hint |
|
1419 |
||
1420 |
aTot:= 0; |
|
1421 |
for i:= Low(TAmmoType) to High(TAmmoType) do |
|
1422 |
if (Ammoz[i].Ammo.Propz and ammoprop_Utility) = 0 then |
|
1423 |
inc(aTot, Ammoz[i].Probability); |
|
1424 |
||
1425 |
t:= aTot; |
|
1426 |
i:= Low(TAmmoType); |
|
1427 |
if (t > 0) then |
|
1428 |
begin |
|
1429 |
t:= GetRandom(t); |
|
1430 |
while t >= 0 do |
|
1431 |
begin |
|
1432 |
inc(i); |
|
1433 |
if (Ammoz[i].Ammo.Propz and ammoprop_Utility) = 0 then |
|
1434 |
dec(t, Ammoz[i].Probability) |
|
1435 |
end |
|
1436 |
end; |
|
1437 |
GetAmmo:= i |
|
1438 |
end; |
|
1439 |
||
1440 |
function GetUtility(Hedgehog: PHedgehog): TAmmoType; |
|
1441 |
var t, uTot: LongInt; |
|
1442 |
i: TAmmoType; |
|
1443 |
begin |
|
1444 |
||
1445 |
uTot:= 0; |
|
1446 |
for i:= Low(TAmmoType) to High(TAmmoType) do |
|
1447 |
if ((Ammoz[i].Ammo.Propz and ammoprop_Utility) <> 0) |
|
1448 |
and ((Hedgehog^.Team^.HedgehogsNumber > 1) or (Ammoz[i].Ammo.AmmoType <> amSwitch)) then |
|
1449 |
inc(uTot, Ammoz[i].Probability); |
|
1450 |
||
1451 |
t:= uTot; |
|
1452 |
i:= Low(TAmmoType); |
|
1453 |
if (t > 0) then |
|
1454 |
begin |
|
1455 |
t:= GetRandom(t); |
|
1456 |
while t >= 0 do |
|
1457 |
begin |
|
1458 |
inc(i); |
|
1459 |
if ((Ammoz[i].Ammo.Propz and ammoprop_Utility) <> 0) and ((Hedgehog^.Team^.HedgehogsNumber > 1) |
|
1460 |
or (Ammoz[i].Ammo.AmmoType <> amSwitch)) then |
|
1461 |
dec(t, Ammoz[i].Probability) |
|
1462 |
end |
|
1463 |
end; |
|
1464 |
GetUtility:= i |
|
1465 |
end; |
|
1466 |
||
9473
a51a69094c24
partial implementation of non-infinite world (edge wrap/warp/bounce)
nemo
parents:
9285
diff
changeset
|
1467 |
(* |
a51a69094c24
partial implementation of non-infinite world (edge wrap/warp/bounce)
nemo
parents:
9285
diff
changeset
|
1468 |
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
|
1469 |
* Normal - infinite world, do nothing |
a51a69094c24
partial implementation of non-infinite world (edge wrap/warp/bounce)
nemo
parents:
9285
diff
changeset
|
1470 |
* 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
|
1471 |
* 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
|
1472 |
* 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
|
1473 |
|
a51a69094c24
partial implementation of non-infinite world (edge wrap/warp/bounce)
nemo
parents:
9285
diff
changeset
|
1474 |
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
|
1475 |
*) |
a51a69094c24
partial implementation of non-infinite world (edge wrap/warp/bounce)
nemo
parents:
9285
diff
changeset
|
1476 |
function WorldWrap(var Gear: PGear): boolean; |
10354 | 1477 |
//var tdx: hwFloat; |
9473
a51a69094c24
partial implementation of non-infinite world (edge wrap/warp/bounce)
nemo
parents:
9285
diff
changeset
|
1478 |
begin |
a51a69094c24
partial implementation of non-infinite world (edge wrap/warp/bounce)
nemo
parents:
9285
diff
changeset
|
1479 |
WorldWrap:= false; |
a51a69094c24
partial implementation of non-infinite world (edge wrap/warp/bounce)
nemo
parents:
9285
diff
changeset
|
1480 |
if WorldEdge = weNone then exit(false); |
10160 | 1481 |
if (hwRound(Gear^.X) < LongInt(leftX)) or |
1482 |
(hwRound(Gear^.X) > LongInt(rightX)) then |
|
9473
a51a69094c24
partial implementation of non-infinite world (edge wrap/warp/bounce)
nemo
parents:
9285
diff
changeset
|
1483 |
begin |
a51a69094c24
partial implementation of non-infinite world (edge wrap/warp/bounce)
nemo
parents:
9285
diff
changeset
|
1484 |
if WorldEdge = weWrap then |
a51a69094c24
partial implementation of non-infinite world (edge wrap/warp/bounce)
nemo
parents:
9285
diff
changeset
|
1485 |
begin |
10160 | 1486 |
if (hwRound(Gear^.X) < LongInt(leftX)) then |
1487 |
Gear^.X:= Gear^.X + int2hwfloat(rightX - leftX) |
|
1488 |
else Gear^.X:= Gear^.X - int2hwfloat(rightX - leftX); |
|
9557 | 1489 |
LeftImpactTimer:= 150; |
1490 |
RightImpactTimer:= 150 |
|
9473
a51a69094c24
partial implementation of non-infinite world (edge wrap/warp/bounce)
nemo
parents:
9285
diff
changeset
|
1491 |
end |
a51a69094c24
partial implementation of non-infinite world (edge wrap/warp/bounce)
nemo
parents:
9285
diff
changeset
|
1492 |
else if WorldEdge = weBounce then |
a51a69094c24
partial implementation of non-infinite world (edge wrap/warp/bounce)
nemo
parents:
9285
diff
changeset
|
1493 |
begin |
9809 | 1494 |
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
|
1495 |
begin |
9557 | 1496 |
LeftImpactTimer:= 333; |
9473
a51a69094c24
partial implementation of non-infinite world (edge wrap/warp/bounce)
nemo
parents:
9285
diff
changeset
|
1497 |
Gear^.dX.isNegative:= false; |
9809 | 1498 |
Gear^.X:= int2hwfloat(LongInt(leftX) + Gear^.Radius) |
9473
a51a69094c24
partial implementation of non-infinite world (edge wrap/warp/bounce)
nemo
parents:
9285
diff
changeset
|
1499 |
end |
10015 | 1500 |
else |
9473
a51a69094c24
partial implementation of non-infinite world (edge wrap/warp/bounce)
nemo
parents:
9285
diff
changeset
|
1501 |
begin |
9557 | 1502 |
RightImpactTimer:= 333; |
9473
a51a69094c24
partial implementation of non-infinite world (edge wrap/warp/bounce)
nemo
parents:
9285
diff
changeset
|
1503 |
Gear^.dX.isNegative:= true; |
9485
3dee8a3b0406
add shotgun wrap, revert 100px offset. Problematic w/ things that rely on Land.
nemo
parents:
9479
diff
changeset
|
1504 |
Gear^.X:= int2hwfloat(rightX-Gear^.Radius) |
9557 | 1505 |
end; |
9561 | 1506 |
if (Gear^.Radius > 2) and (Gear^.dX.QWordValue > _0_001.QWordValue) then |
10508 | 1507 |
AddBounceEffectForGear(Gear); |
10354 | 1508 |
end{ |
9473
a51a69094c24
partial implementation of non-infinite world (edge wrap/warp/bounce)
nemo
parents:
9285
diff
changeset
|
1509 |
else if WorldEdge = weSea then |
a51a69094c24
partial implementation of non-infinite world (edge wrap/warp/bounce)
nemo
parents:
9285
diff
changeset
|
1510 |
begin |
a51a69094c24
partial implementation of non-infinite world (edge wrap/warp/bounce)
nemo
parents:
9285
diff
changeset
|
1511 |
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
|
1512 |
Gear^.State:= Gear^.State and (not gstSubmersible) |
9473
a51a69094c24
partial implementation of non-infinite world (edge wrap/warp/bounce)
nemo
parents:
9285
diff
changeset
|
1513 |
else |
a51a69094c24
partial implementation of non-infinite world (edge wrap/warp/bounce)
nemo
parents:
9285
diff
changeset
|
1514 |
begin |
a51a69094c24
partial implementation of non-infinite world (edge wrap/warp/bounce)
nemo
parents:
9285
diff
changeset
|
1515 |
Gear^.State:= Gear^.State or gstSubmersible; |
a51a69094c24
partial implementation of non-infinite world (edge wrap/warp/bounce)
nemo
parents:
9285
diff
changeset
|
1516 |
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
|
1517 |
Gear^.Y:= int2hwFloat(cWaterLine+cVisibleWater+Gear^.Radius*2); |
a51a69094c24
partial implementation of non-infinite world (edge wrap/warp/bounce)
nemo
parents:
9285
diff
changeset
|
1518 |
tdx:= Gear^.dX; |
9522 | 1519 |
Gear^.dX:= -Gear^.dY; |
9473
a51a69094c24
partial implementation of non-infinite world (edge wrap/warp/bounce)
nemo
parents:
9285
diff
changeset
|
1520 |
Gear^.dY:= tdx; |
a51a69094c24
partial implementation of non-infinite world (edge wrap/warp/bounce)
nemo
parents:
9285
diff
changeset
|
1521 |
Gear^.dY.isNegative:= true |
a51a69094c24
partial implementation of non-infinite world (edge wrap/warp/bounce)
nemo
parents:
9285
diff
changeset
|
1522 |
end |
10354 | 1523 |
end}; |
9473
a51a69094c24
partial implementation of non-infinite world (edge wrap/warp/bounce)
nemo
parents:
9285
diff
changeset
|
1524 |
(* |
a51a69094c24
partial implementation of non-infinite world (edge wrap/warp/bounce)
nemo
parents:
9285
diff
changeset
|
1525 |
* 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
|
1526 |
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
|
1527 |
|
10015 | 1528 |
else |
9473
a51a69094c24
partial implementation of non-infinite world (edge wrap/warp/bounce)
nemo
parents:
9285
diff
changeset
|
1529 |
begin |
a51a69094c24
partial implementation of non-infinite world (edge wrap/warp/bounce)
nemo
parents:
9285
diff
changeset
|
1530 |
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
|
1531 |
Gear^.Y:= -_2048-_256-_256; |
a51a69094c24
partial implementation of non-infinite world (edge wrap/warp/bounce)
nemo
parents:
9285
diff
changeset
|
1532 |
tdx:= Gear^.dX; |
a51a69094c24
partial implementation of non-infinite world (edge wrap/warp/bounce)
nemo
parents:
9285
diff
changeset
|
1533 |
Gear^.dX:= Gear^.dY; |
a51a69094c24
partial implementation of non-infinite world (edge wrap/warp/bounce)
nemo
parents:
9285
diff
changeset
|
1534 |
Gear^.dY:= tdx; |
a51a69094c24
partial implementation of non-infinite world (edge wrap/warp/bounce)
nemo
parents:
9285
diff
changeset
|
1535 |
Gear^.dY.isNegative:= false |
a51a69094c24
partial implementation of non-infinite world (edge wrap/warp/bounce)
nemo
parents:
9285
diff
changeset
|
1536 |
end |
a51a69094c24
partial implementation of non-infinite world (edge wrap/warp/bounce)
nemo
parents:
9285
diff
changeset
|
1537 |
*) |
a51a69094c24
partial implementation of non-infinite world (edge wrap/warp/bounce)
nemo
parents:
9285
diff
changeset
|
1538 |
WorldWrap:= true |
a51a69094c24
partial implementation of non-infinite world (edge wrap/warp/bounce)
nemo
parents:
9285
diff
changeset
|
1539 |
end; |
a51a69094c24
partial implementation of non-infinite world (edge wrap/warp/bounce)
nemo
parents:
9285
diff
changeset
|
1540 |
end; |
9285 | 1541 |
|
10508 | 1542 |
procedure AddBounceEffectForGear(Gear: PGear); |
1543 |
var boing: PVisualGear; |
|
1544 |
begin |
|
1545 |
boing:= AddVisualGear(hwRound(Gear^.X), hwRound(Gear^.Y), vgtStraightShot, 0, false, 1); |
|
1546 |
if boing <> nil then |
|
1547 |
with boing^ do |
|
1548 |
begin |
|
1549 |
Angle:= random(360); |
|
1550 |
dx:= 0; |
|
1551 |
dy:= 0; |
|
1552 |
FrameTicks:= 200; |
|
1553 |
Scale:= hwFloat2Float(Gear^.Density * hwAbs(Gear^.dY) + hwAbs(Gear^.dX)) / 1.5; |
|
1554 |
State:= ord(sprBoing) |
|
1555 |
end; |
|
1556 |
PlaySound(sndMelonImpact, true) |
|
1557 |
end; |
|
1558 |
||
6581 | 1559 |
end. |