author | nemo |
Sun, 15 Jul 2012 15:35:28 -0400 | |
changeset 7391 | 588eabb4b384 |
parent 7389 | 15c3fb4882df |
child 7406 | 1fe2c821f9bf |
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; |
|
7391
588eabb4b384
Apparently order of multiple getrandom in params is undefined. Also remove broken and pointless getrandom call.
nemo
parents:
7389
diff
changeset
|
599 |
i, rx, ry: LongInt; |
588eabb4b384
Apparently order of multiple getrandom in params is undefined. Also remove broken and pointless getrandom call.
nemo
parents:
7389
diff
changeset
|
600 |
rdx, rdy: hwFloat; |
6581 | 601 |
vga: PVisualGear; |
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
|
602 |
ag: PGear; |
6581 | 603 |
begin |
604 |
Gear^.Message:= gmDestroy; |
|
605 |
if (Gear^.Pos and posCaseExplode) <> 0 then |
|
606 |
if (Gear^.Pos and posCasePoison) <> 0 then |
|
607 |
doMakeExplosion(hwRound(Gear^.X), hwRound(Gear^.Y), 25, HH^.Hedgehog, EXPLAutoSound + EXPLPoisoned) |
|
608 |
else |
|
609 |
doMakeExplosion(hwRound(Gear^.X), hwRound(Gear^.Y), 25, HH^.Hedgehog, EXPLAutoSound) |
|
610 |
else if (Gear^.Pos and posCasePoison) <> 0 then |
|
611 |
doMakeExplosion(hwRound(Gear^.X), hwRound(Gear^.Y), 25, HH^.Hedgehog, EXPLAutoSound + EXPLPoisoned + EXPLNoDamage) |
|
612 |
else |
|
613 |
case Gear^.Pos of |
|
614 |
posCaseUtility, |
|
615 |
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
|
616 |
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
|
617 |
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
|
618 |
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
|
619 |
end |
6581 | 620 |
else |
621 |
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
|
622 |
// Add spawning here... |
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
|
623 |
AddRandomness(CheckSum xor GameTicks); |
7391
588eabb4b384
Apparently order of multiple getrandom in params is undefined. Also remove broken and pointless getrandom call.
nemo
parents:
7389
diff
changeset
|
624 |
|
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
|
625 |
for i:= 0 to GetRandom(50)+50 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 |
588eabb4b384
Apparently order of multiple getrandom in params is undefined. Also remove broken and pointless getrandom call.
nemo
parents:
7389
diff
changeset
|
627 |
rx:= GetRandom(rightX-leftX)+leftX; |
588eabb4b384
Apparently order of multiple getrandom in params is undefined. Also remove broken and pointless getrandom call.
nemo
parents:
7389
diff
changeset
|
628 |
ry:= GetRandom(LAND_HEIGHT-topY)+topY; |
588eabb4b384
Apparently order of multiple getrandom in params is undefined. Also remove broken and pointless getrandom call.
nemo
parents:
7389
diff
changeset
|
629 |
rdx:= _90-(GetRandomf*_360); |
588eabb4b384
Apparently order of multiple getrandom in params is undefined. Also remove broken and pointless getrandom call.
nemo
parents:
7389
diff
changeset
|
630 |
rdy:= _90-(GetRandomf*_360); |
588eabb4b384
Apparently order of multiple getrandom in params is undefined. Also remove broken and pointless getrandom call.
nemo
parents:
7389
diff
changeset
|
631 |
AddGear(rx, ry, gtGenericFaller, gstInvisible, rdx, rdy, GetRandom(500)); |
588eabb4b384
Apparently order of multiple getrandom in params is undefined. Also remove broken and pointless getrandom call.
nemo
parents:
7389
diff
changeset
|
632 |
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
|
633 |
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
|
634 |
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
|
635 |
ag^.Power:= Gear^.Power |
6581 | 636 |
end; |
637 |
end; |
|
638 |
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
|
639 |
PlaySound(sndShotgunReload); |
6581 | 640 |
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
|
641 |
HH^.Hedgehog^.Effects[hePoisoned] := 0; |
6581 | 642 |
str(Gear^.Health, s); |
643 |
s:= '+' + s; |
|
644 |
AddCaption(s, HH^.Hedgehog^.Team^.Clan^.Color, capgrpAmmoinfo); |
|
645 |
RenderHealth(HH^.Hedgehog^); |
|
646 |
RecountTeamHealth(HH^.Hedgehog^.Team); |
|
647 |
||
648 |
i:= 0; |
|
649 |
while i < Gear^.Health do |
|
650 |
begin |
|
651 |
vga:= AddVisualGear(hwRound(HH^.X), hwRound(HH^.Y), vgtStraightShot); |
|
652 |
if vga <> nil then |
|
653 |
with vga^ do |
|
654 |
begin |
|
655 |
Tint:= $00FF00FF; |
|
656 |
State:= ord(sprHealth) |
|
657 |
end; |
|
658 |
inc(i, 5); |
|
659 |
end; |
|
660 |
end; |
|
661 |
end |
|
662 |
end; |
|
663 |
||
664 |
procedure HedgehogStep(Gear: PGear); |
|
665 |
var PrevdX: LongInt; |
|
666 |
CurWeapon: PAmmo; |
|
667 |
begin |
|
6924 | 668 |
CurWeapon:= GetCurAmmoEntry(Gear^.Hedgehog^); |
6581 | 669 |
if ((Gear^.State and (gstAttacking or gstMoving)) = 0) then |
670 |
begin |
|
671 |
if isCursorVisible then |
|
672 |
with Gear^.Hedgehog^ do |
|
673 |
with CurWeapon^ do |
|
674 |
begin |
|
675 |
if (Gear^.Message and gmLeft ) <> 0 then |
|
676 |
Pos:= (Pos - 1 + Ammoz[AmmoType].PosCount) mod Ammoz[AmmoType].PosCount |
|
677 |
else |
|
678 |
if (Gear^.Message and gmRight ) <> 0 then |
|
679 |
Pos:= (Pos + 1) mod Ammoz[AmmoType].PosCount |
|
680 |
else |
|
681 |
exit; |
|
7028 | 682 |
GHStepTicks:= 200; |
6581 | 683 |
exit |
684 |
end; |
|
685 |
||
686 |
if ((Gear^.Message and gmAnimate) <> 0) then |
|
687 |
begin |
|
688 |
Gear^.Message:= 0; |
|
689 |
Gear^.State:= Gear^.State or gstAnimation; |
|
690 |
Gear^.Tag:= Gear^.MsgParam; |
|
691 |
Gear^.Timer:= 0; |
|
692 |
Gear^.Pos:= 0 |
|
693 |
end; |
|
694 |
||
695 |
if ((Gear^.Message and gmLJump ) <> 0) then |
|
696 |
begin |
|
697 |
Gear^.Message:= Gear^.Message and (not gmLJump); |
|
698 |
DeleteCI(Gear); |
|
699 |
if TestCollisionYwithGear(Gear, -1) = 0 then |
|
700 |
if not TestCollisionXwithXYShift(Gear, _0, -2, hwSign(Gear^.dX)) then |
|
701 |
Gear^.Y:= Gear^.Y - _2 |
|
702 |
else |
|
703 |
if not TestCollisionXwithXYShift(Gear, _0, -1, hwSign(Gear^.dX)) then |
|
704 |
Gear^.Y:= Gear^.Y - _1; |
|
705 |
if not (TestCollisionXwithGear(Gear, hwSign(Gear^.dX)) |
|
706 |
or (TestCollisionYwithGear(Gear, -1) <> 0)) then |
|
707 |
begin |
|
708 |
Gear^.dY:= -_0_15; |
|
709 |
if not cArtillery then |
|
710 |
Gear^.dX:= SignAs(_0_15, Gear^.dX); |
|
711 |
Gear^.State:= Gear^.State or gstMoving or gstHHJumping; |
|
7053 | 712 |
PlaySoundV(sndJump1, Gear^.Hedgehog^.Team^.voicepack); |
6581 | 713 |
exit |
714 |
end; |
|
715 |
end; |
|
716 |
||
717 |
if ((Gear^.Message and gmHJump ) <> 0) then |
|
718 |
begin |
|
719 |
DeleteCI(Gear); |
|
720 |
Gear^.Message:= Gear^.Message and (not gmHJump); |
|
721 |
||
722 |
Gear^.dY:= -_0_2; |
|
723 |
SetLittle(Gear^.dX); |
|
724 |
Gear^.State:= Gear^.State or gstMoving or gstHHJumping; |
|
7053 | 725 |
PlaySoundV(sndJump3, Gear^.Hedgehog^.Team^.voicepack); |
6581 | 726 |
exit |
727 |
end; |
|
728 |
||
729 |
PrevdX:= hwSign(Gear^.dX); |
|
730 |
if (Gear^.Message and gmLeft )<>0 then |
|
731 |
Gear^.dX:= -cLittle else |
|
732 |
if (Gear^.Message and gmRight )<>0 then |
|
7187
aff30d80bd7b
- Allow camera movement while current hedgehog is falling
unc0rr
parents:
7164
diff
changeset
|
733 |
Gear^.dX:= cLittle |
aff30d80bd7b
- Allow camera movement while current hedgehog is falling
unc0rr
parents:
7164
diff
changeset
|
734 |
else exit; |
6581 | 735 |
|
7187
aff30d80bd7b
- Allow camera movement while current hedgehog is falling
unc0rr
parents:
7164
diff
changeset
|
736 |
StepSoundTimer:= cHHStepTicks; |
6581 | 737 |
|
7028 | 738 |
GHStepTicks:= cHHStepTicks; |
6581 | 739 |
if PrevdX <> hwSign(Gear^.dX) then |
740 |
begin |
|
741 |
FollowGear:= Gear; |
|
742 |
exit |
|
743 |
end; |
|
744 |
DeleteCI(Gear); // must be after exit!! (see previous line) |
|
745 |
||
746 |
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
|
747 |
|
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
|
748 |
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
|
749 |
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
|
750 |
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
|
751 |
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
|
752 |
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
|
753 |
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
|
754 |
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
|
755 |
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
|
756 |
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
|
757 |
if TestCollisionXwithGear(Gear, hwSign(Gear^.dX)) then if (TestCollisionYwithGear(Gear, -1) = 0) then |
6581 | 758 |
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
|
759 |
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
|
760 |
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
|
761 |
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
|
762 |
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
|
763 |
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
|
764 |
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
|
765 |
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
|
766 |
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
|
767 |
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
|
768 |
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
|
769 |
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
|
770 |
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
|
771 |
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
|
772 |
end else Gear^.Y:= Gear^.Y + _1 |
6581 | 773 |
end; |
774 |
||
775 |
if (not cArtillery) and ((Gear^.Message and gmPrecise) = 0) and (not TestCollisionXwithGear(Gear, hwSign(Gear^.dX))) then |
|
776 |
Gear^.X:= Gear^.X + SignAs(_1, Gear^.dX); |
|
777 |
||
778 |
SetAllHHToActive; |
|
779 |
||
780 |
if TestCollisionYwithGear(Gear, 1) = 0 then |
|
781 |
begin |
|
782 |
Gear^.Y:= Gear^.Y + _1; |
|
783 |
if TestCollisionYwithGear(Gear, 1) = 0 then |
|
784 |
begin |
|
785 |
Gear^.Y:= Gear^.Y + _1; |
|
786 |
if TestCollisionYwithGear(Gear, 1) = 0 then |
|
787 |
begin |
|
788 |
Gear^.Y:= Gear^.Y + _1; |
|
789 |
if TestCollisionYwithGear(Gear, 1) = 0 then |
|
790 |
begin |
|
791 |
Gear^.Y:= Gear^.Y + _1; |
|
792 |
if TestCollisionYwithGear(Gear, 1) = 0 then |
|
793 |
begin |
|
794 |
Gear^.Y:= Gear^.Y + _1; |
|
795 |
if TestCollisionYwithGear(Gear, 1) = 0 then |
|
796 |
begin |
|
797 |
Gear^.Y:= Gear^.Y + _1; |
|
798 |
if TestCollisionYwithGear(Gear, 1) = 0 then |
|
799 |
begin |
|
800 |
Gear^.Y:= Gear^.Y - _6; |
|
801 |
Gear^.dY:= _0; |
|
802 |
Gear^.State:= Gear^.State or gstMoving; |
|
803 |
exit |
|
804 |
end; |
|
805 |
end |
|
806 |
end |
|
807 |
end |
|
808 |
end |
|
809 |
end |
|
810 |
end; |
|
811 |
AddGearCI(Gear) |
|
812 |
end |
|
813 |
end; |
|
814 |
||
815 |
procedure HedgehogChAngle(HHGear: PGear); |
|
816 |
var da: LongWord; |
|
817 |
begin |
|
818 |
with HHGear^.Hedgehog^ do |
|
819 |
if ((CurAmmoType = amRope) and ((HHGear^.State and (gstMoving or gstHHJumping)) = gstMoving)) |
|
820 |
or ((CurAmmoType = amPortalGun) and ((HHGear^.State and gstMoving) <> 0)) then |
|
821 |
da:= 2 |
|
822 |
else da:= 1; |
|
823 |
||
824 |
if (((HHGear^.Message and gmPrecise) = 0) or ((GameTicks mod 5) = 1)) then |
|
825 |
if ((HHGear^.Message and gmUp) <> 0) and (HHGear^.Angle >= CurMinAngle + da) then |
|
826 |
dec(HHGear^.Angle, da) |
|
827 |
else |
|
828 |
if ((HHGear^.Message and gmDown) <> 0) and (HHGear^.Angle + da <= CurMaxAngle) then |
|
829 |
inc(HHGear^.Angle, da) |
|
830 |
end; |
|
831 |
||
832 |
||
833 |
//////////////////////////////////////////////////////////////////////////////// |
|
834 |
procedure doStepHedgehogMoving(Gear: PGear); |
|
835 |
var isFalling, isUnderwater: boolean; |
|
836 |
land: Word; |
|
837 |
begin |
|
838 |
land:= 0; |
|
839 |
isUnderwater:= cWaterLine < hwRound(Gear^.Y) + Gear^.Radius; |
|
840 |
if Gear^.dX.QWordValue > 8160437862 then |
|
841 |
Gear^.dX.QWordValue:= 8160437862; |
|
842 |
if Gear^.dY.QWordValue > 8160437862 then |
|
843 |
Gear^.dY.QWordValue:= 8160437862; |
|
844 |
||
845 |
if Gear^.Hedgehog^.Unplaced then |
|
846 |
begin |
|
847 |
Gear^.dY:= _0; |
|
848 |
Gear^.dX:= _0; |
|
849 |
Gear^.State:= Gear^.State and (not gstMoving); |
|
850 |
exit |
|
851 |
end; |
|
852 |
isFalling:= (Gear^.dY.isNegative) or not TestCollisionYKick(Gear, 1); |
|
853 |
if isFalling then |
|
854 |
begin |
|
855 |
if (Gear^.dY.isNegative) and TestCollisionYKick(Gear, -1) then |
|
856 |
Gear^.dY:= _0; |
|
857 |
Gear^.State:= Gear^.State or gstMoving; |
|
858 |
if (CurrentHedgehog^.Gear = Gear) |
|
859 |
and (hwSqr(Gear^.dX) + hwSqr(Gear^.dY) > _0_003) then |
|
860 |
begin |
|
7187
aff30d80bd7b
- Allow camera movement while current hedgehog is falling
unc0rr
parents:
7164
diff
changeset
|
861 |
// TODO: why so aggressive at setting FollowGear when falling? |
6581 | 862 |
FollowGear:= Gear; |
863 |
end; |
|
864 |
if isUnderwater then |
|
865 |
Gear^.dY:= Gear^.dY + cGravity / _2 |
|
866 |
else |
|
867 |
begin |
|
868 |
Gear^.dY:= Gear^.dY + cGravity; |
|
869 |
// this set of circumstances could be less complex if jumping was more clearly identified |
|
870 |
if ((GameFlags and gfMoreWind) <> 0) and (((Gear^.Damage <> 0) |
|
871 |
or ((CurAmmoGear <> nil) and ((CurAmmoGear^.AmmoType = amJetpack) or (CurAmmoGear^.AmmoType = amBirdy))) |
|
872 |
or ((Gear^.dY.QWordValue + Gear^.dX.QWordValue) > _0_55.QWordValue))) then |
|
873 |
Gear^.dX := Gear^.dX + cWindSpeed / Gear^.Density |
|
874 |
end |
|
875 |
end |
|
876 |
else |
|
877 |
begin |
|
878 |
land:= TestCollisionYwithGear(Gear, 1); |
|
879 |
if ((Gear^.dX.QWordValue + Gear^.dY.QWordValue) < _0_55.QWordValue) and ((land and lfIce) = 0) |
|
880 |
and ((Gear^.State and gstHHJumping) <> 0) then |
|
881 |
SetLittle(Gear^.dX); |
|
882 |
||
883 |
if not Gear^.dY.isNegative then |
|
884 |
begin |
|
885 |
CheckHHDamage(Gear); |
|
886 |
||
887 |
if ((Gear^.State and gstHHHJump) <> 0) and (not cArtillery) |
|
888 |
and (Gear^.dX.QWordValue < _0_02.QWordValue) then |
|
889 |
Gear^.dX.isNegative:= not Gear^.dX.isNegative; // landing after high jump |
|
890 |
Gear^.State:= Gear^.State and (not (gstHHJumping or gstHHHJump)); |
|
891 |
Gear^.dY:= _0; |
|
892 |
end |
|
893 |
else |
|
894 |
Gear^.dY:= Gear^.dY + cGravity; |
|
895 |
||
896 |
if ((Gear^.State and gstMoving) <> 0) then |
|
897 |
begin |
|
898 |
if land and lfIce <> 0 then |
|
899 |
begin |
|
900 |
Gear^.dX:= Gear^.dX * (_1 - (_1 - Gear^.Friction) / _2) |
|
901 |
end |
|
902 |
else |
|
903 |
Gear^.dX:= Gear^.dX * Gear^.Friction; |
|
904 |
end |
|
905 |
end; |
|
906 |
||
907 |
if (Gear^.State <> 0) then |
|
908 |
DeleteCI(Gear); |
|
909 |
||
910 |
if isUnderwater then |
|
911 |
begin |
|
912 |
Gear^.dY:= Gear^.dY * _0_999; |
|
913 |
Gear^.dX:= Gear^.dX * _0_999; |
|
914 |
end; |
|
915 |
||
916 |
if (Gear^.State and gstMoving) <> 0 then |
|
917 |
if TestCollisionXKick(Gear, hwSign(Gear^.dX)) then |
|
918 |
if not isFalling then |
|
919 |
if hwAbs(Gear^.dX) > _0_01 then |
|
920 |
if not TestCollisionXwithXYShift(Gear, int2hwFloat(hwSign(Gear^.dX)) - Gear^.dX, -1, hwSign(Gear^.dX)) then |
|
921 |
begin |
|
922 |
Gear^.X:= Gear^.X + Gear^.dX; |
|
923 |
Gear^.dX:= Gear^.dX * _0_96; |
|
924 |
Gear^.Y:= Gear^.Y - _1 |
|
925 |
end |
|
926 |
else |
|
927 |
if not TestCollisionXwithXYShift(Gear, int2hwFloat(hwSign(Gear^.dX)) - Gear^.dX, -2, hwSign(Gear^.dX)) then |
|
928 |
begin |
|
929 |
Gear^.X:= Gear^.X + Gear^.dX; |
|
930 |
Gear^.dX:= Gear^.dX * _0_93; |
|
931 |
Gear^.Y:= Gear^.Y - _2 |
|
932 |
end |
|
933 |
else |
|
934 |
if not TestCollisionXwithXYShift(Gear, int2hwFloat(hwSign(Gear^.dX)) - Gear^.dX, -3, hwSign(Gear^.dX)) then |
|
935 |
begin |
|
936 |
Gear^.X:= Gear^.X + Gear^.dX; |
|
937 |
Gear^.dX:= Gear^.dX * _0_9 ; |
|
938 |
Gear^.Y:= Gear^.Y - _3 |
|
939 |
end |
|
940 |
else |
|
941 |
if not TestCollisionXwithXYShift(Gear, int2hwFloat(hwSign(Gear^.dX)) - Gear^.dX, -4, hwSign(Gear^.dX)) then |
|
942 |
begin |
|
943 |
Gear^.X:= Gear^.X + Gear^.dX; |
|
944 |
Gear^.dX:= Gear^.dX * _0_87; |
|
945 |
Gear^.Y:= Gear^.Y - _4 |
|
946 |
end |
|
947 |
else |
|
948 |
if not TestCollisionXwithXYShift(Gear, int2hwFloat(hwSign(Gear^.dX)) - Gear^.dX, -5, hwSign(Gear^.dX)) then |
|
949 |
begin |
|
950 |
Gear^.X:= Gear^.X + Gear^.dX; |
|
951 |
Gear^.dX:= Gear^.dX * _0_84; |
|
952 |
Gear^.Y:= Gear^.Y - _5 |
|
953 |
end |
|
954 |
else |
|
955 |
if hwAbs(Gear^.dX) > _0_02 then |
|
956 |
Gear^.dX:= -Gear^.Elasticity * Gear^.dX |
|
957 |
else |
|
958 |
begin |
|
959 |
Gear^.State:= Gear^.State and (not gstMoving); |
|
960 |
while TestCollisionYWithGear(Gear,1) = 0 do |
|
961 |
Gear^.Y:= Gear^.Y+_1; |
|
962 |
SetLittle(Gear^.dX) |
|
963 |
end |
|
964 |
else |
|
965 |
begin |
|
966 |
Gear^.State:= Gear^.State and (not gstMoving); |
|
967 |
while TestCollisionYWithGear(Gear,1) = 0 do |
|
968 |
Gear^.Y:= Gear^.Y+_1; |
|
969 |
SetLittle(Gear^.dX) |
|
970 |
end |
|
971 |
else if (hwAbs(Gear^.dX) > cLittle) |
|
972 |
and ((Gear^.State and gstHHJumping) = 0) then |
|
973 |
Gear^.dX:= -Gear^.Elasticity * Gear^.dX |
|
974 |
else |
|
975 |
SetLittle(Gear^.dX); |
|
976 |
||
977 |
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
|
978 |
and (hwAbs(Gear^.dX) + hwAbs(Gear^.dY) < _0_03) then |
6581 | 979 |
begin |
980 |
Gear^.State:= Gear^.State and (not gstWinner); |
|
981 |
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
|
982 |
while (TestCollisionYWithGear(Gear,1) = 0) and not CheckGearDrowning(Gear) do |
6581 | 983 |
Gear^.Y:= Gear^.Y+_1; |
984 |
SetLittle(Gear^.dX); |
|
985 |
Gear^.dY:= _0 |
|
986 |
end |
|
987 |
else |
|
988 |
Gear^.State:= Gear^.State or gstMoving; |
|
989 |
||
990 |
if (Gear^.State and gstMoving) <> 0 then |
|
991 |
begin |
|
992 |
Gear^.State:= Gear^.State and (not gstAnimation); |
|
993 |
// ARTILLERY but not being moved by explosions |
|
994 |
Gear^.X:= Gear^.X + Gear^.dX; |
|
995 |
Gear^.Y:= Gear^.Y + Gear^.dY; |
|
996 |
if (not Gear^.dY.isNegative) and (not TestCollisionYKick(Gear, 1)) |
|
997 |
and TestCollisionYwithXYShift(Gear, 0, 1, 1) then |
|
998 |
begin |
|
999 |
CheckHHDamage(Gear); |
|
1000 |
Gear^.dY:= _0; |
|
1001 |
Gear^.Y:= Gear^.Y + _1 |
|
1002 |
end; |
|
1003 |
CheckGearDrowning(Gear); |
|
1004 |
// hide target cursor if current hog is drowning |
|
1005 |
if (Gear^.State and gstDrowning) <> 0 then |
|
1006 |
if (CurrentHedgehog^.Gear = Gear) then |
|
1007 |
isCursorVisible:= false |
|
1008 |
end; |
|
1009 |
||
1010 |
if (hwAbs(Gear^.dY) > _0) and (Gear^.FlightTime > 0) and ((GameFlags and gfLowGravity) = 0) then |
|
1011 |
begin |
|
1012 |
inc(Gear^.FlightTime); |
|
1013 |
if Gear^.FlightTime = 3000 then |
|
1014 |
begin |
|
1015 |
AddCaption(GetEventString(eidHomerun), cWhiteColor, capgrpMessage); |
|
1016 |
PlaySound(sndHomerun) |
|
1017 |
end; |
|
1018 |
end |
|
1019 |
else |
|
1020 |
begin |
|
1021 |
uStats.hedgehogFlight(Gear, Gear^.FlightTime); |
|
1022 |
Gear^.FlightTime:= 0; |
|
1023 |
end; |
|
1024 |
||
1025 |
end; |
|
1026 |
||
1027 |
procedure doStepHedgehogDriven(HHGear: PGear); |
|
1028 |
var t: PGear; |
|
1029 |
wasJumping: boolean; |
|
1030 |
Hedgehog: PHedgehog; |
|
1031 |
begin |
|
1032 |
Hedgehog:= HHGear^.Hedgehog; |
|
1033 |
if isInMultiShoot then |
|
1034 |
HHGear^.Message:= 0; |
|
1035 |
||
1036 |
if ((Ammoz[CurrentHedgehog^.CurAmmoType].Ammo.Propz and ammoprop_Utility) <> 0) and isInMultiShoot then |
|
1037 |
AllInactive:= true |
|
1038 |
else if not isInMultiShoot then |
|
1039 |
AllInactive:= false; |
|
1040 |
||
1041 |
if (TurnTimeLeft = 0) or (HHGear^.Damage > 0) then |
|
1042 |
begin |
|
1043 |
if TagTurnTimeLeft = 0 then |
|
1044 |
TagTurnTimeLeft:= TurnTimeLeft; |
|
1045 |
TurnTimeLeft:= 0; |
|
1046 |
isCursorVisible:= false; |
|
1047 |
HHGear^.State:= HHGear^.State and (not (gstHHDriven or gstAnimation or gstAttacking)); |
|
1048 |
AttackBar:= 0; |
|
1049 |
if HHGear^.Damage > 0 then |
|
1050 |
HHGear^.State:= HHGear^.State and (not (gstHHJumping or gstHHHJump)); |
|
1051 |
exit |
|
1052 |
end; |
|
1053 |
||
1054 |
if (HHGear^.State and gstAnimation) <> 0 then |
|
1055 |
begin |
|
1056 |
HHGear^.Message:= 0; |
|
1057 |
if (HHGear^.Pos = Wavez[TWave(HHGear^.Tag)].VoiceDelay) and (HHGear^.Timer = 0) then |
|
7053 | 1058 |
PlaySoundV(Wavez[TWave(HHGear^.Tag)].Voice, Hedgehog^.Team^.voicepack); |
6581 | 1059 |
inc(HHGear^.Timer); |
1060 |
if HHGear^.Timer = Wavez[TWave(HHGear^.Tag)].Interval then |
|
1061 |
begin |
|
1062 |
HHGear^.Timer:= 0; |
|
1063 |
inc(HHGear^.Pos); |
|
1064 |
if HHGear^.Pos = Wavez[TWave(HHGear^.Tag)].FramesCount then |
|
1065 |
HHGear^.State:= HHGear^.State and (not gstAnimation) |
|
1066 |
end; |
|
1067 |
exit |
|
1068 |
end; |
|
1069 |
||
1070 |
if ((HHGear^.State and gstMoving) <> 0) |
|
7028 | 1071 |
or (GHStepTicks = cHHStepTicks) |
6581 | 1072 |
or (CurAmmoGear <> nil) then // we are moving |
1073 |
begin |
|
1074 |
with Hedgehog^ do |
|
1075 |
if (CurAmmoGear = nil) |
|
1076 |
and (HHGear^.dY > _0_39) |
|
1077 |
and (CurAmmoType = amParachute) then |
|
1078 |
HHGear^.Message:= HHGear^.Message or gmAttack; |
|
1079 |
// check for case with ammo |
|
1080 |
t:= CheckGearNear(HHGear, gtCase, 36, 36); |
|
1081 |
if t <> nil then |
|
1082 |
PickUp(HHGear, t) |
|
1083 |
end; |
|
1084 |
||
1085 |
if (CurAmmoGear = nil) then |
|
1086 |
if (((HHGear^.Message and gmAttack) <> 0) |
|
1087 |
or ((HHGear^.State and gstAttacking) <> 0)) then |
|
1088 |
Attack(HHGear) // should be before others to avoid desync with '/put' msg and changing weapon msgs |
|
1089 |
else |
|
1090 |
else |
|
1091 |
with Hedgehog^ do |
|
1092 |
if ((Ammoz[CurAmmoGear^.AmmoType].Ammo.Propz and ammoprop_AltAttack) <> 0) |
|
1093 |
and ((HHGear^.Message and gmLJump) <> 0) |
|
1094 |
and ((Ammoz[CurAmmoType].Ammo.Propz and ammoprop_AltUse) <> 0) then |
|
1095 |
begin |
|
1096 |
Attack(HHGear); |
|
1097 |
HHGear^.Message:= HHGear^.Message and (not gmLJump) |
|
1098 |
end; |
|
1099 |
||
1100 |
if (CurAmmoGear = nil) |
|
1101 |
or ((Ammoz[CurAmmoGear^.AmmoType].Ammo.Propz and ammoprop_AltAttack) <> 0) |
|
1102 |
or ((Ammoz[CurAmmoGear^.AmmoType].Ammo.Propz and ammoprop_NoRoundEnd) <> 0) then |
|
1103 |
begin |
|
1104 |
if ((HHGear^.Message and gmSlot) <> 0) then |
|
1105 |
if ChangeAmmo(HHGear) then ApplyAmmoChanges(Hedgehog^); |
|
1106 |
||
1107 |
if ((HHGear^.Message and gmWeapon) <> 0) then |
|
1108 |
HHSetWeapon(HHGear); |
|
1109 |
||
1110 |
if ((HHGear^.Message and gmTimer) <> 0) then |
|
1111 |
HHSetTimer(HHGear); |
|
1112 |
end; |
|
1113 |
||
1114 |
if CurAmmoGear <> nil then |
|
1115 |
begin |
|
1116 |
CurAmmoGear^.Message:= HHGear^.Message; |
|
1117 |
exit |
|
1118 |
end; |
|
1119 |
||
1120 |
if not isInMultiShoot then |
|
1121 |
HedgehogChAngle(HHGear); |
|
1122 |
||
1123 |
if (HHGear^.State and gstMoving) <> 0 then |
|
1124 |
begin |
|
1125 |
wasJumping:= ((HHGear^.State and gstHHJumping) <> 0); |
|
1126 |
||
1127 |
if ((HHGear^.Message and gmHJump) <> 0) and wasJumping and ((HHGear^.State and gstHHHJump) = 0) then |
|
1128 |
if (not (hwAbs(HHGear^.dX) > cLittle)) and (HHGear^.dY < -_0_02) then |
|
1129 |
begin |
|
1130 |
HHGear^.State:= HHGear^.State or gstHHHJump; |
|
1131 |
HHGear^.dY:= -_0_25; |
|
1132 |
if not cArtillery then |
|
1133 |
HHGear^.dX:= -SignAs(_0_02, HHGear^.dX); |
|
7053 | 1134 |
PlaySoundV(sndJump2, Hedgehog^.Team^.voicepack) |
6581 | 1135 |
end; |
1136 |
||
1137 |
HHGear^.Message:= HHGear^.Message and (not (gmLJump or gmHJump)); |
|
1138 |
||
1139 |
if (not cArtillery) and wasJumping and TestCollisionXwithGear(HHGear, hwSign(HHGear^.dX)) then |
|
1140 |
SetLittle(HHGear^.dX); |
|
1141 |
||
1142 |
if Hedgehog^.Gear <> nil then |
|
1143 |
doStepHedgehogMoving(HHGear); |
|
1144 |
||
1145 |
if ((HHGear^.State and (gstMoving or gstDrowning)) = 0) then |
|
1146 |
begin |
|
1147 |
AddGearCI(HHGear); |
|
1148 |
if wasJumping then |
|
7028 | 1149 |
GHStepTicks:= 410 |
6581 | 1150 |
else |
7028 | 1151 |
GHStepTicks:= 95 |
6581 | 1152 |
end; |
1153 |
exit |
|
1154 |
end; |
|
1155 |
||
1156 |
if not isInMultiShoot and (Hedgehog^.Gear <> nil) then |
|
1157 |
begin |
|
7028 | 1158 |
if GHStepTicks > 0 then |
1159 |
dec(GHStepTicks); |
|
1160 |
if (GHStepTicks = 0) then |
|
6581 | 1161 |
HedgehogStep(HHGear) |
1162 |
end |
|
1163 |
end; |
|
1164 |
||
1165 |
//////////////////////////////////////////////////////////////////////////////// |
|
1166 |
procedure doStepHedgehogFree(Gear: PGear); |
|
1167 |
var prevState: Longword; |
|
1168 |
begin |
|
1169 |
prevState:= Gear^.State; |
|
1170 |
||
1171 |
doStepHedgehogMoving(Gear); |
|
1172 |
||
1173 |
if (Gear^.State and (gstMoving or gstDrowning)) <> 0 then |
|
1174 |
begin |
|
1175 |
if Gear^.Damage > 0 then |
|
1176 |
CalcRotationDirAngle(Gear); |
|
1177 |
AllInactive:= false; |
|
1178 |
exit |
|
1179 |
end; |
|
1180 |
||
1181 |
if (Gear^.Health = 0) then |
|
1182 |
begin |
|
1183 |
if PrvInactive or ((GameFlags and gfInfAttack) <> 0) then |
|
1184 |
begin |
|
1185 |
Gear^.Timer:= 0; |
|
1186 |
FollowGear:= Gear; |
|
1187 |
PrvInactive:= false; |
|
1188 |
AllInactive:= false; |
|
1189 |
||
1190 |
if (Gear^.State and gstHHGone) = 0 then |
|
1191 |
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
|
1192 |
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
|
1193 |
if Gear^.Hedgehog^.Effects[heResurrectable] <> 0 then |
6581 | 1194 |
begin |
1195 |
ResurrectHedgehog(Gear); |
|
1196 |
end |
|
1197 |
else |
|
1198 |
begin |
|
1199 |
Gear^.State:= (Gear^.State or gstHHDeath) and (not gstAnimation); |
|
1200 |
Gear^.doStep:= @doStepHedgehogDead; |
|
1201 |
// Death message |
|
1202 |
AddCaption(Format(GetEventString(eidDied), Gear^.Hedgehog^.Name), cWhiteColor, capgrpMessage); |
|
1203 |
end; |
|
1204 |
end |
|
1205 |
else |
|
1206 |
begin |
|
1207 |
Gear^.State:= Gear^.State and (not gstAnimation); |
|
1208 |
Gear^.doStep:= @doStepHedgehogGone; |
|
1209 |
||
1210 |
// Gone message |
|
1211 |
AddCaption(Format(GetEventString(eidGone), Gear^.Hedgehog^.Name), cWhiteColor, capgrpMessage); |
|
1212 |
end |
|
1213 |
end; |
|
1214 |
exit |
|
1215 |
end; |
|
1216 |
||
1217 |
if ((Gear^.State and gstWait) = 0) and |
|
1218 |
(prevState <> Gear^.State) then |
|
1219 |
begin |
|
1220 |
Gear^.State:= Gear^.State or gstWait; |
|
1221 |
Gear^.Timer:= 150 |
|
1222 |
end |
|
1223 |
else |
|
1224 |
begin |
|
1225 |
if Gear^.Timer = 0 then |
|
1226 |
begin |
|
1227 |
Gear^.State:= Gear^.State and (not (gstWait or gstLoser or gstWinner or gstAttacked or gstNotKickable or gstHHChooseTarget)); |
|
1228 |
Gear^.Active:= false; |
|
1229 |
AddGearCI(Gear); |
|
1230 |
exit |
|
1231 |
end |
|
1232 |
else dec(Gear^.Timer) |
|
1233 |
end; |
|
1234 |
||
1235 |
AllInactive:= false |
|
1236 |
end; |
|
1237 |
||
1238 |
//////////////////////////////////////////////////////////////////////////////// |
|
1239 |
procedure doStepHedgehog(Gear: PGear); |
|
1240 |
(* |
|
1241 |
var x,y,tx,ty: LongInt; |
|
1242 |
tdX, tdY, slope: hwFloat; |
|
1243 |
land: Word; *) |
|
1244 |
var slope: hwFloat; |
|
1245 |
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
|
1246 |
CheckSum:= CheckSum xor Gear^.Hedgehog^.BotLevel; |
6581 | 1247 |
if (Gear^.Message and gmDestroy) <> 0 then |
1248 |
begin |
|
1249 |
DeleteGear(Gear); |
|
1250 |
exit |
|
1251 |
end; |
|
1252 |
||
1253 |
if (Gear^.State and gstHHDriven) = 0 then |
|
1254 |
doStepHedgehogFree(Gear) |
|
1255 |
else |
|
1256 |
begin |
|
1257 |
with Gear^.Hedgehog^ do |
|
1258 |
if Team^.hasGone then |
|
1259 |
TeamGoneEffect(Team^) |
|
1260 |
else |
|
1261 |
doStepHedgehogDriven(Gear) |
|
1262 |
end; |
|
1263 |
if (Gear^.Message and (gmAllStoppable or gmLJump or gmHJump) = 0) |
|
1264 |
and (Gear^.State and (gstHHJumping or gstHHHJump or gstAttacking) = 0) |
|
1265 |
and (not Gear^.dY.isNegative) and (GameTicks mod (100*LongWOrd(hwRound(cMaxWindSpeed*2/cGravity))) = 0) |
|
1266 |
and (TestCollisionYwithGear(Gear, 1) and lfIce <> 0) then |
|
1267 |
begin |
|
1268 |
slope:= CalcSlopeBelowGear(Gear); |
|
1269 |
Gear^.dX:=Gear^.dX+slope*_0_07; |
|
1270 |
if slope.QWordValue <> 0 then |
|
1271 |
Gear^.State:= Gear^.State or gstMoving; |
|
1272 |
(* |
|
1273 |
x:= hwRound(Gear^.X); |
|
1274 |
y:= hwRound(Gear^.Y); |
|
1275 |
AddVisualGear(x, y, vgtSmokeTrace); |
|
1276 |
AddVisualGear(x - hwRound(_5*slope), y + hwRound(_5*slope), vgtSmokeTrace); |
|
1277 |
AddVisualGear(x + hwRound(_5*slope), y - hwRound(_5*slope), vgtSmokeTrace); |
|
1278 |
AddVisualGear(x - hwRound(_20 * slope), y + hwRound(_20 * slope), vgtSmokeTrace); |
|
1279 |
AddVisualGear(x + hwRound(_20 * slope), y - hwRound(_20 * slope), vgtSmokeTrace); |
|
1280 |
AddVisualGear(x - hwRound(_30 * slope), y + hwRound(_30 * slope), vgtSmokeTrace); |
|
1281 |
AddVisualGear(x + hwRound(_30 * slope), y - hwRound(_30 * slope), vgtSmokeTrace); |
|
1282 |
AddVisualGear(x - hwRound(_40 * slope), y + hwRound(_40 * slope), vgtSmokeTrace); |
|
1283 |
AddVisualGear(x + hwRound(_40 * slope), y - hwRound(_40 * slope), vgtSmokeTrace); |
|
1284 |
AddVisualGear(x - hwRound(_50 * slope), y + hwRound(_50 * slope), vgtSmokeTrace); |
|
1285 |
AddVisualGear(x + hwRound(_50 * slope), y - hwRound(_50 * slope), vgtSmokeTrace); *) |
|
1286 |
end |
|
1287 |
end; |
|
1288 |
||
1289 |
end. |