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