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