hedgewars/uCollisions.pas
author nemo
Thu, 01 Jul 2010 17:00:14 -0400
changeset 3603 b6b1989744ef
parent 3569 27b0ec683572
child 3608 c509bbc779e7
permissions -rw-r--r--
Grid the landscape, and shortcircuit checks on the collision array if there are no nearby checked in collisions to be collided with. This is a big win for fire's ammoshove in particular. Also add a +2 that seemed missing in the check, and update fire accordingly.
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
4
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
     1
(*
1066
1f1b3686a2b0 Update copyright headers a bit
unc0rr
parents: 967
diff changeset
     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
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
     4
 *
183
57c2ef19f719 Relicense to GPL
unc0rr
parents: 107
diff changeset
     5
 * This program is free software; you can redistribute it and/or modify
57c2ef19f719 Relicense to GPL
unc0rr
parents: 107
diff changeset
     6
 * it under the terms of the GNU General Public License as published by
57c2ef19f719 Relicense to GPL
unc0rr
parents: 107
diff changeset
     7
 * the Free Software Foundation; version 2 of the License
4
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
     8
 *
183
57c2ef19f719 Relicense to GPL
unc0rr
parents: 107
diff changeset
     9
 * This program is distributed in the hope that it will be useful,
57c2ef19f719 Relicense to GPL
unc0rr
parents: 107
diff changeset
    10
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
57c2ef19f719 Relicense to GPL
unc0rr
parents: 107
diff changeset
    11
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
57c2ef19f719 Relicense to GPL
unc0rr
parents: 107
diff changeset
    12
 * GNU General Public License for more details.
4
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
    13
 *
183
57c2ef19f719 Relicense to GPL
unc0rr
parents: 107
diff changeset
    14
 * You should have received a copy of the GNU General Public License
57c2ef19f719 Relicense to GPL
unc0rr
parents: 107
diff changeset
    15
 * along with this program; if not, write to the Free Software
57c2ef19f719 Relicense to GPL
unc0rr
parents: 107
diff changeset
    16
 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
4
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
    17
 *)
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
    18
2630
079ef82eac75 revamped file access and debug display
koda
parents: 2599
diff changeset
    19
{$INCLUDE "options.inc"}
079ef82eac75 revamped file access and debug display
koda
parents: 2599
diff changeset
    20
4
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
    21
unit uCollisions;
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
    22
interface
351
29bc9c36ad5f Fixed-point arithmetics in engine.
unc0rr
parents: 183
diff changeset
    23
uses uGears, uFloat;
2630
079ef82eac75 revamped file access and debug display
koda
parents: 2599
diff changeset
    24
53
0e27949850e3 - Fixed bubble theme object
unc0rr
parents: 38
diff changeset
    25
const cMaxGearArrayInd = 255;
4
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
    26
70
82d93eeecebe - Many AI improvements
unc0rr
parents: 68
diff changeset
    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
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
    32
3038
4e48c276a468 In pascal unit is a namespace
unc0rr
parents: 2948
diff changeset
    33
procedure initModule;
4e48c276a468 In pascal unit is a namespace
unc0rr
parents: 2948
diff changeset
    34
procedure freeModule;
2716
b9ca1bfca24f complete the replacement of init/free wrappers for every unit
koda
parents: 2630
diff changeset
    35
53
0e27949850e3 - Fixed bubble theme object
unc0rr
parents: 38
diff changeset
    36
procedure AddGearCI(Gear: PGear);
0e27949850e3 - Fixed bubble theme object
unc0rr
parents: 38
diff changeset
    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
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
    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
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
    54
implementation
3407
dcc129c4352e Engine:
smxx
parents: 3401
diff changeset
    55
uses uMisc, uConsts, uLand, uLandGraphics;
4
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
    56
53
0e27949850e3 - Fixed bubble theme object
unc0rr
parents: 38
diff changeset
    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
29bc9c36ad5f Fixed-point arithmetics in engine.
unc0rr
parents: 183
diff changeset
    61
906
1cc10dde304c Double increase collision array size
unc0rr
parents: 883
diff changeset
    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
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
    66
53
0e27949850e3 - Fixed bubble theme object
unc0rr
parents: 38
diff changeset
    67
procedure AddGearCI(Gear: PGear);
3603
b6b1989744ef Grid the landscape, and shortcircuit checks on the collision array if there are no nearby checked in collisions to be collided with. This is a big win for fire's ammoshove in particular. Also add a +2 that seemed missing in the check, and update fire accordingly.
nemo
parents: 3569
diff changeset
    68
var i, j, k, tr: LongInt;
b6b1989744ef Grid the landscape, and shortcircuit checks on the collision array if there are no nearby checked in collisions to be collided with. This is a big win for fire's ammoshove in particular. Also add a +2 that seemed missing in the check, and update fire accordingly.
nemo
parents: 3569
diff changeset
    69
    tmpVals: array[0..8] of byte;
53
0e27949850e3 - Fixed bubble theme object
unc0rr
parents: 38
diff changeset
    70
begin
511
2b5b9e00419d - Further work on new collisions implementation
unc0rr
parents: 505
diff changeset
    71
if Gear^.CollisionIndex >= 0 then exit;
4
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
    72
TryDo(Count <= MAXRECTSINDEX, 'Collision rects array overflow', true);
53
0e27949850e3 - Fixed bubble theme object
unc0rr
parents: 38
diff changeset
    73
with cinfos[Count] do
2948
3f21a9dc93d0 Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents: 2716
diff changeset
    74
    begin
3f21a9dc93d0 Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents: 2716
diff changeset
    75
    X:= hwRound(Gear^.X);
3f21a9dc93d0 Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents: 2716
diff changeset
    76
    Y:= hwRound(Gear^.Y);
3f21a9dc93d0 Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents: 2716
diff changeset
    77
    Radius:= Gear^.Radius;
3603
b6b1989744ef Grid the landscape, and shortcircuit checks on the collision array if there are no nearby checked in collisions to be collided with. This is a big win for fire's ammoshove in particular. Also add a +2 that seemed missing in the check, and update fire accordingly.
nemo
parents: 3569
diff changeset
    78
    tr:= Radius - 1;
b6b1989744ef Grid the landscape, and shortcircuit checks on the collision array if there are no nearby checked in collisions to be collided with. This is a big win for fire's ammoshove in particular. Also add a +2 that seemed missing in the check, and update fire accordingly.
nemo
parents: 3569
diff changeset
    79
    ChangeRoundInLand(X, Y, tr, true);
b6b1989744ef Grid the landscape, and shortcircuit checks on the collision array if there are no nearby checked in collisions to be collided with. This is a big win for fire's ammoshove in particular. Also add a +2 that seemed missing in the check, and update fire accordingly.
nemo
parents: 3569
diff changeset
    80
    cGear:= Gear;
b6b1989744ef Grid the landscape, and shortcircuit checks on the collision array if there are no nearby checked in collisions to be collided with. This is a big win for fire's ammoshove in particular. Also add a +2 that seemed missing in the check, and update fire accordingly.
nemo
parents: 3569
diff changeset
    81
    k:= 0;
b6b1989744ef Grid the landscape, and shortcircuit checks on the collision array if there are no nearby checked in collisions to be collided with. This is a big win for fire's ammoshove in particular. Also add a +2 that seemed missing in the check, and update fire accordingly.
nemo
parents: 3569
diff changeset
    82
    for i:= -1 to 1 do
b6b1989744ef Grid the landscape, and shortcircuit checks on the collision array if there are no nearby checked in collisions to be collided with. This is a big win for fire's ammoshove in particular. Also add a +2 that seemed missing in the check, and update fire accordingly.
nemo
parents: 3569
diff changeset
    83
        for j:= -1 to 1 do
b6b1989744ef Grid the landscape, and shortcircuit checks on the collision array if there are no nearby checked in collisions to be collided with. This is a big win for fire's ammoshove in particular. Also add a +2 that seemed missing in the check, and update fire accordingly.
nemo
parents: 3569
diff changeset
    84
            begin
b6b1989744ef Grid the landscape, and shortcircuit checks on the collision array if there are no nearby checked in collisions to be collided with. This is a big win for fire's ammoshove in particular. Also add a +2 that seemed missing in the check, and update fire accordingly.
nemo
parents: 3569
diff changeset
    85
            tmpVals[k]:= LandCollided[(Y + tr*i) div 32, (X + tr*i) div 32];
b6b1989744ef Grid the landscape, and shortcircuit checks on the collision array if there are no nearby checked in collisions to be collided with. This is a big win for fire's ammoshove in particular. Also add a +2 that seemed missing in the check, and update fire accordingly.
nemo
parents: 3569
diff changeset
    86
            inc(k);
b6b1989744ef Grid the landscape, and shortcircuit checks on the collision array if there are no nearby checked in collisions to be collided with. This is a big win for fire's ammoshove in particular. Also add a +2 that seemed missing in the check, and update fire accordingly.
nemo
parents: 3569
diff changeset
    87
            end;
b6b1989744ef Grid the landscape, and shortcircuit checks on the collision array if there are no nearby checked in collisions to be collided with. This is a big win for fire's ammoshove in particular. Also add a +2 that seemed missing in the check, and update fire accordingly.
nemo
parents: 3569
diff changeset
    88
    k:= 0;
b6b1989744ef Grid the landscape, and shortcircuit checks on the collision array if there are no nearby checked in collisions to be collided with. This is a big win for fire's ammoshove in particular. Also add a +2 that seemed missing in the check, and update fire accordingly.
nemo
parents: 3569
diff changeset
    89
    for i:= -1 to 1 do
b6b1989744ef Grid the landscape, and shortcircuit checks on the collision array if there are no nearby checked in collisions to be collided with. This is a big win for fire's ammoshove in particular. Also add a +2 that seemed missing in the check, and update fire accordingly.
nemo
parents: 3569
diff changeset
    90
        for j:= -1 to 1 do
b6b1989744ef Grid the landscape, and shortcircuit checks on the collision array if there are no nearby checked in collisions to be collided with. This is a big win for fire's ammoshove in particular. Also add a +2 that seemed missing in the check, and update fire accordingly.
nemo
parents: 3569
diff changeset
    91
            begin
b6b1989744ef Grid the landscape, and shortcircuit checks on the collision array if there are no nearby checked in collisions to be collided with. This is a big win for fire's ammoshove in particular. Also add a +2 that seemed missing in the check, and update fire accordingly.
nemo
parents: 3569
diff changeset
    92
            if LandCollided[(Y + tr*i) div 32, (X + tr*i) div 32] < 255 then LandCollided[(Y + tr*i) div 32, (X + tr*i) div 32]:= tmpVals[k] + 1;
b6b1989744ef Grid the landscape, and shortcircuit checks on the collision array if there are no nearby checked in collisions to be collided with. This is a big win for fire's ammoshove in particular. Also add a +2 that seemed missing in the check, and update fire accordingly.
nemo
parents: 3569
diff changeset
    93
            inc(k)
b6b1989744ef Grid the landscape, and shortcircuit checks on the collision array if there are no nearby checked in collisions to be collided with. This is a big win for fire's ammoshove in particular. Also add a +2 that seemed missing in the check, and update fire accordingly.
nemo
parents: 3569
diff changeset
    94
            end
2948
3f21a9dc93d0 Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents: 2716
diff changeset
    95
    end;
511
2b5b9e00419d - Further work on new collisions implementation
unc0rr
parents: 505
diff changeset
    96
Gear^.CollisionIndex:= Count;
4
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
    97
inc(Count)
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
    98
end;
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
    99
53
0e27949850e3 - Fixed bubble theme object
unc0rr
parents: 38
diff changeset
   100
procedure DeleteCI(Gear: PGear);
3603
b6b1989744ef Grid the landscape, and shortcircuit checks on the collision array if there are no nearby checked in collisions to be collided with. This is a big win for fire's ammoshove in particular. Also add a +2 that seemed missing in the check, and update fire accordingly.
nemo
parents: 3569
diff changeset
   101
var i, j, k, tr: LongInt;
b6b1989744ef Grid the landscape, and shortcircuit checks on the collision array if there are no nearby checked in collisions to be collided with. This is a big win for fire's ammoshove in particular. Also add a +2 that seemed missing in the check, and update fire accordingly.
nemo
parents: 3569
diff changeset
   102
    tmpVals: array[0..8] of byte;
4
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
   103
begin
511
2b5b9e00419d - Further work on new collisions implementation
unc0rr
parents: 505
diff changeset
   104
if Gear^.CollisionIndex >= 0 then
2948
3f21a9dc93d0 Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents: 2716
diff changeset
   105
    begin
3f21a9dc93d0 Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents: 2716
diff changeset
   106
    with cinfos[Gear^.CollisionIndex] do
3603
b6b1989744ef Grid the landscape, and shortcircuit checks on the collision array if there are no nearby checked in collisions to be collided with. This is a big win for fire's ammoshove in particular. Also add a +2 that seemed missing in the check, and update fire accordingly.
nemo
parents: 3569
diff changeset
   107
        begin
b6b1989744ef Grid the landscape, and shortcircuit checks on the collision array if there are no nearby checked in collisions to be collided with. This is a big win for fire's ammoshove in particular. Also add a +2 that seemed missing in the check, and update fire accordingly.
nemo
parents: 3569
diff changeset
   108
        tr:= Radius - 1;
b6b1989744ef Grid the landscape, and shortcircuit checks on the collision array if there are no nearby checked in collisions to be collided with. This is a big win for fire's ammoshove in particular. Also add a +2 that seemed missing in the check, and update fire accordingly.
nemo
parents: 3569
diff changeset
   109
        ChangeRoundInLand(X, Y, tr, false);
b6b1989744ef Grid the landscape, and shortcircuit checks on the collision array if there are no nearby checked in collisions to be collided with. This is a big win for fire's ammoshove in particular. Also add a +2 that seemed missing in the check, and update fire accordingly.
nemo
parents: 3569
diff changeset
   110
        k:= 0;
b6b1989744ef Grid the landscape, and shortcircuit checks on the collision array if there are no nearby checked in collisions to be collided with. This is a big win for fire's ammoshove in particular. Also add a +2 that seemed missing in the check, and update fire accordingly.
nemo
parents: 3569
diff changeset
   111
        for i:= -1 to 1 do
b6b1989744ef Grid the landscape, and shortcircuit checks on the collision array if there are no nearby checked in collisions to be collided with. This is a big win for fire's ammoshove in particular. Also add a +2 that seemed missing in the check, and update fire accordingly.
nemo
parents: 3569
diff changeset
   112
            for j:= -1 to 1 do
b6b1989744ef Grid the landscape, and shortcircuit checks on the collision array if there are no nearby checked in collisions to be collided with. This is a big win for fire's ammoshove in particular. Also add a +2 that seemed missing in the check, and update fire accordingly.
nemo
parents: 3569
diff changeset
   113
                begin
b6b1989744ef Grid the landscape, and shortcircuit checks on the collision array if there are no nearby checked in collisions to be collided with. This is a big win for fire's ammoshove in particular. Also add a +2 that seemed missing in the check, and update fire accordingly.
nemo
parents: 3569
diff changeset
   114
                tmpVals[k]:= LandCollided[(Y + tr*i) div 32, (X + tr*i) div 32];
b6b1989744ef Grid the landscape, and shortcircuit checks on the collision array if there are no nearby checked in collisions to be collided with. This is a big win for fire's ammoshove in particular. Also add a +2 that seemed missing in the check, and update fire accordingly.
nemo
parents: 3569
diff changeset
   115
                inc(k);
b6b1989744ef Grid the landscape, and shortcircuit checks on the collision array if there are no nearby checked in collisions to be collided with. This is a big win for fire's ammoshove in particular. Also add a +2 that seemed missing in the check, and update fire accordingly.
nemo
parents: 3569
diff changeset
   116
                end;
b6b1989744ef Grid the landscape, and shortcircuit checks on the collision array if there are no nearby checked in collisions to be collided with. This is a big win for fire's ammoshove in particular. Also add a +2 that seemed missing in the check, and update fire accordingly.
nemo
parents: 3569
diff changeset
   117
        k:= 0;
b6b1989744ef Grid the landscape, and shortcircuit checks on the collision array if there are no nearby checked in collisions to be collided with. This is a big win for fire's ammoshove in particular. Also add a +2 that seemed missing in the check, and update fire accordingly.
nemo
parents: 3569
diff changeset
   118
        for i:= -1 to 1 do
b6b1989744ef Grid the landscape, and shortcircuit checks on the collision array if there are no nearby checked in collisions to be collided with. This is a big win for fire's ammoshove in particular. Also add a +2 that seemed missing in the check, and update fire accordingly.
nemo
parents: 3569
diff changeset
   119
            for j:= -1 to 1 do
b6b1989744ef Grid the landscape, and shortcircuit checks on the collision array if there are no nearby checked in collisions to be collided with. This is a big win for fire's ammoshove in particular. Also add a +2 that seemed missing in the check, and update fire accordingly.
nemo
parents: 3569
diff changeset
   120
                begin
b6b1989744ef Grid the landscape, and shortcircuit checks on the collision array if there are no nearby checked in collisions to be collided with. This is a big win for fire's ammoshove in particular. Also add a +2 that seemed missing in the check, and update fire accordingly.
nemo
parents: 3569
diff changeset
   121
                if LandCollided[(Y + tr*i) div 32, (X + tr*i) div 32] > 0 then LandCollided[(Y + tr*i) div 32, (X + tr*i) div 32]:= tmpVals[k] - 1;
b6b1989744ef Grid the landscape, and shortcircuit checks on the collision array if there are no nearby checked in collisions to be collided with. This is a big win for fire's ammoshove in particular. Also add a +2 that seemed missing in the check, and update fire accordingly.
nemo
parents: 3569
diff changeset
   122
                inc(k)
b6b1989744ef Grid the landscape, and shortcircuit checks on the collision array if there are no nearby checked in collisions to be collided with. This is a big win for fire's ammoshove in particular. Also add a +2 that seemed missing in the check, and update fire accordingly.
nemo
parents: 3569
diff changeset
   123
                end
b6b1989744ef Grid the landscape, and shortcircuit checks on the collision array if there are no nearby checked in collisions to be collided with. This is a big win for fire's ammoshove in particular. Also add a +2 that seemed missing in the check, and update fire accordingly.
nemo
parents: 3569
diff changeset
   124
        end;
2948
3f21a9dc93d0 Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents: 2716
diff changeset
   125
    cinfos[Gear^.CollisionIndex]:= cinfos[Pred(Count)];
3f21a9dc93d0 Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents: 2716
diff changeset
   126
    cinfos[Gear^.CollisionIndex].cGear^.CollisionIndex:= Gear^.CollisionIndex;
3f21a9dc93d0 Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents: 2716
diff changeset
   127
    Gear^.CollisionIndex:= -1;
3f21a9dc93d0 Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents: 2716
diff changeset
   128
    dec(Count)
3f21a9dc93d0 Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents: 2716
diff changeset
   129
    end;
4
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
   130
end;
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
   131
53
0e27949850e3 - Fixed bubble theme object
unc0rr
parents: 38
diff changeset
   132
function CheckGearsCollision(Gear: PGear): PGearArray;
3603
b6b1989744ef Grid the landscape, and shortcircuit checks on the collision array if there are no nearby checked in collisions to be collided with. This is a big win for fire's ammoshove in particular. Also add a +2 that seemed missing in the check, and update fire accordingly.
nemo
parents: 3569
diff changeset
   133
var mx, my, xP, xN, x0, yP, yN, y0, tr: LongInt;
2948
3f21a9dc93d0 Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents: 2716
diff changeset
   134
    i: Longword;
4
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
   135
begin
1506
a4ab75470ce1 - Some reformatting
unc0rr
parents: 1066
diff changeset
   136
CheckGearsCollision:= @ga;
53
0e27949850e3 - Fixed bubble theme object
unc0rr
parents: 38
diff changeset
   137
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
   138
if Count = 0 then exit;
351
29bc9c36ad5f Fixed-point arithmetics in engine.
unc0rr
parents: 183
diff changeset
   139
mx:= hwRound(Gear^.X);
29bc9c36ad5f Fixed-point arithmetics in engine.
unc0rr
parents: 183
diff changeset
   140
my:= hwRound(Gear^.Y);
3603
b6b1989744ef Grid the landscape, and shortcircuit checks on the collision array if there are no nearby checked in collisions to be collided with. This is a big win for fire's ammoshove in particular. Also add a +2 that seemed missing in the check, and update fire accordingly.
nemo
parents: 3569
diff changeset
   141
tr:= Gear^.Radius - 1;
b6b1989744ef Grid the landscape, and shortcircuit checks on the collision array if there are no nearby checked in collisions to be collided with. This is a big win for fire's ammoshove in particular. Also add a +2 that seemed missing in the check, and update fire accordingly.
nemo
parents: 3569
diff changeset
   142
xP:= (mx + tr) div 32;
b6b1989744ef Grid the landscape, and shortcircuit checks on the collision array if there are no nearby checked in collisions to be collided with. This is a big win for fire's ammoshove in particular. Also add a +2 that seemed missing in the check, and update fire accordingly.
nemo
parents: 3569
diff changeset
   143
xN:= (mx - tr) div 32;
b6b1989744ef Grid the landscape, and shortcircuit checks on the collision array if there are no nearby checked in collisions to be collided with. This is a big win for fire's ammoshove in particular. Also add a +2 that seemed missing in the check, and update fire accordingly.
nemo
parents: 3569
diff changeset
   144
yP:= (my + tr) div 32;
b6b1989744ef Grid the landscape, and shortcircuit checks on the collision array if there are no nearby checked in collisions to be collided with. This is a big win for fire's ammoshove in particular. Also add a +2 that seemed missing in the check, and update fire accordingly.
nemo
parents: 3569
diff changeset
   145
yN:= (my - tr) div 32;
b6b1989744ef Grid the landscape, and shortcircuit checks on the collision array if there are no nearby checked in collisions to be collided with. This is a big win for fire's ammoshove in particular. Also add a +2 that seemed missing in the check, and update fire accordingly.
nemo
parents: 3569
diff changeset
   146
x0:= mx div 32;
b6b1989744ef Grid the landscape, and shortcircuit checks on the collision array if there are no nearby checked in collisions to be collided with. This is a big win for fire's ammoshove in particular. Also add a +2 that seemed missing in the check, and update fire accordingly.
nemo
parents: 3569
diff changeset
   147
y0:= my div 32;
4
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
   148
3603
b6b1989744ef Grid the landscape, and shortcircuit checks on the collision array if there are no nearby checked in collisions to be collided with. This is a big win for fire's ammoshove in particular. Also add a +2 that seemed missing in the check, and update fire accordingly.
nemo
parents: 3569
diff changeset
   149
if (LandCollided[yN, xN] <> 0) or
b6b1989744ef Grid the landscape, and shortcircuit checks on the collision array if there are no nearby checked in collisions to be collided with. This is a big win for fire's ammoshove in particular. Also add a +2 that seemed missing in the check, and update fire accordingly.
nemo
parents: 3569
diff changeset
   150
   (LandCollided[yN, x0] <> 0) or
b6b1989744ef Grid the landscape, and shortcircuit checks on the collision array if there are no nearby checked in collisions to be collided with. This is a big win for fire's ammoshove in particular. Also add a +2 that seemed missing in the check, and update fire accordingly.
nemo
parents: 3569
diff changeset
   151
   (LandCollided[yN, xP] <> 0) or
b6b1989744ef Grid the landscape, and shortcircuit checks on the collision array if there are no nearby checked in collisions to be collided with. This is a big win for fire's ammoshove in particular. Also add a +2 that seemed missing in the check, and update fire accordingly.
nemo
parents: 3569
diff changeset
   152
   (LandCollided[y0, xN] <> 0) or
b6b1989744ef Grid the landscape, and shortcircuit checks on the collision array if there are no nearby checked in collisions to be collided with. This is a big win for fire's ammoshove in particular. Also add a +2 that seemed missing in the check, and update fire accordingly.
nemo
parents: 3569
diff changeset
   153
   (LandCollided[y0, x0] <> 0) or
b6b1989744ef Grid the landscape, and shortcircuit checks on the collision array if there are no nearby checked in collisions to be collided with. This is a big win for fire's ammoshove in particular. Also add a +2 that seemed missing in the check, and update fire accordingly.
nemo
parents: 3569
diff changeset
   154
   (LandCollided[y0, xP] <> 0) or
b6b1989744ef Grid the landscape, and shortcircuit checks on the collision array if there are no nearby checked in collisions to be collided with. This is a big win for fire's ammoshove in particular. Also add a +2 that seemed missing in the check, and update fire accordingly.
nemo
parents: 3569
diff changeset
   155
   (LandCollided[yP, xN] <> 0) or
b6b1989744ef Grid the landscape, and shortcircuit checks on the collision array if there are no nearby checked in collisions to be collided with. This is a big win for fire's ammoshove in particular. Also add a +2 that seemed missing in the check, and update fire accordingly.
nemo
parents: 3569
diff changeset
   156
   (LandCollided[yP, x0] <> 0) or
b6b1989744ef Grid the landscape, and shortcircuit checks on the collision array if there are no nearby checked in collisions to be collided with. This is a big win for fire's ammoshove in particular. Also add a +2 that seemed missing in the check, and update fire accordingly.
nemo
parents: 3569
diff changeset
   157
   (LandCollided[yP, xP] <> 0) then 
b6b1989744ef Grid the landscape, and shortcircuit checks on the collision array if there are no nearby checked in collisions to be collided with. This is a big win for fire's ammoshove in particular. Also add a +2 that seemed missing in the check, and update fire accordingly.
nemo
parents: 3569
diff changeset
   158
    for i:= 0 to Pred(Count) do
b6b1989744ef Grid the landscape, and shortcircuit checks on the collision array if there are no nearby checked in collisions to be collided with. This is a big win for fire's ammoshove in particular. Also add a +2 that seemed missing in the check, and update fire accordingly.
nemo
parents: 3569
diff changeset
   159
        with cinfos[i] do
b6b1989744ef Grid the landscape, and shortcircuit checks on the collision array if there are no nearby checked in collisions to be collided with. This is a big win for fire's ammoshove in particular. Also add a +2 that seemed missing in the check, and update fire accordingly.
nemo
parents: 3569
diff changeset
   160
            if (Gear <> cGear) and
b6b1989744ef Grid the landscape, and shortcircuit checks on the collision array if there are no nearby checked in collisions to be collided with. This is a big win for fire's ammoshove in particular. Also add a +2 that seemed missing in the check, and update fire accordingly.
nemo
parents: 3569
diff changeset
   161
                (sqr(mx - x) + sqr(my - y) <= sqr(Radius + Gear^.Radius + 2)) then
b6b1989744ef Grid the landscape, and shortcircuit checks on the collision array if there are no nearby checked in collisions to be collided with. This is a big win for fire's ammoshove in particular. Also add a +2 that seemed missing in the check, and update fire accordingly.
nemo
parents: 3569
diff changeset
   162
                    begin
b6b1989744ef Grid the landscape, and shortcircuit checks on the collision array if there are no nearby checked in collisions to be collided with. This is a big win for fire's ammoshove in particular. Also add a +2 that seemed missing in the check, and update fire accordingly.
nemo
parents: 3569
diff changeset
   163
                    ga.ar[ga.Count]:= cinfos[i].cGear;
b6b1989744ef Grid the landscape, and shortcircuit checks on the collision array if there are no nearby checked in collisions to be collided with. This is a big win for fire's ammoshove in particular. Also add a +2 that seemed missing in the check, and update fire accordingly.
nemo
parents: 3569
diff changeset
   164
                    inc(ga.Count)
b6b1989744ef Grid the landscape, and shortcircuit checks on the collision array if there are no nearby checked in collisions to be collided with. This is a big win for fire's ammoshove in particular. Also add a +2 that seemed missing in the check, and update fire accordingly.
nemo
parents: 3569
diff changeset
   165
                    end
4
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
   166
end;
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
   167
371
731ad6d27bd1 integer -> LongInt
unc0rr
parents: 351
diff changeset
   168
function TestCollisionXwithGear(Gear: PGear; Dir: LongInt): boolean;
731ad6d27bd1 integer -> LongInt
unc0rr
parents: 351
diff changeset
   169
var x, y, i: LongInt;
2948
3f21a9dc93d0 Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents: 2716
diff changeset
   170
    TestWord: LongWord;
4
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
   171
begin
505
fcba7d7aea0d Fix old bug with grenade(bomd, etc..) not colliding with attacking hedgehog
unc0rr
parents: 504
diff changeset
   172
if Gear^.IntersectGear <> nil then
fcba7d7aea0d Fix old bug with grenade(bomd, etc..) not colliding with attacking hedgehog
unc0rr
parents: 504
diff changeset
   173
   with Gear^ do
fcba7d7aea0d Fix old bug with grenade(bomd, etc..) not colliding with attacking hedgehog
unc0rr
parents: 504
diff changeset
   174
        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
   175
           (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
   176
           begin
fcba7d7aea0d Fix old bug with grenade(bomd, etc..) not colliding with attacking hedgehog
unc0rr
parents: 504
diff changeset
   177
           IntersectGear:= nil;
fcba7d7aea0d Fix old bug with grenade(bomd, etc..) not colliding with attacking hedgehog
unc0rr
parents: 504
diff changeset
   178
           TestWord:= 0
838
1faae19f2116 Remove tailing spaces in some places
unc0rr
parents: 542
diff changeset
   179
           end else
1966
31e449e1d9dd nemo's patch + ropes ammo scheme hack
unc0rr
parents: 1753
diff changeset
   180
           TestWord:= 255
505
fcba7d7aea0d Fix old bug with grenade(bomd, etc..) not colliding with attacking hedgehog
unc0rr
parents: 504
diff changeset
   181
   else TestWord:= 0;
838
1faae19f2116 Remove tailing spaces in some places
unc0rr
parents: 542
diff changeset
   182
351
29bc9c36ad5f Fixed-point arithmetics in engine.
unc0rr
parents: 183
diff changeset
   183
x:= hwRound(Gear^.X);
29bc9c36ad5f Fixed-point arithmetics in engine.
unc0rr
parents: 183
diff changeset
   184
if Dir < 0 then x:= x - Gear^.Radius
29bc9c36ad5f Fixed-point arithmetics in engine.
unc0rr
parents: 183
diff changeset
   185
           else x:= x + Gear^.Radius;
1753
2ccba26f1aa4 Apply nemo's world resize patch
unc0rr
parents: 1528
diff changeset
   186
if (x and LAND_WIDTH_MASK) = 0 then
4
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
   187
   begin
351
29bc9c36ad5f Fixed-point arithmetics in engine.
unc0rr
parents: 183
diff changeset
   188
   y:= hwRound(Gear^.Y) - Gear^.Radius + 1;
29bc9c36ad5f Fixed-point arithmetics in engine.
unc0rr
parents: 183
diff changeset
   189
   i:= y + Gear^.Radius * 2 - 2;
4
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
   190
   repeat
1753
2ccba26f1aa4 Apply nemo's world resize patch
unc0rr
parents: 1528
diff changeset
   191
     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
   192
        if Land[y, x] > TestWord then exit(true);
4
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
   193
     inc(y)
351
29bc9c36ad5f Fixed-point arithmetics in engine.
unc0rr
parents: 183
diff changeset
   194
   until (y > i);
29bc9c36ad5f Fixed-point arithmetics in engine.
unc0rr
parents: 183
diff changeset
   195
   end;
29bc9c36ad5f Fixed-point arithmetics in engine.
unc0rr
parents: 183
diff changeset
   196
TestCollisionXwithGear:= false
4
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
   197
end;
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
   198
505
fcba7d7aea0d Fix old bug with grenade(bomd, etc..) not colliding with attacking hedgehog
unc0rr
parents: 504
diff changeset
   199
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
   200
var x, y, i: LongInt;
fcba7d7aea0d Fix old bug with grenade(bomd, etc..) not colliding with attacking hedgehog
unc0rr
parents: 504
diff changeset
   201
    TestWord: LongWord;
fcba7d7aea0d Fix old bug with grenade(bomd, etc..) not colliding with attacking hedgehog
unc0rr
parents: 504
diff changeset
   202
begin
fcba7d7aea0d Fix old bug with grenade(bomd, etc..) not colliding with attacking hedgehog
unc0rr
parents: 504
diff changeset
   203
if Gear^.IntersectGear <> nil then
fcba7d7aea0d Fix old bug with grenade(bomd, etc..) not colliding with attacking hedgehog
unc0rr
parents: 504
diff changeset
   204
   with Gear^ do
fcba7d7aea0d Fix old bug with grenade(bomd, etc..) not colliding with attacking hedgehog
unc0rr
parents: 504
diff changeset
   205
        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
   206
           (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
   207
           begin
fcba7d7aea0d Fix old bug with grenade(bomd, etc..) not colliding with attacking hedgehog
unc0rr
parents: 504
diff changeset
   208
           IntersectGear:= nil;
fcba7d7aea0d Fix old bug with grenade(bomd, etc..) not colliding with attacking hedgehog
unc0rr
parents: 504
diff changeset
   209
           TestWord:= 0
513
69e06d710d46 Moving hedgehog could get another hedgehog moving forward
unc0rr
parents: 511
diff changeset
   210
           end else
1966
31e449e1d9dd nemo's patch + ropes ammo scheme hack
unc0rr
parents: 1753
diff changeset
   211
           TestWord:= 255
505
fcba7d7aea0d Fix old bug with grenade(bomd, etc..) not colliding with attacking hedgehog
unc0rr
parents: 504
diff changeset
   212
   else TestWord:= 0;
fcba7d7aea0d Fix old bug with grenade(bomd, etc..) not colliding with attacking hedgehog
unc0rr
parents: 504
diff changeset
   213
fcba7d7aea0d Fix old bug with grenade(bomd, etc..) not colliding with attacking hedgehog
unc0rr
parents: 504
diff changeset
   214
y:= hwRound(Gear^.Y);
fcba7d7aea0d Fix old bug with grenade(bomd, etc..) not colliding with attacking hedgehog
unc0rr
parents: 504
diff changeset
   215
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
   216
           else y:= y + Gear^.Radius;
1753
2ccba26f1aa4 Apply nemo's world resize patch
unc0rr
parents: 1528
diff changeset
   217
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
   218
   begin
fcba7d7aea0d Fix old bug with grenade(bomd, etc..) not colliding with attacking hedgehog
unc0rr
parents: 504
diff changeset
   219
   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
   220
   i:= x + Gear^.Radius * 2 - 2;
fcba7d7aea0d Fix old bug with grenade(bomd, etc..) not colliding with attacking hedgehog
unc0rr
parents: 504
diff changeset
   221
   repeat
1753
2ccba26f1aa4 Apply nemo's world resize patch
unc0rr
parents: 1528
diff changeset
   222
     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
   223
        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
   224
     inc(x)
fcba7d7aea0d Fix old bug with grenade(bomd, etc..) not colliding with attacking hedgehog
unc0rr
parents: 504
diff changeset
   225
   until (x > i);
fcba7d7aea0d Fix old bug with grenade(bomd, etc..) not colliding with attacking hedgehog
unc0rr
parents: 504
diff changeset
   226
   end;
fcba7d7aea0d Fix old bug with grenade(bomd, etc..) not colliding with attacking hedgehog
unc0rr
parents: 504
diff changeset
   227
TestCollisionYwithGear:= false
fcba7d7aea0d Fix old bug with grenade(bomd, etc..) not colliding with attacking hedgehog
unc0rr
parents: 504
diff changeset
   228
end;
fcba7d7aea0d Fix old bug with grenade(bomd, etc..) not colliding with attacking hedgehog
unc0rr
parents: 504
diff changeset
   229
513
69e06d710d46 Moving hedgehog could get another hedgehog moving forward
unc0rr
parents: 511
diff changeset
   230
function TestCollisionXKick(Gear: PGear; Dir: LongInt): boolean;
3603
b6b1989744ef Grid the landscape, and shortcircuit checks on the collision array if there are no nearby checked in collisions to be collided with. This is a big win for fire's ammoshove in particular. Also add a +2 that seemed missing in the check, and update fire accordingly.
nemo
parents: 3569
diff changeset
   231
var x, y, mx, my, i, xP, xN, x0, yP, yN, y0, tr: LongInt;
513
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
x:= hwRound(Gear^.X);
69e06d710d46 Moving hedgehog could get another hedgehog moving forward
unc0rr
parents: 511
diff changeset
   236
if Dir < 0 then x:= x - Gear^.Radius
69e06d710d46 Moving hedgehog could get another hedgehog moving forward
unc0rr
parents: 511
diff changeset
   237
           else x:= x + Gear^.Radius;
1753
2ccba26f1aa4 Apply nemo's world resize patch
unc0rr
parents: 1528
diff changeset
   238
if (x and LAND_WIDTH_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
   y:= hwRound(Gear^.Y) - Gear^.Radius + 1;
69e06d710d46 Moving hedgehog could get another hedgehog moving forward
unc0rr
parents: 511
diff changeset
   241
   i:= y + Gear^.Radius * 2 - 2;
69e06d710d46 Moving hedgehog could get another hedgehog moving forward
unc0rr
parents: 511
diff changeset
   242
   repeat
1753
2ccba26f1aa4 Apply nemo's world resize patch
unc0rr
parents: 1528
diff changeset
   243
     if (y and LAND_HEIGHT_MASK) = 0 then
1966
31e449e1d9dd nemo's patch + ropes ammo scheme hack
unc0rr
parents: 1753
diff changeset
   244
           if Land[y, x] > 255 then exit(true)
536
33538aadb4e7 - Fix some stupid bugs in collisions detecting code
unc0rr
parents: 521
diff changeset
   245
           else if Land[y, x] <> 0 then flag:= true;
513
69e06d710d46 Moving hedgehog could get another hedgehog moving forward
unc0rr
parents: 511
diff changeset
   246
     inc(y)
69e06d710d46 Moving hedgehog could get another hedgehog moving forward
unc0rr
parents: 511
diff changeset
   247
   until (y > i);
69e06d710d46 Moving hedgehog could get another hedgehog moving forward
unc0rr
parents: 511
diff changeset
   248
   end;
538
74219eadab5e - Various small fixes
unc0rr
parents: 536
diff changeset
   249
TestCollisionXKick:= flag;
513
69e06d710d46 Moving hedgehog could get another hedgehog moving forward
unc0rr
parents: 511
diff changeset
   250
536
33538aadb4e7 - Fix some stupid bugs in collisions detecting code
unc0rr
parents: 521
diff changeset
   251
if flag then
513
69e06d710d46 Moving hedgehog could get another hedgehog moving forward
unc0rr
parents: 511
diff changeset
   252
   begin
538
74219eadab5e - Various small fixes
unc0rr
parents: 536
diff changeset
   253
   if hwAbs(Gear^.dX) < cHHKick then exit;
967
8be3938d73c2 Don't let jumping hedgehog to move others
unc0rr
parents: 906
diff changeset
   254
   if (Gear^.State and gstHHJumping <> 0)
8be3938d73c2 Don't let jumping hedgehog to move others
unc0rr
parents: 906
diff changeset
   255
   and (hwAbs(Gear^.dX) < _0_4) then exit;
8be3938d73c2 Don't let jumping hedgehog to move others
unc0rr
parents: 906
diff changeset
   256
513
69e06d710d46 Moving hedgehog could get another hedgehog moving forward
unc0rr
parents: 511
diff changeset
   257
   mx:= hwRound(Gear^.X);
69e06d710d46 Moving hedgehog could get another hedgehog moving forward
unc0rr
parents: 511
diff changeset
   258
   my:= hwRound(Gear^.Y);
3603
b6b1989744ef Grid the landscape, and shortcircuit checks on the collision array if there are no nearby checked in collisions to be collided with. This is a big win for fire's ammoshove in particular. Also add a +2 that seemed missing in the check, and update fire accordingly.
nemo
parents: 3569
diff changeset
   259
   tr:= Gear^.Radius - 1;
b6b1989744ef Grid the landscape, and shortcircuit checks on the collision array if there are no nearby checked in collisions to be collided with. This is a big win for fire's ammoshove in particular. Also add a +2 that seemed missing in the check, and update fire accordingly.
nemo
parents: 3569
diff changeset
   260
   xP:= (mx + tr) div 32;
b6b1989744ef Grid the landscape, and shortcircuit checks on the collision array if there are no nearby checked in collisions to be collided with. This is a big win for fire's ammoshove in particular. Also add a +2 that seemed missing in the check, and update fire accordingly.
nemo
parents: 3569
diff changeset
   261
   xN:= (mx - tr) div 32;
b6b1989744ef Grid the landscape, and shortcircuit checks on the collision array if there are no nearby checked in collisions to be collided with. This is a big win for fire's ammoshove in particular. Also add a +2 that seemed missing in the check, and update fire accordingly.
nemo
parents: 3569
diff changeset
   262
   yP:= (my + tr) div 32;
b6b1989744ef Grid the landscape, and shortcircuit checks on the collision array if there are no nearby checked in collisions to be collided with. This is a big win for fire's ammoshove in particular. Also add a +2 that seemed missing in the check, and update fire accordingly.
nemo
parents: 3569
diff changeset
   263
   yN:= (my - tr) div 32;
b6b1989744ef Grid the landscape, and shortcircuit checks on the collision array if there are no nearby checked in collisions to be collided with. This is a big win for fire's ammoshove in particular. Also add a +2 that seemed missing in the check, and update fire accordingly.
nemo
parents: 3569
diff changeset
   264
   x0:= mx div 32;
b6b1989744ef Grid the landscape, and shortcircuit checks on the collision array if there are no nearby checked in collisions to be collided with. This is a big win for fire's ammoshove in particular. Also add a +2 that seemed missing in the check, and update fire accordingly.
nemo
parents: 3569
diff changeset
   265
   y0:= my div 32;
513
69e06d710d46 Moving hedgehog could get another hedgehog moving forward
unc0rr
parents: 511
diff changeset
   266
3603
b6b1989744ef Grid the landscape, and shortcircuit checks on the collision array if there are no nearby checked in collisions to be collided with. This is a big win for fire's ammoshove in particular. Also add a +2 that seemed missing in the check, and update fire accordingly.
nemo
parents: 3569
diff changeset
   267
   if (LandCollided[yN, xN] <> 0) or
b6b1989744ef Grid the landscape, and shortcircuit checks on the collision array if there are no nearby checked in collisions to be collided with. This is a big win for fire's ammoshove in particular. Also add a +2 that seemed missing in the check, and update fire accordingly.
nemo
parents: 3569
diff changeset
   268
      (LandCollided[yN, x0] <> 0) or
b6b1989744ef Grid the landscape, and shortcircuit checks on the collision array if there are no nearby checked in collisions to be collided with. This is a big win for fire's ammoshove in particular. Also add a +2 that seemed missing in the check, and update fire accordingly.
nemo
parents: 3569
diff changeset
   269
      (LandCollided[yN, xP] <> 0) or
b6b1989744ef Grid the landscape, and shortcircuit checks on the collision array if there are no nearby checked in collisions to be collided with. This is a big win for fire's ammoshove in particular. Also add a +2 that seemed missing in the check, and update fire accordingly.
nemo
parents: 3569
diff changeset
   270
      (LandCollided[y0, xN] <> 0) or
b6b1989744ef Grid the landscape, and shortcircuit checks on the collision array if there are no nearby checked in collisions to be collided with. This is a big win for fire's ammoshove in particular. Also add a +2 that seemed missing in the check, and update fire accordingly.
nemo
parents: 3569
diff changeset
   271
      (LandCollided[y0, x0] <> 0) or
b6b1989744ef Grid the landscape, and shortcircuit checks on the collision array if there are no nearby checked in collisions to be collided with. This is a big win for fire's ammoshove in particular. Also add a +2 that seemed missing in the check, and update fire accordingly.
nemo
parents: 3569
diff changeset
   272
      (LandCollided[y0, xP] <> 0) or
b6b1989744ef Grid the landscape, and shortcircuit checks on the collision array if there are no nearby checked in collisions to be collided with. This is a big win for fire's ammoshove in particular. Also add a +2 that seemed missing in the check, and update fire accordingly.
nemo
parents: 3569
diff changeset
   273
      (LandCollided[yP, xN] <> 0) or
b6b1989744ef Grid the landscape, and shortcircuit checks on the collision array if there are no nearby checked in collisions to be collided with. This is a big win for fire's ammoshove in particular. Also add a +2 that seemed missing in the check, and update fire accordingly.
nemo
parents: 3569
diff changeset
   274
      (LandCollided[yP, x0] <> 0) or
b6b1989744ef Grid the landscape, and shortcircuit checks on the collision array if there are no nearby checked in collisions to be collided with. This is a big win for fire's ammoshove in particular. Also add a +2 that seemed missing in the check, and update fire accordingly.
nemo
parents: 3569
diff changeset
   275
      (LandCollided[yP, xP] <> 0) then 
b6b1989744ef Grid the landscape, and shortcircuit checks on the collision array if there are no nearby checked in collisions to be collided with. This is a big win for fire's ammoshove in particular. Also add a +2 that seemed missing in the check, and update fire accordingly.
nemo
parents: 3569
diff changeset
   276
      for i:= 0 to Pred(Count) do
b6b1989744ef Grid the landscape, and shortcircuit checks on the collision array if there are no nearby checked in collisions to be collided with. This is a big win for fire's ammoshove in particular. Also add a +2 that seemed missing in the check, and update fire accordingly.
nemo
parents: 3569
diff changeset
   277
       with cinfos[i] do
b6b1989744ef Grid the landscape, and shortcircuit checks on the collision array if there are no nearby checked in collisions to be collided with. This is a big win for fire's ammoshove in particular. Also add a +2 that seemed missing in the check, and update fire accordingly.
nemo
parents: 3569
diff changeset
   278
         if (Gear <> cGear) and
b6b1989744ef Grid the landscape, and shortcircuit checks on the collision array if there are no nearby checked in collisions to be collided with. This is a big win for fire's ammoshove in particular. Also add a +2 that seemed missing in the check, and update fire accordingly.
nemo
parents: 3569
diff changeset
   279
            (sqr(mx - x) + sqr(my - y) <= sqr(Radius + Gear^.Radius + 2)) and
b6b1989744ef Grid the landscape, and shortcircuit checks on the collision array if there are no nearby checked in collisions to be collided with. This is a big win for fire's ammoshove in particular. Also add a +2 that seemed missing in the check, and update fire accordingly.
nemo
parents: 3569
diff changeset
   280
            ((mx > x) xor (Dir > 0)) then
b6b1989744ef Grid the landscape, and shortcircuit checks on the collision array if there are no nearby checked in collisions to be collided with. This is a big win for fire's ammoshove in particular. Also add a +2 that seemed missing in the check, and update fire accordingly.
nemo
parents: 3569
diff changeset
   281
            if ((cGear^.Kind in [gtHedgehog, gtMine]) and ((Gear^.State and gstNotKickable) = 0)) or
b6b1989744ef Grid the landscape, and shortcircuit checks on the collision array if there are no nearby checked in collisions to be collided with. This is a big win for fire's ammoshove in particular. Also add a +2 that seemed missing in the check, and update fire accordingly.
nemo
parents: 3569
diff changeset
   282
               // only apply X kick if the barrel is knocked over
b6b1989744ef Grid the landscape, and shortcircuit checks on the collision array if there are no nearby checked in collisions to be collided with. This is a big win for fire's ammoshove in particular. Also add a +2 that seemed missing in the check, and update fire accordingly.
nemo
parents: 3569
diff changeset
   283
               ((cGear^.Kind = gtExplosives) and ((cGear^.State and gsttmpflag) <> 0)) then
b6b1989744ef Grid the landscape, and shortcircuit checks on the collision array if there are no nearby checked in collisions to be collided with. This is a big win for fire's ammoshove in particular. Also add a +2 that seemed missing in the check, and update fire accordingly.
nemo
parents: 3569
diff changeset
   284
                begin
b6b1989744ef Grid the landscape, and shortcircuit checks on the collision array if there are no nearby checked in collisions to be collided with. This is a big win for fire's ammoshove in particular. Also add a +2 that seemed missing in the check, and update fire accordingly.
nemo
parents: 3569
diff changeset
   285
                with cGear^ do
b6b1989744ef Grid the landscape, and shortcircuit checks on the collision array if there are no nearby checked in collisions to be collided with. This is a big win for fire's ammoshove in particular. Also add a +2 that seemed missing in the check, and update fire accordingly.
nemo
parents: 3569
diff changeset
   286
                     begin
b6b1989744ef Grid the landscape, and shortcircuit checks on the collision array if there are no nearby checked in collisions to be collided with. This is a big win for fire's ammoshove in particular. Also add a +2 that seemed missing in the check, and update fire accordingly.
nemo
parents: 3569
diff changeset
   287
                     dX:= Gear^.dX;
b6b1989744ef Grid the landscape, and shortcircuit checks on the collision array if there are no nearby checked in collisions to be collided with. This is a big win for fire's ammoshove in particular. Also add a +2 that seemed missing in the check, and update fire accordingly.
nemo
parents: 3569
diff changeset
   288
                     dY:= Gear^.dY * _0_5;
b6b1989744ef Grid the landscape, and shortcircuit checks on the collision array if there are no nearby checked in collisions to be collided with. This is a big win for fire's ammoshove in particular. Also add a +2 that seemed missing in the check, and update fire accordingly.
nemo
parents: 3569
diff changeset
   289
                     State:= State or gstMoving;
b6b1989744ef Grid the landscape, and shortcircuit checks on the collision array if there are no nearby checked in collisions to be collided with. This is a big win for fire's ammoshove in particular. Also add a +2 that seemed missing in the check, and update fire accordingly.
nemo
parents: 3569
diff changeset
   290
                     Active:= true
b6b1989744ef Grid the landscape, and shortcircuit checks on the collision array if there are no nearby checked in collisions to be collided with. This is a big win for fire's ammoshove in particular. Also add a +2 that seemed missing in the check, and update fire accordingly.
nemo
parents: 3569
diff changeset
   291
                     end;
b6b1989744ef Grid the landscape, and shortcircuit checks on the collision array if there are no nearby checked in collisions to be collided with. This is a big win for fire's ammoshove in particular. Also add a +2 that seemed missing in the check, and update fire accordingly.
nemo
parents: 3569
diff changeset
   292
                DeleteCI(cGear);
b6b1989744ef Grid the landscape, and shortcircuit checks on the collision array if there are no nearby checked in collisions to be collided with. This is a big win for fire's ammoshove in particular. Also add a +2 that seemed missing in the check, and update fire accordingly.
nemo
parents: 3569
diff changeset
   293
                exit(false)
b6b1989744ef Grid the landscape, and shortcircuit checks on the collision array if there are no nearby checked in collisions to be collided with. This is a big win for fire's ammoshove in particular. Also add a +2 that seemed missing in the check, and update fire accordingly.
nemo
parents: 3569
diff changeset
   294
                end
b6b1989744ef Grid the landscape, and shortcircuit checks on the collision array if there are no nearby checked in collisions to be collided with. This is a big win for fire's ammoshove in particular. Also add a +2 that seemed missing in the check, and update fire accordingly.
nemo
parents: 3569
diff changeset
   295
      end
513
69e06d710d46 Moving hedgehog could get another hedgehog moving forward
unc0rr
parents: 511
diff changeset
   296
end;
69e06d710d46 Moving hedgehog could get another hedgehog moving forward
unc0rr
parents: 511
diff changeset
   297
69e06d710d46 Moving hedgehog could get another hedgehog moving forward
unc0rr
parents: 511
diff changeset
   298
function TestCollisionYKick(Gear: PGear; Dir: LongInt): boolean;
3603
b6b1989744ef Grid the landscape, and shortcircuit checks on the collision array if there are no nearby checked in collisions to be collided with. This is a big win for fire's ammoshove in particular. Also add a +2 that seemed missing in the check, and update fire accordingly.
nemo
parents: 3569
diff changeset
   299
var x, y, mx, my, i, xP, xN, x0, yP, yN, y0, tr: LongInt;
513
69e06d710d46 Moving hedgehog could get another hedgehog moving forward
unc0rr
parents: 511
diff changeset
   300
    flag: boolean;
69e06d710d46 Moving hedgehog could get another hedgehog moving forward
unc0rr
parents: 511
diff changeset
   301
begin
69e06d710d46 Moving hedgehog could get another hedgehog moving forward
unc0rr
parents: 511
diff changeset
   302
flag:= false;
69e06d710d46 Moving hedgehog could get another hedgehog moving forward
unc0rr
parents: 511
diff changeset
   303
y:= hwRound(Gear^.Y);
69e06d710d46 Moving hedgehog could get another hedgehog moving forward
unc0rr
parents: 511
diff changeset
   304
if Dir < 0 then y:= y - Gear^.Radius
69e06d710d46 Moving hedgehog could get another hedgehog moving forward
unc0rr
parents: 511
diff changeset
   305
           else y:= y + Gear^.Radius;
1753
2ccba26f1aa4 Apply nemo's world resize patch
unc0rr
parents: 1528
diff changeset
   306
if (y and LAND_HEIGHT_MASK) = 0 then
513
69e06d710d46 Moving hedgehog could get another hedgehog moving forward
unc0rr
parents: 511
diff changeset
   307
   begin
69e06d710d46 Moving hedgehog could get another hedgehog moving forward
unc0rr
parents: 511
diff changeset
   308
   x:= hwRound(Gear^.X) - Gear^.Radius + 1;
69e06d710d46 Moving hedgehog could get another hedgehog moving forward
unc0rr
parents: 511
diff changeset
   309
   i:= x + Gear^.Radius * 2 - 2;
69e06d710d46 Moving hedgehog could get another hedgehog moving forward
unc0rr
parents: 511
diff changeset
   310
   repeat
1753
2ccba26f1aa4 Apply nemo's world resize patch
unc0rr
parents: 1528
diff changeset
   311
     if (x and LAND_WIDTH_MASK) = 0 then
513
69e06d710d46 Moving hedgehog could get another hedgehog moving forward
unc0rr
parents: 511
diff changeset
   312
        if Land[y, x] > 0 then
1966
31e449e1d9dd nemo's patch + ropes ammo scheme hack
unc0rr
parents: 1753
diff changeset
   313
           if Land[y, x] > 255 then exit(true)
536
33538aadb4e7 - Fix some stupid bugs in collisions detecting code
unc0rr
parents: 521
diff changeset
   314
           else if Land[y, x] <> 0 then flag:= true;
513
69e06d710d46 Moving hedgehog could get another hedgehog moving forward
unc0rr
parents: 511
diff changeset
   315
     inc(x)
69e06d710d46 Moving hedgehog could get another hedgehog moving forward
unc0rr
parents: 511
diff changeset
   316
   until (x > i);
69e06d710d46 Moving hedgehog could get another hedgehog moving forward
unc0rr
parents: 511
diff changeset
   317
   end;
538
74219eadab5e - Various small fixes
unc0rr
parents: 536
diff changeset
   318
TestCollisionYKick:= flag;
513
69e06d710d46 Moving hedgehog could get another hedgehog moving forward
unc0rr
parents: 511
diff changeset
   319
536
33538aadb4e7 - Fix some stupid bugs in collisions detecting code
unc0rr
parents: 521
diff changeset
   320
if flag then
513
69e06d710d46 Moving hedgehog could get another hedgehog moving forward
unc0rr
parents: 511
diff changeset
   321
   begin
839
1493f697d1bb Fix broken logic for the new parachute feature
unc0rr
parents: 838
diff changeset
   322
   if hwAbs(Gear^.dY) < cHHKick then exit(true);
967
8be3938d73c2 Don't let jumping hedgehog to move others
unc0rr
parents: 906
diff changeset
   323
   if (Gear^.State and gstHHJumping <> 0)
8be3938d73c2 Don't let jumping hedgehog to move others
unc0rr
parents: 906
diff changeset
   324
   and (not Gear^.dY.isNegative)
8be3938d73c2 Don't let jumping hedgehog to move others
unc0rr
parents: 906
diff changeset
   325
   and (Gear^.dY < _0_4) then exit;
8be3938d73c2 Don't let jumping hedgehog to move others
unc0rr
parents: 906
diff changeset
   326
513
69e06d710d46 Moving hedgehog could get another hedgehog moving forward
unc0rr
parents: 511
diff changeset
   327
   mx:= hwRound(Gear^.X);
69e06d710d46 Moving hedgehog could get another hedgehog moving forward
unc0rr
parents: 511
diff changeset
   328
   my:= hwRound(Gear^.Y);
3603
b6b1989744ef Grid the landscape, and shortcircuit checks on the collision array if there are no nearby checked in collisions to be collided with. This is a big win for fire's ammoshove in particular. Also add a +2 that seemed missing in the check, and update fire accordingly.
nemo
parents: 3569
diff changeset
   329
   tr:= Gear^.Radius - 1;
b6b1989744ef Grid the landscape, and shortcircuit checks on the collision array if there are no nearby checked in collisions to be collided with. This is a big win for fire's ammoshove in particular. Also add a +2 that seemed missing in the check, and update fire accordingly.
nemo
parents: 3569
diff changeset
   330
   xP:= (mx + tr) div 32;
b6b1989744ef Grid the landscape, and shortcircuit checks on the collision array if there are no nearby checked in collisions to be collided with. This is a big win for fire's ammoshove in particular. Also add a +2 that seemed missing in the check, and update fire accordingly.
nemo
parents: 3569
diff changeset
   331
   xN:= (mx - tr) div 32;
b6b1989744ef Grid the landscape, and shortcircuit checks on the collision array if there are no nearby checked in collisions to be collided with. This is a big win for fire's ammoshove in particular. Also add a +2 that seemed missing in the check, and update fire accordingly.
nemo
parents: 3569
diff changeset
   332
   yP:= (my + tr) div 32;
b6b1989744ef Grid the landscape, and shortcircuit checks on the collision array if there are no nearby checked in collisions to be collided with. This is a big win for fire's ammoshove in particular. Also add a +2 that seemed missing in the check, and update fire accordingly.
nemo
parents: 3569
diff changeset
   333
   yN:= (my - tr) div 32;
b6b1989744ef Grid the landscape, and shortcircuit checks on the collision array if there are no nearby checked in collisions to be collided with. This is a big win for fire's ammoshove in particular. Also add a +2 that seemed missing in the check, and update fire accordingly.
nemo
parents: 3569
diff changeset
   334
   x0:= mx div 32;
b6b1989744ef Grid the landscape, and shortcircuit checks on the collision array if there are no nearby checked in collisions to be collided with. This is a big win for fire's ammoshove in particular. Also add a +2 that seemed missing in the check, and update fire accordingly.
nemo
parents: 3569
diff changeset
   335
   y0:= my div 32;
513
69e06d710d46 Moving hedgehog could get another hedgehog moving forward
unc0rr
parents: 511
diff changeset
   336
3603
b6b1989744ef Grid the landscape, and shortcircuit checks on the collision array if there are no nearby checked in collisions to be collided with. This is a big win for fire's ammoshove in particular. Also add a +2 that seemed missing in the check, and update fire accordingly.
nemo
parents: 3569
diff changeset
   337
   if (LandCollided[yN, xN] <> 0) or
b6b1989744ef Grid the landscape, and shortcircuit checks on the collision array if there are no nearby checked in collisions to be collided with. This is a big win for fire's ammoshove in particular. Also add a +2 that seemed missing in the check, and update fire accordingly.
nemo
parents: 3569
diff changeset
   338
      (LandCollided[yN, x0] <> 0) or
b6b1989744ef Grid the landscape, and shortcircuit checks on the collision array if there are no nearby checked in collisions to be collided with. This is a big win for fire's ammoshove in particular. Also add a +2 that seemed missing in the check, and update fire accordingly.
nemo
parents: 3569
diff changeset
   339
      (LandCollided[yN, xP] <> 0) or
b6b1989744ef Grid the landscape, and shortcircuit checks on the collision array if there are no nearby checked in collisions to be collided with. This is a big win for fire's ammoshove in particular. Also add a +2 that seemed missing in the check, and update fire accordingly.
nemo
parents: 3569
diff changeset
   340
      (LandCollided[y0, xN] <> 0) or
b6b1989744ef Grid the landscape, and shortcircuit checks on the collision array if there are no nearby checked in collisions to be collided with. This is a big win for fire's ammoshove in particular. Also add a +2 that seemed missing in the check, and update fire accordingly.
nemo
parents: 3569
diff changeset
   341
      (LandCollided[y0, x0] <> 0) or
b6b1989744ef Grid the landscape, and shortcircuit checks on the collision array if there are no nearby checked in collisions to be collided with. This is a big win for fire's ammoshove in particular. Also add a +2 that seemed missing in the check, and update fire accordingly.
nemo
parents: 3569
diff changeset
   342
      (LandCollided[y0, xP] <> 0) or
b6b1989744ef Grid the landscape, and shortcircuit checks on the collision array if there are no nearby checked in collisions to be collided with. This is a big win for fire's ammoshove in particular. Also add a +2 that seemed missing in the check, and update fire accordingly.
nemo
parents: 3569
diff changeset
   343
      (LandCollided[yP, xN] <> 0) or
b6b1989744ef Grid the landscape, and shortcircuit checks on the collision array if there are no nearby checked in collisions to be collided with. This is a big win for fire's ammoshove in particular. Also add a +2 that seemed missing in the check, and update fire accordingly.
nemo
parents: 3569
diff changeset
   344
      (LandCollided[yP, x0] <> 0) or
b6b1989744ef Grid the landscape, and shortcircuit checks on the collision array if there are no nearby checked in collisions to be collided with. This is a big win for fire's ammoshove in particular. Also add a +2 that seemed missing in the check, and update fire accordingly.
nemo
parents: 3569
diff changeset
   345
      (LandCollided[yP, xP] <> 0) then 
b6b1989744ef Grid the landscape, and shortcircuit checks on the collision array if there are no nearby checked in collisions to be collided with. This is a big win for fire's ammoshove in particular. Also add a +2 that seemed missing in the check, and update fire accordingly.
nemo
parents: 3569
diff changeset
   346
      for i:= 0 to Pred(Count) do
b6b1989744ef Grid the landscape, and shortcircuit checks on the collision array if there are no nearby checked in collisions to be collided with. This is a big win for fire's ammoshove in particular. Also add a +2 that seemed missing in the check, and update fire accordingly.
nemo
parents: 3569
diff changeset
   347
       with cinfos[i] do
b6b1989744ef Grid the landscape, and shortcircuit checks on the collision array if there are no nearby checked in collisions to be collided with. This is a big win for fire's ammoshove in particular. Also add a +2 that seemed missing in the check, and update fire accordingly.
nemo
parents: 3569
diff changeset
   348
         if (Gear <> cGear) and
b6b1989744ef Grid the landscape, and shortcircuit checks on the collision array if there are no nearby checked in collisions to be collided with. This is a big win for fire's ammoshove in particular. Also add a +2 that seemed missing in the check, and update fire accordingly.
nemo
parents: 3569
diff changeset
   349
            (sqr(mx - x) + sqr(my - y) <= sqr(Radius + Gear^.Radius + 2)) and
b6b1989744ef Grid the landscape, and shortcircuit checks on the collision array if there are no nearby checked in collisions to be collided with. This is a big win for fire's ammoshove in particular. Also add a +2 that seemed missing in the check, and update fire accordingly.
nemo
parents: 3569
diff changeset
   350
            ((my > y) xor (Dir > 0)) then
b6b1989744ef Grid the landscape, and shortcircuit checks on the collision array if there are no nearby checked in collisions to be collided with. This is a big win for fire's ammoshove in particular. Also add a +2 that seemed missing in the check, and update fire accordingly.
nemo
parents: 3569
diff changeset
   351
            if (cGear^.Kind in [gtHedgehog, gtMine, gtExplosives]) and ((Gear^.State and gstNotKickable) = 0) then
b6b1989744ef Grid the landscape, and shortcircuit checks on the collision array if there are no nearby checked in collisions to be collided with. This is a big win for fire's ammoshove in particular. Also add a +2 that seemed missing in the check, and update fire accordingly.
nemo
parents: 3569
diff changeset
   352
                begin
b6b1989744ef Grid the landscape, and shortcircuit checks on the collision array if there are no nearby checked in collisions to be collided with. This is a big win for fire's ammoshove in particular. Also add a +2 that seemed missing in the check, and update fire accordingly.
nemo
parents: 3569
diff changeset
   353
                with cGear^ do
b6b1989744ef Grid the landscape, and shortcircuit checks on the collision array if there are no nearby checked in collisions to be collided with. This is a big win for fire's ammoshove in particular. Also add a +2 that seemed missing in the check, and update fire accordingly.
nemo
parents: 3569
diff changeset
   354
                     begin
b6b1989744ef Grid the landscape, and shortcircuit checks on the collision array if there are no nearby checked in collisions to be collided with. This is a big win for fire's ammoshove in particular. Also add a +2 that seemed missing in the check, and update fire accordingly.
nemo
parents: 3569
diff changeset
   355
                     if (Kind <> gtExplosives) or ((State and gsttmpflag) <> 0) then dX:= Gear^.dX * _0_5;
b6b1989744ef Grid the landscape, and shortcircuit checks on the collision array if there are no nearby checked in collisions to be collided with. This is a big win for fire's ammoshove in particular. Also add a +2 that seemed missing in the check, and update fire accordingly.
nemo
parents: 3569
diff changeset
   356
                     dY:= Gear^.dY;
b6b1989744ef Grid the landscape, and shortcircuit checks on the collision array if there are no nearby checked in collisions to be collided with. This is a big win for fire's ammoshove in particular. Also add a +2 that seemed missing in the check, and update fire accordingly.
nemo
parents: 3569
diff changeset
   357
                     State:= State or gstMoving;
b6b1989744ef Grid the landscape, and shortcircuit checks on the collision array if there are no nearby checked in collisions to be collided with. This is a big win for fire's ammoshove in particular. Also add a +2 that seemed missing in the check, and update fire accordingly.
nemo
parents: 3569
diff changeset
   358
                     Active:= true
b6b1989744ef Grid the landscape, and shortcircuit checks on the collision array if there are no nearby checked in collisions to be collided with. This is a big win for fire's ammoshove in particular. Also add a +2 that seemed missing in the check, and update fire accordingly.
nemo
parents: 3569
diff changeset
   359
                     end;
b6b1989744ef Grid the landscape, and shortcircuit checks on the collision array if there are no nearby checked in collisions to be collided with. This is a big win for fire's ammoshove in particular. Also add a +2 that seemed missing in the check, and update fire accordingly.
nemo
parents: 3569
diff changeset
   360
                DeleteCI(cGear);
b6b1989744ef Grid the landscape, and shortcircuit checks on the collision array if there are no nearby checked in collisions to be collided with. This is a big win for fire's ammoshove in particular. Also add a +2 that seemed missing in the check, and update fire accordingly.
nemo
parents: 3569
diff changeset
   361
                exit(false)
b6b1989744ef Grid the landscape, and shortcircuit checks on the collision array if there are no nearby checked in collisions to be collided with. This is a big win for fire's ammoshove in particular. Also add a +2 that seemed missing in the check, and update fire accordingly.
nemo
parents: 3569
diff changeset
   362
                end
b6b1989744ef Grid the landscape, and shortcircuit checks on the collision array if there are no nearby checked in collisions to be collided with. This is a big win for fire's ammoshove in particular. Also add a +2 that seemed missing in the check, and update fire accordingly.
nemo
parents: 3569
diff changeset
   363
      end
513
69e06d710d46 Moving hedgehog could get another hedgehog moving forward
unc0rr
parents: 511
diff changeset
   364
end;
69e06d710d46 Moving hedgehog could get another hedgehog moving forward
unc0rr
parents: 511
diff changeset
   365
498
9c8b385dc9a1 - Get rid of operator := to have GPC support
unc0rr
parents: 393
diff changeset
   366
function TestCollisionXwithXYShift(Gear: PGear; ShiftX: hwFloat; ShiftY: LongInt; Dir: LongInt): boolean;
4
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
   367
begin
351
29bc9c36ad5f Fixed-point arithmetics in engine.
unc0rr
parents: 183
diff changeset
   368
Gear^.X:= Gear^.X + ShiftX;
498
9c8b385dc9a1 - Get rid of operator := to have GPC support
unc0rr
parents: 393
diff changeset
   369
Gear^.Y:= Gear^.Y + int2hwFloat(ShiftY);
351
29bc9c36ad5f Fixed-point arithmetics in engine.
unc0rr
parents: 183
diff changeset
   370
TestCollisionXwithXYShift:= TestCollisionXwithGear(Gear, Dir);
29bc9c36ad5f Fixed-point arithmetics in engine.
unc0rr
parents: 183
diff changeset
   371
Gear^.X:= Gear^.X - ShiftX;
498
9c8b385dc9a1 - Get rid of operator := to have GPC support
unc0rr
parents: 393
diff changeset
   372
Gear^.Y:= Gear^.Y - int2hwFloat(ShiftY)
4
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
   373
end;
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
   374
371
731ad6d27bd1 integer -> LongInt
unc0rr
parents: 351
diff changeset
   375
function TestCollisionY(Gear: PGear; Dir: LongInt): boolean;
731ad6d27bd1 integer -> LongInt
unc0rr
parents: 351
diff changeset
   376
var x, y, i: LongInt;
68
cbb93eb90304 Collision-related stuff
unc0rr
parents: 64
diff changeset
   377
begin
351
29bc9c36ad5f Fixed-point arithmetics in engine.
unc0rr
parents: 183
diff changeset
   378
y:= hwRound(Gear^.Y);
29bc9c36ad5f Fixed-point arithmetics in engine.
unc0rr
parents: 183
diff changeset
   379
if Dir < 0 then y:= y - Gear^.Radius
29bc9c36ad5f Fixed-point arithmetics in engine.
unc0rr
parents: 183
diff changeset
   380
           else y:= y + Gear^.Radius;
1753
2ccba26f1aa4 Apply nemo's world resize patch
unc0rr
parents: 1528
diff changeset
   381
if (y and LAND_HEIGHT_MASK) = 0 then
68
cbb93eb90304 Collision-related stuff
unc0rr
parents: 64
diff changeset
   382
   begin
351
29bc9c36ad5f Fixed-point arithmetics in engine.
unc0rr
parents: 183
diff changeset
   383
   x:= hwRound(Gear^.X) - Gear^.Radius + 1;
29bc9c36ad5f Fixed-point arithmetics in engine.
unc0rr
parents: 183
diff changeset
   384
   i:= x + Gear^.Radius * 2 - 2;
68
cbb93eb90304 Collision-related stuff
unc0rr
parents: 64
diff changeset
   385
   repeat
1753
2ccba26f1aa4 Apply nemo's world resize patch
unc0rr
parents: 1528
diff changeset
   386
     if (x and LAND_WIDTH_MASK) = 0 then
1966
31e449e1d9dd nemo's patch + ropes ammo scheme hack
unc0rr
parents: 1753
diff changeset
   387
        if Land[y, x] > 255 then exit(true);
68
cbb93eb90304 Collision-related stuff
unc0rr
parents: 64
diff changeset
   388
     inc(x)
351
29bc9c36ad5f Fixed-point arithmetics in engine.
unc0rr
parents: 183
diff changeset
   389
   until (x > i);
29bc9c36ad5f Fixed-point arithmetics in engine.
unc0rr
parents: 183
diff changeset
   390
   end;
29bc9c36ad5f Fixed-point arithmetics in engine.
unc0rr
parents: 183
diff changeset
   391
TestCollisionY:= false
68
cbb93eb90304 Collision-related stuff
unc0rr
parents: 64
diff changeset
   392
end;
cbb93eb90304 Collision-related stuff
unc0rr
parents: 64
diff changeset
   393
371
731ad6d27bd1 integer -> LongInt
unc0rr
parents: 351
diff changeset
   394
function TestCollisionYwithXYShift(Gear: PGear; ShiftX, ShiftY: LongInt; Dir: LongInt): boolean;
4
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
   395
begin
498
9c8b385dc9a1 - Get rid of operator := to have GPC support
unc0rr
parents: 393
diff changeset
   396
Gear^.X:= Gear^.X + int2hwFloat(ShiftX);
9c8b385dc9a1 - Get rid of operator := to have GPC support
unc0rr
parents: 393
diff changeset
   397
Gear^.Y:= Gear^.Y + int2hwFloat(ShiftY);
351
29bc9c36ad5f Fixed-point arithmetics in engine.
unc0rr
parents: 183
diff changeset
   398
TestCollisionYwithXYShift:= TestCollisionYwithGear(Gear, Dir);
498
9c8b385dc9a1 - Get rid of operator := to have GPC support
unc0rr
parents: 393
diff changeset
   399
Gear^.X:= Gear^.X - int2hwFloat(ShiftX);
9c8b385dc9a1 - Get rid of operator := to have GPC support
unc0rr
parents: 393
diff changeset
   400
Gear^.Y:= Gear^.Y - int2hwFloat(ShiftY)
4
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
   401
end;
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
   402
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
   403
3414
b2f3bb44777e some portal changes, warning: no loop prevention yet, note: entry angle not preserved yet
sheepluva
parents: 3411
diff changeset
   404
function calcSlopeTangent(Gear: PGear; collisionX, collisionY: LongInt; var outDeltaX, outDeltaY: LongInt; TestWord: LongWord): boolean;
3408
56e636b83cb4 tweak land angle detection/portal a bit
sheepluva
parents: 3407
diff changeset
   405
var ldx, ldy, rdx, rdy: LongInt;
56e636b83cb4 tweak land angle detection/portal a bit
sheepluva
parents: 3407
diff changeset
   406
    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
   407
    tmpx, tmpy: LongWord;
3569
27b0ec683572 portal / slope detection:
sheepluva
parents: 3474
diff changeset
   408
    dx, dy, s: hwFloat;
3408
56e636b83cb4 tweak land angle detection/portal a bit
sheepluva
parents: 3407
diff changeset
   409
    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
   410
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
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
   412
    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
   413
    dy:= Gear^.dY;
3408
56e636b83cb4 tweak land angle detection/portal a bit
sheepluva
parents: 3407
diff changeset
   414
3569
27b0ec683572 portal / slope detection:
sheepluva
parents: 3474
diff changeset
   415
    // we start searching from the direction the gear came from
27b0ec683572 portal / slope detection:
sheepluva
parents: 3474
diff changeset
   416
    if (dx.QWordValue > _0_995.QWordValue )
27b0ec683572 portal / slope detection:
sheepluva
parents: 3474
diff changeset
   417
    or (dy.QWordValue > _0_995.QWordValue ) then
27b0ec683572 portal / slope detection:
sheepluva
parents: 3474
diff changeset
   418
        begin // scale
27b0ec683572 portal / slope detection:
sheepluva
parents: 3474
diff changeset
   419
        s := _1 / Distance(dx,dy);
27b0ec683572 portal / slope detection:
sheepluva
parents: 3474
diff changeset
   420
        dx := s * dx;
27b0ec683572 portal / slope detection:
sheepluva
parents: 3474
diff changeset
   421
        dy := s * dy;
27b0ec683572 portal / slope detection:
sheepluva
parents: 3474
diff changeset
   422
        end;
27b0ec683572 portal / slope detection:
sheepluva
parents: 3474
diff changeset
   423
3408
56e636b83cb4 tweak land angle detection/portal a bit
sheepluva
parents: 3407
diff changeset
   424
    mx:= hwRound(Gear^.X-dx) - hwRound(Gear^.X);
56e636b83cb4 tweak land angle detection/portal a bit
sheepluva
parents: 3407
diff changeset
   425
    my:= hwRound(Gear^.Y-dy) - hwRound(Gear^.Y);
56e636b83cb4 tweak land angle detection/portal a bit
sheepluva
parents: 3407
diff changeset
   426
56e636b83cb4 tweak land angle detection/portal a bit
sheepluva
parents: 3407
diff changeset
   427
    li:= -1;
56e636b83cb4 tweak land angle detection/portal a bit
sheepluva
parents: 3407
diff changeset
   428
    ri:= -1;
3569
27b0ec683572 portal / slope detection:
sheepluva
parents: 3474
diff changeset
   429
3408
56e636b83cb4 tweak land angle detection/portal a bit
sheepluva
parents: 3407
diff changeset
   430
    // go around collision pixel, checking for first/last collisions
56e636b83cb4 tweak land angle detection/portal a bit
sheepluva
parents: 3407
diff changeset
   431
    // this will determinate what angles will be tried to crawl along
56e636b83cb4 tweak land angle detection/portal a bit
sheepluva
parents: 3407
diff changeset
   432
    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
   433
        begin
3408
56e636b83cb4 tweak land angle detection/portal a bit
sheepluva
parents: 3407
diff changeset
   434
        offset[i,0]:= mx;
56e636b83cb4 tweak land angle detection/portal a bit
sheepluva
parents: 3407
diff changeset
   435
        offset[i,1]:= my;
3569
27b0ec683572 portal / slope detection:
sheepluva
parents: 3474
diff changeset
   436
3408
56e636b83cb4 tweak land angle detection/portal a bit
sheepluva
parents: 3407
diff changeset
   437
        tmpx:= collisionX + mx;
56e636b83cb4 tweak land angle detection/portal a bit
sheepluva
parents: 3407
diff changeset
   438
        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
   439
3569
27b0ec683572 portal / slope detection:
sheepluva
parents: 3474
diff changeset
   440
        if (((tmpy) and LAND_HEIGHT_MASK) = 0) and (((tmpx) and LAND_WIDTH_MASK) = 0) then
3408
56e636b83cb4 tweak land angle detection/portal a bit
sheepluva
parents: 3407
diff changeset
   441
            if (Land[tmpy,tmpx] > TestWord) then
56e636b83cb4 tweak land angle detection/portal a bit
sheepluva
parents: 3407
diff changeset
   442
                begin
56e636b83cb4 tweak land angle detection/portal a bit
sheepluva
parents: 3407
diff changeset
   443
                // remember the index belonging to the first and last collision (if in 1st half)
56e636b83cb4 tweak land angle detection/portal a bit
sheepluva
parents: 3407
diff changeset
   444
                if (i <> 0) then
56e636b83cb4 tweak land angle detection/portal a bit
sheepluva
parents: 3407
diff changeset
   445
                    begin
56e636b83cb4 tweak land angle detection/portal a bit
sheepluva
parents: 3407
diff changeset
   446
                    if (ri = -1) then
56e636b83cb4 tweak land angle detection/portal a bit
sheepluva
parents: 3407
diff changeset
   447
                        ri:= i
56e636b83cb4 tweak land angle detection/portal a bit
sheepluva
parents: 3407
diff changeset
   448
                    else
56e636b83cb4 tweak land angle detection/portal a bit
sheepluva
parents: 3407
diff changeset
   449
                        li:= i;
56e636b83cb4 tweak land angle detection/portal a bit
sheepluva
parents: 3407
diff changeset
   450
                    end;
56e636b83cb4 tweak land angle detection/portal a bit
sheepluva
parents: 3407
diff changeset
   451
                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
   452
3408
56e636b83cb4 tweak land angle detection/portal a bit
sheepluva
parents: 3407
diff changeset
   453
        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
   454
3408
56e636b83cb4 tweak land angle detection/portal a bit
sheepluva
parents: 3407
diff changeset
   455
        // 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
   456
        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
   457
        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
   458
        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
   459
        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
   460
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
   461
        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
   462
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
   463
    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
   464
    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
   465
    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
   466
    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
   467
3408
56e636b83cb4 tweak land angle detection/portal a bit
sheepluva
parents: 3407
diff changeset
   468
    // edge-crawl
56e636b83cb4 tweak land angle detection/portal a bit
sheepluva
parents: 3407
diff changeset
   469
    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
   470
        begin
3408
56e636b83cb4 tweak land angle detection/portal a bit
sheepluva
parents: 3407
diff changeset
   471
        // using mx,my as temporary value buffer here
56e636b83cb4 tweak land angle detection/portal a bit
sheepluva
parents: 3407
diff changeset
   472
        
56e636b83cb4 tweak land angle detection/portal a bit
sheepluva
parents: 3407
diff changeset
   473
        jfr:= 8+li+1;
56e636b83cb4 tweak land angle detection/portal a bit
sheepluva
parents: 3407
diff changeset
   474
        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
   475
3408
56e636b83cb4 tweak land angle detection/portal a bit
sheepluva
parents: 3407
diff changeset
   476
        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
   477
            begin
3408
56e636b83cb4 tweak land angle detection/portal a bit
sheepluva
parents: 3407
diff changeset
   478
            tmpo:= j mod 8;
56e636b83cb4 tweak land angle detection/portal a bit
sheepluva
parents: 3407
diff changeset
   479
            tmpx:= ldx + offset[tmpo,0];
56e636b83cb4 tweak land angle detection/portal a bit
sheepluva
parents: 3407
diff changeset
   480
            tmpy:= ldy + offset[tmpo,1];
56e636b83cb4 tweak land angle detection/portal a bit
sheepluva
parents: 3407
diff changeset
   481
            if (((tmpy) and LAND_HEIGHT_MASK) = 0) and (((tmpx) and LAND_WIDTH_MASK)  = 0)
56e636b83cb4 tweak land angle detection/portal a bit
sheepluva
parents: 3407
diff changeset
   482
                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
   483
                    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
   484
                    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
   485
                    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
   486
                    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
   487
                    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
   488
            end;
3408
56e636b83cb4 tweak land angle detection/portal a bit
sheepluva
parents: 3407
diff changeset
   489
56e636b83cb4 tweak land angle detection/portal a bit
sheepluva
parents: 3407
diff changeset
   490
        jfr:= 8+ri-1;
56e636b83cb4 tweak land angle detection/portal a bit
sheepluva
parents: 3407
diff changeset
   491
        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
   492
3408
56e636b83cb4 tweak land angle detection/portal a bit
sheepluva
parents: 3407
diff changeset
   493
        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
   494
            begin
3408
56e636b83cb4 tweak land angle detection/portal a bit
sheepluva
parents: 3407
diff changeset
   495
            tmpo:= j mod 8;
56e636b83cb4 tweak land angle detection/portal a bit
sheepluva
parents: 3407
diff changeset
   496
            tmpx:= rdx + offset[tmpo,0];
56e636b83cb4 tweak land angle detection/portal a bit
sheepluva
parents: 3407
diff changeset
   497
            tmpy:= rdy + offset[tmpo,1];
56e636b83cb4 tweak land angle detection/portal a bit
sheepluva
parents: 3407
diff changeset
   498
            if (((tmpy) and LAND_HEIGHT_MASK) = 0) and (((tmpx) and LAND_WIDTH_MASK)  = 0)
56e636b83cb4 tweak land angle detection/portal a bit
sheepluva
parents: 3407
diff changeset
   499
                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
   500
                    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
   501
                    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
   502
                    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
   503
                    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
   504
                    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
   505
            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
   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:= 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
   509
    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
   510
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
    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
   512
3414
b2f3bb44777e some portal changes, warning: no loop prevention yet, note: entry angle not preserved yet
sheepluva
parents: 3411
diff changeset
   513
outDeltaX:= ldx;
b2f3bb44777e some portal changes, warning: no loop prevention yet, note: entry angle not preserved yet
sheepluva
parents: 3411
diff changeset
   514
outDeltaY:= ldy;
3408
56e636b83cb4 tweak land angle detection/portal a bit
sheepluva
parents: 3407
diff changeset
   515
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
   516
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
   517
3038
4e48c276a468 In pascal unit is a namespace
unc0rr
parents: 2948
diff changeset
   518
procedure initModule;
2716
b9ca1bfca24f complete the replacement of init/free wrappers for every unit
koda
parents: 2630
diff changeset
   519
begin
2948
3f21a9dc93d0 Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents: 2716
diff changeset
   520
    Count:= 0;
2716
b9ca1bfca24f complete the replacement of init/free wrappers for every unit
koda
parents: 2630
diff changeset
   521
end;
b9ca1bfca24f complete the replacement of init/free wrappers for every unit
koda
parents: 2630
diff changeset
   522
3038
4e48c276a468 In pascal unit is a namespace
unc0rr
parents: 2948
diff changeset
   523
procedure freeModule;
2716
b9ca1bfca24f complete the replacement of init/free wrappers for every unit
koda
parents: 2630
diff changeset
   524
begin
b9ca1bfca24f complete the replacement of init/free wrappers for every unit
koda
parents: 2630
diff changeset
   525
b9ca1bfca24f complete the replacement of init/free wrappers for every unit
koda
parents: 2630
diff changeset
   526
end;
b9ca1bfca24f complete the replacement of init/free wrappers for every unit
koda
parents: 2630
diff changeset
   527
4
bcbd7adb4e4b - set svn:eol-style to native
unc0rr
parents: 1
diff changeset
   528
end.