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