author | unc0rr |
Sun, 28 Jan 2007 16:40:04 +0000 | |
changeset 374 | 95169697cc38 |
parent 371 | 731ad6d27bd1 |
child 393 | db01cc79f278 |
permissions | -rw-r--r-- |
4 | 1 |
(* |
2 |
* Hedgewars, a worms-like game |
|
47 | 3 |
* Copyright (c) 2004, 2005, 2006 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:= hwSign(dX)*Sin(Angle*pi/cMaxAngle); |
52 |
// yy:= -Cos(Angle*pi/cMaxAngle); |
|
53 |
xx:= AngleSin(Angle); |
|
54 |
xx.isNegative:= dX.isNegative; |
|
55 |
yy:= -AngleCos(Angle); |
|
56 |
case Ammo^[CurSlot, CurAmmo].AmmoType of |
|
57 |
amGrenade: FollowGear:= AddGear(hwRound(X), hwRound(Y), gtAmmo_Bomb, 0, xx*Power/cPowerDivisor, yy*Power/cPowerDivisor, Ammo^[CurSlot, CurAmmo].Timer); |
|
58 |
amClusterBomb: FollowGear:= AddGear(hwRound(X), hwRound(Y), gtClusterBomb, 0, xx*Power/cPowerDivisor, yy*Power/cPowerDivisor, Ammo^[CurSlot, CurAmmo].Timer); |
|
59 |
amBazooka: FollowGear:= AddGear(hwRound(X), hwRound(Y), gtAmmo_Grenade, 0, xx*Power/cPowerDivisor, yy*Power/cPowerDivisor, 0); |
|
60 |
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
|
61 |
amShotgun: begin |
351 | 62 |
PlaySound(sndShotgunReload, false); |
63 |
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
|
64 |
end; |
351 | 65 |
amPickHammer: CurAmmoGear:= AddGear(hwRound(Gear^.X), hwRound(Gear^.Y) + cHHRadius, gtPickHammer, 0, 0, 0, 0); |
78 | 66 |
amSkip: TurnTimeLeft:= 0; |
351 | 67 |
amRope: CurAmmoGear:= AddGear(hwRound(Gear^.X), hwRound(Gear^.Y), gtRope, 0, xx, yy, 0); |
68 |
amMine: AddGear(hwRound(X) + hwSign(dX) * 7, hwRound(Y), gtMine, 0, hwSign(dX) * _0_02, 0, 3000); |
|
69 |
amDEagle: AddGear(hwRound(X), hwRound(Y), gtDEagleShot, 0, xx * _0_5, yy * _0_5, 0); |
|
70 |
amDynamite: AddGear(hwRound(X) + hwSign(dX) * 7, hwRound(Y), gtDynamite, 0, hwSign(dX) * _0_03, 0, 5000); |
|
71 |
amBaseballBat: AddGear(hwRound(X) + hwSign(dX) * 10, hwRound(Y), gtShover, 0, xx * _0_5, yy * _0_5, 0)^.Radius:= 20; |
|
72 |
amFirePunch: CurAmmoGear:= AddGear(hwRound(X) + hwSign(dX) * 10, hwRound(Y), gtFirePunch, 0, 0, 0, 0); |
|
73 |
amParachute: CurAmmoGear:= AddGear(hwRound(X), hwRound(Y), gtParachute, 0, 0, 0, 0); |
|
74 |
amAirAttack: AddGear(0, 0, gtAirAttack, 0, 0, 0, 0); |
|
75 |
amMineStrike: AddGear(0, 0, gtAirAttack, 1, 0, 0, 0); |
|
76 |
amBlowTorch: CurAmmoGear:= AddGear(hwRound(Gear^.X), hwRound(Gear^.Y), gtBlowTorch, 0, hwSign(Gear^.dX) * _0_5, 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; |
78bff13b11c0
With this patch the game doesn't crash when gaming by net
unc0rr
parents:
16
diff
changeset
|
103 |
OnUsedAmmo(Ammo) |
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); |
|
295 | 119 |
s:= trammo[Ammoz[a].NameId]; |
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; |
130 |
end; |
|
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 |
351 | 140 |
if ((Gear^.Message and gm_LJump ) <> 0) then |
4 | 141 |
begin |
351 | 142 |
Gear^.Message:= 0; |
68 | 143 |
if not TestCollisionYwithGear(Gear, -1) then |
351 | 144 |
if not TestCollisionXwithXYShift(Gear, 0, -2, hwSign(Gear^.dX)) then Gear^.Y:= Gear^.Y - 2 else |
145 |
if not TestCollisionXwithXYShift(Gear, 0, -1, hwSign(Gear^.dX)) then Gear^.Y:= Gear^.Y - 1; |
|
146 |
if not (TestCollisionXwithGear(Gear, hwSign(Gear^.dX)) |
|
68 | 147 |
or TestCollisionYwithGear(Gear, -1)) then |
4 | 148 |
begin |
351 | 149 |
Gear^.dY:= -_0_15; |
150 |
Gear^.dX:= hwSign(Gear^.dX) * _0_15; |
|
151 |
Gear^.State:= Gear^.State or gstFalling or gstHHJumping; |
|
4 | 152 |
exit |
153 |
end; |
|
154 |
end; |
|
351 | 155 |
if ((Gear^.Message and gm_HJump ) <> 0) then |
4 | 156 |
begin |
351 | 157 |
Gear^.Message:= 0; |
68 | 158 |
if not TestCollisionYwithGear(Gear, -1) then |
4 | 159 |
begin |
351 | 160 |
Gear^.dY:= -_0_2; |
161 |
SetLittle(Gear^.dX); |
|
162 |
Gear^.State:= Gear^.State or gstFalling or gstHHJumping; |
|
4 | 163 |
exit |
164 |
end; |
|
165 |
end; |
|
351 | 166 |
PrevdX:= hwSign(Gear^.dX); |
167 |
if (Gear^.Message and gm_Left )<>0 then Gear^.dX:= -cLittle else |
|
168 |
if (Gear^.Message and gm_Right )<>0 then Gear^.dX:= cLittle else exit; |
|
74 | 169 |
StepTicks:= cHHStepTicks; |
351 | 170 |
if PrevdX <> hwSign(Gear^.dX) then exit; |
171 |
PHedgehog(Gear^.Hedgehog)^.visStepPos:= (PHedgehog(Gear^.Hedgehog)^.visStepPos + 1) and 7; |
|
172 |
if TestCollisionXwithGear(Gear, hwSign(Gear^.dX)) then |
|
4 | 173 |
begin |
351 | 174 |
if not (TestCollisionXwithXYShift(Gear, 0, -6, hwSign(Gear^.dX)) |
175 |
or TestCollisionYwithGear(Gear, -1)) then Gear^.Y:= Gear^.Y - 1; |
|
176 |
if not (TestCollisionXwithXYShift(Gear, 0, -5, hwSign(Gear^.dX)) |
|
177 |
or TestCollisionYwithGear(Gear, -1)) then Gear^.Y:= Gear^.Y - 1; |
|
178 |
if not (TestCollisionXwithXYShift(Gear, 0, -4, hwSign(Gear^.dX)) |
|
179 |
or TestCollisionYwithGear(Gear, -1)) then Gear^.Y:= Gear^.Y - 1; |
|
180 |
if not (TestCollisionXwithXYShift(Gear, 0, -3, hwSign(Gear^.dX)) |
|
181 |
or TestCollisionYwithGear(Gear, -1)) then Gear^.Y:= Gear^.Y - 1; |
|
182 |
if not (TestCollisionXwithXYShift(Gear, 0, -2, hwSign(Gear^.dX)) |
|
183 |
or TestCollisionYwithGear(Gear, -1)) then Gear^.Y:= Gear^.Y - 1; |
|
184 |
if not (TestCollisionXwithXYShift(Gear, 0, -1, hwSign(Gear^.dX)) |
|
185 |
or TestCollisionYwithGear(Gear, -1)) then Gear^.Y:= Gear^.Y - 1; |
|
4 | 186 |
end; |
351 | 187 |
if not TestCollisionXwithGear(Gear, hwSign(Gear^.dX)) then Gear^.X:= Gear^.X + hwSign(Gear^.dX); |
300 | 188 |
|
62 | 189 |
SetAllHHToActive; |
37 | 190 |
|
68 | 191 |
if not TestCollisionYwithGear(Gear, 1) then |
4 | 192 |
begin |
351 | 193 |
Gear^.Y:= Gear^.Y + 1; |
68 | 194 |
if not TestCollisionYwithGear(Gear, 1) then |
4 | 195 |
begin |
351 | 196 |
Gear^.Y:= Gear^.Y + 1; |
68 | 197 |
if not TestCollisionYwithGear(Gear, 1) then |
4 | 198 |
begin |
351 | 199 |
Gear^.Y:= Gear^.Y + 1; |
68 | 200 |
if not TestCollisionYwithGear(Gear, 1) then |
4 | 201 |
begin |
351 | 202 |
Gear^.Y:= Gear^.Y + 1; |
68 | 203 |
if not TestCollisionYwithGear(Gear, 1) then |
4 | 204 |
begin |
351 | 205 |
Gear^.Y:= Gear^.Y + 1; |
68 | 206 |
if not TestCollisionYwithGear(Gear, 1) then |
4 | 207 |
begin |
351 | 208 |
Gear^.Y:= Gear^.Y + 1; |
68 | 209 |
if not TestCollisionYwithGear(Gear, 1) then |
4 | 210 |
begin |
351 | 211 |
Gear^.Y:= Gear^.Y - 6; |
212 |
Gear^.dY:= 0; |
|
213 |
Gear^.State:= Gear^.State or gstFalling |
|
4 | 214 |
end; |
215 |
end |
|
216 |
end |
|
217 |
end |
|
218 |
end |
|
219 |
end |
|
62 | 220 |
end |
4 | 221 |
end |
222 |
end; |
|
223 |
||
303
1659c4aad5ab
Now blow torch angle can be changed during blowing :)
unc0rr
parents:
302
diff
changeset
|
224 |
procedure HedgehogChAngle(Gear: PGear); |
1659c4aad5ab
Now blow torch angle can be changed during blowing :)
unc0rr
parents:
302
diff
changeset
|
225 |
begin |
351 | 226 |
if ((Gear^.State and (gstMoving or gstFalling)) = 0) then |
227 |
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
|
228 |
else else |
351 | 229 |
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
|
230 |
end; |
1659c4aad5ab
Now blow torch angle can be changed during blowing :)
unc0rr
parents:
302
diff
changeset
|
231 |
|
302 | 232 |
procedure doStepHedgehog(Gear: PGear); forward; |
233 |
//////////////////////////////////////////////////////////////////////////////// |
|
234 |
procedure doStepHedgehogDriven(Gear: PGear); |
|
235 |
var t: PGear; |
|
236 |
begin |
|
351 | 237 |
if isInMultiShoot and (Gear^.Damage = 0) then |
302 | 238 |
begin |
239 |
exit |
|
240 |
end; |
|
241 |
AllInactive:= false; |
|
242 |
DeleteCI(Gear); |
|
351 | 243 |
if (TurnTimeLeft = 0) or (Gear^.Damage > 0) then |
302 | 244 |
begin |
245 |
TurnTimeLeft:= 0; |
|
351 | 246 |
Gear^.State:= Gear^.State and not gstHHDriven; |
247 |
if Gear^.Damage > 0 then |
|
248 |
Gear^.State:= Gear^.State and not gstHHJumping; |
|
302 | 249 |
exit |
250 |
end; |
|
351 | 251 |
if ((Gear^.State and gstFalling) <> 0) or (StepTicks = cHHStepTicks) |
302 | 252 |
or (CurAmmoGear <> nil) then // we're moving |
253 |
begin |
|
254 |
// check for case with ammo |
|
255 |
t:= CheckGearNear(Gear, gtCase, 36, 36); |
|
256 |
if t <> nil then |
|
257 |
PickUp(Gear, t) |
|
258 |
end; |
|
259 |
||
260 |
if CurAmmoGear <> nil then |
|
261 |
begin |
|
351 | 262 |
CurAmmoGear^.Message:= Gear^.Message; |
302 | 263 |
exit |
264 |
end; |
|
265 |
||
351 | 266 |
if ((Gear^.Message and gm_Attack) <> 0) or |
267 |
((Gear^.State and gstAttacking) <> 0)then Attack(Gear); |
|
302 | 268 |
|
351 | 269 |
if (Gear^.State and gstFalling) <> 0 then |
302 | 270 |
begin |
351 | 271 |
// it could be the source to trick: hwFloat-backspace jump -> vertical wall |
272 |
// collision - > (abs(Gear^.dX) < 0.0000002) -> backspace -> even more high jump |
|
273 |
if ((Gear^.Message and gm_HJump) <> 0) and ((Gear^.State and gstHHJumping) <> 0) then |
|
274 |
if (hwAbs(Gear^.dX) < cLittle + cLittle) and (Gear^.dY < -_0_02) then |
|
302 | 275 |
begin |
351 | 276 |
Gear^.dY:= -_0_25; |
277 |
Gear^.dX:= hwSign(Gear^.dX) * _0_02 |
|
302 | 278 |
end; |
351 | 279 |
Gear^.Message:= Gear^.Message and not (gm_LJump or gm_HJump); |
280 |
if TestCollisionXwithGear(Gear, hwSign(Gear^.dX)) then SetLittle(Gear^.dX); |
|
281 |
Gear^.X:= Gear^.X + Gear^.dX; |
|
282 |
Gear^.dY:= Gear^.dY + cGravity; |
|
369 | 283 |
if (Gear^.dY.isNegative)and TestCollisionYwithGear(Gear, -1) then Gear^.dY:= 0; |
351 | 284 |
Gear^.Y:= Gear^.Y + Gear^.dY; |
285 |
if (not Gear^.dY.isNegative)and TestCollisionYwithGear(Gear, 1) then |
|
302 | 286 |
begin |
287 |
CheckHHDamage(Gear); |
|
351 | 288 |
if ((hwAbs(Gear^.dX) + hwAbs(Gear^.dY)) < _0_55) |
289 |
and ((Gear^.State and gstHHJumping) <> 0) then SetLittle(Gear^.dX); |
|
290 |
Gear^.State:= Gear^.State and not (gstFalling or gstHHJumping); |
|
291 |
StepTicks:= 300; |
|
292 |
Gear^.dY:= 0 |
|
302 | 293 |
end; |
294 |
CheckGearDrowning(Gear); |
|
295 |
exit |
|
351 | 296 |
end ;//else if Gear^.CollIndex = High(Longword) then AddIntersectorsCR(Gear); |
302 | 297 |
|
303
1659c4aad5ab
Now blow torch angle can be changed during blowing :)
unc0rr
parents:
302
diff
changeset
|
298 |
HedgehogChAngle(Gear); |
302 | 299 |
if StepTicks > 0 then dec(StepTicks); |
300 |
if (StepTicks = 0) then HedgehogStep(Gear) |
|
301 |
end; |
|
302 |
||
4 | 303 |
//////////////////////////////////////////////////////////////////////////////// |
304 |
procedure doStepHedgehogFree(Gear: PGear); |
|
305 |
begin |
|
62 | 306 |
//DeleteCI(Gear); |
68 | 307 |
if not TestCollisionYwithGear(Gear, 1) then |
4 | 308 |
begin |
351 | 309 |
if (Gear^.dY < 0) and TestCollisionYwithGear(Gear, -1) then Gear^.dY:= 0; |
310 |
Gear^.State:= Gear^.State or gstFalling or gstMoving; |
|
311 |
Gear^.dY:= Gear^.dY + cGravity |
|
4 | 312 |
end else 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); |
|
316 |
Gear^.State:= Gear^.State and not (gstFalling or gstHHJumping); |
|
317 |
if Gear^.dY > 0 then Gear^.dY:= 0; |
|
318 |
if ((Gear^.State and gstMoving) <> 0) then Gear^.dX:= Gear^.dX * Gear^.Friction |
|
4 | 319 |
end; |
320 |
||
351 | 321 |
if (Gear^.State <> 0) then DeleteCI(Gear); |
4 | 322 |
|
351 | 323 |
if (Gear^.State and gstMoving) <> 0 then |
324 |
if TestCollisionXwithGear(Gear, hwSign(Gear^.dX)) then |
|
325 |
if ((Gear^.State and gstFalling) = 0) then |
|
326 |
if hwAbs(Gear^.dX) > _0_01 then |
|
327 |
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 |
|
328 |
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 |
|
329 |
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 |
|
330 |
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 |
|
331 |
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 |
|
332 |
if hwAbs(Gear^.dX) > _0_02 then Gear^.dX:= -Gear^.Elasticity * Gear^.dX |
|
4 | 333 |
else begin |
351 | 334 |
Gear^.State:= Gear^.State and not gstMoving; |
335 |
SetLittle(Gear^.dX) |
|
4 | 336 |
end |
149 | 337 |
else begin |
351 | 338 |
Gear^.State:= Gear^.State and not gstMoving; |
339 |
SetLittle(Gear^.dX) |
|
149 | 340 |
end |
351 | 341 |
else Gear^.dX:= -Gear^.Elasticity * Gear^.dX; |
4 | 342 |
|
351 | 343 |
if ((Gear^.State and gstFalling) = 0)and |
344 |
(hwAbs(Gear^.dX) + hwAbs(Gear^.dY) < _0_03) then |
|
4 | 345 |
begin |
351 | 346 |
Gear^.State:= Gear^.State and not gstMoving; |
347 |
SetLittle(Gear^.dX); |
|
348 |
Gear^.dY:= 0 |
|
349 |
end else Gear^.State:= Gear^.State or gstMoving; |
|
4 | 350 |
|
351 | 351 |
if (Gear^.State and gstMoving) <> 0 then |
4 | 352 |
begin |
351 | 353 |
Gear^.X:= Gear^.X + Gear^.dX; |
354 |
Gear^.Y:= Gear^.Y + Gear^.dY; |
|
355 |
if (Gear^.dY > 0) and not TestCollisionYwithGear(Gear, 1) and TestCollisionYwithXYShift(Gear, 0, 1, 1) then |
|
74 | 356 |
begin |
82 | 357 |
CheckHHDamage(Gear); |
351 | 358 |
Gear^.dY:= 0; |
359 |
Gear^.Y:= Gear^.Y + 1 |
|
74 | 360 |
end; |
4 | 361 |
end else |
351 | 362 |
if Gear^.Health = 0 then |
4 | 363 |
begin |
364 |
if AllInactive then |
|
365 |
begin |
|
351 | 366 |
doMakeExplosion(hwRound(Gear^.X), hwRound(Gear^.Y), 30, EXPLAutoSound); |
367 |
AddGear(hwRound(Gear^.X), hwRound(Gear^.Y), gtGrave, 0, 0, 0, 0)^.Hedgehog:= Gear^.Hedgehog; |
|
4 | 368 |
DeleteGear(Gear); |
369 |
SetAllToActive |
|
370 |
end; |
|
351 | 371 |
AllInactive:= false; |
4 | 372 |
exit |
373 |
end; |
|
374 |
||
375 |
AllInactive:= false; |
|
376 |
||
377 |
if (not CheckGearDrowning(Gear)) and |
|
351 | 378 |
((Gear^.State and gstMoving) = 0) then |
4 | 379 |
begin |
351 | 380 |
Gear^.State:= 0; |
381 |
Gear^.Active:= false; |
|
53 | 382 |
AddGearCI(Gear); |
4 | 383 |
exit |
384 |
end |
|
385 |
end; |
|
386 |
||
387 |
//////////////////////////////////////////////////////////////////////////////// |
|
388 |
procedure doStepHedgehog(Gear: PGear); |
|
389 |
begin |
|
351 | 390 |
if (Gear^.Message and gm_Destroy) <> 0 then |
4 | 391 |
begin |
392 |
DeleteGear(Gear); |
|
393 |
exit |
|
394 |
end; |
|
351 | 395 |
if (Gear^.State and gstHHDriven) = 0 then doStepHedgehogFree(Gear) |
4 | 396 |
else doStepHedgehogDriven(Gear) |
397 |
end; |