author | unc0rr |
Sun, 11 Feb 2007 19:38:26 +0000 | |
changeset 434 | 2c6ccce17f39 |
parent 424 | 4598c21bb421 |
child 435 | 25820c10c849 |
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; |
351 | 51 |
xx:= AngleSin(Angle); |
52 |
xx.isNegative:= dX.isNegative; |
|
53 |
yy:= -AngleCos(Angle); |
|
54 |
case Ammo^[CurSlot, CurAmmo].AmmoType of |
|
55 |
amGrenade: FollowGear:= AddGear(hwRound(X), hwRound(Y), gtAmmo_Bomb, 0, xx*Power/cPowerDivisor, yy*Power/cPowerDivisor, Ammo^[CurSlot, CurAmmo].Timer); |
|
56 |
amClusterBomb: FollowGear:= AddGear(hwRound(X), hwRound(Y), gtClusterBomb, 0, xx*Power/cPowerDivisor, yy*Power/cPowerDivisor, Ammo^[CurSlot, CurAmmo].Timer); |
|
57 |
amBazooka: FollowGear:= AddGear(hwRound(X), hwRound(Y), gtAmmo_Grenade, 0, xx*Power/cPowerDivisor, yy*Power/cPowerDivisor, 0); |
|
58 |
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
|
59 |
amShotgun: begin |
351 | 60 |
PlaySound(sndShotgunReload, false); |
61 |
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
|
62 |
end; |
351 | 63 |
amPickHammer: CurAmmoGear:= AddGear(hwRound(Gear^.X), hwRound(Gear^.Y) + cHHRadius, gtPickHammer, 0, 0, 0, 0); |
78 | 64 |
amSkip: TurnTimeLeft:= 0; |
351 | 65 |
amRope: CurAmmoGear:= AddGear(hwRound(Gear^.X), hwRound(Gear^.Y), gtRope, 0, xx, yy, 0); |
66 |
amMine: AddGear(hwRound(X) + hwSign(dX) * 7, hwRound(Y), gtMine, 0, hwSign(dX) * _0_02, 0, 3000); |
|
67 |
amDEagle: AddGear(hwRound(X), hwRound(Y), gtDEagleShot, 0, xx * _0_5, yy * _0_5, 0); |
|
68 |
amDynamite: AddGear(hwRound(X) + hwSign(dX) * 7, hwRound(Y), gtDynamite, 0, hwSign(dX) * _0_03, 0, 5000); |
|
69 |
amBaseballBat: AddGear(hwRound(X) + hwSign(dX) * 10, hwRound(Y), gtShover, 0, xx * _0_5, yy * _0_5, 0)^.Radius:= 20; |
|
70 |
amFirePunch: CurAmmoGear:= AddGear(hwRound(X) + hwSign(dX) * 10, hwRound(Y), gtFirePunch, 0, 0, 0, 0); |
|
71 |
amParachute: CurAmmoGear:= AddGear(hwRound(X), hwRound(Y), gtParachute, 0, 0, 0, 0); |
|
408 | 72 |
amAirAttack: AddGear(Ammo^[CurSlot, CurAmmo].Pos, 0, gtAirAttack, 0, 0, 0, 0); |
73 |
amMineStrike: AddGear(Ammo^[CurSlot, CurAmmo].Pos, 0, gtAirAttack, 1, 0, 0, 0); |
|
351 | 74 |
amBlowTorch: CurAmmoGear:= AddGear(hwRound(Gear^.X), hwRound(Gear^.Y), gtBlowTorch, 0, hwSign(Gear^.dX) * _0_5, 0, 0); |
409 | 75 |
amGirder: CurAmmoGear:= AddGear(0, 0, gtGirder, Ammo^[CurSlot, CurAmmo].Pos, 0, 0, 0); |
32
78bff13b11c0
With this patch the game doesn't crash when gaming by net
unc0rr
parents:
16
diff
changeset
|
76 |
end; |
78bff13b11c0
With this patch the game doesn't crash when gaming by net
unc0rr
parents:
16
diff
changeset
|
77 |
Power:= 0; |
78bff13b11c0
With this patch the game doesn't crash when gaming by net
unc0rr
parents:
16
diff
changeset
|
78 |
if CurAmmoGear <> nil then |
78bff13b11c0
With this patch the game doesn't crash when gaming by net
unc0rr
parents:
16
diff
changeset
|
79 |
begin |
82 | 80 |
Message:= Message or gm_Attack; |
351 | 81 |
CurAmmoGear^.Message:= Message |
82 | 82 |
end else begin |
351 | 83 |
if not CurrentTeam^.ExtDriven and |
84 |
((Ammo^[CurSlot, CurAmmo].Propz and ammoprop_Power) <> 0) then SendIPC('a'); |
|
82 | 85 |
AfterAttack |
86 |
end |
|
95 | 87 |
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
|
88 |
end |
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 |
|
78bff13b11c0
With this patch the game doesn't crash when gaming by net
unc0rr
parents:
16
diff
changeset
|
91 |
procedure AfterAttack; |
78bff13b11c0
With this patch the game doesn't crash when gaming by net
unc0rr
parents:
16
diff
changeset
|
92 |
begin |
351 | 93 |
with CurrentTeam^.Hedgehogs[CurrentTeam^.CurrHedgehog].Gear^, |
94 |
CurrentTeam^.Hedgehogs[CurrentTeam^.CurrHedgehog] do |
|
32
78bff13b11c0
With this patch the game doesn't crash when gaming by net
unc0rr
parents:
16
diff
changeset
|
95 |
begin |
78bff13b11c0
With this patch the game doesn't crash when gaming by net
unc0rr
parents:
16
diff
changeset
|
96 |
Inc(AttacksNum); |
78bff13b11c0
With this patch the game doesn't crash when gaming by net
unc0rr
parents:
16
diff
changeset
|
97 |
State:= State and not gstAttacking; |
351 | 98 |
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
|
99 |
else begin |
351 | 100 |
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
|
101 |
State:= State or gstAttacked; |
78bff13b11c0
With this patch the game doesn't crash when gaming by net
unc0rr
parents:
16
diff
changeset
|
102 |
OnUsedAmmo(Ammo) |
78bff13b11c0
With this patch the game doesn't crash when gaming by net
unc0rr
parents:
16
diff
changeset
|
103 |
end; |
95 | 104 |
AttackBar:= 0; |
32
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 |
end; |
78bff13b11c0
With this patch the game doesn't crash when gaming by net
unc0rr
parents:
16
diff
changeset
|
107 |
|
42 | 108 |
//////////////////////////////////////////////////////////////////////////////// |
109 |
procedure PickUp(HH, Gear: PGear); |
|
295 | 110 |
var s: shortstring; |
111 |
a: TAmmoType; |
|
42 | 112 |
begin |
351 | 113 |
Gear^.Message:= gm_Destroy; |
114 |
case Gear^.Pos of |
|
295 | 115 |
posCaseAmmo: begin |
351 | 116 |
a:= TAmmoType(Gear^.State); |
117 |
AddAmmo(PHedgehog(HH^.Hedgehog), a); |
|
394
4c017ae1226a
- Implement hack to let ammo stores work without needed assistance of frontend
unc0rr
parents:
393
diff
changeset
|
118 |
s:= trammo[Ammoz[a].NameId] + '(+' + IntToStr(Ammoz[a].NumberInCase) + ')'; |
351 | 119 |
AddCaption(s, PHedgehog(HH^.Hedgehog)^.Team^.Color, capgrpAmmoinfo); |
295 | 120 |
end; |
42 | 121 |
posCaseHealth: begin |
351 | 122 |
inc(HH^.Health, Gear^.Health); |
123 |
str(Gear^.Health, s); |
|
295 | 124 |
s:= '+' + s; |
351 | 125 |
AddCaption(s, PHedgehog(HH^.Hedgehog)^.Team^.Color, capgrpAmmoinfo); |
126 |
RenderHealth(PHedgehog(HH^.Hedgehog)^); |
|
127 |
RecountTeamHealth(PHedgehog(HH^.Hedgehog)^.Team) |
|
42 | 128 |
end; |
129 |
end; |
|
434 | 130 |
FreeActionsList |
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; |
|
351 | 153 |
if ((Gear^.Message and gm_LJump ) <> 0) then |
4 | 154 |
begin |
351 | 155 |
Gear^.Message:= 0; |
68 | 156 |
if not TestCollisionYwithGear(Gear, -1) then |
351 | 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; |
|
159 |
if not (TestCollisionXwithGear(Gear, hwSign(Gear^.dX)) |
|
68 | 160 |
or TestCollisionYwithGear(Gear, -1)) then |
4 | 161 |
begin |
351 | 162 |
Gear^.dY:= -_0_15; |
163 |
Gear^.dX:= hwSign(Gear^.dX) * _0_15; |
|
164 |
Gear^.State:= Gear^.State or gstFalling or gstHHJumping; |
|
4 | 165 |
exit |
166 |
end; |
|
167 |
end; |
|
351 | 168 |
if ((Gear^.Message and gm_HJump ) <> 0) then |
4 | 169 |
begin |
351 | 170 |
Gear^.Message:= 0; |
68 | 171 |
if not TestCollisionYwithGear(Gear, -1) then |
4 | 172 |
begin |
351 | 173 |
Gear^.dY:= -_0_2; |
174 |
SetLittle(Gear^.dX); |
|
175 |
Gear^.State:= Gear^.State or gstFalling or gstHHJumping; |
|
4 | 176 |
exit |
177 |
end; |
|
178 |
end; |
|
351 | 179 |
PrevdX:= hwSign(Gear^.dX); |
180 |
if (Gear^.Message and gm_Left )<>0 then Gear^.dX:= -cLittle else |
|
181 |
if (Gear^.Message and gm_Right )<>0 then Gear^.dX:= cLittle else exit; |
|
74 | 182 |
StepTicks:= cHHStepTicks; |
351 | 183 |
if PrevdX <> hwSign(Gear^.dX) then exit; |
184 |
PHedgehog(Gear^.Hedgehog)^.visStepPos:= (PHedgehog(Gear^.Hedgehog)^.visStepPos + 1) and 7; |
|
185 |
if TestCollisionXwithGear(Gear, hwSign(Gear^.dX)) then |
|
4 | 186 |
begin |
351 | 187 |
if not (TestCollisionXwithXYShift(Gear, 0, -6, hwSign(Gear^.dX)) |
188 |
or TestCollisionYwithGear(Gear, -1)) then Gear^.Y:= Gear^.Y - 1; |
|
189 |
if not (TestCollisionXwithXYShift(Gear, 0, -5, hwSign(Gear^.dX)) |
|
190 |
or TestCollisionYwithGear(Gear, -1)) then Gear^.Y:= Gear^.Y - 1; |
|
191 |
if not (TestCollisionXwithXYShift(Gear, 0, -4, hwSign(Gear^.dX)) |
|
192 |
or TestCollisionYwithGear(Gear, -1)) then Gear^.Y:= Gear^.Y - 1; |
|
193 |
if not (TestCollisionXwithXYShift(Gear, 0, -3, hwSign(Gear^.dX)) |
|
194 |
or TestCollisionYwithGear(Gear, -1)) then Gear^.Y:= Gear^.Y - 1; |
|
195 |
if not (TestCollisionXwithXYShift(Gear, 0, -2, hwSign(Gear^.dX)) |
|
196 |
or TestCollisionYwithGear(Gear, -1)) then Gear^.Y:= Gear^.Y - 1; |
|
197 |
if not (TestCollisionXwithXYShift(Gear, 0, -1, hwSign(Gear^.dX)) |
|
198 |
or TestCollisionYwithGear(Gear, -1)) then Gear^.Y:= Gear^.Y - 1; |
|
4 | 199 |
end; |
351 | 200 |
if not TestCollisionXwithGear(Gear, hwSign(Gear^.dX)) then Gear^.X:= Gear^.X + hwSign(Gear^.dX); |
300 | 201 |
|
62 | 202 |
SetAllHHToActive; |
37 | 203 |
|
68 | 204 |
if not TestCollisionYwithGear(Gear, 1) then |
4 | 205 |
begin |
351 | 206 |
Gear^.Y:= Gear^.Y + 1; |
68 | 207 |
if not TestCollisionYwithGear(Gear, 1) then |
4 | 208 |
begin |
351 | 209 |
Gear^.Y:= Gear^.Y + 1; |
68 | 210 |
if not TestCollisionYwithGear(Gear, 1) then |
4 | 211 |
begin |
351 | 212 |
Gear^.Y:= Gear^.Y + 1; |
68 | 213 |
if not TestCollisionYwithGear(Gear, 1) then |
4 | 214 |
begin |
351 | 215 |
Gear^.Y:= Gear^.Y + 1; |
68 | 216 |
if not TestCollisionYwithGear(Gear, 1) then |
4 | 217 |
begin |
351 | 218 |
Gear^.Y:= Gear^.Y + 1; |
68 | 219 |
if not TestCollisionYwithGear(Gear, 1) then |
4 | 220 |
begin |
351 | 221 |
Gear^.Y:= Gear^.Y + 1; |
68 | 222 |
if not TestCollisionYwithGear(Gear, 1) then |
4 | 223 |
begin |
351 | 224 |
Gear^.Y:= Gear^.Y - 6; |
225 |
Gear^.dY:= 0; |
|
226 |
Gear^.State:= Gear^.State or gstFalling |
|
4 | 227 |
end; |
228 |
end |
|
229 |
end |
|
230 |
end |
|
231 |
end |
|
232 |
end |
|
62 | 233 |
end |
4 | 234 |
end |
235 |
end; |
|
236 |
||
303
1659c4aad5ab
Now blow torch angle can be changed during blowing :)
unc0rr
parents:
302
diff
changeset
|
237 |
procedure HedgehogChAngle(Gear: PGear); |
1659c4aad5ab
Now blow torch angle can be changed during blowing :)
unc0rr
parents:
302
diff
changeset
|
238 |
begin |
351 | 239 |
if ((Gear^.State and (gstMoving or gstFalling)) = 0) then |
240 |
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
|
241 |
else else |
351 | 242 |
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
|
243 |
end; |
1659c4aad5ab
Now blow torch angle can be changed during blowing :)
unc0rr
parents:
302
diff
changeset
|
244 |
|
302 | 245 |
procedure doStepHedgehog(Gear: PGear); forward; |
246 |
//////////////////////////////////////////////////////////////////////////////// |
|
247 |
procedure doStepHedgehogDriven(Gear: PGear); |
|
248 |
var t: PGear; |
|
249 |
begin |
|
351 | 250 |
if isInMultiShoot and (Gear^.Damage = 0) then |
302 | 251 |
begin |
252 |
exit |
|
253 |
end; |
|
254 |
AllInactive:= false; |
|
255 |
DeleteCI(Gear); |
|
351 | 256 |
if (TurnTimeLeft = 0) or (Gear^.Damage > 0) then |
302 | 257 |
begin |
258 |
TurnTimeLeft:= 0; |
|
351 | 259 |
Gear^.State:= Gear^.State and not gstHHDriven; |
260 |
if Gear^.Damage > 0 then |
|
424 | 261 |
Gear^.State:= Gear^.State and not (gstHHJumping or gstHHHJump); |
302 | 262 |
exit |
263 |
end; |
|
351 | 264 |
if ((Gear^.State and gstFalling) <> 0) or (StepTicks = cHHStepTicks) |
302 | 265 |
or (CurAmmoGear <> nil) then // we're moving |
266 |
begin |
|
267 |
// check for case with ammo |
|
268 |
t:= CheckGearNear(Gear, gtCase, 36, 36); |
|
269 |
if t <> nil then |
|
270 |
PickUp(Gear, t) |
|
271 |
end; |
|
272 |
||
273 |
if CurAmmoGear <> nil then |
|
274 |
begin |
|
351 | 275 |
CurAmmoGear^.Message:= Gear^.Message; |
302 | 276 |
exit |
277 |
end; |
|
278 |
||
351 | 279 |
if ((Gear^.Message and gm_Attack) <> 0) or |
280 |
((Gear^.State and gstAttacking) <> 0)then Attack(Gear); |
|
302 | 281 |
|
351 | 282 |
if (Gear^.State and gstFalling) <> 0 then |
302 | 283 |
begin |
424 | 284 |
if ((Gear^.Message and gm_HJump) <> 0) and |
285 |
((Gear^.State and gstHHJumping) <> 0) and |
|
286 |
((Gear^.State and gstHHHJump) = 0) then |
|
287 |
if (not (hwAbs(Gear^.dX) > cLittle)) and (Gear^.dY < -_0_02) then |
|
302 | 288 |
begin |
424 | 289 |
Gear^.State:= Gear^.State or gstHHHJump; |
351 | 290 |
Gear^.dY:= -_0_25; |
291 |
Gear^.dX:= hwSign(Gear^.dX) * _0_02 |
|
302 | 292 |
end; |
351 | 293 |
Gear^.Message:= Gear^.Message and not (gm_LJump or gm_HJump); |
294 |
if TestCollisionXwithGear(Gear, hwSign(Gear^.dX)) then SetLittle(Gear^.dX); |
|
295 |
Gear^.X:= Gear^.X + Gear^.dX; |
|
296 |
Gear^.dY:= Gear^.dY + cGravity; |
|
369 | 297 |
if (Gear^.dY.isNegative)and TestCollisionYwithGear(Gear, -1) then Gear^.dY:= 0; |
351 | 298 |
Gear^.Y:= Gear^.Y + Gear^.dY; |
299 |
if (not Gear^.dY.isNegative)and TestCollisionYwithGear(Gear, 1) then |
|
302 | 300 |
begin |
301 |
CheckHHDamage(Gear); |
|
351 | 302 |
if ((hwAbs(Gear^.dX) + hwAbs(Gear^.dY)) < _0_55) |
303 |
and ((Gear^.State and gstHHJumping) <> 0) then SetLittle(Gear^.dX); |
|
424 | 304 |
Gear^.State:= Gear^.State and not (gstFalling or gstHHJumping or gstHHHJump); |
351 | 305 |
StepTicks:= 300; |
306 |
Gear^.dY:= 0 |
|
302 | 307 |
end; |
308 |
CheckGearDrowning(Gear); |
|
309 |
exit |
|
351 | 310 |
end ;//else if Gear^.CollIndex = High(Longword) then AddIntersectorsCR(Gear); |
302 | 311 |
|
303
1659c4aad5ab
Now blow torch angle can be changed during blowing :)
unc0rr
parents:
302
diff
changeset
|
312 |
HedgehogChAngle(Gear); |
302 | 313 |
if StepTicks > 0 then dec(StepTicks); |
314 |
if (StepTicks = 0) then HedgehogStep(Gear) |
|
315 |
end; |
|
316 |
||
4 | 317 |
//////////////////////////////////////////////////////////////////////////////// |
318 |
procedure doStepHedgehogFree(Gear: PGear); |
|
319 |
begin |
|
62 | 320 |
//DeleteCI(Gear); |
68 | 321 |
if not TestCollisionYwithGear(Gear, 1) then |
4 | 322 |
begin |
351 | 323 |
if (Gear^.dY < 0) and TestCollisionYwithGear(Gear, -1) then Gear^.dY:= 0; |
324 |
Gear^.State:= Gear^.State or gstFalling or gstMoving; |
|
325 |
Gear^.dY:= Gear^.dY + cGravity |
|
4 | 326 |
end else begin |
327 |
CheckHHDamage(Gear); |
|
351 | 328 |
if ((hwAbs(Gear^.dX) + hwAbs(Gear^.dY)) < _0_55) |
329 |
and ((Gear^.State and gstHHJumping) <> 0) then SetLittle(Gear^.dX); |
|
330 |
Gear^.State:= Gear^.State and not (gstFalling or gstHHJumping); |
|
331 |
if Gear^.dY > 0 then Gear^.dY:= 0; |
|
332 |
if ((Gear^.State and gstMoving) <> 0) then Gear^.dX:= Gear^.dX * Gear^.Friction |
|
4 | 333 |
end; |
334 |
||
351 | 335 |
if (Gear^.State <> 0) then DeleteCI(Gear); |
4 | 336 |
|
351 | 337 |
if (Gear^.State and gstMoving) <> 0 then |
338 |
if TestCollisionXwithGear(Gear, hwSign(Gear^.dX)) then |
|
339 |
if ((Gear^.State and gstFalling) = 0) then |
|
340 |
if hwAbs(Gear^.dX) > _0_01 then |
|
341 |
if not TestCollisionXwithXYShift(Gear, 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 |
|
342 |
if not TestCollisionXwithXYShift(Gear, 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 |
|
343 |
if not TestCollisionXwithXYShift(Gear, 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 |
|
344 |
if not TestCollisionXwithXYShift(Gear, 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 |
|
345 |
if not TestCollisionXwithXYShift(Gear, 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 |
|
346 |
if hwAbs(Gear^.dX) > _0_02 then Gear^.dX:= -Gear^.Elasticity * Gear^.dX |
|
4 | 347 |
else begin |
351 | 348 |
Gear^.State:= Gear^.State and not gstMoving; |
349 |
SetLittle(Gear^.dX) |
|
4 | 350 |
end |
149 | 351 |
else begin |
351 | 352 |
Gear^.State:= Gear^.State and not gstMoving; |
353 |
SetLittle(Gear^.dX) |
|
149 | 354 |
end |
351 | 355 |
else Gear^.dX:= -Gear^.Elasticity * Gear^.dX; |
4 | 356 |
|
351 | 357 |
if ((Gear^.State and gstFalling) = 0)and |
358 |
(hwAbs(Gear^.dX) + hwAbs(Gear^.dY) < _0_03) then |
|
4 | 359 |
begin |
351 | 360 |
Gear^.State:= Gear^.State and not gstMoving; |
361 |
SetLittle(Gear^.dX); |
|
362 |
Gear^.dY:= 0 |
|
363 |
end else Gear^.State:= Gear^.State or gstMoving; |
|
4 | 364 |
|
351 | 365 |
if (Gear^.State and gstMoving) <> 0 then |
4 | 366 |
begin |
351 | 367 |
Gear^.X:= Gear^.X + Gear^.dX; |
368 |
Gear^.Y:= Gear^.Y + Gear^.dY; |
|
369 |
if (Gear^.dY > 0) and not TestCollisionYwithGear(Gear, 1) and TestCollisionYwithXYShift(Gear, 0, 1, 1) then |
|
74 | 370 |
begin |
82 | 371 |
CheckHHDamage(Gear); |
351 | 372 |
Gear^.dY:= 0; |
373 |
Gear^.Y:= Gear^.Y + 1 |
|
74 | 374 |
end; |
4 | 375 |
end else |
351 | 376 |
if Gear^.Health = 0 then |
4 | 377 |
begin |
378 |
if AllInactive then |
|
379 |
begin |
|
351 | 380 |
doMakeExplosion(hwRound(Gear^.X), hwRound(Gear^.Y), 30, EXPLAutoSound); |
381 |
AddGear(hwRound(Gear^.X), hwRound(Gear^.Y), gtGrave, 0, 0, 0, 0)^.Hedgehog:= Gear^.Hedgehog; |
|
4 | 382 |
DeleteGear(Gear); |
383 |
SetAllToActive |
|
384 |
end; |
|
351 | 385 |
AllInactive:= false; |
4 | 386 |
exit |
387 |
end; |
|
388 |
||
389 |
AllInactive:= false; |
|
390 |
||
391 |
if (not CheckGearDrowning(Gear)) and |
|
351 | 392 |
((Gear^.State and gstMoving) = 0) then |
4 | 393 |
begin |
351 | 394 |
Gear^.State:= 0; |
395 |
Gear^.Active:= false; |
|
53 | 396 |
AddGearCI(Gear); |
4 | 397 |
exit |
398 |
end |
|
399 |
end; |
|
400 |
||
401 |
//////////////////////////////////////////////////////////////////////////////// |
|
402 |
procedure doStepHedgehog(Gear: PGear); |
|
403 |
begin |
|
351 | 404 |
if (Gear^.Message and gm_Destroy) <> 0 then |
4 | 405 |
begin |
406 |
DeleteGear(Gear); |
|
407 |
exit |
|
408 |
end; |
|
351 | 409 |
if (Gear^.State and gstHHDriven) = 0 then doStepHedgehogFree(Gear) |
4 | 410 |
else doStepHedgehogDriven(Gear) |
411 |
end; |