author | unc0rr |
Sun, 03 Jun 2007 17:21:57 +0000 | |
changeset 534 | 92fb2b0d5117 |
parent 528 | 54fd6924de4e |
child 538 | 74219eadab5e |
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 |
//////////////////////////////////////////////////////////////////////////////// |
32
78bff13b11c0
With this patch the game doesn't crash when gaming by net
unc0rr
parents:
16
diff
changeset
|
20 |
procedure Attack(Gear: PGear); |
351 | 21 |
var xx, yy: hwFloat; |
32
78bff13b11c0
With this patch the game doesn't crash when gaming by net
unc0rr
parents:
16
diff
changeset
|
22 |
begin |
78bff13b11c0
With this patch the game doesn't crash when gaming by net
unc0rr
parents:
16
diff
changeset
|
23 |
with Gear^, |
351 | 24 |
PHedgehog(Gear^.Hedgehog)^ do |
32
78bff13b11c0
With this patch the game doesn't crash when gaming by net
unc0rr
parents:
16
diff
changeset
|
25 |
begin |
95 | 26 |
if ((State and gstHHDriven) <> 0)and |
27 |
// (((State and gstAttacking) <> 0) or ((Message and gm_Attack) <> 0))and |
|
32
78bff13b11c0
With this patch the game doesn't crash when gaming by net
unc0rr
parents:
16
diff
changeset
|
28 |
((State and (gstAttacked or gstMoving or gstHHChooseTarget)) = 0)and |
351 | 29 |
(((State and gstFalling ) = 0)or((Ammo^[CurSlot, CurAmmo].Propz and ammoprop_AttackInFall) <> 0))and |
30 |
(((State and gstHHJumping) = 0)or((Ammo^[CurSlot, CurAmmo].Propz and ammoprop_AttackInJump) <> 0))and |
|
31 |
((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
|
32 |
begin |
95 | 33 |
State:= State or gstAttacking; |
34 |
if Power = cMaxPower then Message:= Message and not gm_Attack |
|
351 | 35 |
else if (Ammo^[CurSlot, CurAmmo].Propz and ammoprop_Power) = 0 then Message:= Message and not gm_Attack |
95 | 36 |
else begin |
37 |
if Power = 0 then |
|
38 |
begin |
|
351 | 39 |
AttackBar:= CurrentTeam^.AttackBar; |
40 |
PlaySound(sndThrowPowerUp, false) |
|
95 | 41 |
end; |
42 |
inc(Power) |
|
43 |
end; |
|
44 |
if ((Message and gm_Attack) <> 0) then exit; |
|
351 | 45 |
|
46 |
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
|
47 |
begin |
282 | 48 |
StopSound(sndThrowPowerUp); |
351 | 49 |
PlaySound(sndThrowRelease, false); |
32
78bff13b11c0
With this patch the game doesn't crash when gaming by net
unc0rr
parents:
16
diff
changeset
|
50 |
end; |
519 | 51 |
xx:= SignAs(AngleSin(Angle), dX); |
351 | 52 |
yy:= -AngleCos(Angle); |
53 |
case Ammo^[CurSlot, CurAmmo].AmmoType of |
|
54 |
amGrenade: FollowGear:= AddGear(hwRound(X), hwRound(Y), gtAmmo_Bomb, 0, xx*Power/cPowerDivisor, yy*Power/cPowerDivisor, Ammo^[CurSlot, CurAmmo].Timer); |
|
55 |
amClusterBomb: FollowGear:= AddGear(hwRound(X), hwRound(Y), gtClusterBomb, 0, xx*Power/cPowerDivisor, yy*Power/cPowerDivisor, Ammo^[CurSlot, CurAmmo].Timer); |
|
56 |
amBazooka: FollowGear:= AddGear(hwRound(X), hwRound(Y), gtAmmo_Grenade, 0, xx*Power/cPowerDivisor, yy*Power/cPowerDivisor, 0); |
|
57 |
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
|
58 |
amShotgun: begin |
351 | 59 |
PlaySound(sndShotgunReload, false); |
60 |
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
|
61 |
end; |
498 | 62 |
amPickHammer: CurAmmoGear:= AddGear(hwRound(Gear^.X), hwRound(Gear^.Y) + cHHRadius, gtPickHammer, 0, _0, _0, 0); |
78 | 63 |
amSkip: TurnTimeLeft:= 0; |
351 | 64 |
amRope: CurAmmoGear:= AddGear(hwRound(Gear^.X), hwRound(Gear^.Y), gtRope, 0, xx, yy, 0); |
498 | 65 |
amMine: AddGear(hwRound(X) + hwSign(dX) * 7, hwRound(Y), gtMine, 0, SignAs(_0_02, dX), _0, 3000); |
518 | 66 |
amDEagle: AddGear(hwRound(X + xx * cHHRadius), hwRound(Y + yy * cHHRadius), gtDEagleShot, 0, xx * _0_5, yy * _0_5, 0); |
498 | 67 |
amDynamite: AddGear(hwRound(X) + hwSign(dX) * 7, hwRound(Y), gtDynamite, 0, SignAs(_0_03, dX), _0, 5000); |
351 | 68 |
amBaseballBat: AddGear(hwRound(X) + hwSign(dX) * 10, hwRound(Y), gtShover, 0, xx * _0_5, yy * _0_5, 0)^.Radius:= 20; |
498 | 69 |
amFirePunch: CurAmmoGear:= AddGear(hwRound(X) + hwSign(dX) * 10, hwRound(Y), gtFirePunch, 0, _0, _0, 0); |
70 |
amParachute: CurAmmoGear:= AddGear(hwRound(X), hwRound(Y), gtParachute, 0, _0, _0, 0); |
|
71 |
amAirAttack: AddGear(Ammo^[CurSlot, CurAmmo].Pos, 0, gtAirAttack, 0, _0, _0, 0); |
|
72 |
amMineStrike: AddGear(Ammo^[CurSlot, CurAmmo].Pos, 0, gtAirAttack, 1, _0, _0, 0); |
|
73 |
amBlowTorch: CurAmmoGear:= AddGear(hwRound(X), hwRound(Y), gtBlowTorch, 0, SignAs(_0_5, dX), _0, 0); |
|
74 |
amGirder: CurAmmoGear:= AddGear(0, 0, gtGirder, Ammo^[CurSlot, CurAmmo].Pos, _0, _0, 0); |
|
520 | 75 |
amTeleport: CurAmmoGear:= AddGear(0, 0, gtTeleport, 0, _0, _0, 0); |
534 | 76 |
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
|
77 |
end; |
78bff13b11c0
With this patch the game doesn't crash when gaming by net
unc0rr
parents:
16
diff
changeset
|
78 |
Power:= 0; |
78bff13b11c0
With this patch the game doesn't crash when gaming by net
unc0rr
parents:
16
diff
changeset
|
79 |
if CurAmmoGear <> nil then |
78bff13b11c0
With this patch the game doesn't crash when gaming by net
unc0rr
parents:
16
diff
changeset
|
80 |
begin |
82 | 81 |
Message:= Message or gm_Attack; |
351 | 82 |
CurAmmoGear^.Message:= Message |
82 | 83 |
end else begin |
351 | 84 |
if not CurrentTeam^.ExtDriven and |
85 |
((Ammo^[CurSlot, CurAmmo].Propz and ammoprop_Power) <> 0) then SendIPC('a'); |
|
82 | 86 |
AfterAttack |
87 |
end |
|
95 | 88 |
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
|
89 |
end |
78bff13b11c0
With this patch the game doesn't crash when gaming by net
unc0rr
parents:
16
diff
changeset
|
90 |
end; |
78bff13b11c0
With this patch the game doesn't crash when gaming by net
unc0rr
parents:
16
diff
changeset
|
91 |
|
78bff13b11c0
With this patch the game doesn't crash when gaming by net
unc0rr
parents:
16
diff
changeset
|
92 |
procedure AfterAttack; |
78bff13b11c0
With this patch the game doesn't crash when gaming by net
unc0rr
parents:
16
diff
changeset
|
93 |
begin |
351 | 94 |
with CurrentTeam^.Hedgehogs[CurrentTeam^.CurrHedgehog].Gear^, |
95 |
CurrentTeam^.Hedgehogs[CurrentTeam^.CurrHedgehog] do |
|
32
78bff13b11c0
With this patch the game doesn't crash when gaming by net
unc0rr
parents:
16
diff
changeset
|
96 |
begin |
78bff13b11c0
With this patch the game doesn't crash when gaming by net
unc0rr
parents:
16
diff
changeset
|
97 |
Inc(AttacksNum); |
78bff13b11c0
With this patch the game doesn't crash when gaming by net
unc0rr
parents:
16
diff
changeset
|
98 |
State:= State and not gstAttacking; |
351 | 99 |
if Ammo^[CurSlot, CurAmmo].NumPerTurn >= AttacksNum then isInMultiShoot:= true |
32
78bff13b11c0
With this patch the game doesn't crash when gaming by net
unc0rr
parents:
16
diff
changeset
|
100 |
else begin |
351 | 101 |
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
|
102 |
State:= State or gstAttacked; |
534 | 103 |
OnUsedAmmo(CurrentTeam^.Hedgehogs[CurrentTeam^.CurrHedgehog]) |
32
78bff13b11c0
With this patch the game doesn't crash when gaming by net
unc0rr
parents:
16
diff
changeset
|
104 |
end; |
95 | 105 |
AttackBar:= 0; |
32
78bff13b11c0
With this patch the game doesn't crash when gaming by net
unc0rr
parents:
16
diff
changeset
|
106 |
end |
78bff13b11c0
With this patch the game doesn't crash when gaming by net
unc0rr
parents:
16
diff
changeset
|
107 |
end; |
78bff13b11c0
With this patch the game doesn't crash when gaming by net
unc0rr
parents:
16
diff
changeset
|
108 |
|
42 | 109 |
//////////////////////////////////////////////////////////////////////////////// |
110 |
procedure PickUp(HH, Gear: PGear); |
|
295 | 111 |
var s: shortstring; |
112 |
a: TAmmoType; |
|
42 | 113 |
begin |
351 | 114 |
Gear^.Message:= gm_Destroy; |
115 |
case Gear^.Pos of |
|
295 | 116 |
posCaseAmmo: begin |
351 | 117 |
a:= TAmmoType(Gear^.State); |
118 |
AddAmmo(PHedgehog(HH^.Hedgehog), a); |
|
394
4c017ae1226a
- Implement hack to let ammo stores work without needed assistance of frontend
unc0rr
parents:
393
diff
changeset
|
119 |
s:= trammo[Ammoz[a].NameId] + '(+' + IntToStr(Ammoz[a].NumberInCase) + ')'; |
351 | 120 |
AddCaption(s, PHedgehog(HH^.Hedgehog)^.Team^.Color, capgrpAmmoinfo); |
295 | 121 |
end; |
42 | 122 |
posCaseHealth: begin |
351 | 123 |
inc(HH^.Health, Gear^.Health); |
124 |
str(Gear^.Health, s); |
|
295 | 125 |
s:= '+' + s; |
351 | 126 |
AddCaption(s, PHedgehog(HH^.Hedgehog)^.Team^.Color, capgrpAmmoinfo); |
127 |
RenderHealth(PHedgehog(HH^.Hedgehog)^); |
|
128 |
RecountTeamHealth(PHedgehog(HH^.Hedgehog)^.Team) |
|
42 | 129 |
end; |
435 | 130 |
end |
42 | 131 |
end; |
32
78bff13b11c0
With this patch the game doesn't crash when gaming by net
unc0rr
parents:
16
diff
changeset
|
132 |
|
4 | 133 |
const StepTicks: LongWord = 0; |
134 |
||
302 | 135 |
procedure HedgehogStep(Gear: PGear); |
371 | 136 |
var PrevdX: LongInt; |
302 | 137 |
begin |
351 | 138 |
if ((Gear^.State and (gstAttacking or gstMoving or gstFalling)) = 0) then |
4 | 139 |
begin |
408 | 140 |
if isCursorVisible then |
141 |
with PHedgehog(Gear^.Hedgehog)^ do |
|
142 |
with Ammo^[CurSlot, CurAmmo] do |
|
143 |
begin |
|
144 |
if (Gear^.Message and gm_Left )<>0 then |
|
145 |
Pos:= (Pos + Ammoz[AmmoType].PosCount - 1) mod Ammoz[AmmoType].PosCount |
|
146 |
else |
|
147 |
if (Gear^.Message and gm_Right )<>0 then |
|
148 |
Pos:= (Pos + 1) mod Ammoz[AmmoType].PosCount |
|
149 |
else exit; |
|
423 | 150 |
StepTicks:= 200; |
408 | 151 |
exit |
152 |
end; |
|
505
fcba7d7aea0d
Fix old bug with grenade(bomd, etc..) not colliding with attacking hedgehog
unc0rr
parents:
498
diff
changeset
|
153 |
|
351 | 154 |
if ((Gear^.Message and gm_LJump ) <> 0) then |
4 | 155 |
begin |
351 | 156 |
Gear^.Message:= 0; |
505
fcba7d7aea0d
Fix old bug with grenade(bomd, etc..) not colliding with attacking hedgehog
unc0rr
parents:
498
diff
changeset
|
157 |
DeleteCI(Gear); |
68 | 158 |
if not TestCollisionYwithGear(Gear, -1) then |
498 | 159 |
if not TestCollisionXwithXYShift(Gear, _0, -2, hwSign(Gear^.dX)) then Gear^.Y:= Gear^.Y - _2 else |
160 |
if not TestCollisionXwithXYShift(Gear, _0, -1, hwSign(Gear^.dX)) then Gear^.Y:= Gear^.Y - _1; |
|
351 | 161 |
if not (TestCollisionXwithGear(Gear, hwSign(Gear^.dX)) |
68 | 162 |
or TestCollisionYwithGear(Gear, -1)) then |
4 | 163 |
begin |
351 | 164 |
Gear^.dY:= -_0_15; |
498 | 165 |
Gear^.dX:= SignAs(_0_15, Gear^.dX); |
351 | 166 |
Gear^.State:= Gear^.State or gstFalling or gstHHJumping; |
4 | 167 |
exit |
168 |
end; |
|
169 |
end; |
|
505
fcba7d7aea0d
Fix old bug with grenade(bomd, etc..) not colliding with attacking hedgehog
unc0rr
parents:
498
diff
changeset
|
170 |
|
351 | 171 |
if ((Gear^.Message and gm_HJump ) <> 0) then |
4 | 172 |
begin |
505
fcba7d7aea0d
Fix old bug with grenade(bomd, etc..) not colliding with attacking hedgehog
unc0rr
parents:
498
diff
changeset
|
173 |
DeleteCI(Gear); |
351 | 174 |
Gear^.Message:= 0; |
68 | 175 |
if not TestCollisionYwithGear(Gear, -1) then |
4 | 176 |
begin |
351 | 177 |
Gear^.dY:= -_0_2; |
178 |
SetLittle(Gear^.dX); |
|
179 |
Gear^.State:= Gear^.State or gstFalling or gstHHJumping; |
|
4 | 180 |
exit |
181 |
end; |
|
182 |
end; |
|
505
fcba7d7aea0d
Fix old bug with grenade(bomd, etc..) not colliding with attacking hedgehog
unc0rr
parents:
498
diff
changeset
|
183 |
|
351 | 184 |
PrevdX:= hwSign(Gear^.dX); |
185 |
if (Gear^.Message and gm_Left )<>0 then Gear^.dX:= -cLittle else |
|
186 |
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
|
187 |
|
74 | 188 |
StepTicks:= cHHStepTicks; |
351 | 189 |
if PrevdX <> hwSign(Gear^.dX) then exit; |
517 | 190 |
DeleteCI(Gear); // after exit!! ^^^^ |
191 |
||
351 | 192 |
PHedgehog(Gear^.Hedgehog)^.visStepPos:= (PHedgehog(Gear^.Hedgehog)^.visStepPos + 1) and 7; |
193 |
if TestCollisionXwithGear(Gear, hwSign(Gear^.dX)) then |
|
4 | 194 |
begin |
498 | 195 |
if not (TestCollisionXwithXYShift(Gear, _0, -6, hwSign(Gear^.dX)) |
196 |
or TestCollisionYwithGear(Gear, -1)) then Gear^.Y:= Gear^.Y - _1; |
|
197 |
if not (TestCollisionXwithXYShift(Gear, _0, -5, hwSign(Gear^.dX)) |
|
198 |
or TestCollisionYwithGear(Gear, -1)) then Gear^.Y:= Gear^.Y - _1; |
|
199 |
if not (TestCollisionXwithXYShift(Gear, _0, -4, hwSign(Gear^.dX)) |
|
200 |
or TestCollisionYwithGear(Gear, -1)) then Gear^.Y:= Gear^.Y - _1; |
|
201 |
if not (TestCollisionXwithXYShift(Gear, _0, -3, hwSign(Gear^.dX)) |
|
202 |
or TestCollisionYwithGear(Gear, -1)) then Gear^.Y:= Gear^.Y - _1; |
|
203 |
if not (TestCollisionXwithXYShift(Gear, _0, -2, hwSign(Gear^.dX)) |
|
204 |
or TestCollisionYwithGear(Gear, -1)) then Gear^.Y:= Gear^.Y - _1; |
|
205 |
if not (TestCollisionXwithXYShift(Gear, _0, -1, hwSign(Gear^.dX)) |
|
206 |
or TestCollisionYwithGear(Gear, -1)) then Gear^.Y:= Gear^.Y - _1; |
|
4 | 207 |
end; |
498 | 208 |
if not TestCollisionXwithGear(Gear, hwSign(Gear^.dX)) then Gear^.X:= Gear^.X + SignAs(_1, Gear^.dX); |
300 | 209 |
|
62 | 210 |
SetAllHHToActive; |
37 | 211 |
|
68 | 212 |
if not TestCollisionYwithGear(Gear, 1) then |
4 | 213 |
begin |
498 | 214 |
Gear^.Y:= Gear^.Y + _1; |
68 | 215 |
if not TestCollisionYwithGear(Gear, 1) then |
4 | 216 |
begin |
498 | 217 |
Gear^.Y:= Gear^.Y + _1; |
68 | 218 |
if not TestCollisionYwithGear(Gear, 1) then |
4 | 219 |
begin |
498 | 220 |
Gear^.Y:= Gear^.Y + _1; |
68 | 221 |
if not TestCollisionYwithGear(Gear, 1) then |
4 | 222 |
begin |
498 | 223 |
Gear^.Y:= Gear^.Y + _1; |
68 | 224 |
if not TestCollisionYwithGear(Gear, 1) then |
4 | 225 |
begin |
498 | 226 |
Gear^.Y:= Gear^.Y + _1; |
68 | 227 |
if not TestCollisionYwithGear(Gear, 1) then |
4 | 228 |
begin |
498 | 229 |
Gear^.Y:= Gear^.Y + _1; |
68 | 230 |
if not TestCollisionYwithGear(Gear, 1) then |
4 | 231 |
begin |
498 | 232 |
Gear^.Y:= Gear^.Y - _6; |
233 |
Gear^.dY:= _0; |
|
505
fcba7d7aea0d
Fix old bug with grenade(bomd, etc..) not colliding with attacking hedgehog
unc0rr
parents:
498
diff
changeset
|
234 |
Gear^.State:= Gear^.State or gstFalling; |
fcba7d7aea0d
Fix old bug with grenade(bomd, etc..) not colliding with attacking hedgehog
unc0rr
parents:
498
diff
changeset
|
235 |
exit |
4 | 236 |
end; |
237 |
end |
|
238 |
end |
|
239 |
end |
|
240 |
end |
|
241 |
end |
|
505
fcba7d7aea0d
Fix old bug with grenade(bomd, etc..) not colliding with attacking hedgehog
unc0rr
parents:
498
diff
changeset
|
242 |
end; |
fcba7d7aea0d
Fix old bug with grenade(bomd, etc..) not colliding with attacking hedgehog
unc0rr
parents:
498
diff
changeset
|
243 |
AddGearCI(Gear) |
4 | 244 |
end |
245 |
end; |
|
246 |
||
303
1659c4aad5ab
Now blow torch angle can be changed during blowing :)
unc0rr
parents:
302
diff
changeset
|
247 |
procedure HedgehogChAngle(Gear: PGear); |
1659c4aad5ab
Now blow torch angle can be changed during blowing :)
unc0rr
parents:
302
diff
changeset
|
248 |
begin |
351 | 249 |
if ((Gear^.State and (gstMoving or gstFalling)) = 0) then |
250 |
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
|
251 |
else else |
351 | 252 |
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
|
253 |
end; |
1659c4aad5ab
Now blow torch angle can be changed during blowing :)
unc0rr
parents:
302
diff
changeset
|
254 |
|
302 | 255 |
procedure doStepHedgehog(Gear: PGear); forward; |
256 |
//////////////////////////////////////////////////////////////////////////////// |
|
257 |
procedure doStepHedgehogDriven(Gear: PGear); |
|
258 |
var t: PGear; |
|
259 |
begin |
|
351 | 260 |
if isInMultiShoot and (Gear^.Damage = 0) then |
302 | 261 |
begin |
262 |
exit |
|
263 |
end; |
|
264 |
AllInactive:= false; |
|
505
fcba7d7aea0d
Fix old bug with grenade(bomd, etc..) not colliding with attacking hedgehog
unc0rr
parents:
498
diff
changeset
|
265 |
|
351 | 266 |
if (TurnTimeLeft = 0) or (Gear^.Damage > 0) then |
302 | 267 |
begin |
268 |
TurnTimeLeft:= 0; |
|
351 | 269 |
Gear^.State:= Gear^.State and not gstHHDriven; |
270 |
if Gear^.Damage > 0 then |
|
424 | 271 |
Gear^.State:= Gear^.State and not (gstHHJumping or gstHHHJump); |
302 | 272 |
exit |
273 |
end; |
|
525 | 274 |
|
528 | 275 |
if ((Gear^.State and (gstFalling or gstMoving)) <> 0) |
276 |
or (StepTicks = cHHStepTicks) |
|
302 | 277 |
or (CurAmmoGear <> nil) then // we're moving |
278 |
begin |
|
279 |
// check for case with ammo |
|
280 |
t:= CheckGearNear(Gear, gtCase, 36, 36); |
|
281 |
if t <> nil then |
|
282 |
PickUp(Gear, t) |
|
283 |
end; |
|
284 |
||
285 |
if CurAmmoGear <> nil then |
|
286 |
begin |
|
351 | 287 |
CurAmmoGear^.Message:= Gear^.Message; |
302 | 288 |
exit |
289 |
end; |
|
290 |
||
351 | 291 |
if ((Gear^.Message and gm_Attack) <> 0) or |
292 |
((Gear^.State and gstAttacking) <> 0)then Attack(Gear); |
|
302 | 293 |
|
528 | 294 |
if (Gear^.State and (gstFalling or gstMoving)) <> 0 then |
302 | 295 |
begin |
424 | 296 |
if ((Gear^.Message and gm_HJump) <> 0) and |
297 |
((Gear^.State and gstHHJumping) <> 0) and |
|
298 |
((Gear^.State and gstHHHJump) = 0) then |
|
299 |
if (not (hwAbs(Gear^.dX) > cLittle)) and (Gear^.dY < -_0_02) then |
|
302 | 300 |
begin |
424 | 301 |
Gear^.State:= Gear^.State or gstHHHJump; |
351 | 302 |
Gear^.dY:= -_0_25; |
498 | 303 |
Gear^.dX:= SignAs(_0_02, Gear^.dX) |
302 | 304 |
end; |
351 | 305 |
Gear^.Message:= Gear^.Message and not (gm_LJump or gm_HJump); |
306 |
if TestCollisionXwithGear(Gear, hwSign(Gear^.dX)) then SetLittle(Gear^.dX); |
|
307 |
Gear^.X:= Gear^.X + Gear^.dX; |
|
308 |
Gear^.dY:= Gear^.dY + cGravity; |
|
498 | 309 |
if (Gear^.dY.isNegative)and TestCollisionYwithGear(Gear, -1) then Gear^.dY:= _0; |
351 | 310 |
Gear^.Y:= Gear^.Y + Gear^.dY; |
311 |
if (not Gear^.dY.isNegative)and TestCollisionYwithGear(Gear, 1) then |
|
302 | 312 |
begin |
313 |
CheckHHDamage(Gear); |
|
351 | 314 |
if ((hwAbs(Gear^.dX) + hwAbs(Gear^.dY)) < _0_55) |
315 |
and ((Gear^.State and gstHHJumping) <> 0) then SetLittle(Gear^.dX); |
|
424 | 316 |
Gear^.State:= Gear^.State and not (gstFalling or gstHHJumping or gstHHHJump); |
505
fcba7d7aea0d
Fix old bug with grenade(bomd, etc..) not colliding with attacking hedgehog
unc0rr
parents:
498
diff
changeset
|
317 |
AddGearCI(Gear); |
351 | 318 |
StepTicks:= 300; |
498 | 319 |
Gear^.dY:= _0 |
302 | 320 |
end; |
321 |
CheckGearDrowning(Gear); |
|
322 |
exit |
|
351 | 323 |
end ;//else if Gear^.CollIndex = High(Longword) then AddIntersectorsCR(Gear); |
302 | 324 |
|
303
1659c4aad5ab
Now blow torch angle can be changed during blowing :)
unc0rr
parents:
302
diff
changeset
|
325 |
HedgehogChAngle(Gear); |
302 | 326 |
if StepTicks > 0 then dec(StepTicks); |
327 |
if (StepTicks = 0) then HedgehogStep(Gear) |
|
328 |
end; |
|
329 |
||
4 | 330 |
//////////////////////////////////////////////////////////////////////////////// |
331 |
procedure doStepHedgehogFree(Gear: PGear); |
|
511 | 332 |
var prevState: Longword; |
4 | 333 |
begin |
511 | 334 |
prevState:= Gear^.State; |
513
69e06d710d46
Moving hedgehog could get another hedgehog moving forward
unc0rr
parents:
511
diff
changeset
|
335 |
if not TestCollisionYKick(Gear, 1) then |
4 | 336 |
begin |
513
69e06d710d46
Moving hedgehog could get another hedgehog moving forward
unc0rr
parents:
511
diff
changeset
|
337 |
if (Gear^.dY.isNegative) and TestCollisionYKick(Gear, -1) then Gear^.dY:= _0; |
351 | 338 |
Gear^.State:= Gear^.State or gstFalling or gstMoving; |
339 |
Gear^.dY:= Gear^.dY + cGravity |
|
4 | 340 |
end else begin |
341 |
CheckHHDamage(Gear); |
|
351 | 342 |
if ((hwAbs(Gear^.dX) + hwAbs(Gear^.dY)) < _0_55) |
343 |
and ((Gear^.State and gstHHJumping) <> 0) then SetLittle(Gear^.dX); |
|
344 |
Gear^.State:= Gear^.State and not (gstFalling or gstHHJumping); |
|
498 | 345 |
if Gear^.dY > _0 then Gear^.dY:= _0; |
351 | 346 |
if ((Gear^.State and gstMoving) <> 0) then Gear^.dX:= Gear^.dX * Gear^.Friction |
4 | 347 |
end; |
348 |
||
351 | 349 |
if (Gear^.State <> 0) then DeleteCI(Gear); |
4 | 350 |
|
351 | 351 |
if (Gear^.State and gstMoving) <> 0 then |
513
69e06d710d46
Moving hedgehog could get another hedgehog moving forward
unc0rr
parents:
511
diff
changeset
|
352 |
if TestCollisionXKick(Gear, hwSign(Gear^.dX)) then |
351 | 353 |
if ((Gear^.State and gstFalling) = 0) then |
354 |
if hwAbs(Gear^.dX) > _0_01 then |
|
498 | 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 |
|
351 | 360 |
if hwAbs(Gear^.dX) > _0_02 then Gear^.dX:= -Gear^.Elasticity * Gear^.dX |
4 | 361 |
else begin |
351 | 362 |
Gear^.State:= Gear^.State and not gstMoving; |
363 |
SetLittle(Gear^.dX) |
|
4 | 364 |
end |
149 | 365 |
else begin |
351 | 366 |
Gear^.State:= Gear^.State and not gstMoving; |
367 |
SetLittle(Gear^.dX) |
|
149 | 368 |
end |
351 | 369 |
else Gear^.dX:= -Gear^.Elasticity * Gear^.dX; |
4 | 370 |
|
351 | 371 |
if ((Gear^.State and gstFalling) = 0)and |
372 |
(hwAbs(Gear^.dX) + hwAbs(Gear^.dY) < _0_03) then |
|
4 | 373 |
begin |
351 | 374 |
Gear^.State:= Gear^.State and not gstMoving; |
375 |
SetLittle(Gear^.dX); |
|
498 | 376 |
Gear^.dY:= _0 |
351 | 377 |
end else Gear^.State:= Gear^.State or gstMoving; |
4 | 378 |
|
351 | 379 |
if (Gear^.State and gstMoving) <> 0 then |
4 | 380 |
begin |
511 | 381 |
Gear^.State:= Gear^.State and not gstAnimation; |
351 | 382 |
Gear^.X:= Gear^.X + Gear^.dX; |
383 |
Gear^.Y:= Gear^.Y + Gear^.dY; |
|
513
69e06d710d46
Moving hedgehog could get another hedgehog moving forward
unc0rr
parents:
511
diff
changeset
|
384 |
if (not Gear^.dY.isNegative) and |
69e06d710d46
Moving hedgehog could get another hedgehog moving forward
unc0rr
parents:
511
diff
changeset
|
385 |
(not TestCollisionYKick(Gear, 1)) and |
69e06d710d46
Moving hedgehog could get another hedgehog moving forward
unc0rr
parents:
511
diff
changeset
|
386 |
TestCollisionYwithXYShift(Gear, 0, 1, 1) then |
74 | 387 |
begin |
82 | 388 |
CheckHHDamage(Gear); |
498 | 389 |
Gear^.dY:= _0; |
390 |
Gear^.Y:= Gear^.Y + _1 |
|
74 | 391 |
end; |
4 | 392 |
end else |
351 | 393 |
if Gear^.Health = 0 then |
4 | 394 |
begin |
395 |
if AllInactive then |
|
396 |
begin |
|
522 | 397 |
Gear^.State:= Gear^.State or gstNoDamage; |
351 | 398 |
doMakeExplosion(hwRound(Gear^.X), hwRound(Gear^.Y), 30, EXPLAutoSound); |
498 | 399 |
AddGear(hwRound(Gear^.X), hwRound(Gear^.Y), gtGrave, 0, _0, _0, 0)^.Hedgehog:= Gear^.Hedgehog; |
4 | 400 |
DeleteGear(Gear); |
401 |
SetAllToActive |
|
402 |
end; |
|
351 | 403 |
AllInactive:= false; |
4 | 404 |
exit |
405 |
end; |
|
406 |
||
407 |
AllInactive:= false; |
|
408 |
||
409 |
if (not CheckGearDrowning(Gear)) and |
|
351 | 410 |
((Gear^.State and gstMoving) = 0) then |
511 | 411 |
if ((Gear^.State and gstAnimation) = 0) and |
412 |
(prevState <> Gear^.State) then |
|
4 | 413 |
begin |
511 | 414 |
Gear^.State:= gstAnimation; |
415 |
Gear^.Timer:= 150 |
|
416 |
end else |
|
417 |
begin |
|
418 |
if Gear^.Timer = 0 then |
|
419 |
begin |
|
420 |
Gear^.State:= 0; |
|
421 |
Gear^.Active:= false; |
|
422 |
AddGearCI(Gear); |
|
423 |
exit |
|
424 |
end else dec(Gear^.Timer) |
|
4 | 425 |
end |
426 |
end; |
|
427 |
||
428 |
//////////////////////////////////////////////////////////////////////////////// |
|
429 |
procedure doStepHedgehog(Gear: PGear); |
|
430 |
begin |
|
351 | 431 |
if (Gear^.Message and gm_Destroy) <> 0 then |
4 | 432 |
begin |
433 |
DeleteGear(Gear); |
|
434 |
exit |
|
435 |
end; |
|
351 | 436 |
if (Gear^.State and gstHHDriven) = 0 then doStepHedgehogFree(Gear) |
511 | 437 |
else doStepHedgehogDriven(Gear) |
4 | 438 |
end; |