author | unc0rr |
Sat, 19 Apr 2008 19:29:58 +0000 | |
changeset 851 | 8ffa4ad0d8ea |
parent 839 | 1493f697d1bb |
child 854 | fef7f2d908bf |
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); |
351 | 118 |
amBaseballBat: AddGear(hwRound(X) + hwSign(dX) * 10, hwRound(Y), gtShover, 0, xx * _0_5, yy * _0_5, 0)^.Radius:= 20; |
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; |
68 | 234 |
if not TestCollisionYwithGear(Gear, -1) then |
4 | 235 |
begin |
351 | 236 |
Gear^.dY:= -_0_2; |
237 |
SetLittle(Gear^.dX); |
|
542 | 238 |
Gear^.State:= Gear^.State or gstMoving or gstHHJumping; |
799 | 239 |
PlaySound(sndJump3, false); |
4 | 240 |
exit |
241 |
end; |
|
242 |
end; |
|
505
fcba7d7aea0d
Fix old bug with grenade(bomd, etc..) not colliding with attacking hedgehog
unc0rr
parents:
498
diff
changeset
|
243 |
|
351 | 244 |
PrevdX:= hwSign(Gear^.dX); |
245 |
if (Gear^.Message and gm_Left )<>0 then Gear^.dX:= -cLittle else |
|
246 |
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
|
247 |
|
74 | 248 |
StepTicks:= cHHStepTicks; |
610 | 249 |
if PrevdX <> hwSign(Gear^.dX) then |
250 |
begin |
|
251 |
FollowGear:= Gear; |
|
252 |
exit |
|
253 |
end; |
|
254 |
DeleteCI(Gear); // must be after exit!! (see previous line) |
|
838 | 255 |
|
351 | 256 |
PHedgehog(Gear^.Hedgehog)^.visStepPos:= (PHedgehog(Gear^.Hedgehog)^.visStepPos + 1) and 7; |
257 |
if TestCollisionXwithGear(Gear, hwSign(Gear^.dX)) then |
|
4 | 258 |
begin |
498 | 259 |
if not (TestCollisionXwithXYShift(Gear, _0, -6, hwSign(Gear^.dX)) |
260 |
or TestCollisionYwithGear(Gear, -1)) then Gear^.Y:= Gear^.Y - _1; |
|
261 |
if not (TestCollisionXwithXYShift(Gear, _0, -5, hwSign(Gear^.dX)) |
|
262 |
or TestCollisionYwithGear(Gear, -1)) then Gear^.Y:= Gear^.Y - _1; |
|
263 |
if not (TestCollisionXwithXYShift(Gear, _0, -4, hwSign(Gear^.dX)) |
|
264 |
or TestCollisionYwithGear(Gear, -1)) then Gear^.Y:= Gear^.Y - _1; |
|
265 |
if not (TestCollisionXwithXYShift(Gear, _0, -3, hwSign(Gear^.dX)) |
|
266 |
or TestCollisionYwithGear(Gear, -1)) then Gear^.Y:= Gear^.Y - _1; |
|
267 |
if not (TestCollisionXwithXYShift(Gear, _0, -2, hwSign(Gear^.dX)) |
|
268 |
or TestCollisionYwithGear(Gear, -1)) then Gear^.Y:= Gear^.Y - _1; |
|
269 |
if not (TestCollisionXwithXYShift(Gear, _0, -1, hwSign(Gear^.dX)) |
|
270 |
or TestCollisionYwithGear(Gear, -1)) then Gear^.Y:= Gear^.Y - _1; |
|
4 | 271 |
end; |
498 | 272 |
if not TestCollisionXwithGear(Gear, hwSign(Gear^.dX)) then Gear^.X:= Gear^.X + SignAs(_1, Gear^.dX); |
300 | 273 |
|
62 | 274 |
SetAllHHToActive; |
37 | 275 |
|
68 | 276 |
if not TestCollisionYwithGear(Gear, 1) then |
4 | 277 |
begin |
498 | 278 |
Gear^.Y:= Gear^.Y + _1; |
68 | 279 |
if not TestCollisionYwithGear(Gear, 1) then |
4 | 280 |
begin |
498 | 281 |
Gear^.Y:= Gear^.Y + _1; |
68 | 282 |
if not TestCollisionYwithGear(Gear, 1) then |
4 | 283 |
begin |
498 | 284 |
Gear^.Y:= Gear^.Y + _1; |
68 | 285 |
if not TestCollisionYwithGear(Gear, 1) then |
4 | 286 |
begin |
498 | 287 |
Gear^.Y:= Gear^.Y + _1; |
68 | 288 |
if not TestCollisionYwithGear(Gear, 1) then |
4 | 289 |
begin |
498 | 290 |
Gear^.Y:= Gear^.Y + _1; |
68 | 291 |
if not TestCollisionYwithGear(Gear, 1) then |
4 | 292 |
begin |
498 | 293 |
Gear^.Y:= Gear^.Y + _1; |
68 | 294 |
if not TestCollisionYwithGear(Gear, 1) then |
4 | 295 |
begin |
498 | 296 |
Gear^.Y:= Gear^.Y - _6; |
297 |
Gear^.dY:= _0; |
|
542 | 298 |
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
|
299 |
exit |
4 | 300 |
end; |
301 |
end |
|
302 |
end |
|
303 |
end |
|
304 |
end |
|
305 |
end |
|
505
fcba7d7aea0d
Fix old bug with grenade(bomd, etc..) not colliding with attacking hedgehog
unc0rr
parents:
498
diff
changeset
|
306 |
end; |
fcba7d7aea0d
Fix old bug with grenade(bomd, etc..) not colliding with attacking hedgehog
unc0rr
parents:
498
diff
changeset
|
307 |
AddGearCI(Gear) |
4 | 308 |
end |
309 |
end; |
|
310 |
||
303
1659c4aad5ab
Now blow torch angle can be changed during blowing :)
unc0rr
parents:
302
diff
changeset
|
311 |
procedure HedgehogChAngle(Gear: PGear); |
1659c4aad5ab
Now blow torch angle can be changed during blowing :)
unc0rr
parents:
302
diff
changeset
|
312 |
begin |
542 | 313 |
if ((Gear^.State and gstMoving) = 0) then |
351 | 314 |
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
|
315 |
else else |
351 | 316 |
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
|
317 |
end; |
1659c4aad5ab
Now blow torch angle can be changed during blowing :)
unc0rr
parents:
302
diff
changeset
|
318 |
|
302 | 319 |
procedure doStepHedgehog(Gear: PGear); forward; |
320 |
//////////////////////////////////////////////////////////////////////////////// |
|
538 | 321 |
procedure doStepHedgehogMoving(Gear: PGear); |
545 | 322 |
var isFalling: boolean; |
538 | 323 |
begin |
542 | 324 |
isFalling:= not TestCollisionYKick(Gear, 1); |
325 |
if isFalling then |
|
538 | 326 |
begin |
327 |
if (Gear^.dY.isNegative) and TestCollisionYKick(Gear, -1) then Gear^.dY:= _0; |
|
542 | 328 |
Gear^.State:= Gear^.State or gstMoving; |
538 | 329 |
Gear^.dY:= Gear^.dY + cGravity |
330 |
end else |
|
331 |
begin |
|
332 |
if ((hwAbs(Gear^.dX) + hwAbs(Gear^.dY)) < _0_55) |
|
333 |
and ((Gear^.State and gstHHJumping) <> 0) then SetLittle(Gear^.dX); |
|
334 |
||
540 | 335 |
if not Gear^.dY.isNegative then |
336 |
begin |
|
337 |
CheckHHDamage(Gear); |
|
790
a6f442173822
Make high jump behaviour like in worms (back somersault)
unc0rr
parents:
783
diff
changeset
|
338 |
|
a6f442173822
Make high jump behaviour like in worms (back somersault)
unc0rr
parents:
783
diff
changeset
|
339 |
if ((Gear^.State and gstHHHJump) <> 0) and |
a6f442173822
Make high jump behaviour like in worms (back somersault)
unc0rr
parents:
783
diff
changeset
|
340 |
(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
|
341 |
|
542 | 342 |
Gear^.State:= Gear^.State and not (gstHHJumping or gstHHHJump); |
540 | 343 |
Gear^.dY:= _0; |
344 |
end else Gear^.dY:= Gear^.dY + cGravity; |
|
538 | 345 |
|
346 |
if ((Gear^.State and gstMoving) <> 0) then Gear^.dX:= Gear^.dX * Gear^.Friction |
|
347 |
end; |
|
348 |
||
349 |
if (Gear^.State <> 0) then DeleteCI(Gear); |
|
783 | 350 |
|
538 | 351 |
if (Gear^.State and gstMoving) <> 0 then |
352 |
if TestCollisionXKick(Gear, hwSign(Gear^.dX)) then |
|
542 | 353 |
if not isFalling then |
538 | 354 |
if hwAbs(Gear^.dX) > _0_01 then |
355 |
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 |
|
356 |
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 |
|
357 |
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 |
|
358 |
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 |
|
359 |
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 |
|
360 |
if hwAbs(Gear^.dX) > _0_02 then Gear^.dX:= -Gear^.Elasticity * Gear^.dX |
|
361 |
else begin |
|
362 |
Gear^.State:= Gear^.State and not gstMoving; |
|
363 |
SetLittle(Gear^.dX) |
|
364 |
end |
|
365 |
else begin |
|
366 |
Gear^.State:= Gear^.State and not gstMoving; |
|
367 |
SetLittle(Gear^.dX) |
|
368 |
end |
|
369 |
else if hwAbs(Gear^.dX) > cLittle then Gear^.dX:= -Gear^.Elasticity * Gear^.dX |
|
370 |
else SetLittle(Gear^.dX); |
|
371 |
||
542 | 372 |
if (not isFalling) and |
538 | 373 |
(hwAbs(Gear^.dX) + hwAbs(Gear^.dY) < _0_03) then |
374 |
begin |
|
375 |
Gear^.State:= Gear^.State and not gstMoving; |
|
376 |
SetLittle(Gear^.dX); |
|
377 |
Gear^.dY:= _0 |
|
378 |
end else Gear^.State:= Gear^.State or gstMoving; |
|
379 |
||
380 |
if (Gear^.State and gstMoving) <> 0 then |
|
381 |
begin |
|
382 |
Gear^.State:= Gear^.State and not gstAnimation; |
|
383 |
Gear^.X:= Gear^.X + Gear^.dX; |
|
384 |
Gear^.Y:= Gear^.Y + Gear^.dY; |
|
385 |
if (not Gear^.dY.isNegative) and |
|
386 |
(not TestCollisionYKick(Gear, 1)) and |
|
387 |
TestCollisionYwithXYShift(Gear, 0, 1, 1) then |
|
388 |
begin |
|
389 |
CheckHHDamage(Gear); |
|
390 |
Gear^.dY:= _0; |
|
391 |
Gear^.Y:= Gear^.Y + _1 |
|
392 |
end; |
|
393 |
CheckGearDrowning(Gear) |
|
394 |
end |
|
395 |
end; |
|
396 |
||
302 | 397 |
procedure doStepHedgehogDriven(Gear: PGear); |
398 |
var t: PGear; |
|
399 |
begin |
|
558
b2b840eeb10a
Fix bug when hedgehog moves not right after it is kicked
unc0rr
parents:
553
diff
changeset
|
400 |
if not isInMultiShoot then |
b2b840eeb10a
Fix bug when hedgehog moves not right after it is kicked
unc0rr
parents:
553
diff
changeset
|
401 |
AllInactive:= false |
b2b840eeb10a
Fix bug when hedgehog moves not right after it is kicked
unc0rr
parents:
553
diff
changeset
|
402 |
else |
b2b840eeb10a
Fix bug when hedgehog moves not right after it is kicked
unc0rr
parents:
553
diff
changeset
|
403 |
Gear^.Message:= 0; |
505
fcba7d7aea0d
Fix old bug with grenade(bomd, etc..) not colliding with attacking hedgehog
unc0rr
parents:
498
diff
changeset
|
404 |
|
351 | 405 |
if (TurnTimeLeft = 0) or (Gear^.Damage > 0) then |
302 | 406 |
begin |
407 |
TurnTimeLeft:= 0; |
|
351 | 408 |
Gear^.State:= Gear^.State and not gstHHDriven; |
409 |
if Gear^.Damage > 0 then |
|
424 | 410 |
Gear^.State:= Gear^.State and not (gstHHJumping or gstHHHJump); |
302 | 411 |
exit |
412 |
end; |
|
542 | 413 |
|
836 | 414 |
if ((Gear^.State and gstMoving) <> 0) |
415 |
or (StepTicks = cHHStepTicks) |
|
835
6f567934cc44
Automatically use parachute when vertical speed is high enough
unc0rr
parents:
829
diff
changeset
|
416 |
or (CurAmmoGear <> nil) then // we're moving |
836 | 417 |
begin |
839 | 418 |
with PHedgehog(Gear^.Hedgehog)^ do |
419 |
if (CurAmmoGear = nil) |
|
420 |
and (Gear^.dY > _0_39) |
|
421 |
and (Ammo^[CurSlot, CurAmmo].AmmoType = amParachute) then Gear^.Message:= Gear^.Message or gm_Attack; |
|
836 | 422 |
// check for case with ammo |
423 |
t:= CheckGearNear(Gear, gtCase, 36, 36); |
|
424 |
if t <> nil then |
|
425 |
PickUp(Gear, t) |
|
839 | 426 |
end; |
302 | 427 |
|
428 |
if CurAmmoGear <> nil then |
|
429 |
begin |
|
351 | 430 |
CurAmmoGear^.Message:= Gear^.Message; |
302 | 431 |
exit |
432 |
end; |
|
433 |
||
783 | 434 |
if ((Gear^.Message and gm_Slot) <> 0) then ChangeAmmo(Gear); |
435 |
||
436 |
if ((Gear^.Message and gm_Weapon) <> 0) then HHSetWeapon(Gear); |
|
437 |
||
351 | 438 |
if ((Gear^.Message and gm_Attack) <> 0) or |
542 | 439 |
((Gear^.State and gstAttacking) <> 0) then Attack(Gear); |
302 | 440 |
|
542 | 441 |
if (Gear^.State and gstMoving) <> 0 then |
302 | 442 |
begin |
424 | 443 |
if ((Gear^.Message and gm_HJump) <> 0) and |
444 |
((Gear^.State and gstHHJumping) <> 0) and |
|
445 |
((Gear^.State and gstHHHJump) = 0) then |
|
446 |
if (not (hwAbs(Gear^.dX) > cLittle)) and (Gear^.dY < -_0_02) then |
|
302 | 447 |
begin |
542 | 448 |
Gear^.State:= Gear^.State or gstHHHJump or gstMoving; |
351 | 449 |
Gear^.dY:= -_0_25; |
799 | 450 |
Gear^.dX:= -SignAs(_0_02, Gear^.dX); |
451 |
PlaySound(sndJump2, false) |
|
302 | 452 |
end; |
351 | 453 |
Gear^.Message:= Gear^.Message and not (gm_LJump or gm_HJump); |
538 | 454 |
|
455 |
if ((Gear^.State and gstHHJumping) <> 0) and |
|
456 |
TestCollisionXwithGear(Gear, hwSign(Gear^.dX)) then SetLittle(Gear^.dX); |
|
457 |
||
458 |
doStepHedgehogMoving(Gear); |
|
542 | 459 |
|
460 |
if (Gear^.State and gstMoving) = 0 then |
|
302 | 461 |
begin |
505
fcba7d7aea0d
Fix old bug with grenade(bomd, etc..) not colliding with attacking hedgehog
unc0rr
parents:
498
diff
changeset
|
462 |
AddGearCI(Gear); |
542 | 463 |
StepTicks:= 350 |
302 | 464 |
end; |
465 |
exit |
|
538 | 466 |
end; |
302 | 467 |
|
558
b2b840eeb10a
Fix bug when hedgehog moves not right after it is kicked
unc0rr
parents:
553
diff
changeset
|
468 |
if not isInMultiShoot then |
b2b840eeb10a
Fix bug when hedgehog moves not right after it is kicked
unc0rr
parents:
553
diff
changeset
|
469 |
begin |
b2b840eeb10a
Fix bug when hedgehog moves not right after it is kicked
unc0rr
parents:
553
diff
changeset
|
470 |
HedgehogChAngle(Gear); |
b2b840eeb10a
Fix bug when hedgehog moves not right after it is kicked
unc0rr
parents:
553
diff
changeset
|
471 |
if StepTicks > 0 then dec(StepTicks); |
b2b840eeb10a
Fix bug when hedgehog moves not right after it is kicked
unc0rr
parents:
553
diff
changeset
|
472 |
if (StepTicks = 0) then HedgehogStep(Gear) |
b2b840eeb10a
Fix bug when hedgehog moves not right after it is kicked
unc0rr
parents:
553
diff
changeset
|
473 |
end |
302 | 474 |
end; |
475 |
||
4 | 476 |
//////////////////////////////////////////////////////////////////////////////// |
477 |
procedure doStepHedgehogFree(Gear: PGear); |
|
511 | 478 |
var prevState: Longword; |
4 | 479 |
begin |
511 | 480 |
prevState:= Gear^.State; |
4 | 481 |
|
538 | 482 |
doStepHedgehogMoving(Gear); |
4 | 483 |
|
538 | 484 |
if (Gear^.State and gstMoving) = 0 then |
351 | 485 |
if Gear^.Health = 0 then |
4 | 486 |
begin |
487 |
if AllInactive then |
|
488 |
begin |
|
522 | 489 |
Gear^.State:= Gear^.State or gstNoDamage; |
351 | 490 |
doMakeExplosion(hwRound(Gear^.X), hwRound(Gear^.Y), 30, EXPLAutoSound); |
498 | 491 |
AddGear(hwRound(Gear^.X), hwRound(Gear^.Y), gtGrave, 0, _0, _0, 0)^.Hedgehog:= Gear^.Hedgehog; |
4 | 492 |
DeleteGear(Gear); |
493 |
SetAllToActive |
|
494 |
end; |
|
351 | 495 |
AllInactive:= false; |
4 | 496 |
exit |
497 |
end; |
|
498 |
||
499 |
AllInactive:= false; |
|
500 |
||
538 | 501 |
if ((Gear^.State and gstMoving) = 0) then |
511 | 502 |
if ((Gear^.State and gstAnimation) = 0) and |
503 |
(prevState <> Gear^.State) then |
|
4 | 504 |
begin |
511 | 505 |
Gear^.State:= gstAnimation; |
506 |
Gear^.Timer:= 150 |
|
507 |
end else |
|
508 |
begin |
|
509 |
if Gear^.Timer = 0 then |
|
510 |
begin |
|
511 |
Gear^.State:= 0; |
|
512 |
Gear^.Active:= false; |
|
513 |
AddGearCI(Gear); |
|
514 |
exit |
|
515 |
end else dec(Gear^.Timer) |
|
4 | 516 |
end |
517 |
end; |
|
518 |
||
519 |
//////////////////////////////////////////////////////////////////////////////// |
|
520 |
procedure doStepHedgehog(Gear: PGear); |
|
521 |
begin |
|
351 | 522 |
if (Gear^.Message and gm_Destroy) <> 0 then |
4 | 523 |
begin |
524 |
DeleteGear(Gear); |
|
525 |
exit |
|
526 |
end; |
|
351 | 527 |
if (Gear^.State and gstHHDriven) = 0 then doStepHedgehogFree(Gear) |
511 | 528 |
else doStepHedgehogDriven(Gear) |
4 | 529 |
end; |