author | mikade <redgrinner@gmail.com> |
Sun, 05 Apr 2015 12:44:54 +0900 | |
changeset 10893 | b085cf83ab4c |
parent 10818 | f642a28cab0c |
child 11046 | 47a8c19ecb60 |
permissions | -rw-r--r-- |
4 | 1 |
(* |
1066 | 2 |
* Hedgewars, a free turn based strategy game |
9998 | 3 |
* Copyright (c) 2004-2014 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 |
|
10108
c68cf030eded
update FSF address. note: two sdl include files (by Sam Lantinga) still have the old FSF address in their copyright - but I ain't gonna touch their copyright headers
sheepluva
parents:
10015
diff
changeset
|
16 |
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA |
4 | 17 |
*) |
18 |
||
2630 | 19 |
{$INCLUDE "options.inc"} |
20 |
||
4 | 21 |
unit uCollisions; |
22 |
interface |
|
4357
a1fcfc341a52
Introduce unit uTypes in order to remove some cyclic unit dependencies
unC0Rr
parents:
3697
diff
changeset
|
23 |
uses uFloat, uTypes; |
2630 | 24 |
|
5290
eea7570d345f
This can afford to be a bit larger. Does not impact performance.
nemo
parents:
4976
diff
changeset
|
25 |
const cMaxGearArrayInd = 1023; |
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 |
6580
6155187bf599
A partial reformatting of the pascal code to have consistent syntax. Things that are still inconsistent.
lovelacer
parents:
6543
diff
changeset
|
29 |
ar: array[0..cMaxGearArrayInd] of PGear; |
6155187bf599
A partial reformatting of the pascal code to have consistent syntax. Things that are still inconsistent.
lovelacer
parents:
6543
diff
changeset
|
30 |
Count: Longword |
6155187bf599
A partial reformatting of the pascal code to have consistent syntax. Things that are still inconsistent.
lovelacer
parents:
6543
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 |
|
9291
15f7bb217b66
Make add/delete consistent (this has bugged me for so long)
nemo
parents:
9247
diff
changeset
|
36 |
procedure AddCI(Gear: PGear); |
53 | 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 |
|
9706
5178d2263521
return land word from uCollisions to make decisions based on it. Should be handy for trampoline.
nemo
parents:
9305
diff
changeset
|
41 |
function TestCollisionXwithGear(Gear: PGear; Dir: LongInt): Word; |
6081
537bbd5c1a62
Basic test implementation of an ice flag. Allows for slick parts of terrain. Intended for ice gun, or "ice" mask on portions of land objects.
nemo
parents:
5919
diff
changeset
|
42 |
function TestCollisionYwithGear(Gear: PGear; Dir: LongInt): Word; |
513
69e06d710d46
Moving hedgehog could get another hedgehog moving forward
unc0rr
parents:
511
diff
changeset
|
43 |
|
9706
5178d2263521
return land word from uCollisions to make decisions based on it. Should be handy for trampoline.
nemo
parents:
9305
diff
changeset
|
44 |
function TestCollisionXKick(Gear: PGear; Dir: LongInt): Word; |
5178d2263521
return land word from uCollisions to make decisions based on it. Should be handy for trampoline.
nemo
parents:
9305
diff
changeset
|
45 |
function TestCollisionYKick(Gear: PGear; Dir: LongInt): Word; |
513
69e06d710d46
Moving hedgehog could get another hedgehog moving forward
unc0rr
parents:
511
diff
changeset
|
46 |
|
9706
5178d2263521
return land word from uCollisions to make decisions based on it. Should be handy for trampoline.
nemo
parents:
9305
diff
changeset
|
47 |
function TestCollisionX(Gear: PGear; Dir: LongInt): Word; |
5178d2263521
return land word from uCollisions to make decisions based on it. Should be handy for trampoline.
nemo
parents:
9305
diff
changeset
|
48 |
function TestCollisionY(Gear: PGear; Dir: LongInt): Word; |
513
69e06d710d46
Moving hedgehog could get another hedgehog moving forward
unc0rr
parents:
511
diff
changeset
|
49 |
|
9706
5178d2263521
return land word from uCollisions to make decisions based on it. Should be handy for trampoline.
nemo
parents:
9305
diff
changeset
|
50 |
function TestCollisionXwithXYShift(Gear: PGear; ShiftX: hwFloat; ShiftY: LongInt; Dir: LongInt): Word; inline; |
5178d2263521
return land word from uCollisions to make decisions based on it. Should be handy for trampoline.
nemo
parents:
9305
diff
changeset
|
51 |
function TestCollisionXwithXYShift(Gear: PGear; ShiftX: hwFloat; ShiftY: LongInt; Dir: LongInt; withGear: boolean): Word; |
5178d2263521
return land word from uCollisions to make decisions based on it. Should be handy for trampoline.
nemo
parents:
9305
diff
changeset
|
52 |
function TestCollisionYwithXYShift(Gear: PGear; ShiftX, ShiftY: LongInt; Dir: LongInt): Word; inline; |
5178d2263521
return land word from uCollisions to make decisions based on it. Should be handy for trampoline.
nemo
parents:
9305
diff
changeset
|
53 |
function TestCollisionYwithXYShift(Gear: PGear; ShiftX, ShiftY: LongInt; Dir: LongInt; withGear: boolean): Word; |
4 | 54 |
|
10818
f642a28cab0c
Add placement of airmines in engine outside of hog proximity. Has a bug, only protecting 1st team. Also fix a spelling error and rename gstHHChooseTarget to gstChooseTarget
nemo
parents:
10635
diff
changeset
|
55 |
function TestRectangleForObstacle(x1, y1, x2, y2: LongInt; landOnly: boolean): boolean; |
6124 | 56 |
|
10354 | 57 |
function CheckCoordInWater(X, Y: LongInt): boolean; inline; |
58 |
||
9248 | 59 |
// returns: negative sign if going downhill to left, value is steepness (noslope/error = _0, 45 = _0_5) |
6279 | 60 |
function CalcSlopeBelowGear(Gear: PGear): hwFloat; |
7754 | 61 |
function CalcSlopeNearGear(Gear: PGear; dirX, dirY: LongInt): hwFloat; |
9706
5178d2263521
return land word from uCollisions to make decisions based on it. Should be handy for trampoline.
nemo
parents:
9305
diff
changeset
|
62 |
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
|
63 |
|
4 | 64 |
implementation |
9737
f0769402350c
fix for: uCollisions.pas(63,50) Hint: Unit "uGearsList" not used in uCollisions
sheepluva
parents:
9731
diff
changeset
|
65 |
uses uConsts, uLandGraphics, uVariables, uDebug; |
4 | 66 |
|
53 | 67 |
type TCollisionEntry = record |
6580
6155187bf599
A partial reformatting of the pascal code to have consistent syntax. Things that are still inconsistent.
lovelacer
parents:
6543
diff
changeset
|
68 |
X, Y, Radius: LongInt; |
6155187bf599
A partial reformatting of the pascal code to have consistent syntax. Things that are still inconsistent.
lovelacer
parents:
6543
diff
changeset
|
69 |
cGear: PGear; |
6155187bf599
A partial reformatting of the pascal code to have consistent syntax. Things that are still inconsistent.
lovelacer
parents:
6543
diff
changeset
|
70 |
end; |
351 | 71 |
|
5568 | 72 |
const MAXRECTSINDEX = 1023; |
2716
b9ca1bfca24f
complete the replacement of init/free wrappers for every unit
koda
parents:
2630
diff
changeset
|
73 |
var Count: Longword; |
b9ca1bfca24f
complete the replacement of init/free wrappers for every unit
koda
parents:
2630
diff
changeset
|
74 |
cinfos: array[0..MAXRECTSINDEX] of TCollisionEntry; |
b9ca1bfca24f
complete the replacement of init/free wrappers for every unit
koda
parents:
2630
diff
changeset
|
75 |
ga: TGearArray; |
4 | 76 |
|
9291
15f7bb217b66
Make add/delete consistent (this has bugged me for so long)
nemo
parents:
9247
diff
changeset
|
77 |
procedure AddCI(Gear: PGear); |
53 | 78 |
begin |
10551
4eefc711309e
Skip checkin on collision for frequently spammed gear types if collision gets huge instead of trying to delete mines.
nemo
parents:
10494
diff
changeset
|
79 |
if (Gear^.CollisionIndex >= 0) or |
4eefc711309e
Skip checkin on collision for frequently spammed gear types if collision gets huge instead of trying to delete mines.
nemo
parents:
10494
diff
changeset
|
80 |
((Count > MAXRECTSINDEX-200) and ((Gear^.Kind = gtMine) or (Gear^.Kind = gtSMine) or (Gear^.Kind = gtKnife))) then |
6580
6155187bf599
A partial reformatting of the pascal code to have consistent syntax. Things that are still inconsistent.
lovelacer
parents:
6543
diff
changeset
|
81 |
exit; |
4 | 82 |
TryDo(Count <= MAXRECTSINDEX, 'Collision rects array overflow', true); |
53 | 83 |
with cinfos[Count] do |
2948
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2716
diff
changeset
|
84 |
begin |
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2716
diff
changeset
|
85 |
X:= hwRound(Gear^.X); |
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2716
diff
changeset
|
86 |
Y:= hwRound(Gear^.Y); |
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2716
diff
changeset
|
87 |
Radius:= Gear^.Radius; |
9247
68bbe56badcc
poor AI thought he should avoid stepping on frozen crates, and jump for non-frozen ones
nemo
parents:
9080
diff
changeset
|
88 |
ChangeRoundInLand(X, Y, Radius - 1, true, (Gear = CurrentHedgehog^.Gear) or ((Gear^.Kind = gtCase) and (Gear^.State and gstFrozen = 0))); |
3608
c509bbc779e7
Revert prior attempted optimisation. Gridding the land pays in some situations, but not all. Restricting to an upper bound might help, but overall, seems too fuzzy to be worth it. On one side is increased cost of Add/Delete + extra test on collision check, on the other is skipping the list iteration. Perhaps for large lists.
nemo
parents:
3603
diff
changeset
|
89 |
cGear:= Gear |
2948
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2716
diff
changeset
|
90 |
end; |
511 | 91 |
Gear^.CollisionIndex:= Count; |
5569
8313952b2811
suggestion of mikade's - delete old mines if the collision array shows signs of filling up. This is kind of an edge case, esp now that array is up to 1024, but should prevent (easiest) way to crash by collision array overflow (endless mines/minestrikes).
nemo
parents:
5568
diff
changeset
|
92 |
inc(Count); |
4 | 93 |
end; |
94 |
||
53 | 95 |
procedure DeleteCI(Gear: PGear); |
4 | 96 |
begin |
511 | 97 |
if Gear^.CollisionIndex >= 0 then |
2948
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2716
diff
changeset
|
98 |
begin |
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2716
diff
changeset
|
99 |
with cinfos[Gear^.CollisionIndex] do |
10635
8e8b320eefad
nil out CurrentHedgehog in FreeModule, add a test for nil'd CurrentHedgehog in DelCI since I'd still like to use DeleteGear for the other stuff it does. Move some variable initialiasations in AI Misc to hopefully avoid some uninit val errors.
nemo
parents:
10551
diff
changeset
|
100 |
ChangeRoundInLand(X, Y, Radius - 1, false, ((CurrentHedgehog <> nil) and (Gear = CurrentHedgehog^.Gear)) or ((Gear^.Kind = gtCase) and (Gear^.State and gstFrozen = 0))); |
2948
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2716
diff
changeset
|
101 |
cinfos[Gear^.CollisionIndex]:= cinfos[Pred(Count)]; |
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2716
diff
changeset
|
102 |
cinfos[Gear^.CollisionIndex].cGear^.CollisionIndex:= Gear^.CollisionIndex; |
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2716
diff
changeset
|
103 |
Gear^.CollisionIndex:= -1; |
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2716
diff
changeset
|
104 |
dec(Count) |
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2716
diff
changeset
|
105 |
end; |
4 | 106 |
end; |
107 |
||
10354 | 108 |
function CheckCoordInWater(X, Y: LongInt): boolean; inline; |
109 |
begin |
|
110 |
CheckCoordInWater:= (Y > cWaterLine) |
|
10494 | 111 |
or ((WorldEdge = weSea) and ((X < LongInt(leftX)) or (X > LongInt(rightX)))); |
10354 | 112 |
end; |
113 |
||
53 | 114 |
function CheckGearsCollision(Gear: PGear): PGearArray; |
3609
bc63ed514b70
Minor fire tweak for readability and lethalness, remove exit condition that was hanging game (identified by jaylittle)
nemo
parents:
3608
diff
changeset
|
115 |
var mx, my, tr: LongInt; |
2948
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2716
diff
changeset
|
116 |
i: Longword; |
4 | 117 |
begin |
1506 | 118 |
CheckGearsCollision:= @ga; |
53 | 119 |
ga.Count:= 0; |
6580
6155187bf599
A partial reformatting of the pascal code to have consistent syntax. Things that are still inconsistent.
lovelacer
parents:
6543
diff
changeset
|
120 |
if Count = 0 then |
6155187bf599
A partial reformatting of the pascal code to have consistent syntax. Things that are still inconsistent.
lovelacer
parents:
6543
diff
changeset
|
121 |
exit; |
351 | 122 |
mx:= hwRound(Gear^.X); |
123 |
my:= hwRound(Gear^.Y); |
|
4 | 124 |
|
4705
593ef1ad3cd3
ok. restore old [r + 1 + r] for gear width for a moment, and reset snowballs.
nemo
parents:
4684
diff
changeset
|
125 |
tr:= Gear^.Radius + 2; |
3609
bc63ed514b70
Minor fire tweak for readability and lethalness, remove exit condition that was hanging game (identified by jaylittle)
nemo
parents:
3608
diff
changeset
|
126 |
|
3608
c509bbc779e7
Revert prior attempted optimisation. Gridding the land pays in some situations, but not all. Restricting to an upper bound might help, but overall, seems too fuzzy to be worth it. On one side is increased cost of Add/Delete + extra test on collision check, on the other is skipping the list iteration. Perhaps for large lists.
nemo
parents:
3603
diff
changeset
|
127 |
for i:= 0 to Pred(Count) do |
c509bbc779e7
Revert prior attempted optimisation. Gridding the land pays in some situations, but not all. Restricting to an upper bound might help, but overall, seems too fuzzy to be worth it. On one side is increased cost of Add/Delete + extra test on collision check, on the other is skipping the list iteration. Perhaps for large lists.
nemo
parents:
3603
diff
changeset
|
128 |
with cinfos[i] do |
c509bbc779e7
Revert prior attempted optimisation. Gridding the land pays in some situations, but not all. Restricting to an upper bound might help, but overall, seems too fuzzy to be worth it. On one side is increased cost of Add/Delete + extra test on collision check, on the other is skipping the list iteration. Perhaps for large lists.
nemo
parents:
3603
diff
changeset
|
129 |
if (Gear <> cGear) and |
3609
bc63ed514b70
Minor fire tweak for readability and lethalness, remove exit condition that was hanging game (identified by jaylittle)
nemo
parents:
3608
diff
changeset
|
130 |
(sqr(mx - x) + sqr(my - y) <= sqr(Radius + tr)) then |
3608
c509bbc779e7
Revert prior attempted optimisation. Gridding the land pays in some situations, but not all. Restricting to an upper bound might help, but overall, seems too fuzzy to be worth it. On one side is increased cost of Add/Delete + extra test on collision check, on the other is skipping the list iteration. Perhaps for large lists.
nemo
parents:
3603
diff
changeset
|
131 |
begin |
c509bbc779e7
Revert prior attempted optimisation. Gridding the land pays in some situations, but not all. Restricting to an upper bound might help, but overall, seems too fuzzy to be worth it. On one side is increased cost of Add/Delete + extra test on collision check, on the other is skipping the list iteration. Perhaps for large lists.
nemo
parents:
3603
diff
changeset
|
132 |
ga.ar[ga.Count]:= cinfos[i].cGear; |
c509bbc779e7
Revert prior attempted optimisation. Gridding the land pays in some situations, but not all. Restricting to an upper bound might help, but overall, seems too fuzzy to be worth it. On one side is increased cost of Add/Delete + extra test on collision check, on the other is skipping the list iteration. Perhaps for large lists.
nemo
parents:
3603
diff
changeset
|
133 |
inc(ga.Count) |
c509bbc779e7
Revert prior attempted optimisation. Gridding the land pays in some situations, but not all. Restricting to an upper bound might help, but overall, seems too fuzzy to be worth it. On one side is increased cost of Add/Delete + extra test on collision check, on the other is skipping the list iteration. Perhaps for large lists.
nemo
parents:
3603
diff
changeset
|
134 |
end |
4 | 135 |
end; |
136 |
||
9706
5178d2263521
return land word from uCollisions to make decisions based on it. Should be handy for trampoline.
nemo
parents:
9305
diff
changeset
|
137 |
function TestCollisionXwithGear(Gear: PGear; Dir: LongInt): Word; |
371 | 138 |
var x, y, i: LongInt; |
4 | 139 |
begin |
7272
71df899c4163
Second part of the change. Make collision check use the new mask bit.
nemo
parents:
7270
diff
changeset
|
140 |
// Special case to emulate the old intersect gear clearing, but with a bit of slop for pixel overlap |
8751
4609823efc94
More flagging of Land values. Also use less than for tests of non-terrain, instead of "and $FF00 = 0". Saves a couple of ops, which actually matters a small amount in a few places.
nemo
parents:
8744
diff
changeset
|
141 |
if (Gear^.CollisionMask = lfNotCurrentMask) and (Gear^.Kind <> gtHedgehog) and (Gear^.Hedgehog <> nil) and (Gear^.Hedgehog^.Gear <> nil) and |
7754 | 142 |
((hwRound(Gear^.Hedgehog^.Gear^.X) + Gear^.Hedgehog^.Gear^.Radius + 16 < hwRound(Gear^.X) - Gear^.Radius) or |
143 |
(hwRound(Gear^.Hedgehog^.Gear^.X) - Gear^.Hedgehog^.Gear^.Radius - 16 > hwRound(Gear^.X) + Gear^.Radius)) then |
|
7272
71df899c4163
Second part of the change. Make collision check use the new mask bit.
nemo
parents:
7270
diff
changeset
|
144 |
Gear^.CollisionMask:= $FFFF; |
838 | 145 |
|
351 | 146 |
x:= hwRound(Gear^.X); |
6580
6155187bf599
A partial reformatting of the pascal code to have consistent syntax. Things that are still inconsistent.
lovelacer
parents:
6543
diff
changeset
|
147 |
if Dir < 0 then |
6155187bf599
A partial reformatting of the pascal code to have consistent syntax. Things that are still inconsistent.
lovelacer
parents:
6543
diff
changeset
|
148 |
x:= x - Gear^.Radius |
6155187bf599
A partial reformatting of the pascal code to have consistent syntax. Things that are still inconsistent.
lovelacer
parents:
6543
diff
changeset
|
149 |
else |
6155187bf599
A partial reformatting of the pascal code to have consistent syntax. Things that are still inconsistent.
lovelacer
parents:
6543
diff
changeset
|
150 |
x:= x + Gear^.Radius; |
6990
40e5af28d026
change every return value into a more pascal-ish form, using the name of the fucntion (helps the parser and macpas compaitilibity)
koda
parents:
6986
diff
changeset
|
151 |
|
1753 | 152 |
if (x and LAND_WIDTH_MASK) = 0 then |
6580
6155187bf599
A partial reformatting of the pascal code to have consistent syntax. Things that are still inconsistent.
lovelacer
parents:
6543
diff
changeset
|
153 |
begin |
6155187bf599
A partial reformatting of the pascal code to have consistent syntax. Things that are still inconsistent.
lovelacer
parents:
6543
diff
changeset
|
154 |
y:= hwRound(Gear^.Y) - Gear^.Radius + 1; |
6155187bf599
A partial reformatting of the pascal code to have consistent syntax. Things that are still inconsistent.
lovelacer
parents:
6543
diff
changeset
|
155 |
i:= y + Gear^.Radius * 2 - 2; |
6155187bf599
A partial reformatting of the pascal code to have consistent syntax. Things that are still inconsistent.
lovelacer
parents:
6543
diff
changeset
|
156 |
repeat |
6155187bf599
A partial reformatting of the pascal code to have consistent syntax. Things that are still inconsistent.
lovelacer
parents:
6543
diff
changeset
|
157 |
if (y and LAND_HEIGHT_MASK) = 0 then |
7272
71df899c4163
Second part of the change. Make collision check use the new mask bit.
nemo
parents:
7270
diff
changeset
|
158 |
if Land[y, x] and Gear^.CollisionMask <> 0 then |
9731
953197ac43d8
Make sticky mine respect lfBouncy, make hogs do same, kinda... make uCollisions return land w/ mask, restrict bouncy to advbounce gears only, which means piano doesn't bounce anymore
nemo
parents:
9708
diff
changeset
|
159 |
exit(Land[y, x] and Gear^.CollisionMask); |
6580
6155187bf599
A partial reformatting of the pascal code to have consistent syntax. Things that are still inconsistent.
lovelacer
parents:
6543
diff
changeset
|
160 |
inc(y) |
6155187bf599
A partial reformatting of the pascal code to have consistent syntax. Things that are still inconsistent.
lovelacer
parents:
6543
diff
changeset
|
161 |
until (y > i); |
6155187bf599
A partial reformatting of the pascal code to have consistent syntax. Things that are still inconsistent.
lovelacer
parents:
6543
diff
changeset
|
162 |
end; |
9706
5178d2263521
return land word from uCollisions to make decisions based on it. Should be handy for trampoline.
nemo
parents:
9305
diff
changeset
|
163 |
TestCollisionXwithGear:= 0 |
4 | 164 |
end; |
165 |
||
6081
537bbd5c1a62
Basic test implementation of an ice flag. Allows for slick parts of terrain. Intended for ice gun, or "ice" mask on portions of land objects.
nemo
parents:
5919
diff
changeset
|
166 |
function TestCollisionYwithGear(Gear: PGear; Dir: LongInt): Word; |
505
fcba7d7aea0d
Fix old bug with grenade(bomd, etc..) not colliding with attacking hedgehog
unc0rr
parents:
504
diff
changeset
|
167 |
var x, y, i: LongInt; |
fcba7d7aea0d
Fix old bug with grenade(bomd, etc..) not colliding with attacking hedgehog
unc0rr
parents:
504
diff
changeset
|
168 |
begin |
7272
71df899c4163
Second part of the change. Make collision check use the new mask bit.
nemo
parents:
7270
diff
changeset
|
169 |
// Special case to emulate the old intersect gear clearing, but with a bit of slop for pixel overlap |
8751
4609823efc94
More flagging of Land values. Also use less than for tests of non-terrain, instead of "and $FF00 = 0". Saves a couple of ops, which actually matters a small amount in a few places.
nemo
parents:
8744
diff
changeset
|
170 |
if (Gear^.CollisionMask = lfNotCurrentMask) and (Gear^.Kind <> gtHedgehog) and (Gear^.Hedgehog <> nil) and (Gear^.Hedgehog^.Gear <> nil) and |
7754 | 171 |
((hwRound(Gear^.Hedgehog^.Gear^.Y) + Gear^.Hedgehog^.Gear^.Radius + 16 < hwRound(Gear^.Y) - Gear^.Radius) or |
172 |
(hwRound(Gear^.Hedgehog^.Gear^.Y) - Gear^.Hedgehog^.Gear^.Radius - 16 > hwRound(Gear^.Y) + Gear^.Radius)) then |
|
7272
71df899c4163
Second part of the change. Make collision check use the new mask bit.
nemo
parents:
7270
diff
changeset
|
173 |
Gear^.CollisionMask:= $FFFF; |
505
fcba7d7aea0d
Fix old bug with grenade(bomd, etc..) not colliding with attacking hedgehog
unc0rr
parents:
504
diff
changeset
|
174 |
|
fcba7d7aea0d
Fix old bug with grenade(bomd, etc..) not colliding with attacking hedgehog
unc0rr
parents:
504
diff
changeset
|
175 |
y:= hwRound(Gear^.Y); |
6580
6155187bf599
A partial reformatting of the pascal code to have consistent syntax. Things that are still inconsistent.
lovelacer
parents:
6543
diff
changeset
|
176 |
if Dir < 0 then |
6155187bf599
A partial reformatting of the pascal code to have consistent syntax. Things that are still inconsistent.
lovelacer
parents:
6543
diff
changeset
|
177 |
y:= y - Gear^.Radius |
6155187bf599
A partial reformatting of the pascal code to have consistent syntax. Things that are still inconsistent.
lovelacer
parents:
6543
diff
changeset
|
178 |
else |
6155187bf599
A partial reformatting of the pascal code to have consistent syntax. Things that are still inconsistent.
lovelacer
parents:
6543
diff
changeset
|
179 |
y:= y + Gear^.Radius; |
7268 | 180 |
|
1753 | 181 |
if (y and LAND_HEIGHT_MASK) = 0 then |
6580
6155187bf599
A partial reformatting of the pascal code to have consistent syntax. Things that are still inconsistent.
lovelacer
parents:
6543
diff
changeset
|
182 |
begin |
6155187bf599
A partial reformatting of the pascal code to have consistent syntax. Things that are still inconsistent.
lovelacer
parents:
6543
diff
changeset
|
183 |
x:= hwRound(Gear^.X) - Gear^.Radius + 1; |
6155187bf599
A partial reformatting of the pascal code to have consistent syntax. Things that are still inconsistent.
lovelacer
parents:
6543
diff
changeset
|
184 |
i:= x + Gear^.Radius * 2 - 2; |
6155187bf599
A partial reformatting of the pascal code to have consistent syntax. Things that are still inconsistent.
lovelacer
parents:
6543
diff
changeset
|
185 |
repeat |
6155187bf599
A partial reformatting of the pascal code to have consistent syntax. Things that are still inconsistent.
lovelacer
parents:
6543
diff
changeset
|
186 |
if (x and LAND_WIDTH_MASK) = 0 then |
7272
71df899c4163
Second part of the change. Make collision check use the new mask bit.
nemo
parents:
7270
diff
changeset
|
187 |
if Land[y, x] and Gear^.CollisionMask <> 0 then |
71df899c4163
Second part of the change. Make collision check use the new mask bit.
nemo
parents:
7270
diff
changeset
|
188 |
begin |
9731
953197ac43d8
Make sticky mine respect lfBouncy, make hogs do same, kinda... make uCollisions return land w/ mask, restrict bouncy to advbounce gears only, which means piano doesn't bounce anymore
nemo
parents:
9708
diff
changeset
|
189 |
exit(Land[y, x] and Gear^.CollisionMask) |
7272
71df899c4163
Second part of the change. Make collision check use the new mask bit.
nemo
parents:
7270
diff
changeset
|
190 |
end; |
71df899c4163
Second part of the change. Make collision check use the new mask bit.
nemo
parents:
7270
diff
changeset
|
191 |
inc(x) |
6580
6155187bf599
A partial reformatting of the pascal code to have consistent syntax. Things that are still inconsistent.
lovelacer
parents:
6543
diff
changeset
|
192 |
until (x > i); |
6155187bf599
A partial reformatting of the pascal code to have consistent syntax. Things that are still inconsistent.
lovelacer
parents:
6543
diff
changeset
|
193 |
end; |
6081
537bbd5c1a62
Basic test implementation of an ice flag. Allows for slick parts of terrain. Intended for ice gun, or "ice" mask on portions of land objects.
nemo
parents:
5919
diff
changeset
|
194 |
TestCollisionYwithGear:= 0 |
505
fcba7d7aea0d
Fix old bug with grenade(bomd, etc..) not colliding with attacking hedgehog
unc0rr
parents:
504
diff
changeset
|
195 |
end; |
fcba7d7aea0d
Fix old bug with grenade(bomd, etc..) not colliding with attacking hedgehog
unc0rr
parents:
504
diff
changeset
|
196 |
|
9706
5178d2263521
return land word from uCollisions to make decisions based on it. Should be handy for trampoline.
nemo
parents:
9305
diff
changeset
|
197 |
function TestCollisionXKick(Gear: PGear; Dir: LongInt): Word; |
3608
c509bbc779e7
Revert prior attempted optimisation. Gridding the land pays in some situations, but not all. Restricting to an upper bound might help, but overall, seems too fuzzy to be worth it. On one side is increased cost of Add/Delete + extra test on collision check, on the other is skipping the list iteration. Perhaps for large lists.
nemo
parents:
3603
diff
changeset
|
198 |
var x, y, mx, my, i: LongInt; |
9706
5178d2263521
return land word from uCollisions to make decisions based on it. Should be handy for trampoline.
nemo
parents:
9305
diff
changeset
|
199 |
pixel: Word; |
513
69e06d710d46
Moving hedgehog could get another hedgehog moving forward
unc0rr
parents:
511
diff
changeset
|
200 |
begin |
9706
5178d2263521
return land word from uCollisions to make decisions based on it. Should be handy for trampoline.
nemo
parents:
9305
diff
changeset
|
201 |
pixel:= 0; |
513
69e06d710d46
Moving hedgehog could get another hedgehog moving forward
unc0rr
parents:
511
diff
changeset
|
202 |
x:= hwRound(Gear^.X); |
6580
6155187bf599
A partial reformatting of the pascal code to have consistent syntax. Things that are still inconsistent.
lovelacer
parents:
6543
diff
changeset
|
203 |
if Dir < 0 then |
6155187bf599
A partial reformatting of the pascal code to have consistent syntax. Things that are still inconsistent.
lovelacer
parents:
6543
diff
changeset
|
204 |
x:= x - Gear^.Radius |
6155187bf599
A partial reformatting of the pascal code to have consistent syntax. Things that are still inconsistent.
lovelacer
parents:
6543
diff
changeset
|
205 |
else |
6155187bf599
A partial reformatting of the pascal code to have consistent syntax. Things that are still inconsistent.
lovelacer
parents:
6543
diff
changeset
|
206 |
x:= x + Gear^.Radius; |
6990
40e5af28d026
change every return value into a more pascal-ish form, using the name of the fucntion (helps the parser and macpas compaitilibity)
koda
parents:
6986
diff
changeset
|
207 |
|
1753 | 208 |
if (x and LAND_WIDTH_MASK) = 0 then |
6580
6155187bf599
A partial reformatting of the pascal code to have consistent syntax. Things that are still inconsistent.
lovelacer
parents:
6543
diff
changeset
|
209 |
begin |
6155187bf599
A partial reformatting of the pascal code to have consistent syntax. Things that are still inconsistent.
lovelacer
parents:
6543
diff
changeset
|
210 |
y:= hwRound(Gear^.Y) - Gear^.Radius + 1; |
6155187bf599
A partial reformatting of the pascal code to have consistent syntax. Things that are still inconsistent.
lovelacer
parents:
6543
diff
changeset
|
211 |
i:= y + Gear^.Radius * 2 - 2; |
6155187bf599
A partial reformatting of the pascal code to have consistent syntax. Things that are still inconsistent.
lovelacer
parents:
6543
diff
changeset
|
212 |
repeat |
6155187bf599
A partial reformatting of the pascal code to have consistent syntax. Things that are still inconsistent.
lovelacer
parents:
6543
diff
changeset
|
213 |
if (y and LAND_HEIGHT_MASK) = 0 then |
9731
953197ac43d8
Make sticky mine respect lfBouncy, make hogs do same, kinda... make uCollisions return land w/ mask, restrict bouncy to advbounce gears only, which means piano doesn't bounce anymore
nemo
parents:
9708
diff
changeset
|
214 |
if Land[y, x] and Gear^.CollisionMask > 255 then |
953197ac43d8
Make sticky mine respect lfBouncy, make hogs do same, kinda... make uCollisions return land w/ mask, restrict bouncy to advbounce gears only, which means piano doesn't bounce anymore
nemo
parents:
9708
diff
changeset
|
215 |
exit(Land[y, x] and Gear^.CollisionMask) |
953197ac43d8
Make sticky mine respect lfBouncy, make hogs do same, kinda... make uCollisions return land w/ mask, restrict bouncy to advbounce gears only, which means piano doesn't bounce anymore
nemo
parents:
9708
diff
changeset
|
216 |
else if Land[y, x] and Gear^.CollisionMask <> 0 then |
953197ac43d8
Make sticky mine respect lfBouncy, make hogs do same, kinda... make uCollisions return land w/ mask, restrict bouncy to advbounce gears only, which means piano doesn't bounce anymore
nemo
parents:
9708
diff
changeset
|
217 |
pixel:= Land[y, x] and Gear^.CollisionMask; |
6580
6155187bf599
A partial reformatting of the pascal code to have consistent syntax. Things that are still inconsistent.
lovelacer
parents:
6543
diff
changeset
|
218 |
inc(y) |
6155187bf599
A partial reformatting of the pascal code to have consistent syntax. Things that are still inconsistent.
lovelacer
parents:
6543
diff
changeset
|
219 |
until (y > i); |
6155187bf599
A partial reformatting of the pascal code to have consistent syntax. Things that are still inconsistent.
lovelacer
parents:
6543
diff
changeset
|
220 |
end; |
9706
5178d2263521
return land word from uCollisions to make decisions based on it. Should be handy for trampoline.
nemo
parents:
9305
diff
changeset
|
221 |
TestCollisionXKick:= pixel; |
513
69e06d710d46
Moving hedgehog could get another hedgehog moving forward
unc0rr
parents:
511
diff
changeset
|
222 |
|
9706
5178d2263521
return land word from uCollisions to make decisions based on it. Should be handy for trampoline.
nemo
parents:
9305
diff
changeset
|
223 |
if pixel <> 0 then |
6580
6155187bf599
A partial reformatting of the pascal code to have consistent syntax. Things that are still inconsistent.
lovelacer
parents:
6543
diff
changeset
|
224 |
begin |
6155187bf599
A partial reformatting of the pascal code to have consistent syntax. Things that are still inconsistent.
lovelacer
parents:
6543
diff
changeset
|
225 |
if hwAbs(Gear^.dX) < cHHKick then |
6155187bf599
A partial reformatting of the pascal code to have consistent syntax. Things that are still inconsistent.
lovelacer
parents:
6543
diff
changeset
|
226 |
exit; |
6155187bf599
A partial reformatting of the pascal code to have consistent syntax. Things that are still inconsistent.
lovelacer
parents:
6543
diff
changeset
|
227 |
if (Gear^.State and gstHHJumping <> 0) |
6155187bf599
A partial reformatting of the pascal code to have consistent syntax. Things that are still inconsistent.
lovelacer
parents:
6543
diff
changeset
|
228 |
and (hwAbs(Gear^.dX) < _0_4) then |
6155187bf599
A partial reformatting of the pascal code to have consistent syntax. Things that are still inconsistent.
lovelacer
parents:
6543
diff
changeset
|
229 |
exit; |
967 | 230 |
|
6580
6155187bf599
A partial reformatting of the pascal code to have consistent syntax. Things that are still inconsistent.
lovelacer
parents:
6543
diff
changeset
|
231 |
mx:= hwRound(Gear^.X); |
6155187bf599
A partial reformatting of the pascal code to have consistent syntax. Things that are still inconsistent.
lovelacer
parents:
6543
diff
changeset
|
232 |
my:= hwRound(Gear^.Y); |
513
69e06d710d46
Moving hedgehog could get another hedgehog moving forward
unc0rr
parents:
511
diff
changeset
|
233 |
|
6580
6155187bf599
A partial reformatting of the pascal code to have consistent syntax. Things that are still inconsistent.
lovelacer
parents:
6543
diff
changeset
|
234 |
for i:= 0 to Pred(Count) do |
6155187bf599
A partial reformatting of the pascal code to have consistent syntax. Things that are still inconsistent.
lovelacer
parents:
6543
diff
changeset
|
235 |
with cinfos[i] do |
10015 | 236 |
if (Gear <> cGear) and |
9305
8e5140875ab5
bug #668 + reorder conditions for kick slightly, to call the math last
nemo
parents:
9291
diff
changeset
|
237 |
((mx > x) xor (Dir > 0)) and |
7756
b89bd0ffb8aa
Try to prevent a situation where hogs embedded in other hogs/barrels/cleavers get stuck, by checking for gears overlapping on Y
nemo
parents:
7754
diff
changeset
|
238 |
( |
b89bd0ffb8aa
Try to prevent a situation where hogs embedded in other hogs/barrels/cleavers get stuck, by checking for gears overlapping on Y
nemo
parents:
7754
diff
changeset
|
239 |
((cGear^.Kind in [gtHedgehog, gtMine, gtKnife]) and ((Gear^.State and gstNotKickable) = 0)) or |
6580
6155187bf599
A partial reformatting of the pascal code to have consistent syntax. Things that are still inconsistent.
lovelacer
parents:
6543
diff
changeset
|
240 |
// only apply X kick if the barrel is knocked over |
9305
8e5140875ab5
bug #668 + reorder conditions for kick slightly, to call the math last
nemo
parents:
9291
diff
changeset
|
241 |
((cGear^.Kind = gtExplosives) and ((cGear^.State and gsttmpflag) <> 0)) |
8e5140875ab5
bug #668 + reorder conditions for kick slightly, to call the math last
nemo
parents:
9291
diff
changeset
|
242 |
) and |
8e5140875ab5
bug #668 + reorder conditions for kick slightly, to call the math last
nemo
parents:
9291
diff
changeset
|
243 |
(sqr(mx - x) + sqr(my - y) <= sqr(Radius + Gear^.Radius + 2)) then |
6580
6155187bf599
A partial reformatting of the pascal code to have consistent syntax. Things that are still inconsistent.
lovelacer
parents:
6543
diff
changeset
|
244 |
begin |
6155187bf599
A partial reformatting of the pascal code to have consistent syntax. Things that are still inconsistent.
lovelacer
parents:
6543
diff
changeset
|
245 |
with cGear^ do |
6155187bf599
A partial reformatting of the pascal code to have consistent syntax. Things that are still inconsistent.
lovelacer
parents:
6543
diff
changeset
|
246 |
begin |
6155187bf599
A partial reformatting of the pascal code to have consistent syntax. Things that are still inconsistent.
lovelacer
parents:
6543
diff
changeset
|
247 |
dX:= Gear^.dX; |
6155187bf599
A partial reformatting of the pascal code to have consistent syntax. Things that are still inconsistent.
lovelacer
parents:
6543
diff
changeset
|
248 |
dY:= Gear^.dY * _0_5; |
6155187bf599
A partial reformatting of the pascal code to have consistent syntax. Things that are still inconsistent.
lovelacer
parents:
6543
diff
changeset
|
249 |
State:= State or gstMoving; |
7767 | 250 |
if Kind = gtKnife then State:= State and (not gstCollision); |
6580
6155187bf599
A partial reformatting of the pascal code to have consistent syntax. Things that are still inconsistent.
lovelacer
parents:
6543
diff
changeset
|
251 |
Active:= true |
6155187bf599
A partial reformatting of the pascal code to have consistent syntax. Things that are still inconsistent.
lovelacer
parents:
6543
diff
changeset
|
252 |
end; |
6155187bf599
A partial reformatting of the pascal code to have consistent syntax. Things that are still inconsistent.
lovelacer
parents:
6543
diff
changeset
|
253 |
DeleteCI(cGear); |
9706
5178d2263521
return land word from uCollisions to make decisions based on it. Should be handy for trampoline.
nemo
parents:
9305
diff
changeset
|
254 |
exit(0); |
6580
6155187bf599
A partial reformatting of the pascal code to have consistent syntax. Things that are still inconsistent.
lovelacer
parents:
6543
diff
changeset
|
255 |
end |
6155187bf599
A partial reformatting of the pascal code to have consistent syntax. Things that are still inconsistent.
lovelacer
parents:
6543
diff
changeset
|
256 |
end |
513
69e06d710d46
Moving hedgehog could get another hedgehog moving forward
unc0rr
parents:
511
diff
changeset
|
257 |
end; |
69e06d710d46
Moving hedgehog could get another hedgehog moving forward
unc0rr
parents:
511
diff
changeset
|
258 |
|
9706
5178d2263521
return land word from uCollisions to make decisions based on it. Should be handy for trampoline.
nemo
parents:
9305
diff
changeset
|
259 |
function TestCollisionYKick(Gear: PGear; Dir: LongInt): Word; |
7756
b89bd0ffb8aa
Try to prevent a situation where hogs embedded in other hogs/barrels/cleavers get stuck, by checking for gears overlapping on Y
nemo
parents:
7754
diff
changeset
|
260 |
var x, y, mx, my, myr, i: LongInt; |
9706
5178d2263521
return land word from uCollisions to make decisions based on it. Should be handy for trampoline.
nemo
parents:
9305
diff
changeset
|
261 |
pixel: Word; |
513
69e06d710d46
Moving hedgehog could get another hedgehog moving forward
unc0rr
parents:
511
diff
changeset
|
262 |
begin |
9706
5178d2263521
return land word from uCollisions to make decisions based on it. Should be handy for trampoline.
nemo
parents:
9305
diff
changeset
|
263 |
pixel:= 0; |
513
69e06d710d46
Moving hedgehog could get another hedgehog moving forward
unc0rr
parents:
511
diff
changeset
|
264 |
y:= hwRound(Gear^.Y); |
6580
6155187bf599
A partial reformatting of the pascal code to have consistent syntax. Things that are still inconsistent.
lovelacer
parents:
6543
diff
changeset
|
265 |
if Dir < 0 then |
6155187bf599
A partial reformatting of the pascal code to have consistent syntax. Things that are still inconsistent.
lovelacer
parents:
6543
diff
changeset
|
266 |
y:= y - Gear^.Radius |
6155187bf599
A partial reformatting of the pascal code to have consistent syntax. Things that are still inconsistent.
lovelacer
parents:
6543
diff
changeset
|
267 |
else |
6155187bf599
A partial reformatting of the pascal code to have consistent syntax. Things that are still inconsistent.
lovelacer
parents:
6543
diff
changeset
|
268 |
y:= y + Gear^.Radius; |
6990
40e5af28d026
change every return value into a more pascal-ish form, using the name of the fucntion (helps the parser and macpas compaitilibity)
koda
parents:
6986
diff
changeset
|
269 |
|
1753 | 270 |
if (y and LAND_HEIGHT_MASK) = 0 then |
6580
6155187bf599
A partial reformatting of the pascal code to have consistent syntax. Things that are still inconsistent.
lovelacer
parents:
6543
diff
changeset
|
271 |
begin |
6155187bf599
A partial reformatting of the pascal code to have consistent syntax. Things that are still inconsistent.
lovelacer
parents:
6543
diff
changeset
|
272 |
x:= hwRound(Gear^.X) - Gear^.Radius + 1; |
6155187bf599
A partial reformatting of the pascal code to have consistent syntax. Things that are still inconsistent.
lovelacer
parents:
6543
diff
changeset
|
273 |
i:= x + Gear^.Radius * 2 - 2; |
6155187bf599
A partial reformatting of the pascal code to have consistent syntax. Things that are still inconsistent.
lovelacer
parents:
6543
diff
changeset
|
274 |
repeat |
6155187bf599
A partial reformatting of the pascal code to have consistent syntax. Things that are still inconsistent.
lovelacer
parents:
6543
diff
changeset
|
275 |
if (x and LAND_WIDTH_MASK) = 0 then |
513
69e06d710d46
Moving hedgehog could get another hedgehog moving forward
unc0rr
parents:
511
diff
changeset
|
276 |
if Land[y, x] > 0 then |
9731
953197ac43d8
Make sticky mine respect lfBouncy, make hogs do same, kinda... make uCollisions return land w/ mask, restrict bouncy to advbounce gears only, which means piano doesn't bounce anymore
nemo
parents:
9708
diff
changeset
|
277 |
if Land[y, x] and Gear^.CollisionMask > 255 then |
953197ac43d8
Make sticky mine respect lfBouncy, make hogs do same, kinda... make uCollisions return land w/ mask, restrict bouncy to advbounce gears only, which means piano doesn't bounce anymore
nemo
parents:
9708
diff
changeset
|
278 |
exit(Land[y, x] and Gear^.CollisionMask) |
6580
6155187bf599
A partial reformatting of the pascal code to have consistent syntax. Things that are still inconsistent.
lovelacer
parents:
6543
diff
changeset
|
279 |
else if Land[y, x] <> 0 then |
9731
953197ac43d8
Make sticky mine respect lfBouncy, make hogs do same, kinda... make uCollisions return land w/ mask, restrict bouncy to advbounce gears only, which means piano doesn't bounce anymore
nemo
parents:
9708
diff
changeset
|
280 |
pixel:= Land[y, x] and Gear^.CollisionMask; |
6580
6155187bf599
A partial reformatting of the pascal code to have consistent syntax. Things that are still inconsistent.
lovelacer
parents:
6543
diff
changeset
|
281 |
inc(x) |
6155187bf599
A partial reformatting of the pascal code to have consistent syntax. Things that are still inconsistent.
lovelacer
parents:
6543
diff
changeset
|
282 |
until (x > i); |
6155187bf599
A partial reformatting of the pascal code to have consistent syntax. Things that are still inconsistent.
lovelacer
parents:
6543
diff
changeset
|
283 |
end; |
9706
5178d2263521
return land word from uCollisions to make decisions based on it. Should be handy for trampoline.
nemo
parents:
9305
diff
changeset
|
284 |
TestCollisionYKick:= pixel; |
513
69e06d710d46
Moving hedgehog could get another hedgehog moving forward
unc0rr
parents:
511
diff
changeset
|
285 |
|
9706
5178d2263521
return land word from uCollisions to make decisions based on it. Should be handy for trampoline.
nemo
parents:
9305
diff
changeset
|
286 |
if pixel <> 0 then |
6580
6155187bf599
A partial reformatting of the pascal code to have consistent syntax. Things that are still inconsistent.
lovelacer
parents:
6543
diff
changeset
|
287 |
begin |
6155187bf599
A partial reformatting of the pascal code to have consistent syntax. Things that are still inconsistent.
lovelacer
parents:
6543
diff
changeset
|
288 |
if hwAbs(Gear^.dY) < cHHKick then |
6990
40e5af28d026
change every return value into a more pascal-ish form, using the name of the fucntion (helps the parser and macpas compaitilibity)
koda
parents:
6986
diff
changeset
|
289 |
exit; |
40e5af28d026
change every return value into a more pascal-ish form, using the name of the fucntion (helps the parser and macpas compaitilibity)
koda
parents:
6986
diff
changeset
|
290 |
if (Gear^.State and gstHHJumping <> 0) and (not Gear^.dY.isNegative) and (Gear^.dY < _0_4) then |
6580
6155187bf599
A partial reformatting of the pascal code to have consistent syntax. Things that are still inconsistent.
lovelacer
parents:
6543
diff
changeset
|
291 |
exit; |
967 | 292 |
|
6580
6155187bf599
A partial reformatting of the pascal code to have consistent syntax. Things that are still inconsistent.
lovelacer
parents:
6543
diff
changeset
|
293 |
mx:= hwRound(Gear^.X); |
6155187bf599
A partial reformatting of the pascal code to have consistent syntax. Things that are still inconsistent.
lovelacer
parents:
6543
diff
changeset
|
294 |
my:= hwRound(Gear^.Y); |
7756
b89bd0ffb8aa
Try to prevent a situation where hogs embedded in other hogs/barrels/cleavers get stuck, by checking for gears overlapping on Y
nemo
parents:
7754
diff
changeset
|
295 |
myr:= my+Gear^.Radius; |
513
69e06d710d46
Moving hedgehog could get another hedgehog moving forward
unc0rr
parents:
511
diff
changeset
|
296 |
|
6580
6155187bf599
A partial reformatting of the pascal code to have consistent syntax. Things that are still inconsistent.
lovelacer
parents:
6543
diff
changeset
|
297 |
for i:= 0 to Pred(Count) do |
6155187bf599
A partial reformatting of the pascal code to have consistent syntax. Things that are still inconsistent.
lovelacer
parents:
6543
diff
changeset
|
298 |
with cinfos[i] do |
9305
8e5140875ab5
bug #668 + reorder conditions for kick slightly, to call the math last
nemo
parents:
9291
diff
changeset
|
299 |
if (Gear <> cGear) and |
8e5140875ab5
bug #668 + reorder conditions for kick slightly, to call the math last
nemo
parents:
9291
diff
changeset
|
300 |
((myr > y) xor (Dir > 0)) and |
8e5140875ab5
bug #668 + reorder conditions for kick slightly, to call the math last
nemo
parents:
9291
diff
changeset
|
301 |
(Gear^.State and gstNotKickable = 0) and |
10015 | 302 |
(cGear^.Kind in [gtHedgehog, gtMine, gtKnife, gtExplosives]) and |
9305
8e5140875ab5
bug #668 + reorder conditions for kick slightly, to call the math last
nemo
parents:
9291
diff
changeset
|
303 |
(sqr(mx - x) + sqr(my - y) <= sqr(Radius + Gear^.Radius + 2)) then |
6580
6155187bf599
A partial reformatting of the pascal code to have consistent syntax. Things that are still inconsistent.
lovelacer
parents:
6543
diff
changeset
|
304 |
begin |
6155187bf599
A partial reformatting of the pascal code to have consistent syntax. Things that are still inconsistent.
lovelacer
parents:
6543
diff
changeset
|
305 |
with cGear^ do |
6155187bf599
A partial reformatting of the pascal code to have consistent syntax. Things that are still inconsistent.
lovelacer
parents:
6543
diff
changeset
|
306 |
begin |
6155187bf599
A partial reformatting of the pascal code to have consistent syntax. Things that are still inconsistent.
lovelacer
parents:
6543
diff
changeset
|
307 |
if (Kind <> gtExplosives) or ((State and gsttmpflag) <> 0) then |
6155187bf599
A partial reformatting of the pascal code to have consistent syntax. Things that are still inconsistent.
lovelacer
parents:
6543
diff
changeset
|
308 |
dX:= Gear^.dX * _0_5; |
6155187bf599
A partial reformatting of the pascal code to have consistent syntax. Things that are still inconsistent.
lovelacer
parents:
6543
diff
changeset
|
309 |
dY:= Gear^.dY; |
6155187bf599
A partial reformatting of the pascal code to have consistent syntax. Things that are still inconsistent.
lovelacer
parents:
6543
diff
changeset
|
310 |
State:= State or gstMoving; |
7767 | 311 |
if Kind = gtKnife then State:= State and (not gstCollision); |
6580
6155187bf599
A partial reformatting of the pascal code to have consistent syntax. Things that are still inconsistent.
lovelacer
parents:
6543
diff
changeset
|
312 |
Active:= true |
6155187bf599
A partial reformatting of the pascal code to have consistent syntax. Things that are still inconsistent.
lovelacer
parents:
6543
diff
changeset
|
313 |
end; |
6155187bf599
A partial reformatting of the pascal code to have consistent syntax. Things that are still inconsistent.
lovelacer
parents:
6543
diff
changeset
|
314 |
DeleteCI(cGear); |
9706
5178d2263521
return land word from uCollisions to make decisions based on it. Should be handy for trampoline.
nemo
parents:
9305
diff
changeset
|
315 |
exit(0) |
6580
6155187bf599
A partial reformatting of the pascal code to have consistent syntax. Things that are still inconsistent.
lovelacer
parents:
6543
diff
changeset
|
316 |
end |
6155187bf599
A partial reformatting of the pascal code to have consistent syntax. Things that are still inconsistent.
lovelacer
parents:
6543
diff
changeset
|
317 |
end |
513
69e06d710d46
Moving hedgehog could get another hedgehog moving forward
unc0rr
parents:
511
diff
changeset
|
318 |
end; |
69e06d710d46
Moving hedgehog could get another hedgehog moving forward
unc0rr
parents:
511
diff
changeset
|
319 |
|
9706
5178d2263521
return land word from uCollisions to make decisions based on it. Should be handy for trampoline.
nemo
parents:
9305
diff
changeset
|
320 |
function TestCollisionXwithXYShift(Gear: PGear; ShiftX: hwFloat; ShiftY: LongInt; Dir: LongInt): Word; inline; |
6986
409dd3851309
add support for default pascal mode by removing default arguments value (maybe this also helps the parser)
koda
parents:
6700
diff
changeset
|
321 |
begin |
409dd3851309
add support for default pascal mode by removing default arguments value (maybe this also helps the parser)
koda
parents:
6700
diff
changeset
|
322 |
TestCollisionXwithXYShift:= TestCollisionXwithXYShift(Gear, ShiftX, ShiftY, Dir, true); |
409dd3851309
add support for default pascal mode by removing default arguments value (maybe this also helps the parser)
koda
parents:
6700
diff
changeset
|
323 |
end; |
409dd3851309
add support for default pascal mode by removing default arguments value (maybe this also helps the parser)
koda
parents:
6700
diff
changeset
|
324 |
|
9706
5178d2263521
return land word from uCollisions to make decisions based on it. Should be handy for trampoline.
nemo
parents:
9305
diff
changeset
|
325 |
function TestCollisionXwithXYShift(Gear: PGear; ShiftX: hwFloat; ShiftY: LongInt; Dir: LongInt; withGear: boolean): Word; |
4 | 326 |
begin |
351 | 327 |
Gear^.X:= Gear^.X + ShiftX; |
498 | 328 |
Gear^.Y:= Gear^.Y + int2hwFloat(ShiftY); |
10015 | 329 |
if withGear then |
5750
6bbf7aee2cdf
Reenable a bunch of old portal play stuff, like dropping grenade into portal on hog, jumping through portal w/ hog on other end, collecting crate w/ portal etc. Also add cooldown to cake/portal interaction. It may still not do what you expect, but it probably shouldn't spin in place.
nemo
parents:
5572
diff
changeset
|
330 |
TestCollisionXwithXYShift:= TestCollisionXwithGear(Gear, Dir) |
6bbf7aee2cdf
Reenable a bunch of old portal play stuff, like dropping grenade into portal on hog, jumping through portal w/ hog on other end, collecting crate w/ portal etc. Also add cooldown to cake/portal interaction. It may still not do what you expect, but it probably shouldn't spin in place.
nemo
parents:
5572
diff
changeset
|
331 |
else TestCollisionXwithXYShift:= TestCollisionX(Gear, Dir); |
351 | 332 |
Gear^.X:= Gear^.X - ShiftX; |
498 | 333 |
Gear^.Y:= Gear^.Y - int2hwFloat(ShiftY) |
4 | 334 |
end; |
6990
40e5af28d026
change every return value into a more pascal-ish form, using the name of the fucntion (helps the parser and macpas compaitilibity)
koda
parents:
6986
diff
changeset
|
335 |
|
9706
5178d2263521
return land word from uCollisions to make decisions based on it. Should be handy for trampoline.
nemo
parents:
9305
diff
changeset
|
336 |
function TestCollisionX(Gear: PGear; Dir: LongInt): Word; |
4798 | 337 |
var x, y, i: LongInt; |
338 |
begin |
|
339 |
x:= hwRound(Gear^.X); |
|
6580
6155187bf599
A partial reformatting of the pascal code to have consistent syntax. Things that are still inconsistent.
lovelacer
parents:
6543
diff
changeset
|
340 |
if Dir < 0 then |
6155187bf599
A partial reformatting of the pascal code to have consistent syntax. Things that are still inconsistent.
lovelacer
parents:
6543
diff
changeset
|
341 |
x:= x - Gear^.Radius |
6155187bf599
A partial reformatting of the pascal code to have consistent syntax. Things that are still inconsistent.
lovelacer
parents:
6543
diff
changeset
|
342 |
else |
6155187bf599
A partial reformatting of the pascal code to have consistent syntax. Things that are still inconsistent.
lovelacer
parents:
6543
diff
changeset
|
343 |
x:= x + Gear^.Radius; |
6990
40e5af28d026
change every return value into a more pascal-ish form, using the name of the fucntion (helps the parser and macpas compaitilibity)
koda
parents:
6986
diff
changeset
|
344 |
|
4798 | 345 |
if (x and LAND_WIDTH_MASK) = 0 then |
6580
6155187bf599
A partial reformatting of the pascal code to have consistent syntax. Things that are still inconsistent.
lovelacer
parents:
6543
diff
changeset
|
346 |
begin |
6155187bf599
A partial reformatting of the pascal code to have consistent syntax. Things that are still inconsistent.
lovelacer
parents:
6543
diff
changeset
|
347 |
y:= hwRound(Gear^.Y) - Gear^.Radius + 1; |
6155187bf599
A partial reformatting of the pascal code to have consistent syntax. Things that are still inconsistent.
lovelacer
parents:
6543
diff
changeset
|
348 |
i:= y + Gear^.Radius * 2 - 2; |
6155187bf599
A partial reformatting of the pascal code to have consistent syntax. Things that are still inconsistent.
lovelacer
parents:
6543
diff
changeset
|
349 |
repeat |
6155187bf599
A partial reformatting of the pascal code to have consistent syntax. Things that are still inconsistent.
lovelacer
parents:
6543
diff
changeset
|
350 |
if (y and LAND_HEIGHT_MASK) = 0 then |
9731
953197ac43d8
Make sticky mine respect lfBouncy, make hogs do same, kinda... make uCollisions return land w/ mask, restrict bouncy to advbounce gears only, which means piano doesn't bounce anymore
nemo
parents:
9708
diff
changeset
|
351 |
if Land[y, x] and Gear^.CollisionMask > 255 then |
953197ac43d8
Make sticky mine respect lfBouncy, make hogs do same, kinda... make uCollisions return land w/ mask, restrict bouncy to advbounce gears only, which means piano doesn't bounce anymore
nemo
parents:
9708
diff
changeset
|
352 |
exit(Land[y, x] and Gear^.CollisionMask); |
6580
6155187bf599
A partial reformatting of the pascal code to have consistent syntax. Things that are still inconsistent.
lovelacer
parents:
6543
diff
changeset
|
353 |
inc(y) |
6155187bf599
A partial reformatting of the pascal code to have consistent syntax. Things that are still inconsistent.
lovelacer
parents:
6543
diff
changeset
|
354 |
until (y > i); |
6155187bf599
A partial reformatting of the pascal code to have consistent syntax. Things that are still inconsistent.
lovelacer
parents:
6543
diff
changeset
|
355 |
end; |
9706
5178d2263521
return land word from uCollisions to make decisions based on it. Should be handy for trampoline.
nemo
parents:
9305
diff
changeset
|
356 |
TestCollisionX:= 0 |
4798 | 357 |
end; |
4 | 358 |
|
9706
5178d2263521
return land word from uCollisions to make decisions based on it. Should be handy for trampoline.
nemo
parents:
9305
diff
changeset
|
359 |
function TestCollisionY(Gear: PGear; Dir: LongInt): Word; |
371 | 360 |
var x, y, i: LongInt; |
68 | 361 |
begin |
351 | 362 |
y:= hwRound(Gear^.Y); |
6580
6155187bf599
A partial reformatting of the pascal code to have consistent syntax. Things that are still inconsistent.
lovelacer
parents:
6543
diff
changeset
|
363 |
if Dir < 0 then |
6155187bf599
A partial reformatting of the pascal code to have consistent syntax. Things that are still inconsistent.
lovelacer
parents:
6543
diff
changeset
|
364 |
y:= y - Gear^.Radius |
6155187bf599
A partial reformatting of the pascal code to have consistent syntax. Things that are still inconsistent.
lovelacer
parents:
6543
diff
changeset
|
365 |
else |
6155187bf599
A partial reformatting of the pascal code to have consistent syntax. Things that are still inconsistent.
lovelacer
parents:
6543
diff
changeset
|
366 |
y:= y + Gear^.Radius; |
6990
40e5af28d026
change every return value into a more pascal-ish form, using the name of the fucntion (helps the parser and macpas compaitilibity)
koda
parents:
6986
diff
changeset
|
367 |
|
1753 | 368 |
if (y and LAND_HEIGHT_MASK) = 0 then |
6580
6155187bf599
A partial reformatting of the pascal code to have consistent syntax. Things that are still inconsistent.
lovelacer
parents:
6543
diff
changeset
|
369 |
begin |
6155187bf599
A partial reformatting of the pascal code to have consistent syntax. Things that are still inconsistent.
lovelacer
parents:
6543
diff
changeset
|
370 |
x:= hwRound(Gear^.X) - Gear^.Radius + 1; |
6155187bf599
A partial reformatting of the pascal code to have consistent syntax. Things that are still inconsistent.
lovelacer
parents:
6543
diff
changeset
|
371 |
i:= x + Gear^.Radius * 2 - 2; |
6155187bf599
A partial reformatting of the pascal code to have consistent syntax. Things that are still inconsistent.
lovelacer
parents:
6543
diff
changeset
|
372 |
repeat |
6155187bf599
A partial reformatting of the pascal code to have consistent syntax. Things that are still inconsistent.
lovelacer
parents:
6543
diff
changeset
|
373 |
if (x and LAND_WIDTH_MASK) = 0 then |
9731
953197ac43d8
Make sticky mine respect lfBouncy, make hogs do same, kinda... make uCollisions return land w/ mask, restrict bouncy to advbounce gears only, which means piano doesn't bounce anymore
nemo
parents:
9708
diff
changeset
|
374 |
if Land[y, x] and Gear^.CollisionMask > 255 then |
953197ac43d8
Make sticky mine respect lfBouncy, make hogs do same, kinda... make uCollisions return land w/ mask, restrict bouncy to advbounce gears only, which means piano doesn't bounce anymore
nemo
parents:
9708
diff
changeset
|
375 |
exit(Land[y, x] and Gear^.CollisionMask); |
6580
6155187bf599
A partial reformatting of the pascal code to have consistent syntax. Things that are still inconsistent.
lovelacer
parents:
6543
diff
changeset
|
376 |
inc(x) |
6155187bf599
A partial reformatting of the pascal code to have consistent syntax. Things that are still inconsistent.
lovelacer
parents:
6543
diff
changeset
|
377 |
until (x > i); |
6155187bf599
A partial reformatting of the pascal code to have consistent syntax. Things that are still inconsistent.
lovelacer
parents:
6543
diff
changeset
|
378 |
end; |
9706
5178d2263521
return land word from uCollisions to make decisions based on it. Should be handy for trampoline.
nemo
parents:
9305
diff
changeset
|
379 |
TestCollisionY:= 0 |
68 | 380 |
end; |
381 |
||
9706
5178d2263521
return land word from uCollisions to make decisions based on it. Should be handy for trampoline.
nemo
parents:
9305
diff
changeset
|
382 |
function TestCollisionYwithXYShift(Gear: PGear; ShiftX, ShiftY: LongInt; Dir: LongInt): Word; inline; |
6986
409dd3851309
add support for default pascal mode by removing default arguments value (maybe this also helps the parser)
koda
parents:
6700
diff
changeset
|
383 |
begin |
409dd3851309
add support for default pascal mode by removing default arguments value (maybe this also helps the parser)
koda
parents:
6700
diff
changeset
|
384 |
TestCollisionYwithXYShift:= TestCollisionYwithXYShift(Gear, ShiftX, ShiftY, Dir, true); |
409dd3851309
add support for default pascal mode by removing default arguments value (maybe this also helps the parser)
koda
parents:
6700
diff
changeset
|
385 |
end; |
409dd3851309
add support for default pascal mode by removing default arguments value (maybe this also helps the parser)
koda
parents:
6700
diff
changeset
|
386 |
|
9706
5178d2263521
return land word from uCollisions to make decisions based on it. Should be handy for trampoline.
nemo
parents:
9305
diff
changeset
|
387 |
function TestCollisionYwithXYShift(Gear: PGear; ShiftX, ShiftY: LongInt; Dir: LongInt; withGear: boolean): Word; |
4 | 388 |
begin |
498 | 389 |
Gear^.X:= Gear^.X + int2hwFloat(ShiftX); |
390 |
Gear^.Y:= Gear^.Y + int2hwFloat(ShiftY); |
|
6580
6155187bf599
A partial reformatting of the pascal code to have consistent syntax. Things that are still inconsistent.
lovelacer
parents:
6543
diff
changeset
|
391 |
|
6155187bf599
A partial reformatting of the pascal code to have consistent syntax. Things that are still inconsistent.
lovelacer
parents:
6543
diff
changeset
|
392 |
if withGear then |
9706
5178d2263521
return land word from uCollisions to make decisions based on it. Should be handy for trampoline.
nemo
parents:
9305
diff
changeset
|
393 |
TestCollisionYwithXYShift:= TestCollisionYwithGear(Gear, Dir) |
6580
6155187bf599
A partial reformatting of the pascal code to have consistent syntax. Things that are still inconsistent.
lovelacer
parents:
6543
diff
changeset
|
394 |
else |
6155187bf599
A partial reformatting of the pascal code to have consistent syntax. Things that are still inconsistent.
lovelacer
parents:
6543
diff
changeset
|
395 |
TestCollisionYwithXYShift:= TestCollisionY(Gear, Dir); |
10015 | 396 |
|
498 | 397 |
Gear^.X:= Gear^.X - int2hwFloat(ShiftX); |
398 |
Gear^.Y:= Gear^.Y - int2hwFloat(ShiftY) |
|
4 | 399 |
end; |
400 |
||
10818
f642a28cab0c
Add placement of airmines in engine outside of hog proximity. Has a bug, only protecting 1st team. Also fix a spelling error and rename gstHHChooseTarget to gstChooseTarget
nemo
parents:
10635
diff
changeset
|
401 |
function TestRectangleForObstacle(x1, y1, x2, y2: LongInt; landOnly: boolean): boolean; |
5896
9ce1cf4e5a32
lua: boolean TestRectForObstacle(x1, y1, x2, y2, landOnly)
sheepluva
parents:
5834
diff
changeset
|
402 |
var x, y: LongInt; |
9ce1cf4e5a32
lua: boolean TestRectForObstacle(x1, y1, x2, y2, landOnly)
sheepluva
parents:
5834
diff
changeset
|
403 |
TestWord: LongWord; |
9ce1cf4e5a32
lua: boolean TestRectForObstacle(x1, y1, x2, y2, landOnly)
sheepluva
parents:
5834
diff
changeset
|
404 |
begin |
10818
f642a28cab0c
Add placement of airmines in engine outside of hog proximity. Has a bug, only protecting 1st team. Also fix a spelling error and rename gstHHChooseTarget to gstChooseTarget
nemo
parents:
10635
diff
changeset
|
405 |
TestRectangleForObstacle:= true; |
6990
40e5af28d026
change every return value into a more pascal-ish form, using the name of the fucntion (helps the parser and macpas compaitilibity)
koda
parents:
6986
diff
changeset
|
406 |
|
5896
9ce1cf4e5a32
lua: boolean TestRectForObstacle(x1, y1, x2, y2, landOnly)
sheepluva
parents:
5834
diff
changeset
|
407 |
if landOnly then |
9ce1cf4e5a32
lua: boolean TestRectForObstacle(x1, y1, x2, y2, landOnly)
sheepluva
parents:
5834
diff
changeset
|
408 |
TestWord:= 255 |
9ce1cf4e5a32
lua: boolean TestRectForObstacle(x1, y1, x2, y2, landOnly)
sheepluva
parents:
5834
diff
changeset
|
409 |
else |
9ce1cf4e5a32
lua: boolean TestRectForObstacle(x1, y1, x2, y2, landOnly)
sheepluva
parents:
5834
diff
changeset
|
410 |
TestWord:= 0; |
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
|
411 |
|
5896
9ce1cf4e5a32
lua: boolean TestRectForObstacle(x1, y1, x2, y2, landOnly)
sheepluva
parents:
5834
diff
changeset
|
412 |
if x1 > x2 then |
6990
40e5af28d026
change every return value into a more pascal-ish form, using the name of the fucntion (helps the parser and macpas compaitilibity)
koda
parents:
6986
diff
changeset
|
413 |
begin |
5896
9ce1cf4e5a32
lua: boolean TestRectForObstacle(x1, y1, x2, y2, landOnly)
sheepluva
parents:
5834
diff
changeset
|
414 |
x := x1; |
9ce1cf4e5a32
lua: boolean TestRectForObstacle(x1, y1, x2, y2, landOnly)
sheepluva
parents:
5834
diff
changeset
|
415 |
x1 := x2; |
9ce1cf4e5a32
lua: boolean TestRectForObstacle(x1, y1, x2, y2, landOnly)
sheepluva
parents:
5834
diff
changeset
|
416 |
x2 := x; |
6990
40e5af28d026
change every return value into a more pascal-ish form, using the name of the fucntion (helps the parser and macpas compaitilibity)
koda
parents:
6986
diff
changeset
|
417 |
end; |
5896
9ce1cf4e5a32
lua: boolean TestRectForObstacle(x1, y1, x2, y2, landOnly)
sheepluva
parents:
5834
diff
changeset
|
418 |
|
9ce1cf4e5a32
lua: boolean TestRectForObstacle(x1, y1, x2, y2, landOnly)
sheepluva
parents:
5834
diff
changeset
|
419 |
if y1 > y2 then |
6990
40e5af28d026
change every return value into a more pascal-ish form, using the name of the fucntion (helps the parser and macpas compaitilibity)
koda
parents:
6986
diff
changeset
|
420 |
begin |
5896
9ce1cf4e5a32
lua: boolean TestRectForObstacle(x1, y1, x2, y2, landOnly)
sheepluva
parents:
5834
diff
changeset
|
421 |
y := y1; |
9ce1cf4e5a32
lua: boolean TestRectForObstacle(x1, y1, x2, y2, landOnly)
sheepluva
parents:
5834
diff
changeset
|
422 |
y1 := y2; |
9ce1cf4e5a32
lua: boolean TestRectForObstacle(x1, y1, x2, y2, landOnly)
sheepluva
parents:
5834
diff
changeset
|
423 |
y2 := y; |
6990
40e5af28d026
change every return value into a more pascal-ish form, using the name of the fucntion (helps the parser and macpas compaitilibity)
koda
parents:
6986
diff
changeset
|
424 |
end; |
5896
9ce1cf4e5a32
lua: boolean TestRectForObstacle(x1, y1, x2, y2, landOnly)
sheepluva
parents:
5834
diff
changeset
|
425 |
|
5919
f737843dd331
TestRectForObstacle: areas outside map borders are not passable
sheepluva
parents:
5896
diff
changeset
|
426 |
if (hasBorder and ((y1 < 0) or (x1 < 0) or (x2 > LAND_WIDTH))) then |
6990
40e5af28d026
change every return value into a more pascal-ish form, using the name of the fucntion (helps the parser and macpas compaitilibity)
koda
parents:
6986
diff
changeset
|
427 |
exit; |
5919
f737843dd331
TestRectForObstacle: areas outside map borders are not passable
sheepluva
parents:
5896
diff
changeset
|
428 |
|
5896
9ce1cf4e5a32
lua: boolean TestRectForObstacle(x1, y1, x2, y2, landOnly)
sheepluva
parents:
5834
diff
changeset
|
429 |
for y := y1 to y2 do |
9ce1cf4e5a32
lua: boolean TestRectForObstacle(x1, y1, x2, y2, landOnly)
sheepluva
parents:
5834
diff
changeset
|
430 |
for x := x1 to x2 do |
6990
40e5af28d026
change every return value into a more pascal-ish form, using the name of the fucntion (helps the parser and macpas compaitilibity)
koda
parents:
6986
diff
changeset
|
431 |
if ((y and LAND_HEIGHT_MASK) = 0) and ((x and LAND_WIDTH_MASK) = 0) and (Land[y, x] > TestWord) then |
40e5af28d026
change every return value into a more pascal-ish form, using the name of the fucntion (helps the parser and macpas compaitilibity)
koda
parents:
6986
diff
changeset
|
432 |
exit; |
5896
9ce1cf4e5a32
lua: boolean TestRectForObstacle(x1, y1, x2, y2, landOnly)
sheepluva
parents:
5834
diff
changeset
|
433 |
|
10818
f642a28cab0c
Add placement of airmines in engine outside of hog proximity. Has a bug, only protecting 1st team. Also fix a spelling error and rename gstHHChooseTarget to gstChooseTarget
nemo
parents:
10635
diff
changeset
|
434 |
TestRectangleForObstacle:= false |
5896
9ce1cf4e5a32
lua: boolean TestRectForObstacle(x1, y1, x2, y2, landOnly)
sheepluva
parents:
5834
diff
changeset
|
435 |
end; |
9ce1cf4e5a32
lua: boolean TestRectForObstacle(x1, y1, x2, y2, landOnly)
sheepluva
parents:
5834
diff
changeset
|
436 |
|
9ce1cf4e5a32
lua: boolean TestRectForObstacle(x1, y1, x2, y2, landOnly)
sheepluva
parents:
5834
diff
changeset
|
437 |
function CalcSlopeTangent(Gear: PGear; collisionX, collisionY: LongInt; var outDeltaX, outDeltaY: LongInt; TestWord: LongWord): boolean; |
3408 | 438 |
var ldx, ldy, rdx, rdy: LongInt; |
6123 | 439 |
i, j, k, 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
|
440 |
tmpx, tmpy: LongWord; |
3569 | 441 |
dx, dy, s: hwFloat; |
6453
11c578d30bd3
Countless imporvements to the parser and countless help to the parser in sources.
unc0rr
parents:
6279
diff
changeset
|
442 |
offset: array[0..7,0..1] of ShortInt; |
6123 | 443 |
isColl: 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
|
444 |
|
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
|
445 |
begin |
6990
40e5af28d026
change every return value into a more pascal-ish form, using the name of the fucntion (helps the parser and macpas compaitilibity)
koda
parents:
6986
diff
changeset
|
446 |
CalcSlopeTangent:= false; |
40e5af28d026
change every return value into a more pascal-ish form, using the name of the fucntion (helps the parser and macpas compaitilibity)
koda
parents:
6986
diff
changeset
|
447 |
|
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
|
448 |
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
|
449 |
dy:= Gear^.dY; |
3408 | 450 |
|
3569 | 451 |
// we start searching from the direction the gear came from |
452 |
if (dx.QWordValue > _0_995.QWordValue ) |
|
453 |
or (dy.QWordValue > _0_995.QWordValue ) then |
|
454 |
begin // scale |
|
6279 | 455 |
s := _0_995 / Distance(dx,dy); |
3569 | 456 |
dx := s * dx; |
457 |
dy := s * dy; |
|
458 |
end; |
|
459 |
||
3408 | 460 |
mx:= hwRound(Gear^.X-dx) - hwRound(Gear^.X); |
461 |
my:= hwRound(Gear^.Y-dy) - hwRound(Gear^.Y); |
|
462 |
||
463 |
li:= -1; |
|
464 |
ri:= -1; |
|
3569 | 465 |
|
3408 | 466 |
// go around collision pixel, checking for first/last collisions |
467 |
// this will determinate what angles will be tried to crawl along |
|
468 |
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
|
469 |
begin |
3408 | 470 |
offset[i,0]:= mx; |
471 |
offset[i,1]:= my; |
|
3569 | 472 |
|
6123 | 473 |
// multiplicator k tries to skip small pixels/gaps when possible |
474 |
for k:= 4 downto 1 do |
|
475 |
begin |
|
476 |
tmpx:= collisionX + k * mx; |
|
477 |
tmpy:= collisionY + k * 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
|
478 |
|
6123 | 479 |
if (((tmpy) and LAND_HEIGHT_MASK) = 0) and (((tmpx) and LAND_WIDTH_MASK) = 0) then |
480 |
if (Land[tmpy,tmpx] > TestWord) then |
|
3408 | 481 |
begin |
6123 | 482 |
// remember the index belonging to the first and last collision (if in 1st half) |
483 |
if (i <> 0) then |
|
484 |
begin |
|
485 |
if (ri = -1) then |
|
486 |
ri:= i |
|
487 |
else |
|
488 |
li:= i; |
|
489 |
end; |
|
3408 | 490 |
end; |
6123 | 491 |
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
|
492 |
|
6580
6155187bf599
A partial reformatting of the pascal code to have consistent syntax. Things that are still inconsistent.
lovelacer
parents:
6543
diff
changeset
|
493 |
if i = 7 then |
6155187bf599
A partial reformatting of the pascal code to have consistent syntax. Things that are still inconsistent.
lovelacer
parents:
6543
diff
changeset
|
494 |
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
|
495 |
|
3408 | 496 |
// prepare offset for next check (clockwise) |
6580
6155187bf599
A partial reformatting of the pascal code to have consistent syntax. Things that are still inconsistent.
lovelacer
parents:
6543
diff
changeset
|
497 |
if (mx = -1) and (my <> -1) then |
6155187bf599
A partial reformatting of the pascal code to have consistent syntax. Things that are still inconsistent.
lovelacer
parents:
6543
diff
changeset
|
498 |
my:= my - 1 |
6155187bf599
A partial reformatting of the pascal code to have consistent syntax. Things that are still inconsistent.
lovelacer
parents:
6543
diff
changeset
|
499 |
else if (my = -1) and (mx <> 1) then |
6155187bf599
A partial reformatting of the pascal code to have consistent syntax. Things that are still inconsistent.
lovelacer
parents:
6543
diff
changeset
|
500 |
mx:= mx + 1 |
6155187bf599
A partial reformatting of the pascal code to have consistent syntax. Things that are still inconsistent.
lovelacer
parents:
6543
diff
changeset
|
501 |
else if (mx = 1) and (my <> 1) then |
6155187bf599
A partial reformatting of the pascal code to have consistent syntax. Things that are still inconsistent.
lovelacer
parents:
6543
diff
changeset
|
502 |
my:= my + 1 |
6155187bf599
A partial reformatting of the pascal code to have consistent syntax. Things that are still inconsistent.
lovelacer
parents:
6543
diff
changeset
|
503 |
else |
6155187bf599
A partial reformatting of the pascal code to have consistent syntax. Things that are still inconsistent.
lovelacer
parents:
6543
diff
changeset
|
504 |
mx:= mx - 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
|
505 |
|
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
|
506 |
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
|
507 |
|
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
|
508 |
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
|
509 |
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
|
510 |
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
|
511 |
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
|
512 |
|
3408 | 513 |
// edge-crawl |
514 |
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
|
515 |
begin |
3408 | 516 |
// using mx,my as temporary value buffer here |
3697 | 517 |
|
3408 | 518 |
jfr:= 8+li+1; |
519 |
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
|
520 |
|
6123 | 521 |
isColl:= false; |
3408 | 522 |
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
|
523 |
begin |
3408 | 524 |
tmpo:= j mod 8; |
6123 | 525 |
// multiplicator k tries to skip small pixels/gaps when possible |
526 |
for k:= 3 downto 1 do |
|
527 |
begin |
|
528 |
tmpx:= ldx + k * offset[tmpo,0]; |
|
529 |
tmpy:= ldy + k * offset[tmpo,1]; |
|
530 |
if (((tmpy) and LAND_HEIGHT_MASK) = 0) and (((tmpx) and LAND_WIDTH_MASK) = 0) |
|
6580
6155187bf599
A partial reformatting of the pascal code to have consistent syntax. Things that are still inconsistent.
lovelacer
parents:
6543
diff
changeset
|
531 |
and (Land[tmpy,tmpx] > TestWord) then |
6155187bf599
A partial reformatting of the pascal code to have consistent syntax. Things that are still inconsistent.
lovelacer
parents:
6543
diff
changeset
|
532 |
begin |
6155187bf599
A partial reformatting of the pascal code to have consistent syntax. Things that are still inconsistent.
lovelacer
parents:
6543
diff
changeset
|
533 |
ldx:= tmpx; |
6155187bf599
A partial reformatting of the pascal code to have consistent syntax. Things that are still inconsistent.
lovelacer
parents:
6543
diff
changeset
|
534 |
ldy:= tmpy; |
6155187bf599
A partial reformatting of the pascal code to have consistent syntax. Things that are still inconsistent.
lovelacer
parents:
6543
diff
changeset
|
535 |
isColl:= true; |
6155187bf599
A partial reformatting of the pascal code to have consistent syntax. Things that are still inconsistent.
lovelacer
parents:
6543
diff
changeset
|
536 |
break; |
6155187bf599
A partial reformatting of the pascal code to have consistent syntax. Things that are still inconsistent.
lovelacer
parents:
6543
diff
changeset
|
537 |
end; |
6123 | 538 |
end; |
6580
6155187bf599
A partial reformatting of the pascal code to have consistent syntax. Things that are still inconsistent.
lovelacer
parents:
6543
diff
changeset
|
539 |
if isColl then |
6155187bf599
A partial reformatting of the pascal code to have consistent syntax. Things that are still inconsistent.
lovelacer
parents:
6543
diff
changeset
|
540 |
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
|
541 |
end; |
3408 | 542 |
|
543 |
jfr:= 8+ri-1; |
|
544 |
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
|
545 |
|
6123 | 546 |
isColl:= false; |
3408 | 547 |
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
|
548 |
begin |
3408 | 549 |
tmpo:= j mod 8; |
6123 | 550 |
for k:= 3 downto 1 do |
551 |
begin |
|
552 |
tmpx:= rdx + k * offset[tmpo,0]; |
|
553 |
tmpy:= rdy + k * offset[tmpo,1]; |
|
554 |
if (((tmpy) and LAND_HEIGHT_MASK) = 0) and (((tmpx) and LAND_WIDTH_MASK) = 0) |
|
6580
6155187bf599
A partial reformatting of the pascal code to have consistent syntax. Things that are still inconsistent.
lovelacer
parents:
6543
diff
changeset
|
555 |
and (Land[tmpy,tmpx] > TestWord) then |
6155187bf599
A partial reformatting of the pascal code to have consistent syntax. Things that are still inconsistent.
lovelacer
parents:
6543
diff
changeset
|
556 |
begin |
6155187bf599
A partial reformatting of the pascal code to have consistent syntax. Things that are still inconsistent.
lovelacer
parents:
6543
diff
changeset
|
557 |
rdx:= tmpx; |
6155187bf599
A partial reformatting of the pascal code to have consistent syntax. Things that are still inconsistent.
lovelacer
parents:
6543
diff
changeset
|
558 |
rdy:= tmpy; |
6155187bf599
A partial reformatting of the pascal code to have consistent syntax. Things that are still inconsistent.
lovelacer
parents:
6543
diff
changeset
|
559 |
isColl:= true; |
6155187bf599
A partial reformatting of the pascal code to have consistent syntax. Things that are still inconsistent.
lovelacer
parents:
6543
diff
changeset
|
560 |
break; |
6155187bf599
A partial reformatting of the pascal code to have consistent syntax. Things that are still inconsistent.
lovelacer
parents:
6543
diff
changeset
|
561 |
end; |
6123 | 562 |
end; |
6580
6155187bf599
A partial reformatting of the pascal code to have consistent syntax. Things that are still inconsistent.
lovelacer
parents:
6543
diff
changeset
|
563 |
if isColl then |
6155187bf599
A partial reformatting of the pascal code to have consistent syntax. Things that are still inconsistent.
lovelacer
parents:
6543
diff
changeset
|
564 |
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
|
565 |
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
|
566 |
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
|
567 |
|
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
|
568 |
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
|
569 |
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
|
570 |
|
6580
6155187bf599
A partial reformatting of the pascal code to have consistent syntax. Things that are still inconsistent.
lovelacer
parents:
6543
diff
changeset
|
571 |
if ((ldx = 0) and (ldy = 0)) then |
6990
40e5af28d026
change every return value into a more pascal-ish form, using the name of the fucntion (helps the parser and macpas compaitilibity)
koda
parents:
6986
diff
changeset
|
572 |
exit; |
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
|
573 |
|
3414
b2f3bb44777e
some portal changes, warning: no loop prevention yet, note: entry angle not preserved yet
sheepluva
parents:
3411
diff
changeset
|
574 |
outDeltaX:= ldx; |
b2f3bb44777e
some portal changes, warning: no loop prevention yet, note: entry angle not preserved yet
sheepluva
parents:
3411
diff
changeset
|
575 |
outDeltaY:= ldy; |
6990
40e5af28d026
change every return value into a more pascal-ish form, using the name of the fucntion (helps the parser and macpas compaitilibity)
koda
parents:
6986
diff
changeset
|
576 |
CalcSlopeTangent:= 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
|
577 |
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
|
578 |
|
7754 | 579 |
function CalcSlopeNearGear(Gear: PGear; dirX, dirY: LongInt): hwFloat; |
580 |
var dx, dy: hwFloat; |
|
581 |
collX, collY, i, y, x, gx, gy, sdx, sdy: LongInt; |
|
582 |
isColl, bSucc: Boolean; |
|
583 |
begin |
|
584 |
||
10015 | 585 |
if dirY <> 0 then |
7754 | 586 |
begin |
587 |
y:= hwRound(Gear^.Y) + Gear^.Radius * dirY; |
|
588 |
gx:= hwRound(Gear^.X); |
|
589 |
collX := gx; |
|
590 |
isColl:= false; |
|
591 |
||
592 |
if (y and LAND_HEIGHT_MASK) = 0 then |
|
593 |
begin |
|
594 |
x:= hwRound(Gear^.X) - Gear^.Radius + 1; |
|
595 |
i:= x + Gear^.Radius * 2 - 2; |
|
596 |
repeat |
|
597 |
if (x and LAND_WIDTH_MASK) = 0 then |
|
598 |
if Land[y, x] <> 0 then |
|
7767 | 599 |
if (not isColl) or (abs(x-gx) < abs(collX-gx)) then |
7754 | 600 |
begin |
601 |
isColl:= true; |
|
602 |
collX := x; |
|
603 |
end; |
|
604 |
inc(x) |
|
605 |
until (x > i); |
|
606 |
end; |
|
607 |
end |
|
608 |
else |
|
609 |
begin |
|
610 |
x:= hwRound(Gear^.X) + Gear^.Radius * dirX; |
|
611 |
gy:= hwRound(Gear^.Y); |
|
612 |
collY := gy; |
|
613 |
isColl:= false; |
|
614 |
||
615 |
if (x and LAND_WIDTH_MASK) = 0 then |
|
616 |
begin |
|
617 |
y:= hwRound(Gear^.Y) - Gear^.Radius + 1; |
|
618 |
i:= y + Gear^.Radius * 2 - 2; |
|
619 |
repeat |
|
620 |
if (y and LAND_HEIGHT_MASK) = 0 then |
|
621 |
if Land[y, x] <> 0 then |
|
7767 | 622 |
if (not isColl) or (abs(y-gy) < abs(collY-gy)) then |
7754 | 623 |
begin |
624 |
isColl:= true; |
|
625 |
collY := y; |
|
626 |
end; |
|
627 |
inc(y) |
|
628 |
until (y > i); |
|
629 |
end; |
|
630 |
end; |
|
631 |
||
632 |
if isColl then |
|
633 |
begin |
|
634 |
// save original dx/dy |
|
635 |
dx := Gear^.dX; |
|
636 |
dy := Gear^.dY; |
|
637 |
||
638 |
if dirY <> 0 then |
|
639 |
begin |
|
640 |
Gear^.dX.QWordValue:= 0; |
|
641 |
Gear^.dX.isNegative:= (collX >= gx); |
|
642 |
Gear^.dY:= _1*dirY |
|
643 |
end |
|
644 |
else |
|
645 |
begin |
|
646 |
Gear^.dY.QWordValue:= 0; |
|
647 |
Gear^.dY.isNegative:= (collY >= gy); |
|
648 |
Gear^.dX:= _1*dirX |
|
649 |
end; |
|
650 |
||
651 |
sdx:= 0; |
|
652 |
sdy:= 0; |
|
653 |
if dirY <> 0 then |
|
654 |
bSucc := CalcSlopeTangent(Gear, collX, y, sdx, sdy, 0) |
|
655 |
else bSucc := CalcSlopeTangent(Gear, x, collY, sdx, sdy, 0); |
|
656 |
||
657 |
// restore original dx/dy |
|
658 |
Gear^.dX := dx; |
|
659 |
Gear^.dY := dy; |
|
660 |
||
661 |
if bSucc and ((sdx <> 0) or (sdy <> 0)) then |
|
662 |
begin |
|
663 |
dx := int2hwFloat(sdy) / (abs(sdx) + abs(sdy)); |
|
664 |
dx.isNegative := (sdx * sdy) < 0; |
|
665 |
exit (dx); |
|
666 |
end |
|
667 |
end; |
|
668 |
||
669 |
CalcSlopeNearGear := _0; |
|
670 |
end; |
|
671 |
||
6279 | 672 |
function CalcSlopeBelowGear(Gear: PGear): hwFloat; |
6124 | 673 |
var dx, dy: hwFloat; |
6279 | 674 |
collX, i, y, x, gx, sdx, sdy: LongInt; |
6453
11c578d30bd3
Countless imporvements to the parser and countless help to the parser in sources.
unc0rr
parents:
6279
diff
changeset
|
675 |
isColl, bSucc: Boolean; |
6124 | 676 |
begin |
677 |
||
678 |
||
679 |
y:= hwRound(Gear^.Y) + Gear^.Radius; |
|
680 |
gx:= hwRound(Gear^.X); |
|
681 |
collX := gx; |
|
682 |
isColl:= false; |
|
683 |
||
684 |
if (y and LAND_HEIGHT_MASK) = 0 then |
|
6580
6155187bf599
A partial reformatting of the pascal code to have consistent syntax. Things that are still inconsistent.
lovelacer
parents:
6543
diff
changeset
|
685 |
begin |
6155187bf599
A partial reformatting of the pascal code to have consistent syntax. Things that are still inconsistent.
lovelacer
parents:
6543
diff
changeset
|
686 |
x:= hwRound(Gear^.X) - Gear^.Radius + 1; |
6155187bf599
A partial reformatting of the pascal code to have consistent syntax. Things that are still inconsistent.
lovelacer
parents:
6543
diff
changeset
|
687 |
i:= x + Gear^.Radius * 2 - 2; |
6155187bf599
A partial reformatting of the pascal code to have consistent syntax. Things that are still inconsistent.
lovelacer
parents:
6543
diff
changeset
|
688 |
repeat |
6155187bf599
A partial reformatting of the pascal code to have consistent syntax. Things that are still inconsistent.
lovelacer
parents:
6543
diff
changeset
|
689 |
if (x and LAND_WIDTH_MASK) = 0 then |
6124 | 690 |
if Land[y, x] > 255 then |
7767 | 691 |
if (not isColl) or (abs(x-gx) < abs(collX-gx)) then |
6124 | 692 |
begin |
693 |
isColl:= true; |
|
694 |
collX := x; |
|
695 |
end; |
|
6580
6155187bf599
A partial reformatting of the pascal code to have consistent syntax. Things that are still inconsistent.
lovelacer
parents:
6543
diff
changeset
|
696 |
inc(x) |
6155187bf599
A partial reformatting of the pascal code to have consistent syntax. Things that are still inconsistent.
lovelacer
parents:
6543
diff
changeset
|
697 |
until (x > i); |
6155187bf599
A partial reformatting of the pascal code to have consistent syntax. Things that are still inconsistent.
lovelacer
parents:
6543
diff
changeset
|
698 |
end; |
6124 | 699 |
|
700 |
if isColl then |
|
6279 | 701 |
begin |
702 |
// save original dx/dy |
|
703 |
dx := Gear^.dX; |
|
704 |
dy := Gear^.dY; |
|
705 |
||
706 |
Gear^.dX.QWordValue:= 0; |
|
707 |
Gear^.dX.isNegative:= (collX >= gx); |
|
708 |
Gear^.dY:= _1; |
|
709 |
||
710 |
sdx:= 0; |
|
711 |
sdy:= 0; |
|
6453
11c578d30bd3
Countless imporvements to the parser and countless help to the parser in sources.
unc0rr
parents:
6279
diff
changeset
|
712 |
bSucc := CalcSlopeTangent(Gear, collX, y, sdx, sdy, 255); |
6124 | 713 |
|
6279 | 714 |
// restore original dx/dy |
715 |
Gear^.dX := dx; |
|
716 |
Gear^.dY := dy; |
|
6124 | 717 |
|
6453
11c578d30bd3
Countless imporvements to the parser and countless help to the parser in sources.
unc0rr
parents:
6279
diff
changeset
|
718 |
if bSucc and (sdx <> 0) and (sdy <> 0) then |
6279 | 719 |
begin |
720 |
dx := int2hwFloat(sdy) / (abs(sdx) + abs(sdy)); |
|
721 |
dx.isNegative := (sdx * sdy) < 0; |
|
722 |
exit (dx); |
|
723 |
end; |
|
724 |
end; |
|
725 |
||
726 |
CalcSlopeBelowGear := _0; |
|
6124 | 727 |
end; |
728 |
||
3038 | 729 |
procedure initModule; |
2716
b9ca1bfca24f
complete the replacement of init/free wrappers for every unit
koda
parents:
2630
diff
changeset
|
730 |
begin |
2948
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2716
diff
changeset
|
731 |
Count:= 0; |
2716
b9ca1bfca24f
complete the replacement of init/free wrappers for every unit
koda
parents:
2630
diff
changeset
|
732 |
end; |
b9ca1bfca24f
complete the replacement of init/free wrappers for every unit
koda
parents:
2630
diff
changeset
|
733 |
|
3038 | 734 |
procedure freeModule; |
2716
b9ca1bfca24f
complete the replacement of init/free wrappers for every unit
koda
parents:
2630
diff
changeset
|
735 |
begin |
b9ca1bfca24f
complete the replacement of init/free wrappers for every unit
koda
parents:
2630
diff
changeset
|
736 |
|
b9ca1bfca24f
complete the replacement of init/free wrappers for every unit
koda
parents:
2630
diff
changeset
|
737 |
end; |
b9ca1bfca24f
complete the replacement of init/free wrappers for every unit
koda
parents:
2630
diff
changeset
|
738 |
|
4 | 739 |
end. |