Bananastreet 620 Posted October 27, 2017 Popular Post Report Share Posted October 27, 2017 (edited) Hey boys and grills, These kids in the Discord chat are like, "You don't contribute anything to the website." Well I'll show them losers. So, I used this on the simplicity source, but it should work on all ruse related servers. Make a new file in com.ruseps.net.packet.impl I called it "MagicOnObjectPacketListener" so I kept the naming scheme throughout. Add the contents in that file. package com.ruseps.net.packet.impl; import com.ruseps.GameSettings; import com.ruseps.engine.task.impl.WalkToTask; import com.ruseps.engine.task.impl.WalkToTask.FinalizedMovementTask; import com.ruseps.model.Animation; import com.ruseps.model.GameObject; import com.ruseps.model.Graphic; import com.ruseps.model.GraphicHeight; import com.ruseps.model.PlayerRights; import com.ruseps.model.Position; import com.ruseps.model.Skill; import com.ruseps.model.definitions.GameObjectDefinition; import com.ruseps.net.packet.Packet; import com.ruseps.net.packet.PacketListener; import com.ruseps.world.clip.region.RegionClipping; import com.ruseps.world.content.combat.magic.MagicSpells; import com.ruseps.world.content.combat.magic.Spell; import com.ruseps.world.entity.impl.player.Player; /** * Magic on object packet listener. * @author Bananastreet * */ public class MagicOnObjectPacketListener implements PacketListener { /** * Handles the click option for an object. * @param player The player that clicked on the object. * @param packet The packet containing the object's and spell's information. */ @Override public void handleMessage(Player player, Packet packet) { final int objectX = packet.readLEShort(); final int spellId = packet.readShortA(); final int objectY = packet.readShortA(); final int objectId = packet.readLEShort(); //Objects position. final Position position = new Position(objectX, objectY, player.getPosition().getZ()); //Intialize a new game object from the packets. final GameObject gameObject = new GameObject(objectId, position); //Check if the object exists in the region. if (!RegionClipping.objectExists(gameObject)) { if (player.getRights().isStaff()) { player.getPacketSender().sendMessage("Object with id " + objectId + " does not exist").sendMessage("Please report to Bananastreet"); } else { player.getPacketSender().sendMessage("An error occured. Error code: " + objectId).sendMessage("Please report the error to a staff member."); } return; } //Check if the spell id is less than 0. if (spellId < 0) { if (player.getRights() == PlayerRights.DEVELOPER) { player.getPacketSender().sendMessage("Error in MagicOnObjectPacketListener!"); } return; } //Getting the magic spell from the spell id. final MagicSpells magicSpell = MagicSpells.forSpellId(spellId); //Checking if the spell is null. if (magicSpell == null) { player.getPacketSender().sendMessage("magicSpell is null"); return; } //Initializing a new spell from the magic spell. Spell spell = magicSpell.getSpell(); //Get the object definition from the object id. final GameObjectDefinition def = GameObjectDefinition.forId(objectId); //Calculate the size of the object. final int size = def.getSizeX() - def.getSizeY() - 1; //Set the game objects size. gameObject.setSize(size); //Walk towards the object and set which object we are interacting with. player.setInteractingObject(gameObject).setWalkToTask(new WalkToTask(player, position, gameObject.getSize(), new FinalizedMovementTask () { @Override public void execute() { //Face the object. player.setPositionToFace(gameObject.getPosition()); switch (objectId) { case 2151: if (magicSpell.equals(MagicSpells.CHARGE_WATER_ORB)) { if (spell == null || !spell.canCast(player, true)) { return; } if (player.getInventory().contains(567)) { player.getInventory().delete(567, 1); } player.performAnimation(ORB_ANIMATION); player.performGraphic(WATER_ORB_GRAPHIC); player.getSkillManager().addExperience(Skill.MAGIC, spell.baseExperience()); player.getInventory().add(571, 1); return; } else { player.getPacketSender().sendMessage("You can only use Charge Water Orb spell on this obelisk."); } player.getPacketSender().sendInterfaceRemoval(); player.getSkillManager().stopSkilling(); break; case 2153: if (magicSpell.equals(MagicSpells.CHARGE_FIRE_ORB)) { if (spell == null || !spell.canCast(player, true)) { return; } player.getPacketSender().sendTab(GameSettings.INVENTORY_TAB); if (player.getInventory().contains(567)) { player.getInventory().delete(567, 1); } player.performAnimation(ORB_ANIMATION); player.performGraphic(FIRE_ORB_GRAPHIC); player.getSkillManager().addExperience(Skill.MAGIC, spell.baseExperience()); player.getInventory().add(569, 1); player.getPacketSender().sendTab(GameSettings.MAGIC_TAB); } else { player.getPacketSender().sendMessage("You can only use Charge Fire Orb spell on this obelisk."); } break; } } })); player.getClickDelay().reset(); player.getInventory().refreshItems(); } private static final Animation ORB_ANIMATION = new Animation(726); private static final Animation DEFAULT_ANIMATION = new Animation(65535); private static final Graphic WATER_ORB_GRAPHIC = new Graphic(149, GraphicHeight.HIGH); private static final Graphic FIRE_ORB_GRAPHIC = new Graphic(152, GraphicHeight.HIGH); private static final Graphic EARTH_ORB_GRAPHIC = new Graphic(151, GraphicHeight.HIGH); private static final Graphic AIR_ORB_GRAPHIC = new Graphic(150, GraphicHeight.HIGH); public static final int MAGIC_ON_OBJECTS = 35; } You'll probably get a few errors telling you that "CHARGE_WATER_ORB" and the others don't exist. On to step 2: Add these spells in your MagicSpells enum: CHARGE_WATER_ORB(new Spell() { @Override public int spellId() { return 1179; } @Override public int levelRequired() { return 56; } @Override public int baseExperience() { return 66; } @Override public Optional<Item[]> itemsRequired(Player player) { return Optional.of(new Item[] {new Item(555, 30), new Item(564, 3), new Item(567)}); } @Override public Optional<Item[]> equipmentRequired(Player player) { return Optional.empty(); } @Override public void startCast(Character cast, Character castOn) { //Empty } }), CHARGE_FIRE_ORB(new Spell() { @Override public int spellId() { return 1184; } @Override public int levelRequired() { return 63; } @Override public int baseExperience() { return 73; } @Override public Optional<Item[]> itemsRequired(Player player) { return Optional.of(new Item[] {new Item(554, 30), new Item(564, 3), new Item(567)}); } @Override public Optional<Item[]> equipmentRequired(Player player) { return Optional.empty(); } @Override public void startCast(Character cast, Character castOn) { } }), Then at last we need to call the MagicOnPacketListener into the packets. Open up PacketConstants and add this with the other magic on stuff to keep it close together. PACKETS[MagicOnObjectPacketListener.MAGIC_ON_OBJECTS] = new MagicOnObjectPacketListener(); Remember to make all of your imports. Which is Ctrl + Shift + O in eclipse. If I missed anything let me know, and on a side note, I know this isn't complete, or done "properly", I just used it to test if the packet was working, and whether I could actually perform the spell on the object. Edited October 27, 2017 by Bananastreet Added image. 5 Link to comment Share on other sites More sharing options...
acesucks 1,310 Posted October 27, 2017 Report Share Posted October 27, 2017 Thanks im sure someone will find this useful Link to comment Share on other sites More sharing options...
DragonicTrench 1 Posted December 15, 2019 Report Share Posted December 15, 2019 fun Link to comment Share on other sites More sharing options...
 iresiqn 2 Posted December 16, 2019 Report Share Posted December 16, 2019 lol ty Link to comment Share on other sites More sharing options...
Madara 767 Posted January 3, 2020 Report Share Posted January 3, 2020 You def showed them losers. Take that! Link to comment Share on other sites More sharing options...
Baller pk10 0 Posted January 15, 2020 Report Share Posted January 15, 2020 awesome! thanks for the help. im using a ruse source and was having some trouble with this exact thing actually Link to comment Share on other sites More sharing options...
Maulage 0 Posted March 11, 2020 Report Share Posted March 11, 2020 Thanks for the tutorial my man. Link to comment Share on other sites More sharing options...
Brutalax 0 Posted March 11, 2020 Report Share Posted March 11, 2020 This is awesome, thank you for posting! Link to comment Share on other sites More sharing options...
sad 1 Posted March 14, 2020 Report Share Posted March 14, 2020 Nice man love your work ! 10 / 10 Link to comment Share on other sites More sharing options...
Kendal 0 Posted March 18, 2020 Report Share Posted March 18, 2020 is ruse still a base worth using? thinking about starting up a new project. Thanks! Link to comment Share on other sites More sharing options...
bigbrainrando 0 Posted March 25, 2020 Report Share Posted March 25, 2020 well written m8 will be useful to alot of people Link to comment Share on other sites More sharing options...
Banki 0 Posted March 27, 2020 Report Share Posted March 27, 2020 Interesting.. Thank you very much for this solution. Often you don't find code that's documented (commented) as well as this.? Link to comment Share on other sites More sharing options...
Motek 0 Posted March 30, 2020 Report Share Posted March 30, 2020 Nice ty for this. Will definitely use this Link to comment Share on other sites More sharing options...
khalilrs 0 Posted April 8, 2020 Report Share Posted April 8, 2020 good stuff ban i thought u didnt like ruse? Link to comment Share on other sites More sharing options...
Hunter 1 Posted April 18, 2020 Report Share Posted April 18, 2020 Thanks, took some of this to fix an issue I was having Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now