author | unc0rr |
Fri, 20 Jan 2006 19:02:50 +0000 | |
changeset 54 | 839fd258ae6f |
parent 53 | 0e27949850e3 |
child 56 | a29135563e94 |
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); |
38 | 66 |
FollowGear:= 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); |
78bff13b11c0
With this patch the game doesn't crash when gaming by net
unc0rr
parents:
16
diff
changeset
|
74 |
amMine: AddGear(round(X) + Sign(dX) * 7, round(Y), gtMine, 0, Sign(dX) * 0.01, 0, 3000); |
39 | 75 |
amDynamite: AddGear(round(X) + Sign(dX) * 7, round(Y), gtDynamite, 0, Sign(dX) * 0.01, 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 |
|
113 |
case Gear.Pos of |
|
114 |
posCaseHealth: begin |
|
115 |
inc(HH.Health, Gear.Health); |
|
47 | 116 |
RenderHealth(PHedgehog(HH.Hedgehog)^); |
117 |
RecountTeamHealth(PHedgehog(HH.Hedgehog)^.Team) |
|
42 | 118 |
end; |
119 |
end; |
|
120 |
end; |
|
32
78bff13b11c0
With this patch the game doesn't crash when gaming by net
unc0rr
parents:
16
diff
changeset
|
121 |
|
4 | 122 |
procedure doStepHedgehog(Gear: PGear); forward; |
123 |
//////////////////////////////////////////////////////////////////////////////// |
|
124 |
procedure doStepHedgehogDriven(Gear: PGear); |
|
125 |
const StepTicks: LongWord = 0; |
|
42 | 126 |
cStepTicks = 38; |
15 | 127 |
var t: PGear; |
4 | 128 |
begin |
39 | 129 |
if isinMultiShoot and (Gear.Damage = 0) then |
130 |
begin |
|
131 |
exit |
|
132 |
end; |
|
4 | 133 |
AllInactive:= false; |
53 | 134 |
DeleteCI(Gear); |
4 | 135 |
if (TurnTimeLeft = 0) or (Gear.Damage > 0) then |
136 |
begin |
|
137 |
if ((Gear.State and (gstMoving or gstFalling)) = 0) |
|
138 |
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
|
139 |
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
|
140 |
if Gear.Damage > 0 then |
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 gstHHJumping; |
4 | 142 |
exit |
143 |
end; |
|
42 | 144 |
if ((Gear.State and gstFalling) <> 0) or (StepTicks = cStepTicks) |
145 |
or (CurAmmoGear <> nil) then // we're moving |
|
15 | 146 |
begin |
42 | 147 |
// check for case with ammo |
148 |
t:= CheckGearNear(Gear, gtCase, 36, 36); |
|
149 |
if t <> nil then |
|
150 |
begin |
|
151 |
t.Message:= gm_Destroy; |
|
152 |
PickUp(Gear, t) |
|
153 |
end; |
|
15 | 154 |
end; |
4 | 155 |
|
156 |
if CurAmmoGear <> nil then |
|
157 |
begin |
|
158 |
CurAmmoGear.Message:= Gear.Message; |
|
159 |
exit |
|
160 |
end; |
|
161 |
||
162 |
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
|
163 |
if (Gear.State and (gstAttacked or gstHHChooseTarget) = 0) then |
4 | 164 |
with PHedgehog(Gear.Hedgehog)^ do |
165 |
begin |
|
166 |
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
|
167 |
if Gear.Power = cMaxPower then Gear.Message:= Gear.Message and not gm_Attack |
37 | 168 |
else |
38 | 169 |
if (Ammo[CurSlot, CurAmmo].Propz and ammoprop_Power) = 0 then |
170 |
Gear.Message:= Gear.Message and not gm_Attack |
|
4 | 171 |
else begin |
172 |
if Gear.Power = 0 then |
|
173 |
begin |
|
174 |
AttackBar:= CurrentTeam.AttackBar; |
|
175 |
PlaySound(sndThrowPowerUp) |
|
176 |
end; |
|
177 |
inc(Gear.Power) |
|
178 |
end |
|
37 | 179 |
end |
180 |
else Gear.Message:= Gear.Message and not gm_Attack; |
|
4 | 181 |
|
37 | 182 |
if ((Gear.State and gstAttacking) <> 0) and ((Gear.Message and gm_Attack) = 0) then |
183 |
begin |
|
184 |
Attack(Gear); |
|
38 | 185 |
StepTicks:= 40 |
37 | 186 |
end; |
4 | 187 |
|
188 |
if (Gear.State and gstFalling) <> 0 then |
|
189 |
begin |
|
7
b472e4b1a106
Fixed problem with hedgehog physics when turn is over and hedgehog is jumping
unc0rr
parents:
4
diff
changeset
|
190 |
// 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
|
191 |
// collision - > (abs(Gear.dX) < 0.0000002) -> backspace -> even more high jump |
4 | 192 |
if ((Gear.Message and gm_HJump) <> 0) and ((Gear.State and gstHHJumping) <> 0) then |
193 |
if (abs(Gear.dX) < 0.0000002) and (Gear.dY < -0.02) then |
|
194 |
begin |
|
195 |
Gear.dY:= -0.25; |
|
196 |
Gear.dX:= Sign(Gear.dX) * 0.02 |
|
197 |
end; |
|
7
b472e4b1a106
Fixed problem with hedgehog physics when turn is over and hedgehog is jumping
unc0rr
parents:
4
diff
changeset
|
198 |
Gear.Message:= Gear.Message and not (gm_LJump or gm_HJump); |
4 | 199 |
if TestCollisionXwithGear(Gear, Sign(Gear.dX)) then Gear.dX:= 0.0000001 * Sign(Gear.dX); |
200 |
Gear.X:= Gear.X + Gear.dX; |
|
201 |
Gear.dY:= Gear.dY + cGravity; |
|
202 |
if (Gear.dY < 0)and TestCollisionYwithGear(Gear, -1) then Gear.dY:= 0; |
|
203 |
Gear.Y:= Gear.Y + Gear.dY; |
|
204 |
if (Gear.dY >= 0)and HHTestCollisionYwithGear(Gear, 1) then |
|
205 |
begin |
|
206 |
CheckHHDamage(Gear); |
|
207 |
if ((abs(Gear.dX) + abs(Gear.dY)) < 0.55) |
|
208 |
and ((Gear.State and gstHHJumping) <> 0) then Gear.dX:= 0.0000001 * Sign(Gear.dX); |
|
209 |
Gear.State:= Gear.State and not (gstFalling or gstHHJumping); |
|
39 | 210 |
StepTicks:= 300; |
4 | 211 |
Gear.dY:= 0 |
212 |
end; |
|
213 |
CheckGearDrowning(Gear); |
|
214 |
exit |
|
53 | 215 |
end ;//else if Gear.CollIndex = High(Longword) then AddIntersectorsCR(Gear); |
4 | 216 |
|
217 |
if StepTicks > 0 then dec(StepTicks); |
|
218 |
||
219 |
if ((Gear.State and (gstMoving or gstFalling)) = 0) then |
|
220 |
if (Gear.Message and gm_Up )<>0 then if Gear.Angle > 0 then dec(Gear.Angle) |
|
221 |
else else |
|
222 |
if (Gear.Message and gm_Down )<>0 then if Gear.Angle < cMaxAngle then inc(Gear.Angle); |
|
223 |
||
224 |
if ((Gear.State and (gstAttacking or gstMoving or gstFalling)) = 0)and(StepTicks = 0) then |
|
225 |
begin |
|
226 |
if ((Gear.Message and gm_LJump )<>0) then |
|
227 |
begin |
|
228 |
Gear.Message:= 0; |
|
229 |
if not HHTestCollisionYwithGear(Gear, -1) then |
|
230 |
if not TestCollisionXwithXYShift(Gear, 0, -2, Sign(Gear.dX)) then Gear.Y:= Gear.Y - 2 else |
|
231 |
if not TestCollisionXwithXYShift(Gear, 0, -1, Sign(Gear.dX)) then Gear.Y:= Gear.Y - 1; |
|
232 |
if not (TestCollisionXwithGear(Gear, Sign(Gear.dX)) |
|
233 |
or HHTestCollisionYwithGear(Gear, -1)) then |
|
234 |
begin |
|
235 |
Gear.dY:= -0.15; |
|
236 |
Gear.dX:= Sign(Gear.dX) * 0.15; |
|
237 |
Gear.State:= Gear.State or gstFalling or gstHHJumping; |
|
238 |
exit |
|
239 |
end; |
|
240 |
end; |
|
241 |
if ((Gear.Message and gm_HJump )<>0) then |
|
242 |
begin |
|
243 |
Gear.Message:= 0; |
|
244 |
if not HHTestCollisionYwithGear(Gear, -1) then |
|
245 |
begin |
|
246 |
Gear.dY:= -0.20; |
|
247 |
Gear.dX:= 0.0000001 * Sign(Gear.dX); |
|
248 |
Gear.X:= Gear.X - Sign(Gear.dX)*0.00008; // êîìïåíñàöèÿ ñäâèãà %) |
|
249 |
Gear.State:= Gear.State or gstFalling or gstHHJumping; |
|
250 |
exit |
|
251 |
end; |
|
252 |
end; |
|
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; |
|
255 |
PHedgehog(Gear.Hedgehog).visStepPos:= (PHedgehog(Gear.Hedgehog).visStepPos + 1) and 7; |
|
42 | 256 |
StepTicks:= cStepTicks; |
4 | 257 |
if TestCollisionXwithGear(Gear, Sign(Gear.dX)) then |
258 |
begin |
|
259 |
if not (TestCollisionXwithXYShift(Gear, 0, -6, Sign(Gear.dX)) |
|
260 |
or HHTestCollisionYwithGear(Gear, -1)) then Gear.Y:= Gear.Y - 1; |
|
261 |
if not (TestCollisionXwithXYShift(Gear, 0, -5, Sign(Gear.dX)) |
|
262 |
or HHTestCollisionYwithGear(Gear, -1)) then Gear.Y:= Gear.Y - 1; |
|
263 |
if not (TestCollisionXwithXYShift(Gear, 0, -4, Sign(Gear.dX)) |
|
264 |
or HHTestCollisionYwithGear(Gear, -1)) then Gear.Y:= Gear.Y - 1; |
|
265 |
if not (TestCollisionXwithXYShift(Gear, 0, -3, Sign(Gear.dX)) |
|
266 |
or HHTestCollisionYwithGear(Gear, -1)) then Gear.Y:= Gear.Y - 1; |
|
267 |
if not (TestCollisionXwithXYShift(Gear, 0, -2, Sign(Gear.dX)) |
|
268 |
or HHTestCollisionYwithGear(Gear, -1)) then Gear.Y:= Gear.Y - 1; |
|
269 |
if not (TestCollisionXwithXYShift(Gear, 0, -1, Sign(Gear.dX)) |
|
270 |
or HHTestCollisionYwithGear(Gear, -1)) then Gear.Y:= Gear.Y - 1; |
|
271 |
end; |
|
272 |
if not TestCollisionXwithGear(Gear, Sign(Gear.dX)) then Gear.X:= Gear.X + Gear.dX; |
|
37 | 273 |
|
4 | 274 |
if not HHTestCollisionYwithGear(Gear, 1) then |
275 |
begin |
|
276 |
Gear.Y:= Gear.Y + 1; |
|
277 |
if not HHTestCollisionYwithGear(Gear, 1) then |
|
278 |
begin |
|
279 |
Gear.Y:= Gear.Y + 1; |
|
280 |
if not HHTestCollisionYwithGear(Gear, 1) then |
|
281 |
begin |
|
282 |
Gear.Y:= Gear.Y + 1; |
|
283 |
if not HHTestCollisionYwithGear(Gear, 1) then |
|
284 |
begin |
|
285 |
Gear.Y:= Gear.Y + 1; |
|
286 |
if not HHTestCollisionYwithGear(Gear, 1) then |
|
287 |
begin |
|
288 |
Gear.Y:= Gear.Y + 1; |
|
289 |
if not HHTestCollisionYwithGear(Gear, 1) then |
|
290 |
begin |
|
291 |
Gear.Y:= Gear.Y + 1; |
|
292 |
if not HHTestCollisionYwithGear(Gear, 1) then |
|
293 |
begin |
|
294 |
Gear.Y:= Gear.Y - 6; |
|
295 |
Gear.dY:= 0; |
|
296 |
Gear.dX:= 0.0000001 * Sign(Gear.dX); |
|
297 |
Gear.State:= Gear.State or gstFalling |
|
298 |
end; |
|
299 |
end |
|
300 |
end |
|
301 |
end |
|
302 |
end |
|
303 |
end |
|
37 | 304 |
end; |
305 |
SetAllHHToActive |
|
4 | 306 |
end |
307 |
end; |
|
308 |
||
309 |
//////////////////////////////////////////////////////////////////////////////// |
|
310 |
procedure doStepHedgehogFree(Gear: PGear); |
|
311 |
begin |
|
312 |
if not HHTestCollisionYwithGear(Gear, 1) then |
|
313 |
begin |
|
314 |
if (Gear.dY < 0) and HHTestCollisionYwithGear(Gear, -1) then Gear.dY:= 0; |
|
315 |
Gear.State:= Gear.State or gstFalling or gstMoving; |
|
316 |
Gear.dY:= Gear.dY + cGravity |
|
317 |
end else begin |
|
318 |
CheckHHDamage(Gear); |
|
7
b472e4b1a106
Fixed problem with hedgehog physics when turn is over and hedgehog is jumping
unc0rr
parents:
4
diff
changeset
|
319 |
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
|
320 |
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
|
321 |
Gear.State:= Gear.State and not (gstFalling or gstHHJumping); |
4 | 322 |
if Gear.dY > 0 then Gear.dY:= 0; |
323 |
if ((Gear.State and gstMoving) <> 0) then Gear.dX:= Gear.dX * Gear.Friction |
|
324 |
end; |
|
325 |
||
53 | 326 |
if (Gear.State <> 0) then DeleteCI(Gear); |
4 | 327 |
|
328 |
if (Gear.State and gstMoving) <> 0 then |
|
329 |
if TestCollisionXwithGear(Gear, Sign(Gear.dX)) then |
|
330 |
if ((Gear.State and gstFalling) = 0) then |
|
331 |
if abs(Gear.dX) > 0.01 then |
|
332 |
if not TestCollisionXwithXYShift(Gear, 0, -1, Sign(Gear.dX)) then begin Gear.dX:= Gear.dX * 0.9; Gear.Y:= Gear.Y - 1 end else |
|
333 |
if not TestCollisionXwithXYShift(Gear, 0, -2, Sign(Gear.dX)) then begin Gear.dX:= Gear.dX * 0.9; Gear.Y:= Gear.Y - 2 end else |
|
334 |
if not TestCollisionXwithXYShift(Gear, 0, -3, Sign(Gear.dX)) then begin Gear.dX:= Gear.dX * 0.9; Gear.Y:= Gear.Y - 3 end else |
|
335 |
if not TestCollisionXwithXYShift(Gear, 0, -4, Sign(Gear.dX)) then begin Gear.dX:= Gear.dX * 0.9; Gear.Y:= Gear.Y - 4 end else |
|
336 |
if not TestCollisionXwithXYShift(Gear, 0, -5, Sign(Gear.dX)) then begin Gear.dX:= Gear.dX * 0.3; Gear.Y:= Gear.Y - 5 end else |
|
337 |
if abs(Gear.dX) > 0.02 then Gear.dX:= -0.5 * Gear.dX |
|
338 |
else begin |
|
339 |
Gear.State:= Gear.State and not gstMoving; |
|
340 |
Gear.dX:= 0.0000001 * Sign(Gear.dX) |
|
341 |
end |
|
342 |
else begin |
|
343 |
Gear.State:= Gear.State and not gstMoving; |
|
344 |
Gear.dX:= 0.0000001 * Sign(Gear.dX) |
|
345 |
end |
|
346 |
else Gear.dX:= -0.8 * Gear.dX; |
|
347 |
||
348 |
if ((Gear.State and gstFalling) = 0)and |
|
349 |
(sqr(Gear.dX) + sqr(Gear.dY) < 0.0008) then |
|
350 |
begin |
|
351 |
Gear.State:= Gear.State and not gstMoving; |
|
352 |
Gear.dX:= 0.0000001 * Sign(Gear.dX); |
|
353 |
Gear.dY:= 0 |
|
354 |
end else Gear.State:= Gear.State or gstMoving; |
|
355 |
||
356 |
if (Gear.State and gstMoving) <> 0 then |
|
357 |
begin |
|
358 |
Gear.X:= Gear.X + Gear.dX; |
|
359 |
Gear.Y:= Gear.Y + Gear.dY |
|
360 |
end else |
|
361 |
if Gear.Health = 0 then |
|
362 |
begin |
|
363 |
if AllInactive then |
|
364 |
begin |
|
365 |
doMakeExplosion(round(Gear.X), round(Gear.Y), 30, EXPLAutoSound); |
|
366 |
AddGear(round(Gear.X), round(Gear.Y), gtGrave, 0).Hedgehog:= Gear.Hedgehog; |
|
367 |
DeleteGear(Gear); |
|
368 |
SetAllToActive |
|
369 |
end; |
|
7
b472e4b1a106
Fixed problem with hedgehog physics when turn is over and hedgehog is jumping
unc0rr
parents:
4
diff
changeset
|
370 |
AllInactive:= false; |
4 | 371 |
exit |
372 |
end; |
|
373 |
||
374 |
AllInactive:= false; |
|
375 |
||
376 |
if (not CheckGearDrowning(Gear)) and |
|
377 |
((Gear.State and gstMoving) = 0) then |
|
378 |
begin |
|
379 |
Gear.State:= 0; |
|
380 |
Gear.Active:= false; |
|
53 | 381 |
AddGearCI(Gear); |
4 | 382 |
exit |
383 |
end |
|
384 |
end; |
|
385 |
||
386 |
//////////////////////////////////////////////////////////////////////////////// |
|
387 |
procedure doStepHedgehog(Gear: PGear); |
|
388 |
begin |
|
389 |
if (Gear.Message and gm_Destroy) <> 0 then |
|
390 |
begin |
|
391 |
DeleteGear(Gear); |
|
392 |
exit |
|
393 |
end; |
|
394 |
if (Gear.State and gstHHDriven) = 0 then doStepHedgehogFree(Gear) |
|
395 |
else doStepHedgehogDriven(Gear) |
|
396 |
end; |