author | unc0rr |
Mon, 25 Sep 2006 19:48:51 +0000 | |
changeset 166 | 2920ab2bf329 |
parent 149 | aae256899c49 |
child 183 | 57c2ef19f719 |
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 |
* |
5 |
* Distributed under the terms of the BSD-modified licence: |
|
6 |
* |
|
7 |
* Permission is hereby granted, free of charge, to any person obtaining a copy |
|
8 |
* of this software and associated documentation files (the "Software"), to deal |
|
9 |
* with the Software without restriction, including without limitation the |
|
10 |
* rights to use, copy, modify, merge, publish, distribute, sublicense, and/or |
|
11 |
* sell copies of the Software, and to permit persons to whom the Software is |
|
12 |
* furnished to do so, subject to the following conditions: |
|
13 |
* |
|
14 |
* 1. Redistributions of source code must retain the above copyright notice, |
|
15 |
* this list of conditions and the following disclaimer. |
|
16 |
* 2. Redistributions in binary form must reproduce the above copyright notice, |
|
17 |
* this list of conditions and the following disclaimer in the documentation |
|
18 |
* and/or other materials provided with the distribution. |
|
19 |
* 3. The name of the author may not be used to endorse or promote products |
|
20 |
* derived from this software without specific prior written permission. |
|
21 |
* |
|
22 |
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED |
|
23 |
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF |
|
24 |
* MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO |
|
25 |
* EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, |
|
26 |
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, |
|
27 |
* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; |
|
28 |
* OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, |
|
29 |
* WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR |
|
30 |
* OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF |
|
31 |
* ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
|
32 |
*) |
|
33 |
||
37 | 34 |
//////////////////////////////////////////////////////////////////////////////// |
32
78bff13b11c0
With this patch the game doesn't crash when gaming by net
unc0rr
parents:
16
diff
changeset
|
35 |
procedure Attack(Gear: PGear); |
107 | 36 |
var xx, yy: Double; |
32
78bff13b11c0
With this patch the game doesn't crash when gaming by net
unc0rr
parents:
16
diff
changeset
|
37 |
begin |
78bff13b11c0
With this patch the game doesn't crash when gaming by net
unc0rr
parents:
16
diff
changeset
|
38 |
with Gear^, |
95 | 39 |
PHedgehog(Gear.Hedgehog)^ do |
32
78bff13b11c0
With this patch the game doesn't crash when gaming by net
unc0rr
parents:
16
diff
changeset
|
40 |
begin |
95 | 41 |
if ((State and gstHHDriven) <> 0)and |
42 |
// (((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
|
43 |
((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
|
44 |
(((State and gstFalling ) = 0)or((Ammo[CurSlot, CurAmmo].Propz and ammoprop_AttackInFall) <> 0))and |
95 | 45 |
(((State and gstHHJumping) = 0)or((Ammo[CurSlot, CurAmmo].Propz and ammoprop_AttackInJump) <> 0))and |
46 |
((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
|
47 |
begin |
95 | 48 |
State:= State or gstAttacking; |
49 |
if Power = cMaxPower then Message:= Message and not gm_Attack |
|
50 |
else if (Ammo[CurSlot, CurAmmo].Propz and ammoprop_Power) = 0 then Message:= Message and not gm_Attack |
|
51 |
else begin |
|
52 |
if Power = 0 then |
|
53 |
begin |
|
54 |
AttackBar:= CurrentTeam.AttackBar; |
|
55 |
PlaySound(sndThrowPowerUp) |
|
56 |
end; |
|
57 |
inc(Power) |
|
58 |
end; |
|
59 |
if ((Message and gm_Attack) <> 0) then exit; |
|
60 |
||
32
78bff13b11c0
With this patch the game doesn't crash when gaming by net
unc0rr
parents:
16
diff
changeset
|
61 |
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
|
62 |
begin |
78bff13b11c0
With this patch the game doesn't crash when gaming by net
unc0rr
parents:
16
diff
changeset
|
63 |
StopTPUSound; |
78bff13b11c0
With this patch the game doesn't crash when gaming by net
unc0rr
parents:
16
diff
changeset
|
64 |
PlaySound(sndThrowRelease); |
78bff13b11c0
With this patch the game doesn't crash when gaming by net
unc0rr
parents:
16
diff
changeset
|
65 |
end; |
108 | 66 |
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
|
67 |
yy:= -Cos(Angle*pi/cMaxAngle); |
78bff13b11c0
With this patch the game doesn't crash when gaming by net
unc0rr
parents:
16
diff
changeset
|
68 |
case Ammo[CurSlot, CurAmmo].AmmoType of |
78 | 69 |
amGrenade: FollowGear:= AddGear(round(X), round(Y), gtAmmo_Bomb, 0, xx*Power/cPowerDivisor, yy*Power/cPowerDivisor, Ammo[CurSlot, CurAmmo].Timer); |
70 |
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
|
71 |
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
|
72 |
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
|
73 |
amShotgun: begin |
78bff13b11c0
With this patch the game doesn't crash when gaming by net
unc0rr
parents:
16
diff
changeset
|
74 |
PlaySound(sndShotgunReload); |
75 | 75 |
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
|
76 |
end; |
78 | 77 |
amPickHammer: CurAmmoGear:= AddGear(round(Gear.X), round(Gear.Y) + cHHRadius, gtPickHammer, 0); |
78 |
amSkip: TurnTimeLeft:= 0; |
|
79 |
amRope: CurAmmoGear:= AddGear(round(Gear.X), round(Gear.Y), gtRope, 0, xx, yy); |
|
108 | 80 |
amMine: AddGear(round(X) + hwSign(dX) * 7, round(Y), gtMine, 0, hwSign(dX) * 0.02, 0, 3000); |
82 | 81 |
amDEagle: AddGear(round(X), round(Y), gtDEagleShot, 0, xx * 0.5, yy * 0.5); |
108 | 82 |
amDynamite: AddGear(round(X) + hwSign(dX) * 7, round(Y), gtDynamite, 0, hwSign(dX) * 0.035, 0, 5000); |
83 |
amBaseballBat: AddGear(round(X) + hwSign(dX) * 10, round(Y), gtShover, 0, xx * 0.5, yy * 0.5).Radius:= 20; |
|
84 |
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
|
85 |
end; |
78bff13b11c0
With this patch the game doesn't crash when gaming by net
unc0rr
parents:
16
diff
changeset
|
86 |
Power:= 0; |
78bff13b11c0
With this patch the game doesn't crash when gaming by net
unc0rr
parents:
16
diff
changeset
|
87 |
if CurAmmoGear <> nil then |
78bff13b11c0
With this patch the game doesn't crash when gaming by net
unc0rr
parents:
16
diff
changeset
|
88 |
begin |
82 | 89 |
Message:= Message or gm_Attack; |
90 |
CurAmmoGear.Message:= Message |
|
91 |
end else begin |
|
95 | 92 |
if not CurrentTeam.ExtDriven and |
93 |
((Ammo[CurSlot, CurAmmo].Propz and ammoprop_Power) <> 0) then SendIPC('a'); |
|
82 | 94 |
AfterAttack |
95 |
end |
|
95 | 96 |
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
|
97 |
end |
78bff13b11c0
With this patch the game doesn't crash when gaming by net
unc0rr
parents:
16
diff
changeset
|
98 |
end; |
78bff13b11c0
With this patch the game doesn't crash when gaming by net
unc0rr
parents:
16
diff
changeset
|
99 |
|
78bff13b11c0
With this patch the game doesn't crash when gaming by net
unc0rr
parents:
16
diff
changeset
|
100 |
procedure AfterAttack; |
78bff13b11c0
With this patch the game doesn't crash when gaming by net
unc0rr
parents:
16
diff
changeset
|
101 |
begin |
78bff13b11c0
With this patch the game doesn't crash when gaming by net
unc0rr
parents:
16
diff
changeset
|
102 |
with CurrentTeam.Hedgehogs[CurrentTeam.CurrHedgehog].Gear^, |
78bff13b11c0
With this patch the game doesn't crash when gaming by net
unc0rr
parents:
16
diff
changeset
|
103 |
CurrentTeam.Hedgehogs[CurrentTeam.CurrHedgehog] do |
78bff13b11c0
With this patch the game doesn't crash when gaming by net
unc0rr
parents:
16
diff
changeset
|
104 |
begin |
78bff13b11c0
With this patch the game doesn't crash when gaming by net
unc0rr
parents:
16
diff
changeset
|
105 |
Inc(AttacksNum); |
78bff13b11c0
With this patch the game doesn't crash when gaming by net
unc0rr
parents:
16
diff
changeset
|
106 |
State:= State and not gstAttacking; |
78bff13b11c0
With this patch the game doesn't crash when gaming by net
unc0rr
parents:
16
diff
changeset
|
107 |
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
|
108 |
else begin |
78bff13b11c0
With this patch the game doesn't crash when gaming by net
unc0rr
parents:
16
diff
changeset
|
109 |
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
|
110 |
State:= State or gstAttacked; |
78bff13b11c0
With this patch the game doesn't crash when gaming by net
unc0rr
parents:
16
diff
changeset
|
111 |
OnUsedAmmo(Ammo) |
78bff13b11c0
With this patch the game doesn't crash when gaming by net
unc0rr
parents:
16
diff
changeset
|
112 |
end; |
95 | 113 |
AttackBar:= 0; |
32
78bff13b11c0
With this patch the game doesn't crash when gaming by net
unc0rr
parents:
16
diff
changeset
|
114 |
end |
78bff13b11c0
With this patch the game doesn't crash when gaming by net
unc0rr
parents:
16
diff
changeset
|
115 |
end; |
78bff13b11c0
With this patch the game doesn't crash when gaming by net
unc0rr
parents:
16
diff
changeset
|
116 |
|
42 | 117 |
//////////////////////////////////////////////////////////////////////////////// |
118 |
procedure PickUp(HH, Gear: PGear); |
|
119 |
begin |
|
68 | 120 |
Gear.Message:= gm_Destroy; |
42 | 121 |
case Gear.Pos of |
122 |
posCaseHealth: begin |
|
123 |
inc(HH.Health, Gear.Health); |
|
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 |
procedure doStepHedgehog(Gear: PGear); forward; |
131 |
//////////////////////////////////////////////////////////////////////////////// |
|
132 |
procedure doStepHedgehogDriven(Gear: PGear); |
|
133 |
const StepTicks: LongWord = 0; |
|
15 | 134 |
var t: PGear; |
74 | 135 |
PrevdX: integer; |
4 | 136 |
begin |
70 | 137 |
if isInMultiShoot and (Gear.Damage = 0) then |
39 | 138 |
begin |
139 |
exit |
|
140 |
end; |
|
4 | 141 |
AllInactive:= false; |
53 | 142 |
DeleteCI(Gear); |
4 | 143 |
if (TurnTimeLeft = 0) or (Gear.Damage > 0) then |
144 |
begin |
|
75 | 145 |
TurnTimeLeft:= 0; |
4 | 146 |
if ((Gear.State and (gstMoving or gstFalling)) = 0) |
108 | 147 |
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
|
148 |
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
|
149 |
if Gear.Damage > 0 then |
b472e4b1a106
Fixed problem with hedgehog physics when turn is over and hedgehog is jumping
unc0rr
parents:
4
diff
changeset
|
150 |
Gear.State:= Gear.State and not gstHHJumping; |
4 | 151 |
exit |
152 |
end; |
|
70 | 153 |
if ((Gear.State and gstFalling) <> 0) or (StepTicks = cHHStepTicks) |
42 | 154 |
or (CurAmmoGear <> nil) then // we're moving |
15 | 155 |
begin |
42 | 156 |
// check for case with ammo |
157 |
t:= CheckGearNear(Gear, gtCase, 36, 36); |
|
158 |
if t <> nil then |
|
159 |
PickUp(Gear, t) |
|
15 | 160 |
end; |
4 | 161 |
|
162 |
if CurAmmoGear <> nil then |
|
163 |
begin |
|
164 |
CurAmmoGear.Message:= Gear.Message; |
|
165 |
exit |
|
166 |
end; |
|
167 |
||
95 | 168 |
if ((Gear.Message and gm_Attack) <> 0) or |
169 |
((Gear.State and gstAttacking) <> 0)then Attack(Gear); |
|
4 | 170 |
|
171 |
if (Gear.State and gstFalling) <> 0 then |
|
172 |
begin |
|
7
b472e4b1a106
Fixed problem with hedgehog physics when turn is over and hedgehog is jumping
unc0rr
parents:
4
diff
changeset
|
173 |
// 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
|
174 |
// collision - > (abs(Gear.dX) < 0.0000002) -> backspace -> even more high jump |
4 | 175 |
if ((Gear.Message and gm_HJump) <> 0) and ((Gear.State and gstHHJumping) <> 0) then |
176 |
if (abs(Gear.dX) < 0.0000002) and (Gear.dY < -0.02) then |
|
177 |
begin |
|
178 |
Gear.dY:= -0.25; |
|
108 | 179 |
Gear.dX:= hwSign(Gear.dX) * 0.02 |
4 | 180 |
end; |
7
b472e4b1a106
Fixed problem with hedgehog physics when turn is over and hedgehog is jumping
unc0rr
parents:
4
diff
changeset
|
181 |
Gear.Message:= Gear.Message and not (gm_LJump or gm_HJump); |
108 | 182 |
if TestCollisionXwithGear(Gear, hwSign(Gear.dX)) then Gear.dX:= 0.0000001 * hwSign(Gear.dX); |
4 | 183 |
Gear.X:= Gear.X + Gear.dX; |
184 |
Gear.dY:= Gear.dY + cGravity; |
|
82 | 185 |
if (Gear.dY < 0)and TestCollisionYwithGear(Gear, -1) then Gear.dY:= 0; |
4 | 186 |
Gear.Y:= Gear.Y + Gear.dY; |
68 | 187 |
if (Gear.dY >= 0)and TestCollisionYwithGear(Gear, 1) then |
4 | 188 |
begin |
189 |
CheckHHDamage(Gear); |
|
190 |
if ((abs(Gear.dX) + abs(Gear.dY)) < 0.55) |
|
108 | 191 |
and ((Gear.State and gstHHJumping) <> 0) then Gear.dX:= 0.0000001 * hwSign(Gear.dX); |
4 | 192 |
Gear.State:= Gear.State and not (gstFalling or gstHHJumping); |
39 | 193 |
StepTicks:= 300; |
4 | 194 |
Gear.dY:= 0 |
195 |
end; |
|
196 |
CheckGearDrowning(Gear); |
|
197 |
exit |
|
53 | 198 |
end ;//else if Gear.CollIndex = High(Longword) then AddIntersectorsCR(Gear); |
4 | 199 |
|
200 |
if StepTicks > 0 then dec(StepTicks); |
|
201 |
||
202 |
if ((Gear.State and (gstMoving or gstFalling)) = 0) then |
|
203 |
if (Gear.Message and gm_Up )<>0 then if Gear.Angle > 0 then dec(Gear.Angle) |
|
204 |
else else |
|
205 |
if (Gear.Message and gm_Down )<>0 then if Gear.Angle < cMaxAngle then inc(Gear.Angle); |
|
206 |
||
207 |
if ((Gear.State and (gstAttacking or gstMoving or gstFalling)) = 0)and(StepTicks = 0) then |
|
208 |
begin |
|
80 | 209 |
if ((Gear.Message and gm_LJump ) <> 0) then |
4 | 210 |
begin |
211 |
Gear.Message:= 0; |
|
68 | 212 |
if not TestCollisionYwithGear(Gear, -1) then |
108 | 213 |
if not TestCollisionXwithXYShift(Gear, 0, -2, hwSign(Gear.dX)) then Gear.Y:= Gear.Y - 2 else |
214 |
if not TestCollisionXwithXYShift(Gear, 0, -1, hwSign(Gear.dX)) then Gear.Y:= Gear.Y - 1; |
|
215 |
if not (TestCollisionXwithGear(Gear, hwSign(Gear.dX)) |
|
68 | 216 |
or TestCollisionYwithGear(Gear, -1)) then |
4 | 217 |
begin |
218 |
Gear.dY:= -0.15; |
|
108 | 219 |
Gear.dX:= hwSign(Gear.dX) * 0.15; |
4 | 220 |
Gear.State:= Gear.State or gstFalling or gstHHJumping; |
221 |
exit |
|
222 |
end; |
|
223 |
end; |
|
80 | 224 |
if ((Gear.Message and gm_HJump ) <> 0) then |
4 | 225 |
begin |
226 |
Gear.Message:= 0; |
|
68 | 227 |
if not TestCollisionYwithGear(Gear, -1) then |
4 | 228 |
begin |
229 |
Gear.dY:= -0.20; |
|
108 | 230 |
Gear.dX:= 0.0000001 * hwSign(Gear.dX); |
231 |
Gear.X:= Gear.X - hwSign(Gear.dX)*0.00008; // shift compensation |
|
4 | 232 |
Gear.State:= Gear.State or gstFalling or gstHHJumping; |
233 |
exit |
|
234 |
end; |
|
235 |
end; |
|
108 | 236 |
PrevdX:= hwSign(Gear.dX); |
4 | 237 |
if (Gear.Message and gm_Left )<>0 then Gear.dX:= -1.0 else |
238 |
if (Gear.Message and gm_Right )<>0 then Gear.dX:= 1.0 else exit; |
|
74 | 239 |
StepTicks:= cHHStepTicks; |
108 | 240 |
if PrevdX <> hwSign(Gear.dX) then exit; |
4 | 241 |
PHedgehog(Gear.Hedgehog).visStepPos:= (PHedgehog(Gear.Hedgehog).visStepPos + 1) and 7; |
108 | 242 |
if TestCollisionXwithGear(Gear, hwSign(Gear.dX)) then |
4 | 243 |
begin |
108 | 244 |
if not (TestCollisionXwithXYShift(Gear, 0, -6, hwSign(Gear.dX)) |
68 | 245 |
or TestCollisionYwithGear(Gear, -1)) then Gear.Y:= Gear.Y - 1; |
108 | 246 |
if not (TestCollisionXwithXYShift(Gear, 0, -5, hwSign(Gear.dX)) |
68 | 247 |
or TestCollisionYwithGear(Gear, -1)) then Gear.Y:= Gear.Y - 1; |
108 | 248 |
if not (TestCollisionXwithXYShift(Gear, 0, -4, hwSign(Gear.dX)) |
68 | 249 |
or TestCollisionYwithGear(Gear, -1)) then Gear.Y:= Gear.Y - 1; |
108 | 250 |
if not (TestCollisionXwithXYShift(Gear, 0, -3, hwSign(Gear.dX)) |
68 | 251 |
or TestCollisionYwithGear(Gear, -1)) then Gear.Y:= Gear.Y - 1; |
108 | 252 |
if not (TestCollisionXwithXYShift(Gear, 0, -2, hwSign(Gear.dX)) |
68 | 253 |
or TestCollisionYwithGear(Gear, -1)) then Gear.Y:= Gear.Y - 1; |
108 | 254 |
if not (TestCollisionXwithXYShift(Gear, 0, -1, hwSign(Gear.dX)) |
68 | 255 |
or TestCollisionYwithGear(Gear, -1)) then Gear.Y:= Gear.Y - 1; |
4 | 256 |
end; |
108 | 257 |
if not TestCollisionXwithGear(Gear, hwSign(Gear.dX)) then Gear.X:= Gear.X + Gear.dX; |
258 |
Gear.dX:= 0.0000001 * hwSign(Gear.dX); |
|
62 | 259 |
SetAllHHToActive; |
37 | 260 |
|
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 + 1; |
|
68 | 279 |
if not TestCollisionYwithGear(Gear, 1) then |
4 | 280 |
begin |
281 |
Gear.Y:= Gear.Y - 6; |
|
282 |
Gear.dY:= 0; |
|
108 | 283 |
Gear.dX:= 0.0000001 * hwSign(Gear.dX); |
4 | 284 |
Gear.State:= Gear.State or gstFalling |
285 |
end; |
|
286 |
end |
|
287 |
end |
|
288 |
end |
|
289 |
end |
|
290 |
end |
|
62 | 291 |
end |
4 | 292 |
end |
293 |
end; |
|
294 |
||
295 |
//////////////////////////////////////////////////////////////////////////////// |
|
296 |
procedure doStepHedgehogFree(Gear: PGear); |
|
297 |
begin |
|
62 | 298 |
//DeleteCI(Gear); |
68 | 299 |
if not TestCollisionYwithGear(Gear, 1) then |
4 | 300 |
begin |
68 | 301 |
if (Gear.dY < 0) and TestCollisionYwithGear(Gear, -1) then Gear.dY:= 0; |
4 | 302 |
Gear.State:= Gear.State or gstFalling or gstMoving; |
303 |
Gear.dY:= Gear.dY + cGravity |
|
304 |
end else begin |
|
305 |
CheckHHDamage(Gear); |
|
7
b472e4b1a106
Fixed problem with hedgehog physics when turn is over and hedgehog is jumping
unc0rr
parents:
4
diff
changeset
|
306 |
if ((abs(Gear.dX) + abs(Gear.dY)) < 0.55) |
108 | 307 |
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
|
308 |
Gear.State:= Gear.State and not (gstFalling or gstHHJumping); |
74 | 309 |
if Gear.dY > 0 then Gear.dY:= 0; |
4 | 310 |
if ((Gear.State and gstMoving) <> 0) then Gear.dX:= Gear.dX * Gear.Friction |
311 |
end; |
|
312 |
||
53 | 313 |
if (Gear.State <> 0) then DeleteCI(Gear); |
4 | 314 |
|
315 |
if (Gear.State and gstMoving) <> 0 then |
|
108 | 316 |
if TestCollisionXwithGear(Gear, hwSign(Gear.dX)) then |
4 | 317 |
if ((Gear.State and gstFalling) = 0) then |
318 |
if abs(Gear.dX) > 0.01 then |
|
108 | 319 |
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 |
320 |
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 |
|
321 |
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 |
|
322 |
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 |
|
323 |
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 | 324 |
if abs(Gear.dX) > 0.02 then Gear.dX:= -Gear.Elasticity * Gear.dX |
4 | 325 |
else begin |
326 |
Gear.State:= Gear.State and not gstMoving; |
|
108 | 327 |
Gear.dX:= 0.0000001 * hwSign(Gear.dX) |
4 | 328 |
end |
149 | 329 |
else begin |
330 |
Gear.State:= Gear.State and not gstMoving; |
|
331 |
Gear.dX:= 0.0000001 * hwSign(Gear.dX) |
|
332 |
end |
|
333 |
else Gear.dX:= -Gear.Elasticity * Gear.dX; |
|
4 | 334 |
|
335 |
if ((Gear.State and gstFalling) = 0)and |
|
336 |
(sqr(Gear.dX) + sqr(Gear.dY) < 0.0008) then |
|
337 |
begin |
|
338 |
Gear.State:= Gear.State and not gstMoving; |
|
108 | 339 |
Gear.dX:= 0.0000001 * hwSign(Gear.dX); |
4 | 340 |
Gear.dY:= 0 |
73 | 341 |
end else Gear.State:= Gear.State or gstMoving; |
4 | 342 |
|
343 |
if (Gear.State and gstMoving) <> 0 then |
|
344 |
begin |
|
345 |
Gear.X:= Gear.X + Gear.dX; |
|
74 | 346 |
Gear.Y:= Gear.Y + Gear.dY; |
347 |
if (Gear.dY > 0) and not TestCollisionYwithGear(Gear, 1) and TestCollisionYwithXYShift(Gear, 0, 1, 1) then |
|
348 |
begin |
|
82 | 349 |
CheckHHDamage(Gear); |
74 | 350 |
Gear.dY:= 0; |
351 |
Gear.Y:= Gear.Y + 1 |
|
352 |
end; |
|
4 | 353 |
end else |
354 |
if Gear.Health = 0 then |
|
355 |
begin |
|
356 |
if AllInactive then |
|
357 |
begin |
|
358 |
doMakeExplosion(round(Gear.X), round(Gear.Y), 30, EXPLAutoSound); |
|
359 |
AddGear(round(Gear.X), round(Gear.Y), gtGrave, 0).Hedgehog:= Gear.Hedgehog; |
|
360 |
DeleteGear(Gear); |
|
361 |
SetAllToActive |
|
362 |
end; |
|
7
b472e4b1a106
Fixed problem with hedgehog physics when turn is over and hedgehog is jumping
unc0rr
parents:
4
diff
changeset
|
363 |
AllInactive:= false; |
4 | 364 |
exit |
365 |
end; |
|
366 |
||
367 |
AllInactive:= false; |
|
368 |
||
369 |
if (not CheckGearDrowning(Gear)) and |
|
370 |
((Gear.State and gstMoving) = 0) then |
|
371 |
begin |
|
372 |
Gear.State:= 0; |
|
373 |
Gear.Active:= false; |
|
53 | 374 |
AddGearCI(Gear); |
4 | 375 |
exit |
376 |
end |
|
377 |
end; |
|
378 |
||
379 |
//////////////////////////////////////////////////////////////////////////////// |
|
380 |
procedure doStepHedgehog(Gear: PGear); |
|
381 |
begin |
|
382 |
if (Gear.Message and gm_Destroy) <> 0 then |
|
383 |
begin |
|
384 |
DeleteGear(Gear); |
|
385 |
exit |
|
386 |
end; |
|
387 |
if (Gear.State and gstHHDriven) = 0 then doStepHedgehogFree(Gear) |
|
388 |
else doStepHedgehogDriven(Gear) |
|
389 |
end; |