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