use of org.powerbot.bot.rt6.client.Skill in project HeavenMS by ronancpl.
the class MapleItemInformationProvider method canUseSkillBook.
private boolean canUseSkillBook(MapleCharacter player, Integer skillBookId) {
Map<String, Integer> skilldata = MapleItemInformationProvider.getInstance().getSkillStats(skillBookId, player.getJob().getId());
if (skilldata == null || skilldata.get("skillid") == 0)
return false;
Skill skill2 = SkillFactory.getSkill(skilldata.get("skillid"));
return (skilldata.get("skillid") != 0 && ((player.getSkillLevel(skill2) >= skilldata.get("reqSkillLevel") || skilldata.get("reqSkillLevel") == 0) && player.getMasterLevel(skill2) < skilldata.get("masterLevel")));
}
use of org.powerbot.bot.rt6.client.Skill in project HeavenMS by ronancpl.
the class Commands method executeHeavenMsCommandLv2.
public static boolean executeHeavenMsCommandLv2(Channel cserv, Server srv, MapleClient c, String[] sub) {
// JrGM
MapleCharacter player = c.getPlayer();
MapleCharacter victim;
Skill skill;
switch(sub[0]) {
case "hide":
SkillFactory.getSkill(9101004).getEffect(SkillFactory.getSkill(9101004).getMaxLevel()).applyTo(player);
break;
case "unhide":
SkillFactory.getSkill(9101004).getEffect(SkillFactory.getSkill(9101004).getMaxLevel()).applyTo(player);
break;
case "sp":
if (sub.length < 2) {
player.yellowMessage("Syntax: !sp [<playername>] <newsp>");
break;
}
if (sub.length == 2) {
int newSp = Integer.parseInt(sub[1]);
if (newSp < 0)
newSp = 0;
else if (newSp > ServerConstants.MAX_AP)
newSp = ServerConstants.MAX_AP;
player.setRemainingSp(newSp);
player.updateSingleStat(MapleStat.AVAILABLESP, player.getRemainingSp());
} else {
victim = c.getChannelServer().getPlayerStorage().getCharacterByName(sub[1]);
if (victim != null) {
int newSp = Integer.parseInt(sub[2]);
if (newSp < 0)
newSp = 0;
else if (newSp > ServerConstants.MAX_AP)
newSp = ServerConstants.MAX_AP;
victim.setRemainingSp(newSp);
victim.updateSingleStat(MapleStat.AVAILABLESP, player.getRemainingSp());
player.dropMessage(5, "SP given.");
} else {
player.message("Player '" + sub[1] + "' could not be found on this channel.");
}
}
break;
case "ap":
if (sub.length < 2) {
player.yellowMessage("Syntax: !ap [<playername>] <newap>");
break;
}
if (sub.length < 3) {
int newAp = Integer.parseInt(sub[1]);
if (newAp < 0)
newAp = 0;
else if (newAp > ServerConstants.MAX_AP)
newAp = ServerConstants.MAX_AP;
player.setRemainingAp(newAp);
player.updateSingleStat(MapleStat.AVAILABLEAP, player.getRemainingAp());
} else {
victim = c.getChannelServer().getPlayerStorage().getCharacterByName(sub[1]);
if (victim != null) {
int newAp = Integer.parseInt(sub[2]);
if (newAp < 0)
newAp = 0;
else if (newAp > ServerConstants.MAX_AP)
newAp = ServerConstants.MAX_AP;
victim.setRemainingAp(newAp);
victim.updateSingleStat(MapleStat.AVAILABLEAP, victim.getRemainingAp());
} else {
player.message("Player '" + sub[1] + "' could not be found on this channel.");
}
}
break;
case "empowerme":
final int[] array = { 2311003, 2301004, 1301007, 4101004, 2001002, 1101007, 1005, 2301003, 5121009, 1111002, 4111001, 4111002, 4211003, 4211005, 1321000, 2321004, 3121002 };
for (int i : array) {
SkillFactory.getSkill(i).getEffect(SkillFactory.getSkill(i).getMaxLevel()).applyTo(player);
}
break;
case "buffmap":
SkillFactory.getSkill(9101001).getEffect(SkillFactory.getSkill(9101001).getMaxLevel()).applyTo(player, true);
SkillFactory.getSkill(9101002).getEffect(SkillFactory.getSkill(9101002).getMaxLevel()).applyTo(player, true);
SkillFactory.getSkill(9101003).getEffect(SkillFactory.getSkill(9101003).getMaxLevel()).applyTo(player, true);
SkillFactory.getSkill(9101008).getEffect(SkillFactory.getSkill(9101008).getMaxLevel()).applyTo(player, true);
SkillFactory.getSkill(1005).getEffect(SkillFactory.getSkill(1005).getMaxLevel()).applyTo(player, true);
break;
case "buff":
if (sub.length < 2) {
player.yellowMessage("Syntax: !buff <buffid>");
break;
}
int skillid = Integer.parseInt(sub[1]);
skill = SkillFactory.getSkill(skillid);
if (skill != null)
skill.getEffect(skill.getMaxLevel()).applyTo(player);
break;
case "bomb":
if (sub.length > 1) {
victim = c.getWorldServer().getPlayerStorage().getCharacterByName(sub[1]);
if (victim != null) {
victim.getMap().spawnMonsterOnGroundBelow(MapleLifeFactory.getMonster(9300166), victim.getPosition());
Server.getInstance().broadcastGMMessage(c.getWorld(), MaplePacketCreator.serverNotice(5, player.getName() + " used !bomb on " + victim.getName()));
} else {
player.message("Player '" + sub[1] + "' could not be found on this world.");
}
} else {
player.getMap().spawnMonsterOnGroundBelow(MapleLifeFactory.getMonster(9300166), player.getPosition());
}
break;
case "dc":
if (sub.length < 2) {
player.yellowMessage("Syntax: !dc <playername>");
break;
}
victim = c.getWorldServer().getPlayerStorage().getCharacterByName(sub[1]);
if (victim == null) {
victim = c.getChannelServer().getPlayerStorage().getCharacterByName(sub[1]);
if (victim == null) {
victim = player.getMap().getCharacterByName(sub[1]);
if (victim != null) {
try {
// sometimes bugged because the map = null
victim.getClient().disconnect(true, false);
player.getMap().removePlayer(victim);
} catch (Exception e) {
e.printStackTrace();
}
} else {
break;
}
}
}
if (player.gmLevel() < victim.gmLevel()) {
victim = player;
}
victim.getClient().disconnect(false, false);
break;
case "cleardrops":
player.getMap().clearDrops(player);
player.dropMessage(5, "Cleared dropped items");
break;
case "clearslot":
if (sub.length < 2) {
player.yellowMessage("Syntax: !clearslot <all, equip, use, setup, etc or cash.>");
break;
}
String type = sub[1];
if (type.equals("all")) {
for (int i = 0; i < 101; i++) {
Item tempItem = c.getPlayer().getInventory(MapleInventoryType.EQUIP).getItem((byte) i);
if (tempItem == null)
continue;
MapleInventoryManipulator.removeFromSlot(c, MapleInventoryType.EQUIP, (byte) i, tempItem.getQuantity(), false, true);
}
for (int i = 0; i < 101; i++) {
Item tempItem = c.getPlayer().getInventory(MapleInventoryType.USE).getItem((byte) i);
if (tempItem == null)
continue;
MapleInventoryManipulator.removeFromSlot(c, MapleInventoryType.USE, (byte) i, tempItem.getQuantity(), false, true);
}
for (int i = 0; i < 101; i++) {
Item tempItem = c.getPlayer().getInventory(MapleInventoryType.ETC).getItem((byte) i);
if (tempItem == null)
continue;
MapleInventoryManipulator.removeFromSlot(c, MapleInventoryType.ETC, (byte) i, tempItem.getQuantity(), false, true);
}
for (int i = 0; i < 101; i++) {
Item tempItem = c.getPlayer().getInventory(MapleInventoryType.SETUP).getItem((byte) i);
if (tempItem == null)
continue;
MapleInventoryManipulator.removeFromSlot(c, MapleInventoryType.SETUP, (byte) i, tempItem.getQuantity(), false, true);
}
for (int i = 0; i < 101; i++) {
Item tempItem = c.getPlayer().getInventory(MapleInventoryType.CASH).getItem((byte) i);
if (tempItem == null)
continue;
MapleInventoryManipulator.removeFromSlot(c, MapleInventoryType.CASH, (byte) i, tempItem.getQuantity(), false, true);
}
player.yellowMessage("All Slots Cleared.");
} else if (type.equals("equip")) {
for (int i = 0; i < 101; i++) {
Item tempItem = c.getPlayer().getInventory(MapleInventoryType.EQUIP).getItem((byte) i);
if (tempItem == null)
continue;
MapleInventoryManipulator.removeFromSlot(c, MapleInventoryType.EQUIP, (byte) i, tempItem.getQuantity(), false, true);
}
player.yellowMessage("Equipment Slot Cleared.");
} else if (type.equals("use")) {
for (int i = 0; i < 101; i++) {
Item tempItem = c.getPlayer().getInventory(MapleInventoryType.USE).getItem((byte) i);
if (tempItem == null)
continue;
MapleInventoryManipulator.removeFromSlot(c, MapleInventoryType.USE, (byte) i, tempItem.getQuantity(), false, true);
}
player.yellowMessage("Use Slot Cleared.");
} else if (type.equals("setup")) {
for (int i = 0; i < 101; i++) {
Item tempItem = c.getPlayer().getInventory(MapleInventoryType.SETUP).getItem((byte) i);
if (tempItem == null)
continue;
MapleInventoryManipulator.removeFromSlot(c, MapleInventoryType.SETUP, (byte) i, tempItem.getQuantity(), false, true);
}
player.yellowMessage("Set-Up Slot Cleared.");
} else if (type.equals("etc")) {
for (int i = 0; i < 101; i++) {
Item tempItem = c.getPlayer().getInventory(MapleInventoryType.ETC).getItem((byte) i);
if (tempItem == null)
continue;
MapleInventoryManipulator.removeFromSlot(c, MapleInventoryType.ETC, (byte) i, tempItem.getQuantity(), false, true);
}
player.yellowMessage("ETC Slot Cleared.");
} else if (type.equals("cash")) {
for (int i = 0; i < 101; i++) {
Item tempItem = c.getPlayer().getInventory(MapleInventoryType.CASH).getItem((byte) i);
if (tempItem == null)
continue;
MapleInventoryManipulator.removeFromSlot(c, MapleInventoryType.CASH, (byte) i, tempItem.getQuantity(), false, true);
}
player.yellowMessage("Cash Slot Cleared.");
} else
player.yellowMessage("Slot" + type + " does not exist!");
break;
case "warp":
if (sub.length < 2) {
player.yellowMessage("Syntax: !warp <mapid>");
break;
}
try {
MapleMap target = c.getChannelServer().getMapFactory().getMap(Integer.parseInt(sub[1]));
if (target == null) {
player.yellowMessage("Map ID " + sub[1] + " is invalid.");
break;
}
if (player.getEventInstance() != null) {
player.getEventInstance().leftParty(player);
}
player.changeMap(target, target.getRandomPlayerSpawnpoint());
} catch (Exception ex) {
player.yellowMessage("Map ID " + sub[1] + " is invalid.");
break;
}
break;
case "warpto":
if (sub.length < 3) {
player.yellowMessage("Syntax: !warpto <playername> <mapid>");
break;
}
victim = cserv.getPlayerStorage().getCharacterByName(sub[1]);
if (victim == null) {
// If victim isn't on current channel or isnt a character try and find him by loop all channels on current world.
for (Channel ch : srv.getChannelsFromWorld(c.getWorld())) {
victim = ch.getPlayerStorage().getCharacterByName(sub[1]);
if (victim != null) {
// We found the person, no need to continue the loop.
break;
}
}
}
if (victim != null) {
// Remove warper from current event instance.
if (player.getEventInstance() != null) {
player.getEventInstance().unregisterPlayer(player);
}
// Attempt to join the victims warp instance.
if (victim.getEventInstance() != null) {
if (victim.getClient().getChannel() == player.getClient().getChannel()) {
// just in case.. you never know...
// victim.getEventInstance().registerPlayer(player);
player.changeMap(victim.getEventInstance().getMapInstance(victim.getMapId()), victim.getMap().findClosestPortal(victim.getPosition()));
} else {
player.dropMessage(6, "Please change to channel " + victim.getClient().getChannel());
}
} else {
// If victim isn't in an event instance, just warp them.
player.changeMap(victim.getMapId(), victim.getMap().findClosestPortal(victim.getPosition()));
}
if (player.getClient().getChannel() != victim.getClient().getChannel()) {
// And then change channel if needed.
player.dropMessage("Changing channel, please wait a moment.");
player.getClient().changeChannel(victim.getClient().getChannel());
}
} else {
player.dropMessage(6, "Unknown player.");
}
break;
case "warphere":
case "summon":
if (sub.length < 2) {
player.yellowMessage("Syntax: !warphere <playername>");
break;
}
victim = cserv.getPlayerStorage().getCharacterByName(sub[1]);
if (victim == null) {
// If victim isn't on current channel, loop all channels on current world.
for (Channel ch : srv.getChannelsFromWorld(c.getWorld())) {
victim = ch.getPlayerStorage().getCharacterByName(sub[1]);
if (victim != null) {
// We found the person, no need to continue the loop.
break;
}
}
}
if (victim != null) {
boolean changingEvent = true;
if (victim.getEventInstance() != null) {
if (player.getEventInstance() != null && victim.getEventInstance().getLeaderId() == player.getEventInstance().getLeaderId()) {
changingEvent = false;
} else {
victim.getEventInstance().unregisterPlayer(victim);
}
}
// Attempt to join the warpers instance.
if (player.getEventInstance() != null && changingEvent) {
if (player.getClient().getChannel() == victim.getClient().getChannel()) {
// just in case.. you never know...
player.getEventInstance().registerPlayer(victim);
victim.changeMap(player.getEventInstance().getMapInstance(player.getMapId()), player.getMap().findClosestPortal(player.getPosition()));
} else {
player.dropMessage("Target isn't on your channel, not able to warp into event instance.");
}
} else {
// If victim isn't in an event instance or is in the same event instance as the one the caller is, just warp them.
victim.changeMap(player.getMapId(), player.getMap().findClosestPortal(player.getPosition()));
}
if (player.getClient().getChannel() != victim.getClient().getChannel()) {
// And then change channel if needed.
victim.dropMessage("Changing channel, please wait a moment.");
victim.getClient().changeChannel(player.getClient().getChannel());
}
} else {
player.dropMessage(6, "Unknown player.");
}
break;
case "reach":
if (sub.length < 2) {
player.yellowMessage("Syntax: !reach <playername>");
break;
}
victim = c.getWorldServer().getPlayerStorage().getCharacterByName(sub[1]);
if (victim != null && victim.isLoggedin()) {
if (player.getClient().getChannel() != victim.getClient().getChannel()) {
player.dropMessage(5, "Player '" + victim.getName() + "' is at channel " + victim.getClient().getChannel() + ".");
} else {
MapleMap map = victim.getMap();
player.changeMap(map, map.findClosestPortal(victim.getPosition()));
}
} else {
player.dropMessage(6, "Unknown player.");
}
break;
case "gmshop":
MapleShopFactory.getInstance().getShop(1337).sendShop(c);
break;
case "heal":
player.setHpMp(30000);
break;
case "item":
case "drop":
if (sub.length < 2) {
player.yellowMessage("Syntax: !item <itemid> <quantity>");
break;
}
int itemId = Integer.parseInt(sub[1]);
MapleItemInformationProvider ii = MapleItemInformationProvider.getInstance();
if (ii.getName(itemId) == null) {
player.yellowMessage("Item id '" + sub[1] + "' does not exist.");
break;
}
short quantity = 1;
if (sub.length >= 3)
quantity = Short.parseShort(sub[2]);
if (ServerConstants.BLOCK_GENERATE_CASH_ITEM && ii.isCash(itemId)) {
player.yellowMessage("You cannot create a cash item with this command.");
break;
}
if (ItemConstants.isPet(itemId)) {
if (sub.length >= 3) {
// thanks to istreety & TacoBell
quantity = 1;
long days = Math.max(1, Integer.parseInt(sub[2]));
long expiration = System.currentTimeMillis() + (days * 24 * 60 * 60 * 1000);
int petid = MaplePet.createPet(itemId);
if (sub[0].equals("item")) {
MapleInventoryManipulator.addById(c, itemId, quantity, player.getName(), petid, expiration);
} else {
Item toDrop = new Item(itemId, (short) 0, quantity, petid);
toDrop.setExpiration(expiration);
toDrop.setOwner("");
if (player.gmLevel() < 3) {
byte b = toDrop.getFlag();
b |= ItemConstants.ACCOUNT_SHARING;
b |= ItemConstants.UNTRADEABLE;
toDrop.setFlag(b);
}
c.getPlayer().getMap().spawnItemDrop(c.getPlayer(), c.getPlayer(), toDrop, c.getPlayer().getPosition(), true, true);
}
break;
} else {
player.yellowMessage("Pet Syntax: !item <itemid> <expiration>");
break;
}
}
if (sub[0].equals("item")) {
byte flag = 0;
if (player.gmLevel() < 3) {
flag |= ItemConstants.ACCOUNT_SHARING;
flag |= ItemConstants.UNTRADEABLE;
}
MapleInventoryManipulator.addById(c, itemId, quantity, player.getName(), -1, flag, -1);
} else {
Item toDrop;
if (ItemConstants.getInventoryType(itemId) == MapleInventoryType.EQUIP) {
toDrop = ii.getEquipById(itemId);
} else {
toDrop = new Item(itemId, (short) 0, quantity);
}
toDrop.setOwner(player.getName());
if (player.gmLevel() < 3) {
byte b = toDrop.getFlag();
b |= ItemConstants.ACCOUNT_SHARING;
b |= ItemConstants.UNTRADEABLE;
toDrop.setFlag(b);
}
c.getPlayer().getMap().spawnItemDrop(c.getPlayer(), c.getPlayer(), toDrop, c.getPlayer().getPosition(), true, true);
}
break;
case "level":
if (sub.length < 2) {
player.yellowMessage("Syntax: !level <newlevel>");
break;
}
player.loseExp(player.getExp(), false, false);
player.setLevel(Math.min(Integer.parseInt(sub[1]), player.getMaxClassLevel()) - 1);
player.resetPlayerRates();
if (ServerConstants.USE_ADD_RATES_BY_LEVEL == true)
player.setPlayerRates();
player.setWorldRates();
player.levelUp(false);
break;
case "levelpro":
if (sub.length < 2) {
player.yellowMessage("Syntax: !levelpro <newlevel>");
break;
}
while (player.getLevel() < Math.min(player.getMaxClassLevel(), Integer.parseInt(sub[1]))) {
player.levelUp(false);
}
break;
case "setstat":
if (sub.length < 2) {
player.yellowMessage("Syntax: !setstat <newstat>");
break;
}
int x;
try {
x = Integer.parseInt(sub[1]);
if (x > Short.MAX_VALUE)
x = Short.MAX_VALUE;
else if (x < 0)
x = 0;
player.setStr(x);
player.setDex(x);
player.setInt(x);
player.setLuk(x);
player.updateSingleStat(MapleStat.STR, x);
player.updateSingleStat(MapleStat.DEX, x);
player.updateSingleStat(MapleStat.INT, x);
player.updateSingleStat(MapleStat.LUK, x);
} catch (NumberFormatException nfe) {
}
break;
case "maxstat":
final String[] s = { "setstat", String.valueOf(Short.MAX_VALUE) };
executeHeavenMsCommandLv2(cserv, srv, c, s);
player.loseExp(player.getExp(), false, false);
player.setLevel(255);
player.resetPlayerRates();
if (ServerConstants.USE_ADD_RATES_BY_LEVEL == true)
player.setPlayerRates();
player.setWorldRates();
player.setFame(13337);
player.setMaxHp(30000);
player.setMaxMp(30000);
player.updateSingleStat(MapleStat.LEVEL, 255);
player.updateSingleStat(MapleStat.FAME, 13337);
player.updateSingleStat(MapleStat.MAXHP, 30000);
player.updateSingleStat(MapleStat.MAXMP, 30000);
player.yellowMessage("Stats maxed out.");
break;
case "maxskill":
for (MapleData skill_ : MapleDataProviderFactory.getDataProvider(new File(System.getProperty("wzpath") + "/" + "String.wz")).getData("Skill.img").getChildren()) {
try {
skill = SkillFactory.getSkill(Integer.parseInt(skill_.getName()));
player.changeSkillLevel(skill, (byte) skill.getMaxLevel(), skill.getMaxLevel(), -1);
} catch (NumberFormatException nfe) {
nfe.printStackTrace();
break;
} catch (NullPointerException npe) {
continue;
}
}
if (player.getJob().isA(MapleJob.ARAN1) || player.getJob().isA(MapleJob.LEGEND)) {
skill = SkillFactory.getSkill(5001005);
player.changeSkillLevel(skill, (byte) -1, -1, -1);
} else {
skill = SkillFactory.getSkill(21001001);
player.changeSkillLevel(skill, (byte) -1, -1, -1);
}
player.yellowMessage("Skills maxed out.");
break;
case "mesos":
if (sub.length >= 2) {
player.gainMeso(Integer.parseInt(sub[1]), true);
}
break;
case "search":
if (sub.length < 3) {
player.yellowMessage("Syntax: !search <type> <name>");
break;
}
StringBuilder sb = new StringBuilder();
String search = joinStringFrom(sub, 2);
// for the lulz
long start = System.currentTimeMillis();
MapleData data = null;
MapleDataProvider dataProvider = MapleDataProviderFactory.getDataProvider(new File("wz/String.wz"));
if (!sub[1].equalsIgnoreCase("ITEM")) {
if (sub[1].equalsIgnoreCase("NPC")) {
data = dataProvider.getData("Npc.img");
} else if (sub[1].equalsIgnoreCase("MOB") || sub[1].equalsIgnoreCase("MONSTER")) {
data = dataProvider.getData("Mob.img");
} else if (sub[1].equalsIgnoreCase("SKILL")) {
data = dataProvider.getData("Skill.img");
/*} else if (sub[1].equalsIgnoreCase("MAP")) {
TODO
*/
} else {
sb.append("#bInvalid search.\r\nSyntax: '!search [type] [name]', where [type] is NPC, ITEM, MOB, or SKILL.");
}
if (data != null) {
String name;
for (MapleData searchData : data.getChildren()) {
name = MapleDataTool.getString(searchData.getChildByPath("name"), "NO-NAME");
if (name.toLowerCase().contains(search.toLowerCase())) {
sb.append("#b").append(Integer.parseInt(searchData.getName())).append("#k - #r").append(name).append("\r\n");
}
}
}
} else {
for (Pair<Integer, String> itemPair : MapleItemInformationProvider.getInstance().getAllItems()) {
if (sb.length() < 32654) {
// ohlol
if (itemPair.getRight().toLowerCase().contains(search.toLowerCase())) {
// #v").append(id).append("# #k-
sb.append("#b").append(itemPair.getLeft()).append("#k - #r").append(itemPair.getRight()).append("\r\n");
}
} else {
sb.append("#bCouldn't load all items, there are too many results.\r\n");
break;
}
}
}
if (sb.length() == 0) {
sb.append("#bNo ").append(sub[1].toLowerCase()).append("s found.\r\n");
}
// because I can, and it's free
sb.append("\r\n#kLoaded within ").append((double) (System.currentTimeMillis() - start) / 1000).append(" seconds.");
c.announce(MaplePacketCreator.getNPCTalk(9010000, (byte) 0, sb.toString(), "00 00", (byte) 0));
break;
case "jail":
if (sub.length < 2) {
player.yellowMessage("Syntax: !jail <playername> [<minutes>]");
break;
}
int minutesJailed = 5;
if (sub.length >= 3) {
minutesJailed = Integer.valueOf(sub[2]);
if (minutesJailed <= 0) {
player.yellowMessage("Syntax: !jail <playername> [<minutes>]");
break;
}
}
victim = cserv.getPlayerStorage().getCharacterByName(sub[1]);
if (victim != null) {
victim.addJailExpirationTime(minutesJailed * 60 * 1000);
int mapid = 300000012;
if (victim.getMapId() != mapid) {
// those gone to jail won't be changing map anyway
MapleMap target = cserv.getMapFactory().getMap(mapid);
MaplePortal targetPortal = target.getPortal(0);
victim.changeMap(target, targetPortal);
player.message(victim.getName() + " was jailed for " + minutesJailed + " minutes.");
} else {
player.message(victim.getName() + "'s time in jail has been extended for " + minutesJailed + " minutes.");
}
} else {
player.message("Player '" + sub[1] + "' could not be found on this channel.");
}
break;
case "unjail":
if (sub.length < 2) {
player.yellowMessage("Syntax: !unjail <playername>");
break;
}
victim = cserv.getPlayerStorage().getCharacterByName(sub[1]);
if (victim != null) {
if (victim.getJailExpirationTimeLeft() <= 0) {
player.message("This player is already free.");
break;
}
victim.removeJailExpirationTime();
victim.message("By lack of concrete proof you are now unjailed. Enjoy freedom!");
player.message(victim.getName() + " was unjailed.");
} else {
player.message("Player '" + sub[1] + "' could not be found on this channel.");
}
break;
case "job":
if (sub.length == 2) {
int jobid = Integer.parseInt(sub[1]);
if (jobid < 0 || jobid >= 2200) {
player.message("Jobid " + jobid + " is not available.");
break;
}
player.changeJob(MapleJob.getById(jobid));
player.equipChanged();
} else if (sub.length == 3) {
victim = c.getChannelServer().getPlayerStorage().getCharacterByName(sub[1]);
if (victim != null) {
int jobid = Integer.parseInt(sub[2]);
if (jobid < 0 || jobid >= 2200) {
player.message("Jobid " + jobid + " is not available.");
break;
}
victim.changeJob(MapleJob.getById(jobid));
player.equipChanged();
} else {
player.message("Player '" + sub[1] + "' could not be found on this channel.");
}
} else {
player.message("Syntax: !job <job id> <opt: IGN of another person>");
}
break;
case "unbug":
c.getPlayer().getMap().broadcastMessage(MaplePacketCreator.enableActions());
break;
default:
return false;
}
return true;
}
use of org.powerbot.bot.rt6.client.Skill in project HeavenMS by ronancpl.
the class DistributeAPHandler method calcHpChange.
private static int calcHpChange(MapleCharacter player, MapleJob job, boolean usedAPReset) {
int MaxHP = 0;
if (job.isA(MapleJob.WARRIOR) || job.isA(MapleJob.DAWNWARRIOR1)) {
if (!usedAPReset) {
Skill increaseHP = SkillFactory.getSkill(job.isA(MapleJob.DAWNWARRIOR1) ? DawnWarrior.MAX_HP_INCREASE : Warrior.IMPROVED_MAXHP);
int sLvl = player.getSkillLevel(increaseHP);
if (sLvl > 0)
MaxHP += increaseHP.getEffect(sLvl).getY();
}
if (ServerConstants.USE_RANDOMIZE_HPMP_GAIN) {
if (usedAPReset) {
MaxHP += 20;
} else {
MaxHP += Randomizer.rand(18, 22);
}
} else {
MaxHP += 20;
}
} else if (job.isA(MapleJob.ARAN1)) {
if (ServerConstants.USE_RANDOMIZE_HPMP_GAIN) {
if (usedAPReset) {
MaxHP += 20;
} else {
MaxHP += Randomizer.rand(26, 30);
}
} else {
MaxHP += 28;
}
} else if (job.isA(MapleJob.MAGICIAN) || job.isA(MapleJob.BLAZEWIZARD1)) {
if (ServerConstants.USE_RANDOMIZE_HPMP_GAIN) {
if (usedAPReset) {
MaxHP += 6;
} else {
MaxHP += Randomizer.rand(5, 9);
}
} else {
MaxHP += 6;
}
} else if (job.isA(MapleJob.THIEF) || job.isA(MapleJob.NIGHTWALKER1)) {
if (ServerConstants.USE_RANDOMIZE_HPMP_GAIN) {
if (usedAPReset) {
MaxHP += 16;
} else {
MaxHP += Randomizer.rand(14, 18);
}
} else {
MaxHP += 16;
}
} else if (job.isA(MapleJob.BOWMAN) || job.isA(MapleJob.WINDARCHER1)) {
if (ServerConstants.USE_RANDOMIZE_HPMP_GAIN) {
if (usedAPReset) {
MaxHP += 16;
} else {
MaxHP += Randomizer.rand(14, 18);
}
} else {
MaxHP += 16;
}
} else if (job.isA(MapleJob.PIRATE) || job.isA(MapleJob.THUNDERBREAKER1)) {
if (!usedAPReset) {
Skill increaseHP = SkillFactory.getSkill(Brawler.IMPROVE_MAX_HP);
int sLvl = player.getSkillLevel(increaseHP);
if (sLvl > 0)
MaxHP += increaseHP.getEffect(sLvl).getY();
}
if (ServerConstants.USE_RANDOMIZE_HPMP_GAIN) {
if (usedAPReset) {
MaxHP += 18;
} else {
MaxHP += Randomizer.rand(16, 20);
}
} else {
MaxHP += 18;
}
} else if (usedAPReset) {
MaxHP += 8;
} else {
if (ServerConstants.USE_RANDOMIZE_HPMP_GAIN) {
MaxHP += Randomizer.rand(8, 12);
} else {
MaxHP += 10;
}
}
return MaxHP;
}
use of org.powerbot.bot.rt6.client.Skill in project HeavenMS by ronancpl.
the class SpecialMoveHandler method handlePacket.
@Override
public final void handlePacket(SeekableLittleEndianAccessor slea, MapleClient c) {
MapleCharacter chr = c.getPlayer();
chr.getAutobanManager().setTimestamp(4, slea.readInt(), 3);
int skillid = slea.readInt();
/*
if ((!GameConstants.isPqSkillMap(chr.getMapId()) && GameConstants.isPqSkill(skillid)) || (!chr.isGM() && GameConstants.isGMSkills(skillid)) || (!GameConstants.isInJobTree(skillid, chr.getJob().getId()) && !chr.isGM())) {
AutobanFactory.PACKET_EDIT.alert(chr, chr.getName() + " tried to packet edit skills.");
FilePrinter.printError(FilePrinter.EXPLOITS + chr.getName() + ".txt", chr.getName() + " tried to use skill " + skillid + " without it being in their job.\r\n");
c.disconnect(true, false);
return;
}
*/
Point pos = null;
int __skillLevel = slea.readByte();
Skill skill = SkillFactory.getSkill(skillid);
int skillLevel = chr.getSkillLevel(skill);
if (skillid % 10000000 == 1010 || skillid % 10000000 == 1011) {
if (chr.getDojoEnergy() < 10000) {
// PE hacking or maybe just lagging
return;
}
skillLevel = 1;
chr.setDojoEnergy(0);
c.announce(MaplePacketCreator.getEnergy("energy", chr.getDojoEnergy()));
c.announce(MaplePacketCreator.serverNotice(5, "As you used the secret skill, your energy bar has been reset."));
}
if (skillLevel == 0 || skillLevel != __skillLevel)
return;
MapleStatEffect effect = skill.getEffect(skillLevel);
if (effect.getCooldown() > 0) {
if (chr.skillIsCooling(skillid)) {
return;
} else if (skillid != Corsair.BATTLE_SHIP) {
c.announce(MaplePacketCreator.skillCooldown(skillid, effect.getCooldown()));
chr.addCooldown(skillid, System.currentTimeMillis(), effect.getCooldown() * 1000);
}
}
if (skillid == Hero.MONSTER_MAGNET || skillid == Paladin.MONSTER_MAGNET || skillid == DarkKnight.MONSTER_MAGNET) {
// Monster Magnet
int num = slea.readInt();
int mobId;
byte success;
for (int i = 0; i < num; i++) {
mobId = slea.readInt();
success = slea.readByte();
chr.getMap().broadcastMessage(chr, MaplePacketCreator.showMagnet(mobId, success), false);
MapleMonster monster = chr.getMap().getMonsterByOid(mobId);
if (monster != null) {
if (!monster.isBoss()) {
monster.switchController(chr, monster.isControllerHasAggro());
}
}
}
byte direction = slea.readByte();
chr.getMap().broadcastMessage(chr, MaplePacketCreator.showBuffeffect(chr.getId(), skillid, chr.getSkillLevel(skillid), direction), false);
c.announce(MaplePacketCreator.enableActions());
return;
} else if (skillid == Brawler.MP_RECOVERY) {
// MP Recovery
Skill s = SkillFactory.getSkill(skillid);
MapleStatEffect ef = s.getEffect(chr.getSkillLevel(s));
int lose = chr.getMaxHp() / ef.getX();
chr.setHp(chr.getHp() - lose);
chr.updateSingleStat(MapleStat.HP, chr.getHp());
int gain = lose * (ef.getY() / 100);
chr.setMp(chr.getMp() + gain);
chr.updateSingleStat(MapleStat.MP, chr.getMp());
} else if (skillid == Priest.DISPEL || skillid == SuperGM.HEAL_PLUS_DISPEL) {
slea.skip((skillid == Priest.DISPEL) ? 10 : 11);
chr.getMap().broadcastMessage(chr, MaplePacketCreator.showBuffeffect(chr.getId(), skillid, chr.getSkillLevel(skillid)), false);
} else if (skillid % 10000000 == 1004) {
slea.readShort();
}
if (slea.available() == 5) {
pos = new Point(slea.readShort(), slea.readShort());
}
if (chr.isAlive()) {
if (skill.getId() != Priest.MYSTIC_DOOR) {
skill.getEffect(skillLevel).applyTo(chr, pos);
} else if (chr.canDoor()) {
// update door lists
chr.cancelMagicDoor();
skill.getEffect(skillLevel).applyTo(chr, pos);
} else {
chr.message("Please wait 5 seconds before casting Mystic Door again.");
c.announce(MaplePacketCreator.enableActions());
}
} else {
c.announce(MaplePacketCreator.enableActions());
}
}
use of org.powerbot.bot.rt6.client.Skill in project HeavenMS by ronancpl.
the class SummonDamageHandler method handlePacket.
@Override
public void handlePacket(SeekableLittleEndianAccessor slea, MapleClient c) {
int oid = slea.readInt();
MapleCharacter player = c.getPlayer();
if (!player.isAlive()) {
return;
}
MapleSummon summon = null;
for (MapleSummon sum : player.getSummonsValues()) {
if (sum.getObjectId() == oid) {
summon = sum;
}
}
if (summon == null) {
return;
}
Skill summonSkill = SkillFactory.getSkill(summon.getSkill());
MapleStatEffect summonEffect = summonSkill.getEffect(summon.getSkillLevel());
slea.skip(4);
List<SummonAttackEntry> allDamage = new ArrayList<>();
byte direction = slea.readByte();
int numAttacked = slea.readByte();
// Thanks Gerald :D, I failed lol (mob x,y and summon x,y)
slea.skip(8);
for (int x = 0; x < numAttacked; x++) {
// attacked oid
int monsterOid = slea.readInt();
slea.skip(18);
int damage = slea.readInt();
allDamage.add(new SummonAttackEntry(monsterOid, damage));
}
player.getMap().broadcastMessage(player, MaplePacketCreator.summonAttack(player.getId(), summon.getObjectId(), direction, allDamage), summon.getPosition());
for (SummonAttackEntry attackEntry : allDamage) {
int damage = attackEntry.getDamage();
MapleMonster target = player.getMap().getMonsterByOid(attackEntry.getMonsterOid());
if (target != null) {
if (damage > 0 && summonEffect.getMonsterStati().size() > 0) {
if (summonEffect.makeChanceResult()) {
target.applyStatus(player, new MonsterStatusEffect(summonEffect.getMonsterStati(), summonSkill, null, false), summonEffect.isPoison(), 4000);
}
}
player.getMap().damageMonster(player, target, damage);
}
}
}
Aggregations