author | unc0rr |
Sun, 17 Dec 2006 17:55:41 +0000 | |
changeset 302 | 7aca131ecd7f |
parent 300 | be94799f33d2 |
child 303 | 1659c4aad5ab |
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); |
107 | 21 |
var xx, yy: Double; |
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^, |
95 | 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 |
78bff13b11c0
With this patch the game doesn't crash when gaming by net
unc0rr
parents:
16
diff
changeset
|
29 |
(((State and gstFalling ) = 0)or((Ammo[CurSlot, CurAmmo].Propz and ammoprop_AttackInFall) <> 0))and |
95 | 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 |
|
35 |
else if (Ammo[CurSlot, CurAmmo].Propz and ammoprop_Power) = 0 then Message:= Message and not gm_Attack |
|
36 |
else begin |
|
37 |
if Power = 0 then |
|
38 |
begin |
|
39 |
AttackBar:= CurrentTeam.AttackBar; |
|
40 |
PlaySound(sndThrowPowerUp) |
|
41 |
end; |
|
42 |
inc(Power) |
|
43 |
end; |
|
44 |
if ((Message and gm_Attack) <> 0) then exit; |
|
45 |
||
32
78bff13b11c0
With this patch the game doesn't crash when gaming by net
unc0rr
parents:
16
diff
changeset
|
46 |
if (Ammo[CurSlot, CurAmmo].Propz and ammoprop_Power) <> 0 then |
78bff13b11c0
With this patch the game doesn't crash when gaming by net
unc0rr
parents:
16
diff
changeset
|
47 |
begin |
282 | 48 |
StopSound(sndThrowPowerUp); |
32
78bff13b11c0
With this patch the game doesn't crash when gaming by net
unc0rr
parents:
16
diff
changeset
|
49 |
PlaySound(sndThrowRelease); |
78bff13b11c0
With this patch the game doesn't crash when gaming by net
unc0rr
parents:
16
diff
changeset
|
50 |
end; |
108 | 51 |
xx:= hwSign(dX)*Sin(Angle*pi/cMaxAngle); |
32
78bff13b11c0
With this patch the game doesn't crash when gaming by net
unc0rr
parents:
16
diff
changeset
|
52 |
yy:= -Cos(Angle*pi/cMaxAngle); |
78bff13b11c0
With this patch the game doesn't crash when gaming by net
unc0rr
parents:
16
diff
changeset
|
53 |
case Ammo[CurSlot, CurAmmo].AmmoType of |
78 | 54 |
amGrenade: FollowGear:= AddGear(round(X), round(Y), gtAmmo_Bomb, 0, xx*Power/cPowerDivisor, yy*Power/cPowerDivisor, Ammo[CurSlot, CurAmmo].Timer); |
55 |
amClusterBomb: FollowGear:= AddGear(round(X), round(Y), gtClusterBomb, 0, xx*Power/cPowerDivisor, yy*Power/cPowerDivisor, Ammo[CurSlot, CurAmmo].Timer); |
|
32
78bff13b11c0
With this patch the game doesn't crash when gaming by net
unc0rr
parents:
16
diff
changeset
|
56 |
amBazooka: FollowGear:= AddGear(round(X), round(Y), gtAmmo_Grenade, 0, xx*Power/cPowerDivisor, yy*Power/cPowerDivisor); |
78bff13b11c0
With this patch the game doesn't crash when gaming by net
unc0rr
parents:
16
diff
changeset
|
57 |
amUFO: FollowGear:= AddGear(round(X), round(Y), gtUFO, 0, xx*Power/cPowerDivisor, yy*Power/cPowerDivisor); |
78bff13b11c0
With this patch the game doesn't crash when gaming by net
unc0rr
parents:
16
diff
changeset
|
58 |
amShotgun: begin |
78bff13b11c0
With this patch the game doesn't crash when gaming by net
unc0rr
parents:
16
diff
changeset
|
59 |
PlaySound(sndShotgunReload); |
75 | 60 |
CurAmmoGear:= AddGear(round(X), round(Y), gtShotgunShot, 0, xx * 0.5, yy * 0.5); |
32
78bff13b11c0
With this patch the game doesn't crash when gaming by net
unc0rr
parents:
16
diff
changeset
|
61 |
end; |
78 | 62 |
amPickHammer: CurAmmoGear:= AddGear(round(Gear.X), round(Gear.Y) + cHHRadius, gtPickHammer, 0); |
63 |
amSkip: TurnTimeLeft:= 0; |
|
64 |
amRope: CurAmmoGear:= AddGear(round(Gear.X), round(Gear.Y), gtRope, 0, xx, yy); |
|
108 | 65 |
amMine: AddGear(round(X) + hwSign(dX) * 7, round(Y), gtMine, 0, hwSign(dX) * 0.02, 0, 3000); |
82 | 66 |
amDEagle: AddGear(round(X), round(Y), gtDEagleShot, 0, xx * 0.5, yy * 0.5); |
108 | 67 |
amDynamite: AddGear(round(X) + hwSign(dX) * 7, round(Y), gtDynamite, 0, hwSign(dX) * 0.035, 0, 5000); |
68 |
amBaseballBat: AddGear(round(X) + hwSign(dX) * 10, round(Y), gtShover, 0, xx * 0.5, yy * 0.5).Radius:= 20; |
|
69 |
amFirePunch: CurAmmoGear:= AddGear(round(X) + hwSign(dX) * 10, round(Y), gtFirePunch, 0); |
|
263 | 70 |
amParachute: CurAmmoGear:= AddGear(round(X), round(Y), gtParachute, 0); |
285 | 71 |
amAirAttack: AddGear(0, 0, gtAirAttack, 0); |
72 |
amMineStrike: AddGear(0, 0, gtAirAttack, 1); |
|
302 | 73 |
amBlowTorch: CurAmmoGear:= AddGear(round(Gear.X), round(Gear.Y), gtBlowTorch, 0, hwSign(Gear.dX) * 0.5); |
32
78bff13b11c0
With this patch the game doesn't crash when gaming by net
unc0rr
parents:
16
diff
changeset
|
74 |
end; |
78bff13b11c0
With this patch the game doesn't crash when gaming by net
unc0rr
parents:
16
diff
changeset
|
75 |
Power:= 0; |
78bff13b11c0
With this patch the game doesn't crash when gaming by net
unc0rr
parents:
16
diff
changeset
|
76 |
if CurAmmoGear <> nil then |
78bff13b11c0
With this patch the game doesn't crash when gaming by net
unc0rr
parents:
16
diff
changeset
|
77 |
begin |
82 | 78 |
Message:= Message or gm_Attack; |
79 |
CurAmmoGear.Message:= Message |
|
80 |
end else begin |
|
95 | 81 |
if not CurrentTeam.ExtDriven and |
82 |
((Ammo[CurSlot, CurAmmo].Propz and ammoprop_Power) <> 0) then SendIPC('a'); |
|
82 | 83 |
AfterAttack |
84 |
end |
|
95 | 85 |
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
|
86 |
end |
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 |
|
78bff13b11c0
With this patch the game doesn't crash when gaming by net
unc0rr
parents:
16
diff
changeset
|
89 |
procedure AfterAttack; |
78bff13b11c0
With this patch the game doesn't crash when gaming by net
unc0rr
parents:
16
diff
changeset
|
90 |
begin |
78bff13b11c0
With this patch the game doesn't crash when gaming by net
unc0rr
parents:
16
diff
changeset
|
91 |
with CurrentTeam.Hedgehogs[CurrentTeam.CurrHedgehog].Gear^, |
78bff13b11c0
With this patch the game doesn't crash when gaming by net
unc0rr
parents:
16
diff
changeset
|
92 |
CurrentTeam.Hedgehogs[CurrentTeam.CurrHedgehog] do |
78bff13b11c0
With this patch the game doesn't crash when gaming by net
unc0rr
parents:
16
diff
changeset
|
93 |
begin |
78bff13b11c0
With this patch the game doesn't crash when gaming by net
unc0rr
parents:
16
diff
changeset
|
94 |
Inc(AttacksNum); |
78bff13b11c0
With this patch the game doesn't crash when gaming by net
unc0rr
parents:
16
diff
changeset
|
95 |
State:= State and not gstAttacking; |
78bff13b11c0
With this patch the game doesn't crash when gaming by net
unc0rr
parents:
16
diff
changeset
|
96 |
if Ammo[CurSlot, CurAmmo].NumPerTurn >= AttacksNum then isInMultiShoot:= true |
78bff13b11c0
With this patch the game doesn't crash when gaming by net
unc0rr
parents:
16
diff
changeset
|
97 |
else begin |
78bff13b11c0
With this patch the game doesn't crash when gaming by net
unc0rr
parents:
16
diff
changeset
|
98 |
TurnTimeLeft:= Ammoz[Ammo[CurSlot, CurAmmo].AmmoType].TimeAfterTurn; |
78bff13b11c0
With this patch the game doesn't crash when gaming by net
unc0rr
parents:
16
diff
changeset
|
99 |
State:= State or gstAttacked; |
78bff13b11c0
With this patch the game doesn't crash when gaming by net
unc0rr
parents:
16
diff
changeset
|
100 |
OnUsedAmmo(Ammo) |
78bff13b11c0
With this patch the game doesn't crash when gaming by net
unc0rr
parents:
16
diff
changeset
|
101 |
end; |
95 | 102 |
AttackBar:= 0; |
32
78bff13b11c0
With this patch the game doesn't crash when gaming by net
unc0rr
parents:
16
diff
changeset
|
103 |
end |
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 |
|
42 | 106 |
//////////////////////////////////////////////////////////////////////////////// |
107 |
procedure PickUp(HH, Gear: PGear); |
|
295 | 108 |
var s: shortstring; |
109 |
a: TAmmoType; |
|
42 | 110 |
begin |
68 | 111 |
Gear.Message:= gm_Destroy; |
42 | 112 |
case Gear.Pos of |
295 | 113 |
posCaseAmmo: begin |
114 |
a:= TAmmoType(Gear.State); |
|
115 |
AddAmmo(PHedgehog(HH.Hedgehog), a); |
|
116 |
s:= trammo[Ammoz[a].NameId]; |
|
117 |
AddCaption(s, PHedgehog(HH.Hedgehog).Team.Color, capgrpAmmoinfo); |
|
118 |
end; |
|
42 | 119 |
posCaseHealth: begin |
120 |
inc(HH.Health, Gear.Health); |
|
295 | 121 |
str(Gear.Health, s); |
122 |
s:= '+' + s; |
|
123 |
AddCaption(s, PHedgehog(HH.Hedgehog).Team.Color, capgrpAmmoinfo); |
|
47 | 124 |
RenderHealth(PHedgehog(HH.Hedgehog)^); |
125 |
RecountTeamHealth(PHedgehog(HH.Hedgehog)^.Team) |
|
42 | 126 |
end; |
127 |
end; |
|
128 |
end; |
|
32
78bff13b11c0
With this patch the game doesn't crash when gaming by net
unc0rr
parents:
16
diff
changeset
|
129 |
|
4 | 130 |
const StepTicks: LongWord = 0; |
131 |
||
302 | 132 |
procedure HedgehogStep(Gear: PGear); |
133 |
var PrevdX: integer; |
|
134 |
begin |
|
135 |
if ((Gear.State and (gstAttacking or gstMoving or gstFalling)) = 0) then |
|
4 | 136 |
begin |
80 | 137 |
if ((Gear.Message and gm_LJump ) <> 0) then |
4 | 138 |
begin |
139 |
Gear.Message:= 0; |
|
68 | 140 |
if not TestCollisionYwithGear(Gear, -1) then |
108 | 141 |
if not TestCollisionXwithXYShift(Gear, 0, -2, hwSign(Gear.dX)) then Gear.Y:= Gear.Y - 2 else |
142 |
if not TestCollisionXwithXYShift(Gear, 0, -1, hwSign(Gear.dX)) then Gear.Y:= Gear.Y - 1; |
|
143 |
if not (TestCollisionXwithGear(Gear, hwSign(Gear.dX)) |
|
68 | 144 |
or TestCollisionYwithGear(Gear, -1)) then |
4 | 145 |
begin |
146 |
Gear.dY:= -0.15; |
|
108 | 147 |
Gear.dX:= hwSign(Gear.dX) * 0.15; |
4 | 148 |
Gear.State:= Gear.State or gstFalling or gstHHJumping; |
149 |
exit |
|
150 |
end; |
|
151 |
end; |
|
80 | 152 |
if ((Gear.Message and gm_HJump ) <> 0) then |
4 | 153 |
begin |
154 |
Gear.Message:= 0; |
|
68 | 155 |
if not TestCollisionYwithGear(Gear, -1) then |
4 | 156 |
begin |
157 |
Gear.dY:= -0.20; |
|
108 | 158 |
Gear.dX:= 0.0000001 * hwSign(Gear.dX); |
159 |
Gear.X:= Gear.X - hwSign(Gear.dX)*0.00008; // shift compensation |
|
4 | 160 |
Gear.State:= Gear.State or gstFalling or gstHHJumping; |
161 |
exit |
|
162 |
end; |
|
163 |
end; |
|
108 | 164 |
PrevdX:= hwSign(Gear.dX); |
300 | 165 |
if (Gear.Message and gm_Left )<>0 then Gear.dX:= -cLittle else |
166 |
if (Gear.Message and gm_Right )<>0 then Gear.dX:= cLittle else exit; |
|
74 | 167 |
StepTicks:= cHHStepTicks; |
108 | 168 |
if PrevdX <> hwSign(Gear.dX) then exit; |
4 | 169 |
PHedgehog(Gear.Hedgehog).visStepPos:= (PHedgehog(Gear.Hedgehog).visStepPos + 1) and 7; |
108 | 170 |
if TestCollisionXwithGear(Gear, hwSign(Gear.dX)) then |
4 | 171 |
begin |
108 | 172 |
if not (TestCollisionXwithXYShift(Gear, 0, -6, hwSign(Gear.dX)) |
68 | 173 |
or TestCollisionYwithGear(Gear, -1)) then Gear.Y:= Gear.Y - 1; |
108 | 174 |
if not (TestCollisionXwithXYShift(Gear, 0, -5, hwSign(Gear.dX)) |
68 | 175 |
or TestCollisionYwithGear(Gear, -1)) then Gear.Y:= Gear.Y - 1; |
108 | 176 |
if not (TestCollisionXwithXYShift(Gear, 0, -4, hwSign(Gear.dX)) |
68 | 177 |
or TestCollisionYwithGear(Gear, -1)) then Gear.Y:= Gear.Y - 1; |
108 | 178 |
if not (TestCollisionXwithXYShift(Gear, 0, -3, hwSign(Gear.dX)) |
68 | 179 |
or TestCollisionYwithGear(Gear, -1)) then Gear.Y:= Gear.Y - 1; |
108 | 180 |
if not (TestCollisionXwithXYShift(Gear, 0, -2, hwSign(Gear.dX)) |
68 | 181 |
or TestCollisionYwithGear(Gear, -1)) then Gear.Y:= Gear.Y - 1; |
108 | 182 |
if not (TestCollisionXwithXYShift(Gear, 0, -1, hwSign(Gear.dX)) |
68 | 183 |
or TestCollisionYwithGear(Gear, -1)) then Gear.Y:= Gear.Y - 1; |
4 | 184 |
end; |
300 | 185 |
if not TestCollisionXwithGear(Gear, hwSign(Gear.dX)) then Gear.X:= Gear.X + hwSign(Gear.dX); |
186 |
||
62 | 187 |
SetAllHHToActive; |
37 | 188 |
|
68 | 189 |
if not TestCollisionYwithGear(Gear, 1) then |
4 | 190 |
begin |
191 |
Gear.Y:= Gear.Y + 1; |
|
68 | 192 |
if not TestCollisionYwithGear(Gear, 1) then |
4 | 193 |
begin |
194 |
Gear.Y:= Gear.Y + 1; |
|
68 | 195 |
if not TestCollisionYwithGear(Gear, 1) then |
4 | 196 |
begin |
197 |
Gear.Y:= Gear.Y + 1; |
|
68 | 198 |
if not TestCollisionYwithGear(Gear, 1) then |
4 | 199 |
begin |
200 |
Gear.Y:= Gear.Y + 1; |
|
68 | 201 |
if not TestCollisionYwithGear(Gear, 1) then |
4 | 202 |
begin |
203 |
Gear.Y:= Gear.Y + 1; |
|
68 | 204 |
if not TestCollisionYwithGear(Gear, 1) then |
4 | 205 |
begin |
206 |
Gear.Y:= Gear.Y + 1; |
|
68 | 207 |
if not TestCollisionYwithGear(Gear, 1) then |
4 | 208 |
begin |
209 |
Gear.Y:= Gear.Y - 6; |
|
210 |
Gear.dY:= 0; |
|
211 |
Gear.State:= Gear.State or gstFalling |
|
212 |
end; |
|
213 |
end |
|
214 |
end |
|
215 |
end |
|
216 |
end |
|
217 |
end |
|
62 | 218 |
end |
4 | 219 |
end |
220 |
end; |
|
221 |
||
302 | 222 |
procedure doStepHedgehog(Gear: PGear); forward; |
223 |
//////////////////////////////////////////////////////////////////////////////// |
|
224 |
procedure doStepHedgehogDriven(Gear: PGear); |
|
225 |
var t: PGear; |
|
226 |
begin |
|
227 |
if isInMultiShoot and (Gear.Damage = 0) then |
|
228 |
begin |
|
229 |
exit |
|
230 |
end; |
|
231 |
AllInactive:= false; |
|
232 |
DeleteCI(Gear); |
|
233 |
if (TurnTimeLeft = 0) or (Gear.Damage > 0) then |
|
234 |
begin |
|
235 |
TurnTimeLeft:= 0; |
|
236 |
Gear.State:= Gear.State and not gstHHDriven; |
|
237 |
if Gear.Damage > 0 then |
|
238 |
Gear.State:= Gear.State and not gstHHJumping; |
|
239 |
exit |
|
240 |
end; |
|
241 |
if ((Gear.State and gstFalling) <> 0) or (StepTicks = cHHStepTicks) |
|
242 |
or (CurAmmoGear <> nil) then // we're moving |
|
243 |
begin |
|
244 |
// check for case with ammo |
|
245 |
t:= CheckGearNear(Gear, gtCase, 36, 36); |
|
246 |
if t <> nil then |
|
247 |
PickUp(Gear, t) |
|
248 |
end; |
|
249 |
||
250 |
if CurAmmoGear <> nil then |
|
251 |
begin |
|
252 |
CurAmmoGear.Message:= Gear.Message; |
|
253 |
exit |
|
254 |
end; |
|
255 |
||
256 |
if ((Gear.Message and gm_Attack) <> 0) or |
|
257 |
((Gear.State and gstAttacking) <> 0)then Attack(Gear); |
|
258 |
||
259 |
if (Gear.State and gstFalling) <> 0 then |
|
260 |
begin |
|
261 |
// it could be the source to trick: double-backspace jump -> vertical wall |
|
262 |
// collision - > (abs(Gear.dX) < 0.0000002) -> backspace -> even more high jump |
|
263 |
if ((Gear.Message and gm_HJump) <> 0) and ((Gear.State and gstHHJumping) <> 0) then |
|
264 |
if (abs(Gear.dX) < 2 * cLittle) and (Gear.dY < -0.02) then |
|
265 |
begin |
|
266 |
Gear.dY:= -0.25; |
|
267 |
Gear.dX:= hwSign(Gear.dX) * 0.02 |
|
268 |
end; |
|
269 |
Gear.Message:= Gear.Message and not (gm_LJump or gm_HJump); |
|
270 |
if TestCollisionXwithGear(Gear, hwSign(Gear.dX)) then SetLittle(Gear.dX); |
|
271 |
Gear.X:= Gear.X + Gear.dX; |
|
272 |
Gear.dY:= Gear.dY + cGravity; |
|
273 |
if (Gear.dY < 0)and TestCollisionYwithGear(Gear, -1) then Gear.dY:= 0; |
|
274 |
Gear.Y:= Gear.Y + Gear.dY; |
|
275 |
if (Gear.dY >= 0)and TestCollisionYwithGear(Gear, 1) then |
|
276 |
begin |
|
277 |
CheckHHDamage(Gear); |
|
278 |
if ((abs(Gear.dX) + abs(Gear.dY)) < 0.55) |
|
279 |
and ((Gear.State and gstHHJumping) <> 0) then SetLittle(Gear.dX); |
|
280 |
Gear.State:= Gear.State and not (gstFalling or gstHHJumping); |
|
281 |
StepTicks:= 300; |
|
282 |
Gear.dY:= 0 |
|
283 |
end; |
|
284 |
CheckGearDrowning(Gear); |
|
285 |
exit |
|
286 |
end ;//else if Gear.CollIndex = High(Longword) then AddIntersectorsCR(Gear); |
|
287 |
||
288 |
if ((Gear.State and (gstMoving or gstFalling)) = 0) then |
|
289 |
if (Gear.Message and gm_Up )<>0 then if Gear.Angle > 0 then dec(Gear.Angle) |
|
290 |
else else |
|
291 |
if (Gear.Message and gm_Down )<>0 then if Gear.Angle < cMaxAngle then inc(Gear.Angle); |
|
292 |
||
293 |
if StepTicks > 0 then dec(StepTicks); |
|
294 |
if (StepTicks = 0) then HedgehogStep(Gear) |
|
295 |
end; |
|
296 |
||
4 | 297 |
//////////////////////////////////////////////////////////////////////////////// |
298 |
procedure doStepHedgehogFree(Gear: PGear); |
|
299 |
begin |
|
62 | 300 |
//DeleteCI(Gear); |
68 | 301 |
if not TestCollisionYwithGear(Gear, 1) then |
4 | 302 |
begin |
68 | 303 |
if (Gear.dY < 0) and TestCollisionYwithGear(Gear, -1) then Gear.dY:= 0; |
4 | 304 |
Gear.State:= Gear.State or gstFalling or gstMoving; |
305 |
Gear.dY:= Gear.dY + cGravity |
|
306 |
end else begin |
|
307 |
CheckHHDamage(Gear); |
|
7
b472e4b1a106
Fixed problem with hedgehog physics when turn is over and hedgehog is jumping
unc0rr
parents:
4
diff
changeset
|
308 |
if ((abs(Gear.dX) + abs(Gear.dY)) < 0.55) |
300 | 309 |
and ((Gear.State and gstHHJumping) <> 0) then SetLittle(Gear.dX); |
7
b472e4b1a106
Fixed problem with hedgehog physics when turn is over and hedgehog is jumping
unc0rr
parents:
4
diff
changeset
|
310 |
Gear.State:= Gear.State and not (gstFalling or gstHHJumping); |
74 | 311 |
if Gear.dY > 0 then Gear.dY:= 0; |
4 | 312 |
if ((Gear.State and gstMoving) <> 0) then Gear.dX:= Gear.dX * Gear.Friction |
313 |
end; |
|
314 |
||
53 | 315 |
if (Gear.State <> 0) then DeleteCI(Gear); |
4 | 316 |
|
317 |
if (Gear.State and gstMoving) <> 0 then |
|
108 | 318 |
if TestCollisionXwithGear(Gear, hwSign(Gear.dX)) then |
4 | 319 |
if ((Gear.State and gstFalling) = 0) then |
320 |
if abs(Gear.dX) > 0.01 then |
|
108 | 321 |
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 |
322 |
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 |
|
323 |
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.90; Gear.Y:= Gear.Y - 3 end else |
|
324 |
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 |
|
325 |
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 |
|
149 | 326 |
if abs(Gear.dX) > 0.02 then Gear.dX:= -Gear.Elasticity * Gear.dX |
4 | 327 |
else begin |
328 |
Gear.State:= Gear.State and not gstMoving; |
|
300 | 329 |
SetLittle(Gear.dX) |
4 | 330 |
end |
149 | 331 |
else begin |
332 |
Gear.State:= Gear.State and not gstMoving; |
|
300 | 333 |
SetLittle(Gear.dX) |
149 | 334 |
end |
335 |
else Gear.dX:= -Gear.Elasticity * Gear.dX; |
|
4 | 336 |
|
337 |
if ((Gear.State and gstFalling) = 0)and |
|
338 |
(sqr(Gear.dX) + sqr(Gear.dY) < 0.0008) then |
|
339 |
begin |
|
340 |
Gear.State:= Gear.State and not gstMoving; |
|
300 | 341 |
SetLittle(Gear.dX); |
4 | 342 |
Gear.dY:= 0 |
73 | 343 |
end else Gear.State:= Gear.State or gstMoving; |
4 | 344 |
|
345 |
if (Gear.State and gstMoving) <> 0 then |
|
346 |
begin |
|
347 |
Gear.X:= Gear.X + Gear.dX; |
|
74 | 348 |
Gear.Y:= Gear.Y + Gear.dY; |
349 |
if (Gear.dY > 0) and not TestCollisionYwithGear(Gear, 1) and TestCollisionYwithXYShift(Gear, 0, 1, 1) then |
|
350 |
begin |
|
82 | 351 |
CheckHHDamage(Gear); |
74 | 352 |
Gear.dY:= 0; |
353 |
Gear.Y:= Gear.Y + 1 |
|
354 |
end; |
|
4 | 355 |
end else |
356 |
if Gear.Health = 0 then |
|
357 |
begin |
|
358 |
if AllInactive then |
|
359 |
begin |
|
360 |
doMakeExplosion(round(Gear.X), round(Gear.Y), 30, EXPLAutoSound); |
|
361 |
AddGear(round(Gear.X), round(Gear.Y), gtGrave, 0).Hedgehog:= Gear.Hedgehog; |
|
362 |
DeleteGear(Gear); |
|
363 |
SetAllToActive |
|
364 |
end; |
|
7
b472e4b1a106
Fixed problem with hedgehog physics when turn is over and hedgehog is jumping
unc0rr
parents:
4
diff
changeset
|
365 |
AllInactive:= false; |
4 | 366 |
exit |
367 |
end; |
|
368 |
||
369 |
AllInactive:= false; |
|
370 |
||
371 |
if (not CheckGearDrowning(Gear)) and |
|
372 |
((Gear.State and gstMoving) = 0) then |
|
373 |
begin |
|
374 |
Gear.State:= 0; |
|
375 |
Gear.Active:= false; |
|
53 | 376 |
AddGearCI(Gear); |
4 | 377 |
exit |
378 |
end |
|
379 |
end; |
|
380 |
||
381 |
//////////////////////////////////////////////////////////////////////////////// |
|
382 |
procedure doStepHedgehog(Gear: PGear); |
|
383 |
begin |
|
384 |
if (Gear.Message and gm_Destroy) <> 0 then |
|
385 |
begin |
|
386 |
DeleteGear(Gear); |
|
387 |
exit |
|
388 |
end; |
|
389 |
if (Gear.State and gstHHDriven) = 0 then doStepHedgehogFree(Gear) |
|
390 |
else doStepHedgehogDriven(Gear) |
|
391 |
end; |