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