317 Projectiles need help.
They just dont appear =/ I had them before but now nope
Anyhow:
Code:
public void fire(final Location source, final Location dest, final int gfx,
final int angle, final int speed, final int startHeight,
final int endHeight, final Entity lockon) {
final int offsetX = (source.getX() - dest.getX()) * -1;
final int offsetY = (source.getY() - dest.getY()) * -1;
for (final Player p : World.getInstance().getPlayerList()) {
if (p.getLocation().withinDistance(source)
&& p.getLocation().withinDistance(dest)) {
p.getActionSender().sendProjectile(source, offsetX, offsetY,
gfx, angle, speed, startHeight, endHeight, lockon);
}
}
}
:
Code:
public void sendProjectile(final Location source, final int offsetX,
final int offsetY, final int gfx, final int angle,
final int startHeight, final int endHeight, final int speed,
final Entity lockon) {
sendCoords(source, -3, -2);
StaticPacketBuilder spb = new StaticPacketBuilder().setId(117);
spb.addByte((byte) angle);
spb.addByte((byte) offsetX);
spb.addByte((byte) offsetY);
if (lockon == null) {
spb.addShort(-1);
} else {
spb.addShort(lockon.getIndex()
+ (lockon instanceof Player ? 32768 : 0));
}
spb.addShort(gfx);
spb.addByte((byte) startHeight);
spb.addByte((byte) endHeight);
spb.addShort(51);
spb.addShort(speed);
spb.addByte((byte) 16);
spb.addByte((byte) 64);
player.getSession().write(spb.toPacket());
}
And:
Code:
public void sendCoords(final Location location, final int xoff,
final int yoff) {
final StaticPacketBuilder spb = new StaticPacketBuilder().setId(85);
int regionX = player.getUpdateFlags().getLastRegion().getRegionX(), regionY = player
.getUpdateFlags().getLastRegion().getRegionY();
spb.addByteC((byte) (location.getY() - regionY * 8) - yoff);
spb.addByteC((byte) (location.getX() - regionX * 8) - xoff);
player.getSession().write(spb.toPacket());
}
Dont post saying that Y and X have to be switched round only because you made it confusing it took me 30 mins to realise I had it correct >.>
Someone see anything wrong or missing?
reply
Client side:
Code:
if (j == 117) {
final int i3 = stream.readUnsignedByte();
int l5 = anInt1268 + (i3 >> 4 & 7);
int k8 = anInt1269 + (i3 & 7);
int j11 = l5 + stream.readSignedByte();
int k13 = k8 + stream.readSignedByte();
final int l15 = stream.readSignedWord();
final int i17 = stream.readUnsignedWord();
final int i18 = stream.readUnsignedByte() * 4;
final int l18 = stream.readUnsignedByte() * 4;
final int k19 = stream.readUnsignedWord();
final int j20 = stream.readUnsignedWord();
final int i21 = stream.readUnsignedByte();
final int j21 = stream.readUnsignedByte();
if (l5 >= 0 && k8 >= 0 && l5 < 104 && k8 < 104 && j11 >= 0
&& k13 >= 0 && j11 < 104 && k13 < 104
&& i17 != 65535) {
l5 = l5 * 128 + 64;
k8 = k8 * 128 + 64;
j11 = j11 * 128 + 64;
k13 = k13 * 128 + 64;
final Animable_Sub4 class30_sub2_sub4_sub4 = new Animable_Sub4(
i21, l18, k19 + Main.loopCycle,
j20 + Main.loopCycle, j21,
plane, method42(plane, k8, l5)
- i18,
k8, l5, l15, i17);
class30_sub2_sub4_sub4.method455(k19 + Main.loopCycle,
k13, method42(plane, k13, j11)
- l18,
j11);
aClass19_1013.insertHead(class30_sub2_sub4_sub4);
}
}
}
Code:
if (pktType == 85) {
anInt1269 = inStream.readUnsignedByteC();
anInt1268 = inStream.readUnsignedByteC();
pktType = -1;
return true;
}