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