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