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