author | lovelacer |
Tue, 17 Jan 2012 09:01:31 -0500 | |
changeset 6580 | 6155187bf599 |
parent 6543 | 697e9b730189 |
child 6581 | e510d1245bd7 |
permissions | -rw-r--r-- |
6468 | 1 |
(* |
2 |
* Hedgewars, a free turn based strategy game |
|
3 |
* Copyright (c) 2004-2011 Andrey Korotaev <unC0Rr@gmail.com> |
|
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 |
|
16 |
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA |
|
17 |
*) |
|
18 |
||
19 |
{$INCLUDE "options.inc"} |
|
20 |
||
21 |
unit uGearsUtils; |
|
22 |
interface |
|
23 |
uses uTypes; |
|
24 |
||
25 |
procedure doMakeExplosion(X, Y, Radius: LongInt; AttackingHog: PHedgehog; Mask: Longword; const Tint: LongWord = $FFFFFFFF); |
|
26 |
function ModifyDamage(dmg: Longword; Gear: PGear): Longword; |
|
27 |
procedure ApplyDamage(Gear: PGear; AttackerHog: PHedgehog; Damage: Longword; Source: TDamageSource); |
|
28 |
procedure spawnHealthTagForHH(HHGear: PGear; dmg: Longword); |
|
29 |
procedure HHHurt(Hedgehog: PHedgehog; Source: TDamageSource); |
|
30 |
procedure CheckHHDamage(Gear: PGear); |
|
31 |
procedure CalcRotationDirAngle(Gear: PGear); |
|
32 |
procedure ResurrectHedgehog(gear: PGear); |
|
33 |
procedure FindPlace(var Gear: PGear; withFall: boolean; Left, Right: LongInt; skipProximity: boolean = false); |
|
34 |
function CheckGearNear(Gear: PGear; Kind: TGearType; rX, rY: LongInt): PGear; |
|
35 |
function CheckGearsNear(mX, mY: LongInt; Kind: TGearsType; rX, rY: LongInt): PGear; |
|
6543 | 36 |
function CheckGearDrowning(Gear: PGear): boolean; |
37 |
||
38 |
var doStepHandlers: array[TGearType] of TGearStepProcedure; |
|
6468 | 39 |
|
40 |
||
41 |
implementation |
|
42 |
uses uFloat, uSound, uCollisions, uUtils, uConsts, uVisualGears, uAIMisc, |
|
43 |
uVariables, uLandGraphics, uScript, uStats, uCaptions, uTeams, uStore, |
|
6543 | 44 |
uLocale, uTextures, uRenderUtils, uRandom, SDLh, uDebug, uGears, |
45 |
uGearsList; |
|
6468 | 46 |
|
47 |
procedure doMakeExplosion(X, Y, Radius: LongInt; AttackingHog: PHedgehog; Mask: Longword; const Tint: LongWord); |
|
48 |
var Gear: PGear; |
|
49 |
dmg, dmgRadius, dmgBase: LongInt; |
|
50 |
fX, fY: hwFloat; |
|
51 |
vg: PVisualGear; |
|
52 |
i, cnt: LongInt; |
|
53 |
begin |
|
6531
c938a35588af
Remove density adjustment in ammoshove. Means a mine and a barrel will be batted same distance again.
nemo
parents:
6498
diff
changeset
|
54 |
if Radius > 4 then AddFileLog('Explosion: at (' + inttostr(x) + ',' + inttostr(y) + ')'); |
c938a35588af
Remove density adjustment in ammoshove. Means a mine and a barrel will be batted same distance again.
nemo
parents:
6498
diff
changeset
|
55 |
if Radius > 25 then KickFlakes(Radius, X, Y); |
c938a35588af
Remove density adjustment in ammoshove. Means a mine and a barrel will be batted same distance again.
nemo
parents:
6498
diff
changeset
|
56 |
|
c938a35588af
Remove density adjustment in ammoshove. Means a mine and a barrel will be batted same distance again.
nemo
parents:
6498
diff
changeset
|
57 |
if ((Mask and EXPLNoGfx) = 0) then |
c938a35588af
Remove density adjustment in ammoshove. Means a mine and a barrel will be batted same distance again.
nemo
parents:
6498
diff
changeset
|
58 |
begin |
c938a35588af
Remove density adjustment in ammoshove. Means a mine and a barrel will be batted same distance again.
nemo
parents:
6498
diff
changeset
|
59 |
vg:= nil; |
c938a35588af
Remove density adjustment in ammoshove. Means a mine and a barrel will be batted same distance again.
nemo
parents:
6498
diff
changeset
|
60 |
if Radius > 50 then vg:= AddVisualGear(X, Y, vgtBigExplosion) |
c938a35588af
Remove density adjustment in ammoshove. Means a mine and a barrel will be batted same distance again.
nemo
parents:
6498
diff
changeset
|
61 |
else if Radius > 10 then vg:= AddVisualGear(X, Y, vgtExplosion); |
c938a35588af
Remove density adjustment in ammoshove. Means a mine and a barrel will be batted same distance again.
nemo
parents:
6498
diff
changeset
|
62 |
if vg <> nil then |
c938a35588af
Remove density adjustment in ammoshove. Means a mine and a barrel will be batted same distance again.
nemo
parents:
6498
diff
changeset
|
63 |
vg^.Tint:= Tint; |
c938a35588af
Remove density adjustment in ammoshove. Means a mine and a barrel will be batted same distance again.
nemo
parents:
6498
diff
changeset
|
64 |
end; |
c938a35588af
Remove density adjustment in ammoshove. Means a mine and a barrel will be batted same distance again.
nemo
parents:
6498
diff
changeset
|
65 |
if (Mask and EXPLAutoSound) <> 0 then PlaySound(sndExplosion); |
6468 | 66 |
|
6531
c938a35588af
Remove density adjustment in ammoshove. Means a mine and a barrel will be batted same distance again.
nemo
parents:
6498
diff
changeset
|
67 |
if (Mask and EXPLAllDamageInRadius) = 0 then |
c938a35588af
Remove density adjustment in ammoshove. Means a mine and a barrel will be batted same distance again.
nemo
parents:
6498
diff
changeset
|
68 |
dmgRadius:= Radius shl 1 |
c938a35588af
Remove density adjustment in ammoshove. Means a mine and a barrel will be batted same distance again.
nemo
parents:
6498
diff
changeset
|
69 |
else |
c938a35588af
Remove density adjustment in ammoshove. Means a mine and a barrel will be batted same distance again.
nemo
parents:
6498
diff
changeset
|
70 |
dmgRadius:= Radius; |
c938a35588af
Remove density adjustment in ammoshove. Means a mine and a barrel will be batted same distance again.
nemo
parents:
6498
diff
changeset
|
71 |
dmgBase:= dmgRadius + cHHRadius div 2; |
c938a35588af
Remove density adjustment in ammoshove. Means a mine and a barrel will be batted same distance again.
nemo
parents:
6498
diff
changeset
|
72 |
fX:= int2hwFloat(X); |
c938a35588af
Remove density adjustment in ammoshove. Means a mine and a barrel will be batted same distance again.
nemo
parents:
6498
diff
changeset
|
73 |
fY:= int2hwFloat(Y); |
c938a35588af
Remove density adjustment in ammoshove. Means a mine and a barrel will be batted same distance again.
nemo
parents:
6498
diff
changeset
|
74 |
Gear:= GearsList; |
c938a35588af
Remove density adjustment in ammoshove. Means a mine and a barrel will be batted same distance again.
nemo
parents:
6498
diff
changeset
|
75 |
while Gear <> nil do |
c938a35588af
Remove density adjustment in ammoshove. Means a mine and a barrel will be batted same distance again.
nemo
parents:
6498
diff
changeset
|
76 |
begin |
c938a35588af
Remove density adjustment in ammoshove. Means a mine and a barrel will be batted same distance again.
nemo
parents:
6498
diff
changeset
|
77 |
dmg:= 0; |
c938a35588af
Remove density adjustment in ammoshove. Means a mine and a barrel will be batted same distance again.
nemo
parents:
6498
diff
changeset
|
78 |
//dmg:= dmgRadius + cHHRadius div 2 - hwRound(Distance(Gear^.X - int2hwFloat(X), Gear^.Y - int2hwFloat(Y))); |
c938a35588af
Remove density adjustment in ammoshove. Means a mine and a barrel will be batted same distance again.
nemo
parents:
6498
diff
changeset
|
79 |
//if (dmg > 1) and |
c938a35588af
Remove density adjustment in ammoshove. Means a mine and a barrel will be batted same distance again.
nemo
parents:
6498
diff
changeset
|
80 |
if (Gear^.State and gstNoDamage) = 0 then |
6468 | 81 |
begin |
6531
c938a35588af
Remove density adjustment in ammoshove. Means a mine and a barrel will be batted same distance again.
nemo
parents:
6498
diff
changeset
|
82 |
case Gear^.Kind of |
c938a35588af
Remove density adjustment in ammoshove. Means a mine and a barrel will be batted same distance again.
nemo
parents:
6498
diff
changeset
|
83 |
gtHedgehog, |
c938a35588af
Remove density adjustment in ammoshove. Means a mine and a barrel will be batted same distance again.
nemo
parents:
6498
diff
changeset
|
84 |
gtMine, |
c938a35588af
Remove density adjustment in ammoshove. Means a mine and a barrel will be batted same distance again.
nemo
parents:
6498
diff
changeset
|
85 |
gtBall, |
c938a35588af
Remove density adjustment in ammoshove. Means a mine and a barrel will be batted same distance again.
nemo
parents:
6498
diff
changeset
|
86 |
gtMelonPiece, |
c938a35588af
Remove density adjustment in ammoshove. Means a mine and a barrel will be batted same distance again.
nemo
parents:
6498
diff
changeset
|
87 |
gtGrenade, |
c938a35588af
Remove density adjustment in ammoshove. Means a mine and a barrel will be batted same distance again.
nemo
parents:
6498
diff
changeset
|
88 |
gtClusterBomb, |
c938a35588af
Remove density adjustment in ammoshove. Means a mine and a barrel will be batted same distance again.
nemo
parents:
6498
diff
changeset
|
89 |
// gtCluster, too game breaking I think |
c938a35588af
Remove density adjustment in ammoshove. Means a mine and a barrel will be batted same distance again.
nemo
parents:
6498
diff
changeset
|
90 |
gtSMine, |
c938a35588af
Remove density adjustment in ammoshove. Means a mine and a barrel will be batted same distance again.
nemo
parents:
6498
diff
changeset
|
91 |
gtCase, |
c938a35588af
Remove density adjustment in ammoshove. Means a mine and a barrel will be batted same distance again.
nemo
parents:
6498
diff
changeset
|
92 |
gtTarget, |
c938a35588af
Remove density adjustment in ammoshove. Means a mine and a barrel will be batted same distance again.
nemo
parents:
6498
diff
changeset
|
93 |
gtFlame, |
c938a35588af
Remove density adjustment in ammoshove. Means a mine and a barrel will be batted same distance again.
nemo
parents:
6498
diff
changeset
|
94 |
gtExplosives, |
c938a35588af
Remove density adjustment in ammoshove. Means a mine and a barrel will be batted same distance again.
nemo
parents:
6498
diff
changeset
|
95 |
gtStructure: begin |
c938a35588af
Remove density adjustment in ammoshove. Means a mine and a barrel will be batted same distance again.
nemo
parents:
6498
diff
changeset
|
96 |
// Run the calcs only once we know we have a type that will need damage |
c938a35588af
Remove density adjustment in ammoshove. Means a mine and a barrel will be batted same distance again.
nemo
parents:
6498
diff
changeset
|
97 |
if hwRound(hwAbs(Gear^.X-fX)+hwAbs(Gear^.Y-fY)) < dmgBase then |
c938a35588af
Remove density adjustment in ammoshove. Means a mine and a barrel will be batted same distance again.
nemo
parents:
6498
diff
changeset
|
98 |
dmg:= dmgBase - max(hwRound(Distance(Gear^.X - fX, Gear^.Y - fY)),Gear^.Radius); |
c938a35588af
Remove density adjustment in ammoshove. Means a mine and a barrel will be batted same distance again.
nemo
parents:
6498
diff
changeset
|
99 |
if dmg > 1 then |
c938a35588af
Remove density adjustment in ammoshove. Means a mine and a barrel will be batted same distance again.
nemo
parents:
6498
diff
changeset
|
100 |
begin |
c938a35588af
Remove density adjustment in ammoshove. Means a mine and a barrel will be batted same distance again.
nemo
parents:
6498
diff
changeset
|
101 |
dmg:= ModifyDamage(min(dmg div 2, Radius), Gear); |
c938a35588af
Remove density adjustment in ammoshove. Means a mine and a barrel will be batted same distance again.
nemo
parents:
6498
diff
changeset
|
102 |
//AddFileLog('Damage: ' + inttostr(dmg)); |
c938a35588af
Remove density adjustment in ammoshove. Means a mine and a barrel will be batted same distance again.
nemo
parents:
6498
diff
changeset
|
103 |
if (Mask and EXPLNoDamage) = 0 then |
6468 | 104 |
begin |
6531
c938a35588af
Remove density adjustment in ammoshove. Means a mine and a barrel will be batted same distance again.
nemo
parents:
6498
diff
changeset
|
105 |
if not Gear^.Invulnerable then |
c938a35588af
Remove density adjustment in ammoshove. Means a mine and a barrel will be batted same distance again.
nemo
parents:
6498
diff
changeset
|
106 |
ApplyDamage(Gear, AttackingHog, dmg, dsExplosion) |
c938a35588af
Remove density adjustment in ammoshove. Means a mine and a barrel will be batted same distance again.
nemo
parents:
6498
diff
changeset
|
107 |
else |
c938a35588af
Remove density adjustment in ammoshove. Means a mine and a barrel will be batted same distance again.
nemo
parents:
6498
diff
changeset
|
108 |
Gear^.State:= Gear^.State or gstWinner; |
c938a35588af
Remove density adjustment in ammoshove. Means a mine and a barrel will be batted same distance again.
nemo
parents:
6498
diff
changeset
|
109 |
end; |
c938a35588af
Remove density adjustment in ammoshove. Means a mine and a barrel will be batted same distance again.
nemo
parents:
6498
diff
changeset
|
110 |
if ((Mask and EXPLDoNotTouchAny) = 0) and (((Mask and EXPLDoNotTouchHH) = 0) or (Gear^.Kind <> gtHedgehog)) then |
c938a35588af
Remove density adjustment in ammoshove. Means a mine and a barrel will be batted same distance again.
nemo
parents:
6498
diff
changeset
|
111 |
begin |
c938a35588af
Remove density adjustment in ammoshove. Means a mine and a barrel will be batted same distance again.
nemo
parents:
6498
diff
changeset
|
112 |
DeleteCI(Gear); |
c938a35588af
Remove density adjustment in ammoshove. Means a mine and a barrel will be batted same distance again.
nemo
parents:
6498
diff
changeset
|
113 |
Gear^.dX:= Gear^.dX + SignAs(_0_005 * dmg + cHHKick, Gear^.X - fX)/(Gear^.Density/_3); |
c938a35588af
Remove density adjustment in ammoshove. Means a mine and a barrel will be batted same distance again.
nemo
parents:
6498
diff
changeset
|
114 |
Gear^.dY:= Gear^.dY + SignAs(_0_005 * dmg + cHHKick, Gear^.Y - fY)/(Gear^.Density/_3); |
c938a35588af
Remove density adjustment in ammoshove. Means a mine and a barrel will be batted same distance again.
nemo
parents:
6498
diff
changeset
|
115 |
|
c938a35588af
Remove density adjustment in ammoshove. Means a mine and a barrel will be batted same distance again.
nemo
parents:
6498
diff
changeset
|
116 |
Gear^.State:= (Gear^.State or gstMoving) and (not gstLoser); |
c938a35588af
Remove density adjustment in ammoshove. Means a mine and a barrel will be batted same distance again.
nemo
parents:
6498
diff
changeset
|
117 |
if not Gear^.Invulnerable then |
c938a35588af
Remove density adjustment in ammoshove. Means a mine and a barrel will be batted same distance again.
nemo
parents:
6498
diff
changeset
|
118 |
Gear^.State:= (Gear^.State or gstMoving) and (not gstWinner); |
c938a35588af
Remove density adjustment in ammoshove. Means a mine and a barrel will be batted same distance again.
nemo
parents:
6498
diff
changeset
|
119 |
Gear^.Active:= true; |
c938a35588af
Remove density adjustment in ammoshove. Means a mine and a barrel will be batted same distance again.
nemo
parents:
6498
diff
changeset
|
120 |
if Gear^.Kind <> gtFlame then FollowGear:= Gear |
c938a35588af
Remove density adjustment in ammoshove. Means a mine and a barrel will be batted same distance again.
nemo
parents:
6498
diff
changeset
|
121 |
end; |
c938a35588af
Remove density adjustment in ammoshove. Means a mine and a barrel will be batted same distance again.
nemo
parents:
6498
diff
changeset
|
122 |
if ((Mask and EXPLPoisoned) <> 0) and (Gear^.Kind = gtHedgehog) and (not Gear^.Invulnerable) then |
c938a35588af
Remove density adjustment in ammoshove. Means a mine and a barrel will be batted same distance again.
nemo
parents:
6498
diff
changeset
|
123 |
Gear^.Hedgehog^.Effects[hePoisoned] := true; |
c938a35588af
Remove density adjustment in ammoshove. Means a mine and a barrel will be batted same distance again.
nemo
parents:
6498
diff
changeset
|
124 |
end; |
6468 | 125 |
|
6531
c938a35588af
Remove density adjustment in ammoshove. Means a mine and a barrel will be batted same distance again.
nemo
parents:
6498
diff
changeset
|
126 |
end; |
c938a35588af
Remove density adjustment in ammoshove. Means a mine and a barrel will be batted same distance again.
nemo
parents:
6498
diff
changeset
|
127 |
gtGrave: begin |
c938a35588af
Remove density adjustment in ammoshove. Means a mine and a barrel will be batted same distance again.
nemo
parents:
6498
diff
changeset
|
128 |
// Run the calcs only once we know we have a type that will need damage |
c938a35588af
Remove density adjustment in ammoshove. Means a mine and a barrel will be batted same distance again.
nemo
parents:
6498
diff
changeset
|
129 |
if hwRound(hwAbs(Gear^.X-fX)+hwAbs(Gear^.Y-fY)) < dmgBase then |
c938a35588af
Remove density adjustment in ammoshove. Means a mine and a barrel will be batted same distance again.
nemo
parents:
6498
diff
changeset
|
130 |
dmg:= dmgBase - hwRound(Distance(Gear^.X - fX, Gear^.Y - fY)); |
c938a35588af
Remove density adjustment in ammoshove. Means a mine and a barrel will be batted same distance again.
nemo
parents:
6498
diff
changeset
|
131 |
if dmg > 1 then |
c938a35588af
Remove density adjustment in ammoshove. Means a mine and a barrel will be batted same distance again.
nemo
parents:
6498
diff
changeset
|
132 |
begin |
c938a35588af
Remove density adjustment in ammoshove. Means a mine and a barrel will be batted same distance again.
nemo
parents:
6498
diff
changeset
|
133 |
dmg:= ModifyDamage(min(dmg div 2, Radius), Gear); |
c938a35588af
Remove density adjustment in ammoshove. Means a mine and a barrel will be batted same distance again.
nemo
parents:
6498
diff
changeset
|
134 |
Gear^.dY:= - _0_004 * dmg; |
c938a35588af
Remove density adjustment in ammoshove. Means a mine and a barrel will be batted same distance again.
nemo
parents:
6498
diff
changeset
|
135 |
Gear^.Active:= true |
c938a35588af
Remove density adjustment in ammoshove. Means a mine and a barrel will be batted same distance again.
nemo
parents:
6498
diff
changeset
|
136 |
end |
c938a35588af
Remove density adjustment in ammoshove. Means a mine and a barrel will be batted same distance again.
nemo
parents:
6498
diff
changeset
|
137 |
end; |
c938a35588af
Remove density adjustment in ammoshove. Means a mine and a barrel will be batted same distance again.
nemo
parents:
6498
diff
changeset
|
138 |
end; |
c938a35588af
Remove density adjustment in ammoshove. Means a mine and a barrel will be batted same distance again.
nemo
parents:
6498
diff
changeset
|
139 |
end; |
c938a35588af
Remove density adjustment in ammoshove. Means a mine and a barrel will be batted same distance again.
nemo
parents:
6498
diff
changeset
|
140 |
Gear:= Gear^.NextGear |
c938a35588af
Remove density adjustment in ammoshove. Means a mine and a barrel will be batted same distance again.
nemo
parents:
6498
diff
changeset
|
141 |
end; |
6468 | 142 |
|
6531
c938a35588af
Remove density adjustment in ammoshove. Means a mine and a barrel will be batted same distance again.
nemo
parents:
6498
diff
changeset
|
143 |
if (Mask and EXPLDontDraw) = 0 then |
c938a35588af
Remove density adjustment in ammoshove. Means a mine and a barrel will be batted same distance again.
nemo
parents:
6498
diff
changeset
|
144 |
if (GameFlags and gfSolidLand) = 0 then |
c938a35588af
Remove density adjustment in ammoshove. Means a mine and a barrel will be batted same distance again.
nemo
parents:
6498
diff
changeset
|
145 |
begin |
c938a35588af
Remove density adjustment in ammoshove. Means a mine and a barrel will be batted same distance again.
nemo
parents:
6498
diff
changeset
|
146 |
cnt:= DrawExplosion(X, Y, Radius) div 1608; // approx 2 16x16 circles to erase per chunk |
c938a35588af
Remove density adjustment in ammoshove. Means a mine and a barrel will be batted same distance again.
nemo
parents:
6498
diff
changeset
|
147 |
if (cnt > 0) and (SpritesData[sprChunk].Texture <> nil) then |
c938a35588af
Remove density adjustment in ammoshove. Means a mine and a barrel will be batted same distance again.
nemo
parents:
6498
diff
changeset
|
148 |
for i:= 0 to cnt do |
c938a35588af
Remove density adjustment in ammoshove. Means a mine and a barrel will be batted same distance again.
nemo
parents:
6498
diff
changeset
|
149 |
AddVisualGear(X, Y, vgtChunk) |
6468 | 150 |
end; |
151 |
||
6531
c938a35588af
Remove density adjustment in ammoshove. Means a mine and a barrel will be batted same distance again.
nemo
parents:
6498
diff
changeset
|
152 |
uAIMisc.AwareOfExplosion(0, 0, 0) |
6468 | 153 |
end; |
154 |
||
155 |
function ModifyDamage(dmg: Longword; Gear: PGear): Longword; |
|
156 |
var i: hwFloat; |
|
157 |
begin |
|
158 |
(* Invulnerability cannot be placed in here due to still needing kicks |
|
159 |
Not without a new damage machine. |
|
160 |
King check should be in here instead of ApplyDamage since Tiy wants them kicked less |
|
161 |
*) |
|
162 |
i:= _1; |
|
6580
6155187bf599
A partial reformatting of the pascal code to have consistent syntax. Things that are still inconsistent.
lovelacer
parents:
6543
diff
changeset
|
163 |
if (CurrentHedgehog <> nil) and CurrentHedgehog^.King then |
6155187bf599
A partial reformatting of the pascal code to have consistent syntax. Things that are still inconsistent.
lovelacer
parents:
6543
diff
changeset
|
164 |
i:= _1_5; |
6468 | 165 |
if (Gear^.Hedgehog <> nil) and (Gear^.Hedgehog^.King) then |
6580
6155187bf599
A partial reformatting of the pascal code to have consistent syntax. Things that are still inconsistent.
lovelacer
parents:
6543
diff
changeset
|
166 |
ModifyDamage:= hwRound(_0_01 * cDamageModifier * dmg * i * cDamagePercent * _0_5) |
6468 | 167 |
else |
6580
6155187bf599
A partial reformatting of the pascal code to have consistent syntax. Things that are still inconsistent.
lovelacer
parents:
6543
diff
changeset
|
168 |
ModifyDamage:= hwRound(_0_01 * cDamageModifier * dmg * i * cDamagePercent) |
6468 | 169 |
end; |
170 |
||
171 |
procedure ApplyDamage(Gear: PGear; AttackerHog: PHedgehog; Damage: Longword; Source: TDamageSource); |
|
172 |
var s: shortstring; |
|
173 |
vampDmg, tmpDmg, i: Longword; |
|
174 |
vg: PVisualGear; |
|
175 |
begin |
|
6580
6155187bf599
A partial reformatting of the pascal code to have consistent syntax. Things that are still inconsistent.
lovelacer
parents:
6543
diff
changeset
|
176 |
if Damage = 0 then |
6155187bf599
A partial reformatting of the pascal code to have consistent syntax. Things that are still inconsistent.
lovelacer
parents:
6543
diff
changeset
|
177 |
exit; // nothing to apply |
6468 | 178 |
|
179 |
if (Gear^.Kind = gtHedgehog) then |
|
6580
6155187bf599
A partial reformatting of the pascal code to have consistent syntax. Things that are still inconsistent.
lovelacer
parents:
6543
diff
changeset
|
180 |
begin |
6155187bf599
A partial reformatting of the pascal code to have consistent syntax. Things that are still inconsistent.
lovelacer
parents:
6543
diff
changeset
|
181 |
Gear^.LastDamage := AttackerHog; |
6468 | 182 |
|
6580
6155187bf599
A partial reformatting of the pascal code to have consistent syntax. Things that are still inconsistent.
lovelacer
parents:
6543
diff
changeset
|
183 |
Gear^.Hedgehog^.Team^.Clan^.Flawless:= false; |
6155187bf599
A partial reformatting of the pascal code to have consistent syntax. Things that are still inconsistent.
lovelacer
parents:
6543
diff
changeset
|
184 |
HHHurt(Gear^.Hedgehog, Source); |
6155187bf599
A partial reformatting of the pascal code to have consistent syntax. Things that are still inconsistent.
lovelacer
parents:
6543
diff
changeset
|
185 |
AddDamageTag(hwRound(Gear^.X), hwRound(Gear^.Y), Damage, Gear^.Hedgehog^.Team^.Clan^.Color); |
6155187bf599
A partial reformatting of the pascal code to have consistent syntax. Things that are still inconsistent.
lovelacer
parents:
6543
diff
changeset
|
186 |
tmpDmg:= min(Damage, max(0,Gear^.Health-Gear^.Damage)); |
6155187bf599
A partial reformatting of the pascal code to have consistent syntax. Things that are still inconsistent.
lovelacer
parents:
6543
diff
changeset
|
187 |
if (Gear <> CurrentHedgehog^.Gear) and (CurrentHedgehog^.Gear <> nil) and (tmpDmg >= 1) then |
6468 | 188 |
begin |
6580
6155187bf599
A partial reformatting of the pascal code to have consistent syntax. Things that are still inconsistent.
lovelacer
parents:
6543
diff
changeset
|
189 |
if cVampiric then |
6468 | 190 |
begin |
6580
6155187bf599
A partial reformatting of the pascal code to have consistent syntax. Things that are still inconsistent.
lovelacer
parents:
6543
diff
changeset
|
191 |
vampDmg:= hwRound(int2hwFloat(tmpDmg)*_0_8); |
6155187bf599
A partial reformatting of the pascal code to have consistent syntax. Things that are still inconsistent.
lovelacer
parents:
6543
diff
changeset
|
192 |
if vampDmg >= 1 then |
6468 | 193 |
begin |
6580
6155187bf599
A partial reformatting of the pascal code to have consistent syntax. Things that are still inconsistent.
lovelacer
parents:
6543
diff
changeset
|
194 |
// was considering pulsing on attack, Tiy thinks it should be permanent while in play |
6155187bf599
A partial reformatting of the pascal code to have consistent syntax. Things that are still inconsistent.
lovelacer
parents:
6543
diff
changeset
|
195 |
//CurrentHedgehog^.Gear^.State:= CurrentHedgehog^.Gear^.State or gstVampiric; |
6155187bf599
A partial reformatting of the pascal code to have consistent syntax. Things that are still inconsistent.
lovelacer
parents:
6543
diff
changeset
|
196 |
inc(CurrentHedgehog^.Gear^.Health,vampDmg); |
6155187bf599
A partial reformatting of the pascal code to have consistent syntax. Things that are still inconsistent.
lovelacer
parents:
6543
diff
changeset
|
197 |
str(vampDmg, s); |
6155187bf599
A partial reformatting of the pascal code to have consistent syntax. Things that are still inconsistent.
lovelacer
parents:
6543
diff
changeset
|
198 |
s:= '+' + s; |
6155187bf599
A partial reformatting of the pascal code to have consistent syntax. Things that are still inconsistent.
lovelacer
parents:
6543
diff
changeset
|
199 |
AddCaption(s, CurrentHedgehog^.Team^.Clan^.Color, capgrpAmmoinfo); |
6155187bf599
A partial reformatting of the pascal code to have consistent syntax. Things that are still inconsistent.
lovelacer
parents:
6543
diff
changeset
|
200 |
RenderHealth(CurrentHedgehog^); |
6155187bf599
A partial reformatting of the pascal code to have consistent syntax. Things that are still inconsistent.
lovelacer
parents:
6543
diff
changeset
|
201 |
RecountTeamHealth(CurrentHedgehog^.Team); |
6155187bf599
A partial reformatting of the pascal code to have consistent syntax. Things that are still inconsistent.
lovelacer
parents:
6543
diff
changeset
|
202 |
i:= 0; |
6155187bf599
A partial reformatting of the pascal code to have consistent syntax. Things that are still inconsistent.
lovelacer
parents:
6543
diff
changeset
|
203 |
while i < vampDmg do |
6155187bf599
A partial reformatting of the pascal code to have consistent syntax. Things that are still inconsistent.
lovelacer
parents:
6543
diff
changeset
|
204 |
begin |
6155187bf599
A partial reformatting of the pascal code to have consistent syntax. Things that are still inconsistent.
lovelacer
parents:
6543
diff
changeset
|
205 |
vg:= AddVisualGear(hwRound(CurrentHedgehog^.Gear^.X), hwRound(CurrentHedgehog^.Gear^.Y), vgtStraightShot); |
6155187bf599
A partial reformatting of the pascal code to have consistent syntax. Things that are still inconsistent.
lovelacer
parents:
6543
diff
changeset
|
206 |
if vg <> nil then |
6155187bf599
A partial reformatting of the pascal code to have consistent syntax. Things that are still inconsistent.
lovelacer
parents:
6543
diff
changeset
|
207 |
with vg^ do |
6155187bf599
A partial reformatting of the pascal code to have consistent syntax. Things that are still inconsistent.
lovelacer
parents:
6543
diff
changeset
|
208 |
begin |
6155187bf599
A partial reformatting of the pascal code to have consistent syntax. Things that are still inconsistent.
lovelacer
parents:
6543
diff
changeset
|
209 |
Tint:= $FF0000FF; |
6155187bf599
A partial reformatting of the pascal code to have consistent syntax. Things that are still inconsistent.
lovelacer
parents:
6543
diff
changeset
|
210 |
State:= ord(sprHealth) |
6155187bf599
A partial reformatting of the pascal code to have consistent syntax. Things that are still inconsistent.
lovelacer
parents:
6543
diff
changeset
|
211 |
end; |
6155187bf599
A partial reformatting of the pascal code to have consistent syntax. Things that are still inconsistent.
lovelacer
parents:
6543
diff
changeset
|
212 |
inc(i, 5); |
6155187bf599
A partial reformatting of the pascal code to have consistent syntax. Things that are still inconsistent.
lovelacer
parents:
6543
diff
changeset
|
213 |
end; |
6155187bf599
A partial reformatting of the pascal code to have consistent syntax. Things that are still inconsistent.
lovelacer
parents:
6543
diff
changeset
|
214 |
end |
6155187bf599
A partial reformatting of the pascal code to have consistent syntax. Things that are still inconsistent.
lovelacer
parents:
6543
diff
changeset
|
215 |
end; |
6155187bf599
A partial reformatting of the pascal code to have consistent syntax. Things that are still inconsistent.
lovelacer
parents:
6543
diff
changeset
|
216 |
if ((GameFlags and gfKarma) <> 0) and |
6155187bf599
A partial reformatting of the pascal code to have consistent syntax. Things that are still inconsistent.
lovelacer
parents:
6543
diff
changeset
|
217 |
((GameFlags and gfInvulnerable) = 0) |
6155187bf599
A partial reformatting of the pascal code to have consistent syntax. Things that are still inconsistent.
lovelacer
parents:
6543
diff
changeset
|
218 |
and (not CurrentHedgehog^.Gear^.Invulnerable) then |
6155187bf599
A partial reformatting of the pascal code to have consistent syntax. Things that are still inconsistent.
lovelacer
parents:
6543
diff
changeset
|
219 |
begin // this cannot just use Damage or it interrupts shotgun and gets you called stupid |
6155187bf599
A partial reformatting of the pascal code to have consistent syntax. Things that are still inconsistent.
lovelacer
parents:
6543
diff
changeset
|
220 |
inc(CurrentHedgehog^.Gear^.Karma, tmpDmg); |
6155187bf599
A partial reformatting of the pascal code to have consistent syntax. Things that are still inconsistent.
lovelacer
parents:
6543
diff
changeset
|
221 |
CurrentHedgehog^.Gear^.LastDamage := CurrentHedgehog; |
6155187bf599
A partial reformatting of the pascal code to have consistent syntax. Things that are still inconsistent.
lovelacer
parents:
6543
diff
changeset
|
222 |
spawnHealthTagForHH(CurrentHedgehog^.Gear, tmpDmg); |
6468 | 223 |
end; |
224 |
uStats.HedgehogDamaged(Gear, AttackerHog, Damage, false); |
|
225 |
end; |
|
6580
6155187bf599
A partial reformatting of the pascal code to have consistent syntax. Things that are still inconsistent.
lovelacer
parents:
6543
diff
changeset
|
226 |
end |
6155187bf599
A partial reformatting of the pascal code to have consistent syntax. Things that are still inconsistent.
lovelacer
parents:
6543
diff
changeset
|
227 |
else if Gear^.Kind <> gtStructure then // not gtHedgehog nor gtStructure |
6468 | 228 |
begin |
229 |
Gear^.Hedgehog:= AttackerHog; |
|
230 |
end; |
|
231 |
inc(Gear^.Damage, Damage); |
|
232 |
||
233 |
ScriptCall('onGearDamage', Gear^.UID, Damage); |
|
234 |
end; |
|
235 |
||
236 |
procedure spawnHealthTagForHH(HHGear: PGear; dmg: Longword); |
|
237 |
var tag: PVisualGear; |
|
238 |
begin |
|
239 |
tag:= AddVisualGear(hwRound(HHGear^.X), hwRound(HHGear^.Y), vgtHealthTag, dmg); |
|
240 |
if (tag <> nil) then |
|
241 |
tag^.Hedgehog:= HHGear^.Hedgehog; // the tag needs the tag to determine the text color |
|
242 |
AllInactive:= false; |
|
243 |
HHGear^.Active:= true; |
|
244 |
end; |
|
245 |
||
246 |
procedure HHHurt(Hedgehog: PHedgehog; Source: TDamageSource); |
|
247 |
begin |
|
248 |
if (Source = dsFall) or (Source = dsExplosion) then |
|
249 |
case random(3) of |
|
250 |
0: PlaySound(sndOoff1, Hedgehog^.Team^.voicepack); |
|
251 |
1: PlaySound(sndOoff2, Hedgehog^.Team^.voicepack); |
|
252 |
2: PlaySound(sndOoff3, Hedgehog^.Team^.voicepack); |
|
253 |
end |
|
254 |
else if (Source = dsPoison) then |
|
255 |
case random(2) of |
|
256 |
0: PlaySound(sndPoisonCough, Hedgehog^.Team^.voicepack); |
|
257 |
1: PlaySound(sndPoisonMoan, Hedgehog^.Team^.voicepack); |
|
258 |
end |
|
259 |
else |
|
260 |
case random(4) of |
|
261 |
0: PlaySound(sndOw1, Hedgehog^.Team^.voicepack); |
|
262 |
1: PlaySound(sndOw2, Hedgehog^.Team^.voicepack); |
|
263 |
2: PlaySound(sndOw3, Hedgehog^.Team^.voicepack); |
|
264 |
3: PlaySound(sndOw4, Hedgehog^.Team^.voicepack); |
|
265 |
end |
|
266 |
end; |
|
267 |
||
268 |
procedure CheckHHDamage(Gear: PGear); |
|
269 |
var |
|
270 |
dmg: Longword; |
|
271 |
i: LongInt; |
|
272 |
particle: PVisualGear; |
|
273 |
begin |
|
274 |
if _0_4 < Gear^.dY then |
|
275 |
begin |
|
276 |
dmg := ModifyDamage(1 + hwRound((hwAbs(Gear^.dY) - _0_4) * 70), Gear); |
|
277 |
PlaySound(sndBump); |
|
6580
6155187bf599
A partial reformatting of the pascal code to have consistent syntax. Things that are still inconsistent.
lovelacer
parents:
6543
diff
changeset
|
278 |
if dmg < 1 then |
6155187bf599
A partial reformatting of the pascal code to have consistent syntax. Things that are still inconsistent.
lovelacer
parents:
6543
diff
changeset
|
279 |
exit; |
6468 | 280 |
|
281 |
for i:= min(12, (3 + dmg div 10)) downto 0 do |
|
282 |
begin |
|
283 |
particle := AddVisualGear(hwRound(Gear^.X) - 5 + Random(10), hwRound(Gear^.Y) + 12, vgtDust); |
|
6580
6155187bf599
A partial reformatting of the pascal code to have consistent syntax. Things that are still inconsistent.
lovelacer
parents:
6543
diff
changeset
|
284 |
if particle <> nil then |
6155187bf599
A partial reformatting of the pascal code to have consistent syntax. Things that are still inconsistent.
lovelacer
parents:
6543
diff
changeset
|
285 |
particle^.dX := particle^.dX + (Gear^.dX.QWordValue / 21474836480); |
6468 | 286 |
end; |
287 |
||
6580
6155187bf599
A partial reformatting of the pascal code to have consistent syntax. Things that are still inconsistent.
lovelacer
parents:
6543
diff
changeset
|
288 |
if (Gear^.Invulnerable) then |
6155187bf599
A partial reformatting of the pascal code to have consistent syntax. Things that are still inconsistent.
lovelacer
parents:
6543
diff
changeset
|
289 |
exit; |
6468 | 290 |
|
291 |
//if _0_6 < Gear^.dY then |
|
292 |
// PlaySound(sndOw4, Gear^.Hedgehog^.Team^.voicepack) |
|
293 |
//else |
|
294 |
// PlaySound(sndOw1, Gear^.Hedgehog^.Team^.voicepack); |
|
295 |
||
296 |
if Gear^.LastDamage <> nil then |
|
297 |
ApplyDamage(Gear, Gear^.LastDamage, dmg, dsFall) |
|
6580
6155187bf599
A partial reformatting of the pascal code to have consistent syntax. Things that are still inconsistent.
lovelacer
parents:
6543
diff
changeset
|
298 |
else |
6468 | 299 |
ApplyDamage(Gear, CurrentHedgehog, dmg, dsFall); |
300 |
end |
|
301 |
end; |
|
302 |
||
303 |
||
304 |
procedure CalcRotationDirAngle(Gear: PGear); |
|
305 |
var |
|
306 |
dAngle: real; |
|
307 |
begin |
|
308 |
dAngle := (Gear^.dX.QWordValue + Gear^.dY.QWordValue) / $80000000; |
|
309 |
if not Gear^.dX.isNegative then |
|
310 |
Gear^.DirAngle := Gear^.DirAngle + dAngle |
|
311 |
else |
|
312 |
Gear^.DirAngle := Gear^.DirAngle - dAngle; |
|
313 |
||
6580
6155187bf599
A partial reformatting of the pascal code to have consistent syntax. Things that are still inconsistent.
lovelacer
parents:
6543
diff
changeset
|
314 |
if Gear^.DirAngle < 0 then |
6155187bf599
A partial reformatting of the pascal code to have consistent syntax. Things that are still inconsistent.
lovelacer
parents:
6543
diff
changeset
|
315 |
Gear^.DirAngle := Gear^.DirAngle + 360 |
6155187bf599
A partial reformatting of the pascal code to have consistent syntax. Things that are still inconsistent.
lovelacer
parents:
6543
diff
changeset
|
316 |
else if 360 < Gear^.DirAngle then |
6155187bf599
A partial reformatting of the pascal code to have consistent syntax. Things that are still inconsistent.
lovelacer
parents:
6543
diff
changeset
|
317 |
Gear^.DirAngle := Gear^.DirAngle - 360 |
6468 | 318 |
end; |
319 |
||
320 |
function CheckGearDrowning(Gear: PGear): boolean; |
|
321 |
var |
|
322 |
skipSpeed, skipAngle, skipDecay: hwFloat; |
|
323 |
i, maxDrops, X, Y: LongInt; |
|
324 |
vdX, vdY: real; |
|
325 |
particle: PVisualGear; |
|
326 |
isSubmersible: boolean; |
|
327 |
begin |
|
328 |
// probably needs tweaking. might need to be in a case statement based upon gear type |
|
329 |
Y:= hwRound(Gear^.Y); |
|
330 |
if cWaterLine < Y + Gear^.Radius then |
|
331 |
begin |
|
6498 | 332 |
isSubmersible:= (Gear = CurrentHedgehog^.Gear) and (CurAmmoGear <> nil) and (CurAmmoGear^.AmmoType = amJetpack); |
6468 | 333 |
skipSpeed := _0_25; |
334 |
skipAngle := _1_9; |
|
335 |
skipDecay := _0_87; |
|
336 |
X:= hwRound(Gear^.X); |
|
337 |
vdX:= hwFloat2Float(Gear^.dX); |
|
338 |
vdY:= hwFloat2Float(Gear^.dY); |
|
339 |
// this could perhaps be a tiny bit higher. |
|
6580
6155187bf599
A partial reformatting of the pascal code to have consistent syntax. Things that are still inconsistent.
lovelacer
parents:
6543
diff
changeset
|
340 |
if (hwSqr(Gear^.dX) + hwSqr(Gear^.dY) > skipSpeed) |
6155187bf599
A partial reformatting of the pascal code to have consistent syntax. Things that are still inconsistent.
lovelacer
parents:
6543
diff
changeset
|
341 |
and (hwAbs(Gear^.dX) > skipAngle * hwAbs(Gear^.dY)) then |
6468 | 342 |
begin |
343 |
Gear^.dY.isNegative := true; |
|
344 |
Gear^.dY := Gear^.dY * skipDecay; |
|
345 |
Gear^.dX := Gear^.dX * skipDecay; |
|
346 |
CheckGearDrowning := false; |
|
347 |
PlaySound(sndSkip) |
|
348 |
end |
|
349 |
else |
|
350 |
begin |
|
351 |
if not isSubmersible then |
|
352 |
begin |
|
353 |
CheckGearDrowning := true; |
|
354 |
Gear^.State := gstDrowning; |
|
355 |
Gear^.RenderTimer := false; |
|
6580
6155187bf599
A partial reformatting of the pascal code to have consistent syntax. Things that are still inconsistent.
lovelacer
parents:
6543
diff
changeset
|
356 |
if (Gear^.Kind <> gtSniperRifleShot) and (Gear^.Kind <> gtShotgunShot) |
6155187bf599
A partial reformatting of the pascal code to have consistent syntax. Things that are still inconsistent.
lovelacer
parents:
6543
diff
changeset
|
357 |
and (Gear^.Kind <> gtDEagleShot) and (Gear^.Kind <> gtSineGunShot) then |
6468 | 358 |
if Gear^.Kind = gtHedgehog then |
359 |
begin |
|
360 |
if Gear^.Hedgehog^.Effects[heResurrectable] then |
|
361 |
ResurrectHedgehog(Gear) |
|
362 |
else |
|
363 |
begin |
|
364 |
Gear^.doStep := @doStepDrowningGear; |
|
365 |
Gear^.State := Gear^.State and (not gstHHDriven); |
|
366 |
AddCaption(Format(GetEventString(eidDrowned), Gear^.Hedgehog^.Name), cWhiteColor, capgrpMessage); |
|
367 |
end |
|
368 |
end |
|
6580
6155187bf599
A partial reformatting of the pascal code to have consistent syntax. Things that are still inconsistent.
lovelacer
parents:
6543
diff
changeset
|
369 |
else |
6155187bf599
A partial reformatting of the pascal code to have consistent syntax. Things that are still inconsistent.
lovelacer
parents:
6543
diff
changeset
|
370 |
Gear^.doStep := @doStepDrowningGear; |
6155187bf599
A partial reformatting of the pascal code to have consistent syntax. Things that are still inconsistent.
lovelacer
parents:
6543
diff
changeset
|
371 |
if Gear^.Kind = gtFlake then |
6155187bf599
A partial reformatting of the pascal code to have consistent syntax. Things that are still inconsistent.
lovelacer
parents:
6543
diff
changeset
|
372 |
exit // skip splashes |
6468 | 373 |
end; |
6580
6155187bf599
A partial reformatting of the pascal code to have consistent syntax. Things that are still inconsistent.
lovelacer
parents:
6543
diff
changeset
|
374 |
if ((not isSubmersible) and (Y < cWaterLine + 64 + Gear^.Radius)) |
6155187bf599
A partial reformatting of the pascal code to have consistent syntax. Things that are still inconsistent.
lovelacer
parents:
6543
diff
changeset
|
375 |
or (isSubmersible and (Y < cWaterLine + 2 + Gear^.Radius) and ((CurAmmoGear^.Pos = 0) |
6155187bf599
A partial reformatting of the pascal code to have consistent syntax. Things that are still inconsistent.
lovelacer
parents:
6543
diff
changeset
|
376 |
and (CurAmmoGear^.dY < _0_01))) then |
6468 | 377 |
// don't play splash if they are already way past the surface |
378 |
PlaySound(sndSplash) |
|
379 |
end; |
|
380 |
||
6580
6155187bf599
A partial reformatting of the pascal code to have consistent syntax. Things that are still inconsistent.
lovelacer
parents:
6543
diff
changeset
|
381 |
if ((cReducedQuality and rqPlainSplash) = 0) |
6155187bf599
A partial reformatting of the pascal code to have consistent syntax. Things that are still inconsistent.
lovelacer
parents:
6543
diff
changeset
|
382 |
and (((not isSubmersible) and (Y < cWaterLine + 64 + Gear^.Radius)) |
6155187bf599
A partial reformatting of the pascal code to have consistent syntax. Things that are still inconsistent.
lovelacer
parents:
6543
diff
changeset
|
383 |
or (isSubmersible and (Y < cWaterLine + 2 + Gear^.Radius) and ((CurAmmoGear^.Pos = 0) |
6155187bf599
A partial reformatting of the pascal code to have consistent syntax. Things that are still inconsistent.
lovelacer
parents:
6543
diff
changeset
|
384 |
and (CurAmmoGear^.dY < _0_01)))) then |
6468 | 385 |
begin |
386 |
AddVisualGear(X, cWaterLine, vgtSplash); |
|
387 |
||
388 |
maxDrops := (Gear^.Radius div 2) + round(vdX * Gear^.Radius * 2) + round(vdY * Gear^.Radius * 2); |
|
389 |
for i:= max(maxDrops div 3, min(32, Random(maxDrops))) downto 0 do |
|
390 |
begin |
|
391 |
particle := AddVisualGear(X - 3 + Random(6), cWaterLine, vgtDroplet); |
|
392 |
if particle <> nil then |
|
393 |
begin |
|
394 |
particle^.dX := particle^.dX - vdX / 10; |
|
395 |
particle^.dY := particle^.dY - vdY / 5; |
|
396 |
end |
|
397 |
end |
|
398 |
end; |
|
6580
6155187bf599
A partial reformatting of the pascal code to have consistent syntax. Things that are still inconsistent.
lovelacer
parents:
6543
diff
changeset
|
399 |
if isSubmersible and (CurAmmoGear^.Pos = 0) then |
6155187bf599
A partial reformatting of the pascal code to have consistent syntax. Things that are still inconsistent.
lovelacer
parents:
6543
diff
changeset
|
400 |
CurAmmoGear^.Pos := 1000 |
6468 | 401 |
end |
402 |
else |
|
403 |
CheckGearDrowning := false; |
|
404 |
end; |
|
405 |
||
406 |
||
407 |
procedure ResurrectHedgehog(gear: PGear); |
|
408 |
var tempTeam : PTeam; |
|
409 |
begin |
|
410 |
AttackBar:= 0; |
|
411 |
gear^.dX := _0; |
|
412 |
gear^.dY := _0; |
|
413 |
gear^.Damage := 0; |
|
414 |
gear^.Health := gear^.Hedgehog^.InitialHealth; |
|
415 |
gear^.Hedgehog^.Effects[hePoisoned] := false; |
|
416 |
if not CurrentHedgehog^.Effects[heResurrectable] then |
|
417 |
with CurrentHedgehog^ do |
|
418 |
begin |
|
419 |
inc(Team^.stats.AIKills); |
|
420 |
FreeTexture(Team^.AIKillsTex); |
|
421 |
Team^.AIKillsTex := RenderStringTex(inttostr(Team^.stats.AIKills), Team^.Clan^.Color, fnt16); |
|
422 |
end; |
|
423 |
tempTeam := gear^.Hedgehog^.Team; |
|
424 |
DeleteCI(gear); |
|
425 |
FindPlace(gear, false, 0, LAND_WIDTH, true); |
|
6580
6155187bf599
A partial reformatting of the pascal code to have consistent syntax. Things that are still inconsistent.
lovelacer
parents:
6543
diff
changeset
|
426 |
if gear <> nil then |
6155187bf599
A partial reformatting of the pascal code to have consistent syntax. Things that are still inconsistent.
lovelacer
parents:
6543
diff
changeset
|
427 |
begin |
6468 | 428 |
RenderHealth(gear^.Hedgehog^); |
429 |
ScriptCall('onGearResurrect', gear^.uid); |
|
430 |
gear^.State := gstWait; |
|
431 |
end; |
|
432 |
RecountTeamHealth(tempTeam); |
|
433 |
end; |
|
434 |
||
6490 | 435 |
function CountNonZeroz(x, y, r, c: LongInt): LongInt; |
436 |
var i: LongInt; |
|
437 |
count: LongInt = 0; |
|
438 |
begin |
|
439 |
if (y and LAND_HEIGHT_MASK) = 0 then |
|
440 |
for i:= max(x - r, 0) to min(x + r, LAND_WIDTH - 4) do |
|
441 |
if Land[y, i] <> 0 then |
|
442 |
begin |
|
443 |
inc(count); |
|
6580
6155187bf599
A partial reformatting of the pascal code to have consistent syntax. Things that are still inconsistent.
lovelacer
parents:
6543
diff
changeset
|
444 |
if count = c then |
6155187bf599
A partial reformatting of the pascal code to have consistent syntax. Things that are still inconsistent.
lovelacer
parents:
6543
diff
changeset
|
445 |
exit(count) |
6490 | 446 |
end; |
447 |
CountNonZeroz:= count; |
|
448 |
end; |
|
6468 | 449 |
|
450 |
procedure FindPlace(var Gear: PGear; withFall: boolean; Left, Right: LongInt; skipProximity: boolean); |
|
451 |
var x: LongInt; |
|
452 |
y, sy: LongInt; |
|
453 |
ar: array[0..511] of TPoint; |
|
454 |
ar2: array[0..1023] of TPoint; |
|
455 |
cnt, cnt2: Longword; |
|
456 |
delta: LongInt; |
|
457 |
reallySkip, tryAgain: boolean; |
|
458 |
begin |
|
459 |
reallySkip:= false; // try not skipping proximity at first |
|
460 |
tryAgain:= true; |
|
461 |
while tryAgain do |
|
462 |
begin |
|
463 |
delta:= 250; |
|
464 |
cnt2:= 0; |
|
465 |
repeat |
|
466 |
x:= Left + LongInt(GetRandom(Delta)); |
|
467 |
repeat |
|
468 |
inc(x, Delta); |
|
469 |
cnt:= 0; |
|
470 |
y:= min(1024, topY) - 2 * Gear^.Radius; |
|
471 |
while y < cWaterLine do |
|
472 |
begin |
|
473 |
repeat |
|
474 |
inc(y, 2); |
|
475 |
until (y >= cWaterLine) or (CountNonZeroz(x, y, Gear^.Radius - 1, 1) = 0); |
|
476 |
||
477 |
sy:= y; |
|
478 |
||
479 |
repeat |
|
480 |
inc(y); |
|
481 |
until (y >= cWaterLine) or (CountNonZeroz(x, y, Gear^.Radius - 1, 1) <> 0); |
|
482 |
||
6580
6155187bf599
A partial reformatting of the pascal code to have consistent syntax. Things that are still inconsistent.
lovelacer
parents:
6543
diff
changeset
|
483 |
if (y - sy > Gear^.Radius * 2) |
6155187bf599
A partial reformatting of the pascal code to have consistent syntax. Things that are still inconsistent.
lovelacer
parents:
6543
diff
changeset
|
484 |
and (((Gear^.Kind = gtExplosives) |
6155187bf599
A partial reformatting of the pascal code to have consistent syntax. Things that are still inconsistent.
lovelacer
parents:
6543
diff
changeset
|
485 |
and (y < cWaterLine) |
6155187bf599
A partial reformatting of the pascal code to have consistent syntax. Things that are still inconsistent.
lovelacer
parents:
6543
diff
changeset
|
486 |
and (reallySkip or (CheckGearsNear(x, y - Gear^.Radius, [gtFlame, gtHedgehog, gtMine, gtCase, gtExplosives], 60, 60) = nil)) |
6155187bf599
A partial reformatting of the pascal code to have consistent syntax. Things that are still inconsistent.
lovelacer
parents:
6543
diff
changeset
|
487 |
and (CountNonZeroz(x, y+1, Gear^.Radius - 1, Gear^.Radius+1) > Gear^.Radius)) |
6155187bf599
A partial reformatting of the pascal code to have consistent syntax. Things that are still inconsistent.
lovelacer
parents:
6543
diff
changeset
|
488 |
or |
6155187bf599
A partial reformatting of the pascal code to have consistent syntax. Things that are still inconsistent.
lovelacer
parents:
6543
diff
changeset
|
489 |
((Gear^.Kind <> gtExplosives) |
6155187bf599
A partial reformatting of the pascal code to have consistent syntax. Things that are still inconsistent.
lovelacer
parents:
6543
diff
changeset
|
490 |
and (y < cWaterLine) |
6155187bf599
A partial reformatting of the pascal code to have consistent syntax. Things that are still inconsistent.
lovelacer
parents:
6543
diff
changeset
|
491 |
and (reallySkip or (CheckGearsNear(x, y - Gear^.Radius, [gtFlame, gtHedgehog, gtMine, gtCase, gtExplosives], 110, 110) = nil)))) then |
6155187bf599
A partial reformatting of the pascal code to have consistent syntax. Things that are still inconsistent.
lovelacer
parents:
6543
diff
changeset
|
492 |
|
6155187bf599
A partial reformatting of the pascal code to have consistent syntax. Things that are still inconsistent.
lovelacer
parents:
6543
diff
changeset
|
493 |
begin |
6468 | 494 |
ar[cnt].X:= x; |
6580
6155187bf599
A partial reformatting of the pascal code to have consistent syntax. Things that are still inconsistent.
lovelacer
parents:
6543
diff
changeset
|
495 |
if withFall then |
6155187bf599
A partial reformatting of the pascal code to have consistent syntax. Things that are still inconsistent.
lovelacer
parents:
6543
diff
changeset
|
496 |
ar[cnt].Y:= sy + Gear^.Radius |
6155187bf599
A partial reformatting of the pascal code to have consistent syntax. Things that are still inconsistent.
lovelacer
parents:
6543
diff
changeset
|
497 |
else |
6155187bf599
A partial reformatting of the pascal code to have consistent syntax. Things that are still inconsistent.
lovelacer
parents:
6543
diff
changeset
|
498 |
ar[cnt].Y:= y - Gear^.Radius; |
6468 | 499 |
inc(cnt) |
500 |
end; |
|
501 |
||
502 |
inc(y, 45) |
|
503 |
end; |
|
504 |
||
505 |
if cnt > 0 then |
|
506 |
with ar[GetRandom(cnt)] do |
|
507 |
begin |
|
508 |
ar2[cnt2].x:= x; |
|
509 |
ar2[cnt2].y:= y; |
|
510 |
inc(cnt2) |
|
511 |
end |
|
512 |
until (x + Delta > Right); |
|
513 |
||
514 |
dec(Delta, 60) |
|
515 |
until (cnt2 > 0) or (Delta < 70); |
|
6580
6155187bf599
A partial reformatting of the pascal code to have consistent syntax. Things that are still inconsistent.
lovelacer
parents:
6543
diff
changeset
|
516 |
if (cnt2 = 0) and skipProximity and (not reallySkip) then |
6155187bf599
A partial reformatting of the pascal code to have consistent syntax. Things that are still inconsistent.
lovelacer
parents:
6543
diff
changeset
|
517 |
tryAgain:= true |
6468 | 518 |
else tryAgain:= false; |
519 |
reallySkip:= true; |
|
520 |
end; |
|
521 |
||
522 |
if cnt2 > 0 then |
|
523 |
with ar2[GetRandom(cnt2)] do |
|
524 |
begin |
|
525 |
Gear^.X:= int2hwFloat(x); |
|
526 |
Gear^.Y:= int2hwFloat(y); |
|
527 |
AddFileLog('Assigned Gear coordinates (' + inttostr(x) + ',' + inttostr(y) + ')'); |
|
528 |
end |
|
529 |
else |
|
530 |
begin |
|
531 |
OutError('Can''t find place for Gear', false); |
|
6580
6155187bf599
A partial reformatting of the pascal code to have consistent syntax. Things that are still inconsistent.
lovelacer
parents:
6543
diff
changeset
|
532 |
if Gear^.Kind = gtHedgehog then |
6155187bf599
A partial reformatting of the pascal code to have consistent syntax. Things that are still inconsistent.
lovelacer
parents:
6543
diff
changeset
|
533 |
Gear^.Hedgehog^.Effects[heResurrectable] := false; |
6468 | 534 |
DeleteGear(Gear); |
535 |
Gear:= nil |
|
536 |
end |
|
537 |
end; |
|
538 |
||
539 |
function CheckGearNear(Gear: PGear; Kind: TGearType; rX, rY: LongInt): PGear; |
|
540 |
var t: PGear; |
|
541 |
begin |
|
542 |
t:= GearsList; |
|
543 |
rX:= sqr(rX); |
|
544 |
rY:= sqr(rY); |
|
545 |
||
546 |
while t <> nil do |
|
547 |
begin |
|
548 |
if (t <> Gear) and (t^.Kind = Kind) then |
|
549 |
if not((hwSqr(Gear^.X - t^.X) / rX + hwSqr(Gear^.Y - t^.Y) / rY) > _1) then |
|
550 |
exit(t); |
|
551 |
t:= t^.NextGear |
|
552 |
end; |
|
553 |
||
554 |
CheckGearNear:= nil |
|
555 |
end; |
|
556 |
||
557 |
||
558 |
function CheckGearsNear(mX, mY: LongInt; Kind: TGearsType; rX, rY: LongInt): PGear; |
|
559 |
var t: PGear; |
|
560 |
begin |
|
561 |
t:= GearsList; |
|
562 |
rX:= sqr(rX); |
|
563 |
rY:= sqr(rY); |
|
564 |
while t <> nil do |
|
565 |
begin |
|
566 |
if t^.Kind in Kind then |
|
567 |
if not (hwSqr(int2hwFloat(mX) - t^.X) / rX + hwSqr(int2hwFloat(mY) - t^.Y) / rY > _1) then |
|
568 |
exit(t); |
|
569 |
t:= t^.NextGear |
|
570 |
end; |
|
571 |
CheckGearsNear:= nil |
|
572 |
end; |
|
573 |
end. |