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