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