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