author | unc0rr |
Sun, 11 May 2008 19:21:58 +0000 | |
changeset 926 | d231e007452a |
parent 925 | c20156328529 |
child 927 | 2c1675344a6f |
permissions | -rw-r--r-- |
4 | 1 |
(* |
2 |
* Hedgewars, a worms-like game |
|
883 | 3 |
* Copyright (c) 2004-2008 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); |
21 |
var slot: Longword; |
|
22 |
caSlot, caAmmo: PLongword; |
|
23 |
begin |
|
24 |
slot:= Gear^.MsgParam; |
|
25 |
||
26 |
with PHedgehog(Gear^.Hedgehog)^ do |
|
27 |
begin |
|
28 |
if ((Gear^.State and (gstAttacking or gstAttacked)) <> 0) or (AttacksNum > 0) |
|
29 |
or ((Gear^.State and gstHHDriven) = 0) then exit; |
|
30 |
||
31 |
Gear^.Message:= Gear^.Message and not (gm_LJump or gm_HJump or gm_Slot); |
|
32 |
||
33 |
if CurAmmoGear = nil then begin caSlot:= @CurSlot; caAmmo:= @CurAmmo end |
|
34 |
else begin caSlot:= @AltSlot; caAmmo:= @AltAmmo end; |
|
35 |
||
36 |
if caSlot^ = slot then |
|
37 |
begin |
|
38 |
inc(caAmmo^); |
|
39 |
if (caAmmo^ > cMaxSlotAmmoIndex) or (Ammo^[slot, caAmmo^].Count = 0) then caAmmo^:= 0 |
|
40 |
end else |
|
41 |
if Ammo^[slot, 0].Count > 0 then |
|
42 |
begin |
|
43 |
caSlot^:= slot; |
|
44 |
caAmmo^:= 0; |
|
45 |
end; |
|
46 |
end; |
|
47 |
ApplyAmmoChanges(PHedgehog(Gear^.Hedgehog)^) |
|
48 |
end; |
|
49 |
||
50 |
procedure HHSetWeapon(Gear: PGear); |
|
51 |
var t: LongInt; |
|
52 |
weap: TAmmoType; |
|
53 |
begin |
|
54 |
weap:= TAmmoType(Gear^.MsgParam); |
|
55 |
Gear^.MsgParam:= Ammoz[weap].Slot; |
|
56 |
||
57 |
t:= cMaxSlotAmmoIndex; |
|
58 |
||
59 |
Gear^.Message:= Gear^.Message and not gm_Weapon; |
|
60 |
||
61 |
with PHedgehog(Gear^.Hedgehog)^ do |
|
926
d231e007452a
Timer as hedgehog message (avoid possible desync in very rare cases)
unc0rr
parents:
925
diff
changeset
|
62 |
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
|
63 |
begin |
d231e007452a
Timer as hedgehog message (avoid possible desync in very rare cases)
unc0rr
parents:
925
diff
changeset
|
64 |
ChangeAmmo(Gear); |
d231e007452a
Timer as hedgehog message (avoid possible desync in very rare cases)
unc0rr
parents:
925
diff
changeset
|
65 |
dec(t) |
d231e007452a
Timer as hedgehog message (avoid possible desync in very rare cases)
unc0rr
parents:
925
diff
changeset
|
66 |
end |
783 | 67 |
end; |
68 |
||
926
d231e007452a
Timer as hedgehog message (avoid possible desync in very rare cases)
unc0rr
parents:
925
diff
changeset
|
69 |
procedure HHSetTimer(Gear: PGear); |
d231e007452a
Timer as hedgehog message (avoid possible desync in very rare cases)
unc0rr
parents:
925
diff
changeset
|
70 |
begin |
d231e007452a
Timer as hedgehog message (avoid possible desync in very rare cases)
unc0rr
parents:
925
diff
changeset
|
71 |
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
|
72 |
with PHedgehog(Gear^.Hedgehog)^ do |
d231e007452a
Timer as hedgehog message (avoid possible desync in very rare cases)
unc0rr
parents:
925
diff
changeset
|
73 |
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
|
74 |
begin |
d231e007452a
Timer as hedgehog message (avoid possible desync in very rare cases)
unc0rr
parents:
925
diff
changeset
|
75 |
Ammo^[CurSlot, CurAmmo].Timer:= 1000 * Gear^.MsgParam; |
d231e007452a
Timer as hedgehog message (avoid possible desync in very rare cases)
unc0rr
parents:
925
diff
changeset
|
76 |
with CurrentTeam^ do |
d231e007452a
Timer as hedgehog message (avoid possible desync in very rare cases)
unc0rr
parents:
925
diff
changeset
|
77 |
ApplyAmmoChanges(Hedgehogs[CurrHedgehog]); |
d231e007452a
Timer as hedgehog message (avoid possible desync in very rare cases)
unc0rr
parents:
925
diff
changeset
|
78 |
end; |
d231e007452a
Timer as hedgehog message (avoid possible desync in very rare cases)
unc0rr
parents:
925
diff
changeset
|
79 |
end; |
d231e007452a
Timer as hedgehog message (avoid possible desync in very rare cases)
unc0rr
parents:
925
diff
changeset
|
80 |
|
d231e007452a
Timer as hedgehog message (avoid possible desync in very rare cases)
unc0rr
parents:
925
diff
changeset
|
81 |
|
32
78bff13b11c0
With this patch the game doesn't crash when gaming by net
unc0rr
parents:
16
diff
changeset
|
82 |
procedure Attack(Gear: PGear); |
351 | 83 |
var xx, yy: hwFloat; |
32
78bff13b11c0
With this patch the game doesn't crash when gaming by net
unc0rr
parents:
16
diff
changeset
|
84 |
begin |
78bff13b11c0
With this patch the game doesn't crash when gaming by net
unc0rr
parents:
16
diff
changeset
|
85 |
with Gear^, |
351 | 86 |
PHedgehog(Gear^.Hedgehog)^ do |
32
78bff13b11c0
With this patch the game doesn't crash when gaming by net
unc0rr
parents:
16
diff
changeset
|
87 |
begin |
95 | 88 |
if ((State and gstHHDriven) <> 0)and |
542 | 89 |
((State and (gstAttacked or gstHHChooseTarget)) = 0)and |
836 | 90 |
(((State and gstMoving) = 0) or ((Ammo^[CurSlot, CurAmmo].Propz and ammoprop_AttackInMove) <> 0))and |
91 |
((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
|
92 |
begin |
95 | 93 |
State:= State or gstAttacking; |
94 |
if Power = cMaxPower then Message:= Message and not gm_Attack |
|
351 | 95 |
else if (Ammo^[CurSlot, CurAmmo].Propz and ammoprop_Power) = 0 then Message:= Message and not gm_Attack |
95 | 96 |
else begin |
97 |
if Power = 0 then |
|
98 |
begin |
|
351 | 99 |
AttackBar:= CurrentTeam^.AttackBar; |
100 |
PlaySound(sndThrowPowerUp, false) |
|
95 | 101 |
end; |
102 |
inc(Power) |
|
103 |
end; |
|
104 |
if ((Message and gm_Attack) <> 0) then exit; |
|
351 | 105 |
|
106 |
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
|
107 |
begin |
282 | 108 |
StopSound(sndThrowPowerUp); |
351 | 109 |
PlaySound(sndThrowRelease, false); |
32
78bff13b11c0
With this patch the game doesn't crash when gaming by net
unc0rr
parents:
16
diff
changeset
|
110 |
end; |
519 | 111 |
xx:= SignAs(AngleSin(Angle), dX); |
900 | 112 |
yy:= -AngleCos(Angle); |
113 |
||
114 |
if ((Gear^.State and gstHHHJump) <> 0) then xx:= - xx; |
|
351 | 115 |
case Ammo^[CurSlot, CurAmmo].AmmoType of |
116 |
amGrenade: FollowGear:= AddGear(hwRound(X), hwRound(Y), gtAmmo_Bomb, 0, xx*Power/cPowerDivisor, yy*Power/cPowerDivisor, Ammo^[CurSlot, CurAmmo].Timer); |
|
117 |
amClusterBomb: FollowGear:= AddGear(hwRound(X), hwRound(Y), gtClusterBomb, 0, xx*Power/cPowerDivisor, yy*Power/cPowerDivisor, Ammo^[CurSlot, CurAmmo].Timer); |
|
118 |
amBazooka: FollowGear:= AddGear(hwRound(X), hwRound(Y), gtAmmo_Grenade, 0, xx*Power/cPowerDivisor, yy*Power/cPowerDivisor, 0); |
|
119 |
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
|
120 |
amShotgun: begin |
351 | 121 |
PlaySound(sndShotgunReload, false); |
122 |
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
|
123 |
end; |
498 | 124 |
amPickHammer: CurAmmoGear:= AddGear(hwRound(Gear^.X), hwRound(Gear^.Y) + cHHRadius, gtPickHammer, 0, _0, _0, 0); |
866 | 125 |
amSkip: ParseCommand('/skip', true); |
351 | 126 |
amRope: CurAmmoGear:= AddGear(hwRound(Gear^.X), hwRound(Gear^.Y), gtRope, 0, xx, yy, 0); |
800 | 127 |
amMine: begin |
128 |
AddGear(hwRound(X) + hwSign(dX) * 7, hwRound(Y), gtMine, 0, SignAs(_0_02, dX), _0, 3000); |
|
129 |
PlaySound(sndLaugh, false) |
|
130 |
end; |
|
876 | 131 |
amDEagle: CurAmmoGear:= AddGear(hwRound(X + xx * cHHRadius), hwRound(Y + yy * cHHRadius), gtDEagleShot, 0, xx * _0_5, yy * _0_5, 0); |
498 | 132 |
amDynamite: AddGear(hwRound(X) + hwSign(dX) * 7, hwRound(Y), gtDynamite, 0, SignAs(_0_03, dX), _0, 5000); |
925 | 133 |
amFirePunch: CurAmmoGear:= AddGear(hwRound(X) + hwSign(dX) * 10, hwRound(Y), gtFirePunch, 0, _0, _0, 0); |
134 |
amWhip: CurAmmoGear:= AddGear(hwRound(X) + hwSign(dX) * 10, hwRound(Y), gtWhip, 0, SignAs(_1, dX), - _0_8, 0); |
|
854 | 135 |
amBaseballBat: CurAmmoGear:= AddGear(hwRound(X) + hwSign(dX) * 10, hwRound(Y), gtShover, 0, xx * _0_5, yy * _0_5, 0); |
498 | 136 |
amParachute: CurAmmoGear:= AddGear(hwRound(X), hwRound(Y), gtParachute, 0, _0, _0, 0); |
137 |
amAirAttack: AddGear(Ammo^[CurSlot, CurAmmo].Pos, 0, gtAirAttack, 0, _0, _0, 0); |
|
138 |
amMineStrike: AddGear(Ammo^[CurSlot, CurAmmo].Pos, 0, gtAirAttack, 1, _0, _0, 0); |
|
139 |
amBlowTorch: CurAmmoGear:= AddGear(hwRound(X), hwRound(Y), gtBlowTorch, 0, SignAs(_0_5, dX), _0, 0); |
|
140 |
amGirder: CurAmmoGear:= AddGear(0, 0, gtGirder, Ammo^[CurSlot, CurAmmo].Pos, _0, _0, 0); |
|
520 | 141 |
amTeleport: CurAmmoGear:= AddGear(0, 0, gtTeleport, 0, _0, _0, 0); |
534 | 142 |
amSwitch: CurAmmoGear:= AddGear(hwRound(X), hwRound(Y), gtSwitcher, 0, _0, _0, 0); |
924 | 143 |
amMortar: FollowGear:= AddGear(hwRound(X), hwRound(Y), gtMortar, 0, xx*cMaxPower/cPowerDivisor, yy*cMaxPower/cPowerDivisor, 0); |
32
78bff13b11c0
With this patch the game doesn't crash when gaming by net
unc0rr
parents:
16
diff
changeset
|
144 |
end; |
829 | 145 |
|
146 |
uStats.AmmoUsed(Ammo^[CurSlot, CurAmmo].AmmoType); |
|
147 |
||
32
78bff13b11c0
With this patch the game doesn't crash when gaming by net
unc0rr
parents:
16
diff
changeset
|
148 |
Power:= 0; |
78bff13b11c0
With this patch the game doesn't crash when gaming by net
unc0rr
parents:
16
diff
changeset
|
149 |
if CurAmmoGear <> nil then |
78bff13b11c0
With this patch the game doesn't crash when gaming by net
unc0rr
parents:
16
diff
changeset
|
150 |
begin |
82 | 151 |
Message:= Message or gm_Attack; |
351 | 152 |
CurAmmoGear^.Message:= Message |
82 | 153 |
end else begin |
351 | 154 |
if not CurrentTeam^.ExtDriven and |
155 |
((Ammo^[CurSlot, CurAmmo].Propz and ammoprop_Power) <> 0) then SendIPC('a'); |
|
82 | 156 |
AfterAttack |
157 |
end |
|
95 | 158 |
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
|
159 |
end |
78bff13b11c0
With this patch the game doesn't crash when gaming by net
unc0rr
parents:
16
diff
changeset
|
160 |
end; |
78bff13b11c0
With this patch the game doesn't crash when gaming by net
unc0rr
parents:
16
diff
changeset
|
161 |
|
78bff13b11c0
With this patch the game doesn't crash when gaming by net
unc0rr
parents:
16
diff
changeset
|
162 |
procedure AfterAttack; |
78bff13b11c0
With this patch the game doesn't crash when gaming by net
unc0rr
parents:
16
diff
changeset
|
163 |
begin |
602 | 164 |
with CurrentHedgehog^.Gear^, |
165 |
CurrentHedgehog^ do |
|
32
78bff13b11c0
With this patch the game doesn't crash when gaming by net
unc0rr
parents:
16
diff
changeset
|
166 |
begin |
78bff13b11c0
With this patch the game doesn't crash when gaming by net
unc0rr
parents:
16
diff
changeset
|
167 |
Inc(AttacksNum); |
78bff13b11c0
With this patch the game doesn't crash when gaming by net
unc0rr
parents:
16
diff
changeset
|
168 |
State:= State and not gstAttacking; |
614 | 169 |
if (Ammo^[CurSlot, CurAmmo].NumPerTurn >= AttacksNum) or |
170 |
((GameFlags and gfMultiWeapon) <> 0) then isInMultiShoot:= true |
|
32
78bff13b11c0
With this patch the game doesn't crash when gaming by net
unc0rr
parents:
16
diff
changeset
|
171 |
else begin |
351 | 172 |
TurnTimeLeft:= Ammoz[Ammo^[CurSlot, CurAmmo].AmmoType].TimeAfterTurn; |
32
78bff13b11c0
With this patch the game doesn't crash when gaming by net
unc0rr
parents:
16
diff
changeset
|
173 |
State:= State or gstAttacked; |
602 | 174 |
OnUsedAmmo(CurrentHedgehog^) |
32
78bff13b11c0
With this patch the game doesn't crash when gaming by net
unc0rr
parents:
16
diff
changeset
|
175 |
end; |
95 | 176 |
AttackBar:= 0; |
32
78bff13b11c0
With this patch the game doesn't crash when gaming by net
unc0rr
parents:
16
diff
changeset
|
177 |
end |
78bff13b11c0
With this patch the game doesn't crash when gaming by net
unc0rr
parents:
16
diff
changeset
|
178 |
end; |
78bff13b11c0
With this patch the game doesn't crash when gaming by net
unc0rr
parents:
16
diff
changeset
|
179 |
|
42 | 180 |
//////////////////////////////////////////////////////////////////////////////// |
863 | 181 |
procedure doStepHedgehogDead(Gear: PGear); |
868 | 182 |
const frametime = 200; |
183 |
timertime = frametime * 6; |
|
863 | 184 |
begin |
185 |
if Gear^.Timer > 1 then |
|
186 |
begin |
|
187 |
AllInactive:= false; |
|
868 | 188 |
dec(Gear^.Timer); |
189 |
if (Gear^.Timer mod frametime) = 0 then inc(Gear^.Pos) |
|
863 | 190 |
end else |
191 |
if Gear^.Timer = 1 then |
|
192 |
begin |
|
193 |
Gear^.State:= Gear^.State or gstNoDamage; |
|
194 |
doMakeExplosion(hwRound(Gear^.X), hwRound(Gear^.Y), 30, EXPLAutoSound); |
|
195 |
AddGear(hwRound(Gear^.X), hwRound(Gear^.Y), gtGrave, 0, _0, _0, 0)^.Hedgehog:= Gear^.Hedgehog; |
|
196 |
DeleteGear(Gear); |
|
197 |
SetAllToActive |
|
198 |
end else // Gear^.Timer = 0 |
|
199 |
begin |
|
200 |
AllInactive:= false; |
|
868 | 201 |
Gear^.Z:= cCurrHHZ; |
202 |
RemoveGearFromList(Gear); |
|
203 |
InsertGearToList(Gear); |
|
863 | 204 |
PlaySound(sndByeBye, false); |
868 | 205 |
Gear^.Pos:= 0; |
206 |
Gear^.Timer:= timertime |
|
863 | 207 |
end |
208 |
end; |
|
209 |
||
210 |
//////////////////////////////////////////////////////////////////////////////// |
|
42 | 211 |
procedure PickUp(HH, Gear: PGear); |
295 | 212 |
var s: shortstring; |
213 |
a: TAmmoType; |
|
42 | 214 |
begin |
351 | 215 |
Gear^.Message:= gm_Destroy; |
216 |
case Gear^.Pos of |
|
295 | 217 |
posCaseAmmo: begin |
351 | 218 |
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
|
219 |
AddAmmo(PHedgehog(HH^.Hedgehog)^, a); |
836 | 220 |
if not (PHedgehog(HH^.Hedgehog)^.Team^.ExtDriven |
221 |
or (PHedgehog(HH^.Hedgehog)^.BotLevel > 0)) then |
|
222 |
begin |
|
223 |
s:= trammo[Ammoz[a].NameId] + '(+' + IntToStr(Ammoz[a].NumberInCase) + ')'; |
|
224 |
AddCaption(s, PHedgehog(HH^.Hedgehog)^.Team^.Clan^.Color, capgrpAmmoinfo); |
|
225 |
end |
|
295 | 226 |
end; |
42 | 227 |
posCaseHealth: begin |
351 | 228 |
inc(HH^.Health, Gear^.Health); |
229 |
str(Gear^.Health, s); |
|
295 | 230 |
s:= '+' + s; |
549 | 231 |
AddCaption(s, PHedgehog(HH^.Hedgehog)^.Team^.Clan^.Color, capgrpAmmoinfo); |
351 | 232 |
RenderHealth(PHedgehog(HH^.Hedgehog)^); |
233 |
RecountTeamHealth(PHedgehog(HH^.Hedgehog)^.Team) |
|
42 | 234 |
end; |
435 | 235 |
end |
42 | 236 |
end; |
32
78bff13b11c0
With this patch the game doesn't crash when gaming by net
unc0rr
parents:
16
diff
changeset
|
237 |
|
4 | 238 |
const StepTicks: LongWord = 0; |
239 |
||
302 | 240 |
procedure HedgehogStep(Gear: PGear); |
371 | 241 |
var PrevdX: LongInt; |
302 | 242 |
begin |
542 | 243 |
if ((Gear^.State and (gstAttacking or gstMoving)) = 0) then |
4 | 244 |
begin |
408 | 245 |
if isCursorVisible then |
246 |
with PHedgehog(Gear^.Hedgehog)^ do |
|
247 |
with Ammo^[CurSlot, CurAmmo] do |
|
248 |
begin |
|
542 | 249 |
if (Gear^.Message and gm_Left ) <> 0 then |
408 | 250 |
Pos:= (Pos + Ammoz[AmmoType].PosCount - 1) mod Ammoz[AmmoType].PosCount |
251 |
else |
|
542 | 252 |
if (Gear^.Message and gm_Right ) <> 0 then |
408 | 253 |
Pos:= (Pos + 1) mod Ammoz[AmmoType].PosCount |
254 |
else exit; |
|
423 | 255 |
StepTicks:= 200; |
408 | 256 |
exit |
257 |
end; |
|
505
fcba7d7aea0d
Fix old bug with grenade(bomd, etc..) not colliding with attacking hedgehog
unc0rr
parents:
498
diff
changeset
|
258 |
|
351 | 259 |
if ((Gear^.Message and gm_LJump ) <> 0) then |
4 | 260 |
begin |
542 | 261 |
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
|
262 |
DeleteCI(Gear); |
68 | 263 |
if not TestCollisionYwithGear(Gear, -1) then |
498 | 264 |
if not TestCollisionXwithXYShift(Gear, _0, -2, hwSign(Gear^.dX)) then Gear^.Y:= Gear^.Y - _2 else |
265 |
if not TestCollisionXwithXYShift(Gear, _0, -1, hwSign(Gear^.dX)) then Gear^.Y:= Gear^.Y - _1; |
|
351 | 266 |
if not (TestCollisionXwithGear(Gear, hwSign(Gear^.dX)) |
68 | 267 |
or TestCollisionYwithGear(Gear, -1)) then |
4 | 268 |
begin |
351 | 269 |
Gear^.dY:= -_0_15; |
498 | 270 |
Gear^.dX:= SignAs(_0_15, Gear^.dX); |
542 | 271 |
Gear^.State:= Gear^.State or gstMoving or gstHHJumping; |
799 | 272 |
PlaySound(sndJump1, false); |
4 | 273 |
exit |
274 |
end; |
|
275 |
end; |
|
505
fcba7d7aea0d
Fix old bug with grenade(bomd, etc..) not colliding with attacking hedgehog
unc0rr
parents:
498
diff
changeset
|
276 |
|
351 | 277 |
if ((Gear^.Message and gm_HJump ) <> 0) then |
4 | 278 |
begin |
505
fcba7d7aea0d
Fix old bug with grenade(bomd, etc..) not colliding with attacking hedgehog
unc0rr
parents:
498
diff
changeset
|
279 |
DeleteCI(Gear); |
542 | 280 |
Gear^.Message:= Gear^.Message and not gm_HJump; |
855
8842c71d16bf
- Fix too long delay between shotgun and deagle shots
unc0rr
parents:
854
diff
changeset
|
281 |
|
8842c71d16bf
- Fix too long delay between shotgun and deagle shots
unc0rr
parents:
854
diff
changeset
|
282 |
Gear^.dY:= -_0_2; |
8842c71d16bf
- Fix too long delay between shotgun and deagle shots
unc0rr
parents:
854
diff
changeset
|
283 |
SetLittle(Gear^.dX); |
8842c71d16bf
- Fix too long delay between shotgun and deagle shots
unc0rr
parents:
854
diff
changeset
|
284 |
Gear^.State:= Gear^.State or gstMoving or gstHHJumping; |
8842c71d16bf
- Fix too long delay between shotgun and deagle shots
unc0rr
parents:
854
diff
changeset
|
285 |
PlaySound(sndJump3, false); |
8842c71d16bf
- Fix too long delay between shotgun and deagle shots
unc0rr
parents:
854
diff
changeset
|
286 |
exit |
4 | 287 |
end; |
505
fcba7d7aea0d
Fix old bug with grenade(bomd, etc..) not colliding with attacking hedgehog
unc0rr
parents:
498
diff
changeset
|
288 |
|
351 | 289 |
PrevdX:= hwSign(Gear^.dX); |
290 |
if (Gear^.Message and gm_Left )<>0 then Gear^.dX:= -cLittle else |
|
291 |
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
|
292 |
|
74 | 293 |
StepTicks:= cHHStepTicks; |
610 | 294 |
if PrevdX <> hwSign(Gear^.dX) then |
295 |
begin |
|
296 |
FollowGear:= Gear; |
|
297 |
exit |
|
298 |
end; |
|
299 |
DeleteCI(Gear); // must be after exit!! (see previous line) |
|
838 | 300 |
|
351 | 301 |
PHedgehog(Gear^.Hedgehog)^.visStepPos:= (PHedgehog(Gear^.Hedgehog)^.visStepPos + 1) and 7; |
302 |
if TestCollisionXwithGear(Gear, hwSign(Gear^.dX)) then |
|
4 | 303 |
begin |
498 | 304 |
if not (TestCollisionXwithXYShift(Gear, _0, -6, hwSign(Gear^.dX)) |
305 |
or TestCollisionYwithGear(Gear, -1)) then Gear^.Y:= Gear^.Y - _1; |
|
306 |
if not (TestCollisionXwithXYShift(Gear, _0, -5, hwSign(Gear^.dX)) |
|
307 |
or TestCollisionYwithGear(Gear, -1)) then Gear^.Y:= Gear^.Y - _1; |
|
308 |
if not (TestCollisionXwithXYShift(Gear, _0, -4, hwSign(Gear^.dX)) |
|
309 |
or TestCollisionYwithGear(Gear, -1)) then Gear^.Y:= Gear^.Y - _1; |
|
310 |
if not (TestCollisionXwithXYShift(Gear, _0, -3, hwSign(Gear^.dX)) |
|
311 |
or TestCollisionYwithGear(Gear, -1)) then Gear^.Y:= Gear^.Y - _1; |
|
312 |
if not (TestCollisionXwithXYShift(Gear, _0, -2, hwSign(Gear^.dX)) |
|
313 |
or TestCollisionYwithGear(Gear, -1)) then Gear^.Y:= Gear^.Y - _1; |
|
314 |
if not (TestCollisionXwithXYShift(Gear, _0, -1, hwSign(Gear^.dX)) |
|
315 |
or TestCollisionYwithGear(Gear, -1)) then Gear^.Y:= Gear^.Y - _1; |
|
4 | 316 |
end; |
498 | 317 |
if not TestCollisionXwithGear(Gear, hwSign(Gear^.dX)) then Gear^.X:= Gear^.X + SignAs(_1, Gear^.dX); |
300 | 318 |
|
62 | 319 |
SetAllHHToActive; |
37 | 320 |
|
68 | 321 |
if not TestCollisionYwithGear(Gear, 1) then |
4 | 322 |
begin |
498 | 323 |
Gear^.Y:= Gear^.Y + _1; |
68 | 324 |
if not TestCollisionYwithGear(Gear, 1) then |
4 | 325 |
begin |
498 | 326 |
Gear^.Y:= Gear^.Y + _1; |
68 | 327 |
if not TestCollisionYwithGear(Gear, 1) then |
4 | 328 |
begin |
498 | 329 |
Gear^.Y:= Gear^.Y + _1; |
68 | 330 |
if not TestCollisionYwithGear(Gear, 1) then |
4 | 331 |
begin |
498 | 332 |
Gear^.Y:= Gear^.Y + _1; |
68 | 333 |
if not TestCollisionYwithGear(Gear, 1) then |
4 | 334 |
begin |
498 | 335 |
Gear^.Y:= Gear^.Y + _1; |
68 | 336 |
if not TestCollisionYwithGear(Gear, 1) then |
4 | 337 |
begin |
498 | 338 |
Gear^.Y:= Gear^.Y + _1; |
68 | 339 |
if not TestCollisionYwithGear(Gear, 1) then |
4 | 340 |
begin |
498 | 341 |
Gear^.Y:= Gear^.Y - _6; |
342 |
Gear^.dY:= _0; |
|
542 | 343 |
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
|
344 |
exit |
4 | 345 |
end; |
346 |
end |
|
347 |
end |
|
348 |
end |
|
349 |
end |
|
350 |
end |
|
505
fcba7d7aea0d
Fix old bug with grenade(bomd, etc..) not colliding with attacking hedgehog
unc0rr
parents:
498
diff
changeset
|
351 |
end; |
fcba7d7aea0d
Fix old bug with grenade(bomd, etc..) not colliding with attacking hedgehog
unc0rr
parents:
498
diff
changeset
|
352 |
AddGearCI(Gear) |
4 | 353 |
end |
354 |
end; |
|
355 |
||
303
1659c4aad5ab
Now blow torch angle can be changed during blowing :)
unc0rr
parents:
302
diff
changeset
|
356 |
procedure HedgehogChAngle(Gear: PGear); |
1659c4aad5ab
Now blow torch angle can be changed during blowing :)
unc0rr
parents:
302
diff
changeset
|
357 |
begin |
542 | 358 |
if ((Gear^.State and gstMoving) = 0) then |
351 | 359 |
if (Gear^.Message and gm_Up )<>0 then if Gear^.Angle > CurMinAngle then dec(Gear^.Angle) |
303
1659c4aad5ab
Now blow torch angle can be changed during blowing :)
unc0rr
parents:
302
diff
changeset
|
360 |
else else |
351 | 361 |
if (Gear^.Message and gm_Down )<>0 then if Gear^.Angle < CurMaxAngle then inc(Gear^.Angle); |
303
1659c4aad5ab
Now blow torch angle can be changed during blowing :)
unc0rr
parents:
302
diff
changeset
|
362 |
end; |
1659c4aad5ab
Now blow torch angle can be changed during blowing :)
unc0rr
parents:
302
diff
changeset
|
363 |
|
302 | 364 |
procedure doStepHedgehog(Gear: PGear); forward; |
365 |
//////////////////////////////////////////////////////////////////////////////// |
|
538 | 366 |
procedure doStepHedgehogMoving(Gear: PGear); |
545 | 367 |
var isFalling: boolean; |
538 | 368 |
begin |
855
8842c71d16bf
- Fix too long delay between shotgun and deagle shots
unc0rr
parents:
854
diff
changeset
|
369 |
isFalling:= (Gear^.dY.isNegative) or not TestCollisionYKick(Gear, 1); |
542 | 370 |
if isFalling then |
538 | 371 |
begin |
372 |
if (Gear^.dY.isNegative) and TestCollisionYKick(Gear, -1) then Gear^.dY:= _0; |
|
542 | 373 |
Gear^.State:= Gear^.State or gstMoving; |
538 | 374 |
Gear^.dY:= Gear^.dY + cGravity |
375 |
end else |
|
376 |
begin |
|
377 |
if ((hwAbs(Gear^.dX) + hwAbs(Gear^.dY)) < _0_55) |
|
378 |
and ((Gear^.State and gstHHJumping) <> 0) then SetLittle(Gear^.dX); |
|
379 |
||
540 | 380 |
if not Gear^.dY.isNegative then |
381 |
begin |
|
382 |
CheckHHDamage(Gear); |
|
790
a6f442173822
Make high jump behaviour like in worms (back somersault)
unc0rr
parents:
783
diff
changeset
|
383 |
|
a6f442173822
Make high jump behaviour like in worms (back somersault)
unc0rr
parents:
783
diff
changeset
|
384 |
if ((Gear^.State and gstHHHJump) <> 0) and |
a6f442173822
Make high jump behaviour like in worms (back somersault)
unc0rr
parents:
783
diff
changeset
|
385 |
(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
|
386 |
|
542 | 387 |
Gear^.State:= Gear^.State and not (gstHHJumping or gstHHHJump); |
540 | 388 |
Gear^.dY:= _0; |
389 |
end else Gear^.dY:= Gear^.dY + cGravity; |
|
538 | 390 |
|
391 |
if ((Gear^.State and gstMoving) <> 0) then Gear^.dX:= Gear^.dX * Gear^.Friction |
|
392 |
end; |
|
393 |
||
394 |
if (Gear^.State <> 0) then DeleteCI(Gear); |
|
783 | 395 |
|
538 | 396 |
if (Gear^.State and gstMoving) <> 0 then |
397 |
if TestCollisionXKick(Gear, hwSign(Gear^.dX)) then |
|
542 | 398 |
if not isFalling then |
538 | 399 |
if hwAbs(Gear^.dX) > _0_01 then |
400 |
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 |
|
401 |
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 |
|
402 |
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 |
|
403 |
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 |
|
404 |
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 |
|
405 |
if hwAbs(Gear^.dX) > _0_02 then Gear^.dX:= -Gear^.Elasticity * Gear^.dX |
|
406 |
else begin |
|
407 |
Gear^.State:= Gear^.State and not gstMoving; |
|
408 |
SetLittle(Gear^.dX) |
|
409 |
end |
|
410 |
else begin |
|
411 |
Gear^.State:= Gear^.State and not gstMoving; |
|
412 |
SetLittle(Gear^.dX) |
|
413 |
end |
|
414 |
else if hwAbs(Gear^.dX) > cLittle then Gear^.dX:= -Gear^.Elasticity * Gear^.dX |
|
415 |
else SetLittle(Gear^.dX); |
|
416 |
||
542 | 417 |
if (not isFalling) and |
538 | 418 |
(hwAbs(Gear^.dX) + hwAbs(Gear^.dY) < _0_03) then |
419 |
begin |
|
420 |
Gear^.State:= Gear^.State and not gstMoving; |
|
421 |
SetLittle(Gear^.dX); |
|
422 |
Gear^.dY:= _0 |
|
423 |
end else Gear^.State:= Gear^.State or gstMoving; |
|
424 |
||
425 |
if (Gear^.State and gstMoving) <> 0 then |
|
426 |
begin |
|
427 |
Gear^.State:= Gear^.State and not gstAnimation; |
|
428 |
Gear^.X:= Gear^.X + Gear^.dX; |
|
429 |
Gear^.Y:= Gear^.Y + Gear^.dY; |
|
430 |
if (not Gear^.dY.isNegative) and |
|
431 |
(not TestCollisionYKick(Gear, 1)) and |
|
432 |
TestCollisionYwithXYShift(Gear, 0, 1, 1) then |
|
433 |
begin |
|
434 |
CheckHHDamage(Gear); |
|
435 |
Gear^.dY:= _0; |
|
436 |
Gear^.Y:= Gear^.Y + _1 |
|
437 |
end; |
|
438 |
CheckGearDrowning(Gear) |
|
439 |
end |
|
440 |
end; |
|
441 |
||
302 | 442 |
procedure doStepHedgehogDriven(Gear: PGear); |
443 |
var t: PGear; |
|
444 |
begin |
|
558
b2b840eeb10a
Fix bug when hedgehog moves not right after it is kicked
unc0rr
parents:
553
diff
changeset
|
445 |
if not isInMultiShoot then |
b2b840eeb10a
Fix bug when hedgehog moves not right after it is kicked
unc0rr
parents:
553
diff
changeset
|
446 |
AllInactive:= false |
b2b840eeb10a
Fix bug when hedgehog moves not right after it is kicked
unc0rr
parents:
553
diff
changeset
|
447 |
else |
b2b840eeb10a
Fix bug when hedgehog moves not right after it is kicked
unc0rr
parents:
553
diff
changeset
|
448 |
Gear^.Message:= 0; |
505
fcba7d7aea0d
Fix old bug with grenade(bomd, etc..) not colliding with attacking hedgehog
unc0rr
parents:
498
diff
changeset
|
449 |
|
351 | 450 |
if (TurnTimeLeft = 0) or (Gear^.Damage > 0) then |
302 | 451 |
begin |
452 |
TurnTimeLeft:= 0; |
|
351 | 453 |
Gear^.State:= Gear^.State and not gstHHDriven; |
454 |
if Gear^.Damage > 0 then |
|
424 | 455 |
Gear^.State:= Gear^.State and not (gstHHJumping or gstHHHJump); |
302 | 456 |
exit |
457 |
end; |
|
542 | 458 |
|
836 | 459 |
if ((Gear^.State and gstMoving) <> 0) |
460 |
or (StepTicks = cHHStepTicks) |
|
835
6f567934cc44
Automatically use parachute when vertical speed is high enough
unc0rr
parents:
829
diff
changeset
|
461 |
or (CurAmmoGear <> nil) then // we're moving |
836 | 462 |
begin |
839 | 463 |
with PHedgehog(Gear^.Hedgehog)^ do |
464 |
if (CurAmmoGear = nil) |
|
465 |
and (Gear^.dY > _0_39) |
|
466 |
and (Ammo^[CurSlot, CurAmmo].AmmoType = amParachute) then Gear^.Message:= Gear^.Message or gm_Attack; |
|
836 | 467 |
// check for case with ammo |
468 |
t:= CheckGearNear(Gear, gtCase, 36, 36); |
|
469 |
if t <> nil then |
|
470 |
PickUp(Gear, t) |
|
855
8842c71d16bf
- Fix too long delay between shotgun and deagle shots
unc0rr
parents:
854
diff
changeset
|
471 |
end; |
302 | 472 |
|
473 |
if CurAmmoGear <> nil then |
|
474 |
begin |
|
351 | 475 |
CurAmmoGear^.Message:= Gear^.Message; |
302 | 476 |
exit |
477 |
end; |
|
478 |
||
783 | 479 |
if ((Gear^.Message and gm_Slot) <> 0) then ChangeAmmo(Gear); |
480 |
||
481 |
if ((Gear^.Message and gm_Weapon) <> 0) then HHSetWeapon(Gear); |
|
482 |
||
926
d231e007452a
Timer as hedgehog message (avoid possible desync in very rare cases)
unc0rr
parents:
925
diff
changeset
|
483 |
if ((Gear^.Message and gm_Timer) <> 0) then HHSetTimer(Gear); |
d231e007452a
Timer as hedgehog message (avoid possible desync in very rare cases)
unc0rr
parents:
925
diff
changeset
|
484 |
|
351 | 485 |
if ((Gear^.Message and gm_Attack) <> 0) or |
542 | 486 |
((Gear^.State and gstAttacking) <> 0) then Attack(Gear); |
302 | 487 |
|
542 | 488 |
if (Gear^.State and gstMoving) <> 0 then |
302 | 489 |
begin |
424 | 490 |
if ((Gear^.Message and gm_HJump) <> 0) and |
491 |
((Gear^.State and gstHHJumping) <> 0) and |
|
492 |
((Gear^.State and gstHHHJump) = 0) then |
|
493 |
if (not (hwAbs(Gear^.dX) > cLittle)) and (Gear^.dY < -_0_02) then |
|
302 | 494 |
begin |
542 | 495 |
Gear^.State:= Gear^.State or gstHHHJump or gstMoving; |
351 | 496 |
Gear^.dY:= -_0_25; |
799 | 497 |
Gear^.dX:= -SignAs(_0_02, Gear^.dX); |
498 |
PlaySound(sndJump2, false) |
|
302 | 499 |
end; |
351 | 500 |
Gear^.Message:= Gear^.Message and not (gm_LJump or gm_HJump); |
538 | 501 |
|
502 |
if ((Gear^.State and gstHHJumping) <> 0) and |
|
503 |
TestCollisionXwithGear(Gear, hwSign(Gear^.dX)) then SetLittle(Gear^.dX); |
|
504 |
||
505 |
doStepHedgehogMoving(Gear); |
|
542 | 506 |
|
507 |
if (Gear^.State and gstMoving) = 0 then |
|
302 | 508 |
begin |
505
fcba7d7aea0d
Fix old bug with grenade(bomd, etc..) not colliding with attacking hedgehog
unc0rr
parents:
498
diff
changeset
|
509 |
AddGearCI(Gear); |
542 | 510 |
StepTicks:= 350 |
302 | 511 |
end; |
512 |
exit |
|
538 | 513 |
end; |
302 | 514 |
|
558
b2b840eeb10a
Fix bug when hedgehog moves not right after it is kicked
unc0rr
parents:
553
diff
changeset
|
515 |
if not isInMultiShoot then |
b2b840eeb10a
Fix bug when hedgehog moves not right after it is kicked
unc0rr
parents:
553
diff
changeset
|
516 |
begin |
b2b840eeb10a
Fix bug when hedgehog moves not right after it is kicked
unc0rr
parents:
553
diff
changeset
|
517 |
HedgehogChAngle(Gear); |
b2b840eeb10a
Fix bug when hedgehog moves not right after it is kicked
unc0rr
parents:
553
diff
changeset
|
518 |
if StepTicks > 0 then dec(StepTicks); |
b2b840eeb10a
Fix bug when hedgehog moves not right after it is kicked
unc0rr
parents:
553
diff
changeset
|
519 |
if (StepTicks = 0) then HedgehogStep(Gear) |
b2b840eeb10a
Fix bug when hedgehog moves not right after it is kicked
unc0rr
parents:
553
diff
changeset
|
520 |
end |
302 | 521 |
end; |
522 |
||
4 | 523 |
//////////////////////////////////////////////////////////////////////////////// |
524 |
procedure doStepHedgehogFree(Gear: PGear); |
|
511 | 525 |
var prevState: Longword; |
4 | 526 |
begin |
511 | 527 |
prevState:= Gear^.State; |
4 | 528 |
|
538 | 529 |
doStepHedgehogMoving(Gear); |
4 | 530 |
|
865 | 531 |
if (Gear^.State and gstMoving) <> 0 then |
532 |
begin |
|
533 |
AllInactive:= false; |
|
534 |
exit |
|
535 |
end; |
|
4 | 536 |
|
863 | 537 |
if (Gear^.Health = 0) then |
538 |
begin |
|
868 | 539 |
if PrvInactive then |
864 | 540 |
begin |
541 |
Gear^.Timer:= 0; |
|
868 | 542 |
Gear^.State:= Gear^.State or gstHHDeath; |
543 |
Gear^.doStep:= @doStepHedgehogDead; |
|
544 |
PrvInactive:= false; |
|
545 |
AllInactive:= false |
|
864 | 546 |
end; |
863 | 547 |
exit |
548 |
end; |
|
4 | 549 |
|
863 | 550 |
if ((Gear^.State and gstAnimation) = 0) and |
551 |
(prevState <> Gear^.State) then |
|
552 |
begin |
|
553 |
Gear^.State:= gstAnimation; |
|
554 |
Gear^.Timer:= 150 |
|
555 |
end else |
|
556 |
begin |
|
557 |
if Gear^.Timer = 0 then |
|
558 |
begin |
|
559 |
Gear^.State:= 0; |
|
560 |
Gear^.Active:= false; |
|
561 |
AddGearCI(Gear); |
|
562 |
exit |
|
563 |
end else dec(Gear^.Timer) |
|
564 |
end; |
|
565 |
||
566 |
AllInactive:= false |
|
4 | 567 |
end; |
568 |
||
569 |
//////////////////////////////////////////////////////////////////////////////// |
|
570 |
procedure doStepHedgehog(Gear: PGear); |
|
571 |
begin |
|
351 | 572 |
if (Gear^.Message and gm_Destroy) <> 0 then |
4 | 573 |
begin |
574 |
DeleteGear(Gear); |
|
575 |
exit |
|
576 |
end; |
|
351 | 577 |
if (Gear^.State and gstHHDriven) = 0 then doStepHedgehogFree(Gear) |
511 | 578 |
else doStepHedgehogDriven(Gear) |
4 | 579 |
end; |