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