author | unc0rr |
Mon, 19 Jan 2009 18:15:31 +0000 | |
changeset 1723 | 430064bafa18 |
parent 1712 | f5b916de40f0 |
child 1749 | 7170f626e9d6 |
permissions | -rw-r--r-- |
4 | 1 |
(* |
1066 | 2 |
* Hedgewars, a free turn based strategy game |
1689 | 3 |
* Copyright (c) 2004-2009 Andrey Korotaev <unC0Rr@gmail.com> |
4 | 4 |
* |
183 | 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 |
|
4 | 8 |
* |
183 | 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. |
|
4 | 13 |
* |
183 | 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 |
|
4 | 17 |
*) |
18 |
||
37 | 19 |
//////////////////////////////////////////////////////////////////////////////// |
783 | 20 |
procedure ChangeAmmo(Gear: PGear); |
941
b5222ddafe1f
- Fix bug with picking up ammos from cases, when total ammo count may become more than AMMO_INFINITE
unc0rr
parents:
931
diff
changeset
|
21 |
var slot, i: Longword; |
783 | 22 |
begin |
23 |
slot:= Gear^.MsgParam; |
|
24 |
||
25 |
with PHedgehog(Gear^.Hedgehog)^ do |
|
927
2c1675344a6f
Remove AltSlot and AltAmmo fields of Hedgehog record, as they are not actually needed
unc0rr
parents:
926
diff
changeset
|
26 |
begin |
928
b9064b48b001
Some preparation work for attacking from rope, parachute and etc.
unc0rr
parents:
927
diff
changeset
|
27 |
if ((Gear^.State and (gstAttacking or gstAttacked)) <> 0) |
b9064b48b001
Some preparation work for attacking from rope, parachute and etc.
unc0rr
parents:
927
diff
changeset
|
28 |
or (AttacksNum > 0) |
927
2c1675344a6f
Remove AltSlot and AltAmmo fields of Hedgehog record, as they are not actually needed
unc0rr
parents:
926
diff
changeset
|
29 |
or ((Gear^.State and gstHHDriven) = 0) then exit; |
783 | 30 |
|
927
2c1675344a6f
Remove AltSlot and AltAmmo fields of Hedgehog record, as they are not actually needed
unc0rr
parents:
926
diff
changeset
|
31 |
Gear^.Message:= Gear^.Message and not (gm_LJump or gm_HJump or gm_Slot); |
783 | 32 |
|
927
2c1675344a6f
Remove AltSlot and AltAmmo fields of Hedgehog record, as they are not actually needed
unc0rr
parents:
926
diff
changeset
|
33 |
if CurSlot = slot then |
2c1675344a6f
Remove AltSlot and AltAmmo fields of Hedgehog record, as they are not actually needed
unc0rr
parents:
926
diff
changeset
|
34 |
begin |
941
b5222ddafe1f
- Fix bug with picking up ammos from cases, when total ammo count may become more than AMMO_INFINITE
unc0rr
parents:
931
diff
changeset
|
35 |
i:= 0; |
b5222ddafe1f
- Fix bug with picking up ammos from cases, when total ammo count may become more than AMMO_INFINITE
unc0rr
parents:
931
diff
changeset
|
36 |
repeat |
927
2c1675344a6f
Remove AltSlot and AltAmmo fields of Hedgehog record, as they are not actually needed
unc0rr
parents:
926
diff
changeset
|
37 |
inc(CurAmmo); |
941
b5222ddafe1f
- Fix bug with picking up ammos from cases, when total ammo count may become more than AMMO_INFINITE
unc0rr
parents:
931
diff
changeset
|
38 |
if (CurAmmo > cMaxSlotAmmoIndex) then |
b5222ddafe1f
- Fix bug with picking up ammos from cases, when total ammo count may become more than AMMO_INFINITE
unc0rr
parents:
931
diff
changeset
|
39 |
begin |
b5222ddafe1f
- Fix bug with picking up ammos from cases, when total ammo count may become more than AMMO_INFINITE
unc0rr
parents:
931
diff
changeset
|
40 |
CurAmmo:= 0; |
b5222ddafe1f
- Fix bug with picking up ammos from cases, when total ammo count may become more than AMMO_INFINITE
unc0rr
parents:
931
diff
changeset
|
41 |
inc(i); |
b5222ddafe1f
- Fix bug with picking up ammos from cases, when total ammo count may become more than AMMO_INFINITE
unc0rr
parents:
931
diff
changeset
|
42 |
TryDo(i < 2, 'Engine bug: no ammo in current slot', true) |
b5222ddafe1f
- Fix bug with picking up ammos from cases, when total ammo count may become more than AMMO_INFINITE
unc0rr
parents:
931
diff
changeset
|
43 |
end; |
b5222ddafe1f
- Fix bug with picking up ammos from cases, when total ammo count may become more than AMMO_INFINITE
unc0rr
parents:
931
diff
changeset
|
44 |
until (Ammo^[slot, CurAmmo].Count > 0) and (Team^.Clan^.TurnNumber > Ammoz[Ammo^[slot, CurAmmo].AmmoType].SkipTurns) |
927
2c1675344a6f
Remove AltSlot and AltAmmo fields of Hedgehog record, as they are not actually needed
unc0rr
parents:
926
diff
changeset
|
45 |
end else |
2c1675344a6f
Remove AltSlot and AltAmmo fields of Hedgehog record, as they are not actually needed
unc0rr
parents:
926
diff
changeset
|
46 |
begin |
941
b5222ddafe1f
- Fix bug with picking up ammos from cases, when total ammo count may become more than AMMO_INFINITE
unc0rr
parents:
931
diff
changeset
|
47 |
i:= 0; |
b5222ddafe1f
- Fix bug with picking up ammos from cases, when total ammo count may become more than AMMO_INFINITE
unc0rr
parents:
931
diff
changeset
|
48 |
// check whether there's ammo in slot |
b5222ddafe1f
- Fix bug with picking up ammos from cases, when total ammo count may become more than AMMO_INFINITE
unc0rr
parents:
931
diff
changeset
|
49 |
while (i <= cMaxSlotAmmoIndex) |
b5222ddafe1f
- Fix bug with picking up ammos from cases, when total ammo count may become more than AMMO_INFINITE
unc0rr
parents:
931
diff
changeset
|
50 |
and ((Ammo^[slot, i].Count = 0) |
b5222ddafe1f
- Fix bug with picking up ammos from cases, when total ammo count may become more than AMMO_INFINITE
unc0rr
parents:
931
diff
changeset
|
51 |
or (Team^.Clan^.TurnNumber <= Ammoz[Ammo^[slot, i].AmmoType].SkipTurns)) do inc(i); |
b5222ddafe1f
- Fix bug with picking up ammos from cases, when total ammo count may become more than AMMO_INFINITE
unc0rr
parents:
931
diff
changeset
|
52 |
|
b5222ddafe1f
- Fix bug with picking up ammos from cases, when total ammo count may become more than AMMO_INFINITE
unc0rr
parents:
931
diff
changeset
|
53 |
if i <= cMaxSlotAmmoIndex then |
b5222ddafe1f
- Fix bug with picking up ammos from cases, when total ammo count may become more than AMMO_INFINITE
unc0rr
parents:
931
diff
changeset
|
54 |
begin |
b5222ddafe1f
- Fix bug with picking up ammos from cases, when total ammo count may become more than AMMO_INFINITE
unc0rr
parents:
931
diff
changeset
|
55 |
CurSlot:= slot; |
b5222ddafe1f
- Fix bug with picking up ammos from cases, when total ammo count may become more than AMMO_INFINITE
unc0rr
parents:
931
diff
changeset
|
56 |
CurAmmo:= i |
b5222ddafe1f
- Fix bug with picking up ammos from cases, when total ammo count may become more than AMMO_INFINITE
unc0rr
parents:
931
diff
changeset
|
57 |
end |
b5222ddafe1f
- Fix bug with picking up ammos from cases, when total ammo count may become more than AMMO_INFINITE
unc0rr
parents:
931
diff
changeset
|
58 |
end |
1710
cecb3cc93251
Fix angle restriction applying to rc plane when choosing via ammomenu
unc0rr
parents:
1689
diff
changeset
|
59 |
end |
783 | 60 |
end; |
61 |
||
62 |
procedure HHSetWeapon(Gear: PGear); |
|
63 |
var t: LongInt; |
|
64 |
weap: TAmmoType; |
|
65 |
begin |
|
66 |
weap:= TAmmoType(Gear^.MsgParam); |
|
941
b5222ddafe1f
- Fix bug with picking up ammos from cases, when total ammo count may become more than AMMO_INFINITE
unc0rr
parents:
931
diff
changeset
|
67 |
|
b5222ddafe1f
- Fix bug with picking up ammos from cases, when total ammo count may become more than AMMO_INFINITE
unc0rr
parents:
931
diff
changeset
|
68 |
if PHedgehog(Gear^.Hedgehog)^.Team^.Clan^.TurnNumber <= Ammoz[weap].SkipTurns then exit; // weapon isn't activated yet |
b5222ddafe1f
- Fix bug with picking up ammos from cases, when total ammo count may become more than AMMO_INFINITE
unc0rr
parents:
931
diff
changeset
|
69 |
|
783 | 70 |
Gear^.MsgParam:= Ammoz[weap].Slot; |
71 |
||
72 |
t:= cMaxSlotAmmoIndex; |
|
73 |
||
74 |
Gear^.Message:= Gear^.Message and not gm_Weapon; |
|
75 |
||
76 |
with PHedgehog(Gear^.Hedgehog)^ do |
|
926
d231e007452a
Timer as hedgehog message (avoid possible desync in very rare cases)
unc0rr
parents:
925
diff
changeset
|
77 |
while (Ammo^[CurSlot, CurAmmo].AmmoType <> weap) and (t >= 0) do |
d231e007452a
Timer as hedgehog message (avoid possible desync in very rare cases)
unc0rr
parents:
925
diff
changeset
|
78 |
begin |
d231e007452a
Timer as hedgehog message (avoid possible desync in very rare cases)
unc0rr
parents:
925
diff
changeset
|
79 |
ChangeAmmo(Gear); |
d231e007452a
Timer as hedgehog message (avoid possible desync in very rare cases)
unc0rr
parents:
925
diff
changeset
|
80 |
dec(t) |
1710
cecb3cc93251
Fix angle restriction applying to rc plane when choosing via ammomenu
unc0rr
parents:
1689
diff
changeset
|
81 |
end; |
cecb3cc93251
Fix angle restriction applying to rc plane when choosing via ammomenu
unc0rr
parents:
1689
diff
changeset
|
82 |
|
cecb3cc93251
Fix angle restriction applying to rc plane when choosing via ammomenu
unc0rr
parents:
1689
diff
changeset
|
83 |
ApplyAmmoChanges(PHedgehog(Gear^.Hedgehog)^) |
783 | 84 |
end; |
85 |
||
926
d231e007452a
Timer as hedgehog message (avoid possible desync in very rare cases)
unc0rr
parents:
925
diff
changeset
|
86 |
procedure HHSetTimer(Gear: PGear); |
d231e007452a
Timer as hedgehog message (avoid possible desync in very rare cases)
unc0rr
parents:
925
diff
changeset
|
87 |
begin |
d231e007452a
Timer as hedgehog message (avoid possible desync in very rare cases)
unc0rr
parents:
925
diff
changeset
|
88 |
Gear^.Message:= Gear^.Message and not gm_Timer; |
d231e007452a
Timer as hedgehog message (avoid possible desync in very rare cases)
unc0rr
parents:
925
diff
changeset
|
89 |
with PHedgehog(Gear^.Hedgehog)^ do |
d231e007452a
Timer as hedgehog message (avoid possible desync in very rare cases)
unc0rr
parents:
925
diff
changeset
|
90 |
if (Ammo^[CurSlot, CurAmmo].Propz and ammoprop_Timerable) <> 0 then |
d231e007452a
Timer as hedgehog message (avoid possible desync in very rare cases)
unc0rr
parents:
925
diff
changeset
|
91 |
begin |
d231e007452a
Timer as hedgehog message (avoid possible desync in very rare cases)
unc0rr
parents:
925
diff
changeset
|
92 |
Ammo^[CurSlot, CurAmmo].Timer:= 1000 * Gear^.MsgParam; |
d231e007452a
Timer as hedgehog message (avoid possible desync in very rare cases)
unc0rr
parents:
925
diff
changeset
|
93 |
with CurrentTeam^ do |
d231e007452a
Timer as hedgehog message (avoid possible desync in very rare cases)
unc0rr
parents:
925
diff
changeset
|
94 |
ApplyAmmoChanges(Hedgehogs[CurrHedgehog]); |
d231e007452a
Timer as hedgehog message (avoid possible desync in very rare cases)
unc0rr
parents:
925
diff
changeset
|
95 |
end; |
d231e007452a
Timer as hedgehog message (avoid possible desync in very rare cases)
unc0rr
parents:
925
diff
changeset
|
96 |
end; |
d231e007452a
Timer as hedgehog message (avoid possible desync in very rare cases)
unc0rr
parents:
925
diff
changeset
|
97 |
|
d231e007452a
Timer as hedgehog message (avoid possible desync in very rare cases)
unc0rr
parents:
925
diff
changeset
|
98 |
|
32
78bff13b11c0
With this patch the game doesn't crash when gaming by net
unc0rr
parents:
16
diff
changeset
|
99 |
procedure Attack(Gear: PGear); |
351 | 100 |
var xx, yy: hwFloat; |
32
78bff13b11c0
With this patch the game doesn't crash when gaming by net
unc0rr
parents:
16
diff
changeset
|
101 |
begin |
78bff13b11c0
With this patch the game doesn't crash when gaming by net
unc0rr
parents:
16
diff
changeset
|
102 |
with Gear^, |
351 | 103 |
PHedgehog(Gear^.Hedgehog)^ do |
32
78bff13b11c0
With this patch the game doesn't crash when gaming by net
unc0rr
parents:
16
diff
changeset
|
104 |
begin |
95 | 105 |
if ((State and gstHHDriven) <> 0)and |
542 | 106 |
((State and (gstAttacked or gstHHChooseTarget)) = 0)and |
836 | 107 |
(((State and gstMoving) = 0) or ((Ammo^[CurSlot, CurAmmo].Propz and ammoprop_AttackInMove) <> 0))and |
108 |
((TargetPoint.X <> NoPointX) or ((Ammo^[CurSlot, CurAmmo].Propz and ammoprop_NeedTarget) = 0)) then |
|
32
78bff13b11c0
With this patch the game doesn't crash when gaming by net
unc0rr
parents:
16
diff
changeset
|
109 |
begin |
95 | 110 |
State:= State or gstAttacking; |
111 |
if Power = cMaxPower then Message:= Message and not gm_Attack |
|
351 | 112 |
else if (Ammo^[CurSlot, CurAmmo].Propz and ammoprop_Power) = 0 then Message:= Message and not gm_Attack |
95 | 113 |
else begin |
114 |
if Power = 0 then |
|
115 |
begin |
|
351 | 116 |
AttackBar:= CurrentTeam^.AttackBar; |
1669 | 117 |
PlaySound(sndThrowPowerUp, false, nil) |
95 | 118 |
end; |
119 |
inc(Power) |
|
120 |
end; |
|
121 |
if ((Message and gm_Attack) <> 0) then exit; |
|
351 | 122 |
|
123 |
if (Ammo^[CurSlot, CurAmmo].Propz and ammoprop_Power) <> 0 then |
|
32
78bff13b11c0
With this patch the game doesn't crash when gaming by net
unc0rr
parents:
16
diff
changeset
|
124 |
begin |
282 | 125 |
StopSound(sndThrowPowerUp); |
1669 | 126 |
PlaySound(sndThrowRelease, false, nil); |
32
78bff13b11c0
With this patch the game doesn't crash when gaming by net
unc0rr
parents:
16
diff
changeset
|
127 |
end; |
519 | 128 |
xx:= SignAs(AngleSin(Angle), dX); |
900 | 129 |
yy:= -AngleCos(Angle); |
130 |
||
131 |
if ((Gear^.State and gstHHHJump) <> 0) then xx:= - xx; |
|
351 | 132 |
case Ammo^[CurSlot, CurAmmo].AmmoType of |
133 |
amGrenade: FollowGear:= AddGear(hwRound(X), hwRound(Y), gtAmmo_Bomb, 0, xx*Power/cPowerDivisor, yy*Power/cPowerDivisor, Ammo^[CurSlot, CurAmmo].Timer); |
|
134 |
amClusterBomb: FollowGear:= AddGear(hwRound(X), hwRound(Y), gtClusterBomb, 0, xx*Power/cPowerDivisor, yy*Power/cPowerDivisor, Ammo^[CurSlot, CurAmmo].Timer); |
|
135 |
amBazooka: FollowGear:= AddGear(hwRound(X), hwRound(Y), gtAmmo_Grenade, 0, xx*Power/cPowerDivisor, yy*Power/cPowerDivisor, 0); |
|
136 |
amUFO: FollowGear:= AddGear(hwRound(X), hwRound(Y), gtUFO, 0, xx*Power/cPowerDivisor, yy*Power/cPowerDivisor, 0); |
|
32
78bff13b11c0
With this patch the game doesn't crash when gaming by net
unc0rr
parents:
16
diff
changeset
|
137 |
amShotgun: begin |
1669 | 138 |
PlaySound(sndShotgunReload, false, nil); |
351 | 139 |
CurAmmoGear:= AddGear(hwRound(X), hwRound(Y), gtShotgunShot, 0, xx * _0_5, yy * _0_5, 0); |
32
78bff13b11c0
With this patch the game doesn't crash when gaming by net
unc0rr
parents:
16
diff
changeset
|
140 |
end; |
498 | 141 |
amPickHammer: CurAmmoGear:= AddGear(hwRound(Gear^.X), hwRound(Gear^.Y) + cHHRadius, gtPickHammer, 0, _0, _0, 0); |
866 | 142 |
amSkip: ParseCommand('/skip', true); |
351 | 143 |
amRope: CurAmmoGear:= AddGear(hwRound(Gear^.X), hwRound(Gear^.Y), gtRope, 0, xx, yy, 0); |
800 | 144 |
amMine: begin |
145 |
AddGear(hwRound(X) + hwSign(dX) * 7, hwRound(Y), gtMine, 0, SignAs(_0_02, dX), _0, 3000); |
|
1682 | 146 |
PlaySound(sndLaugh, false, CurrentTeam^.voicepack) |
800 | 147 |
end; |
876 | 148 |
amDEagle: CurAmmoGear:= AddGear(hwRound(X + xx * cHHRadius), hwRound(Y + yy * cHHRadius), gtDEagleShot, 0, xx * _0_5, yy * _0_5, 0); |
1112 | 149 |
amDynamite: begin |
150 |
AddGear(hwRound(X) + hwSign(dX) * 7, hwRound(Y), gtDynamite, 0, SignAs(_0_03, dX), _0, 5000); |
|
1682 | 151 |
PlaySound(sndLaugh, false, CurrentTeam^.voicepack) |
1112 | 152 |
end; |
979
edb8f208c1d9
Fix firepunch direction when attacking from high jump
unc0rr
parents:
958
diff
changeset
|
153 |
amFirePunch: CurAmmoGear:= AddGear(hwRound(X) + hwSign(dX) * 10, hwRound(Y), gtFirePunch, 0, xx, _0, 0); |
1712 | 154 |
amWhip: begin |
155 |
CurAmmoGear:= AddGear(hwRound(X) + hwSign(dX) * 10, hwRound(Y), gtWhip, 0, SignAs(_1, dX), - _0_8, 0); |
|
156 |
PlaySound(sndWhipCrack, false, nil) |
|
157 |
end; |
|
854 | 158 |
amBaseballBat: CurAmmoGear:= AddGear(hwRound(X) + hwSign(dX) * 10, hwRound(Y), gtShover, 0, xx * _0_5, yy * _0_5, 0); |
498 | 159 |
amParachute: CurAmmoGear:= AddGear(hwRound(X), hwRound(Y), gtParachute, 0, _0, _0, 0); |
160 |
amAirAttack: AddGear(Ammo^[CurSlot, CurAmmo].Pos, 0, gtAirAttack, 0, _0, _0, 0); |
|
161 |
amMineStrike: AddGear(Ammo^[CurSlot, CurAmmo].Pos, 0, gtAirAttack, 1, _0, _0, 0); |
|
162 |
amBlowTorch: CurAmmoGear:= AddGear(hwRound(X), hwRound(Y), gtBlowTorch, 0, SignAs(_0_5, dX), _0, 0); |
|
163 |
amGirder: CurAmmoGear:= AddGear(0, 0, gtGirder, Ammo^[CurSlot, CurAmmo].Pos, _0, _0, 0); |
|
520 | 164 |
amTeleport: CurAmmoGear:= AddGear(0, 0, gtTeleport, 0, _0, _0, 0); |
534 | 165 |
amSwitch: CurAmmoGear:= AddGear(hwRound(X), hwRound(Y), gtSwitcher, 0, _0, _0, 0); |
924 | 166 |
amMortar: FollowGear:= AddGear(hwRound(X), hwRound(Y), gtMortar, 0, xx*cMaxPower/cPowerDivisor, yy*cMaxPower/cPowerDivisor, 0); |
1712 | 167 |
amRCPlane: begin |
168 |
CurAmmoGear:= AddGear(hwRound(X), hwRound(Y), gtRCPlane, 0, xx * cMaxPower / cPowerDivisor / 4, yy * cMaxPower / cPowerDivisor / 4, 0); |
|
169 |
PlaySound(sndRCPlane, true, nil) |
|
170 |
end; |
|
984 | 171 |
amKamikaze: CurAmmoGear:= AddGear(hwRound(X), hwRound(Y), gtKamikaze, 0, xx * _0_5, yy * _0_5, 0); |
1112 | 172 |
amCake: begin |
173 |
CurAmmoGear:= AddGear(hwRound(X) + hwSign(dX) * 3, hwRound(Y), gtCake, 0, xx, _0, 0); |
|
1682 | 174 |
PlaySound(sndLaugh, false, CurrentTeam^.voicepack) |
1112 | 175 |
end; |
1286 | 176 |
amSeduction: CurAmmoGear:= AddGear(hwRound(X + xx * cHHRadius * 2), hwRound(Y + yy * cHHRadius * 2), gtSeduction, 0, xx * _0_4, yy * _0_4, 0); |
1261 | 177 |
amWatermelon: FollowGear:= AddGear(hwRound(X), hwRound(Y), gtWatermelon, 0, xx*Power/cPowerDivisor, yy*Power/cPowerDivisor, Ammo^[CurSlot, CurAmmo].Timer); |
1263 | 178 |
amHellishBomb: FollowGear:= AddGear(hwRound(X), hwRound(Y), gtHellishBomb, 0, xx*Power/cPowerDivisor, yy*Power/cPowerDivisor, 5000); |
1507 | 179 |
amNapalm: AddGear(Ammo^[CurSlot, CurAmmo].Pos, 0, gtAirAttack, 2, _0, _0, 0); |
1573 | 180 |
amDrill: FollowGear:= AddGear(hwRound(X), hwRound(Y), gtDrill, 0, xx*Power/cPowerDivisor, yy*Power/cPowerDivisor, 0); |
1601 | 181 |
amBallgun: CurAmmoGear:= AddGear(hwRound(X), hwRound(Y), gtBallgun, 0, xx * _0_5, yy * _0_5, 0); |
32
78bff13b11c0
With this patch the game doesn't crash when gaming by net
unc0rr
parents:
16
diff
changeset
|
182 |
end; |
829 | 183 |
|
184 |
uStats.AmmoUsed(Ammo^[CurSlot, CurAmmo].AmmoType); |
|
185 |
||
32
78bff13b11c0
With this patch the game doesn't crash when gaming by net
unc0rr
parents:
16
diff
changeset
|
186 |
Power:= 0; |
930 | 187 |
if (CurAmmoGear <> nil) |
188 |
and (((Ammo^[CurSlot, CurAmmo].Propz) and ammoprop_AltUse) = 0){check for dropping ammo from rope} then |
|
32
78bff13b11c0
With this patch the game doesn't crash when gaming by net
unc0rr
parents:
16
diff
changeset
|
189 |
begin |
930 | 190 |
CurAmmoGear^.Ammo:= @(Ammo^[CurSlot, CurAmmo]); |
82 | 191 |
Message:= Message or gm_Attack; |
351 | 192 |
CurAmmoGear^.Message:= Message |
82 | 193 |
end else begin |
351 | 194 |
if not CurrentTeam^.ExtDriven and |
195 |
((Ammo^[CurSlot, CurAmmo].Propz and ammoprop_Power) <> 0) then SendIPC('a'); |
|
82 | 196 |
AfterAttack |
197 |
end |
|
95 | 198 |
end else Message:= Message and not gm_Attack |
32
78bff13b11c0
With this patch the game doesn't crash when gaming by net
unc0rr
parents:
16
diff
changeset
|
199 |
end |
78bff13b11c0
With this patch the game doesn't crash when gaming by net
unc0rr
parents:
16
diff
changeset
|
200 |
end; |
78bff13b11c0
With this patch the game doesn't crash when gaming by net
unc0rr
parents:
16
diff
changeset
|
201 |
|
78bff13b11c0
With this patch the game doesn't crash when gaming by net
unc0rr
parents:
16
diff
changeset
|
202 |
procedure AfterAttack; |
78bff13b11c0
With this patch the game doesn't crash when gaming by net
unc0rr
parents:
16
diff
changeset
|
203 |
begin |
602 | 204 |
with CurrentHedgehog^.Gear^, |
1286 | 205 |
CurrentHedgehog^ do |
206 |
begin |
|
207 |
Inc(AttacksNum); |
|
208 |
State:= State and not gstAttacking; |
|
209 |
if (Ammo^[CurSlot, CurAmmo].NumPerTurn >= AttacksNum) or |
|
210 |
((GameFlags and gfMultiWeapon) <> 0) then isInMultiShoot:= true |
|
211 |
else begin |
|
212 |
TurnTimeLeft:= Ammoz[Ammo^[CurSlot, CurAmmo].AmmoType].TimeAfterTurn; |
|
213 |
State:= State or gstAttacked; |
|
214 |
OnUsedAmmo(CurrentHedgehog^) |
|
215 |
end; |
|
216 |
AttackBar:= 0; |
|
217 |
end |
|
32
78bff13b11c0
With this patch the game doesn't crash when gaming by net
unc0rr
parents:
16
diff
changeset
|
218 |
end; |
78bff13b11c0
With this patch the game doesn't crash when gaming by net
unc0rr
parents:
16
diff
changeset
|
219 |
|
42 | 220 |
//////////////////////////////////////////////////////////////////////////////// |
863 | 221 |
procedure doStepHedgehogDead(Gear: PGear); |
868 | 222 |
const frametime = 200; |
223 |
timertime = frametime * 6; |
|
863 | 224 |
begin |
225 |
if Gear^.Timer > 1 then |
|
226 |
begin |
|
227 |
AllInactive:= false; |
|
868 | 228 |
dec(Gear^.Timer); |
229 |
if (Gear^.Timer mod frametime) = 0 then inc(Gear^.Pos) |
|
863 | 230 |
end else |
231 |
if Gear^.Timer = 1 then |
|
232 |
begin |
|
233 |
Gear^.State:= Gear^.State or gstNoDamage; |
|
234 |
doMakeExplosion(hwRound(Gear^.X), hwRound(Gear^.Y), 30, EXPLAutoSound); |
|
235 |
AddGear(hwRound(Gear^.X), hwRound(Gear^.Y), gtGrave, 0, _0, _0, 0)^.Hedgehog:= Gear^.Hedgehog; |
|
236 |
DeleteGear(Gear); |
|
237 |
SetAllToActive |
|
238 |
end else // Gear^.Timer = 0 |
|
239 |
begin |
|
240 |
AllInactive:= false; |
|
868 | 241 |
Gear^.Z:= cCurrHHZ; |
242 |
RemoveGearFromList(Gear); |
|
243 |
InsertGearToList(Gear); |
|
1669 | 244 |
PlaySound(sndByeBye, false, PHedgehog(Gear^.Hedgehog)^.Team^.voicepack); |
868 | 245 |
Gear^.Pos:= 0; |
246 |
Gear^.Timer:= timertime |
|
863 | 247 |
end |
248 |
end; |
|
249 |
||
250 |
//////////////////////////////////////////////////////////////////////////////// |
|
42 | 251 |
procedure PickUp(HH, Gear: PGear); |
295 | 252 |
var s: shortstring; |
253 |
a: TAmmoType; |
|
42 | 254 |
begin |
351 | 255 |
Gear^.Message:= gm_Destroy; |
256 |
case Gear^.Pos of |
|
295 | 257 |
posCaseAmmo: begin |
351 | 258 |
a:= TAmmoType(Gear^.State); |
553
5478386d935f
- Switch to bazooka (or whatever) after use of some weapon (fixes problem with bots)
unc0rr
parents:
549
diff
changeset
|
259 |
AddAmmo(PHedgehog(HH^.Hedgehog)^, a); |
1072 | 260 |
if (not (PHedgehog(HH^.Hedgehog)^.Team^.ExtDriven |
261 |
or (PHedgehog(HH^.Hedgehog)^.BotLevel > 0))) |
|
262 |
or (GameType = gmtDemo) then |
|
836 | 263 |
begin |
264 |
s:= trammo[Ammoz[a].NameId] + '(+' + IntToStr(Ammoz[a].NumberInCase) + ')'; |
|
265 |
AddCaption(s, PHedgehog(HH^.Hedgehog)^.Team^.Clan^.Color, capgrpAmmoinfo); |
|
266 |
end |
|
295 | 267 |
end; |
42 | 268 |
posCaseHealth: begin |
351 | 269 |
inc(HH^.Health, Gear^.Health); |
270 |
str(Gear^.Health, s); |
|
295 | 271 |
s:= '+' + s; |
549 | 272 |
AddCaption(s, PHedgehog(HH^.Hedgehog)^.Team^.Clan^.Color, capgrpAmmoinfo); |
351 | 273 |
RenderHealth(PHedgehog(HH^.Hedgehog)^); |
274 |
RecountTeamHealth(PHedgehog(HH^.Hedgehog)^.Team) |
|
42 | 275 |
end; |
435 | 276 |
end |
42 | 277 |
end; |
32
78bff13b11c0
With this patch the game doesn't crash when gaming by net
unc0rr
parents:
16
diff
changeset
|
278 |
|
4 | 279 |
const StepTicks: LongWord = 0; |
280 |
||
302 | 281 |
procedure HedgehogStep(Gear: PGear); |
371 | 282 |
var PrevdX: LongInt; |
302 | 283 |
begin |
542 | 284 |
if ((Gear^.State and (gstAttacking or gstMoving)) = 0) then |
4 | 285 |
begin |
408 | 286 |
if isCursorVisible then |
287 |
with PHedgehog(Gear^.Hedgehog)^ do |
|
288 |
with Ammo^[CurSlot, CurAmmo] do |
|
289 |
begin |
|
542 | 290 |
if (Gear^.Message and gm_Left ) <> 0 then |
408 | 291 |
Pos:= (Pos + Ammoz[AmmoType].PosCount - 1) mod Ammoz[AmmoType].PosCount |
292 |
else |
|
542 | 293 |
if (Gear^.Message and gm_Right ) <> 0 then |
408 | 294 |
Pos:= (Pos + 1) mod Ammoz[AmmoType].PosCount |
295 |
else exit; |
|
423 | 296 |
StepTicks:= 200; |
408 | 297 |
exit |
298 |
end; |
|
505
fcba7d7aea0d
Fix old bug with grenade(bomd, etc..) not colliding with attacking hedgehog
unc0rr
parents:
498
diff
changeset
|
299 |
|
1033 | 300 |
if ((Gear^.Message and gm_Animate) <> 0) then |
301 |
begin |
|
302 |
Gear^.Message:= 0; |
|
303 |
Gear^.State:= Gear^.State or gstAnimation; |
|
304 |
Gear^.Tag:= Gear^.MsgParam; |
|
305 |
Gear^.Timer:= 0; |
|
306 |
Gear^.Pos:= 0 |
|
307 |
end; |
|
308 |
||
351 | 309 |
if ((Gear^.Message and gm_LJump ) <> 0) then |
4 | 310 |
begin |
542 | 311 |
Gear^.Message:= Gear^.Message and not gm_LJump; |
505
fcba7d7aea0d
Fix old bug with grenade(bomd, etc..) not colliding with attacking hedgehog
unc0rr
parents:
498
diff
changeset
|
312 |
DeleteCI(Gear); |
68 | 313 |
if not TestCollisionYwithGear(Gear, -1) then |
498 | 314 |
if not TestCollisionXwithXYShift(Gear, _0, -2, hwSign(Gear^.dX)) then Gear^.Y:= Gear^.Y - _2 else |
315 |
if not TestCollisionXwithXYShift(Gear, _0, -1, hwSign(Gear^.dX)) then Gear^.Y:= Gear^.Y - _1; |
|
351 | 316 |
if not (TestCollisionXwithGear(Gear, hwSign(Gear^.dX)) |
68 | 317 |
or TestCollisionYwithGear(Gear, -1)) then |
4 | 318 |
begin |
351 | 319 |
Gear^.dY:= -_0_15; |
498 | 320 |
Gear^.dX:= SignAs(_0_15, Gear^.dX); |
542 | 321 |
Gear^.State:= Gear^.State or gstMoving or gstHHJumping; |
1669 | 322 |
PlaySound(sndJump1, false, PHedgehog(Gear^.Hedgehog)^.Team^.voicepack); |
4 | 323 |
exit |
324 |
end; |
|
325 |
end; |
|
505
fcba7d7aea0d
Fix old bug with grenade(bomd, etc..) not colliding with attacking hedgehog
unc0rr
parents:
498
diff
changeset
|
326 |
|
351 | 327 |
if ((Gear^.Message and gm_HJump ) <> 0) then |
4 | 328 |
begin |
505
fcba7d7aea0d
Fix old bug with grenade(bomd, etc..) not colliding with attacking hedgehog
unc0rr
parents:
498
diff
changeset
|
329 |
DeleteCI(Gear); |
542 | 330 |
Gear^.Message:= Gear^.Message and not gm_HJump; |
855
8842c71d16bf
- Fix too long delay between shotgun and deagle shots
unc0rr
parents:
854
diff
changeset
|
331 |
|
8842c71d16bf
- Fix too long delay between shotgun and deagle shots
unc0rr
parents:
854
diff
changeset
|
332 |
Gear^.dY:= -_0_2; |
8842c71d16bf
- Fix too long delay between shotgun and deagle shots
unc0rr
parents:
854
diff
changeset
|
333 |
SetLittle(Gear^.dX); |
8842c71d16bf
- Fix too long delay between shotgun and deagle shots
unc0rr
parents:
854
diff
changeset
|
334 |
Gear^.State:= Gear^.State or gstMoving or gstHHJumping; |
1669 | 335 |
PlaySound(sndJump3, false, PHedgehog(Gear^.Hedgehog)^.Team^.voicepack); |
855
8842c71d16bf
- Fix too long delay between shotgun and deagle shots
unc0rr
parents:
854
diff
changeset
|
336 |
exit |
4 | 337 |
end; |
505
fcba7d7aea0d
Fix old bug with grenade(bomd, etc..) not colliding with attacking hedgehog
unc0rr
parents:
498
diff
changeset
|
338 |
|
351 | 339 |
PrevdX:= hwSign(Gear^.dX); |
340 |
if (Gear^.Message and gm_Left )<>0 then Gear^.dX:= -cLittle else |
|
341 |
if (Gear^.Message and gm_Right )<>0 then Gear^.dX:= cLittle else exit; |
|
505
fcba7d7aea0d
Fix old bug with grenade(bomd, etc..) not colliding with attacking hedgehog
unc0rr
parents:
498
diff
changeset
|
342 |
|
74 | 343 |
StepTicks:= cHHStepTicks; |
610 | 344 |
if PrevdX <> hwSign(Gear^.dX) then |
345 |
begin |
|
346 |
FollowGear:= Gear; |
|
347 |
exit |
|
348 |
end; |
|
349 |
DeleteCI(Gear); // must be after exit!! (see previous line) |
|
838 | 350 |
|
351 | 351 |
PHedgehog(Gear^.Hedgehog)^.visStepPos:= (PHedgehog(Gear^.Hedgehog)^.visStepPos + 1) and 7; |
352 |
if TestCollisionXwithGear(Gear, hwSign(Gear^.dX)) then |
|
4 | 353 |
begin |
498 | 354 |
if not (TestCollisionXwithXYShift(Gear, _0, -6, hwSign(Gear^.dX)) |
355 |
or TestCollisionYwithGear(Gear, -1)) then Gear^.Y:= Gear^.Y - _1; |
|
356 |
if not (TestCollisionXwithXYShift(Gear, _0, -5, hwSign(Gear^.dX)) |
|
357 |
or TestCollisionYwithGear(Gear, -1)) then Gear^.Y:= Gear^.Y - _1; |
|
358 |
if not (TestCollisionXwithXYShift(Gear, _0, -4, hwSign(Gear^.dX)) |
|
359 |
or TestCollisionYwithGear(Gear, -1)) then Gear^.Y:= Gear^.Y - _1; |
|
360 |
if not (TestCollisionXwithXYShift(Gear, _0, -3, hwSign(Gear^.dX)) |
|
361 |
or TestCollisionYwithGear(Gear, -1)) then Gear^.Y:= Gear^.Y - _1; |
|
362 |
if not (TestCollisionXwithXYShift(Gear, _0, -2, hwSign(Gear^.dX)) |
|
363 |
or TestCollisionYwithGear(Gear, -1)) then Gear^.Y:= Gear^.Y - _1; |
|
364 |
if not (TestCollisionXwithXYShift(Gear, _0, -1, hwSign(Gear^.dX)) |
|
365 |
or TestCollisionYwithGear(Gear, -1)) then Gear^.Y:= Gear^.Y - _1; |
|
4 | 366 |
end; |
1528 | 367 |
|
498 | 368 |
if not TestCollisionXwithGear(Gear, hwSign(Gear^.dX)) then Gear^.X:= Gear^.X + SignAs(_1, Gear^.dX); |
62 | 369 |
SetAllHHToActive; |
37 | 370 |
|
68 | 371 |
if not TestCollisionYwithGear(Gear, 1) then |
4 | 372 |
begin |
498 | 373 |
Gear^.Y:= Gear^.Y + _1; |
68 | 374 |
if not TestCollisionYwithGear(Gear, 1) then |
4 | 375 |
begin |
498 | 376 |
Gear^.Y:= Gear^.Y + _1; |
68 | 377 |
if not TestCollisionYwithGear(Gear, 1) then |
4 | 378 |
begin |
498 | 379 |
Gear^.Y:= Gear^.Y + _1; |
68 | 380 |
if not TestCollisionYwithGear(Gear, 1) then |
4 | 381 |
begin |
498 | 382 |
Gear^.Y:= Gear^.Y + _1; |
68 | 383 |
if not TestCollisionYwithGear(Gear, 1) then |
4 | 384 |
begin |
498 | 385 |
Gear^.Y:= Gear^.Y + _1; |
68 | 386 |
if not TestCollisionYwithGear(Gear, 1) then |
4 | 387 |
begin |
498 | 388 |
Gear^.Y:= Gear^.Y + _1; |
68 | 389 |
if not TestCollisionYwithGear(Gear, 1) then |
4 | 390 |
begin |
498 | 391 |
Gear^.Y:= Gear^.Y - _6; |
392 |
Gear^.dY:= _0; |
|
542 | 393 |
Gear^.State:= Gear^.State or gstMoving; |
505
fcba7d7aea0d
Fix old bug with grenade(bomd, etc..) not colliding with attacking hedgehog
unc0rr
parents:
498
diff
changeset
|
394 |
exit |
4 | 395 |
end; |
396 |
end |
|
397 |
end |
|
398 |
end |
|
399 |
end |
|
400 |
end |
|
505
fcba7d7aea0d
Fix old bug with grenade(bomd, etc..) not colliding with attacking hedgehog
unc0rr
parents:
498
diff
changeset
|
401 |
end; |
fcba7d7aea0d
Fix old bug with grenade(bomd, etc..) not colliding with attacking hedgehog
unc0rr
parents:
498
diff
changeset
|
402 |
AddGearCI(Gear) |
4 | 403 |
end |
404 |
end; |
|
405 |
||
303
1659c4aad5ab
Now blow torch angle can be changed during blowing :)
unc0rr
parents:
302
diff
changeset
|
406 |
procedure HedgehogChAngle(Gear: PGear); |
958 | 407 |
var da: LongWord; |
303
1659c4aad5ab
Now blow torch angle can be changed during blowing :)
unc0rr
parents:
302
diff
changeset
|
408 |
begin |
958 | 409 |
with PHedgehog(Gear^.Hedgehog)^ do |
410 |
if (Ammo^[CurSlot, CurAmmo].AmmoType = amRope) |
|
411 |
and ((Gear^.State and (gstMoving or gstHHJumping)) = gstMoving) then da:= 2 else da:= 1; |
|
412 |
||
1639 | 413 |
if (((Gear^.Message and gm_Precise) = 0) or ((GameTicks mod 5) = 1)) then |
414 |
if ((Gear^.Message and gm_Up) <> 0) and (Gear^.Angle - da >= CurMinAngle) then dec(Gear^.Angle, da) |
|
415 |
else |
|
1689 | 416 |
if ((Gear^.Message and gm_Down) <> 0) and (Gear^.Angle + da <= CurMaxAngle) then inc(Gear^.Angle, da) |
303
1659c4aad5ab
Now blow torch angle can be changed during blowing :)
unc0rr
parents:
302
diff
changeset
|
417 |
end; |
1659c4aad5ab
Now blow torch angle can be changed during blowing :)
unc0rr
parents:
302
diff
changeset
|
418 |
|
302 | 419 |
procedure doStepHedgehog(Gear: PGear); forward; |
420 |
//////////////////////////////////////////////////////////////////////////////// |
|
538 | 421 |
procedure doStepHedgehogMoving(Gear: PGear); |
545 | 422 |
var isFalling: boolean; |
538 | 423 |
begin |
855
8842c71d16bf
- Fix too long delay between shotgun and deagle shots
unc0rr
parents:
854
diff
changeset
|
424 |
isFalling:= (Gear^.dY.isNegative) or not TestCollisionYKick(Gear, 1); |
542 | 425 |
if isFalling then |
538 | 426 |
begin |
427 |
if (Gear^.dY.isNegative) and TestCollisionYKick(Gear, -1) then Gear^.dY:= _0; |
|
542 | 428 |
Gear^.State:= Gear^.State or gstMoving; |
538 | 429 |
Gear^.dY:= Gear^.dY + cGravity |
430 |
end else |
|
431 |
begin |
|
432 |
if ((hwAbs(Gear^.dX) + hwAbs(Gear^.dY)) < _0_55) |
|
433 |
and ((Gear^.State and gstHHJumping) <> 0) then SetLittle(Gear^.dX); |
|
434 |
||
540 | 435 |
if not Gear^.dY.isNegative then |
436 |
begin |
|
437 |
CheckHHDamage(Gear); |
|
790
a6f442173822
Make high jump behaviour like in worms (back somersault)
unc0rr
parents:
783
diff
changeset
|
438 |
|
a6f442173822
Make high jump behaviour like in worms (back somersault)
unc0rr
parents:
783
diff
changeset
|
439 |
if ((Gear^.State and gstHHHJump) <> 0) and |
a6f442173822
Make high jump behaviour like in worms (back somersault)
unc0rr
parents:
783
diff
changeset
|
440 |
(Gear^.dX.QWordValue < _0_02.QWordValue) then Gear^.dX.isNegative:= not Gear^.dX.isNegative; // landing after high jump |
a6f442173822
Make high jump behaviour like in worms (back somersault)
unc0rr
parents:
783
diff
changeset
|
441 |
|
542 | 442 |
Gear^.State:= Gear^.State and not (gstHHJumping or gstHHHJump); |
540 | 443 |
Gear^.dY:= _0; |
444 |
end else Gear^.dY:= Gear^.dY + cGravity; |
|
538 | 445 |
|
446 |
if ((Gear^.State and gstMoving) <> 0) then Gear^.dX:= Gear^.dX * Gear^.Friction |
|
447 |
end; |
|
448 |
||
449 |
if (Gear^.State <> 0) then DeleteCI(Gear); |
|
783 | 450 |
|
538 | 451 |
if (Gear^.State and gstMoving) <> 0 then |
452 |
if TestCollisionXKick(Gear, hwSign(Gear^.dX)) then |
|
542 | 453 |
if not isFalling then |
538 | 454 |
if hwAbs(Gear^.dX) > _0_01 then |
455 |
if not TestCollisionXwithXYShift(Gear, int2hwFloat(hwSign(Gear^.dX)) - Gear^.dX, -1, hwSign(Gear^.dX)) then begin Gear^.X:= Gear^.X + Gear^.dX; Gear^.dX:= Gear^.dX * _0_96; Gear^.Y:= Gear^.Y - _1 end else |
|
456 |
if not TestCollisionXwithXYShift(Gear, int2hwFloat(hwSign(Gear^.dX)) - Gear^.dX, -2, hwSign(Gear^.dX)) then begin Gear^.X:= Gear^.X + Gear^.dX; Gear^.dX:= Gear^.dX * _0_93; Gear^.Y:= Gear^.Y - _2 end else |
|
457 |
if not TestCollisionXwithXYShift(Gear, int2hwFloat(hwSign(Gear^.dX)) - Gear^.dX, -3, hwSign(Gear^.dX)) then begin Gear^.X:= Gear^.X + Gear^.dX; Gear^.dX:= Gear^.dX * _0_9 ; Gear^.Y:= Gear^.Y - _3 end else |
|
458 |
if not TestCollisionXwithXYShift(Gear, int2hwFloat(hwSign(Gear^.dX)) - Gear^.dX, -4, hwSign(Gear^.dX)) then begin Gear^.X:= Gear^.X + Gear^.dX; Gear^.dX:= Gear^.dX * _0_87; Gear^.Y:= Gear^.Y - _4 end else |
|
459 |
if not TestCollisionXwithXYShift(Gear, int2hwFloat(hwSign(Gear^.dX)) - Gear^.dX, -5, hwSign(Gear^.dX)) then begin Gear^.X:= Gear^.X + Gear^.dX; Gear^.dX:= Gear^.dX * _0_84; Gear^.Y:= Gear^.Y - _5 end else |
|
460 |
if hwAbs(Gear^.dX) > _0_02 then Gear^.dX:= -Gear^.Elasticity * Gear^.dX |
|
461 |
else begin |
|
462 |
Gear^.State:= Gear^.State and not gstMoving; |
|
463 |
SetLittle(Gear^.dX) |
|
464 |
end |
|
465 |
else begin |
|
466 |
Gear^.State:= Gear^.State and not gstMoving; |
|
467 |
SetLittle(Gear^.dX) |
|
468 |
end |
|
1518 | 469 |
else if (hwAbs(Gear^.dX) > cLittle) |
470 |
and ((Gear^.State and gstHHJumping) = 0) |
|
471 |
then Gear^.dX:= -Gear^.Elasticity * Gear^.dX |
|
472 |
else SetLittle(Gear^.dX); |
|
538 | 473 |
|
542 | 474 |
if (not isFalling) and |
538 | 475 |
(hwAbs(Gear^.dX) + hwAbs(Gear^.dY) < _0_03) then |
476 |
begin |
|
477 |
Gear^.State:= Gear^.State and not gstMoving; |
|
478 |
SetLittle(Gear^.dX); |
|
479 |
Gear^.dY:= _0 |
|
480 |
end else Gear^.State:= Gear^.State or gstMoving; |
|
481 |
||
482 |
if (Gear^.State and gstMoving) <> 0 then |
|
483 |
begin |
|
484 |
Gear^.State:= Gear^.State and not gstAnimation; |
|
485 |
Gear^.X:= Gear^.X + Gear^.dX; |
|
486 |
Gear^.Y:= Gear^.Y + Gear^.dY; |
|
487 |
if (not Gear^.dY.isNegative) and |
|
488 |
(not TestCollisionYKick(Gear, 1)) and |
|
489 |
TestCollisionYwithXYShift(Gear, 0, 1, 1) then |
|
490 |
begin |
|
491 |
CheckHHDamage(Gear); |
|
492 |
Gear^.dY:= _0; |
|
493 |
Gear^.Y:= Gear^.Y + _1 |
|
494 |
end; |
|
1658
208a3258afdf
Fix a bug with visible cursor when hedgehog is dead
unc0rr
parents:
1645
diff
changeset
|
495 |
CheckGearDrowning(Gear); |
208a3258afdf
Fix a bug with visible cursor when hedgehog is dead
unc0rr
parents:
1645
diff
changeset
|
496 |
if (Gear^.State and gstDrowning) <> 0 then isCursorVisible:= false |
538 | 497 |
end |
498 |
end; |
|
499 |
||
302 | 500 |
procedure doStepHedgehogDriven(Gear: PGear); |
501 |
var t: PGear; |
|
1519
7b6adbe5266a
More delay after jump, less delay after small fall for hedgehog
unc0rr
parents:
1518
diff
changeset
|
502 |
wasJumping: boolean; |
302 | 503 |
begin |
558
b2b840eeb10a
Fix bug when hedgehog moves not right after it is kicked
unc0rr
parents:
553
diff
changeset
|
504 |
if not isInMultiShoot then |
b2b840eeb10a
Fix bug when hedgehog moves not right after it is kicked
unc0rr
parents:
553
diff
changeset
|
505 |
AllInactive:= false |
b2b840eeb10a
Fix bug when hedgehog moves not right after it is kicked
unc0rr
parents:
553
diff
changeset
|
506 |
else |
b2b840eeb10a
Fix bug when hedgehog moves not right after it is kicked
unc0rr
parents:
553
diff
changeset
|
507 |
Gear^.Message:= 0; |
505
fcba7d7aea0d
Fix old bug with grenade(bomd, etc..) not colliding with attacking hedgehog
unc0rr
parents:
498
diff
changeset
|
508 |
|
1035 | 509 |
if (TurnTimeLeft = 0) or (Gear^.Damage > 0) then |
1645 | 510 |
begin |
511 |
TurnTimeLeft:= 0; |
|
512 |
isCursorVisible:= false; |
|
513 |
Gear^.State:= Gear^.State and not (gstHHDriven or gstAnimation); |
|
514 |
if Gear^.Damage > 0 then |
|
515 |
Gear^.State:= Gear^.State and not (gstHHJumping or gstHHHJump); |
|
516 |
exit |
|
517 |
end; |
|
1035 | 518 |
|
1033 | 519 |
if (Gear^.State and gstAnimation) <> 0 then |
520 |
begin |
|
521 |
Gear^.Message:= 0; |
|
522 |
inc(Gear^.Timer); |
|
523 |
if Gear^.Timer = 125 then |
|
524 |
begin |
|
525 |
Gear^.Timer:= 0; |
|
526 |
inc(Gear^.Pos); |
|
1034 | 527 |
if Gear^.Pos = Wavez[TWave(Gear^.Tag)].FramesCount then |
1033 | 528 |
Gear^.State:= Gear^.State and not gstAnimation |
529 |
end; |
|
530 |
exit |
|
531 |
end; |
|
532 |
||
836 | 533 |
if ((Gear^.State and gstMoving) <> 0) |
534 |
or (StepTicks = cHHStepTicks) |
|
835
6f567934cc44
Automatically use parachute when vertical speed is high enough
unc0rr
parents:
829
diff
changeset
|
535 |
or (CurAmmoGear <> nil) then // we're moving |
836 | 536 |
begin |
839 | 537 |
with PHedgehog(Gear^.Hedgehog)^ do |
538 |
if (CurAmmoGear = nil) |
|
539 |
and (Gear^.dY > _0_39) |
|
540 |
and (Ammo^[CurSlot, CurAmmo].AmmoType = amParachute) then Gear^.Message:= Gear^.Message or gm_Attack; |
|
836 | 541 |
// check for case with ammo |
542 |
t:= CheckGearNear(Gear, gtCase, 36, 36); |
|
543 |
if t <> nil then |
|
544 |
PickUp(Gear, t) |
|
855
8842c71d16bf
- Fix too long delay between shotgun and deagle shots
unc0rr
parents:
854
diff
changeset
|
545 |
end; |
302 | 546 |
|
930 | 547 |
if (CurAmmoGear = nil) then |
548 |
if (((Gear^.Message and gm_Attack) <> 0) |
|
549 |
or ((Gear^.State and gstAttacking) <> 0)) then |
|
550 |
Attack(Gear) // should be before others to avoid desync with '/put' msg and changing weapon msgs |
|
551 |
else |
|
552 |
else with PHedgehog(Gear^.Hedgehog)^ do |
|
1519
7b6adbe5266a
More delay after jump, less delay after small fall for hedgehog
unc0rr
parents:
1518
diff
changeset
|
553 |
if ((CurAmmoGear^.Ammo^.Propz and ammoprop_AltAttack) <> 0) |
930 | 554 |
and ((Gear^.Message and gm_LJump) <> 0) |
931 | 555 |
and (((Ammo^[CurSlot, CurAmmo].Propz) and ammoprop_AltUse) <> 0) then |
556 |
begin |
|
557 |
Gear^.Message:= Gear^.Message and not gm_LJump; |
|
558 |
Attack(Gear) |
|
559 |
end; |
|
930 | 560 |
|
561 |
if (CurAmmoGear = nil) |
|
562 |
or ((CurAmmoGear^.Ammo^.Propz and ammoprop_AltAttack) <> 0) then |
|
563 |
begin |
|
1710
cecb3cc93251
Fix angle restriction applying to rc plane when choosing via ammomenu
unc0rr
parents:
1689
diff
changeset
|
564 |
if ((Gear^.Message and gm_Slot) <> 0) then |
cecb3cc93251
Fix angle restriction applying to rc plane when choosing via ammomenu
unc0rr
parents:
1689
diff
changeset
|
565 |
begin |
cecb3cc93251
Fix angle restriction applying to rc plane when choosing via ammomenu
unc0rr
parents:
1689
diff
changeset
|
566 |
ChangeAmmo(Gear); |
cecb3cc93251
Fix angle restriction applying to rc plane when choosing via ammomenu
unc0rr
parents:
1689
diff
changeset
|
567 |
ApplyAmmoChanges(PHedgehog(Gear^.Hedgehog)^) |
cecb3cc93251
Fix angle restriction applying to rc plane when choosing via ammomenu
unc0rr
parents:
1689
diff
changeset
|
568 |
end; |
930 | 569 |
|
570 |
if ((Gear^.Message and gm_Weapon) <> 0) then HHSetWeapon(Gear); |
|
571 |
||
572 |
if ((Gear^.Message and gm_Timer) <> 0) then HHSetTimer(Gear); |
|
573 |
end; |
|
574 |
||
302 | 575 |
if CurAmmoGear <> nil then |
576 |
begin |
|
351 | 577 |
CurAmmoGear^.Message:= Gear^.Message; |
302 | 578 |
exit |
579 |
end; |
|
580 |
||
952 | 581 |
if not isInMultiShoot then |
582 |
HedgehogChAngle(Gear); |
|
926
d231e007452a
Timer as hedgehog message (avoid possible desync in very rare cases)
unc0rr
parents:
925
diff
changeset
|
583 |
|
542 | 584 |
if (Gear^.State and gstMoving) <> 0 then |
1519
7b6adbe5266a
More delay after jump, less delay after small fall for hedgehog
unc0rr
parents:
1518
diff
changeset
|
585 |
begin |
7b6adbe5266a
More delay after jump, less delay after small fall for hedgehog
unc0rr
parents:
1518
diff
changeset
|
586 |
wasJumping:= ((Gear^.State and gstHHJumping) <> 0); |
7b6adbe5266a
More delay after jump, less delay after small fall for hedgehog
unc0rr
parents:
1518
diff
changeset
|
587 |
|
7b6adbe5266a
More delay after jump, less delay after small fall for hedgehog
unc0rr
parents:
1518
diff
changeset
|
588 |
if ((Gear^.Message and gm_HJump) <> 0) and |
7b6adbe5266a
More delay after jump, less delay after small fall for hedgehog
unc0rr
parents:
1518
diff
changeset
|
589 |
wasJumping and |
7b6adbe5266a
More delay after jump, less delay after small fall for hedgehog
unc0rr
parents:
1518
diff
changeset
|
590 |
((Gear^.State and gstHHHJump) = 0) then |
7b6adbe5266a
More delay after jump, less delay after small fall for hedgehog
unc0rr
parents:
1518
diff
changeset
|
591 |
if (not (hwAbs(Gear^.dX) > cLittle)) and (Gear^.dY < -_0_02) then |
7b6adbe5266a
More delay after jump, less delay after small fall for hedgehog
unc0rr
parents:
1518
diff
changeset
|
592 |
begin |
7b6adbe5266a
More delay after jump, less delay after small fall for hedgehog
unc0rr
parents:
1518
diff
changeset
|
593 |
Gear^.State:= Gear^.State or gstHHHJump or gstMoving; |
7b6adbe5266a
More delay after jump, less delay after small fall for hedgehog
unc0rr
parents:
1518
diff
changeset
|
594 |
Gear^.dY:= -_0_25; |
7b6adbe5266a
More delay after jump, less delay after small fall for hedgehog
unc0rr
parents:
1518
diff
changeset
|
595 |
Gear^.dX:= -SignAs(_0_02, Gear^.dX); |
1669 | 596 |
PlaySound(sndJump2, false, PHedgehog(Gear^.Hedgehog)^.Team^.voicepack) |
1519
7b6adbe5266a
More delay after jump, less delay after small fall for hedgehog
unc0rr
parents:
1518
diff
changeset
|
597 |
end; |
7b6adbe5266a
More delay after jump, less delay after small fall for hedgehog
unc0rr
parents:
1518
diff
changeset
|
598 |
|
7b6adbe5266a
More delay after jump, less delay after small fall for hedgehog
unc0rr
parents:
1518
diff
changeset
|
599 |
Gear^.Message:= Gear^.Message and not (gm_LJump or gm_HJump); |
538 | 600 |
|
1519
7b6adbe5266a
More delay after jump, less delay after small fall for hedgehog
unc0rr
parents:
1518
diff
changeset
|
601 |
if wasJumping and |
7b6adbe5266a
More delay after jump, less delay after small fall for hedgehog
unc0rr
parents:
1518
diff
changeset
|
602 |
TestCollisionXwithGear(Gear, hwSign(Gear^.dX)) then SetLittle(Gear^.dX); |
538 | 603 |
|
1519
7b6adbe5266a
More delay after jump, less delay after small fall for hedgehog
unc0rr
parents:
1518
diff
changeset
|
604 |
doStepHedgehogMoving(Gear); |
542 | 605 |
|
1519
7b6adbe5266a
More delay after jump, less delay after small fall for hedgehog
unc0rr
parents:
1518
diff
changeset
|
606 |
if ((Gear^.State and (gstMoving or gstDrowning)) = 0) then |
7b6adbe5266a
More delay after jump, less delay after small fall for hedgehog
unc0rr
parents:
1518
diff
changeset
|
607 |
begin |
7b6adbe5266a
More delay after jump, less delay after small fall for hedgehog
unc0rr
parents:
1518
diff
changeset
|
608 |
AddGearCI(Gear); |
7b6adbe5266a
More delay after jump, less delay after small fall for hedgehog
unc0rr
parents:
1518
diff
changeset
|
609 |
if wasJumping then |
7b6adbe5266a
More delay after jump, less delay after small fall for hedgehog
unc0rr
parents:
1518
diff
changeset
|
610 |
StepTicks:= 410 |
7b6adbe5266a
More delay after jump, less delay after small fall for hedgehog
unc0rr
parents:
1518
diff
changeset
|
611 |
else |
7b6adbe5266a
More delay after jump, less delay after small fall for hedgehog
unc0rr
parents:
1518
diff
changeset
|
612 |
StepTicks:= 95 |
7b6adbe5266a
More delay after jump, less delay after small fall for hedgehog
unc0rr
parents:
1518
diff
changeset
|
613 |
end; |
7b6adbe5266a
More delay after jump, less delay after small fall for hedgehog
unc0rr
parents:
1518
diff
changeset
|
614 |
exit |
7b6adbe5266a
More delay after jump, less delay after small fall for hedgehog
unc0rr
parents:
1518
diff
changeset
|
615 |
end; |
302 | 616 |
|
1033 | 617 |
if not isInMultiShoot then |
618 |
begin |
|
619 |
if StepTicks > 0 then dec(StepTicks); |
|
620 |
if (StepTicks = 0) then HedgehogStep(Gear) |
|
621 |
end |
|
302 | 622 |
end; |
623 |
||
4 | 624 |
//////////////////////////////////////////////////////////////////////////////// |
625 |
procedure doStepHedgehogFree(Gear: PGear); |
|
511 | 626 |
var prevState: Longword; |
4 | 627 |
begin |
511 | 628 |
prevState:= Gear^.State; |
4 | 629 |
|
538 | 630 |
doStepHedgehogMoving(Gear); |
4 | 631 |
|
1002 | 632 |
if (Gear^.State and (gstMoving or gstDrowning)) <> 0 then |
865 | 633 |
begin |
1012 | 634 |
if Gear^.Damage > 0 then CalcRotationDirAngle(Gear); |
865 | 635 |
AllInactive:= false; |
636 |
exit |
|
637 |
end; |
|
4 | 638 |
|
863 | 639 |
if (Gear^.Health = 0) then |
640 |
begin |
|
868 | 641 |
if PrvInactive then |
864 | 642 |
begin |
643 |
Gear^.Timer:= 0; |
|
868 | 644 |
Gear^.State:= Gear^.State or gstHHDeath; |
645 |
Gear^.doStep:= @doStepHedgehogDead; |
|
1347 | 646 |
FollowGear:= Gear; |
868 | 647 |
PrvInactive:= false; |
648 |
AllInactive:= false |
|
864 | 649 |
end; |
863 | 650 |
exit |
651 |
end; |
|
4 | 652 |
|
1033 | 653 |
if ((Gear^.State and gstWait) = 0) and |
863 | 654 |
(prevState <> Gear^.State) then |
655 |
begin |
|
1033 | 656 |
Gear^.State:= gstWait; |
863 | 657 |
Gear^.Timer:= 150 |
658 |
end else |
|
659 |
begin |
|
660 |
if Gear^.Timer = 0 then |
|
661 |
begin |
|
662 |
Gear^.State:= 0; |
|
663 |
Gear^.Active:= false; |
|
664 |
AddGearCI(Gear); |
|
665 |
exit |
|
666 |
end else dec(Gear^.Timer) |
|
667 |
end; |
|
668 |
||
669 |
AllInactive:= false |
|
4 | 670 |
end; |
671 |
||
672 |
//////////////////////////////////////////////////////////////////////////////// |
|
673 |
procedure doStepHedgehog(Gear: PGear); |
|
674 |
begin |
|
351 | 675 |
if (Gear^.Message and gm_Destroy) <> 0 then |
1505 | 676 |
begin |
677 |
DeleteGear(Gear); |
|
678 |
exit |
|
679 |
end; |
|
680 |
||
351 | 681 |
if (Gear^.State and gstHHDriven) = 0 then doStepHedgehogFree(Gear) |
511 | 682 |
else doStepHedgehogDriven(Gear) |
4 | 683 |
end; |