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