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