Hi! On my private project, I made this which I thought I would like to share with you guys.
I know this has been released before, but this features all animations and improved code.
Please note that this does not include the dragonkin lamp, but I may release it in the nearest future.
Code:package com.rs.game.player.content;
import java.util.Arrays;
import com.rs.game.Animation;
import com.rs.game.Graphics;
import com.rs.game.item.Item;
import com.rs.game.player.Player;
import com.rs.game.player.Skills;
import com.rs.game.player.dialogues.AncientEffigyD;
/**
*
* @author _Hassan <https://www.rune-server.ee/members/_hassan/> Created: 18 Apr
* 2017 ~ server
*
*/
public class AncientEffigy {
private static AncientEffigy instance;
public static final AncientEffigy getInstance() {
if (instance == null)
instance = new AncientEffigy();
return instance;
}
private Item item;
private final Object[][] EMOTES = { { new Animation(14177), new Graphics(2692) },
{ new Animation(4068), new Animation(4067) } };
private final Item[] EFFIGIES = { new Item(18778), new Item(18779), new Item(18780), new Item(18781) };
private final int[] SKILL_1 = { Skills.AGILITY, Skills.CONSTRUCTION, Skills.COOKING, Skills.FISHING,
Skills.FLETCHING, Skills.HERBLORE, Skills.MINING, Skills.SUMMONING };
private final int[] SKILL_2 = { Skills.CRAFTING, Skills.THIEVING, Skills.FIREMAKING, Skills.FARMING,
Skills.WOODCUTTING, Skills.HUNTER, Skills.SMITHING, Skills.RUNECRAFTING };
private final String[] SKILL_MESSAGES = { "deftness and precision", "buildings and security",
"fire and preparation", "life and cultivation", "lumber and woodworking", "flora and fuana",
"metalwork and minerals", "binding essence and spirits" };
public boolean isEffigy(Player player, Item item) {
this.item = item;
if (item.getId() == effigy().getId()) {
player.getDialogueManager().startDialogue(AncientEffigyD.class, item);
return true;
}
return false;
}
public void advanceEffigy(Player player, Item item) {
player.lock(5);
player.getInventory().deleteItem(effigy().getId(), 1);
player.getInventory().addItem(effigy().getId() + 1, 1);
player.setNextAnimation((Animation) EMOTES[1][0]);
if (effigy().getId() + 1 == 18782)
player.setAniAndGfx((Animation) EMOTES[0][0], (Graphics) EMOTES[0][1]);
}
private final Item effigy() {
return Arrays.stream(EFFIGIES).filter(effigy -> item.getId() == effigy.getId()).findAny().orElse(null);
}
public int[] getSkills(int type) {
return type == 0 ? SKILL_1 : SKILL_2;
}
public String getMessage(int skill) {
return SKILL_MESSAGES[skill];
}
public int getRequiredLvl(Item item) {
switch (item.getId()) {
case 18778:
return 91;
case 18779:
return 93;
case 18780:
return 95;
case 18781:
return 97;
}
return -1;
}
public int getXP(Item item) {
switch (item.getId()) {
case 18778:
return 15000;
case 18779:
return 20000;
case 18780:
return 25000;
case 18781:
return 30000;
}
return -1;
}
}
Code:package com.rs.game.player.dialogues;
import com.rs.GameSettings;
import com.rs.game.item.Item;
import com.rs.game.player.Skills;
import com.rs.game.player.content.AncientEffigy;
import com.rs.utils.Utils;
/**
*
* @author _Hassan <https://www.rune-server.ee/members/_hassan/> Created: 19 Apr
* 2017 ~ server
*
*/
public class AncientEffigyD extends Dialogue {
Item item;
int skill_1, skill_2;
int random = Utils.random(AncientEffigy.getInstance().getSkills(0).length);
@Override
public void start() {
item = (Item) parameters[0];
skill_1 = AncientEffigy.getInstance().getSkills(0)[random];
skill_2 = AncientEffigy.getInstance().getSkills(1)[random];
stage = 1;
sendDialogue(
"As you inspect the ancient effigy, you begin to feel a strange sensation of the relic searching your mind, drawing on your knowledge.");
}
@Override
public void run(int interfaceId, int componentId) {
switch (stage) {
case END:
end();
break;
case 1:
sendDialogue("Images from your experiences of " + AncientEffigy.getInstance().getMessage(random)
+ " fill your mind.");
break;
case 2:
sendOptions("Which images do you wish to focus on?", Skills.SKILL_NAME[skill_1],
Skills.SKILL_NAME[skill_2]);
break;
case 3:
switch (componentId) {
case OPTION_1:
case OPTION_2:
int required_lvl = AncientEffigy.getInstance().getRequiredLvl(item);
boolean op1 = componentId == OPTION_1;
if (op1 ? player.getSkills().getLevelForXp(skill_1) < required_lvl
: player.getSkills().getLevelForXp(skill_2) < required_lvl) {
stage = END;
sendDialogue(
"The images in your mind fade; the ancient effigy seems to desire knowledge of experiences you have not yet had.");
return;
}
int xp = AncientEffigy.getInstance().getXP(item) * GameSettings.XP_RATE;
player.getSkills().addXp(op1 ? skill_1 : skill_2, xp);
player.sm(
"You have gained " + Utils.formatNumber(xp) + " "
+ (op1 ? Skills.SKILL_NAME[skill_1] : Skills.SKILL_NAME[skill_2]) + " experience!",
false);
sendDialogue(
"As you focus on your memories, you can almost hear a voice in the back of your mind whispering to you...");
}
break;
case 4:
AncientEffigy.getInstance().advanceEffigy(player, item);
sendDialogue(
"The ancient effigy glows briefly, it seems to be changed somehow and no longer responds to the same memories as before.");
break;
case 5:
sendDialogue(
"A sudden bolt of inspiration flashes through your mind, revealling new insight into your experiences!");
break;
}
stage++;
if (stage == 6)
end();
}
@Override
public void finish() {
// TODO Auto-generated method stub
}
}
enjoy
bye