[Hyperion] Object Option Packet Handler (Option 3)
Now i can't remember if this was released or just came with the base.
I added the 3rd option to it so basically if you already have the objectoptionpackethandler class then just add in the extra option at the bottom.
1. Adding the class
step ( a ) - inside the package "org.hyperion.rs2.packet" add the class "ObjectOptionPacketHandler".
step ( b ) - inside the class put the following:
Code:
package org.hyperion.rs2.packet;
import org.hyperion.rs2.model.Location;
import org.hyperion.rs2.model.Player;
import org.hyperion.rs2.net.Packet;
/**
* Object option packet handler.
*
* @author Graham Edgecombe
*
*/
public class ObjectOptionPacketHandler implements PacketHandler {
/**
* Option 1 opcode.
*/
private static final int OPTION_1 = 132, OPTION_2 = 252, OPTION_3 = 70;
@Override
public void handle(Player player, Packet packet) {
switch (packet.getOpcode()) {
case OPTION_1:
handleOption1(player, packet);
break;
case OPTION_2:
handleOption2(player, packet);
break;
case OPTION_3:
handleOption3(player, packet);
break;
}
}
/**
* Handles the option 1 packet.
*
* @param player
* The player.
* @param packet
* The packet.
*/
private void handleOption1(final Player player, Packet packet) {
int x = packet.getLEShortA() & 0xFFFF;
int id = packet.getShort() & 0xFFFF;
int y = packet.getShortA() & 0xFFFF;
Location loc = Location.create(x, y, player.getLocation().getZ());
player.face(Location.create(x, y,
player.getLocation().getZ()));
System.out.println("************************Option 1*************************************");
System.out.println("* Object Id = " + id +" | "+ " Object X = " + x
+" | "+ " Object Y = " + y+" *");
System.out.println("*********************************************************************");
if(player.getLocation().isWithinInteractionDistance(loc)){
switch(id){
case 2843:
break;
}
}
}
/**
* Handles the option 2 packet.
*
* @param player
* The player.
* @param packet
* The packet.
*/
private void handleOption2(Player player, Packet packet) {
int id = packet.getLEShortA() & 0xFFFF;
int y = packet.getLEShort() & 0xFFFF;
int x = packet.getShortA() & 0xFFFF;
Location loc = Location.create(x, y, player.getLocation().getZ());
player.face(Location.create(x, y,
player.getLocation().getZ()));
System.out.println("************************Option 2*************************************");
System.out.println("* Object Id = " + id +" | "+ " Object X = " + x
+" | "+ " Object Y = " + y+" *");
System.out.println("*********************************************************************");
if(player.getLocation().isWithinInteractionDistance(loc)){
switch (id) {
case 1161:
break;
}
}
}
/**
* Handles the option 3 packet.
*
* @param player
* The player.
* @param packet
* The packet.
*/
private void handleOption3(Player player, Packet packet) {
int x = packet.getShortA() & 0xFFFF;
int y = packet.getShort() & 0xFFFF;
int id = packet.getLEShortA() & 0xFFFF;
Location loc = Location.create(x, y, player.getLocation().getZ());
player.face(Location.create(x, y,
player.getLocation().getZ()));
System.out.println("************************Option 3*************************************");
System.out.println("* Object Id = " + id +" | "+ " Object X = " + x
+" | "+ " Object Y = " + y+" *");
System.out.println("*********************************************************************");
if(player.getLocation().isWithinInteractionDistance(loc)){
switch(id){
case 12965:
break;
}
}
}
}
lol just realised that it was provided by graham in the initial release, for those who need it just copy and paste the third option at the end, and add the packet to the top where the packets are.
2. Configuration File
step ( a ) - open up your "configuration.cfg" which is probably in the "/data/" of your hyperion folder.
step ( b ) - add the following line to the bottom of the text file:
Code:
# object option 1
packetHandlers[132]: org.hyperion.rs2.packet.ObjectOptionPacketHandler
# object option 2
packetHandlers[252]: org.hyperion.rs2.packet.ObjectOptionPacketHandler
# object option 3
packetHandlers[70]: org.hyperion.rs2.packet.ObjectOptionPacketHandler
save, compile then go test to see if it works. If you already have object options 1 and 2, just add object option 3 to the configuration file.
if i have missed anything just post,
~ Frank
Credits:
Graham - ObjectOptionPacketHandler class