Ok. I was frustrated with getting custom speeds using the current RS2HD sendProjectile method, so I tried converting Dkk's.
I converted this:
Code:
public void sendProjectile(Entity receiver, WorldTile startTile, WorldTile endTile, int gfxId, int startHeight, int endHeight, int speed, int delay, int curve, int startDistanceOffset, int creatorSize) {
sendWorldTile(startTile);
OutputStream stream = new OutputStream();
stream.writePacket(223);
int x = startTile.getX()-startTile.getRegionX() << 3;
int y = startTile.getY()-startTile.getRegionY() << 3;
stream.writeByte((x & 0x7) << 3 | y & 0x7);
stream.writeByte(endTile.getX()-startTile.getX());
stream.writeByte(endTile.getY()-startTile.getY());
stream.writeShort(receiver == null ? 0 : (receiver instanceof Player ? -(receiver.getIndex()+1) : receiver.getIndex()+1));
stream.writeShort(gfxId);
stream.writeByte(startHeight);
stream.writeByte(endHeight);
stream.writeShort(delay);
int duration = (Utils.getDistance(startTile.getX(), startTile.getY(), endTile.getX(), endTile.getY()) * 30 / ((speed / 10) < 1 ? 1 : (speed / 10))) + delay;
stream.writeShort(duration);
stream.writeByte(curve);
stream.writeByte(creatorSize * 64 + startDistanceOffset * 64);
session.write(stream);
}
to this:
Code:
public void sendCustomProjectile(Entity receiver, Location startTile, Location endTile, int gfxId, int startHeight, int endHeight, int speed, int delay, int curve, int startDistanceOffset, int creatorSize) {
sendCoords(startTile);
int x = startTile.getX()-startTile.getRegionX() << 3;
int y = startTile.getY()-startTile.getRegionY() << 3;
int byte2 = (x & 0x7) << 3 | y & 0x7;
int byte3 = endTile.getX()-startTile.getX();
int byte4 = endTile.getY()-startTile.getY();
int duration = (Misc.getDistance(startTile.getX(), startTile.getY(), endTile.getX(), endTile.getY()) * 30 / ((speed / 10) < 1 ? 1 : (speed / 10))) + delay;
StaticPacketBuilder spb = new StaticPacketBuilder().setId(223)
.addByte((byte) byte2)
.addByte((byte) byte3)
.addByte((byte) byte4)
.addShort(receiver == null ? 0 : (receiver instanceof Player ? -(receiver.getIndex()+1) : receiver.getIndex()+1))
.addShort(gfxId)
.addByte((byte) startHeight)
.addByte((byte) endHeight)
.addByte((byte) delay)
.addShort(duration)
.addByte((byte) curve)
.addByte((byte) (creatorSize * 64 + startDistanceOffset * 64));
player.getSession().write(spb.toPacket());
}
I have added the method to the projectilemanager like this.. Converting straight from Dkk's manager:
Code:
public void sendProjectile(Location shooter, Location receiver, int gfxId, int startHeight, int endHeight, int speed, int delay, int curve, int startDistanceOffset) {
try {
//for(Player p : World.getWorld().getRegionManager().getLocalPlayers(source)) {
for(Player p : World.getWorld().getPlayers()) {
if(p.getLocation().withinDistance(shooter) && p.getLocation().withinDistance(receiver)) {
p.getActionSender().sendCustomProjectile(null, shooter, receiver, gfxId, startHeight, endHeight, speed, delay, curve, startDistanceOffset, 1);
}
}
} catch(Exception e) {
}
}
and my usage is like this, same as Dkk's:
Code:
World.getInstance().getProjectileManager().sendProjectile(n.getLocation(), p.getLocation(), 2263, 18, 18, 50, 50, 0, 0);
(if the usage is wrong, don't tell me that's the problem because I am pretty sure it's not considering that I do not get any compiler errors about not compatible shit.)
It logs me out every time I try to send the projectile. Did I do something wrong?