author | sheepluva |
Tue, 29 Jun 2010 22:16:26 +0200 | |
changeset 3590 | 66e1bc1ea3a9 |
parent 3569 | 27b0ec683572 |
child 3603 | b6b1989744ef |
permissions | -rw-r--r-- |
4 | 1 |
(* |
1066 | 2 |
* Hedgewars, a free turn based strategy game |
3236
4ab3917d7d44
Update (c) lines to 2010 as unc0rr requested - they all had varying values so I just took the first year mentioned, then tacked on -2010
nemo
parents:
3038
diff
changeset
|
3 |
* Copyright (c) 2005-2010 Andrey Korotaev <unC0Rr@gmail.com> |
4 | 4 |
* |
183 | 5 |
* This program is free software; you can redistribute it and/or modify |
6 |
* it under the terms of the GNU General Public License as published by |
|
7 |
* the Free Software Foundation; version 2 of the License |
|
4 | 8 |
* |
183 | 9 |
* This program is distributed in the hope that it will be useful, |
10 |
* but WITHOUT ANY WARRANTY; without even the implied warranty of |
|
11 |
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|
12 |
* GNU General Public License for more details. |
|
4 | 13 |
* |
183 | 14 |
* You should have received a copy of the GNU General Public License |
15 |
* along with this program; if not, write to the Free Software |
|
16 |
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA |
|
4 | 17 |
*) |
18 |
||
2630 | 19 |
{$INCLUDE "options.inc"} |
20 |
||
4 | 21 |
unit uCollisions; |
22 |
interface |
|
351 | 23 |
uses uGears, uFloat; |
2630 | 24 |
|
53 | 25 |
const cMaxGearArrayInd = 255; |
4 | 26 |
|
70 | 27 |
type PGearArray = ^TGearArray; |
2948
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2716
diff
changeset
|
28 |
TGearArray = record |
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2716
diff
changeset
|
29 |
ar: array[0..cMaxGearArrayInd] of PGear; |
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2716
diff
changeset
|
30 |
Count: Longword |
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2716
diff
changeset
|
31 |
end; |
4 | 32 |
|
3038 | 33 |
procedure initModule; |
34 |
procedure freeModule; |
|
2716
b9ca1bfca24f
complete the replacement of init/free wrappers for every unit
koda
parents:
2630
diff
changeset
|
35 |
|
53 | 36 |
procedure AddGearCI(Gear: PGear); |
37 |
procedure DeleteCI(Gear: PGear); |
|
513
69e06d710d46
Moving hedgehog could get another hedgehog moving forward
unc0rr
parents:
511
diff
changeset
|
38 |
|
2716
b9ca1bfca24f
complete the replacement of init/free wrappers for every unit
koda
parents:
2630
diff
changeset
|
39 |
function CheckGearsCollision(Gear: PGear): PGearArray; |
513
69e06d710d46
Moving hedgehog could get another hedgehog moving forward
unc0rr
parents:
511
diff
changeset
|
40 |
|
2716
b9ca1bfca24f
complete the replacement of init/free wrappers for every unit
koda
parents:
2630
diff
changeset
|
41 |
function TestCollisionXwithGear(Gear: PGear; Dir: LongInt): boolean; |
b9ca1bfca24f
complete the replacement of init/free wrappers for every unit
koda
parents:
2630
diff
changeset
|
42 |
function TestCollisionYwithGear(Gear: PGear; Dir: LongInt): boolean; |
513
69e06d710d46
Moving hedgehog could get another hedgehog moving forward
unc0rr
parents:
511
diff
changeset
|
43 |
|
2716
b9ca1bfca24f
complete the replacement of init/free wrappers for every unit
koda
parents:
2630
diff
changeset
|
44 |
function TestCollisionXKick(Gear: PGear; Dir: LongInt): boolean; |
b9ca1bfca24f
complete the replacement of init/free wrappers for every unit
koda
parents:
2630
diff
changeset
|
45 |
function TestCollisionYKick(Gear: PGear; Dir: LongInt): boolean; |
513
69e06d710d46
Moving hedgehog could get another hedgehog moving forward
unc0rr
parents:
511
diff
changeset
|
46 |
|
2716
b9ca1bfca24f
complete the replacement of init/free wrappers for every unit
koda
parents:
2630
diff
changeset
|
47 |
function TestCollisionY(Gear: PGear; Dir: LongInt): boolean; |
513
69e06d710d46
Moving hedgehog could get another hedgehog moving forward
unc0rr
parents:
511
diff
changeset
|
48 |
|
2716
b9ca1bfca24f
complete the replacement of init/free wrappers for every unit
koda
parents:
2630
diff
changeset
|
49 |
function TestCollisionXwithXYShift(Gear: PGear; ShiftX: hwFloat; ShiftY: LongInt; Dir: LongInt): boolean; |
b9ca1bfca24f
complete the replacement of init/free wrappers for every unit
koda
parents:
2630
diff
changeset
|
50 |
function TestCollisionYwithXYShift(Gear: PGear; ShiftX, ShiftY: LongInt; Dir: LongInt): boolean; |
4 | 51 |
|
3414
b2f3bb44777e
some portal changes, warning: no loop prevention yet, note: entry angle not preserved yet
sheepluva
parents:
3411
diff
changeset
|
52 |
function calcSlopeTangent(Gear: PGear; collisionX, collisionY: LongInt; var outDeltaX, outDeltaY: LongInt; TestWord: LongWord): Boolean; |
3401
d5d31d16eccc
add a part of my landslide vector collision and use if for the portal gun DirAngle, not flawless yet
sheepluva
parents:
3236
diff
changeset
|
53 |
|
4 | 54 |
implementation |
3407 | 55 |
uses uMisc, uConsts, uLand, uLandGraphics; |
4 | 56 |
|
53 | 57 |
type TCollisionEntry = record |
2948
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2716
diff
changeset
|
58 |
X, Y, Radius: LongInt; |
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2716
diff
changeset
|
59 |
cGear: PGear; |
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2716
diff
changeset
|
60 |
end; |
351 | 61 |
|
906 | 62 |
const MAXRECTSINDEX = 511; |
2716
b9ca1bfca24f
complete the replacement of init/free wrappers for every unit
koda
parents:
2630
diff
changeset
|
63 |
var Count: Longword; |
b9ca1bfca24f
complete the replacement of init/free wrappers for every unit
koda
parents:
2630
diff
changeset
|
64 |
cinfos: array[0..MAXRECTSINDEX] of TCollisionEntry; |
b9ca1bfca24f
complete the replacement of init/free wrappers for every unit
koda
parents:
2630
diff
changeset
|
65 |
ga: TGearArray; |
4 | 66 |
|
53 | 67 |
procedure AddGearCI(Gear: PGear); |
68 |
begin |
|
511 | 69 |
if Gear^.CollisionIndex >= 0 then exit; |
4 | 70 |
TryDo(Count <= MAXRECTSINDEX, 'Collision rects array overflow', true); |
53 | 71 |
with cinfos[Count] do |
2948
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2716
diff
changeset
|
72 |
begin |
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2716
diff
changeset
|
73 |
X:= hwRound(Gear^.X); |
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2716
diff
changeset
|
74 |
Y:= hwRound(Gear^.Y); |
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2716
diff
changeset
|
75 |
Radius:= Gear^.Radius; |
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2716
diff
changeset
|
76 |
ChangeRoundInLand(X, Y, Radius - 1, true); |
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2716
diff
changeset
|
77 |
cGear:= Gear |
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2716
diff
changeset
|
78 |
end; |
511 | 79 |
Gear^.CollisionIndex:= Count; |
4 | 80 |
inc(Count) |
81 |
end; |
|
82 |
||
53 | 83 |
procedure DeleteCI(Gear: PGear); |
4 | 84 |
begin |
511 | 85 |
if Gear^.CollisionIndex >= 0 then |
2948
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2716
diff
changeset
|
86 |
begin |
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2716
diff
changeset
|
87 |
with cinfos[Gear^.CollisionIndex] do |
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2716
diff
changeset
|
88 |
ChangeRoundInLand(X, Y, Radius - 1, false); |
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2716
diff
changeset
|
89 |
cinfos[Gear^.CollisionIndex]:= cinfos[Pred(Count)]; |
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2716
diff
changeset
|
90 |
cinfos[Gear^.CollisionIndex].cGear^.CollisionIndex:= Gear^.CollisionIndex; |
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2716
diff
changeset
|
91 |
Gear^.CollisionIndex:= -1; |
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2716
diff
changeset
|
92 |
dec(Count) |
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2716
diff
changeset
|
93 |
end; |
4 | 94 |
end; |
95 |
||
53 | 96 |
function CheckGearsCollision(Gear: PGear): PGearArray; |
371 | 97 |
var mx, my: LongInt; |
2948
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2716
diff
changeset
|
98 |
i: Longword; |
4 | 99 |
begin |
1506 | 100 |
CheckGearsCollision:= @ga; |
53 | 101 |
ga.Count:= 0; |
12
366adfa1a727
Fix reading out of bounds of the collisions array. This fixes flying hedgehogs and not moving after explosion
unc0rr
parents:
4
diff
changeset
|
102 |
if Count = 0 then exit; |
351 | 103 |
mx:= hwRound(Gear^.X); |
104 |
my:= hwRound(Gear^.Y); |
|
4 | 105 |
|
106 |
for i:= 0 to Pred(Count) do |
|
2948
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2716
diff
changeset
|
107 |
with cinfos[i] do |
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2716
diff
changeset
|
108 |
if (Gear <> cGear) and |
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2716
diff
changeset
|
109 |
(sqr(mx - x) + sqr(my - y) <= sqr(Radius + Gear^.Radius)) then |
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2716
diff
changeset
|
110 |
begin |
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2716
diff
changeset
|
111 |
ga.ar[ga.Count]:= cinfos[i].cGear; |
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2716
diff
changeset
|
112 |
inc(ga.Count) |
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2716
diff
changeset
|
113 |
end |
4 | 114 |
end; |
115 |
||
371 | 116 |
function TestCollisionXwithGear(Gear: PGear; Dir: LongInt): boolean; |
117 |
var x, y, i: LongInt; |
|
2948
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2716
diff
changeset
|
118 |
TestWord: LongWord; |
4 | 119 |
begin |
505
fcba7d7aea0d
Fix old bug with grenade(bomd, etc..) not colliding with attacking hedgehog
unc0rr
parents:
504
diff
changeset
|
120 |
if Gear^.IntersectGear <> nil then |
fcba7d7aea0d
Fix old bug with grenade(bomd, etc..) not colliding with attacking hedgehog
unc0rr
parents:
504
diff
changeset
|
121 |
with Gear^ do |
fcba7d7aea0d
Fix old bug with grenade(bomd, etc..) not colliding with attacking hedgehog
unc0rr
parents:
504
diff
changeset
|
122 |
if (hwRound(IntersectGear^.X) + IntersectGear^.Radius < hwRound(X) - Radius) or |
fcba7d7aea0d
Fix old bug with grenade(bomd, etc..) not colliding with attacking hedgehog
unc0rr
parents:
504
diff
changeset
|
123 |
(hwRound(IntersectGear^.X) - IntersectGear^.Radius > hwRound(X) + Radius) then |
fcba7d7aea0d
Fix old bug with grenade(bomd, etc..) not colliding with attacking hedgehog
unc0rr
parents:
504
diff
changeset
|
124 |
begin |
fcba7d7aea0d
Fix old bug with grenade(bomd, etc..) not colliding with attacking hedgehog
unc0rr
parents:
504
diff
changeset
|
125 |
IntersectGear:= nil; |
fcba7d7aea0d
Fix old bug with grenade(bomd, etc..) not colliding with attacking hedgehog
unc0rr
parents:
504
diff
changeset
|
126 |
TestWord:= 0 |
838 | 127 |
end else |
1966 | 128 |
TestWord:= 255 |
505
fcba7d7aea0d
Fix old bug with grenade(bomd, etc..) not colliding with attacking hedgehog
unc0rr
parents:
504
diff
changeset
|
129 |
else TestWord:= 0; |
838 | 130 |
|
351 | 131 |
x:= hwRound(Gear^.X); |
132 |
if Dir < 0 then x:= x - Gear^.Radius |
|
133 |
else x:= x + Gear^.Radius; |
|
1753 | 134 |
if (x and LAND_WIDTH_MASK) = 0 then |
4 | 135 |
begin |
351 | 136 |
y:= hwRound(Gear^.Y) - Gear^.Radius + 1; |
137 |
i:= y + Gear^.Radius * 2 - 2; |
|
4 | 138 |
repeat |
1753 | 139 |
if (y and LAND_HEIGHT_MASK) = 0 then |
505
fcba7d7aea0d
Fix old bug with grenade(bomd, etc..) not colliding with attacking hedgehog
unc0rr
parents:
504
diff
changeset
|
140 |
if Land[y, x] > TestWord then exit(true); |
4 | 141 |
inc(y) |
351 | 142 |
until (y > i); |
143 |
end; |
|
144 |
TestCollisionXwithGear:= false |
|
4 | 145 |
end; |
146 |
||
505
fcba7d7aea0d
Fix old bug with grenade(bomd, etc..) not colliding with attacking hedgehog
unc0rr
parents:
504
diff
changeset
|
147 |
function TestCollisionYwithGear(Gear: PGear; Dir: LongInt): boolean; |
fcba7d7aea0d
Fix old bug with grenade(bomd, etc..) not colliding with attacking hedgehog
unc0rr
parents:
504
diff
changeset
|
148 |
var x, y, i: LongInt; |
fcba7d7aea0d
Fix old bug with grenade(bomd, etc..) not colliding with attacking hedgehog
unc0rr
parents:
504
diff
changeset
|
149 |
TestWord: LongWord; |
fcba7d7aea0d
Fix old bug with grenade(bomd, etc..) not colliding with attacking hedgehog
unc0rr
parents:
504
diff
changeset
|
150 |
begin |
fcba7d7aea0d
Fix old bug with grenade(bomd, etc..) not colliding with attacking hedgehog
unc0rr
parents:
504
diff
changeset
|
151 |
if Gear^.IntersectGear <> nil then |
fcba7d7aea0d
Fix old bug with grenade(bomd, etc..) not colliding with attacking hedgehog
unc0rr
parents:
504
diff
changeset
|
152 |
with Gear^ do |
fcba7d7aea0d
Fix old bug with grenade(bomd, etc..) not colliding with attacking hedgehog
unc0rr
parents:
504
diff
changeset
|
153 |
if (hwRound(IntersectGear^.Y) + IntersectGear^.Radius < hwRound(Y) - Radius) or |
fcba7d7aea0d
Fix old bug with grenade(bomd, etc..) not colliding with attacking hedgehog
unc0rr
parents:
504
diff
changeset
|
154 |
(hwRound(IntersectGear^.Y) - IntersectGear^.Radius > hwRound(Y) + Radius) then |
fcba7d7aea0d
Fix old bug with grenade(bomd, etc..) not colliding with attacking hedgehog
unc0rr
parents:
504
diff
changeset
|
155 |
begin |
fcba7d7aea0d
Fix old bug with grenade(bomd, etc..) not colliding with attacking hedgehog
unc0rr
parents:
504
diff
changeset
|
156 |
IntersectGear:= nil; |
fcba7d7aea0d
Fix old bug with grenade(bomd, etc..) not colliding with attacking hedgehog
unc0rr
parents:
504
diff
changeset
|
157 |
TestWord:= 0 |
513
69e06d710d46
Moving hedgehog could get another hedgehog moving forward
unc0rr
parents:
511
diff
changeset
|
158 |
end else |
1966 | 159 |
TestWord:= 255 |
505
fcba7d7aea0d
Fix old bug with grenade(bomd, etc..) not colliding with attacking hedgehog
unc0rr
parents:
504
diff
changeset
|
160 |
else TestWord:= 0; |
fcba7d7aea0d
Fix old bug with grenade(bomd, etc..) not colliding with attacking hedgehog
unc0rr
parents:
504
diff
changeset
|
161 |
|
fcba7d7aea0d
Fix old bug with grenade(bomd, etc..) not colliding with attacking hedgehog
unc0rr
parents:
504
diff
changeset
|
162 |
y:= hwRound(Gear^.Y); |
fcba7d7aea0d
Fix old bug with grenade(bomd, etc..) not colliding with attacking hedgehog
unc0rr
parents:
504
diff
changeset
|
163 |
if Dir < 0 then y:= y - Gear^.Radius |
fcba7d7aea0d
Fix old bug with grenade(bomd, etc..) not colliding with attacking hedgehog
unc0rr
parents:
504
diff
changeset
|
164 |
else y:= y + Gear^.Radius; |
1753 | 165 |
if (y and LAND_HEIGHT_MASK) = 0 then |
505
fcba7d7aea0d
Fix old bug with grenade(bomd, etc..) not colliding with attacking hedgehog
unc0rr
parents:
504
diff
changeset
|
166 |
begin |
fcba7d7aea0d
Fix old bug with grenade(bomd, etc..) not colliding with attacking hedgehog
unc0rr
parents:
504
diff
changeset
|
167 |
x:= hwRound(Gear^.X) - Gear^.Radius + 1; |
fcba7d7aea0d
Fix old bug with grenade(bomd, etc..) not colliding with attacking hedgehog
unc0rr
parents:
504
diff
changeset
|
168 |
i:= x + Gear^.Radius * 2 - 2; |
fcba7d7aea0d
Fix old bug with grenade(bomd, etc..) not colliding with attacking hedgehog
unc0rr
parents:
504
diff
changeset
|
169 |
repeat |
1753 | 170 |
if (x and LAND_WIDTH_MASK) = 0 then |
505
fcba7d7aea0d
Fix old bug with grenade(bomd, etc..) not colliding with attacking hedgehog
unc0rr
parents:
504
diff
changeset
|
171 |
if Land[y, x] > TestWord then exit(true); |
fcba7d7aea0d
Fix old bug with grenade(bomd, etc..) not colliding with attacking hedgehog
unc0rr
parents:
504
diff
changeset
|
172 |
inc(x) |
fcba7d7aea0d
Fix old bug with grenade(bomd, etc..) not colliding with attacking hedgehog
unc0rr
parents:
504
diff
changeset
|
173 |
until (x > i); |
fcba7d7aea0d
Fix old bug with grenade(bomd, etc..) not colliding with attacking hedgehog
unc0rr
parents:
504
diff
changeset
|
174 |
end; |
fcba7d7aea0d
Fix old bug with grenade(bomd, etc..) not colliding with attacking hedgehog
unc0rr
parents:
504
diff
changeset
|
175 |
TestCollisionYwithGear:= false |
fcba7d7aea0d
Fix old bug with grenade(bomd, etc..) not colliding with attacking hedgehog
unc0rr
parents:
504
diff
changeset
|
176 |
end; |
fcba7d7aea0d
Fix old bug with grenade(bomd, etc..) not colliding with attacking hedgehog
unc0rr
parents:
504
diff
changeset
|
177 |
|
513
69e06d710d46
Moving hedgehog could get another hedgehog moving forward
unc0rr
parents:
511
diff
changeset
|
178 |
function TestCollisionXKick(Gear: PGear; Dir: LongInt): boolean; |
69e06d710d46
Moving hedgehog could get another hedgehog moving forward
unc0rr
parents:
511
diff
changeset
|
179 |
var x, y, mx, my, i: LongInt; |
69e06d710d46
Moving hedgehog could get another hedgehog moving forward
unc0rr
parents:
511
diff
changeset
|
180 |
flag: boolean; |
69e06d710d46
Moving hedgehog could get another hedgehog moving forward
unc0rr
parents:
511
diff
changeset
|
181 |
begin |
69e06d710d46
Moving hedgehog could get another hedgehog moving forward
unc0rr
parents:
511
diff
changeset
|
182 |
flag:= false; |
69e06d710d46
Moving hedgehog could get another hedgehog moving forward
unc0rr
parents:
511
diff
changeset
|
183 |
x:= hwRound(Gear^.X); |
69e06d710d46
Moving hedgehog could get another hedgehog moving forward
unc0rr
parents:
511
diff
changeset
|
184 |
if Dir < 0 then x:= x - Gear^.Radius |
69e06d710d46
Moving hedgehog could get another hedgehog moving forward
unc0rr
parents:
511
diff
changeset
|
185 |
else x:= x + Gear^.Radius; |
1753 | 186 |
if (x and LAND_WIDTH_MASK) = 0 then |
513
69e06d710d46
Moving hedgehog could get another hedgehog moving forward
unc0rr
parents:
511
diff
changeset
|
187 |
begin |
69e06d710d46
Moving hedgehog could get another hedgehog moving forward
unc0rr
parents:
511
diff
changeset
|
188 |
y:= hwRound(Gear^.Y) - Gear^.Radius + 1; |
69e06d710d46
Moving hedgehog could get another hedgehog moving forward
unc0rr
parents:
511
diff
changeset
|
189 |
i:= y + Gear^.Radius * 2 - 2; |
69e06d710d46
Moving hedgehog could get another hedgehog moving forward
unc0rr
parents:
511
diff
changeset
|
190 |
repeat |
1753 | 191 |
if (y and LAND_HEIGHT_MASK) = 0 then |
1966 | 192 |
if Land[y, x] > 255 then exit(true) |
536 | 193 |
else if Land[y, x] <> 0 then flag:= true; |
513
69e06d710d46
Moving hedgehog could get another hedgehog moving forward
unc0rr
parents:
511
diff
changeset
|
194 |
inc(y) |
69e06d710d46
Moving hedgehog could get another hedgehog moving forward
unc0rr
parents:
511
diff
changeset
|
195 |
until (y > i); |
69e06d710d46
Moving hedgehog could get another hedgehog moving forward
unc0rr
parents:
511
diff
changeset
|
196 |
end; |
538 | 197 |
TestCollisionXKick:= flag; |
513
69e06d710d46
Moving hedgehog could get another hedgehog moving forward
unc0rr
parents:
511
diff
changeset
|
198 |
|
536 | 199 |
if flag then |
513
69e06d710d46
Moving hedgehog could get another hedgehog moving forward
unc0rr
parents:
511
diff
changeset
|
200 |
begin |
538 | 201 |
if hwAbs(Gear^.dX) < cHHKick then exit; |
967 | 202 |
if (Gear^.State and gstHHJumping <> 0) |
203 |
and (hwAbs(Gear^.dX) < _0_4) then exit; |
|
204 |
||
513
69e06d710d46
Moving hedgehog could get another hedgehog moving forward
unc0rr
parents:
511
diff
changeset
|
205 |
mx:= hwRound(Gear^.X); |
69e06d710d46
Moving hedgehog could get another hedgehog moving forward
unc0rr
parents:
511
diff
changeset
|
206 |
my:= hwRound(Gear^.Y); |
69e06d710d46
Moving hedgehog could get another hedgehog moving forward
unc0rr
parents:
511
diff
changeset
|
207 |
|
69e06d710d46
Moving hedgehog could get another hedgehog moving forward
unc0rr
parents:
511
diff
changeset
|
208 |
for i:= 0 to Pred(Count) do |
69e06d710d46
Moving hedgehog could get another hedgehog moving forward
unc0rr
parents:
511
diff
changeset
|
209 |
with cinfos[i] do |
69e06d710d46
Moving hedgehog could get another hedgehog moving forward
unc0rr
parents:
511
diff
changeset
|
210 |
if (Gear <> cGear) and |
855
8842c71d16bf
- Fix too long delay between shotgun and deagle shots
unc0rr
parents:
839
diff
changeset
|
211 |
(sqr(mx - x) + sqr(my - y) <= sqr(Radius + Gear^.Radius + 2)) and |
517 | 212 |
((mx > x) xor (Dir > 0)) then |
3474
c6d308f5a431
Skip collision on X for barrels that aren't knocked over
nemo
parents:
3473
diff
changeset
|
213 |
if ((cGear^.Kind in [gtHedgehog, gtMine]) and ((Gear^.State and gstNotKickable) = 0)) or |
c6d308f5a431
Skip collision on X for barrels that aren't knocked over
nemo
parents:
3473
diff
changeset
|
214 |
// only apply X kick if the barrel is knocked over |
c6d308f5a431
Skip collision on X for barrels that aren't knocked over
nemo
parents:
3473
diff
changeset
|
215 |
((cGear^.Kind = gtExplosives) and ((cGear^.State and gsttmpflag) <> 0)) then |
513
69e06d710d46
Moving hedgehog could get another hedgehog moving forward
unc0rr
parents:
511
diff
changeset
|
216 |
begin |
521 | 217 |
with cGear^ do |
513
69e06d710d46
Moving hedgehog could get another hedgehog moving forward
unc0rr
parents:
511
diff
changeset
|
218 |
begin |
3474
c6d308f5a431
Skip collision on X for barrels that aren't knocked over
nemo
parents:
3473
diff
changeset
|
219 |
dX:= Gear^.dX; |
542 | 220 |
dY:= Gear^.dY * _0_5; |
521 | 221 |
State:= State or gstMoving; |
513
69e06d710d46
Moving hedgehog could get another hedgehog moving forward
unc0rr
parents:
511
diff
changeset
|
222 |
Active:= true |
69e06d710d46
Moving hedgehog could get another hedgehog moving forward
unc0rr
parents:
511
diff
changeset
|
223 |
end; |
521 | 224 |
DeleteCI(cGear); |
538 | 225 |
exit(false) |
226 |
end |
|
513
69e06d710d46
Moving hedgehog could get another hedgehog moving forward
unc0rr
parents:
511
diff
changeset
|
227 |
end |
69e06d710d46
Moving hedgehog could get another hedgehog moving forward
unc0rr
parents:
511
diff
changeset
|
228 |
end; |
69e06d710d46
Moving hedgehog could get another hedgehog moving forward
unc0rr
parents:
511
diff
changeset
|
229 |
|
69e06d710d46
Moving hedgehog could get another hedgehog moving forward
unc0rr
parents:
511
diff
changeset
|
230 |
function TestCollisionYKick(Gear: PGear; Dir: LongInt): boolean; |
69e06d710d46
Moving hedgehog could get another hedgehog moving forward
unc0rr
parents:
511
diff
changeset
|
231 |
var x, y, mx, my, i: LongInt; |
69e06d710d46
Moving hedgehog could get another hedgehog moving forward
unc0rr
parents:
511
diff
changeset
|
232 |
flag: boolean; |
69e06d710d46
Moving hedgehog could get another hedgehog moving forward
unc0rr
parents:
511
diff
changeset
|
233 |
begin |
69e06d710d46
Moving hedgehog could get another hedgehog moving forward
unc0rr
parents:
511
diff
changeset
|
234 |
flag:= false; |
69e06d710d46
Moving hedgehog could get another hedgehog moving forward
unc0rr
parents:
511
diff
changeset
|
235 |
y:= hwRound(Gear^.Y); |
69e06d710d46
Moving hedgehog could get another hedgehog moving forward
unc0rr
parents:
511
diff
changeset
|
236 |
if Dir < 0 then y:= y - Gear^.Radius |
69e06d710d46
Moving hedgehog could get another hedgehog moving forward
unc0rr
parents:
511
diff
changeset
|
237 |
else y:= y + Gear^.Radius; |
1753 | 238 |
if (y and LAND_HEIGHT_MASK) = 0 then |
513
69e06d710d46
Moving hedgehog could get another hedgehog moving forward
unc0rr
parents:
511
diff
changeset
|
239 |
begin |
69e06d710d46
Moving hedgehog could get another hedgehog moving forward
unc0rr
parents:
511
diff
changeset
|
240 |
x:= hwRound(Gear^.X) - Gear^.Radius + 1; |
69e06d710d46
Moving hedgehog could get another hedgehog moving forward
unc0rr
parents:
511
diff
changeset
|
241 |
i:= x + Gear^.Radius * 2 - 2; |
69e06d710d46
Moving hedgehog could get another hedgehog moving forward
unc0rr
parents:
511
diff
changeset
|
242 |
repeat |
1753 | 243 |
if (x and LAND_WIDTH_MASK) = 0 then |
513
69e06d710d46
Moving hedgehog could get another hedgehog moving forward
unc0rr
parents:
511
diff
changeset
|
244 |
if Land[y, x] > 0 then |
1966 | 245 |
if Land[y, x] > 255 then exit(true) |
536 | 246 |
else if Land[y, x] <> 0 then flag:= true; |
513
69e06d710d46
Moving hedgehog could get another hedgehog moving forward
unc0rr
parents:
511
diff
changeset
|
247 |
inc(x) |
69e06d710d46
Moving hedgehog could get another hedgehog moving forward
unc0rr
parents:
511
diff
changeset
|
248 |
until (x > i); |
69e06d710d46
Moving hedgehog could get another hedgehog moving forward
unc0rr
parents:
511
diff
changeset
|
249 |
end; |
538 | 250 |
TestCollisionYKick:= flag; |
513
69e06d710d46
Moving hedgehog could get another hedgehog moving forward
unc0rr
parents:
511
diff
changeset
|
251 |
|
536 | 252 |
if flag then |
513
69e06d710d46
Moving hedgehog could get another hedgehog moving forward
unc0rr
parents:
511
diff
changeset
|
253 |
begin |
839 | 254 |
if hwAbs(Gear^.dY) < cHHKick then exit(true); |
967 | 255 |
if (Gear^.State and gstHHJumping <> 0) |
256 |
and (not Gear^.dY.isNegative) |
|
257 |
and (Gear^.dY < _0_4) then exit; |
|
258 |
||
513
69e06d710d46
Moving hedgehog could get another hedgehog moving forward
unc0rr
parents:
511
diff
changeset
|
259 |
mx:= hwRound(Gear^.X); |
69e06d710d46
Moving hedgehog could get another hedgehog moving forward
unc0rr
parents:
511
diff
changeset
|
260 |
my:= hwRound(Gear^.Y); |
69e06d710d46
Moving hedgehog could get another hedgehog moving forward
unc0rr
parents:
511
diff
changeset
|
261 |
|
69e06d710d46
Moving hedgehog could get another hedgehog moving forward
unc0rr
parents:
511
diff
changeset
|
262 |
for i:= 0 to Pred(Count) do |
69e06d710d46
Moving hedgehog could get another hedgehog moving forward
unc0rr
parents:
511
diff
changeset
|
263 |
with cinfos[i] do |
69e06d710d46
Moving hedgehog could get another hedgehog moving forward
unc0rr
parents:
511
diff
changeset
|
264 |
if (Gear <> cGear) and |
855
8842c71d16bf
- Fix too long delay between shotgun and deagle shots
unc0rr
parents:
839
diff
changeset
|
265 |
(sqr(mx - x) + sqr(my - y) <= sqr(Radius + Gear^.Radius + 2)) and |
513
69e06d710d46
Moving hedgehog could get another hedgehog moving forward
unc0rr
parents:
511
diff
changeset
|
266 |
((my > y) xor (Dir > 0)) then |
3411 | 267 |
if (cGear^.Kind in [gtHedgehog, gtMine, gtExplosives]) and ((Gear^.State and gstNotKickable) = 0) then |
513
69e06d710d46
Moving hedgehog could get another hedgehog moving forward
unc0rr
parents:
511
diff
changeset
|
268 |
begin |
521 | 269 |
with cGear^ do |
513
69e06d710d46
Moving hedgehog could get another hedgehog moving forward
unc0rr
parents:
511
diff
changeset
|
270 |
begin |
3473
f80431269806
Increase minimum threshold for barrel damage to reduce likelihood of blowing one up on jumping out, increase damage to compensate (may need tweaking). Only apply dX for collision w/ kick if barrel is rolling.
nemo
parents:
3414
diff
changeset
|
271 |
if (Kind <> gtExplosives) or ((State and gsttmpflag) <> 0) then dX:= Gear^.dX * _0_5; |
542 | 272 |
dY:= Gear^.dY; |
521 | 273 |
State:= State or gstMoving; |
513
69e06d710d46
Moving hedgehog could get another hedgehog moving forward
unc0rr
parents:
511
diff
changeset
|
274 |
Active:= true |
69e06d710d46
Moving hedgehog could get another hedgehog moving forward
unc0rr
parents:
511
diff
changeset
|
275 |
end; |
521 | 276 |
DeleteCI(cGear); |
538 | 277 |
exit(false) |
278 |
end |
|
513
69e06d710d46
Moving hedgehog could get another hedgehog moving forward
unc0rr
parents:
511
diff
changeset
|
279 |
end |
69e06d710d46
Moving hedgehog could get another hedgehog moving forward
unc0rr
parents:
511
diff
changeset
|
280 |
end; |
69e06d710d46
Moving hedgehog could get another hedgehog moving forward
unc0rr
parents:
511
diff
changeset
|
281 |
|
498 | 282 |
function TestCollisionXwithXYShift(Gear: PGear; ShiftX: hwFloat; ShiftY: LongInt; Dir: LongInt): boolean; |
4 | 283 |
begin |
351 | 284 |
Gear^.X:= Gear^.X + ShiftX; |
498 | 285 |
Gear^.Y:= Gear^.Y + int2hwFloat(ShiftY); |
351 | 286 |
TestCollisionXwithXYShift:= TestCollisionXwithGear(Gear, Dir); |
287 |
Gear^.X:= Gear^.X - ShiftX; |
|
498 | 288 |
Gear^.Y:= Gear^.Y - int2hwFloat(ShiftY) |
4 | 289 |
end; |
290 |
||
371 | 291 |
function TestCollisionY(Gear: PGear; Dir: LongInt): boolean; |
292 |
var x, y, i: LongInt; |
|
68 | 293 |
begin |
351 | 294 |
y:= hwRound(Gear^.Y); |
295 |
if Dir < 0 then y:= y - Gear^.Radius |
|
296 |
else y:= y + Gear^.Radius; |
|
1753 | 297 |
if (y and LAND_HEIGHT_MASK) = 0 then |
68 | 298 |
begin |
351 | 299 |
x:= hwRound(Gear^.X) - Gear^.Radius + 1; |
300 |
i:= x + Gear^.Radius * 2 - 2; |
|
68 | 301 |
repeat |
1753 | 302 |
if (x and LAND_WIDTH_MASK) = 0 then |
1966 | 303 |
if Land[y, x] > 255 then exit(true); |
68 | 304 |
inc(x) |
351 | 305 |
until (x > i); |
306 |
end; |
|
307 |
TestCollisionY:= false |
|
68 | 308 |
end; |
309 |
||
371 | 310 |
function TestCollisionYwithXYShift(Gear: PGear; ShiftX, ShiftY: LongInt; Dir: LongInt): boolean; |
4 | 311 |
begin |
498 | 312 |
Gear^.X:= Gear^.X + int2hwFloat(ShiftX); |
313 |
Gear^.Y:= Gear^.Y + int2hwFloat(ShiftY); |
|
351 | 314 |
TestCollisionYwithXYShift:= TestCollisionYwithGear(Gear, Dir); |
498 | 315 |
Gear^.X:= Gear^.X - int2hwFloat(ShiftX); |
316 |
Gear^.Y:= Gear^.Y - int2hwFloat(ShiftY) |
|
4 | 317 |
end; |
318 |
||
3401
d5d31d16eccc
add a part of my landslide vector collision and use if for the portal gun DirAngle, not flawless yet
sheepluva
parents:
3236
diff
changeset
|
319 |
|
3414
b2f3bb44777e
some portal changes, warning: no loop prevention yet, note: entry angle not preserved yet
sheepluva
parents:
3411
diff
changeset
|
320 |
function calcSlopeTangent(Gear: PGear; collisionX, collisionY: LongInt; var outDeltaX, outDeltaY: LongInt; TestWord: LongWord): boolean; |
3408 | 321 |
var ldx, ldy, rdx, rdy: LongInt; |
322 |
i, j, mx, my, li, ri, jfr, jto, tmpo : ShortInt; |
|
3401
d5d31d16eccc
add a part of my landslide vector collision and use if for the portal gun DirAngle, not flawless yet
sheepluva
parents:
3236
diff
changeset
|
323 |
tmpx, tmpy: LongWord; |
3569 | 324 |
dx, dy, s: hwFloat; |
3408 | 325 |
offset: Array[0..7,0..1] of ShortInt; |
3401
d5d31d16eccc
add a part of my landslide vector collision and use if for the portal gun DirAngle, not flawless yet
sheepluva
parents:
3236
diff
changeset
|
326 |
|
d5d31d16eccc
add a part of my landslide vector collision and use if for the portal gun DirAngle, not flawless yet
sheepluva
parents:
3236
diff
changeset
|
327 |
begin |
d5d31d16eccc
add a part of my landslide vector collision and use if for the portal gun DirAngle, not flawless yet
sheepluva
parents:
3236
diff
changeset
|
328 |
dx:= Gear^.dX; |
d5d31d16eccc
add a part of my landslide vector collision and use if for the portal gun DirAngle, not flawless yet
sheepluva
parents:
3236
diff
changeset
|
329 |
dy:= Gear^.dY; |
3408 | 330 |
|
3569 | 331 |
// we start searching from the direction the gear came from |
332 |
if (dx.QWordValue > _0_995.QWordValue ) |
|
333 |
or (dy.QWordValue > _0_995.QWordValue ) then |
|
334 |
begin // scale |
|
335 |
s := _1 / Distance(dx,dy); |
|
336 |
dx := s * dx; |
|
337 |
dy := s * dy; |
|
338 |
end; |
|
339 |
||
3408 | 340 |
mx:= hwRound(Gear^.X-dx) - hwRound(Gear^.X); |
341 |
my:= hwRound(Gear^.Y-dy) - hwRound(Gear^.Y); |
|
342 |
||
343 |
li:= -1; |
|
344 |
ri:= -1; |
|
3569 | 345 |
|
3408 | 346 |
// go around collision pixel, checking for first/last collisions |
347 |
// this will determinate what angles will be tried to crawl along |
|
348 |
for i:= 0 to 7 do |
|
3401
d5d31d16eccc
add a part of my landslide vector collision and use if for the portal gun DirAngle, not flawless yet
sheepluva
parents:
3236
diff
changeset
|
349 |
begin |
3408 | 350 |
offset[i,0]:= mx; |
351 |
offset[i,1]:= my; |
|
3569 | 352 |
|
3408 | 353 |
tmpx:= collisionX + mx; |
354 |
tmpy:= collisionY + my; |
|
3401
d5d31d16eccc
add a part of my landslide vector collision and use if for the portal gun DirAngle, not flawless yet
sheepluva
parents:
3236
diff
changeset
|
355 |
|
3569 | 356 |
if (((tmpy) and LAND_HEIGHT_MASK) = 0) and (((tmpx) and LAND_WIDTH_MASK) = 0) then |
3408 | 357 |
if (Land[tmpy,tmpx] > TestWord) then |
358 |
begin |
|
359 |
// remember the index belonging to the first and last collision (if in 1st half) |
|
360 |
if (i <> 0) then |
|
361 |
begin |
|
362 |
if (ri = -1) then |
|
363 |
ri:= i |
|
364 |
else |
|
365 |
li:= i; |
|
366 |
end; |
|
367 |
end; |
|
3401
d5d31d16eccc
add a part of my landslide vector collision and use if for the portal gun DirAngle, not flawless yet
sheepluva
parents:
3236
diff
changeset
|
368 |
|
3408 | 369 |
if i = 7 then break; |
3401
d5d31d16eccc
add a part of my landslide vector collision and use if for the portal gun DirAngle, not flawless yet
sheepluva
parents:
3236
diff
changeset
|
370 |
|
3408 | 371 |
// prepare offset for next check (clockwise) |
3401
d5d31d16eccc
add a part of my landslide vector collision and use if for the portal gun DirAngle, not flawless yet
sheepluva
parents:
3236
diff
changeset
|
372 |
if (mx = -1) and (my <> -1) then my:= my - 1 |
d5d31d16eccc
add a part of my landslide vector collision and use if for the portal gun DirAngle, not flawless yet
sheepluva
parents:
3236
diff
changeset
|
373 |
else if (my = -1) and (mx <> 1) then mx:= mx + 1 |
d5d31d16eccc
add a part of my landslide vector collision and use if for the portal gun DirAngle, not flawless yet
sheepluva
parents:
3236
diff
changeset
|
374 |
else if (mx = 1) and (my <> 1) then my:= my + 1 |
d5d31d16eccc
add a part of my landslide vector collision and use if for the portal gun DirAngle, not flawless yet
sheepluva
parents:
3236
diff
changeset
|
375 |
else mx:= mx - 1; |
d5d31d16eccc
add a part of my landslide vector collision and use if for the portal gun DirAngle, not flawless yet
sheepluva
parents:
3236
diff
changeset
|
376 |
|
d5d31d16eccc
add a part of my landslide vector collision and use if for the portal gun DirAngle, not flawless yet
sheepluva
parents:
3236
diff
changeset
|
377 |
end; |
d5d31d16eccc
add a part of my landslide vector collision and use if for the portal gun DirAngle, not flawless yet
sheepluva
parents:
3236
diff
changeset
|
378 |
|
d5d31d16eccc
add a part of my landslide vector collision and use if for the portal gun DirAngle, not flawless yet
sheepluva
parents:
3236
diff
changeset
|
379 |
ldx:= collisionX; |
d5d31d16eccc
add a part of my landslide vector collision and use if for the portal gun DirAngle, not flawless yet
sheepluva
parents:
3236
diff
changeset
|
380 |
ldy:= collisionY; |
d5d31d16eccc
add a part of my landslide vector collision and use if for the portal gun DirAngle, not flawless yet
sheepluva
parents:
3236
diff
changeset
|
381 |
rdx:= collisionX; |
d5d31d16eccc
add a part of my landslide vector collision and use if for the portal gun DirAngle, not flawless yet
sheepluva
parents:
3236
diff
changeset
|
382 |
rdy:= collisionY; |
d5d31d16eccc
add a part of my landslide vector collision and use if for the portal gun DirAngle, not flawless yet
sheepluva
parents:
3236
diff
changeset
|
383 |
|
3408 | 384 |
// edge-crawl |
385 |
for i:= 0 to 8 do |
|
3401
d5d31d16eccc
add a part of my landslide vector collision and use if for the portal gun DirAngle, not flawless yet
sheepluva
parents:
3236
diff
changeset
|
386 |
begin |
3408 | 387 |
// using mx,my as temporary value buffer here |
388 |
||
389 |
jfr:= 8+li+1; |
|
390 |
jto:= 8+li-1; |
|
3401
d5d31d16eccc
add a part of my landslide vector collision and use if for the portal gun DirAngle, not flawless yet
sheepluva
parents:
3236
diff
changeset
|
391 |
|
3408 | 392 |
for j:= jfr downto jto do |
3401
d5d31d16eccc
add a part of my landslide vector collision and use if for the portal gun DirAngle, not flawless yet
sheepluva
parents:
3236
diff
changeset
|
393 |
begin |
3408 | 394 |
tmpo:= j mod 8; |
395 |
tmpx:= ldx + offset[tmpo,0]; |
|
396 |
tmpy:= ldy + offset[tmpo,1]; |
|
397 |
if (((tmpy) and LAND_HEIGHT_MASK) = 0) and (((tmpx) and LAND_WIDTH_MASK) = 0) |
|
398 |
and (Land[tmpy,tmpx] > TestWord) then |
|
3401
d5d31d16eccc
add a part of my landslide vector collision and use if for the portal gun DirAngle, not flawless yet
sheepluva
parents:
3236
diff
changeset
|
399 |
begin |
d5d31d16eccc
add a part of my landslide vector collision and use if for the portal gun DirAngle, not flawless yet
sheepluva
parents:
3236
diff
changeset
|
400 |
ldx:= tmpx; |
d5d31d16eccc
add a part of my landslide vector collision and use if for the portal gun DirAngle, not flawless yet
sheepluva
parents:
3236
diff
changeset
|
401 |
ldy:= tmpy; |
d5d31d16eccc
add a part of my landslide vector collision and use if for the portal gun DirAngle, not flawless yet
sheepluva
parents:
3236
diff
changeset
|
402 |
break; |
d5d31d16eccc
add a part of my landslide vector collision and use if for the portal gun DirAngle, not flawless yet
sheepluva
parents:
3236
diff
changeset
|
403 |
end; |
d5d31d16eccc
add a part of my landslide vector collision and use if for the portal gun DirAngle, not flawless yet
sheepluva
parents:
3236
diff
changeset
|
404 |
end; |
3408 | 405 |
|
406 |
jfr:= 8+ri-1; |
|
407 |
jto:= 8+ri+1; |
|
3401
d5d31d16eccc
add a part of my landslide vector collision and use if for the portal gun DirAngle, not flawless yet
sheepluva
parents:
3236
diff
changeset
|
408 |
|
3408 | 409 |
for j:= jfr to jto do |
3401
d5d31d16eccc
add a part of my landslide vector collision and use if for the portal gun DirAngle, not flawless yet
sheepluva
parents:
3236
diff
changeset
|
410 |
begin |
3408 | 411 |
tmpo:= j mod 8; |
412 |
tmpx:= rdx + offset[tmpo,0]; |
|
413 |
tmpy:= rdy + offset[tmpo,1]; |
|
414 |
if (((tmpy) and LAND_HEIGHT_MASK) = 0) and (((tmpx) and LAND_WIDTH_MASK) = 0) |
|
415 |
and (Land[tmpy,tmpx] > TestWord) then |
|
3401
d5d31d16eccc
add a part of my landslide vector collision and use if for the portal gun DirAngle, not flawless yet
sheepluva
parents:
3236
diff
changeset
|
416 |
begin |
d5d31d16eccc
add a part of my landslide vector collision and use if for the portal gun DirAngle, not flawless yet
sheepluva
parents:
3236
diff
changeset
|
417 |
rdx:= tmpx; |
d5d31d16eccc
add a part of my landslide vector collision and use if for the portal gun DirAngle, not flawless yet
sheepluva
parents:
3236
diff
changeset
|
418 |
rdy:= tmpy; |
d5d31d16eccc
add a part of my landslide vector collision and use if for the portal gun DirAngle, not flawless yet
sheepluva
parents:
3236
diff
changeset
|
419 |
break; |
d5d31d16eccc
add a part of my landslide vector collision and use if for the portal gun DirAngle, not flawless yet
sheepluva
parents:
3236
diff
changeset
|
420 |
end; |
d5d31d16eccc
add a part of my landslide vector collision and use if for the portal gun DirAngle, not flawless yet
sheepluva
parents:
3236
diff
changeset
|
421 |
end; |
d5d31d16eccc
add a part of my landslide vector collision and use if for the portal gun DirAngle, not flawless yet
sheepluva
parents:
3236
diff
changeset
|
422 |
end; |
d5d31d16eccc
add a part of my landslide vector collision and use if for the portal gun DirAngle, not flawless yet
sheepluva
parents:
3236
diff
changeset
|
423 |
|
d5d31d16eccc
add a part of my landslide vector collision and use if for the portal gun DirAngle, not flawless yet
sheepluva
parents:
3236
diff
changeset
|
424 |
ldx:= rdx - ldx; |
d5d31d16eccc
add a part of my landslide vector collision and use if for the portal gun DirAngle, not flawless yet
sheepluva
parents:
3236
diff
changeset
|
425 |
ldy:= rdy - ldy; |
d5d31d16eccc
add a part of my landslide vector collision and use if for the portal gun DirAngle, not flawless yet
sheepluva
parents:
3236
diff
changeset
|
426 |
|
d5d31d16eccc
add a part of my landslide vector collision and use if for the portal gun DirAngle, not flawless yet
sheepluva
parents:
3236
diff
changeset
|
427 |
if ((ldx = 0) and (ldy = 0)) then EXIT(false); |
d5d31d16eccc
add a part of my landslide vector collision and use if for the portal gun DirAngle, not flawless yet
sheepluva
parents:
3236
diff
changeset
|
428 |
|
3414
b2f3bb44777e
some portal changes, warning: no loop prevention yet, note: entry angle not preserved yet
sheepluva
parents:
3411
diff
changeset
|
429 |
outDeltaX:= ldx; |
b2f3bb44777e
some portal changes, warning: no loop prevention yet, note: entry angle not preserved yet
sheepluva
parents:
3411
diff
changeset
|
430 |
outDeltaY:= ldy; |
3408 | 431 |
exit(true); |
3401
d5d31d16eccc
add a part of my landslide vector collision and use if for the portal gun DirAngle, not flawless yet
sheepluva
parents:
3236
diff
changeset
|
432 |
end; |
d5d31d16eccc
add a part of my landslide vector collision and use if for the portal gun DirAngle, not flawless yet
sheepluva
parents:
3236
diff
changeset
|
433 |
|
3038 | 434 |
procedure initModule; |
2716
b9ca1bfca24f
complete the replacement of init/free wrappers for every unit
koda
parents:
2630
diff
changeset
|
435 |
begin |
2948
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2716
diff
changeset
|
436 |
Count:= 0; |
2716
b9ca1bfca24f
complete the replacement of init/free wrappers for every unit
koda
parents:
2630
diff
changeset
|
437 |
end; |
b9ca1bfca24f
complete the replacement of init/free wrappers for every unit
koda
parents:
2630
diff
changeset
|
438 |
|
3038 | 439 |
procedure freeModule; |
2716
b9ca1bfca24f
complete the replacement of init/free wrappers for every unit
koda
parents:
2630
diff
changeset
|
440 |
begin |
b9ca1bfca24f
complete the replacement of init/free wrappers for every unit
koda
parents:
2630
diff
changeset
|
441 |
|
b9ca1bfca24f
complete the replacement of init/free wrappers for every unit
koda
parents:
2630
diff
changeset
|
442 |
end; |
b9ca1bfca24f
complete the replacement of init/free wrappers for every unit
koda
parents:
2630
diff
changeset
|
443 |
|
4 | 444 |
end. |