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