author | unc0rr |
Wed, 28 Dec 2005 22:18:11 +0000 | |
changeset 32 | 78bff13b11c0 |
parent 16 | b6f4b413dd41 |
child 37 | 2b7f2a43b999 |
permissions | -rw-r--r-- |
4 | 1 |
(* |
2 |
* Hedgewars, a worms-like game |
|
3 |
* Copyright (c) 2004, 2005 Andrey Korotaev <unC0Rr@gmail.com> |
|
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 |
||
32
78bff13b11c0
With this patch the game doesn't crash when gaming by net
unc0rr
parents:
16
diff
changeset
|
34 |
procedure Attack(Gear: PGear); |
78bff13b11c0
With this patch the game doesn't crash when gaming by net
unc0rr
parents:
16
diff
changeset
|
35 |
var xx, yy: real; |
78bff13b11c0
With this patch the game doesn't crash when gaming by net
unc0rr
parents:
16
diff
changeset
|
36 |
begin |
78bff13b11c0
With this patch the game doesn't crash when gaming by net
unc0rr
parents:
16
diff
changeset
|
37 |
with Gear^, |
78bff13b11c0
With this patch the game doesn't crash when gaming by net
unc0rr
parents:
16
diff
changeset
|
38 |
CurrentTeam.Hedgehogs[CurrentTeam.CurrHedgehog] do |
78bff13b11c0
With this patch the game doesn't crash when gaming by net
unc0rr
parents:
16
diff
changeset
|
39 |
begin |
78bff13b11c0
With this patch the game doesn't crash when gaming by net
unc0rr
parents:
16
diff
changeset
|
40 |
{$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
|
41 |
if CurAmmoGear <> nil then |
78bff13b11c0
With this patch the game doesn't crash when gaming by net
unc0rr
parents:
16
diff
changeset
|
42 |
begin |
78bff13b11c0
With this patch the game doesn't crash when gaming by net
unc0rr
parents:
16
diff
changeset
|
43 |
Message:= Message and not gm_Attack; |
78bff13b11c0
With this patch the game doesn't crash when gaming by net
unc0rr
parents:
16
diff
changeset
|
44 |
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
|
45 |
end; |
78bff13b11c0
With this patch the game doesn't crash when gaming by net
unc0rr
parents:
16
diff
changeset
|
46 |
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
|
47 |
((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
|
48 |
(((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
|
49 |
(((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
|
50 |
(CurAmmoGear = nil) then |
78bff13b11c0
With this patch the game doesn't crash when gaming by net
unc0rr
parents:
16
diff
changeset
|
51 |
begin |
78bff13b11c0
With this patch the game doesn't crash when gaming by net
unc0rr
parents:
16
diff
changeset
|
52 |
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
|
53 |
begin |
78bff13b11c0
With this patch the game doesn't crash when gaming by net
unc0rr
parents:
16
diff
changeset
|
54 |
StopTPUSound; |
78bff13b11c0
With this patch the game doesn't crash when gaming by net
unc0rr
parents:
16
diff
changeset
|
55 |
PlaySound(sndThrowRelease); |
78bff13b11c0
With this patch the game doesn't crash when gaming by net
unc0rr
parents:
16
diff
changeset
|
56 |
end; |
78bff13b11c0
With this patch the game doesn't crash when gaming by net
unc0rr
parents:
16
diff
changeset
|
57 |
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
|
58 |
yy:= -Cos(Angle*pi/cMaxAngle); |
78bff13b11c0
With this patch the game doesn't crash when gaming by net
unc0rr
parents:
16
diff
changeset
|
59 |
case Ammo[CurSlot, CurAmmo].AmmoType of |
78bff13b11c0
With this patch the game doesn't crash when gaming by net
unc0rr
parents:
16
diff
changeset
|
60 |
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
|
61 |
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
|
62 |
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
|
63 |
amShotgun: begin |
78bff13b11c0
With this patch the game doesn't crash when gaming by net
unc0rr
parents:
16
diff
changeset
|
64 |
PlaySound(sndShotgunReload); |
78bff13b11c0
With this patch the game doesn't crash when gaming by net
unc0rr
parents:
16
diff
changeset
|
65 |
FollowGear:= AddGear(round(X + xx*20), round(Y + yy*20), gtShotgunShot, 0, xx * 0.5, 0.5 * yy); |
78bff13b11c0
With this patch the game doesn't crash when gaming by net
unc0rr
parents:
16
diff
changeset
|
66 |
end; |
78bff13b11c0
With this patch the game doesn't crash when gaming by net
unc0rr
parents:
16
diff
changeset
|
67 |
amSkip: TurnTimeLeft:= 0; |
78bff13b11c0
With this patch the game doesn't crash when gaming by net
unc0rr
parents:
16
diff
changeset
|
68 |
amPickHammer: CurAmmoGear:= AddGear(round(Gear.X), round(Gear.Y) + cHHHalfHeight, gtPickHammer, 0); |
78bff13b11c0
With this patch the game doesn't crash when gaming by net
unc0rr
parents:
16
diff
changeset
|
69 |
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
|
70 |
amMine: AddGear(round(X) + Sign(dX) * 7, round(Y), gtMine, 0, Sign(dX) * 0.01, 0, 3000); |
78bff13b11c0
With this patch the game doesn't crash when gaming by net
unc0rr
parents:
16
diff
changeset
|
71 |
end; |
78bff13b11c0
With this patch the game doesn't crash when gaming by net
unc0rr
parents:
16
diff
changeset
|
72 |
Power:= 0; |
78bff13b11c0
With this patch the game doesn't crash when gaming by net
unc0rr
parents:
16
diff
changeset
|
73 |
if CurAmmoGear <> nil then |
78bff13b11c0
With this patch the game doesn't crash when gaming by net
unc0rr
parents:
16
diff
changeset
|
74 |
begin |
78bff13b11c0
With this patch the game doesn't crash when gaming by net
unc0rr
parents:
16
diff
changeset
|
75 |
CurAmmoGear.Message:= Gear.Message; |
78bff13b11c0
With this patch the game doesn't crash when gaming by net
unc0rr
parents:
16
diff
changeset
|
76 |
exit |
78bff13b11c0
With this patch the game doesn't crash when gaming by net
unc0rr
parents:
16
diff
changeset
|
77 |
end else |
78bff13b11c0
With this patch the game doesn't crash when gaming by net
unc0rr
parents:
16
diff
changeset
|
78 |
begin |
78bff13b11c0
With this patch the game doesn't crash when gaming by net
unc0rr
parents:
16
diff
changeset
|
79 |
Message:= Message and not gm_Attack; |
78bff13b11c0
With this patch the game doesn't crash when gaming by net
unc0rr
parents:
16
diff
changeset
|
80 |
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
|
81 |
end; |
78bff13b11c0
With this patch the game doesn't crash when gaming by net
unc0rr
parents:
16
diff
changeset
|
82 |
AfterAttack |
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 |
end; |
78bff13b11c0
With this patch the game doesn't crash when gaming by net
unc0rr
parents:
16
diff
changeset
|
86 |
|
78bff13b11c0
With this patch the game doesn't crash when gaming by net
unc0rr
parents:
16
diff
changeset
|
87 |
procedure AfterAttack; |
78bff13b11c0
With this patch the game doesn't crash when gaming by net
unc0rr
parents:
16
diff
changeset
|
88 |
begin |
78bff13b11c0
With this patch the game doesn't crash when gaming by net
unc0rr
parents:
16
diff
changeset
|
89 |
with CurrentTeam.Hedgehogs[CurrentTeam.CurrHedgehog].Gear^, |
78bff13b11c0
With this patch the game doesn't crash when gaming by net
unc0rr
parents:
16
diff
changeset
|
90 |
CurrentTeam.Hedgehogs[CurrentTeam.CurrHedgehog] do |
78bff13b11c0
With this patch the game doesn't crash when gaming by net
unc0rr
parents:
16
diff
changeset
|
91 |
begin |
78bff13b11c0
With this patch the game doesn't crash when gaming by net
unc0rr
parents:
16
diff
changeset
|
92 |
Inc(AttacksNum); |
78bff13b11c0
With this patch the game doesn't crash when gaming by net
unc0rr
parents:
16
diff
changeset
|
93 |
State:= State and not gstAttacking; |
78bff13b11c0
With this patch the game doesn't crash when gaming by net
unc0rr
parents:
16
diff
changeset
|
94 |
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
|
95 |
else begin |
78bff13b11c0
With this patch the game doesn't crash when gaming by net
unc0rr
parents:
16
diff
changeset
|
96 |
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
|
97 |
State:= State or gstAttacked; |
78bff13b11c0
With this patch the game doesn't crash when gaming by net
unc0rr
parents:
16
diff
changeset
|
98 |
OnUsedAmmo(Ammo) |
78bff13b11c0
With this patch the game doesn't crash when gaming by net
unc0rr
parents:
16
diff
changeset
|
99 |
end; |
78bff13b11c0
With this patch the game doesn't crash when gaming by net
unc0rr
parents:
16
diff
changeset
|
100 |
AttackBar:= 0 |
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 |
end; |
78bff13b11c0
With this patch the game doesn't crash when gaming by net
unc0rr
parents:
16
diff
changeset
|
103 |
|
78bff13b11c0
With this patch the game doesn't crash when gaming by net
unc0rr
parents:
16
diff
changeset
|
104 |
|
78bff13b11c0
With this patch the game doesn't crash when gaming by net
unc0rr
parents:
16
diff
changeset
|
105 |
|
4 | 106 |
procedure doStepHedgehog(Gear: PGear); forward; |
107 |
//////////////////////////////////////////////////////////////////////////////// |
|
108 |
procedure doStepHedgehogDriven(Gear: PGear); |
|
109 |
const StepTicks: LongWord = 0; |
|
15 | 110 |
var t: PGear; |
4 | 111 |
begin |
112 |
if isinMultiShoot and (Gear.Damage = 0) then exit; |
|
113 |
AllInactive:= false; |
|
114 |
if (TurnTimeLeft = 0) or (Gear.Damage > 0) then |
|
115 |
begin |
|
116 |
if ((Gear.State and (gstMoving or gstFalling)) = 0) |
|
117 |
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
|
118 |
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
|
119 |
if Gear.Damage > 0 then |
b472e4b1a106
Fixed problem with hedgehog physics when turn is over and hedgehog is jumping
unc0rr
parents:
4
diff
changeset
|
120 |
Gear.State:= Gear.State and not gstHHJumping; |
4 | 121 |
exit |
122 |
end; |
|
15 | 123 |
|
124 |
// check for case with ammo |
|
16 | 125 |
t:= CheckGearNear(Gear, gtCase, 30, 30); |
15 | 126 |
if t <> nil then |
127 |
begin |
|
128 |
t.Message:= gm_Destroy; |
|
129 |
; // take ammo from it |
|
130 |
end; |
|
4 | 131 |
|
132 |
if CurAmmoGear <> nil then |
|
133 |
begin |
|
134 |
CurAmmoGear.Message:= Gear.Message; |
|
135 |
exit |
|
136 |
end; |
|
137 |
||
138 |
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
|
139 |
if (Gear.State and (gstAttacked or gstHHChooseTarget) = 0) then |
4 | 140 |
with PHedgehog(Gear.Hedgehog)^ do |
141 |
begin |
|
142 |
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
|
143 |
if Gear.Power = cMaxPower then Gear.Message:= Gear.Message and not gm_Attack |
4 | 144 |
else begin |
32
78bff13b11c0
With this patch the game doesn't crash when gaming by net
unc0rr
parents:
16
diff
changeset
|
145 |
if (Ammo[CurSlot, CurAmmo].Propz and ammoprop_Power) = 0 then Attack(Gear) |
4 | 146 |
else begin |
147 |
if Gear.Power = 0 then |
|
148 |
begin |
|
149 |
AttackBar:= CurrentTeam.AttackBar; |
|
150 |
PlaySound(sndThrowPowerUp) |
|
151 |
end; |
|
152 |
inc(Gear.Power) |
|
153 |
end |
|
154 |
end; |
|
155 |
end else Gear.Message:= Gear.Message and not gm_Attack; |
|
156 |
||
32
78bff13b11c0
With this patch the game doesn't crash when gaming by net
unc0rr
parents:
16
diff
changeset
|
157 |
if ((Gear.State and gstAttacking) <> 0) and ((Gear.Message and gm_Attack) = 0) then Attack(Gear); |
4 | 158 |
|
159 |
if (Gear.State and gstFalling) <> 0 then |
|
160 |
begin |
|
7
b472e4b1a106
Fixed problem with hedgehog physics when turn is over and hedgehog is jumping
unc0rr
parents:
4
diff
changeset
|
161 |
// 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
|
162 |
// collision - > (abs(Gear.dX) < 0.0000002) -> backspace -> even more high jump |
4 | 163 |
if ((Gear.Message and gm_HJump) <> 0) and ((Gear.State and gstHHJumping) <> 0) then |
164 |
if (abs(Gear.dX) < 0.0000002) and (Gear.dY < -0.02) then |
|
165 |
begin |
|
166 |
Gear.dY:= -0.25; |
|
167 |
Gear.dX:= Sign(Gear.dX) * 0.02 |
|
168 |
end; |
|
7
b472e4b1a106
Fixed problem with hedgehog physics when turn is over and hedgehog is jumping
unc0rr
parents:
4
diff
changeset
|
169 |
Gear.Message:= Gear.Message and not (gm_LJump or gm_HJump); |
4 | 170 |
if TestCollisionXwithGear(Gear, Sign(Gear.dX)) then Gear.dX:= 0.0000001 * Sign(Gear.dX); |
171 |
Gear.X:= Gear.X + Gear.dX; |
|
172 |
Gear.dY:= Gear.dY + cGravity; |
|
173 |
if (Gear.dY < 0)and TestCollisionYwithGear(Gear, -1) then Gear.dY:= 0; |
|
174 |
Gear.Y:= Gear.Y + Gear.dY; |
|
175 |
if (Gear.dY >= 0)and HHTestCollisionYwithGear(Gear, 1) then |
|
176 |
begin |
|
177 |
CheckHHDamage(Gear); |
|
178 |
if ((abs(Gear.dX) + abs(Gear.dY)) < 0.55) |
|
179 |
and ((Gear.State and gstHHJumping) <> 0) then Gear.dX:= 0.0000001 * Sign(Gear.dX); |
|
180 |
Gear.State:= Gear.State and not (gstFalling or gstHHJumping); |
|
181 |
StepTicks:= 200; |
|
182 |
Gear.dY:= 0 |
|
183 |
end; |
|
184 |
CheckGearDrowning(Gear); |
|
185 |
exit |
|
186 |
end; |
|
187 |
||
188 |
if StepTicks > 0 then dec(StepTicks); |
|
189 |
||
190 |
if ((Gear.State and (gstMoving or gstFalling)) = 0) then |
|
191 |
if (Gear.Message and gm_Up )<>0 then if Gear.Angle > 0 then dec(Gear.Angle) |
|
192 |
else else |
|
193 |
if (Gear.Message and gm_Down )<>0 then if Gear.Angle < cMaxAngle then inc(Gear.Angle); |
|
194 |
||
195 |
if ((Gear.State and (gstAttacking or gstMoving or gstFalling)) = 0)and(StepTicks = 0) then |
|
196 |
begin |
|
197 |
if ((Gear.Message and gm_LJump )<>0) then |
|
198 |
begin |
|
199 |
Gear.Message:= 0; |
|
200 |
if not HHTestCollisionYwithGear(Gear, -1) then |
|
201 |
if not TestCollisionXwithXYShift(Gear, 0, -2, Sign(Gear.dX)) then Gear.Y:= Gear.Y - 2 else |
|
202 |
if not TestCollisionXwithXYShift(Gear, 0, -1, Sign(Gear.dX)) then Gear.Y:= Gear.Y - 1; |
|
203 |
if not (TestCollisionXwithGear(Gear, Sign(Gear.dX)) |
|
204 |
or HHTestCollisionYwithGear(Gear, -1)) then |
|
205 |
begin |
|
206 |
Gear.dY:= -0.15; |
|
207 |
Gear.dX:= Sign(Gear.dX) * 0.15; |
|
208 |
Gear.State:= Gear.State or gstFalling or gstHHJumping; |
|
209 |
exit |
|
210 |
end; |
|
211 |
end; |
|
212 |
if ((Gear.Message and gm_HJump )<>0) then |
|
213 |
begin |
|
214 |
Gear.Message:= 0; |
|
215 |
if not HHTestCollisionYwithGear(Gear, -1) then |
|
216 |
begin |
|
217 |
Gear.dY:= -0.20; |
|
218 |
Gear.dX:= 0.0000001 * Sign(Gear.dX); |
|
219 |
Gear.X:= Gear.X - Sign(Gear.dX)*0.00008; // êîìïåíñàöèÿ ñäâèãà %) |
|
220 |
Gear.State:= Gear.State or gstFalling or gstHHJumping; |
|
221 |
exit |
|
222 |
end; |
|
223 |
end; |
|
224 |
if (Gear.Message and gm_Left )<>0 then Gear.dX:= -1.0 else |
|
225 |
if (Gear.Message and gm_Right )<>0 then Gear.dX:= 1.0 else exit; |
|
226 |
PHedgehog(Gear.Hedgehog).visStepPos:= (PHedgehog(Gear.Hedgehog).visStepPos + 1) and 7; |
|
227 |
StepTicks:= 40; |
|
228 |
if TestCollisionXwithGear(Gear, Sign(Gear.dX)) then |
|
229 |
begin |
|
230 |
if not (TestCollisionXwithXYShift(Gear, 0, -6, Sign(Gear.dX)) |
|
231 |
or HHTestCollisionYwithGear(Gear, -1)) then Gear.Y:= Gear.Y - 1; |
|
232 |
if not (TestCollisionXwithXYShift(Gear, 0, -5, Sign(Gear.dX)) |
|
233 |
or HHTestCollisionYwithGear(Gear, -1)) then Gear.Y:= Gear.Y - 1; |
|
234 |
if not (TestCollisionXwithXYShift(Gear, 0, -4, Sign(Gear.dX)) |
|
235 |
or HHTestCollisionYwithGear(Gear, -1)) then Gear.Y:= Gear.Y - 1; |
|
236 |
if not (TestCollisionXwithXYShift(Gear, 0, -3, Sign(Gear.dX)) |
|
237 |
or HHTestCollisionYwithGear(Gear, -1)) then Gear.Y:= Gear.Y - 1; |
|
238 |
if not (TestCollisionXwithXYShift(Gear, 0, -2, Sign(Gear.dX)) |
|
239 |
or HHTestCollisionYwithGear(Gear, -1)) then Gear.Y:= Gear.Y - 1; |
|
240 |
if not (TestCollisionXwithXYShift(Gear, 0, -1, Sign(Gear.dX)) |
|
241 |
or HHTestCollisionYwithGear(Gear, -1)) then Gear.Y:= Gear.Y - 1; |
|
242 |
end; |
|
243 |
if not TestCollisionXwithGear(Gear, Sign(Gear.dX)) then Gear.X:= Gear.X + Gear.dX; |
|
244 |
||
245 |
if not HHTestCollisionYwithGear(Gear, 1) then |
|
246 |
begin |
|
247 |
Gear.Y:= Gear.Y + 1; |
|
248 |
if not HHTestCollisionYwithGear(Gear, 1) then |
|
249 |
begin |
|
250 |
Gear.Y:= Gear.Y + 1; |
|
251 |
if not HHTestCollisionYwithGear(Gear, 1) then |
|
252 |
begin |
|
253 |
Gear.Y:= Gear.Y + 1; |
|
254 |
if not HHTestCollisionYwithGear(Gear, 1) then |
|
255 |
begin |
|
256 |
Gear.Y:= Gear.Y + 1; |
|
257 |
if not HHTestCollisionYwithGear(Gear, 1) then |
|
258 |
begin |
|
259 |
Gear.Y:= Gear.Y + 1; |
|
260 |
if not HHTestCollisionYwithGear(Gear, 1) then |
|
261 |
begin |
|
262 |
Gear.Y:= Gear.Y + 1; |
|
263 |
if not HHTestCollisionYwithGear(Gear, 1) then |
|
264 |
begin |
|
265 |
Gear.Y:= Gear.Y - 6; |
|
266 |
Gear.dY:= 0; |
|
267 |
Gear.dX:= 0.0000001 * Sign(Gear.dX); |
|
268 |
Gear.State:= Gear.State or gstFalling |
|
269 |
end; |
|
270 |
SetAllHHToActive |
|
271 |
end |
|
272 |
end |
|
273 |
end |
|
274 |
end |
|
275 |
end |
|
276 |
end |
|
277 |
end |
|
278 |
end; |
|
279 |
||
280 |
//////////////////////////////////////////////////////////////////////////////// |
|
281 |
procedure doStepHedgehogFree(Gear: PGear); |
|
282 |
begin |
|
283 |
if not HHTestCollisionYwithGear(Gear, 1) then |
|
284 |
begin |
|
285 |
if (Gear.dY < 0) and HHTestCollisionYwithGear(Gear, -1) then Gear.dY:= 0; |
|
286 |
Gear.State:= Gear.State or gstFalling or gstMoving; |
|
287 |
Gear.dY:= Gear.dY + cGravity |
|
288 |
end else begin |
|
289 |
CheckHHDamage(Gear); |
|
7
b472e4b1a106
Fixed problem with hedgehog physics when turn is over and hedgehog is jumping
unc0rr
parents:
4
diff
changeset
|
290 |
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
|
291 |
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
|
292 |
Gear.State:= Gear.State and not (gstFalling or gstHHJumping); |
4 | 293 |
if Gear.dY > 0 then Gear.dY:= 0; |
294 |
if ((Gear.State and gstMoving) <> 0) then Gear.dX:= Gear.dX * Gear.Friction |
|
295 |
end; |
|
296 |
||
297 |
||
298 |
if (Gear.State and gstMoving) <> 0 then |
|
299 |
if TestCollisionXwithGear(Gear, Sign(Gear.dX)) then |
|
300 |
if ((Gear.State and gstFalling) = 0) then |
|
301 |
if abs(Gear.dX) > 0.01 then |
|
302 |
if not TestCollisionXwithXYShift(Gear, 0, -1, Sign(Gear.dX)) then begin Gear.dX:= Gear.dX * 0.9; Gear.Y:= Gear.Y - 1 end else |
|
303 |
if not TestCollisionXwithXYShift(Gear, 0, -2, Sign(Gear.dX)) then begin Gear.dX:= Gear.dX * 0.9; Gear.Y:= Gear.Y - 2 end else |
|
304 |
if not TestCollisionXwithXYShift(Gear, 0, -3, Sign(Gear.dX)) then begin Gear.dX:= Gear.dX * 0.9; Gear.Y:= Gear.Y - 3 end else |
|
305 |
if not TestCollisionXwithXYShift(Gear, 0, -4, Sign(Gear.dX)) then begin Gear.dX:= Gear.dX * 0.9; Gear.Y:= Gear.Y - 4 end else |
|
306 |
if not TestCollisionXwithXYShift(Gear, 0, -5, Sign(Gear.dX)) then begin Gear.dX:= Gear.dX * 0.3; Gear.Y:= Gear.Y - 5 end else |
|
307 |
if abs(Gear.dX) > 0.02 then Gear.dX:= -0.5 * Gear.dX |
|
308 |
else begin |
|
309 |
Gear.State:= Gear.State and not gstMoving; |
|
310 |
Gear.dX:= 0.0000001 * Sign(Gear.dX) |
|
311 |
end |
|
312 |
else begin |
|
313 |
Gear.State:= Gear.State and not gstMoving; |
|
314 |
Gear.dX:= 0.0000001 * Sign(Gear.dX) |
|
315 |
end |
|
316 |
else Gear.dX:= -0.8 * Gear.dX; |
|
317 |
||
318 |
if ((Gear.State and gstFalling) = 0)and |
|
319 |
(sqr(Gear.dX) + sqr(Gear.dY) < 0.0008) then |
|
320 |
begin |
|
321 |
Gear.State:= Gear.State and not gstMoving; |
|
322 |
Gear.dX:= 0.0000001 * Sign(Gear.dX); |
|
323 |
Gear.dY:= 0 |
|
324 |
end else Gear.State:= Gear.State or gstMoving; |
|
325 |
||
326 |
if (Gear.State and gstMoving) <> 0 then |
|
327 |
begin |
|
328 |
Gear.X:= Gear.X + Gear.dX; |
|
329 |
Gear.Y:= Gear.Y + Gear.dY |
|
330 |
end else |
|
331 |
if Gear.Health = 0 then |
|
332 |
begin |
|
333 |
if AllInactive then |
|
334 |
begin |
|
335 |
doMakeExplosion(round(Gear.X), round(Gear.Y), 30, EXPLAutoSound); |
|
336 |
AddGear(round(Gear.X), round(Gear.Y), gtGrave, 0).Hedgehog:= Gear.Hedgehog; |
|
337 |
DeleteGear(Gear); |
|
338 |
SetAllToActive |
|
339 |
end; |
|
7
b472e4b1a106
Fixed problem with hedgehog physics when turn is over and hedgehog is jumping
unc0rr
parents:
4
diff
changeset
|
340 |
AllInactive:= false; |
4 | 341 |
exit |
342 |
end; |
|
343 |
||
344 |
AllInactive:= false; |
|
345 |
||
346 |
if (not CheckGearDrowning(Gear)) and |
|
347 |
((Gear.State and gstMoving) = 0) then |
|
348 |
begin |
|
349 |
Gear.State:= 0; |
|
350 |
Gear.Active:= false; |
|
351 |
AddGearCR(Gear); |
|
352 |
exit |
|
353 |
end |
|
354 |
end; |
|
355 |
||
356 |
//////////////////////////////////////////////////////////////////////////////// |
|
357 |
procedure doStepHedgehog(Gear: PGear); |
|
358 |
begin |
|
359 |
if (Gear.Message and gm_Destroy) <> 0 then |
|
360 |
begin |
|
361 |
DeleteGear(Gear); |
|
362 |
exit |
|
363 |
end; |
|
364 |
if Gear.CollIndex < High(Longword) then DeleteCR(Gear); |
|
365 |
if (Gear.State and gstHHDriven) = 0 then doStepHedgehogFree(Gear) |
|
366 |
else doStepHedgehogDriven(Gear) |
|
367 |
end; |