author | belphegorr <szabibibi@gmail.com> |
Thu, 16 Aug 2012 16:06:24 +0300 | |
changeset 7454 | ce7d7138b436 |
parent 7409 | fd91aa100ce0 |
child 7426 | 55b49cc1f33a |
permissions | -rw-r--r-- |
6581 | 1 |
(* |
2 |
* Hedgewars, a free turn based strategy game |
|
6700 | 3 |
* Copyright (c) 2004-2012 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 |
|
16 |
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA |
|
17 |
*) |
|
18 |
||
19 |
{$INCLUDE "options.inc"} |
|
20 |
||
21 |
unit uGearsHedgehog; |
|
22 |
interface |
|
23 |
uses uTypes; |
|
24 |
||
25 |
procedure doStepHedgehog(Gear: PGear); |
|
26 |
procedure AfterAttack; |
|
27 |
procedure HedgehogStep(Gear: PGear); |
|
28 |
procedure doStepHedgehogMoving(Gear: PGear); |
|
29 |
procedure HedgehogChAngle(HHGear: PGear); |
|
30 |
procedure PickUp(HH, Gear: PGear); |
|
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:
7375
diff
changeset
|
31 |
procedure AddPickup(HH: THedgehog; ammo: TAmmoType; cnt, X, Y: LongWord); |
6581 | 32 |
|
33 |
implementation |
|
6992 | 34 |
uses uConsts, uVariables, uFloat, uAmmos, uSound, uCaptions, |
6581 | 35 |
uCommands, uLocale, uUtils, uVisualGears, uStats, uIO, uScript, |
36 |
uGearsList, uGears, uCollisions, uRandom, uStore, uTeams, |
|
37 |
uGearsUtils; |
|
38 |
||
7028 | 39 |
var GHStepTicks: LongWord = 0; |
40 |
||
6581 | 41 |
// Shouldn't more of this ammo switching stuff be moved to uAmmos ? |
42 |
function ChangeAmmo(HHGear: PGear): boolean; |
|
43 |
var slot, i: Longword; |
|
44 |
ammoidx: LongInt; |
|
45 |
begin |
|
46 |
ChangeAmmo:= false; |
|
47 |
slot:= HHGear^.MsgParam; |
|
48 |
||
49 |
with HHGear^.Hedgehog^ do |
|
50 |
begin |
|
51 |
HHGear^.Message:= HHGear^.Message and (not gmSlot); |
|
52 |
ammoidx:= 0; |
|
53 |
if ((HHGear^.State and (gstAttacking or gstAttacked)) <> 0) |
|
54 |
or ((MultiShootAttacks > 0) and ((Ammoz[CurAmmoType].Ammo.Propz and ammoprop_NoRoundEnd) = 0)) |
|
55 |
or ((HHGear^.State and gstHHDriven) = 0) then |
|
56 |
exit; |
|
57 |
ChangeAmmo:= true; |
|
58 |
||
59 |
while (ammoidx < cMaxSlotAmmoIndex) and (Ammo^[slot, ammoidx].AmmoType <> CurAmmoType) do |
|
60 |
inc(ammoidx); |
|
61 |
||
62 |
if ((Ammoz[CurAmmoType].Ammo.Propz and ammoprop_NoRoundEnd) <> 0) and (MultiShootAttacks > 0) then |
|
63 |
OnUsedAmmo(HHGear^.Hedgehog^); |
|
64 |
||
65 |
MultiShootAttacks:= 0; |
|
66 |
HHGear^.Message:= HHGear^.Message and (not (gmLJump or gmHJump)); |
|
67 |
||
68 |
if Ammoz[CurAmmoType].Slot = slot then |
|
69 |
begin |
|
70 |
i:= 0; |
|
71 |
repeat |
|
72 |
inc(ammoidx); |
|
73 |
if (ammoidx > cMaxSlotAmmoIndex) then |
|
74 |
begin |
|
75 |
inc(i); |
|
76 |
CurAmmoType:= amNothing; |
|
77 |
ammoidx:= -1; |
|
78 |
//TryDo(i < 2, 'Engine bug: no ammo in current slot', true) |
|
79 |
end; |
|
80 |
until (i = 1) or ((Ammo^[slot, ammoidx].Count > 0) |
|
81 |
and (Team^.Clan^.TurnNumber > Ammoz[Ammo^[slot, ammoidx].AmmoType].SkipTurns)) |
|
82 |
||
83 |
end |
|
84 |
else |
|
85 |
begin |
|
86 |
i:= 0; |
|
87 |
// check whether there is ammo in slot |
|
88 |
while (i <= cMaxSlotAmmoIndex) and ((Ammo^[slot, i].Count = 0) |
|
89 |
or (Team^.Clan^.TurnNumber <= Ammoz[Ammo^[slot, i].AmmoType].SkipTurns)) |
|
90 |
do inc(i); |
|
91 |
||
92 |
if i <= cMaxSlotAmmoIndex then |
|
93 |
ammoidx:= i |
|
94 |
else ammoidx:= -1 |
|
95 |
end; |
|
96 |
if ammoidx >= 0 then |
|
97 |
CurAmmoType:= Ammo^[slot, ammoidx].AmmoType; |
|
98 |
end |
|
99 |
end; |
|
100 |
||
101 |
procedure HHSetWeapon(HHGear: PGear); |
|
102 |
var t: LongInt; |
|
103 |
weap: TAmmoType; |
|
104 |
Hedgehog: PHedgehog; |
|
105 |
s: boolean; |
|
106 |
begin |
|
107 |
s:= false; |
|
108 |
||
109 |
weap:= TAmmoType(HHGear^.MsgParam); |
|
110 |
Hedgehog:= HHGear^.Hedgehog; |
|
111 |
||
112 |
if Hedgehog^.Team^.Clan^.TurnNumber <= Ammoz[weap].SkipTurns then |
|
113 |
exit; // weapon is not activated yet |
|
114 |
||
115 |
HHGear^.MsgParam:= Ammoz[weap].Slot; |
|
116 |
||
117 |
t:= cMaxSlotAmmoIndex; |
|
118 |
||
119 |
HHGear^.Message:= HHGear^.Message and (not gmWeapon); |
|
120 |
||
121 |
with Hedgehog^ do |
|
122 |
while (CurAmmoType <> weap) and (t >= 0) do |
|
123 |
begin |
|
124 |
s:= ChangeAmmo(HHGear); |
|
125 |
dec(t) |
|
126 |
end; |
|
127 |
||
128 |
if s then |
|
129 |
ApplyAmmoChanges(HHGear^.Hedgehog^) |
|
130 |
end; |
|
131 |
||
132 |
procedure HHSetTimer(Gear: PGear); |
|
133 |
var CurWeapon: PAmmo; |
|
134 |
color: LongWord; |
|
135 |
begin |
|
136 |
Gear^.Message:= Gear^.Message and (not gmTimer); |
|
6924 | 137 |
CurWeapon:= GetCurAmmoEntry(Gear^.Hedgehog^); |
6581 | 138 |
with Gear^.Hedgehog^ do |
139 |
if ((Gear^.Message and gmPrecise) <> 0) and ((CurWeapon^.Propz and ammoprop_SetBounce) <> 0) then |
|
140 |
begin |
|
141 |
color:= Gear^.Hedgehog^.Team^.Clan^.Color; |
|
142 |
case Gear^.MsgParam of |
|
143 |
1: begin |
|
7069 | 144 |
AddCaption(FormatA(trmsg[sidBounce], trmsg[sidBounce1]), color, capgrpAmmostate); |
6581 | 145 |
CurWeapon^.Bounciness:= 350; |
146 |
end; |
|
147 |
2: begin |
|
7069 | 148 |
AddCaption(FormatA(trmsg[sidBounce], trmsg[sidBounce2]), color, capgrpAmmostate); |
6581 | 149 |
CurWeapon^.Bounciness:= 700; |
150 |
end; |
|
151 |
3: begin |
|
7069 | 152 |
AddCaption(FormatA(trmsg[sidBounce], trmsg[sidBounce3]), color, capgrpAmmostate); |
6581 | 153 |
CurWeapon^.Bounciness:= 1000; |
154 |
end; |
|
155 |
4: begin |
|
7069 | 156 |
AddCaption(FormatA(trmsg[sidBounce], trmsg[sidBounce4]), color, capgrpAmmostate); |
6581 | 157 |
CurWeapon^.Bounciness:= 2000; |
158 |
end; |
|
159 |
5: begin |
|
7069 | 160 |
AddCaption(FormatA(trmsg[sidBounce], trmsg[sidBounce5]), color, capgrpAmmostate); |
6581 | 161 |
CurWeapon^.Bounciness:= 4000; |
162 |
end |
|
163 |
end |
|
164 |
end |
|
165 |
else if (CurWeapon^.Propz and ammoprop_Timerable) <> 0 then |
|
166 |
begin |
|
167 |
CurWeapon^.Timer:= 1000 * Gear^.MsgParam; |
|
168 |
with CurrentTeam^ do |
|
169 |
ApplyAmmoChanges(Hedgehogs[CurrHedgehog]); |
|
170 |
end; |
|
171 |
end; |
|
172 |
||
173 |
||
174 |
procedure Attack(Gear: PGear); |
|
175 |
var xx, yy, newDx, newDy, lx, ly: hwFloat; |
|
176 |
speech: PVisualGear; |
|
177 |
newGear: PGear; |
|
178 |
CurWeapon: PAmmo; |
|
179 |
altUse: boolean; |
|
180 |
elastic: hwFloat; |
|
181 |
begin |
|
182 |
newGear:= nil; |
|
183 |
bShowFinger:= false; |
|
6924 | 184 |
CurWeapon:= GetCurAmmoEntry(Gear^.Hedgehog^); |
6581 | 185 |
with Gear^, |
186 |
Gear^.Hedgehog^ do |
|
187 |
begin |
|
188 |
if ((State and gstHHDriven) <> 0) and ((State and (gstAttacked or gstHHChooseTarget)) = 0) and (((State and gstMoving) = 0) |
|
189 |
or (Power > 0) |
|
190 |
or (CurAmmoType = amTeleport) |
|
191 |
or |
|
192 |
// Allow attacks while moving on ammo with AltAttack |
|
193 |
((CurAmmoGear <> nil) and ((Ammoz[CurAmmoGear^.AmmoType].Ammo.Propz and ammoprop_AltAttack) <> 0)) |
|
194 |
or ((Ammoz[CurAmmoType].Ammo.Propz and ammoprop_AttackInMove) <> 0)) |
|
195 |
and ((TargetPoint.X <> NoPointX) or ((Ammoz[CurAmmoType].Ammo.Propz and ammoprop_NeedTarget) = 0)) then |
|
196 |
begin |
|
197 |
State:= State or gstAttacking; |
|
198 |
if Power = cMaxPower then |
|
199 |
Message:= Message and (not gmAttack) |
|
200 |
else if (Ammoz[CurAmmoType].Ammo.Propz and ammoprop_Power) = 0 then |
|
201 |
Message:= Message and (not gmAttack) |
|
202 |
else |
|
203 |
begin |
|
204 |
if Power = 0 then |
|
205 |
begin |
|
206 |
AttackBar:= CurrentTeam^.AttackBar; |
|
207 |
PlaySound(sndThrowPowerUp) |
|
208 |
end; |
|
209 |
inc(Power) |
|
210 |
end; |
|
211 |
if ((Message and gmAttack) <> 0) then |
|
212 |
exit; |
|
213 |
||
214 |
if (Ammoz[CurAmmoType].Ammo.Propz and ammoprop_Power) <> 0 then |
|
215 |
begin |
|
216 |
StopSound(sndThrowPowerUp); |
|
217 |
PlaySound(sndThrowRelease); |
|
218 |
end; |
|
219 |
||
220 |
xx:= SignAs(AngleSin(Angle), dX); |
|
221 |
yy:= -AngleCos(Angle); |
|
222 |
||
223 |
lx:= X + int2hwfloat(round(GetLaunchX(CurAmmoType, hwSign(dX), Angle))); |
|
224 |
ly:= Y + int2hwfloat(round(GetLaunchY(CurAmmoType, Angle))); |
|
225 |
||
226 |
if ((Gear^.State and gstHHHJump) <> 0) and (not cArtillery) then |
|
227 |
xx:= - xx; |
|
228 |
if Ammoz[CurAmmoType].Ammo.AttackVoice <> sndNone then |
|
229 |
AddVoice(Ammoz[CurAmmoType].Ammo.AttackVoice, CurrentTeam^.voicepack); |
|
230 |
||
231 |
// Initiating alt attack |
|
232 |
if (CurAmmoGear <> nil) |
|
233 |
and ((Ammoz[CurAmmoGear^.AmmoType].Ammo.Propz and ammoprop_AltAttack) <> 0) |
|
234 |
and ((Gear^.Message and gmLJump) <> 0) |
|
235 |
and ((Ammoz[CurAmmoType].Ammo.Propz and ammoprop_AltUse) <> 0) then |
|
236 |
begin |
|
237 |
newDx:= dX / _2; |
|
238 |
newDy:= dY / _2; |
|
239 |
altUse:= true; |
|
240 |
end |
|
241 |
else |
|
242 |
begin |
|
243 |
newDx:= xx*Power/cPowerDivisor; |
|
244 |
newDy:= yy*Power/cPowerDivisor; |
|
245 |
altUse:= false |
|
246 |
end; |
|
247 |
||
248 |
case CurAmmoType of |
|
249 |
amGrenade: newGear:= AddGear(hwRound(lx), hwRound(ly), gtGrenade, 0, newDx, newDy, CurWeapon^.Timer); |
|
250 |
amMolotov: newGear:= AddGear(hwRound(lx), hwRound(ly), gtMolotov, 0, newDx, newDy, 0); |
|
251 |
amClusterBomb: newGear:= AddGear(hwRound(lx), hwRound(ly), gtClusterBomb, 0, newDx, newDy, CurWeapon^.Timer); |
|
252 |
amGasBomb: newGear:= AddGear(hwRound(lx), hwRound(ly), gtGasBomb, 0, newDx, newDy, CurWeapon^.Timer); |
|
253 |
amBazooka: newGear:= AddGear(hwRound(lx), hwRound(ly), gtShell, 0, newDx, newDy, 0); |
|
254 |
amSnowball: newGear:= AddGear(hwRound(lx), hwRound(ly), gtSnowball, 0, newDx, newDy, 0); |
|
255 |
amBee: newGear:= AddGear(hwRound(lx), hwRound(ly), gtBee, 0, newDx, newDy, 0); |
|
256 |
amShotgun: begin |
|
257 |
PlaySound(sndShotgunReload); |
|
258 |
newGear:= AddGear(hwRound(lx), hwRound(ly), gtShotgunShot, 0, xx * _0_5, yy * _0_5, 0); |
|
259 |
end; |
|
260 |
amPickHammer: newGear:= AddGear(hwRound(lx), hwRound(ly) + cHHRadius, gtPickHammer, 0, _0, _0, 0); |
|
261 |
amSkip: ParseCommand('/skip', true); |
|
262 |
amRope: newGear:= AddGear(hwRound(lx), hwRound(ly), gtRope, 0, xx, yy, 0); |
|
263 |
amMine: if altUse then |
|
264 |
newGear:= AddGear(hwRound(lx) + hwSign(dX) * 7, hwRound(ly), gtMine, gstWait, newDx, newDy, 3000) |
|
265 |
else |
|
266 |
newGear:= AddGear(hwRound(lx) + hwSign(dX) * 7, hwRound(ly), gtMine, gstWait, SignAs(_0_02, dX), _0, 3000); |
|
267 |
amSMine: newGear:= AddGear(hwRound(lx), hwRound(ly), gtSMine, 0, xx*Power/cPowerDivisor, yy*Power/cPowerDivisor, 0); |
|
268 |
amDEagle: newGear:= AddGear(hwRound(lx + xx * cHHRadius), hwRound(ly + yy * cHHRadius), gtDEagleShot, 0, xx * _0_5, yy * _0_5, 0); |
|
269 |
amSineGun: newGear:= AddGear(hwRound(lx + xx * cHHRadius), hwRound(ly + yy * cHHRadius), gtSineGunShot, 0, xx * _0_5, yy * _0_5, 0); |
|
270 |
amPortalGun: begin |
|
271 |
newGear:= AddGear(hwRound(lx + xx * cHHRadius), hwRound(ly + yy * cHHRadius), gtPortal, 0, xx * _0_6, yy * _0_6, |
|
272 |
// set selected color |
|
273 |
CurWeapon^.Pos); |
|
274 |
end; |
|
275 |
amSniperRifle: begin |
|
276 |
PlaySound(sndSniperReload); |
|
277 |
newGear:= AddGear(hwRound(lx + xx * cHHRadius), hwRound(ly + yy * cHHRadius), gtSniperRifleShot, 0, xx * _0_5, yy * _0_5, 0); |
|
278 |
end; |
|
279 |
amDynamite: newGear:= AddGear(hwRound(lx) + hwSign(dX) * 7, hwRound(ly), gtDynamite, 0, SignAs(_0_03, dX), _0, 5000); |
|
280 |
amFirePunch: newGear:= AddGear(hwRound(lx) + hwSign(dX) * 10, hwRound(ly), gtFirePunch, 0, xx, _0, 0); |
|
281 |
amWhip: begin |
|
282 |
newGear:= AddGear(hwRound(lx) + hwSign(dX) * 10, hwRound(ly), gtWhip, 0, SignAs(_1, dX), - _0_8, 0); |
|
283 |
PlaySound(sndWhipCrack) |
|
284 |
end; |
|
285 |
amHammer: begin |
|
286 |
newGear:= AddGear(hwRound(lx) + hwSign(dX) * 10, hwRound(ly), gtHammer, 0, SignAs(_1, dX), - _0_8, 0); |
|
287 |
PlaySound(sndWhack) |
|
288 |
end; |
|
289 |
amBaseballBat: begin |
|
290 |
newGear:= AddGear(hwRound(lx) + hwSign(dX) * 10, hwRound(ly), gtShover, gsttmpFlag, xx * _0_5, yy * _0_5, 0); |
|
291 |
PlaySound(sndBaseballBat) // TODO: Only play if something is hit? |
|
292 |
end; |
|
293 |
amParachute: begin |
|
294 |
newGear:= AddGear(hwRound(lx), hwRound(ly), gtParachute, 0, _0, _0, 0); |
|
295 |
PlaySound(sndParachute) |
|
296 |
end; |
|
297 |
// we save CurWeapon^.Pos (in this case: cursor direction) by using it as (otherwise irrelevant) X value of the new gear. |
|
298 |
amAirAttack: newGear:= AddGear(CurWeapon^.Pos, 0, gtAirAttack, 0, _0, _0, 0); |
|
299 |
amMineStrike: newGear:= AddGear(CurWeapon^.Pos, 0, gtAirAttack, 1, _0, _0, 0); |
|
300 |
amDrillStrike: newGear:= AddGear(CurWeapon^.Pos, 0, gtAirAttack, 3, _0, _0, CurWeapon^.Timer); |
|
301 |
amNapalm: newGear:= AddGear(CurWeapon^.Pos, 0, gtAirAttack, 2, _0, _0, 0); |
|
302 |
amBlowTorch: newGear:= AddGear(hwRound(lx), hwRound(ly), gtBlowTorch, 0, SignAs(_0_5, dX), _0, 0); |
|
303 |
amGirder: newGear:= AddGear(0, 0, gtGirder, CurWeapon^.Pos, _0, _0, 0); |
|
304 |
amTeleport: newGear:= AddGear(CurWeapon^.Pos, 0, gtTeleport, 0, _0, _0, 0); |
|
305 |
amSwitch: newGear:= AddGear(hwRound(lx), hwRound(ly), gtSwitcher, 0, _0, _0, 0); |
|
306 |
amMortar: begin |
|
307 |
playSound(sndMortar); |
|
308 |
newGear:= AddGear(hwRound(lx), hwRound(ly), gtMortar, 0, xx*cMaxPower/cPowerDivisor, yy*cMaxPower/cPowerDivisor, 0); |
|
309 |
end; |
|
310 |
amRCPlane: begin |
|
311 |
newGear:= AddGear(hwRound(lx), hwRound(ly), gtRCPlane, 0, xx * cMaxPower / cPowerDivisor / 4, yy * cMaxPower / cPowerDivisor / 4, 0); |
|
7053 | 312 |
newGear^.SoundChannel:= LoopSound(sndRCPlane) |
6581 | 313 |
end; |
314 |
amKamikaze: newGear:= AddGear(hwRound(lx), hwRound(ly), gtKamikaze, 0, xx * _0_5, yy * _0_5, 0); |
|
315 |
amCake: newGear:= AddGear(hwRound(lx) + hwSign(dX) * 3, hwRound(ly), gtCake, 0, xx, _0, 0); |
|
316 |
amSeduction: newGear:= AddGear(hwRound(lx), hwRound(ly), gtSeduction, 0, _0, _0, 0); |
|
317 |
amWatermelon: newGear:= AddGear(hwRound(lx), hwRound(ly), gtWatermelon, 0, newDx, newDy, CurWeapon^.Timer); |
|
318 |
amHellishBomb: newGear:= AddGear(hwRound(lx), hwRound(ly), gtHellishBomb, 0, newDx, newDy, 0); |
|
319 |
amDrill: newGear:= AddGear(hwRound(lx), hwRound(ly), gtDrill, 0, newDx, newDy, 0); |
|
320 |
amBallgun: newGear:= AddGear(hwRound(X), hwRound(Y), gtBallgun, 0, xx * _0_5, yy * _0_5, 0); |
|
321 |
amJetpack: newGear:= AddGear(hwRound(lx), hwRound(ly), gtJetpack, 0, _0, _0, 0); |
|
322 |
amBirdy: begin |
|
323 |
PlaySound(sndWhistle); |
|
324 |
newGear:= AddGear(hwRound(lx), hwRound(ly) - 32, gtBirdy, 0, _0, _0, 0); |
|
325 |
end; |
|
326 |
amLowGravity: begin |
|
327 |
PlaySound(sndLowGravity); |
|
328 |
cGravity:= cMaxWindSpeed; |
|
329 |
cGravityf:= 0.00025 |
|
330 |
end; |
|
331 |
amExtraDamage: begin |
|
332 |
PlaySound(sndHellishImpact4); |
|
333 |
cDamageModifier:= _1_5 |
|
334 |
end; |
|
335 |
amInvulnerable: Invulnerable:= true; |
|
336 |
amExtraTime: begin |
|
337 |
PlaySound(sndSwitchHog); |
|
338 |
TurnTimeLeft:= TurnTimeLeft + 30000 |
|
339 |
end; |
|
340 |
amLaserSight: cLaserSighting:= true; |
|
341 |
amVampiric: begin |
|
7053 | 342 |
PlaySoundV(sndOw1, Team^.voicepack); |
6581 | 343 |
cVampiric:= true; |
344 |
end; |
|
345 |
amPiano: begin |
|
346 |
// Tuck the hedgehog away until the piano attack is completed |
|
347 |
Unplaced:= true; |
|
348 |
X:= _0; |
|
349 |
Y:= _0; |
|
350 |
newGear:= AddGear(TargetPoint.X, 0, gtPiano, 0, _0, _0, 0); |
|
351 |
PauseMusic |
|
352 |
end; |
|
353 |
amFlamethrower: newGear:= AddGear(hwRound(X), hwRound(Y), gtFlamethrower, 0, xx * _0_5, yy * _0_5, 0); |
|
354 |
amLandGun: newGear:= AddGear(hwRound(X), hwRound(Y), gtLandGun, 0, xx * _0_5, yy * _0_5, 0); |
|
355 |
amResurrector: begin |
|
356 |
newGear:= AddGear(hwRound(lx), hwRound(ly), gtResurrector, 0, _0, _0, 0); |
|
357 |
newGear^.SoundChannel := LoopSound(sndResurrector); |
|
358 |
end; |
|
359 |
amStructure: newGear:= AddGear(hwRound(lx) + hwSign(dX) * 7, hwRound(ly), gtStructure, gstWait, SignAs(_0_02, dX), _0, 3000); |
|
360 |
amTardis: newGear:= AddGear(hwRound(X), hwRound(Y), gtTardis, 0, _0, _0, 5000); |
|
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:
6992
diff
changeset
|
361 |
amIceGun: newGear:= AddGear(hwRound(X), hwRound(Y), gtIceGun, 0, _0, _0, 0); |
6581 | 362 |
end; |
363 |
||
364 |
case CurAmmoType of |
|
365 |
amGrenade, amMolotov, |
|
366 |
amClusterBomb, amGasBomb, |
|
367 |
amBazooka, amSnowball, |
|
368 |
amBee, amSMine, |
|
369 |
amMortar, amWatermelon, |
|
370 |
amHellishBomb, amDrill: FollowGear:= newGear; |
|
371 |
||
372 |
amShotgun, amPickHammer, |
|
373 |
amRope, amDEagle, |
|
374 |
amSineGun, amSniperRifle, |
|
375 |
amFirePunch, amWhip, |
|
376 |
amHammer, amBaseballBat, |
|
377 |
amParachute, amBlowTorch, |
|
378 |
amGirder, amTeleport, |
|
379 |
amSwitch, amRCPlane, |
|
380 |
amKamikaze, amCake, |
|
381 |
amSeduction, amBallgun, |
|
382 |
amJetpack, amBirdy, |
|
383 |
amFlamethrower, amLandGun, |
|
384 |
amResurrector, amStructure, |
|
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:
6992
diff
changeset
|
385 |
amTardis, amPiano, |
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:
6992
diff
changeset
|
386 |
amIceGun: CurAmmoGear:= newGear; |
6581 | 387 |
end; |
388 |
||
389 |
if ((CurAmmoType = amMine) or (CurAmmoType = amSMine)) and (GameFlags and gfInfAttack <> 0) then |
|
390 |
newGear^.FlightTime:= GameTicks + 1000 |
|
391 |
else if CurAmmoType = amDrill then |
|
392 |
newGear^.FlightTime:= GameTicks + 250; |
|
393 |
if Ammoz[CurAmmoType].Ammo.Propz and ammoprop_NeedTarget <> 0 then |
|
394 |
begin |
|
395 |
newGear^.Target.X:= TargetPoint.X; |
|
396 |
newGear^.Target.Y:= TargetPoint.Y |
|
397 |
end; |
|
7272
71df899c4163
Second part of the change. Make collision check use the new mask bit.
nemo
parents:
7187
diff
changeset
|
398 |
if newGear <> nil then newGear^.CollisionMask:= $FF7F; |
6581 | 399 |
|
400 |
// Clear FollowGear if using on a rope/parachute/saucer etc so focus stays with the hog's movement |
|
401 |
if altUse then |
|
402 |
FollowGear:= nil; |
|
403 |
||
404 |
if (newGear <> nil) and ((Ammoz[newGear^.AmmoType].Ammo.Propz and ammoprop_SetBounce) <> 0) then |
|
405 |
begin |
|
406 |
elastic:= int2hwfloat(CurWeapon^.Bounciness) / _1000; |
|
407 |
||
408 |
if elastic < _1 then |
|
409 |
newGear^.Elasticity:= newGear^.Elasticity * elastic |
|
410 |
else if elastic > _1 then |
|
411 |
newGear^.Elasticity:= _1 - ((_1-newGear^.Elasticity) / elastic); |
|
412 |
(* Experimented with friction modifier. Didn't seem helpful |
|
413 |
fric:= int2hwfloat(CurWeapon^.Bounciness) / _250; |
|
414 |
if fric < _1 then newGear^.Friction:= newGear^.Friction * fric |
|
415 |
else if fric > _1 then newGear^.Friction:= _1 - ((_1-newGear^.Friction) / fric)*) |
|
416 |
end; |
|
417 |
||
418 |
||
419 |
uStats.AmmoUsed(CurAmmoType); |
|
420 |
||
421 |
if not (SpeechText = '') then |
|
422 |
begin |
|
423 |
speech:= AddVisualGear(0, 0, vgtSpeechBubble); |
|
424 |
if speech <> nil then |
|
425 |
begin |
|
426 |
speech^.Text:= SpeechText; |
|
427 |
speech^.Hedgehog:= Gear^.Hedgehog; |
|
428 |
speech^.FrameTicks:= SpeechType; |
|
429 |
end; |
|
430 |
SpeechText:= '' |
|
431 |
end; |
|
432 |
||
433 |
Power:= 0; |
|
434 |
if (CurAmmoGear <> nil) |
|
435 |
and ((Ammoz[CurAmmoType].Ammo.Propz and ammoprop_AltUse) = 0){check for dropping ammo from rope} then |
|
436 |
begin |
|
437 |
Message:= Message or gmAttack; |
|
438 |
CurAmmoGear^.Message:= Message |
|
439 |
end |
|
440 |
else |
|
441 |
begin |
|
442 |
if not CurrentTeam^.ExtDriven |
|
443 |
and ((Ammoz[CurAmmoType].Ammo.Propz and ammoprop_Power) <> 0) then |
|
7067
f98ec3aecf4e
A solution to char vs string problem: mark single-letter strings with _S macro
unc0rr
parents:
7053
diff
changeset
|
444 |
SendIPC(_S'a'); |
6581 | 445 |
AfterAttack; |
446 |
end |
|
447 |
end |
|
448 |
else |
|
449 |
Message:= Message and (not gmAttack); |
|
450 |
end; |
|
451 |
TargetPoint.X := NoPointX; |
|
452 |
ScriptCall('onHogAttack'); |
|
453 |
end; |
|
454 |
||
455 |
procedure AfterAttack; |
|
456 |
var s: shortstring; |
|
457 |
a: TAmmoType; |
|
458 |
begin |
|
459 |
with CurrentHedgehog^.Gear^, CurrentHedgehog^ do |
|
460 |
begin |
|
461 |
a:= CurAmmoType; |
|
462 |
State:= State and (not gstAttacking); |
|
463 |
if (Ammoz[a].Ammo.Propz and ammoprop_Effect) = 0 then |
|
464 |
begin |
|
465 |
Inc(MultiShootAttacks); |
|
466 |
||
467 |
if (Ammoz[a].Ammo.NumPerTurn >= MultiShootAttacks) then |
|
468 |
begin |
|
469 |
s:= inttostr(Ammoz[a].Ammo.NumPerTurn - MultiShootAttacks + 1); |
|
470 |
AddCaption(format(trmsg[sidRemaining], s), cWhiteColor, capgrpAmmostate); |
|
471 |
end; |
|
472 |
||
473 |
if (Ammoz[a].Ammo.NumPerTurn >= MultiShootAttacks) |
|
474 |
or ((GameFlags and gfMultiWeapon) <> 0) then |
|
475 |
begin |
|
476 |
isInMultiShoot:= true |
|
477 |
end |
|
478 |
else |
|
479 |
begin |
|
480 |
OnUsedAmmo(CurrentHedgehog^); |
|
481 |
if ((Ammoz[a].Ammo.Propz and ammoprop_NoRoundEnd) = 0) and (((GameFlags and gfInfAttack) = 0) or PlacingHogs) then |
|
482 |
begin |
|
483 |
if TagTurnTimeLeft = 0 then |
|
484 |
TagTurnTimeLeft:= TurnTimeLeft; |
|
485 |
TurnTimeLeft:=(Ammoz[a].TimeAfterTurn * cGetAwayTime) div 100; |
|
486 |
end; |
|
487 |
if ((Ammoz[a].Ammo.Propz and ammoprop_NoRoundEnd) = 0) then |
|
488 |
State:= State or gstAttacked; |
|
489 |
if (Ammoz[a].Ammo.Propz and ammoprop_NoRoundEnd) <> 0 then |
|
490 |
ApplyAmmoChanges(CurrentHedgehog^) |
|
491 |
end; |
|
492 |
end |
|
493 |
else |
|
494 |
begin |
|
495 |
OnUsedAmmo(CurrentHedgehog^); |
|
496 |
ApplyAmmoChanges(CurrentHedgehog^); |
|
497 |
end; |
|
498 |
AttackBar:= 0 |
|
499 |
end |
|
500 |
end; |
|
501 |
||
502 |
//////////////////////////////////////////////////////////////////////////////// |
|
503 |
procedure doStepHedgehogDead(Gear: PGear); |
|
504 |
const frametime = 200; |
|
505 |
timertime = frametime * 6; |
|
506 |
begin |
|
507 |
if Gear^.Hedgehog^.Unplaced then |
|
508 |
exit; |
|
509 |
if Gear^.Timer > 1 then |
|
510 |
begin |
|
511 |
AllInactive:= false; |
|
512 |
dec(Gear^.Timer); |
|
513 |
if (Gear^.Timer mod frametime) = 0 then |
|
514 |
inc(Gear^.Pos) |
|
515 |
end |
|
516 |
else if Gear^.Timer = 1 then |
|
517 |
begin |
|
518 |
Gear^.State:= Gear^.State or gstNoDamage; |
|
519 |
doMakeExplosion(hwRound(Gear^.X), hwRound(Gear^.Y), 30, CurrentHedgehog, EXPLAutoSound); |
|
520 |
AddGear(hwRound(Gear^.X), hwRound(Gear^.Y), gtGrave, 0, _0, _0, 0)^.Hedgehog:= Gear^.Hedgehog; |
|
521 |
DeleteGear(Gear); |
|
522 |
SetAllToActive |
|
523 |
end |
|
524 |
else // Gear^.Timer = 0 |
|
525 |
begin |
|
526 |
AllInactive:= false; |
|
527 |
Gear^.Z:= cCurrHHZ; |
|
528 |
RemoveGearFromList(Gear); |
|
529 |
InsertGearToList(Gear); |
|
7053 | 530 |
PlaySoundV(sndByeBye, Gear^.Hedgehog^.Team^.voicepack); |
6581 | 531 |
Gear^.Pos:= 0; |
532 |
Gear^.Timer:= timertime |
|
533 |
end |
|
534 |
end; |
|
535 |
||
536 |
//////////////////////////////////////////////////////////////////////////////// |
|
537 |
procedure doStepHedgehogGone(Gear: PGear); |
|
538 |
const frametime = 65; |
|
539 |
timertime = frametime * 11; |
|
540 |
begin |
|
541 |
if Gear^.Hedgehog^.Unplaced then |
|
542 |
exit; |
|
543 |
if Gear^.Timer > 1 then |
|
544 |
begin |
|
545 |
AllInactive:= false; |
|
546 |
dec(Gear^.Timer); |
|
547 |
if (Gear^.Timer mod frametime) = 0 then |
|
548 |
inc(Gear^.Pos) |
|
549 |
end |
|
550 |
else |
|
551 |
if Gear^.Timer = 1 then |
|
552 |
begin |
|
553 |
DeleteGear(Gear); |
|
554 |
SetAllToActive |
|
555 |
end |
|
556 |
else // Gear^.Timer = 0 |
|
557 |
begin |
|
558 |
AllInactive:= false; |
|
559 |
Gear^.Z:= cCurrHHZ; |
|
560 |
RemoveGearFromList(Gear); |
|
561 |
InsertGearToList(Gear); |
|
7053 | 562 |
PlaySoundV(sndByeBye, Gear^.Hedgehog^.Team^.voicepack); |
6581 | 563 |
PlaySound(sndWarp); |
564 |
Gear^.Pos:= 0; |
|
565 |
Gear^.Timer:= timertime |
|
566 |
end |
|
567 |
end; |
|
568 |
||
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:
7375
diff
changeset
|
569 |
procedure AddPickup(HH: THedgehog; ammo: TAmmoType; cnt, X, Y: LongWord); |
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:
7375
diff
changeset
|
570 |
var s: shortstring; |
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:
7375
diff
changeset
|
571 |
vga: PVisualGear; |
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:
7375
diff
changeset
|
572 |
begin |
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:
7375
diff
changeset
|
573 |
PlaySound(sndShotgunReload); |
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:
7375
diff
changeset
|
574 |
if cnt <> 0 then AddAmmo(HH, ammo, cnt) |
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:
7375
diff
changeset
|
575 |
else AddAmmo(HH, ammo); |
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:
7375
diff
changeset
|
576 |
|
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:
7375
diff
changeset
|
577 |
if (not (HH.Team^.ExtDriven |
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:
7375
diff
changeset
|
578 |
or (HH.BotLevel > 0))) |
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:
7375
diff
changeset
|
579 |
or (HH.Team^.Clan^.ClanIndex = LocalClan) |
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:
7375
diff
changeset
|
580 |
or (GameType = gmtDemo) 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:
7375
diff
changeset
|
581 |
begin |
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:
7375
diff
changeset
|
582 |
if cnt <> 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:
7375
diff
changeset
|
583 |
s:= trammo[Ammoz[ammo].NameId] + ' (+' + IntToStr(cnt) + ')' |
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:
7375
diff
changeset
|
584 |
else |
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:
7375
diff
changeset
|
585 |
s:= trammo[Ammoz[ammo].NameId] + ' (+' + IntToStr(Ammoz[ammo].NumberInCase) + ')'; |
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:
7375
diff
changeset
|
586 |
AddCaption(s, HH.Team^.Clan^.Color, capgrpAmmoinfo); |
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:
7375
diff
changeset
|
587 |
|
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:
7375
diff
changeset
|
588 |
// show ammo icon |
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:
7375
diff
changeset
|
589 |
vga:= AddVisualGear(X, Y, vgtAmmo); |
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:
7375
diff
changeset
|
590 |
if vga <> nil 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:
7375
diff
changeset
|
591 |
vga^.Frame:= Longword(ammo); |
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:
7375
diff
changeset
|
592 |
end; |
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:
7375
diff
changeset
|
593 |
end; |
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:
7375
diff
changeset
|
594 |
|
6581 | 595 |
//////////////////////////////////////////////////////////////////////////////// |
596 |
procedure PickUp(HH, Gear: PGear); |
|
597 |
var s: shortstring; |
|
598 |
a: TAmmoType; |
|
7406
1fe2c821f9bf
Try avoiding spamming the log by retaining the gears. untested.
nemo
parents:
7391
diff
changeset
|
599 |
i: LongInt; |
6581 | 600 |
vga: PVisualGear; |
7406
1fe2c821f9bf
Try avoiding spamming the log by retaining the gears. untested.
nemo
parents:
7391
diff
changeset
|
601 |
ag, gi: PGear; |
6581 | 602 |
begin |
603 |
Gear^.Message:= gmDestroy; |
|
604 |
if (Gear^.Pos and posCaseExplode) <> 0 then |
|
605 |
if (Gear^.Pos and posCasePoison) <> 0 then |
|
606 |
doMakeExplosion(hwRound(Gear^.X), hwRound(Gear^.Y), 25, HH^.Hedgehog, EXPLAutoSound + EXPLPoisoned) |
|
607 |
else |
|
608 |
doMakeExplosion(hwRound(Gear^.X), hwRound(Gear^.Y), 25, HH^.Hedgehog, EXPLAutoSound) |
|
609 |
else if (Gear^.Pos and posCasePoison) <> 0 then |
|
610 |
doMakeExplosion(hwRound(Gear^.X), hwRound(Gear^.Y), 25, HH^.Hedgehog, EXPLAutoSound + EXPLPoisoned + EXPLNoDamage) |
|
611 |
else |
|
612 |
case Gear^.Pos of |
|
613 |
posCaseUtility, |
|
614 |
posCaseAmmo: begin |
|
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:
7375
diff
changeset
|
615 |
if Gear^.AmmoType <> amNothing 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:
7375
diff
changeset
|
616 |
begin |
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:
7375
diff
changeset
|
617 |
AddPickup(HH^.Hedgehog^, Gear^.AmmoType, Gear^.Power, hwRound(Gear^.X), hwRound(Gear^.Y)); |
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:
7375
diff
changeset
|
618 |
end |
6581 | 619 |
else |
620 |
begin |
|
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:
7375
diff
changeset
|
621 |
// Add spawning here... |
7409 | 622 |
AddRandomness(GameTicks); |
7406
1fe2c821f9bf
Try avoiding spamming the log by retaining the gears. untested.
nemo
parents:
7391
diff
changeset
|
623 |
|
1fe2c821f9bf
Try avoiding spamming the log by retaining the gears. untested.
nemo
parents:
7391
diff
changeset
|
624 |
gi := GearsList; |
1fe2c821f9bf
Try avoiding spamming the log by retaining the gears. untested.
nemo
parents:
7391
diff
changeset
|
625 |
while gi <> nil do |
7391
588eabb4b384
Apparently order of multiple getrandom in params is undefined. Also remove broken and pointless getrandom call.
nemo
parents:
7389
diff
changeset
|
626 |
begin |
7406
1fe2c821f9bf
Try avoiding spamming the log by retaining the gears. untested.
nemo
parents:
7391
diff
changeset
|
627 |
if gi^.Kind = gtGenericFaller then |
1fe2c821f9bf
Try avoiding spamming the log by retaining the gears. untested.
nemo
parents:
7391
diff
changeset
|
628 |
begin |
1fe2c821f9bf
Try avoiding spamming the log by retaining the gears. untested.
nemo
parents:
7391
diff
changeset
|
629 |
gi^.Active:= true; |
1fe2c821f9bf
Try avoiding spamming the log by retaining the gears. untested.
nemo
parents:
7391
diff
changeset
|
630 |
gi^.X:= int2hwFloat(GetRandom(rightX-leftX)+leftX); |
1fe2c821f9bf
Try avoiding spamming the log by retaining the gears. untested.
nemo
parents:
7391
diff
changeset
|
631 |
gi^.Y:= int2hwFloat(GetRandom(LAND_HEIGHT-topY)+topY); |
1fe2c821f9bf
Try avoiding spamming the log by retaining the gears. untested.
nemo
parents:
7391
diff
changeset
|
632 |
gi^.dX:= _90-(GetRandomf*_360); |
1fe2c821f9bf
Try avoiding spamming the log by retaining the gears. untested.
nemo
parents:
7391
diff
changeset
|
633 |
gi^.dY:= _90-(GetRandomf*_360) |
1fe2c821f9bf
Try avoiding spamming the log by retaining the gears. untested.
nemo
parents:
7391
diff
changeset
|
634 |
end; |
1fe2c821f9bf
Try avoiding spamming the log by retaining the gears. untested.
nemo
parents:
7391
diff
changeset
|
635 |
gi := gi^.NextGear |
7391
588eabb4b384
Apparently order of multiple getrandom in params is undefined. Also remove broken and pointless getrandom call.
nemo
parents:
7389
diff
changeset
|
636 |
end; |
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:
7375
diff
changeset
|
637 |
ag:= AddGear(hwRound(Gear^.X), hwRound(Gear^.Y), gtAddAmmo, gstInvisible, _0, _0, GetRandom(200)+100); |
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:
7375
diff
changeset
|
638 |
ag^.Pos:= Gear^.Pos; |
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:
7375
diff
changeset
|
639 |
ag^.Power:= Gear^.Power |
6581 | 640 |
end; |
641 |
end; |
|
642 |
posCaseHealth: begin |
|
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:
7375
diff
changeset
|
643 |
PlaySound(sndShotgunReload); |
6581 | 644 |
inc(HH^.Health, Gear^.Health); |
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:
6992
diff
changeset
|
645 |
HH^.Hedgehog^.Effects[hePoisoned] := 0; |
6581 | 646 |
str(Gear^.Health, s); |
647 |
s:= '+' + s; |
|
648 |
AddCaption(s, HH^.Hedgehog^.Team^.Clan^.Color, capgrpAmmoinfo); |
|
649 |
RenderHealth(HH^.Hedgehog^); |
|
650 |
RecountTeamHealth(HH^.Hedgehog^.Team); |
|
651 |
||
652 |
i:= 0; |
|
653 |
while i < Gear^.Health do |
|
654 |
begin |
|
655 |
vga:= AddVisualGear(hwRound(HH^.X), hwRound(HH^.Y), vgtStraightShot); |
|
656 |
if vga <> nil then |
|
657 |
with vga^ do |
|
658 |
begin |
|
659 |
Tint:= $00FF00FF; |
|
660 |
State:= ord(sprHealth) |
|
661 |
end; |
|
662 |
inc(i, 5); |
|
663 |
end; |
|
664 |
end; |
|
665 |
end |
|
666 |
end; |
|
667 |
||
668 |
procedure HedgehogStep(Gear: PGear); |
|
669 |
var PrevdX: LongInt; |
|
670 |
CurWeapon: PAmmo; |
|
671 |
begin |
|
6924 | 672 |
CurWeapon:= GetCurAmmoEntry(Gear^.Hedgehog^); |
6581 | 673 |
if ((Gear^.State and (gstAttacking or gstMoving)) = 0) then |
674 |
begin |
|
675 |
if isCursorVisible then |
|
676 |
with Gear^.Hedgehog^ do |
|
677 |
with CurWeapon^ do |
|
678 |
begin |
|
679 |
if (Gear^.Message and gmLeft ) <> 0 then |
|
680 |
Pos:= (Pos - 1 + Ammoz[AmmoType].PosCount) mod Ammoz[AmmoType].PosCount |
|
681 |
else |
|
682 |
if (Gear^.Message and gmRight ) <> 0 then |
|
683 |
Pos:= (Pos + 1) mod Ammoz[AmmoType].PosCount |
|
684 |
else |
|
685 |
exit; |
|
7028 | 686 |
GHStepTicks:= 200; |
6581 | 687 |
exit |
688 |
end; |
|
689 |
||
690 |
if ((Gear^.Message and gmAnimate) <> 0) then |
|
691 |
begin |
|
692 |
Gear^.Message:= 0; |
|
693 |
Gear^.State:= Gear^.State or gstAnimation; |
|
694 |
Gear^.Tag:= Gear^.MsgParam; |
|
695 |
Gear^.Timer:= 0; |
|
696 |
Gear^.Pos:= 0 |
|
697 |
end; |
|
698 |
||
699 |
if ((Gear^.Message and gmLJump ) <> 0) then |
|
700 |
begin |
|
701 |
Gear^.Message:= Gear^.Message and (not gmLJump); |
|
702 |
DeleteCI(Gear); |
|
703 |
if TestCollisionYwithGear(Gear, -1) = 0 then |
|
704 |
if not TestCollisionXwithXYShift(Gear, _0, -2, hwSign(Gear^.dX)) then |
|
705 |
Gear^.Y:= Gear^.Y - _2 |
|
706 |
else |
|
707 |
if not TestCollisionXwithXYShift(Gear, _0, -1, hwSign(Gear^.dX)) then |
|
708 |
Gear^.Y:= Gear^.Y - _1; |
|
709 |
if not (TestCollisionXwithGear(Gear, hwSign(Gear^.dX)) |
|
710 |
or (TestCollisionYwithGear(Gear, -1) <> 0)) then |
|
711 |
begin |
|
712 |
Gear^.dY:= -_0_15; |
|
713 |
if not cArtillery then |
|
714 |
Gear^.dX:= SignAs(_0_15, Gear^.dX); |
|
715 |
Gear^.State:= Gear^.State or gstMoving or gstHHJumping; |
|
7053 | 716 |
PlaySoundV(sndJump1, Gear^.Hedgehog^.Team^.voicepack); |
6581 | 717 |
exit |
718 |
end; |
|
719 |
end; |
|
720 |
||
721 |
if ((Gear^.Message and gmHJump ) <> 0) then |
|
722 |
begin |
|
723 |
DeleteCI(Gear); |
|
724 |
Gear^.Message:= Gear^.Message and (not gmHJump); |
|
725 |
||
726 |
Gear^.dY:= -_0_2; |
|
727 |
SetLittle(Gear^.dX); |
|
728 |
Gear^.State:= Gear^.State or gstMoving or gstHHJumping; |
|
7053 | 729 |
PlaySoundV(sndJump3, Gear^.Hedgehog^.Team^.voicepack); |
6581 | 730 |
exit |
731 |
end; |
|
732 |
||
733 |
PrevdX:= hwSign(Gear^.dX); |
|
734 |
if (Gear^.Message and gmLeft )<>0 then |
|
735 |
Gear^.dX:= -cLittle else |
|
736 |
if (Gear^.Message and gmRight )<>0 then |
|
7187
aff30d80bd7b
- Allow camera movement while current hedgehog is falling
unc0rr
parents:
7164
diff
changeset
|
737 |
Gear^.dX:= cLittle |
aff30d80bd7b
- Allow camera movement while current hedgehog is falling
unc0rr
parents:
7164
diff
changeset
|
738 |
else exit; |
6581 | 739 |
|
7187
aff30d80bd7b
- Allow camera movement while current hedgehog is falling
unc0rr
parents:
7164
diff
changeset
|
740 |
StepSoundTimer:= cHHStepTicks; |
6581 | 741 |
|
7028 | 742 |
GHStepTicks:= cHHStepTicks; |
6581 | 743 |
if PrevdX <> hwSign(Gear^.dX) then |
744 |
begin |
|
745 |
FollowGear:= Gear; |
|
746 |
exit |
|
747 |
end; |
|
748 |
DeleteCI(Gear); // must be after exit!! (see previous line) |
|
749 |
||
750 |
Gear^.Hedgehog^.visStepPos:= (Gear^.Hedgehog^.visStepPos + 1) and 7; |
|
7164
fad64b97947e
Some brainfucking code which greatly reduces number of TestCollision* calls in hedgehog walk routine. Especially helpful to AI optimization. Also fixes some edge cases.
unc0rr
parents:
7069
diff
changeset
|
751 |
|
fad64b97947e
Some brainfucking code which greatly reduces number of TestCollision* calls in hedgehog walk routine. Especially helpful to AI optimization. Also fixes some edge cases.
unc0rr
parents:
7069
diff
changeset
|
752 |
if TestCollisionXwithGear(Gear, hwSign(Gear^.dX)) then if (TestCollisionYwithGear(Gear, -1) = 0) then |
fad64b97947e
Some brainfucking code which greatly reduces number of TestCollision* calls in hedgehog walk routine. Especially helpful to AI optimization. Also fixes some edge cases.
unc0rr
parents:
7069
diff
changeset
|
753 |
begin |
fad64b97947e
Some brainfucking code which greatly reduces number of TestCollision* calls in hedgehog walk routine. Especially helpful to AI optimization. Also fixes some edge cases.
unc0rr
parents:
7069
diff
changeset
|
754 |
Gear^.Y:= Gear^.Y - _1; |
fad64b97947e
Some brainfucking code which greatly reduces number of TestCollision* calls in hedgehog walk routine. Especially helpful to AI optimization. Also fixes some edge cases.
unc0rr
parents:
7069
diff
changeset
|
755 |
if TestCollisionXwithGear(Gear, hwSign(Gear^.dX)) then if (TestCollisionYwithGear(Gear, -1) = 0) then |
fad64b97947e
Some brainfucking code which greatly reduces number of TestCollision* calls in hedgehog walk routine. Especially helpful to AI optimization. Also fixes some edge cases.
unc0rr
parents:
7069
diff
changeset
|
756 |
begin |
fad64b97947e
Some brainfucking code which greatly reduces number of TestCollision* calls in hedgehog walk routine. Especially helpful to AI optimization. Also fixes some edge cases.
unc0rr
parents:
7069
diff
changeset
|
757 |
Gear^.Y:= Gear^.Y - _1; |
fad64b97947e
Some brainfucking code which greatly reduces number of TestCollision* calls in hedgehog walk routine. Especially helpful to AI optimization. Also fixes some edge cases.
unc0rr
parents:
7069
diff
changeset
|
758 |
if TestCollisionXwithGear(Gear, hwSign(Gear^.dX)) then if (TestCollisionYwithGear(Gear, -1) = 0) then |
fad64b97947e
Some brainfucking code which greatly reduces number of TestCollision* calls in hedgehog walk routine. Especially helpful to AI optimization. Also fixes some edge cases.
unc0rr
parents:
7069
diff
changeset
|
759 |
begin |
fad64b97947e
Some brainfucking code which greatly reduces number of TestCollision* calls in hedgehog walk routine. Especially helpful to AI optimization. Also fixes some edge cases.
unc0rr
parents:
7069
diff
changeset
|
760 |
Gear^.Y:= Gear^.Y - _1; |
fad64b97947e
Some brainfucking code which greatly reduces number of TestCollision* calls in hedgehog walk routine. Especially helpful to AI optimization. Also fixes some edge cases.
unc0rr
parents:
7069
diff
changeset
|
761 |
if TestCollisionXwithGear(Gear, hwSign(Gear^.dX)) then if (TestCollisionYwithGear(Gear, -1) = 0) then |
6581 | 762 |
begin |
7164
fad64b97947e
Some brainfucking code which greatly reduces number of TestCollision* calls in hedgehog walk routine. Especially helpful to AI optimization. Also fixes some edge cases.
unc0rr
parents:
7069
diff
changeset
|
763 |
Gear^.Y:= Gear^.Y - _1; |
fad64b97947e
Some brainfucking code which greatly reduces number of TestCollision* calls in hedgehog walk routine. Especially helpful to AI optimization. Also fixes some edge cases.
unc0rr
parents:
7069
diff
changeset
|
764 |
if TestCollisionXwithGear(Gear, hwSign(Gear^.dX)) then if (TestCollisionYwithGear(Gear, -1) = 0) then |
fad64b97947e
Some brainfucking code which greatly reduces number of TestCollision* calls in hedgehog walk routine. Especially helpful to AI optimization. Also fixes some edge cases.
unc0rr
parents:
7069
diff
changeset
|
765 |
begin |
fad64b97947e
Some brainfucking code which greatly reduces number of TestCollision* calls in hedgehog walk routine. Especially helpful to AI optimization. Also fixes some edge cases.
unc0rr
parents:
7069
diff
changeset
|
766 |
Gear^.Y:= Gear^.Y - _1; |
fad64b97947e
Some brainfucking code which greatly reduces number of TestCollision* calls in hedgehog walk routine. Especially helpful to AI optimization. Also fixes some edge cases.
unc0rr
parents:
7069
diff
changeset
|
767 |
if TestCollisionXwithGear(Gear, hwSign(Gear^.dX)) then if (TestCollisionYwithGear(Gear, -1) = 0) then |
fad64b97947e
Some brainfucking code which greatly reduces number of TestCollision* calls in hedgehog walk routine. Especially helpful to AI optimization. Also fixes some edge cases.
unc0rr
parents:
7069
diff
changeset
|
768 |
begin |
fad64b97947e
Some brainfucking code which greatly reduces number of TestCollision* calls in hedgehog walk routine. Especially helpful to AI optimization. Also fixes some edge cases.
unc0rr
parents:
7069
diff
changeset
|
769 |
Gear^.Y:= Gear^.Y - _1; |
fad64b97947e
Some brainfucking code which greatly reduces number of TestCollision* calls in hedgehog walk routine. Especially helpful to AI optimization. Also fixes some edge cases.
unc0rr
parents:
7069
diff
changeset
|
770 |
if TestCollisionXwithGear(Gear, hwSign(Gear^.dX)) then |
fad64b97947e
Some brainfucking code which greatly reduces number of TestCollision* calls in hedgehog walk routine. Especially helpful to AI optimization. Also fixes some edge cases.
unc0rr
parents:
7069
diff
changeset
|
771 |
Gear^.Y:= Gear^.Y + _6 |
fad64b97947e
Some brainfucking code which greatly reduces number of TestCollision* calls in hedgehog walk routine. Especially helpful to AI optimization. Also fixes some edge cases.
unc0rr
parents:
7069
diff
changeset
|
772 |
end else Gear^.Y:= Gear^.Y + _5 else |
fad64b97947e
Some brainfucking code which greatly reduces number of TestCollision* calls in hedgehog walk routine. Especially helpful to AI optimization. Also fixes some edge cases.
unc0rr
parents:
7069
diff
changeset
|
773 |
end else Gear^.Y:= Gear^.Y + _4 else |
fad64b97947e
Some brainfucking code which greatly reduces number of TestCollision* calls in hedgehog walk routine. Especially helpful to AI optimization. Also fixes some edge cases.
unc0rr
parents:
7069
diff
changeset
|
774 |
end else Gear^.Y:= Gear^.Y + _3 else |
fad64b97947e
Some brainfucking code which greatly reduces number of TestCollision* calls in hedgehog walk routine. Especially helpful to AI optimization. Also fixes some edge cases.
unc0rr
parents:
7069
diff
changeset
|
775 |
end else Gear^.Y:= Gear^.Y + _2 else |
fad64b97947e
Some brainfucking code which greatly reduces number of TestCollision* calls in hedgehog walk routine. Especially helpful to AI optimization. Also fixes some edge cases.
unc0rr
parents:
7069
diff
changeset
|
776 |
end else Gear^.Y:= Gear^.Y + _1 |
6581 | 777 |
end; |
778 |
||
779 |
if (not cArtillery) and ((Gear^.Message and gmPrecise) = 0) and (not TestCollisionXwithGear(Gear, hwSign(Gear^.dX))) then |
|
780 |
Gear^.X:= Gear^.X + SignAs(_1, Gear^.dX); |
|
781 |
||
782 |
SetAllHHToActive; |
|
783 |
||
784 |
if TestCollisionYwithGear(Gear, 1) = 0 then |
|
785 |
begin |
|
786 |
Gear^.Y:= Gear^.Y + _1; |
|
787 |
if TestCollisionYwithGear(Gear, 1) = 0 then |
|
788 |
begin |
|
789 |
Gear^.Y:= Gear^.Y + _1; |
|
790 |
if TestCollisionYwithGear(Gear, 1) = 0 then |
|
791 |
begin |
|
792 |
Gear^.Y:= Gear^.Y + _1; |
|
793 |
if TestCollisionYwithGear(Gear, 1) = 0 then |
|
794 |
begin |
|
795 |
Gear^.Y:= Gear^.Y + _1; |
|
796 |
if TestCollisionYwithGear(Gear, 1) = 0 then |
|
797 |
begin |
|
798 |
Gear^.Y:= Gear^.Y + _1; |
|
799 |
if TestCollisionYwithGear(Gear, 1) = 0 then |
|
800 |
begin |
|
801 |
Gear^.Y:= Gear^.Y + _1; |
|
802 |
if TestCollisionYwithGear(Gear, 1) = 0 then |
|
803 |
begin |
|
804 |
Gear^.Y:= Gear^.Y - _6; |
|
805 |
Gear^.dY:= _0; |
|
806 |
Gear^.State:= Gear^.State or gstMoving; |
|
807 |
exit |
|
808 |
end; |
|
809 |
end |
|
810 |
end |
|
811 |
end |
|
812 |
end |
|
813 |
end |
|
814 |
end; |
|
815 |
AddGearCI(Gear) |
|
816 |
end |
|
817 |
end; |
|
818 |
||
819 |
procedure HedgehogChAngle(HHGear: PGear); |
|
820 |
var da: LongWord; |
|
821 |
begin |
|
822 |
with HHGear^.Hedgehog^ do |
|
823 |
if ((CurAmmoType = amRope) and ((HHGear^.State and (gstMoving or gstHHJumping)) = gstMoving)) |
|
824 |
or ((CurAmmoType = amPortalGun) and ((HHGear^.State and gstMoving) <> 0)) then |
|
825 |
da:= 2 |
|
826 |
else da:= 1; |
|
827 |
||
828 |
if (((HHGear^.Message and gmPrecise) = 0) or ((GameTicks mod 5) = 1)) then |
|
829 |
if ((HHGear^.Message and gmUp) <> 0) and (HHGear^.Angle >= CurMinAngle + da) then |
|
830 |
dec(HHGear^.Angle, da) |
|
831 |
else |
|
832 |
if ((HHGear^.Message and gmDown) <> 0) and (HHGear^.Angle + da <= CurMaxAngle) then |
|
833 |
inc(HHGear^.Angle, da) |
|
834 |
end; |
|
835 |
||
836 |
||
837 |
//////////////////////////////////////////////////////////////////////////////// |
|
838 |
procedure doStepHedgehogMoving(Gear: PGear); |
|
839 |
var isFalling, isUnderwater: boolean; |
|
840 |
land: Word; |
|
841 |
begin |
|
842 |
land:= 0; |
|
843 |
isUnderwater:= cWaterLine < hwRound(Gear^.Y) + Gear^.Radius; |
|
844 |
if Gear^.dX.QWordValue > 8160437862 then |
|
845 |
Gear^.dX.QWordValue:= 8160437862; |
|
846 |
if Gear^.dY.QWordValue > 8160437862 then |
|
847 |
Gear^.dY.QWordValue:= 8160437862; |
|
848 |
||
849 |
if Gear^.Hedgehog^.Unplaced then |
|
850 |
begin |
|
851 |
Gear^.dY:= _0; |
|
852 |
Gear^.dX:= _0; |
|
853 |
Gear^.State:= Gear^.State and (not gstMoving); |
|
854 |
exit |
|
855 |
end; |
|
856 |
isFalling:= (Gear^.dY.isNegative) or not TestCollisionYKick(Gear, 1); |
|
857 |
if isFalling then |
|
858 |
begin |
|
859 |
if (Gear^.dY.isNegative) and TestCollisionYKick(Gear, -1) then |
|
860 |
Gear^.dY:= _0; |
|
861 |
Gear^.State:= Gear^.State or gstMoving; |
|
862 |
if (CurrentHedgehog^.Gear = Gear) |
|
863 |
and (hwSqr(Gear^.dX) + hwSqr(Gear^.dY) > _0_003) then |
|
864 |
begin |
|
7187
aff30d80bd7b
- Allow camera movement while current hedgehog is falling
unc0rr
parents:
7164
diff
changeset
|
865 |
// TODO: why so aggressive at setting FollowGear when falling? |
6581 | 866 |
FollowGear:= Gear; |
867 |
end; |
|
868 |
if isUnderwater then |
|
869 |
Gear^.dY:= Gear^.dY + cGravity / _2 |
|
870 |
else |
|
871 |
begin |
|
872 |
Gear^.dY:= Gear^.dY + cGravity; |
|
873 |
// this set of circumstances could be less complex if jumping was more clearly identified |
|
874 |
if ((GameFlags and gfMoreWind) <> 0) and (((Gear^.Damage <> 0) |
|
875 |
or ((CurAmmoGear <> nil) and ((CurAmmoGear^.AmmoType = amJetpack) or (CurAmmoGear^.AmmoType = amBirdy))) |
|
876 |
or ((Gear^.dY.QWordValue + Gear^.dX.QWordValue) > _0_55.QWordValue))) then |
|
877 |
Gear^.dX := Gear^.dX + cWindSpeed / Gear^.Density |
|
878 |
end |
|
879 |
end |
|
880 |
else |
|
881 |
begin |
|
882 |
land:= TestCollisionYwithGear(Gear, 1); |
|
883 |
if ((Gear^.dX.QWordValue + Gear^.dY.QWordValue) < _0_55.QWordValue) and ((land and lfIce) = 0) |
|
884 |
and ((Gear^.State and gstHHJumping) <> 0) then |
|
885 |
SetLittle(Gear^.dX); |
|
886 |
||
887 |
if not Gear^.dY.isNegative then |
|
888 |
begin |
|
889 |
CheckHHDamage(Gear); |
|
890 |
||
891 |
if ((Gear^.State and gstHHHJump) <> 0) and (not cArtillery) |
|
892 |
and (Gear^.dX.QWordValue < _0_02.QWordValue) then |
|
893 |
Gear^.dX.isNegative:= not Gear^.dX.isNegative; // landing after high jump |
|
894 |
Gear^.State:= Gear^.State and (not (gstHHJumping or gstHHHJump)); |
|
895 |
Gear^.dY:= _0; |
|
896 |
end |
|
897 |
else |
|
898 |
Gear^.dY:= Gear^.dY + cGravity; |
|
899 |
||
900 |
if ((Gear^.State and gstMoving) <> 0) then |
|
901 |
begin |
|
902 |
if land and lfIce <> 0 then |
|
903 |
begin |
|
904 |
Gear^.dX:= Gear^.dX * (_1 - (_1 - Gear^.Friction) / _2) |
|
905 |
end |
|
906 |
else |
|
907 |
Gear^.dX:= Gear^.dX * Gear^.Friction; |
|
908 |
end |
|
909 |
end; |
|
910 |
||
911 |
if (Gear^.State <> 0) then |
|
912 |
DeleteCI(Gear); |
|
913 |
||
914 |
if isUnderwater then |
|
915 |
begin |
|
916 |
Gear^.dY:= Gear^.dY * _0_999; |
|
917 |
Gear^.dX:= Gear^.dX * _0_999; |
|
918 |
end; |
|
919 |
||
920 |
if (Gear^.State and gstMoving) <> 0 then |
|
921 |
if TestCollisionXKick(Gear, hwSign(Gear^.dX)) then |
|
922 |
if not isFalling then |
|
923 |
if hwAbs(Gear^.dX) > _0_01 then |
|
924 |
if not TestCollisionXwithXYShift(Gear, int2hwFloat(hwSign(Gear^.dX)) - Gear^.dX, -1, hwSign(Gear^.dX)) then |
|
925 |
begin |
|
926 |
Gear^.X:= Gear^.X + Gear^.dX; |
|
927 |
Gear^.dX:= Gear^.dX * _0_96; |
|
928 |
Gear^.Y:= Gear^.Y - _1 |
|
929 |
end |
|
930 |
else |
|
931 |
if not TestCollisionXwithXYShift(Gear, int2hwFloat(hwSign(Gear^.dX)) - Gear^.dX, -2, hwSign(Gear^.dX)) then |
|
932 |
begin |
|
933 |
Gear^.X:= Gear^.X + Gear^.dX; |
|
934 |
Gear^.dX:= Gear^.dX * _0_93; |
|
935 |
Gear^.Y:= Gear^.Y - _2 |
|
936 |
end |
|
937 |
else |
|
938 |
if not TestCollisionXwithXYShift(Gear, int2hwFloat(hwSign(Gear^.dX)) - Gear^.dX, -3, hwSign(Gear^.dX)) then |
|
939 |
begin |
|
940 |
Gear^.X:= Gear^.X + Gear^.dX; |
|
941 |
Gear^.dX:= Gear^.dX * _0_9 ; |
|
942 |
Gear^.Y:= Gear^.Y - _3 |
|
943 |
end |
|
944 |
else |
|
945 |
if not TestCollisionXwithXYShift(Gear, int2hwFloat(hwSign(Gear^.dX)) - Gear^.dX, -4, hwSign(Gear^.dX)) then |
|
946 |
begin |
|
947 |
Gear^.X:= Gear^.X + Gear^.dX; |
|
948 |
Gear^.dX:= Gear^.dX * _0_87; |
|
949 |
Gear^.Y:= Gear^.Y - _4 |
|
950 |
end |
|
951 |
else |
|
952 |
if not TestCollisionXwithXYShift(Gear, int2hwFloat(hwSign(Gear^.dX)) - Gear^.dX, -5, hwSign(Gear^.dX)) then |
|
953 |
begin |
|
954 |
Gear^.X:= Gear^.X + Gear^.dX; |
|
955 |
Gear^.dX:= Gear^.dX * _0_84; |
|
956 |
Gear^.Y:= Gear^.Y - _5 |
|
957 |
end |
|
958 |
else |
|
959 |
if hwAbs(Gear^.dX) > _0_02 then |
|
960 |
Gear^.dX:= -Gear^.Elasticity * Gear^.dX |
|
961 |
else |
|
962 |
begin |
|
963 |
Gear^.State:= Gear^.State and (not gstMoving); |
|
964 |
while TestCollisionYWithGear(Gear,1) = 0 do |
|
965 |
Gear^.Y:= Gear^.Y+_1; |
|
966 |
SetLittle(Gear^.dX) |
|
967 |
end |
|
968 |
else |
|
969 |
begin |
|
970 |
Gear^.State:= Gear^.State and (not gstMoving); |
|
971 |
while TestCollisionYWithGear(Gear,1) = 0 do |
|
972 |
Gear^.Y:= Gear^.Y+_1; |
|
973 |
SetLittle(Gear^.dX) |
|
974 |
end |
|
975 |
else if (hwAbs(Gear^.dX) > cLittle) |
|
976 |
and ((Gear^.State and gstHHJumping) = 0) then |
|
977 |
Gear^.dX:= -Gear^.Elasticity * Gear^.dX |
|
978 |
else |
|
979 |
SetLittle(Gear^.dX); |
|
980 |
||
981 |
if (not isFalling) |
|
7362
53bcfc714cb3
Fix rare condition when hog's gear stucks in an infinite loop which adds 1 to its Y coordinate not checking for drowning
unc0rr
parents:
7339
diff
changeset
|
982 |
and (hwAbs(Gear^.dX) + hwAbs(Gear^.dY) < _0_03) then |
6581 | 983 |
begin |
984 |
Gear^.State:= Gear^.State and (not gstWinner); |
|
985 |
Gear^.State:= Gear^.State and (not gstMoving); |
|
7362
53bcfc714cb3
Fix rare condition when hog's gear stucks in an infinite loop which adds 1 to its Y coordinate not checking for drowning
unc0rr
parents:
7339
diff
changeset
|
986 |
while (TestCollisionYWithGear(Gear,1) = 0) and not CheckGearDrowning(Gear) do |
6581 | 987 |
Gear^.Y:= Gear^.Y+_1; |
988 |
SetLittle(Gear^.dX); |
|
989 |
Gear^.dY:= _0 |
|
990 |
end |
|
991 |
else |
|
992 |
Gear^.State:= Gear^.State or gstMoving; |
|
993 |
||
994 |
if (Gear^.State and gstMoving) <> 0 then |
|
995 |
begin |
|
996 |
Gear^.State:= Gear^.State and (not gstAnimation); |
|
997 |
// ARTILLERY but not being moved by explosions |
|
998 |
Gear^.X:= Gear^.X + Gear^.dX; |
|
999 |
Gear^.Y:= Gear^.Y + Gear^.dY; |
|
1000 |
if (not Gear^.dY.isNegative) and (not TestCollisionYKick(Gear, 1)) |
|
1001 |
and TestCollisionYwithXYShift(Gear, 0, 1, 1) then |
|
1002 |
begin |
|
1003 |
CheckHHDamage(Gear); |
|
1004 |
Gear^.dY:= _0; |
|
1005 |
Gear^.Y:= Gear^.Y + _1 |
|
1006 |
end; |
|
1007 |
CheckGearDrowning(Gear); |
|
1008 |
// hide target cursor if current hog is drowning |
|
1009 |
if (Gear^.State and gstDrowning) <> 0 then |
|
1010 |
if (CurrentHedgehog^.Gear = Gear) then |
|
1011 |
isCursorVisible:= false |
|
1012 |
end; |
|
1013 |
||
1014 |
if (hwAbs(Gear^.dY) > _0) and (Gear^.FlightTime > 0) and ((GameFlags and gfLowGravity) = 0) then |
|
1015 |
begin |
|
1016 |
inc(Gear^.FlightTime); |
|
1017 |
if Gear^.FlightTime = 3000 then |
|
1018 |
begin |
|
1019 |
AddCaption(GetEventString(eidHomerun), cWhiteColor, capgrpMessage); |
|
1020 |
PlaySound(sndHomerun) |
|
1021 |
end; |
|
1022 |
end |
|
1023 |
else |
|
1024 |
begin |
|
1025 |
uStats.hedgehogFlight(Gear, Gear^.FlightTime); |
|
1026 |
Gear^.FlightTime:= 0; |
|
1027 |
end; |
|
1028 |
||
1029 |
end; |
|
1030 |
||
1031 |
procedure doStepHedgehogDriven(HHGear: PGear); |
|
1032 |
var t: PGear; |
|
1033 |
wasJumping: boolean; |
|
1034 |
Hedgehog: PHedgehog; |
|
1035 |
begin |
|
1036 |
Hedgehog:= HHGear^.Hedgehog; |
|
1037 |
if isInMultiShoot then |
|
1038 |
HHGear^.Message:= 0; |
|
1039 |
||
1040 |
if ((Ammoz[CurrentHedgehog^.CurAmmoType].Ammo.Propz and ammoprop_Utility) <> 0) and isInMultiShoot then |
|
1041 |
AllInactive:= true |
|
1042 |
else if not isInMultiShoot then |
|
1043 |
AllInactive:= false; |
|
1044 |
||
1045 |
if (TurnTimeLeft = 0) or (HHGear^.Damage > 0) then |
|
1046 |
begin |
|
1047 |
if TagTurnTimeLeft = 0 then |
|
1048 |
TagTurnTimeLeft:= TurnTimeLeft; |
|
1049 |
TurnTimeLeft:= 0; |
|
1050 |
isCursorVisible:= false; |
|
1051 |
HHGear^.State:= HHGear^.State and (not (gstHHDriven or gstAnimation or gstAttacking)); |
|
1052 |
AttackBar:= 0; |
|
1053 |
if HHGear^.Damage > 0 then |
|
1054 |
HHGear^.State:= HHGear^.State and (not (gstHHJumping or gstHHHJump)); |
|
1055 |
exit |
|
1056 |
end; |
|
1057 |
||
1058 |
if (HHGear^.State and gstAnimation) <> 0 then |
|
1059 |
begin |
|
1060 |
HHGear^.Message:= 0; |
|
1061 |
if (HHGear^.Pos = Wavez[TWave(HHGear^.Tag)].VoiceDelay) and (HHGear^.Timer = 0) then |
|
7053 | 1062 |
PlaySoundV(Wavez[TWave(HHGear^.Tag)].Voice, Hedgehog^.Team^.voicepack); |
6581 | 1063 |
inc(HHGear^.Timer); |
1064 |
if HHGear^.Timer = Wavez[TWave(HHGear^.Tag)].Interval then |
|
1065 |
begin |
|
1066 |
HHGear^.Timer:= 0; |
|
1067 |
inc(HHGear^.Pos); |
|
1068 |
if HHGear^.Pos = Wavez[TWave(HHGear^.Tag)].FramesCount then |
|
1069 |
HHGear^.State:= HHGear^.State and (not gstAnimation) |
|
1070 |
end; |
|
1071 |
exit |
|
1072 |
end; |
|
1073 |
||
1074 |
if ((HHGear^.State and gstMoving) <> 0) |
|
7028 | 1075 |
or (GHStepTicks = cHHStepTicks) |
6581 | 1076 |
or (CurAmmoGear <> nil) then // we are moving |
1077 |
begin |
|
1078 |
with Hedgehog^ do |
|
1079 |
if (CurAmmoGear = nil) |
|
1080 |
and (HHGear^.dY > _0_39) |
|
1081 |
and (CurAmmoType = amParachute) then |
|
1082 |
HHGear^.Message:= HHGear^.Message or gmAttack; |
|
1083 |
// check for case with ammo |
|
1084 |
t:= CheckGearNear(HHGear, gtCase, 36, 36); |
|
1085 |
if t <> nil then |
|
1086 |
PickUp(HHGear, t) |
|
1087 |
end; |
|
1088 |
||
1089 |
if (CurAmmoGear = nil) then |
|
1090 |
if (((HHGear^.Message and gmAttack) <> 0) |
|
1091 |
or ((HHGear^.State and gstAttacking) <> 0)) then |
|
1092 |
Attack(HHGear) // should be before others to avoid desync with '/put' msg and changing weapon msgs |
|
1093 |
else |
|
1094 |
else |
|
1095 |
with Hedgehog^ do |
|
1096 |
if ((Ammoz[CurAmmoGear^.AmmoType].Ammo.Propz and ammoprop_AltAttack) <> 0) |
|
1097 |
and ((HHGear^.Message and gmLJump) <> 0) |
|
1098 |
and ((Ammoz[CurAmmoType].Ammo.Propz and ammoprop_AltUse) <> 0) then |
|
1099 |
begin |
|
1100 |
Attack(HHGear); |
|
1101 |
HHGear^.Message:= HHGear^.Message and (not gmLJump) |
|
1102 |
end; |
|
1103 |
||
1104 |
if (CurAmmoGear = nil) |
|
1105 |
or ((Ammoz[CurAmmoGear^.AmmoType].Ammo.Propz and ammoprop_AltAttack) <> 0) |
|
1106 |
or ((Ammoz[CurAmmoGear^.AmmoType].Ammo.Propz and ammoprop_NoRoundEnd) <> 0) then |
|
1107 |
begin |
|
1108 |
if ((HHGear^.Message and gmSlot) <> 0) then |
|
1109 |
if ChangeAmmo(HHGear) then ApplyAmmoChanges(Hedgehog^); |
|
1110 |
||
1111 |
if ((HHGear^.Message and gmWeapon) <> 0) then |
|
1112 |
HHSetWeapon(HHGear); |
|
1113 |
||
1114 |
if ((HHGear^.Message and gmTimer) <> 0) then |
|
1115 |
HHSetTimer(HHGear); |
|
1116 |
end; |
|
1117 |
||
1118 |
if CurAmmoGear <> nil then |
|
1119 |
begin |
|
1120 |
CurAmmoGear^.Message:= HHGear^.Message; |
|
1121 |
exit |
|
1122 |
end; |
|
1123 |
||
1124 |
if not isInMultiShoot then |
|
1125 |
HedgehogChAngle(HHGear); |
|
1126 |
||
1127 |
if (HHGear^.State and gstMoving) <> 0 then |
|
1128 |
begin |
|
1129 |
wasJumping:= ((HHGear^.State and gstHHJumping) <> 0); |
|
1130 |
||
1131 |
if ((HHGear^.Message and gmHJump) <> 0) and wasJumping and ((HHGear^.State and gstHHHJump) = 0) then |
|
1132 |
if (not (hwAbs(HHGear^.dX) > cLittle)) and (HHGear^.dY < -_0_02) then |
|
1133 |
begin |
|
1134 |
HHGear^.State:= HHGear^.State or gstHHHJump; |
|
1135 |
HHGear^.dY:= -_0_25; |
|
1136 |
if not cArtillery then |
|
1137 |
HHGear^.dX:= -SignAs(_0_02, HHGear^.dX); |
|
7053 | 1138 |
PlaySoundV(sndJump2, Hedgehog^.Team^.voicepack) |
6581 | 1139 |
end; |
1140 |
||
1141 |
HHGear^.Message:= HHGear^.Message and (not (gmLJump or gmHJump)); |
|
1142 |
||
1143 |
if (not cArtillery) and wasJumping and TestCollisionXwithGear(HHGear, hwSign(HHGear^.dX)) then |
|
1144 |
SetLittle(HHGear^.dX); |
|
1145 |
||
1146 |
if Hedgehog^.Gear <> nil then |
|
1147 |
doStepHedgehogMoving(HHGear); |
|
1148 |
||
1149 |
if ((HHGear^.State and (gstMoving or gstDrowning)) = 0) then |
|
1150 |
begin |
|
1151 |
AddGearCI(HHGear); |
|
1152 |
if wasJumping then |
|
7028 | 1153 |
GHStepTicks:= 410 |
6581 | 1154 |
else |
7028 | 1155 |
GHStepTicks:= 95 |
6581 | 1156 |
end; |
1157 |
exit |
|
1158 |
end; |
|
1159 |
||
1160 |
if not isInMultiShoot and (Hedgehog^.Gear <> nil) then |
|
1161 |
begin |
|
7028 | 1162 |
if GHStepTicks > 0 then |
1163 |
dec(GHStepTicks); |
|
1164 |
if (GHStepTicks = 0) then |
|
6581 | 1165 |
HedgehogStep(HHGear) |
1166 |
end |
|
1167 |
end; |
|
1168 |
||
1169 |
//////////////////////////////////////////////////////////////////////////////// |
|
1170 |
procedure doStepHedgehogFree(Gear: PGear); |
|
1171 |
var prevState: Longword; |
|
1172 |
begin |
|
1173 |
prevState:= Gear^.State; |
|
1174 |
||
1175 |
doStepHedgehogMoving(Gear); |
|
1176 |
||
1177 |
if (Gear^.State and (gstMoving or gstDrowning)) <> 0 then |
|
1178 |
begin |
|
1179 |
if Gear^.Damage > 0 then |
|
1180 |
CalcRotationDirAngle(Gear); |
|
1181 |
AllInactive:= false; |
|
1182 |
exit |
|
1183 |
end; |
|
1184 |
||
1185 |
if (Gear^.Health = 0) then |
|
1186 |
begin |
|
1187 |
if PrvInactive or ((GameFlags and gfInfAttack) <> 0) then |
|
1188 |
begin |
|
1189 |
Gear^.Timer:= 0; |
|
1190 |
FollowGear:= Gear; |
|
1191 |
PrvInactive:= false; |
|
1192 |
AllInactive:= false; |
|
1193 |
||
1194 |
if (Gear^.State and gstHHGone) = 0 then |
|
1195 |
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:
6992
diff
changeset
|
1196 |
Gear^.Hedgehog^.Effects[hePoisoned] := 0; |
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:
6992
diff
changeset
|
1197 |
if Gear^.Hedgehog^.Effects[heResurrectable] <> 0 then |
6581 | 1198 |
begin |
1199 |
ResurrectHedgehog(Gear); |
|
1200 |
end |
|
1201 |
else |
|
1202 |
begin |
|
1203 |
Gear^.State:= (Gear^.State or gstHHDeath) and (not gstAnimation); |
|
1204 |
Gear^.doStep:= @doStepHedgehogDead; |
|
1205 |
// Death message |
|
1206 |
AddCaption(Format(GetEventString(eidDied), Gear^.Hedgehog^.Name), cWhiteColor, capgrpMessage); |
|
1207 |
end; |
|
1208 |
end |
|
1209 |
else |
|
1210 |
begin |
|
1211 |
Gear^.State:= Gear^.State and (not gstAnimation); |
|
1212 |
Gear^.doStep:= @doStepHedgehogGone; |
|
1213 |
||
1214 |
// Gone message |
|
1215 |
AddCaption(Format(GetEventString(eidGone), Gear^.Hedgehog^.Name), cWhiteColor, capgrpMessage); |
|
1216 |
end |
|
1217 |
end; |
|
1218 |
exit |
|
1219 |
end; |
|
1220 |
||
1221 |
if ((Gear^.State and gstWait) = 0) and |
|
1222 |
(prevState <> Gear^.State) then |
|
1223 |
begin |
|
1224 |
Gear^.State:= Gear^.State or gstWait; |
|
1225 |
Gear^.Timer:= 150 |
|
1226 |
end |
|
1227 |
else |
|
1228 |
begin |
|
1229 |
if Gear^.Timer = 0 then |
|
1230 |
begin |
|
1231 |
Gear^.State:= Gear^.State and (not (gstWait or gstLoser or gstWinner or gstAttacked or gstNotKickable or gstHHChooseTarget)); |
|
1232 |
Gear^.Active:= false; |
|
1233 |
AddGearCI(Gear); |
|
1234 |
exit |
|
1235 |
end |
|
1236 |
else dec(Gear^.Timer) |
|
1237 |
end; |
|
1238 |
||
1239 |
AllInactive:= false |
|
1240 |
end; |
|
1241 |
||
1242 |
//////////////////////////////////////////////////////////////////////////////// |
|
1243 |
procedure doStepHedgehog(Gear: PGear); |
|
1244 |
(* |
|
1245 |
var x,y,tx,ty: LongInt; |
|
1246 |
tdX, tdY, slope: hwFloat; |
|
1247 |
land: Word; *) |
|
1248 |
var slope: hwFloat; |
|
1249 |
begin |
|
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:
7375
diff
changeset
|
1250 |
CheckSum:= CheckSum xor Gear^.Hedgehog^.BotLevel; |
6581 | 1251 |
if (Gear^.Message and gmDestroy) <> 0 then |
1252 |
begin |
|
1253 |
DeleteGear(Gear); |
|
1254 |
exit |
|
1255 |
end; |
|
1256 |
||
1257 |
if (Gear^.State and gstHHDriven) = 0 then |
|
1258 |
doStepHedgehogFree(Gear) |
|
1259 |
else |
|
1260 |
begin |
|
1261 |
with Gear^.Hedgehog^ do |
|
1262 |
if Team^.hasGone then |
|
1263 |
TeamGoneEffect(Team^) |
|
1264 |
else |
|
1265 |
doStepHedgehogDriven(Gear) |
|
1266 |
end; |
|
1267 |
if (Gear^.Message and (gmAllStoppable or gmLJump or gmHJump) = 0) |
|
1268 |
and (Gear^.State and (gstHHJumping or gstHHHJump or gstAttacking) = 0) |
|
1269 |
and (not Gear^.dY.isNegative) and (GameTicks mod (100*LongWOrd(hwRound(cMaxWindSpeed*2/cGravity))) = 0) |
|
1270 |
and (TestCollisionYwithGear(Gear, 1) and lfIce <> 0) then |
|
1271 |
begin |
|
1272 |
slope:= CalcSlopeBelowGear(Gear); |
|
1273 |
Gear^.dX:=Gear^.dX+slope*_0_07; |
|
1274 |
if slope.QWordValue <> 0 then |
|
1275 |
Gear^.State:= Gear^.State or gstMoving; |
|
1276 |
(* |
|
1277 |
x:= hwRound(Gear^.X); |
|
1278 |
y:= hwRound(Gear^.Y); |
|
1279 |
AddVisualGear(x, y, vgtSmokeTrace); |
|
1280 |
AddVisualGear(x - hwRound(_5*slope), y + hwRound(_5*slope), vgtSmokeTrace); |
|
1281 |
AddVisualGear(x + hwRound(_5*slope), y - hwRound(_5*slope), vgtSmokeTrace); |
|
1282 |
AddVisualGear(x - hwRound(_20 * slope), y + hwRound(_20 * slope), vgtSmokeTrace); |
|
1283 |
AddVisualGear(x + hwRound(_20 * slope), y - hwRound(_20 * slope), vgtSmokeTrace); |
|
1284 |
AddVisualGear(x - hwRound(_30 * slope), y + hwRound(_30 * slope), vgtSmokeTrace); |
|
1285 |
AddVisualGear(x + hwRound(_30 * slope), y - hwRound(_30 * slope), vgtSmokeTrace); |
|
1286 |
AddVisualGear(x - hwRound(_40 * slope), y + hwRound(_40 * slope), vgtSmokeTrace); |
|
1287 |
AddVisualGear(x + hwRound(_40 * slope), y - hwRound(_40 * slope), vgtSmokeTrace); |
|
1288 |
AddVisualGear(x - hwRound(_50 * slope), y + hwRound(_50 * slope), vgtSmokeTrace); |
|
1289 |
AddVisualGear(x + hwRound(_50 * slope), y - hwRound(_50 * slope), vgtSmokeTrace); *) |
|
1290 |
end |
|
1291 |
end; |
|
1292 |
||
1293 |
end. |