mirror of
https://github.com/2006-Scape/2006Scape.git
synced 2026-07-06 16:49:07 +00:00
Projectile clipping, PassDoor fix (#176)
* Numbered packet sizes. Corrected sound packet length to 6 from 5. Corrected sound packet in server. Teleport sound now plays correctly. Corrected modern teleport animation playthrough. Removed redundant teleport delay. * Changed sendSound packet size back to 5 and removed type attribute to maintain compatibility with Parabot. * After running around an object to attack the player will no longer wait a number of ticks to start attacking again. Fixed an issue where walkTo being called from CycleEvents would not execute correctly. Player will no longer face a killed npc after it respawns. Added projectile clipping. Added a new algorithm for player->player/npc following that accounts for projectile clipping.
This commit is contained in:
committed by
Daniel Ginovker
parent
a4e4b89d99
commit
c827d46ca0
@@ -63,7 +63,9 @@ public class ObjectManager {
|
||||
}, ticks);
|
||||
}
|
||||
|
||||
public static void doubleGateTicks(final Client player, final int objectId, final int objectX, final int objectY, final int x1, final int y1, final int x2, final int y2, final int objectH, final int face, int ticks) {
|
||||
public static void doubleGateTicks(final Client player, final int objectId, final int objectX, final int objectY,
|
||||
final int x1, final int y1, final int x2, final int y2,
|
||||
final int objectH, final int face, int ticks) {
|
||||
CycleEventHandler.getSingleton().addEvent(player, new CycleEvent() {
|
||||
@Override
|
||||
public void execute(CycleEventContainer container) {
|
||||
|
||||
@@ -279,6 +279,10 @@ public final class ObjectDef {
|
||||
return aBoolean767;
|
||||
}
|
||||
|
||||
public boolean isUnshootable() {
|
||||
return aBoolean757;
|
||||
}
|
||||
|
||||
public boolean aBoolean736;
|
||||
public String name;
|
||||
public int anInt744;
|
||||
|
||||
@@ -3,6 +3,7 @@ package redone.world.clip;
|
||||
import java.util.LinkedList;
|
||||
|
||||
import redone.game.players.Client;
|
||||
import redone.util.Misc;
|
||||
|
||||
public class PathFinder {
|
||||
|
||||
@@ -209,6 +210,207 @@ public class PathFinder {
|
||||
}
|
||||
}
|
||||
|
||||
public int getRegionCoordinate(int x) {
|
||||
return (x >> 3) - 6;
|
||||
}
|
||||
|
||||
public int getLocalCoordinate(int x) {
|
||||
return x - 8 * getRegionCoordinate(x);
|
||||
}
|
||||
|
||||
public boolean accessible(int x, int y, int heightLevel, int destX, int destY) {
|
||||
destX = destX - 8 * getRegionCoordinate(x);
|
||||
destY = destY - 8 * getRegionCoordinate(y);
|
||||
int[][] via = new int[104][104];
|
||||
int[][] cost = new int[104][104];
|
||||
LinkedList<Integer> tileQueueX = new LinkedList<Integer>();
|
||||
LinkedList<Integer> tileQueueY = new LinkedList<Integer>();
|
||||
for (int xx = 0; xx < 104; xx++) {
|
||||
for (int yy = 0; yy < 104; yy++) {
|
||||
cost[xx][yy] = 99999999;
|
||||
}
|
||||
}
|
||||
int curX = getLocalCoordinate(x);
|
||||
int curY = getLocalCoordinate(y);
|
||||
via[curX][curY] = 99;
|
||||
cost[curX][curY] = 0;
|
||||
int tail = 0;
|
||||
tileQueueX.add(curX);
|
||||
tileQueueY.add(curY);
|
||||
boolean foundPath = false;
|
||||
int pathLength = 4000;
|
||||
while (tail != tileQueueX.size() && tileQueueX.size() < pathLength) {
|
||||
curX = tileQueueX.get(tail);
|
||||
curY = tileQueueY.get(tail);
|
||||
int curAbsX = getRegionCoordinate(x) * 8 + curX;
|
||||
int curAbsY = getRegionCoordinate(y) * 8 + curY;
|
||||
if (curX == destX && curY == destY) {
|
||||
foundPath = true;
|
||||
break;
|
||||
}
|
||||
tail = (tail + 1) % pathLength;
|
||||
int thisCost = cost[curX][curY] + 1;
|
||||
if (curY > 0
|
||||
&& via[curX][curY - 1] == 0
|
||||
&& (Region.getClipping(curAbsX, curAbsY - 1, heightLevel) & 0x1280102) == 0) {
|
||||
tileQueueX.add(curX);
|
||||
tileQueueY.add(curY - 1);
|
||||
via[curX][curY - 1] = 1;
|
||||
cost[curX][curY - 1] = thisCost;
|
||||
}
|
||||
if (curX > 0
|
||||
&& via[curX - 1][curY] == 0
|
||||
&& (Region.getClipping(curAbsX - 1, curAbsY, heightLevel) & 0x1280108) == 0) {
|
||||
tileQueueX.add(curX - 1);
|
||||
tileQueueY.add(curY);
|
||||
via[curX - 1][curY] = 2;
|
||||
cost[curX - 1][curY] = thisCost;
|
||||
}
|
||||
if (curY < 104 - 1
|
||||
&& via[curX][curY + 1] == 0
|
||||
&& (Region.getClipping(curAbsX, curAbsY + 1, heightLevel) & 0x1280120) == 0) {
|
||||
tileQueueX.add(curX);
|
||||
tileQueueY.add(curY + 1);
|
||||
via[curX][curY + 1] = 4;
|
||||
cost[curX][curY + 1] = thisCost;
|
||||
}
|
||||
if (curX < 104 - 1
|
||||
&& via[curX + 1][curY] == 0
|
||||
&& (Region.getClipping(curAbsX + 1, curAbsY, heightLevel) & 0x1280180) == 0) {
|
||||
tileQueueX.add(curX + 1);
|
||||
tileQueueY.add(curY);
|
||||
via[curX + 1][curY] = 8;
|
||||
cost[curX + 1][curY] = thisCost;
|
||||
}
|
||||
if (curX > 0
|
||||
&& curY > 0
|
||||
&& via[curX - 1][curY - 1] == 0
|
||||
&& (Region.getClipping(curAbsX - 1, curAbsY - 1,
|
||||
heightLevel) & 0x128010e) == 0
|
||||
&& (Region.getClipping(curAbsX - 1, curAbsY, heightLevel) & 0x1280108) == 0
|
||||
&& (Region.getClipping(curAbsX, curAbsY - 1, heightLevel) & 0x1280102) == 0) {
|
||||
tileQueueX.add(curX - 1);
|
||||
tileQueueY.add(curY - 1);
|
||||
via[curX - 1][curY - 1] = 3;
|
||||
cost[curX - 1][curY - 1] = thisCost;
|
||||
}
|
||||
if (curX > 0
|
||||
&& curY < 104 - 1
|
||||
&& via[curX - 1][curY + 1] == 0
|
||||
&& (Region.getClipping(curAbsX - 1, curAbsY + 1,
|
||||
heightLevel) & 0x1280138) == 0
|
||||
&& (Region.getClipping(curAbsX - 1, curAbsY, heightLevel) & 0x1280108) == 0
|
||||
&& (Region.getClipping(curAbsX, curAbsY + 1, heightLevel) & 0x1280120) == 0) {
|
||||
tileQueueX.add(curX - 1);
|
||||
tileQueueY.add(curY + 1);
|
||||
via[curX - 1][curY + 1] = 6;
|
||||
cost[curX - 1][curY + 1] = thisCost;
|
||||
}
|
||||
if (curX < 104 - 1
|
||||
&& curY > 0
|
||||
&& via[curX + 1][curY - 1] == 0
|
||||
&& (Region.getClipping(curAbsX + 1, curAbsY - 1,
|
||||
heightLevel) & 0x1280183) == 0
|
||||
&& (Region.getClipping(curAbsX + 1, curAbsY, heightLevel) & 0x1280180) == 0
|
||||
&& (Region.getClipping(curAbsX, curAbsY - 1, heightLevel) & 0x1280102) == 0) {
|
||||
tileQueueX.add(curX + 1);
|
||||
tileQueueY.add(curY - 1);
|
||||
via[curX + 1][curY - 1] = 9;
|
||||
cost[curX + 1][curY - 1] = thisCost;
|
||||
}
|
||||
if (curX < 104 - 1
|
||||
&& curY < 104 - 1
|
||||
&& via[curX + 1][curY + 1] == 0
|
||||
&& (Region.getClipping(curAbsX + 1, curAbsY + 1,
|
||||
heightLevel) & 0x12801e0) == 0
|
||||
&& (Region.getClipping(curAbsX + 1, curAbsY, heightLevel) & 0x1280180) == 0
|
||||
&& (Region.getClipping(curAbsX, curAbsY + 1, heightLevel) & 0x1280120) == 0) {
|
||||
tileQueueX.add(curX + 1);
|
||||
tileQueueY.add(curY + 1);
|
||||
via[curX + 1][curY + 1] = 12;
|
||||
cost[curX + 1][curY + 1] = thisCost;
|
||||
}
|
||||
}
|
||||
return foundPath;
|
||||
}
|
||||
|
||||
public static boolean isProjectilePathClear(int x0, int y0, int z, int x1, int y1) {
|
||||
int deltaX = x1 - x0;
|
||||
int deltaY = y1 - y0;
|
||||
|
||||
double error = 0;
|
||||
final double deltaError = Math.abs(
|
||||
(deltaY) / (deltaX == 0
|
||||
? ((double) deltaY)
|
||||
: ((double) deltaX)));
|
||||
|
||||
int x = x0;
|
||||
int y = y0;
|
||||
|
||||
int pX = x;
|
||||
int pY = y;
|
||||
|
||||
boolean incrX = x0 < x1;
|
||||
boolean incrY = y0 < y1;
|
||||
|
||||
while (true) {
|
||||
if (x != x1) {
|
||||
x += (incrX ? 1 : -1);
|
||||
}
|
||||
|
||||
if (y != y1) {
|
||||
error += deltaError;
|
||||
|
||||
if (error >= 0.5) {
|
||||
y += (incrY ? 1 : -1);
|
||||
error -= 1;
|
||||
}
|
||||
}
|
||||
|
||||
if (!shootable(x, y, z, pX, pY)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
if (incrX && incrY
|
||||
&& x >= x1 && y >= y1) {
|
||||
break;
|
||||
} else if (!incrX && !incrY
|
||||
&& x <= x1 && y <= y1) {
|
||||
break;
|
||||
} else if (!incrX && incrY
|
||||
&& x <= x1 && y >= y1) {
|
||||
break;
|
||||
} else if (incrX && !incrY
|
||||
&& x >= x1 && y <= y1) {
|
||||
break;
|
||||
}
|
||||
|
||||
pX = x;
|
||||
pY = y;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
private static boolean shootable(int x, int y, int z, int px, int py) {
|
||||
if (x == px && y == py) {
|
||||
return true;
|
||||
}
|
||||
|
||||
int[] delta1 = Misc.delta(x, y, px, py);
|
||||
int[] delta2 = Misc.delta(px, py, x, y);
|
||||
|
||||
int dir = Misc.directionFromDelta(delta1[0], delta1[1]);
|
||||
int dir2 = Misc.directionFromDelta(delta2[0], delta2[1]);
|
||||
|
||||
if (dir == -1 || dir2 == -1) {
|
||||
return false;
|
||||
}
|
||||
|
||||
return Region.canMove(x, y, z, dir) && Region.canMove(px, py, z, dir2)
|
||||
|| Region.canShoot(x, y, z, dir) && Region.canShoot(px, py, z, dir2);
|
||||
}
|
||||
|
||||
public int localize(int x, int mapRegion) {
|
||||
return x - 8 * mapRegion;
|
||||
}
|
||||
|
||||
@@ -24,10 +24,6 @@ public class Region {
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
public static boolean blockedShot(int x, int y, int z) {
|
||||
return (getClipping(x, y, z) & 0x20000) == 0;
|
||||
}
|
||||
|
||||
public static Objects getObject(int id, int x, int y, int z) {
|
||||
Region r = getRegion(x, y);
|
||||
@@ -65,7 +61,121 @@ public class Region {
|
||||
}
|
||||
clips[height][x - regionAbsX][y - regionAbsY] |= shift;
|
||||
}
|
||||
|
||||
|
||||
private void addProjectileClip(int x, int y, int height, int shift) {
|
||||
int regionAbsX = (id >> 8) * 64;
|
||||
int regionAbsY = (id & 0xff) * 64;
|
||||
if (projectileClips[height] == null) {
|
||||
projectileClips[height] = new int[64][64];
|
||||
}
|
||||
projectileClips[height][x - regionAbsX][y - regionAbsY] |= shift;
|
||||
}
|
||||
|
||||
public static boolean canMove(int x, int y, int z, int direction) {
|
||||
if (direction == 6) {
|
||||
if ((Region.getClipping(x, y - 1, z) & 0x1280102) == 0) {
|
||||
return true;
|
||||
}
|
||||
} else if (direction == 3) {
|
||||
if ((Region.getClipping(x - 1, y, z) & 0x1280108) == 0) {
|
||||
return true;
|
||||
}
|
||||
} else if (direction == 1) {
|
||||
if ((Region.getClipping(x, y + 1, z) & 0x1280120) == 0) {
|
||||
return true;
|
||||
}
|
||||
} else if (direction == 4) {
|
||||
if ((Region.getClipping(x + 1, y, z) & 0x1280180) == 0) {
|
||||
return true;
|
||||
}
|
||||
} else if (direction == 5) {
|
||||
if ((Region.getClipping(x - 1, y - 1, z) & 0x128010e) == 0
|
||||
&& (Region.getClipping(x - 1, y, z) & 0x1280108) == 0
|
||||
&& (Region.getClipping(x, y - 1, z) & 0x1280102) == 0) {
|
||||
return true;
|
||||
}
|
||||
} else if (direction == 0) {
|
||||
if ((Region.getClipping(x - 1, y + 1, z) & 0x1280138) == 0
|
||||
&& (Region.getClipping(x - 1, y, z) & 0x1280108) == 0
|
||||
&& (Region.getClipping(x, y + 1, z) & 0x1280120) == 0) {
|
||||
return true;
|
||||
}
|
||||
} else if (direction == 7) {
|
||||
if ((Region.getClipping(x + 1, y - 1, z) & 0x1280183) == 0
|
||||
&& (Region.getClipping(x + 1, y, z) & 0x1280180) == 0
|
||||
&& (Region.getClipping(x, y - 1, z) & 0x1280102) == 0) {
|
||||
return true;
|
||||
}
|
||||
} else if (direction == 2) {
|
||||
if ((Region.getClipping(x + 1, y + 1, z) & 0x12801e0) == 0
|
||||
&& (Region.getClipping(x + 1, y, z) & 0x1280180) == 0
|
||||
&& (Region.getClipping(x, y + 1, z) & 0x1280120) == 0) {
|
||||
return true;
|
||||
}
|
||||
} else if (direction == -1) {
|
||||
throw new IllegalArgumentException("Invalid direction: " + direction);
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
public static boolean canShoot(int x, int y, int z, int direction) {
|
||||
if (direction == 0) {
|
||||
return !projectileBlockedNorthWest(x, y, z) && !projectileBlockedNorth(x, y, z)
|
||||
&& !projectileBlockedWest(x, y, z);
|
||||
} else if (direction == 1) {
|
||||
return !projectileBlockedNorth(x, y, z);
|
||||
} else if (direction == 2) {
|
||||
return !projectileBlockedNorthEast(x, y, z) && !projectileBlockedNorth(x, y, z)
|
||||
&& !projectileBlockedEast(x, y, z);
|
||||
} else if (direction == 3) {
|
||||
return !projectileBlockedWest(x, y, z);
|
||||
} else if (direction == 4) {
|
||||
return !projectileBlockedEast(x, y, z);
|
||||
} else if (direction == 5) {
|
||||
return !projectileBlockedSouthWest(x, y, z) && !projectileBlockedSouth(x, y, z)
|
||||
&& !projectileBlockedWest(x, y, z);
|
||||
} else if (direction == 6) {
|
||||
return !projectileBlockedSouth(x, y, z);
|
||||
} else if (direction == 7) {
|
||||
return !projectileBlockedSouthEast(x, y, z) && !projectileBlockedSouth(x, y, z)
|
||||
&& !projectileBlockedEast(x, y, z);
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
public static boolean projectileBlockedNorth(int x, int y, int z) {
|
||||
return (getProjectileClipping(x, y + 1, z) & 0x1280120) != 0;
|
||||
}
|
||||
|
||||
public static boolean projectileBlockedEast(int x, int y, int z) {
|
||||
return (getProjectileClipping(x + 1, y, z) & 0x1280180) != 0;
|
||||
}
|
||||
|
||||
public static boolean projectileBlockedSouth(int x, int y, int z) {
|
||||
return (getProjectileClipping(x, y - 1, z) & 0x1280102) != 0;
|
||||
}
|
||||
|
||||
public static boolean projectileBlockedWest(int x, int y, int z) {
|
||||
return (getProjectileClipping(x - 1, y, z) & 0x1280108) != 0;
|
||||
}
|
||||
|
||||
public static boolean projectileBlockedNorthEast(int x, int y, int z) {
|
||||
return (getProjectileClipping(x + 1, y + 1, z) & 0x12801e0) != 0;
|
||||
}
|
||||
|
||||
public static boolean projectileBlockedNorthWest(int x, int y, int z) {
|
||||
return (getProjectileClipping(x - 1, y + 1, z) & 0x1280138) != 0;
|
||||
}
|
||||
|
||||
public static boolean projectileBlockedSouthEast(int x, int y, int z) {
|
||||
return (getProjectileClipping(x + 1, y - 1, z) & 0x1280183) != 0;
|
||||
}
|
||||
|
||||
public static boolean projectileBlockedSouthWest(int x, int y, int z) {
|
||||
return (getProjectileClipping(x - 1, y - 1, z) & 0x128010e) != 0;
|
||||
}
|
||||
|
||||
public static boolean canMove(int startX, int startY, int endX, int endY, int height, int xLength, int yLength) {
|
||||
int diffX = endX - startX;
|
||||
int diffY = endY - startY;
|
||||
@@ -149,6 +259,15 @@ public class Region {
|
||||
return clips[height][x - regionAbsX][y - regionAbsY];
|
||||
}
|
||||
|
||||
private int getProjectileClip(int x, int y, int height) {
|
||||
int regionAbsX = (id >> 8) * 64;
|
||||
int regionAbsY = (id & 0xff) * 64;
|
||||
if (projectileClips[height] == null) {
|
||||
return 0;
|
||||
}
|
||||
return projectileClips[height][x - regionAbsX][y - regionAbsY];
|
||||
}
|
||||
|
||||
private static void addClipping(int x, int y, int height, int shift) {
|
||||
int regionX = x >> 3;
|
||||
int regionY = y >> 3;
|
||||
@@ -161,9 +280,23 @@ public class Region {
|
||||
}
|
||||
}
|
||||
|
||||
private static void addProjectileClipping(int x, int y, int height, int shift) {
|
||||
int regionX = x >> 3;
|
||||
int regionY = y >> 3;
|
||||
int regionId = (regionX / 8 << 8) + regionY / 8;
|
||||
for (Region r : regions) {
|
||||
if (r.id() == regionId) {
|
||||
r.addProjectileClip(x, y, height, shift);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
private static Region[] regions;
|
||||
private final int id;
|
||||
private final int[][][] clips = new int[4][][];
|
||||
private final int[][][] projectileClips = new int[4][][];
|
||||
private boolean members = false;
|
||||
|
||||
public Region(int id, boolean members) {
|
||||
@@ -298,6 +431,107 @@ public class Region {
|
||||
}
|
||||
}
|
||||
|
||||
private static void addProjectileClippingForVariableObject(int x, int y, int height,
|
||||
int type, int direction, boolean flag) {
|
||||
if (type == 0) {
|
||||
if (direction == 0) {
|
||||
addProjectileClipping(x, y, height, 128);
|
||||
addProjectileClipping(x - 1, y, height, 8);
|
||||
} else if (direction == 1) {
|
||||
addProjectileClipping(x, y, height, 2);
|
||||
addProjectileClipping(x, y + 1, height, 32);
|
||||
} else if (direction == 2) {
|
||||
addProjectileClipping(x, y, height, 8);
|
||||
addProjectileClipping(x + 1, y, height, 128);
|
||||
} else if (direction == 3) {
|
||||
addProjectileClipping(x, y, height, 32);
|
||||
addProjectileClipping(x, y - 1, height, 2);
|
||||
}
|
||||
} else if (type == 1 || type == 3) {
|
||||
if (direction == 0) {
|
||||
addProjectileClipping(x, y, height, 1);
|
||||
addProjectileClipping(x - 1, y, height, 16);
|
||||
} else if (direction == 1) {
|
||||
addProjectileClipping(x, y, height, 4);
|
||||
addProjectileClipping(x + 1, y + 1, height, 64);
|
||||
} else if (direction == 2) {
|
||||
addProjectileClipping(x, y, height, 16);
|
||||
addProjectileClipping(x + 1, y - 1, height, 1);
|
||||
} else if (direction == 3) {
|
||||
addProjectileClipping(x, y, height, 64);
|
||||
addProjectileClipping(x - 1, y - 1, height, 4);
|
||||
}
|
||||
} else if (type == 2) {
|
||||
if (direction == 0) {
|
||||
addProjectileClipping(x, y, height, 130);
|
||||
addProjectileClipping(x - 1, y, height, 8);
|
||||
addProjectileClipping(x, y + 1, height, 32);
|
||||
} else if (direction == 1) {
|
||||
addProjectileClipping(x, y, height, 10);
|
||||
addProjectileClipping(x, y + 1, height, 32);
|
||||
addProjectileClipping(x + 1, y, height, 128);
|
||||
} else if (direction == 2) {
|
||||
addProjectileClipping(x, y, height, 40);
|
||||
addProjectileClipping(x + 1, y, height, 128);
|
||||
addProjectileClipping(x, y - 1, height, 2);
|
||||
} else if (direction == 3) {
|
||||
addProjectileClipping(x, y, height, 160);
|
||||
addProjectileClipping(x, y - 1, height, 2);
|
||||
addProjectileClipping(x - 1, y, height, 8);
|
||||
}
|
||||
}
|
||||
if (flag) {
|
||||
if (type == 0) {
|
||||
if (direction == 0) {
|
||||
addProjectileClipping(x, y, height, 65536);
|
||||
addProjectileClipping(x - 1, y, height, 4096);
|
||||
} else if (direction == 1) {
|
||||
addProjectileClipping(x, y, height, 1024);
|
||||
addProjectileClipping(x, y + 1, height, 16384);
|
||||
} else if (direction == 2) {
|
||||
addProjectileClipping(x, y, height, 4096);
|
||||
addProjectileClipping(x + 1, y, height, 65536);
|
||||
} else if (direction == 3) {
|
||||
addProjectileClipping(x, y, height, 16384);
|
||||
addProjectileClipping(x, y - 1, height, 1024);
|
||||
}
|
||||
}
|
||||
if (type == 1 || type == 3) {
|
||||
if (direction == 0) {
|
||||
addProjectileClipping(x, y, height, 512);
|
||||
addProjectileClipping(x - 1, y + 1, height, 8192);
|
||||
} else if (direction == 1) {
|
||||
addProjectileClipping(x, y, height, 2048);
|
||||
addProjectileClipping(x + 1, y + 1, height, 32768);
|
||||
} else if (direction == 2) {
|
||||
addProjectileClipping(x, y, height, 8192);
|
||||
addProjectileClipping(x + 1, y + 1, height, 512);
|
||||
} else if (direction == 3) {
|
||||
addProjectileClipping(x, y, height, 32768);
|
||||
addProjectileClipping(x - 1, y - 1, height, 2048);
|
||||
}
|
||||
} else if (type == 2) {
|
||||
if (direction == 0) {
|
||||
addProjectileClipping(x, y, height, 66560);
|
||||
addProjectileClipping(x - 1, y, height, 4096);
|
||||
addProjectileClipping(x, y + 1, height, 16384);
|
||||
} else if (direction == 1) {
|
||||
addProjectileClipping(x, y, height, 5120);
|
||||
addProjectileClipping(x, y + 1, height, 16384);
|
||||
addProjectileClipping(x + 1, y, height, 65536);
|
||||
} else if (direction == 2) {
|
||||
addProjectileClipping(x, y, height, 20480);
|
||||
addProjectileClipping(x + 1, y, height, 65536);
|
||||
addProjectileClipping(x, y - 1, height, 1024);
|
||||
} else if (direction == 3) {
|
||||
addProjectileClipping(x, y, height, 81920);
|
||||
addProjectileClipping(x, y - 1, height, 1024);
|
||||
addProjectileClipping(x - 1, y, height, 4096);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private static void addClippingForSolidObject(int x, int y, int height,
|
||||
int xLength, int yLength, boolean flag) {
|
||||
int clipping = 256;
|
||||
@@ -311,6 +545,19 @@ public class Region {
|
||||
}
|
||||
}
|
||||
|
||||
private static void addProjectileClippingForSolidObject(int x, int y, int height,
|
||||
int xLength, int yLength, boolean flag) {
|
||||
int clipping = 256;
|
||||
if (flag) {
|
||||
clipping += 0x20000;
|
||||
}
|
||||
for (int i = x; i < x + xLength; i++) {
|
||||
for (int i2 = y; i2 < y + yLength; i2++) {
|
||||
addProjectileClipping(i, i2, height, clipping);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public static void addObject(int objectId, int x, int y, int height, int type, int direction, boolean startUp) {
|
||||
if (ObjectDef.getObjectDef(objectId) == null) {
|
||||
}
|
||||
@@ -327,16 +574,26 @@ public class Region {
|
||||
if (ObjectDef.getObjectDef(objectId).hasActions()
|
||||
&& ObjectDef.getObjectDef(objectId).aBoolean767()) {
|
||||
addClipping(x, y, height, 0x200000);
|
||||
if (ObjectDef.getObjectDef(objectId).isUnshootable()) {
|
||||
addProjectileClipping(x, y, height, 0x200000);
|
||||
}
|
||||
}
|
||||
} else if (type >= 9) {
|
||||
if (ObjectDef.getObjectDef(objectId).aBoolean767()) {
|
||||
addClippingForSolidObject(x, y, height, xLength, yLength,
|
||||
ObjectDef.getObjectDef(objectId).solid());
|
||||
if (ObjectDef.getObjectDef(objectId).isUnshootable()) {
|
||||
addProjectileClippingForSolidObject(x, y, height, xLength, yLength,
|
||||
ObjectDef.getObjectDef(objectId).solid());
|
||||
}
|
||||
}
|
||||
} else if (type >= 0 && type <= 3) {
|
||||
if (ObjectDef.getObjectDef(objectId).aBoolean767()) {
|
||||
addClippingForVariableObject(x, y, height, type, direction,
|
||||
ObjectDef.getObjectDef(objectId).solid());
|
||||
if (ObjectDef.getObjectDef(objectId).isUnshootable()) {
|
||||
addProjectileClippingForVariableObject(x, y, height, type, direction, ObjectDef.getObjectDef(objectId).solid());
|
||||
}
|
||||
}
|
||||
}
|
||||
Region r = getRegion(x, y);
|
||||
@@ -363,6 +620,21 @@ public class Region {
|
||||
return 0;
|
||||
}
|
||||
|
||||
public static int getProjectileClipping(int x, int y, int height) {
|
||||
if (height > 3) {
|
||||
height = 0;
|
||||
}
|
||||
int regionX = x >> 3;
|
||||
int regionY = y >> 3;
|
||||
int regionId = (regionX / 8 << 8) + regionY / 8;
|
||||
for (Region r : regions) {
|
||||
if (r.id() == regionId) {
|
||||
return r.getProjectileClip(x, y, height);
|
||||
}
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
public static boolean getClipping(int x, int y, int height, int moveTypeX,
|
||||
int moveTypeY) {
|
||||
try {
|
||||
|
||||
Reference in New Issue
Block a user