Hello Community of Rune-Server,
I was working on this for my server, so i decided to release it here as well
Credits:
80% - Me, for the coding.
20% - Matrix, for the base i use.
NOTE: This uses the RuneScape experience rate.
Also has correct graphics on object, but no sound.
In
com/rs/game/player/content/ make a class named:
BonesOnAltar.java and add this in it.
Code:
package com.rs.game.player.content;
import java.util.HashMap;
import java.util.Map;
import com.rs.game.Animation;
import com.rs.game.Graphics;
import com.rs.game.World;
import com.rs.game.WorldObject;
import com.rs.game.item.Item;
import com.rs.game.player.Player;
import com.rs.game.player.Skills;
import com.rs.game.player.actions.Action;
import com.rs.game.player.actions.Cooking.Cookables;
@SuppressWarnings("unused")
public class BonesOnAltar extends Action {
public final String MESSAGE = "The gods are very pleased with your offerings.";
public final double MULTIPLIER = 2.5;
public enum Bones {
BONES(new Item(526, 1), 5),
BIG_BONES(new Item(532, 1), 15),
BABYDRAGON_BONES(new Item(534, 1), 30),
WYVERN_BONES(new Item(6812, 1), 50),
DRAGON_BONES(new Item(536, 1), 72),
OURG_BONES(new Item(4834, 1), 140),
FROST_DRAGON_BONES(new Item(18830, 1), 180),
DAGANNOTH_BONES(new Item(6729, 1), 125);
private static Map<Short, Bones> bones = new HashMap<Short, Bones>();
public static Bones forId(short itemId) {
return bones.get(itemId);
}
static {
for (Bones bone: Bones.values()) {
bones.put((short) bone.getBone().getId(), bone);
}
}
private Item item;
private int xp;
private Bones(Item item, int xp) {
this.item = item;
this.xp = xp;
}
public Item getBone() {
return item;
}
public int getXP() {
return xp;
}
}
private Bones bone;
private int amount;
private Item item;
private WorldObject object;
private Animation USING = new Animation(896);
public BonesOnAltar(WorldObject object, Item item, int amount) {
this.amount = amount;
this.item = item;
this.object = object;
}
public static Bones isGood(Item item) {
return Bones.forId((short) item.getId());
}
public boolean start(Player player) {
if((this.bone = Bones.forId((short) item.getId())) == null) {
return false;
}
player.faceObject(object);
return true;
}
public boolean process(Player player) {
if (!World.getRegion(object.getRegionId()).containsObject(
object.getId(), object))
return false;
if (!player.getInventory().containsItem(item.getId(), 1)) {
return false;
}
if (!player.getInventory().containsItem(bone.getBone().getId(), 1)) {
return false;
}
return true;
}
public int processWithDelay(Player player) {
player.setNextAnimation(USING);
player.getPackets().sendGraphics(new Graphics(624), object);
player.getInventory().deleteItem(item.getId(), 1);
player.getSkills().addXp(Skills.PRAYER, bone.getXP()*MULTIPLIER);
player.getPackets().sendGameMessage(MESSAGE);
player.getInventory().refresh();
return 3;
}
public void stop(final Player player) {
this.setActionDelay(player, 3);
}
}
Then, in the
com/rs/game/player/dialogues/ folder, create a class named
PrayerD.java and add this in it.
Code:
package com.rs.game.player.dialogues;
import com.rs.game.WorldObject;
import com.rs.game.player.content.BonesOnAltar;
import com.rs.game.player.content.BonesOnAltar.Bones;
import com.rs.game.player.content.SkillsDialogue;
public class PrayerD extends Dialogue {
private Bones bones;
private WorldObject object;
@Override
public void start() {
this.bones = (Bones) parameters[0];
this.object = (WorldObject) parameters[1];
SkillsDialogue
.sendSkillsDialogue(
player,
SkillsDialogue.OFFER,
"How many would you like to offer?",
player.getInventory().getItems()
.getNumberOf(bones.getBone()),
new int[] { bones.getBone().getId() }, null);
}
@Override
public void run(int interfaceId, int componentId) {
player.getActionManager().setAction(
new BonesOnAltar(object, bones.getBone(), SkillsDialogue
.getQuantity(player)));
end();
}
@Override
public void finish() {
}
}
Now, open
DialogueHandler.java which should be located at:
com/rs/game/player/dialogues/ and declare this where all your declared dialogues are, preferably at the end of the already declared ones.
Code:
handledDialogues.put("PrayerD", (Class<Dialogue>) Class.forName(PrayerD.class.getCanonicalName()));
Now, open
ObjectHandler.java which should located at:
com/rs/net/decoders/handlers/ and declare this case for object 409(Prayer altar) in the
HandleItemOnObject method.
Code:
} else if(object.getId() == 409) {
Bones bone = BonesOnAltar.isGood(item);
if(bone != null) {
player.getDialogueManager().startDialogue("PrayerD", bone, object);
return;
} else {
player.getPackets().sendGameMessage("Nothing interesting happens.");
return;
}
Also make sure you import these 2 in
ObjectHandler.java
Code:
import com.rs.game.player.content.BonesOnAltar;
import com.rs.game.player.content.BonesOnAltar.Bones;
Now, open
Burying.java which should be found at:
com/rs/game/player/content/ and change the stuff in the enum with this one, to make it have same experience as bones on altar but without the xp multiplier.
Code:
BONES(526, 5),
BIG_BONES(532, 15),
BABYDRAGON_BONES(534, 30),
WYVERN_BONES(6812, 50),
DRAGON_BONES(536, 72),
OURG_BONES(4834, 140),
FROST_DRAGON_BONES(18830, 180),
DAGANNOTH_BONES(6729, 125);
If you use this, at least say thanks