Code:
package server.game.content.skills.core;
import java.util.HashMap;
import java.util.Map;
import server.game.content.skills.SkillHandler;
import server.game.npcs.NPCHandler;
import server.game.players.Client;
import server.util.Misc;
public class Slayer {
private static Client c;
public Slayer(Client c) {
Slayer.c = c;
}
public enum SlayerTasks {
CRAWLING_HANDS("crawling hand", 5),
CAVE_BUGS("cave bug", 7),
CAVE_CRAWLER("cave crawler", 10),
BANSHEE("banshee", 15),
CAVE_SLIME("cave slime", 17),
ROCKSLUG("rockslug", 20),
DESERT_LIZARD("desert lizard", 22),
COCKATRICE("cockatrice", 25),
PYREFIEND("pyrefiend", 30),
MOGRE("mogre", 32),
HARPIE_BUG_SWARM("harpie bug swarm", 33),
WALL_BEAST("wall beast", 35),
KILLERWATT("killerwatt", 37),
BASILISK("basilisk", 40),
FEVER_SPIDER("fever spider", 42),
INFERNAL_MAGE("infernal mage", 45),
BLOODVELD("bloodveld", 50),
JELLY("jelly", 52),
TUROTH("turoth", 55),
ZYGOMITE("zygomite", 57),
ABERRANT_SPECTER("aberrant specter", 60),
DUST_DEVIL("dust devil", 65),
KURASK("kurask", 70),
SKELETAL_WYVERNS("skeletal wyvern", 72),
GARGOYLE("gargoyle", 75),
NECHRYAL("nechryael", 80),
ABYSSAL_DEMON("abyssal demon", 85),
DARK_BEAST("dark beast", 90);
private String monsterName;
private int levelReq;
private SlayerTasks(String monsterName, int levelReq) {
this.monsterName = monsterName;
this.levelReq = levelReq;
}
public String getMonster() {
return monsterName;
}
public int getLevel() {
return levelReq;
}
}
public static final String BURTHORPE_ASSIGNMENTS[] = {
"banshee", "bat", "bear", "bird", "cave bug", "cave crawler", "cave slime", "cave crawler", "cow", "crawling hand",
"dog", "dwarf", "ghost", "goblin", "kalphite", "monkey", "moss giant", "skeleton", "spider", "werewolf",
"wolf", "zombie", "rat", "scorpion"
};
public static final String CANIFIS_ASSIGNMENTS[] = {
"killerwatt", "banshee", "basilisk", "bat", "bloodveld", "blue dragon", "bronze dragon", "cave bug", "cave crawler", "cave slime",
"cockatrice", "crawling hand", "dagannoth", "desert lizard", "dog", "ghoul", "green dragon", "earth warrior", "elf", "hellhound",
"hobgoblin", "ice giant", "infernal mage", "jelly", "kalphite", "lesser demon", "moss giant", "mogre", "ogre", "pyrefiend",
"rockslug", "shadow warrior", "skeleton", "shade", "troll", "vampire", "werewolf"
};
public static final String EDGEVILLE_DUNGEON_ASSIGNMENTS[] = {
"zygomite", "aberrant specter", "banshee", "basilisk", "blue dragon", "bloodveld", "bronze dragon", "cave bug", "cockatrice", "crawling hand",
"crocodile", "dagannoth", "desert lizard", "dust devil", "earth warrior", "elf", "fire giant", "goblin", "green dragon", "ghoul",
"harpie bug swarm", "hellhound", "hill giant", "ice giant", "ice warrior", "infernal mage", "jelly", "kalphite", "kurask", "lesser demon",
"moss giant", "ogre", "pyrefiend", "rockslug", "shade", "shadow warrior", "troll", "turoth", "vampire", "wall beast",
"werewolf"
};
public static final String ZANARIS_ASSIGNMENTS[] = {
"aberrant specter", "abyssal demon", "banshee", "basilisk", "black demon", "bronze dragon", "bloodveld", "blue dragon", "cave bug", "cave crawler",
"cave slime", "cockatrice", "crawling hand", "dagannoth", "desert lizard", "dust devil", "elf", "fever spider", "fire giant", "gargoyle",
"greater demon", "hellhound", "iron dragon", "infernal mage", "jelly", "kalphite", "kurask", "lesser demon", "nechryael", "pyrefiend",
"rockslug", "shadow warrior", "steel dragon", "troll", "turoth", "wall beast"
};
public static final String SHILO_VILLAGE_ASSIGNMENTS[] = {
"skeletal wyvern", "dark beast", "aberrant specter", "abyssal demon", "banshee", "basilisk", "black demon", "black dragon", "bloodveld", "bronze dragon",
"cave crawler", "cockatrice", "desert lizard", "dust devil", "elf", "fever spider", "gargoyle", "greater demon", "infernal mage", "iron dragon",
"jelly", "kalphite", "kurask", "lesser demon", "nechryael", "pyrefiend", "steel dragon", "troll", "turoth"
};
public static int taskAmount;
public static String slayerMaster = "none";
public static String slayerTask = "none";
private static String quest1 = "Lost City";
private static String quest2 = "Shilo Village";
public enum SlayerMasters {
//name, npcid, location, taskamount, questreq, levelreq, slayertasks
TURAEL("Turael", 70, "Burthrope", 100, 0, 1, Slayer.BURTHORPE_ASSIGNMENTS),
MAZCHNA("Mazchna", 1596, "Canifis", 100, 0, 1, Slayer.CANIFIS_ASSIGNMENTS),
VANNAKA("Vannaka", 1597, "Edgeville dungeon", 100, 0, 1, Slayer.EDGEVILLE_DUNGEON_ASSIGNMENTS),
CHAELDAR("Chaeldar", 1598, "Zanaris", 100, 1, 1, Slayer.ZANARIS_ASSIGNMENTS),
DURADEL("Duradel", 1599, "Shilo village", 100, 2, 1, Slayer.SHILO_VILLAGE_ASSIGNMENTS);
String masterName, location;
int npcId, hardness, questReq, levelReq;
String[] masterTasks;
private static Map<Integer, SlayerMasters> masterIds = new HashMap<Integer, SlayerMasters>();
private static Map<String, SlayerMasters> masterNames = new HashMap<String, SlayerMasters>();
static {
for (SlayerMasters data : SlayerMasters.values()) {
masterIds.put(data.npcId, data);
masterNames.put(data.masterName, data);
}
}
private SlayerMasters(String masterName, int npcId, String location, int hardness, int questReq, int levelReq, String[] masterTasks) {
this.masterName = masterName;
this.npcId = npcId;
this.location = location;
this.hardness = hardness;
this.questReq = questReq;
this.levelReq = levelReq;
this.masterTasks = masterTasks;
}
public static SlayerMasters forName(String masterName){
return masterNames.get(masterName);
}
public static SlayerMasters forId(int masterId){
return masterIds.get(masterId);
}
public String getName() {
return masterName;
}
public int getNpc() {
return npcId;
}
public String getLocation() {
return location;
}
public int getHardness() {
return hardness;
}
public int getQuest() {
return questReq;
}
public int getLevel() {
return levelReq;
}
public String[] masterTasks() {
return masterTasks;
}
}
public static void assignEasierTask() {
if(slayerMaster.equals("Turael"))
c.getDH().sendNpcChat1("You're still hunting " + slayerTask + " come back when you've finished your task.", c.npcType, slayerMaster);
else
newTask("Turael");
}
public static void canTalkMaster() {
SlayerMasters s = SlayerMasters.forName(slayerMaster);
if (c.playerLevel[c.playerSlayer] > s.getLevel()) {
newTask(slayerMaster);
} else if(c.playerLevel[c.playerSlayer] < s.getLevel()) {
c.sendMessage("You need a slayer level of " + s.getLevel() + " to talk " + slayerMaster + ".");
return;
} else if(s.getQuest() == 1) {
c.sendMessage("You need to complete " + quest1 + " to talk " + slayerMaster + ".");
return ;
} else if(s.getQuest() == 2) {
c.sendMessage("You need to complete " + quest2 + " to talk " + slayerMaster + ".");
return;
}
}
public static void newTask(String masterName) {
SlayerMasters s = SlayerMasters.forName(masterName);
if (!SkillHandler.SLAYER) {
c.sendMessage("This skill is currently disabled.");
return;
}
canTalkMaster();
slayerTask = s.masterTasks()[Misc.random(s.masterTasks().length - 1)];
taskAmount = 10 + Misc.random(s.getHardness());
slayerMaster = masterName;
String str = "Your current assignment is "
+ NPCHandler
.getNpcListName(s.getNpc())
.toLowerCase()
+ (taskAmount > 1 ? "'s" : "")
+ "; you only have " + taskAmount
+ " left.";
String message = str.replaceAll("_", " ");
c.sendMessage(message);
}
public static boolean canSlayNpc(int i) {
for (SlayerTasks s: SlayerTasks.values()) {
if(c.playerLevel[c.playerSlayer] < s.getLevel() && s.getMonster() == NPCHandler.getNpcListName(NPCHandler.npcs[i].npcType).toLowerCase()) {
c.sendMessage("You need " + s.getLevel() + " to slay " + s.getMonster() + ".");
return false;
}
}
appendSlayerKill(i);
return true;
}
public static boolean appendSlayerKill(int i) {
if (canSlayNpc(i)) {
taskAmount--;
c.getPA().addSkillXP(NPCHandler.npcs[i].MaxHP * SkillHandler.SLAYER_EXPERIENCE, c.playerSlayer);
if (taskAmount <= 0) {
c.getPA().addSkillXP((NPCHandler.npcs[i].MaxHP * 8) * SkillHandler.SLAYER_EXPERIENCE, c.playerSlayer);
resetSlayer();
}
}
return false;
}
public static void resetSlayer() {
slayerMaster = "none";
slayerTask = "none";
taskAmount = 0;
c.sendMessage("You have finished your slayer task! Speak to a slayer master to get a new one.");
}
}