author | unc0rr |
Sat, 07 Mar 2009 17:42:54 +0000 | |
changeset 1865 | ebc6dfca60d4 |
parent 1861 | 98de5dc5fda7 |
child 1883 | 7c7476f56114 |
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); |
1849 | 182 |
amLowGravity: cGravity:= cMaxWindSpeed / 2; |
183 |
amExtraDamage: cDamageModifier:= _1_5; |
|
184 |
//this flag unfortunately gets cleared too often for true invulnerability, although it seemed like the natural choice |
|
185 |
//amInvulnerable: State:= State or gstNoDamage; |
|
186 |
amInvulnerable: Invulnerable:= true; |
|
187 |
amExtraTime: TurnTimeLeft:= TurnTimeLeft + 30000; |
|
1854 | 188 |
amLaserSight: cLaserSighting:= true; |
32
78bff13b11c0
With this patch the game doesn't crash when gaming by net
unc0rr
parents:
16
diff
changeset
|
189 |
end; |
829 | 190 |
|
191 |
uStats.AmmoUsed(Ammo^[CurSlot, CurAmmo].AmmoType); |
|
192 |
||
32
78bff13b11c0
With this patch the game doesn't crash when gaming by net
unc0rr
parents:
16
diff
changeset
|
193 |
Power:= 0; |
930 | 194 |
if (CurAmmoGear <> nil) |
195 |
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
|
196 |
begin |
930 | 197 |
CurAmmoGear^.Ammo:= @(Ammo^[CurSlot, CurAmmo]); |
82 | 198 |
Message:= Message or gm_Attack; |
351 | 199 |
CurAmmoGear^.Message:= Message |
82 | 200 |
end else begin |
351 | 201 |
if not CurrentTeam^.ExtDriven and |
202 |
((Ammo^[CurSlot, CurAmmo].Propz and ammoprop_Power) <> 0) then SendIPC('a'); |
|
1849 | 203 |
AfterAttack; |
82 | 204 |
end |
1849 | 205 |
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
|
206 |
end |
78bff13b11c0
With this patch the game doesn't crash when gaming by net
unc0rr
parents:
16
diff
changeset
|
207 |
end; |
78bff13b11c0
With this patch the game doesn't crash when gaming by net
unc0rr
parents:
16
diff
changeset
|
208 |
|
78bff13b11c0
With this patch the game doesn't crash when gaming by net
unc0rr
parents:
16
diff
changeset
|
209 |
procedure AfterAttack; |
78bff13b11c0
With this patch the game doesn't crash when gaming by net
unc0rr
parents:
16
diff
changeset
|
210 |
begin |
602 | 211 |
with CurrentHedgehog^.Gear^, |
1286 | 212 |
CurrentHedgehog^ do |
213 |
begin |
|
1849 | 214 |
State:= State and not gstAttacking; |
215 |
if ((Ammo^[CurSlot, CurAmmo].Propz) and ammoprop_Utility) = 0 then |
|
216 |
begin |
|
217 |
Inc(AttacksNum); |
|
218 |
if (Ammo^[CurSlot, CurAmmo].NumPerTurn >= AttacksNum) or |
|
219 |
((GameFlags and gfMultiWeapon) <> 0) then |
|
220 |
isInMultiShoot:= true |
|
221 |
else |
|
222 |
begin |
|
223 |
TurnTimeLeft:= Ammoz[Ammo^[CurSlot, CurAmmo].AmmoType].TimeAfterTurn; |
|
224 |
State:= State or gstAttacked; |
|
225 |
OnUsedAmmo(CurrentHedgehog^); |
|
226 |
end; |
|
227 |
end |
|
228 |
else |
|
229 |
begin |
|
230 |
OnUsedAmmo(CurrentHedgehog^); |
|
231 |
ApplyAmmoChanges(CurrentHedgehog^); |
|
232 |
end; |
|
1286 | 233 |
AttackBar:= 0; |
234 |
end |
|
32
78bff13b11c0
With this patch the game doesn't crash when gaming by net
unc0rr
parents:
16
diff
changeset
|
235 |
end; |
78bff13b11c0
With this patch the game doesn't crash when gaming by net
unc0rr
parents:
16
diff
changeset
|
236 |
|
42 | 237 |
//////////////////////////////////////////////////////////////////////////////// |
863 | 238 |
procedure doStepHedgehogDead(Gear: PGear); |
868 | 239 |
const frametime = 200; |
240 |
timertime = frametime * 6; |
|
863 | 241 |
begin |
242 |
if Gear^.Timer > 1 then |
|
243 |
begin |
|
244 |
AllInactive:= false; |
|
868 | 245 |
dec(Gear^.Timer); |
246 |
if (Gear^.Timer mod frametime) = 0 then inc(Gear^.Pos) |
|
863 | 247 |
end else |
248 |
if Gear^.Timer = 1 then |
|
249 |
begin |
|
250 |
Gear^.State:= Gear^.State or gstNoDamage; |
|
251 |
doMakeExplosion(hwRound(Gear^.X), hwRound(Gear^.Y), 30, EXPLAutoSound); |
|
252 |
AddGear(hwRound(Gear^.X), hwRound(Gear^.Y), gtGrave, 0, _0, _0, 0)^.Hedgehog:= Gear^.Hedgehog; |
|
253 |
DeleteGear(Gear); |
|
254 |
SetAllToActive |
|
255 |
end else // Gear^.Timer = 0 |
|
256 |
begin |
|
257 |
AllInactive:= false; |
|
868 | 258 |
Gear^.Z:= cCurrHHZ; |
259 |
RemoveGearFromList(Gear); |
|
260 |
InsertGearToList(Gear); |
|
1669 | 261 |
PlaySound(sndByeBye, false, PHedgehog(Gear^.Hedgehog)^.Team^.voicepack); |
868 | 262 |
Gear^.Pos:= 0; |
263 |
Gear^.Timer:= timertime |
|
863 | 264 |
end |
265 |
end; |
|
266 |
||
267 |
//////////////////////////////////////////////////////////////////////////////// |
|
42 | 268 |
procedure PickUp(HH, Gear: PGear); |
295 | 269 |
var s: shortstring; |
270 |
a: TAmmoType; |
|
42 | 271 |
begin |
351 | 272 |
Gear^.Message:= gm_Destroy; |
273 |
case Gear^.Pos of |
|
1861 | 274 |
posCaseUtility, |
295 | 275 |
posCaseAmmo: begin |
351 | 276 |
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
|
277 |
AddAmmo(PHedgehog(HH^.Hedgehog)^, a); |
1072 | 278 |
if (not (PHedgehog(HH^.Hedgehog)^.Team^.ExtDriven |
279 |
or (PHedgehog(HH^.Hedgehog)^.BotLevel > 0))) |
|
280 |
or (GameType = gmtDemo) then |
|
836 | 281 |
begin |
282 |
s:= trammo[Ammoz[a].NameId] + '(+' + IntToStr(Ammoz[a].NumberInCase) + ')'; |
|
283 |
AddCaption(s, PHedgehog(HH^.Hedgehog)^.Team^.Clan^.Color, capgrpAmmoinfo); |
|
284 |
end |
|
295 | 285 |
end; |
42 | 286 |
posCaseHealth: begin |
351 | 287 |
inc(HH^.Health, Gear^.Health); |
288 |
str(Gear^.Health, s); |
|
295 | 289 |
s:= '+' + s; |
549 | 290 |
AddCaption(s, PHedgehog(HH^.Hedgehog)^.Team^.Clan^.Color, capgrpAmmoinfo); |
351 | 291 |
RenderHealth(PHedgehog(HH^.Hedgehog)^); |
292 |
RecountTeamHealth(PHedgehog(HH^.Hedgehog)^.Team) |
|
42 | 293 |
end; |
435 | 294 |
end |
42 | 295 |
end; |
32
78bff13b11c0
With this patch the game doesn't crash when gaming by net
unc0rr
parents:
16
diff
changeset
|
296 |
|
4 | 297 |
const StepTicks: LongWord = 0; |
298 |
||
302 | 299 |
procedure HedgehogStep(Gear: PGear); |
371 | 300 |
var PrevdX: LongInt; |
302 | 301 |
begin |
542 | 302 |
if ((Gear^.State and (gstAttacking or gstMoving)) = 0) then |
4 | 303 |
begin |
408 | 304 |
if isCursorVisible then |
305 |
with PHedgehog(Gear^.Hedgehog)^ do |
|
306 |
with Ammo^[CurSlot, CurAmmo] do |
|
307 |
begin |
|
542 | 308 |
if (Gear^.Message and gm_Left ) <> 0 then |
408 | 309 |
Pos:= (Pos + Ammoz[AmmoType].PosCount - 1) mod Ammoz[AmmoType].PosCount |
310 |
else |
|
542 | 311 |
if (Gear^.Message and gm_Right ) <> 0 then |
408 | 312 |
Pos:= (Pos + 1) mod Ammoz[AmmoType].PosCount |
313 |
else exit; |
|
423 | 314 |
StepTicks:= 200; |
408 | 315 |
exit |
316 |
end; |
|
505
fcba7d7aea0d
Fix old bug with grenade(bomd, etc..) not colliding with attacking hedgehog
unc0rr
parents:
498
diff
changeset
|
317 |
|
1033 | 318 |
if ((Gear^.Message and gm_Animate) <> 0) then |
319 |
begin |
|
320 |
Gear^.Message:= 0; |
|
321 |
Gear^.State:= Gear^.State or gstAnimation; |
|
322 |
Gear^.Tag:= Gear^.MsgParam; |
|
323 |
Gear^.Timer:= 0; |
|
324 |
Gear^.Pos:= 0 |
|
325 |
end; |
|
326 |
||
351 | 327 |
if ((Gear^.Message and gm_LJump ) <> 0) then |
4 | 328 |
begin |
542 | 329 |
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
|
330 |
DeleteCI(Gear); |
68 | 331 |
if not TestCollisionYwithGear(Gear, -1) then |
498 | 332 |
if not TestCollisionXwithXYShift(Gear, _0, -2, hwSign(Gear^.dX)) then Gear^.Y:= Gear^.Y - _2 else |
333 |
if not TestCollisionXwithXYShift(Gear, _0, -1, hwSign(Gear^.dX)) then Gear^.Y:= Gear^.Y - _1; |
|
351 | 334 |
if not (TestCollisionXwithGear(Gear, hwSign(Gear^.dX)) |
68 | 335 |
or TestCollisionYwithGear(Gear, -1)) then |
4 | 336 |
begin |
351 | 337 |
Gear^.dY:= -_0_15; |
498 | 338 |
Gear^.dX:= SignAs(_0_15, Gear^.dX); |
542 | 339 |
Gear^.State:= Gear^.State or gstMoving or gstHHJumping; |
1669 | 340 |
PlaySound(sndJump1, false, PHedgehog(Gear^.Hedgehog)^.Team^.voicepack); |
4 | 341 |
exit |
342 |
end; |
|
343 |
end; |
|
505
fcba7d7aea0d
Fix old bug with grenade(bomd, etc..) not colliding with attacking hedgehog
unc0rr
parents:
498
diff
changeset
|
344 |
|
351 | 345 |
if ((Gear^.Message and gm_HJump ) <> 0) then |
4 | 346 |
begin |
505
fcba7d7aea0d
Fix old bug with grenade(bomd, etc..) not colliding with attacking hedgehog
unc0rr
parents:
498
diff
changeset
|
347 |
DeleteCI(Gear); |
542 | 348 |
Gear^.Message:= Gear^.Message and not gm_HJump; |
855
8842c71d16bf
- Fix too long delay between shotgun and deagle shots
unc0rr
parents:
854
diff
changeset
|
349 |
|
8842c71d16bf
- Fix too long delay between shotgun and deagle shots
unc0rr
parents:
854
diff
changeset
|
350 |
Gear^.dY:= -_0_2; |
8842c71d16bf
- Fix too long delay between shotgun and deagle shots
unc0rr
parents:
854
diff
changeset
|
351 |
SetLittle(Gear^.dX); |
8842c71d16bf
- Fix too long delay between shotgun and deagle shots
unc0rr
parents:
854
diff
changeset
|
352 |
Gear^.State:= Gear^.State or gstMoving or gstHHJumping; |
1669 | 353 |
PlaySound(sndJump3, false, PHedgehog(Gear^.Hedgehog)^.Team^.voicepack); |
855
8842c71d16bf
- Fix too long delay between shotgun and deagle shots
unc0rr
parents:
854
diff
changeset
|
354 |
exit |
4 | 355 |
end; |
505
fcba7d7aea0d
Fix old bug with grenade(bomd, etc..) not colliding with attacking hedgehog
unc0rr
parents:
498
diff
changeset
|
356 |
|
351 | 357 |
PrevdX:= hwSign(Gear^.dX); |
358 |
if (Gear^.Message and gm_Left )<>0 then Gear^.dX:= -cLittle else |
|
359 |
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
|
360 |
|
74 | 361 |
StepTicks:= cHHStepTicks; |
610 | 362 |
if PrevdX <> hwSign(Gear^.dX) then |
363 |
begin |
|
364 |
FollowGear:= Gear; |
|
365 |
exit |
|
366 |
end; |
|
367 |
DeleteCI(Gear); // must be after exit!! (see previous line) |
|
838 | 368 |
|
351 | 369 |
PHedgehog(Gear^.Hedgehog)^.visStepPos:= (PHedgehog(Gear^.Hedgehog)^.visStepPos + 1) and 7; |
370 |
if TestCollisionXwithGear(Gear, hwSign(Gear^.dX)) then |
|
4 | 371 |
begin |
498 | 372 |
if not (TestCollisionXwithXYShift(Gear, _0, -6, hwSign(Gear^.dX)) |
373 |
or TestCollisionYwithGear(Gear, -1)) then Gear^.Y:= Gear^.Y - _1; |
|
374 |
if not (TestCollisionXwithXYShift(Gear, _0, -5, hwSign(Gear^.dX)) |
|
375 |
or TestCollisionYwithGear(Gear, -1)) then Gear^.Y:= Gear^.Y - _1; |
|
376 |
if not (TestCollisionXwithXYShift(Gear, _0, -4, hwSign(Gear^.dX)) |
|
377 |
or TestCollisionYwithGear(Gear, -1)) then Gear^.Y:= Gear^.Y - _1; |
|
378 |
if not (TestCollisionXwithXYShift(Gear, _0, -3, hwSign(Gear^.dX)) |
|
379 |
or TestCollisionYwithGear(Gear, -1)) then Gear^.Y:= Gear^.Y - _1; |
|
380 |
if not (TestCollisionXwithXYShift(Gear, _0, -2, hwSign(Gear^.dX)) |
|
381 |
or TestCollisionYwithGear(Gear, -1)) then Gear^.Y:= Gear^.Y - _1; |
|
382 |
if not (TestCollisionXwithXYShift(Gear, _0, -1, hwSign(Gear^.dX)) |
|
383 |
or TestCollisionYwithGear(Gear, -1)) then Gear^.Y:= Gear^.Y - _1; |
|
4 | 384 |
end; |
1528 | 385 |
|
498 | 386 |
if not TestCollisionXwithGear(Gear, hwSign(Gear^.dX)) then Gear^.X:= Gear^.X + SignAs(_1, Gear^.dX); |
62 | 387 |
SetAllHHToActive; |
37 | 388 |
|
68 | 389 |
if not TestCollisionYwithGear(Gear, 1) then |
4 | 390 |
begin |
498 | 391 |
Gear^.Y:= Gear^.Y + _1; |
68 | 392 |
if not TestCollisionYwithGear(Gear, 1) then |
4 | 393 |
begin |
498 | 394 |
Gear^.Y:= Gear^.Y + _1; |
68 | 395 |
if not TestCollisionYwithGear(Gear, 1) then |
4 | 396 |
begin |
498 | 397 |
Gear^.Y:= Gear^.Y + _1; |
68 | 398 |
if not TestCollisionYwithGear(Gear, 1) then |
4 | 399 |
begin |
498 | 400 |
Gear^.Y:= Gear^.Y + _1; |
68 | 401 |
if not TestCollisionYwithGear(Gear, 1) then |
4 | 402 |
begin |
498 | 403 |
Gear^.Y:= Gear^.Y + _1; |
68 | 404 |
if not TestCollisionYwithGear(Gear, 1) then |
4 | 405 |
begin |
498 | 406 |
Gear^.Y:= Gear^.Y + _1; |
68 | 407 |
if not TestCollisionYwithGear(Gear, 1) then |
4 | 408 |
begin |
498 | 409 |
Gear^.Y:= Gear^.Y - _6; |
410 |
Gear^.dY:= _0; |
|
542 | 411 |
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
|
412 |
exit |
4 | 413 |
end; |
414 |
end |
|
415 |
end |
|
416 |
end |
|
417 |
end |
|
418 |
end |
|
505
fcba7d7aea0d
Fix old bug with grenade(bomd, etc..) not colliding with attacking hedgehog
unc0rr
parents:
498
diff
changeset
|
419 |
end; |
fcba7d7aea0d
Fix old bug with grenade(bomd, etc..) not colliding with attacking hedgehog
unc0rr
parents:
498
diff
changeset
|
420 |
AddGearCI(Gear) |
4 | 421 |
end |
422 |
end; |
|
423 |
||
303
1659c4aad5ab
Now blow torch angle can be changed during blowing :)
unc0rr
parents:
302
diff
changeset
|
424 |
procedure HedgehogChAngle(Gear: PGear); |
958 | 425 |
var da: LongWord; |
303
1659c4aad5ab
Now blow torch angle can be changed during blowing :)
unc0rr
parents:
302
diff
changeset
|
426 |
begin |
958 | 427 |
with PHedgehog(Gear^.Hedgehog)^ do |
428 |
if (Ammo^[CurSlot, CurAmmo].AmmoType = amRope) |
|
429 |
and ((Gear^.State and (gstMoving or gstHHJumping)) = gstMoving) then da:= 2 else da:= 1; |
|
430 |
||
1639 | 431 |
if (((Gear^.Message and gm_Precise) = 0) or ((GameTicks mod 5) = 1)) then |
432 |
if ((Gear^.Message and gm_Up) <> 0) and (Gear^.Angle - da >= CurMinAngle) then dec(Gear^.Angle, da) |
|
433 |
else |
|
1689 | 434 |
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
|
435 |
end; |
1659c4aad5ab
Now blow torch angle can be changed during blowing :)
unc0rr
parents:
302
diff
changeset
|
436 |
|
302 | 437 |
procedure doStepHedgehog(Gear: PGear); forward; |
438 |
//////////////////////////////////////////////////////////////////////////////// |
|
538 | 439 |
procedure doStepHedgehogMoving(Gear: PGear); |
545 | 440 |
var isFalling: boolean; |
538 | 441 |
begin |
855
8842c71d16bf
- Fix too long delay between shotgun and deagle shots
unc0rr
parents:
854
diff
changeset
|
442 |
isFalling:= (Gear^.dY.isNegative) or not TestCollisionYKick(Gear, 1); |
542 | 443 |
if isFalling then |
538 | 444 |
begin |
445 |
if (Gear^.dY.isNegative) and TestCollisionYKick(Gear, -1) then Gear^.dY:= _0; |
|
542 | 446 |
Gear^.State:= Gear^.State or gstMoving; |
538 | 447 |
Gear^.dY:= Gear^.dY + cGravity |
448 |
end else |
|
449 |
begin |
|
450 |
if ((hwAbs(Gear^.dX) + hwAbs(Gear^.dY)) < _0_55) |
|
451 |
and ((Gear^.State and gstHHJumping) <> 0) then SetLittle(Gear^.dX); |
|
452 |
||
540 | 453 |
if not Gear^.dY.isNegative then |
454 |
begin |
|
455 |
CheckHHDamage(Gear); |
|
790
a6f442173822
Make high jump behaviour like in worms (back somersault)
unc0rr
parents:
783
diff
changeset
|
456 |
|
a6f442173822
Make high jump behaviour like in worms (back somersault)
unc0rr
parents:
783
diff
changeset
|
457 |
if ((Gear^.State and gstHHHJump) <> 0) and |
a6f442173822
Make high jump behaviour like in worms (back somersault)
unc0rr
parents:
783
diff
changeset
|
458 |
(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
|
459 |
|
542 | 460 |
Gear^.State:= Gear^.State and not (gstHHJumping or gstHHHJump); |
540 | 461 |
Gear^.dY:= _0; |
462 |
end else Gear^.dY:= Gear^.dY + cGravity; |
|
538 | 463 |
|
464 |
if ((Gear^.State and gstMoving) <> 0) then Gear^.dX:= Gear^.dX * Gear^.Friction |
|
465 |
end; |
|
466 |
||
467 |
if (Gear^.State <> 0) then DeleteCI(Gear); |
|
783 | 468 |
|
538 | 469 |
if (Gear^.State and gstMoving) <> 0 then |
470 |
if TestCollisionXKick(Gear, hwSign(Gear^.dX)) then |
|
542 | 471 |
if not isFalling then |
538 | 472 |
if hwAbs(Gear^.dX) > _0_01 then |
473 |
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 |
|
474 |
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 |
|
475 |
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 |
|
476 |
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 |
|
477 |
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 |
|
478 |
if hwAbs(Gear^.dX) > _0_02 then Gear^.dX:= -Gear^.Elasticity * Gear^.dX |
|
479 |
else begin |
|
480 |
Gear^.State:= Gear^.State and not gstMoving; |
|
481 |
SetLittle(Gear^.dX) |
|
482 |
end |
|
483 |
else begin |
|
484 |
Gear^.State:= Gear^.State and not gstMoving; |
|
485 |
SetLittle(Gear^.dX) |
|
486 |
end |
|
1518 | 487 |
else if (hwAbs(Gear^.dX) > cLittle) |
488 |
and ((Gear^.State and gstHHJumping) = 0) |
|
489 |
then Gear^.dX:= -Gear^.Elasticity * Gear^.dX |
|
490 |
else SetLittle(Gear^.dX); |
|
538 | 491 |
|
542 | 492 |
if (not isFalling) and |
538 | 493 |
(hwAbs(Gear^.dX) + hwAbs(Gear^.dY) < _0_03) then |
494 |
begin |
|
1865
ebc6dfca60d4
- nemo's patch: some animations, zero probability for infinite weapons
unc0rr
parents:
1861
diff
changeset
|
495 |
Gear^.State:= Gear^.State and not gstWinner; |
538 | 496 |
Gear^.State:= Gear^.State and not gstMoving; |
497 |
SetLittle(Gear^.dX); |
|
498 |
Gear^.dY:= _0 |
|
499 |
end else Gear^.State:= Gear^.State or gstMoving; |
|
500 |
||
501 |
if (Gear^.State and gstMoving) <> 0 then |
|
502 |
begin |
|
503 |
Gear^.State:= Gear^.State and not gstAnimation; |
|
504 |
Gear^.X:= Gear^.X + Gear^.dX; |
|
505 |
Gear^.Y:= Gear^.Y + Gear^.dY; |
|
506 |
if (not Gear^.dY.isNegative) and |
|
507 |
(not TestCollisionYKick(Gear, 1)) and |
|
508 |
TestCollisionYwithXYShift(Gear, 0, 1, 1) then |
|
509 |
begin |
|
510 |
CheckHHDamage(Gear); |
|
511 |
Gear^.dY:= _0; |
|
512 |
Gear^.Y:= Gear^.Y + _1 |
|
513 |
end; |
|
1658
208a3258afdf
Fix a bug with visible cursor when hedgehog is dead
unc0rr
parents:
1645
diff
changeset
|
514 |
CheckGearDrowning(Gear); |
208a3258afdf
Fix a bug with visible cursor when hedgehog is dead
unc0rr
parents:
1645
diff
changeset
|
515 |
if (Gear^.State and gstDrowning) <> 0 then isCursorVisible:= false |
538 | 516 |
end |
517 |
end; |
|
518 |
||
302 | 519 |
procedure doStepHedgehogDriven(Gear: PGear); |
520 |
var t: PGear; |
|
1519
7b6adbe5266a
More delay after jump, less delay after small fall for hedgehog
unc0rr
parents:
1518
diff
changeset
|
521 |
wasJumping: boolean; |
302 | 522 |
begin |
558
b2b840eeb10a
Fix bug when hedgehog moves not right after it is kicked
unc0rr
parents:
553
diff
changeset
|
523 |
if not isInMultiShoot then |
b2b840eeb10a
Fix bug when hedgehog moves not right after it is kicked
unc0rr
parents:
553
diff
changeset
|
524 |
AllInactive:= false |
b2b840eeb10a
Fix bug when hedgehog moves not right after it is kicked
unc0rr
parents:
553
diff
changeset
|
525 |
else |
b2b840eeb10a
Fix bug when hedgehog moves not right after it is kicked
unc0rr
parents:
553
diff
changeset
|
526 |
Gear^.Message:= 0; |
505
fcba7d7aea0d
Fix old bug with grenade(bomd, etc..) not colliding with attacking hedgehog
unc0rr
parents:
498
diff
changeset
|
527 |
|
1035 | 528 |
if (TurnTimeLeft = 0) or (Gear^.Damage > 0) then |
1645 | 529 |
begin |
530 |
TurnTimeLeft:= 0; |
|
531 |
isCursorVisible:= false; |
|
1749
7170f626e9d6
Fix crash when attackbar wasn't deleted, but hedgehog gear was
unc0rr
parents:
1712
diff
changeset
|
532 |
Gear^.State:= Gear^.State and not (gstHHDriven or gstAnimation or gstAttacking); |
7170f626e9d6
Fix crash when attackbar wasn't deleted, but hedgehog gear was
unc0rr
parents:
1712
diff
changeset
|
533 |
AttackBar:= 0; |
1645 | 534 |
if Gear^.Damage > 0 then |
535 |
Gear^.State:= Gear^.State and not (gstHHJumping or gstHHHJump); |
|
536 |
exit |
|
537 |
end; |
|
1035 | 538 |
|
1033 | 539 |
if (Gear^.State and gstAnimation) <> 0 then |
540 |
begin |
|
541 |
Gear^.Message:= 0; |
|
542 |
inc(Gear^.Timer); |
|
543 |
if Gear^.Timer = 125 then |
|
544 |
begin |
|
545 |
Gear^.Timer:= 0; |
|
546 |
inc(Gear^.Pos); |
|
1034 | 547 |
if Gear^.Pos = Wavez[TWave(Gear^.Tag)].FramesCount then |
1033 | 548 |
Gear^.State:= Gear^.State and not gstAnimation |
549 |
end; |
|
550 |
exit |
|
551 |
end; |
|
552 |
||
836 | 553 |
if ((Gear^.State and gstMoving) <> 0) |
554 |
or (StepTicks = cHHStepTicks) |
|
835
6f567934cc44
Automatically use parachute when vertical speed is high enough
unc0rr
parents:
829
diff
changeset
|
555 |
or (CurAmmoGear <> nil) then // we're moving |
836 | 556 |
begin |
839 | 557 |
with PHedgehog(Gear^.Hedgehog)^ do |
558 |
if (CurAmmoGear = nil) |
|
559 |
and (Gear^.dY > _0_39) |
|
560 |
and (Ammo^[CurSlot, CurAmmo].AmmoType = amParachute) then Gear^.Message:= Gear^.Message or gm_Attack; |
|
836 | 561 |
// check for case with ammo |
562 |
t:= CheckGearNear(Gear, gtCase, 36, 36); |
|
563 |
if t <> nil then |
|
564 |
PickUp(Gear, t) |
|
855
8842c71d16bf
- Fix too long delay between shotgun and deagle shots
unc0rr
parents:
854
diff
changeset
|
565 |
end; |
302 | 566 |
|
930 | 567 |
if (CurAmmoGear = nil) then |
568 |
if (((Gear^.Message and gm_Attack) <> 0) |
|
569 |
or ((Gear^.State and gstAttacking) <> 0)) then |
|
570 |
Attack(Gear) // should be before others to avoid desync with '/put' msg and changing weapon msgs |
|
571 |
else |
|
572 |
else with PHedgehog(Gear^.Hedgehog)^ do |
|
1519
7b6adbe5266a
More delay after jump, less delay after small fall for hedgehog
unc0rr
parents:
1518
diff
changeset
|
573 |
if ((CurAmmoGear^.Ammo^.Propz and ammoprop_AltAttack) <> 0) |
930 | 574 |
and ((Gear^.Message and gm_LJump) <> 0) |
931 | 575 |
and (((Ammo^[CurSlot, CurAmmo].Propz) and ammoprop_AltUse) <> 0) then |
576 |
begin |
|
577 |
Gear^.Message:= Gear^.Message and not gm_LJump; |
|
578 |
Attack(Gear) |
|
579 |
end; |
|
930 | 580 |
|
581 |
if (CurAmmoGear = nil) |
|
582 |
or ((CurAmmoGear^.Ammo^.Propz and ammoprop_AltAttack) <> 0) then |
|
583 |
begin |
|
1710
cecb3cc93251
Fix angle restriction applying to rc plane when choosing via ammomenu
unc0rr
parents:
1689
diff
changeset
|
584 |
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
|
585 |
begin |
cecb3cc93251
Fix angle restriction applying to rc plane when choosing via ammomenu
unc0rr
parents:
1689
diff
changeset
|
586 |
ChangeAmmo(Gear); |
cecb3cc93251
Fix angle restriction applying to rc plane when choosing via ammomenu
unc0rr
parents:
1689
diff
changeset
|
587 |
ApplyAmmoChanges(PHedgehog(Gear^.Hedgehog)^) |
cecb3cc93251
Fix angle restriction applying to rc plane when choosing via ammomenu
unc0rr
parents:
1689
diff
changeset
|
588 |
end; |
930 | 589 |
|
590 |
if ((Gear^.Message and gm_Weapon) <> 0) then HHSetWeapon(Gear); |
|
591 |
||
592 |
if ((Gear^.Message and gm_Timer) <> 0) then HHSetTimer(Gear); |
|
593 |
end; |
|
594 |
||
302 | 595 |
if CurAmmoGear <> nil then |
596 |
begin |
|
351 | 597 |
CurAmmoGear^.Message:= Gear^.Message; |
302 | 598 |
exit |
599 |
end; |
|
600 |
||
952 | 601 |
if not isInMultiShoot then |
602 |
HedgehogChAngle(Gear); |
|
926
d231e007452a
Timer as hedgehog message (avoid possible desync in very rare cases)
unc0rr
parents:
925
diff
changeset
|
603 |
|
542 | 604 |
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
|
605 |
begin |
7b6adbe5266a
More delay after jump, less delay after small fall for hedgehog
unc0rr
parents:
1518
diff
changeset
|
606 |
wasJumping:= ((Gear^.State and gstHHJumping) <> 0); |
7b6adbe5266a
More delay after jump, less delay after small fall for hedgehog
unc0rr
parents:
1518
diff
changeset
|
607 |
|
7b6adbe5266a
More delay after jump, less delay after small fall for hedgehog
unc0rr
parents:
1518
diff
changeset
|
608 |
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
|
609 |
wasJumping and |
7b6adbe5266a
More delay after jump, less delay after small fall for hedgehog
unc0rr
parents:
1518
diff
changeset
|
610 |
((Gear^.State and gstHHHJump) = 0) then |
7b6adbe5266a
More delay after jump, less delay after small fall for hedgehog
unc0rr
parents:
1518
diff
changeset
|
611 |
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
|
612 |
begin |
7b6adbe5266a
More delay after jump, less delay after small fall for hedgehog
unc0rr
parents:
1518
diff
changeset
|
613 |
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
|
614 |
Gear^.dY:= -_0_25; |
7b6adbe5266a
More delay after jump, less delay after small fall for hedgehog
unc0rr
parents:
1518
diff
changeset
|
615 |
Gear^.dX:= -SignAs(_0_02, Gear^.dX); |
1669 | 616 |
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
|
617 |
end; |
7b6adbe5266a
More delay after jump, less delay after small fall for hedgehog
unc0rr
parents:
1518
diff
changeset
|
618 |
|
7b6adbe5266a
More delay after jump, less delay after small fall for hedgehog
unc0rr
parents:
1518
diff
changeset
|
619 |
Gear^.Message:= Gear^.Message and not (gm_LJump or gm_HJump); |
538 | 620 |
|
1519
7b6adbe5266a
More delay after jump, less delay after small fall for hedgehog
unc0rr
parents:
1518
diff
changeset
|
621 |
if wasJumping and |
7b6adbe5266a
More delay after jump, less delay after small fall for hedgehog
unc0rr
parents:
1518
diff
changeset
|
622 |
TestCollisionXwithGear(Gear, hwSign(Gear^.dX)) then SetLittle(Gear^.dX); |
538 | 623 |
|
1519
7b6adbe5266a
More delay after jump, less delay after small fall for hedgehog
unc0rr
parents:
1518
diff
changeset
|
624 |
doStepHedgehogMoving(Gear); |
542 | 625 |
|
1519
7b6adbe5266a
More delay after jump, less delay after small fall for hedgehog
unc0rr
parents:
1518
diff
changeset
|
626 |
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
|
627 |
begin |
7b6adbe5266a
More delay after jump, less delay after small fall for hedgehog
unc0rr
parents:
1518
diff
changeset
|
628 |
AddGearCI(Gear); |
7b6adbe5266a
More delay after jump, less delay after small fall for hedgehog
unc0rr
parents:
1518
diff
changeset
|
629 |
if wasJumping then |
7b6adbe5266a
More delay after jump, less delay after small fall for hedgehog
unc0rr
parents:
1518
diff
changeset
|
630 |
StepTicks:= 410 |
7b6adbe5266a
More delay after jump, less delay after small fall for hedgehog
unc0rr
parents:
1518
diff
changeset
|
631 |
else |
7b6adbe5266a
More delay after jump, less delay after small fall for hedgehog
unc0rr
parents:
1518
diff
changeset
|
632 |
StepTicks:= 95 |
7b6adbe5266a
More delay after jump, less delay after small fall for hedgehog
unc0rr
parents:
1518
diff
changeset
|
633 |
end; |
7b6adbe5266a
More delay after jump, less delay after small fall for hedgehog
unc0rr
parents:
1518
diff
changeset
|
634 |
exit |
7b6adbe5266a
More delay after jump, less delay after small fall for hedgehog
unc0rr
parents:
1518
diff
changeset
|
635 |
end; |
302 | 636 |
|
1033 | 637 |
if not isInMultiShoot then |
638 |
begin |
|
639 |
if StepTicks > 0 then dec(StepTicks); |
|
640 |
if (StepTicks = 0) then HedgehogStep(Gear) |
|
641 |
end |
|
302 | 642 |
end; |
643 |
||
4 | 644 |
//////////////////////////////////////////////////////////////////////////////// |
645 |
procedure doStepHedgehogFree(Gear: PGear); |
|
511 | 646 |
var prevState: Longword; |
4 | 647 |
begin |
511 | 648 |
prevState:= Gear^.State; |
4 | 649 |
|
538 | 650 |
doStepHedgehogMoving(Gear); |
4 | 651 |
|
1002 | 652 |
if (Gear^.State and (gstMoving or gstDrowning)) <> 0 then |
865 | 653 |
begin |
1012 | 654 |
if Gear^.Damage > 0 then CalcRotationDirAngle(Gear); |
865 | 655 |
AllInactive:= false; |
656 |
exit |
|
657 |
end; |
|
4 | 658 |
|
863 | 659 |
if (Gear^.Health = 0) then |
660 |
begin |
|
868 | 661 |
if PrvInactive then |
864 | 662 |
begin |
663 |
Gear^.Timer:= 0; |
|
868 | 664 |
Gear^.State:= Gear^.State or gstHHDeath; |
665 |
Gear^.doStep:= @doStepHedgehogDead; |
|
1347 | 666 |
FollowGear:= Gear; |
868 | 667 |
PrvInactive:= false; |
668 |
AllInactive:= false |
|
864 | 669 |
end; |
863 | 670 |
exit |
671 |
end; |
|
4 | 672 |
|
1033 | 673 |
if ((Gear^.State and gstWait) = 0) and |
863 | 674 |
(prevState <> Gear^.State) then |
675 |
begin |
|
1033 | 676 |
Gear^.State:= gstWait; |
863 | 677 |
Gear^.Timer:= 150 |
678 |
end else |
|
679 |
begin |
|
680 |
if Gear^.Timer = 0 then |
|
681 |
begin |
|
682 |
Gear^.State:= 0; |
|
683 |
Gear^.Active:= false; |
|
684 |
AddGearCI(Gear); |
|
685 |
exit |
|
686 |
end else dec(Gear^.Timer) |
|
687 |
end; |
|
688 |
||
689 |
AllInactive:= false |
|
4 | 690 |
end; |
691 |
||
692 |
//////////////////////////////////////////////////////////////////////////////// |
|
693 |
procedure doStepHedgehog(Gear: PGear); |
|
694 |
begin |
|
351 | 695 |
if (Gear^.Message and gm_Destroy) <> 0 then |
1505 | 696 |
begin |
697 |
DeleteGear(Gear); |
|
698 |
exit |
|
699 |
end; |
|
700 |
||
351 | 701 |
if (Gear^.State and gstHHDriven) = 0 then doStepHedgehogFree(Gear) |
511 | 702 |
else doStepHedgehogDriven(Gear) |
4 | 703 |
end; |