use of server.life.MonsterDropEntry in project HeavenMS by ronancpl.
the class MapleMap method dropFromMonster.
private void dropFromMonster(final MapleCharacter chr, final MapleMonster mob, final boolean useBaseRate) {
if (mob.dropsDisabled() || !dropsOn) {
return;
}
final byte droptype = (byte) (mob.getStats().isExplosiveReward() ? 3 : mob.getStats().isFfaLoot() ? 2 : chr.getParty() != null ? 1 : 0);
final int mobpos = mob.getPosition().x;
int chRate = chr.getDropRate();
byte d = 1;
Point pos = new Point(0, mob.getPosition().y);
MonsterStatusEffect stati = mob.getStati(MonsterStatus.SHOWDOWN);
if (stati != null) {
chRate *= (stati.getStati().get(MonsterStatus.SHOWDOWN).doubleValue() / 100.0 + 1.0);
}
if (useBaseRate)
chRate = 1;
final MapleMonsterInformationProvider mi = MapleMonsterInformationProvider.getInstance();
final List<MonsterDropEntry> dropEntry = new ArrayList<>();
final List<MonsterDropEntry> questEntry = new ArrayList<>();
sortDropEntries(mi.retrieveEffectiveDrop(mob.getId()), dropEntry, questEntry);
// Normal Drops
d = dropItemsFromMonsterOnMap(dropEntry, pos, d, chRate, droptype, mobpos, chr, mob);
// Global Drops
final List<MonsterGlobalDropEntry> globalEntry = mi.getGlobalDrop();
d = dropGlobalItemsFromMonsterOnMap(globalEntry, pos, d, droptype, mobpos, chr, mob);
// Quest Drops
dropItemsFromMonsterOnMap(questEntry, pos, d, chRate, droptype, mobpos, chr, mob);
}
use of server.life.MonsterDropEntry in project HeavenMS by ronancpl.
the class AbstractDealDamageHandler method applyAttack.
protected synchronized void applyAttack(AttackInfo attack, final MapleCharacter player, int attackCount) {
Skill theSkill = null;
MapleStatEffect attackEffect = null;
final int job = player.getJob().getId();
try {
if (player.isBanned()) {
return;
}
if (attack.skill != 0) {
// returns back the skill id if its not a hidden skill so we are gucci
theSkill = SkillFactory.getSkill(GameConstants.getHiddenSkill(attack.skill));
attackEffect = attack.getAttackEffect(player, theSkill);
if (attackEffect == null) {
player.getClient().announce(MaplePacketCreator.enableActions());
return;
}
if (player.getMp() < attackEffect.getMpCon()) {
AutobanFactory.MPCON.addPoint(player.getAutobanManager(), "Skill: " + attack.skill + "; Player MP: " + player.getMp() + "; MP Needed: " + attackEffect.getMpCon());
}
if (attack.skill != Cleric.HEAL) {
if (player.isAlive()) {
if (// Poison Bomb
attack.skill == NightWalker.POISON_BOMB)
attackEffect.applyTo(player, new Point(attack.position.x, attack.position.y));
else if (// prevent BP refreshing
attack.skill != Aran.BODY_PRESSURE)
attackEffect.applyTo(player);
} else {
player.getClient().announce(MaplePacketCreator.enableActions());
}
}
int mobCount = attackEffect.getMobCount();
if (attack.skill == DawnWarrior.FINAL_ATTACK || attack.skill == Page.FINAL_ATTACK_BW || attack.skill == Page.FINAL_ATTACK_SWORD || attack.skill == Fighter.FINAL_ATTACK_SWORD || attack.skill == Fighter.FINAL_ATTACK_AXE || attack.skill == Spearman.FINAL_ATTACK_SPEAR || attack.skill == Spearman.FINAL_ATTACK_POLEARM || attack.skill == WindArcher.FINAL_ATTACK || attack.skill == DawnWarrior.FINAL_ATTACK || attack.skill == Hunter.FINAL_ATTACK || attack.skill == Crossbowman.FINAL_ATTACK) {
// :(
mobCount = 15;
}
if (attack.skill == Aran.HIDDEN_FULL_DOUBLE || attack.skill == Aran.HIDDEN_FULL_TRIPLE || attack.skill == Aran.HIDDEN_OVER_DOUBLE || attack.skill == Aran.HIDDEN_OVER_TRIPLE) {
mobCount = 12;
}
if (attack.numAttacked > mobCount) {
AutobanFactory.MOB_COUNT.autoban(player, "Skill: " + attack.skill + "; Count: " + attack.numAttacked + " Max: " + attackEffect.getMobCount());
return;
}
}
if (!player.isAlive()) {
return;
}
// WTF IS THIS F3,1
/*if (attackCount != attack.numDamage && attack.skill != ChiefBandit.MESO_EXPLOSION && attack.skill != NightWalker.VAMPIRE && attack.skill != WindArcher.WIND_SHOT && attack.skill != Aran.COMBO_SMASH && attack.skill != Aran.COMBO_FENRIR && attack.skill != Aran.COMBO_TEMPEST && attack.skill != NightLord.NINJA_AMBUSH && attack.skill != Shadower.NINJA_AMBUSH) {
return;
}*/
int totDamage = 0;
final MapleMap map = player.getMap();
if (attack.skill == ChiefBandit.MESO_EXPLOSION) {
int delay = 0;
for (Integer oned : attack.allDamage.keySet()) {
MapleMapObject mapobject = map.getMapObject(oned.intValue());
if (mapobject != null && mapobject.getType() == MapleMapObjectType.ITEM) {
final MapleMapItem mapitem = (MapleMapItem) mapobject;
if (mapitem.getMeso() == 0) {
// Maybe it is possible some how?
return;
}
synchronized (mapitem) {
if (mapitem.isPickedUp()) {
return;
}
TimerManager.getInstance().schedule(new Runnable() {
@Override
public void run() {
map.pickItemDrop(MaplePacketCreator.removeItemFromMap(mapitem.getObjectId(), 4, 0), mapitem);
}
}, delay);
delay += 100;
}
} else if (mapobject != null && mapobject.getType() != MapleMapObjectType.MONSTER) {
return;
}
}
}
for (Integer oned : attack.allDamage.keySet()) {
final MapleMonster monster = map.getMonsterByOid(oned.intValue());
if (monster != null) {
double distance = player.getPosition().distanceSq(monster.getPosition());
double distanceToDetect = 200000.0;
if (attack.ranged)
distanceToDetect += 400000;
if (attack.magic)
distanceToDetect += 200000;
if (player.getJob().isA(MapleJob.ARAN1))
// Arans have extra range over normal warriors.
distanceToDetect += 200000;
if (attack.skill == Aran.COMBO_SMASH || attack.skill == Aran.BODY_PRESSURE)
distanceToDetect += 40000;
else if (attack.skill == Bishop.GENESIS || attack.skill == ILArchMage.BLIZZARD || attack.skill == FPArchMage.METEOR_SHOWER)
distanceToDetect += 275000;
else if (attack.skill == Hero.BRANDISH || attack.skill == DragonKnight.SPEAR_CRUSHER || attack.skill == DragonKnight.POLE_ARM_CRUSHER)
distanceToDetect += 40000;
else if (attack.skill == DragonKnight.DRAGON_ROAR || attack.skill == SuperGM.SUPER_DRAGON_ROAR)
distanceToDetect += 250000;
else if (attack.skill == Shadower.BOOMERANG_STEP)
distanceToDetect += 60000;
if (distance > distanceToDetect) {
AutobanFactory.DISTANCE_HACK.alert(player, "Distance Sq to monster: " + distance + " SID: " + attack.skill + " MID: " + monster.getId());
}
int totDamageToOneMonster = 0;
List<Integer> onedList = attack.allDamage.get(oned);
for (Integer eachd : onedList) {
if (eachd < 0)
eachd += Integer.MAX_VALUE;
totDamageToOneMonster += eachd;
}
totDamage += totDamageToOneMonster;
player.checkMonsterAggro(monster);
if (player.getBuffedValue(MapleBuffStat.PICKPOCKET) != null && (attack.skill == 0 || attack.skill == Rogue.DOUBLE_STAB || attack.skill == Bandit.SAVAGE_BLOW || attack.skill == ChiefBandit.ASSAULTER || attack.skill == ChiefBandit.BAND_OF_THIEVES || attack.skill == Shadower.ASSASSINATE || attack.skill == Shadower.TAUNT || attack.skill == Shadower.BOOMERANG_STEP)) {
Skill pickpocket = SkillFactory.getSkill(ChiefBandit.PICKPOCKET);
int picklv = (player.isGM()) ? pickpocket.getMaxLevel() : player.getSkillLevel(pickpocket);
if (picklv > 0) {
int delay = 0;
final int maxmeso = player.getBuffedValue(MapleBuffStat.PICKPOCKET).intValue();
for (Integer eachd : onedList) {
eachd += Integer.MAX_VALUE;
if (pickpocket.getEffect(picklv).makeChanceResult()) {
final Integer eachdf;
if (eachd < 0)
eachdf = eachd + Integer.MAX_VALUE;
else
eachdf = eachd;
TimerManager.getInstance().schedule(new Runnable() {
@Override
public void run() {
player.getMap().spawnMesoDrop(Math.min((int) Math.max(((double) eachdf / (double) 20000) * (double) maxmeso, (double) 1), maxmeso), new Point((int) (monster.getPosition().getX() + Randomizer.nextInt(100) - 50), (int) (monster.getPosition().getY())), monster, player, true, (byte) 2);
}
}, delay);
delay += 100;
}
}
}
} else if (attack.skill == Marauder.ENERGY_DRAIN || attack.skill == ThunderBreaker.ENERGY_DRAIN || attack.skill == NightWalker.VAMPIRE || attack.skill == Assassin.DRAIN) {
player.addHP(Math.min(monster.getMaxHp(), Math.min((int) ((double) totDamage * (double) SkillFactory.getSkill(attack.skill).getEffect(player.getSkillLevel(SkillFactory.getSkill(attack.skill))).getX() / 100.0), player.getMaxHp() / 2)));
} else if (attack.skill == Bandit.STEAL) {
Skill steal = SkillFactory.getSkill(Bandit.STEAL);
if (monster.getStolen().size() < 1) {
// One steal per mob <3
if (steal.getEffect(player.getSkillLevel(steal)).makeChanceResult()) {
MapleMonsterInformationProvider mi = MapleMonsterInformationProvider.getInstance();
List<Integer> dropPool = mi.retrieveDropPool(monster.getId());
if (!dropPool.isEmpty()) {
Integer rndPool = (int) Math.floor(Math.random() * dropPool.get(dropPool.size() - 1));
int i = 0;
while (rndPool >= dropPool.get(i)) i++;
List<MonsterDropEntry> toSteal = new ArrayList<>();
toSteal.add(mi.retrieveDrop(monster.getId()).get(i));
player.getMap().dropItemsFromMonster(toSteal, player, monster);
monster.addStolen(toSteal.get(0).itemId);
}
}
}
} else if (attack.skill == FPArchMage.FIRE_DEMON) {
monster.setTempEffectiveness(Element.ICE, ElementalEffectiveness.WEAK, SkillFactory.getSkill(FPArchMage.FIRE_DEMON).getEffect(player.getSkillLevel(SkillFactory.getSkill(FPArchMage.FIRE_DEMON))).getDuration() * 1000);
} else if (attack.skill == ILArchMage.ICE_DEMON) {
monster.setTempEffectiveness(Element.FIRE, ElementalEffectiveness.WEAK, SkillFactory.getSkill(ILArchMage.ICE_DEMON).getEffect(player.getSkillLevel(SkillFactory.getSkill(ILArchMage.ICE_DEMON))).getDuration() * 1000);
} else if (attack.skill == Outlaw.HOMING_BEACON || attack.skill == Corsair.BULLSEYE) {
player.setMarkedMonster(monster.getObjectId());
player.announce(MaplePacketCreator.giveBuff(1, attack.skill, Collections.singletonList(new Pair<>(MapleBuffStat.HOMING_BEACON, monster.getObjectId()))));
}
if (job == 2111 || job == 2112) {
if (player.getBuffedValue(MapleBuffStat.WK_CHARGE) != null) {
Skill snowCharge = SkillFactory.getSkill(Aran.SNOW_CHARGE);
if (totDamageToOneMonster > 0) {
MonsterStatusEffect monsterStatusEffect = new MonsterStatusEffect(Collections.singletonMap(MonsterStatus.SPEED, snowCharge.getEffect(player.getSkillLevel(snowCharge)).getX()), snowCharge, null, false);
monster.applyStatus(player, monsterStatusEffect, false, snowCharge.getEffect(player.getSkillLevel(snowCharge)).getY() * 1000);
}
}
}
if (player.getBuffedValue(MapleBuffStat.HAMSTRING) != null) {
Skill hamstring = SkillFactory.getSkill(Bowmaster.HAMSTRING);
if (hamstring.getEffect(player.getSkillLevel(hamstring)).makeChanceResult()) {
MonsterStatusEffect monsterStatusEffect = new MonsterStatusEffect(Collections.singletonMap(MonsterStatus.SPEED, hamstring.getEffect(player.getSkillLevel(hamstring)).getX()), hamstring, null, false);
monster.applyStatus(player, monsterStatusEffect, false, hamstring.getEffect(player.getSkillLevel(hamstring)).getY() * 1000);
}
}
if (player.getBuffedValue(MapleBuffStat.SLOW) != null) {
Skill slow = SkillFactory.getSkill(Evan.SLOW);
if (slow.getEffect(player.getSkillLevel(slow)).makeChanceResult()) {
MonsterStatusEffect monsterStatusEffect = new MonsterStatusEffect(Collections.singletonMap(MonsterStatus.SPEED, slow.getEffect(player.getSkillLevel(slow)).getX()), slow, null, false);
monster.applyStatus(player, monsterStatusEffect, false, slow.getEffect(player.getSkillLevel(slow)).getY() * 60 * 1000);
}
}
if (player.getBuffedValue(MapleBuffStat.BLIND) != null) {
Skill blind = SkillFactory.getSkill(Marksman.BLIND);
if (blind.getEffect(player.getSkillLevel(blind)).makeChanceResult()) {
MonsterStatusEffect monsterStatusEffect = new MonsterStatusEffect(Collections.singletonMap(MonsterStatus.ACC, blind.getEffect(player.getSkillLevel(blind)).getX()), blind, null, false);
monster.applyStatus(player, monsterStatusEffect, false, blind.getEffect(player.getSkillLevel(blind)).getY() * 1000);
}
}
if (job == 121 || job == 122) {
for (int charge = 1211005; charge < 1211007; charge++) {
Skill chargeSkill = SkillFactory.getSkill(charge);
if (player.isBuffFrom(MapleBuffStat.WK_CHARGE, chargeSkill)) {
if (totDamageToOneMonster > 0) {
if (charge == WhiteKnight.BW_ICE_CHARGE || charge == WhiteKnight.SWORD_ICE_CHARGE) {
monster.setTempEffectiveness(Element.ICE, ElementalEffectiveness.WEAK, chargeSkill.getEffect(player.getSkillLevel(chargeSkill)).getY() * 1000);
break;
}
if (charge == WhiteKnight.BW_FIRE_CHARGE || charge == WhiteKnight.SWORD_FIRE_CHARGE) {
monster.setTempEffectiveness(Element.FIRE, ElementalEffectiveness.WEAK, chargeSkill.getEffect(player.getSkillLevel(chargeSkill)).getY() * 1000);
break;
}
}
}
}
if (job == 122) {
for (int charge = 1221003; charge < 1221004; charge++) {
Skill chargeSkill = SkillFactory.getSkill(charge);
if (player.isBuffFrom(MapleBuffStat.WK_CHARGE, chargeSkill)) {
if (totDamageToOneMonster > 0) {
monster.setTempEffectiveness(Element.HOLY, ElementalEffectiveness.WEAK, chargeSkill.getEffect(player.getSkillLevel(chargeSkill)).getY() * 1000);
break;
}
}
}
}
} else if (player.getBuffedValue(MapleBuffStat.COMBO_DRAIN) != null) {
Skill skill;
if (player.getBuffedValue(MapleBuffStat.COMBO_DRAIN) != null) {
skill = SkillFactory.getSkill(21100005);
player.setHp(player.getHp() + ((totDamage * skill.getEffect(player.getSkillLevel(skill)).getX()) / 100), true);
player.updateSingleStat(MapleStat.HP, player.getHp());
}
} else if (job == 412 || job == 422 || job == 1411) {
Skill type = SkillFactory.getSkill(player.getJob().getId() == 412 ? 4120005 : (player.getJob().getId() == 1411 ? 14110004 : 4220005));
if (player.getSkillLevel(type) > 0) {
MapleStatEffect venomEffect = type.getEffect(player.getSkillLevel(type));
for (int i = 0; i < attackCount; i++) {
if (venomEffect.makeChanceResult()) {
if (monster.getVenomMulti() < 3) {
monster.setVenomMulti((monster.getVenomMulti() + 1));
MonsterStatusEffect monsterStatusEffect = new MonsterStatusEffect(Collections.singletonMap(MonsterStatus.POISON, 1), type, null, false);
monster.applyStatus(player, monsterStatusEffect, false, venomEffect.getDuration(), true);
}
}
}
}
} else if (job == 521 || job == 522) {
// from what I can gather this is how it should work
if (!monster.isBoss()) {
Skill type = SkillFactory.getSkill(Outlaw.FLAME_THROWER);
if (player.getSkillLevel(type) > 0) {
MapleStatEffect DoT = type.getEffect(player.getSkillLevel(type));
MonsterStatusEffect monsterStatusEffect = new MonsterStatusEffect(Collections.singletonMap(MonsterStatus.POISON, 1), type, null, false);
monster.applyStatus(player, monsterStatusEffect, true, DoT.getDuration(), false);
}
}
} else if (job >= 311 && job <= 322) {
if (!monster.isBoss()) {
Skill mortalBlow;
if (job == 311 || job == 312) {
mortalBlow = SkillFactory.getSkill(Ranger.MORTAL_BLOW);
} else {
mortalBlow = SkillFactory.getSkill(Sniper.MORTAL_BLOW);
}
if (player.getSkillLevel(mortalBlow) > 0) {
MapleStatEffect mortal = mortalBlow.getEffect(player.getSkillLevel(mortalBlow));
if (monster.getHp() <= (monster.getStats().getHp() * mortal.getX()) / 100) {
if (Randomizer.rand(1, 100) <= mortal.getY()) {
monster.getMap().killMonster(monster, player, true);
}
}
}
}
}
if (attack.skill != 0) {
if (attackEffect.getFixDamage() != -1) {
if (totDamageToOneMonster != attackEffect.getFixDamage() && totDamageToOneMonster != 0) {
AutobanFactory.FIX_DAMAGE.autoban(player, String.valueOf(totDamageToOneMonster) + " damage");
}
if (ServerConstants.USE_ULTRA_THREE_SNAILS) {
AbstractPlayerInteraction api = player.getClient().getAbstractPlayerInteraction();
int shellId;
switch(totDamageToOneMonster) {
case 10:
shellId = 4000019;
break;
case 25:
shellId = 4000000;
break;
default:
shellId = 4000016;
}
if (api.haveItem(shellId, 1)) {
api.gainItem(shellId, (short) -1, false);
totDamageToOneMonster *= player.getLevel();
} else {
player.dropMessage(5, "You ran out of shells to activate the hidden power of Three Snails.");
}
}
}
}
if (totDamageToOneMonster > 0 && attackEffect != null && attackEffect.getMonsterStati().size() > 0) {
if (attackEffect.makeChanceResult()) {
monster.applyStatus(player, new MonsterStatusEffect(attackEffect.getMonsterStati(), theSkill, null, false), attackEffect.isPoison(), attackEffect.getDuration());
}
}
if (attack.isHH && !monster.isBoss()) {
map.damageMonster(player, monster, monster.getHp() - 1);
} else if (attack.isHH) {
int HHDmg = (player.calculateMaxBaseDamage(player.getTotalWatk()) * (SkillFactory.getSkill(Paladin.HEAVENS_HAMMER).getEffect(player.getSkillLevel(SkillFactory.getSkill(Paladin.HEAVENS_HAMMER))).getDamage() / 100));
map.damageMonster(player, monster, (int) (Math.floor(Math.random() * (HHDmg / 5) + HHDmg * .8)));
} else if (attack.isTempest && !monster.isBoss()) {
map.damageMonster(player, monster, monster.getHp());
} else if (attack.isTempest) {
int TmpDmg = (player.calculateMaxBaseDamage(player.getTotalWatk()) * (SkillFactory.getSkill(Aran.COMBO_TEMPEST).getEffect(player.getSkillLevel(SkillFactory.getSkill(Aran.COMBO_TEMPEST))).getDamage() / 100));
map.damageMonster(player, monster, (int) (Math.floor(Math.random() * (TmpDmg / 5) + TmpDmg * .8)));
} else {
map.damageMonster(player, monster, totDamageToOneMonster);
}
if (monster.isBuffed(MonsterStatus.WEAPON_REFLECT)) {
for (int i = 0; i < monster.getSkills().size(); i++) {
if (monster.getSkills().get(i).left == 145) {
MobSkill toUse = MobSkillFactory.getMobSkill(monster.getSkills().get(i).left, monster.getSkills().get(i).right);
player.addHP(-toUse.getX());
map.broadcastMessage(player, MaplePacketCreator.damagePlayer(0, monster.getId(), player.getId(), toUse.getX(), 0, 0, false, 0, true, monster.getObjectId(), 0, 0), true);
}
}
}
if (monster.isBuffed(MonsterStatus.MAGIC_REFLECT)) {
for (int i = 0; i < monster.getSkills().size(); i++) {
if (monster.getSkills().get(i).left == 145) {
MobSkill toUse = MobSkillFactory.getMobSkill(monster.getSkills().get(i).left, monster.getSkills().get(i).right);
player.addMP(-toUse.getY());
}
}
}
}
}
} catch (Exception e) {
e.printStackTrace();
}
}
use of server.life.MonsterDropEntry in project HeavenMS by ronancpl.
the class Commands method executeHeavenMsCommandLv0.
public static boolean executeHeavenMsCommandLv0(Channel cserv, Server srv, MapleClient c, String[] sub) {
// Player
MapleCharacter player = c.getPlayer();
switch(sub[0]) {
case "help":
case "commands":
case "playercommands":
c.getAbstractPlayerInteraction().openNpc(9201143, "commands");
break;
case "droplimit":
int dropCount = c.getPlayer().getMap().getDroppedItemCount();
if (((float) dropCount) / ServerConstants.ITEM_LIMIT_ON_MAP < 0.75f) {
c.getPlayer().showHint("Current drop count: #b" + dropCount + "#k / #e" + ServerConstants.ITEM_LIMIT_ON_MAP + "#n", 300);
} else {
c.getPlayer().showHint("Current drop count: #r" + dropCount + "#k / #e" + ServerConstants.ITEM_LIMIT_ON_MAP + "#n", 300);
}
break;
case "time":
DateFormat dateFormat = new SimpleDateFormat("HH:mm:ss");
dateFormat.setTimeZone(TimeZone.getTimeZone(ServerConstants.TIMEZONE));
player.yellowMessage("Solaxia Server Time: " + dateFormat.format(new Date()));
break;
case "credits":
case "staff":
c.getAbstractPlayerInteraction().openNpc(2010007, "credits");
break;
case "lastrestart":
case "uptime":
long milliseconds = System.currentTimeMillis() - Server.uptime;
int seconds = (int) (milliseconds / 1000) % 60;
int minutes = (int) ((milliseconds / (1000 * 60)) % 60);
int hours = (int) ((milliseconds / (1000 * 60 * 60)) % 24);
int days = (int) ((milliseconds / (1000 * 60 * 60 * 24)));
player.yellowMessage("Server has been online for " + days + " days " + hours + " hours " + minutes + " minutes and " + seconds + " seconds.");
break;
case "gacha":
Gachapon gacha = null;
String search = joinStringFrom(sub, 1);
String gachaName = "";
String[] names = { "Henesys", "Ellinia", "Perion", "Kerning City", "Sleepywood", "Mushroom Shrine", "Showa Spa Male", "Showa Spa Female", "New Leaf City", "Nautilus Harbor" };
int[] ids = { 9100100, 9100101, 9100102, 9100103, 9100104, 9100105, 9100106, 9100107, 9100109, 9100117 };
for (int i = 0; i < names.length; i++) {
if (search.equalsIgnoreCase(names[i])) {
gachaName = names[i];
gacha = Gachapon.getByNpcId(ids[i]);
}
}
if (gacha == null) {
player.yellowMessage("Please use @gacha <name> where name corresponds to one of the below:");
for (String name : names) {
player.yellowMessage(name);
}
break;
}
String output = "The #b" + gachaName + "#k Gachapon contains the following items.\r\n\r\n";
for (int i = 0; i < 2; i++) {
for (int id : gacha.getItems(i)) {
output += "-" + MapleItemInformationProvider.getInstance().getName(id) + "\r\n";
}
}
output += "\r\nPlease keep in mind that there are items that are in all gachapons and are not listed here.";
c.announce(MaplePacketCreator.getNPCTalk(9010000, (byte) 0, output, "00 00", (byte) 0));
break;
case "whatdropsfrom":
if (sub.length < 2) {
player.dropMessage(5, "Please do @whatdropsfrom <monster name>");
break;
}
String monsterName = joinStringFrom(sub, 1);
output = "";
int limit = 3;
Iterator<Pair<Integer, String>> listIterator = MapleMonsterInformationProvider.getMobsIDsFromName(monsterName).iterator();
for (int i = 0; i < limit; i++) {
if (listIterator.hasNext()) {
Pair<Integer, String> data = listIterator.next();
int mobId = data.getLeft();
String mobName = data.getRight();
output += mobName + " drops the following items:\r\n\r\n";
for (MonsterDropEntry drop : MapleMonsterInformationProvider.getInstance().retrieveDrop(mobId)) {
try {
String name = MapleItemInformationProvider.getInstance().getName(drop.itemId);
if (name.equals("null") || drop.chance == 0) {
continue;
}
float chance = 1000000 / drop.chance / player.getDropRate();
output += "- " + name + " (1/" + (int) chance + ")\r\n";
} catch (Exception ex) {
ex.printStackTrace();
continue;
}
}
output += "\r\n";
}
}
c.announce(MaplePacketCreator.getNPCTalk(9010000, (byte) 0, output, "00 00", (byte) 0));
break;
case "whodrops":
if (sub.length < 2) {
player.dropMessage(5, "Please do @whodrops <item name>");
break;
}
String searchString = joinStringFrom(sub, 1);
output = "";
listIterator = MapleItemInformationProvider.getInstance().getItemDataByName(searchString).iterator();
if (listIterator.hasNext()) {
int count = 1;
while (listIterator.hasNext() && count <= 3) {
Pair<Integer, String> data = listIterator.next();
output += "#b" + data.getRight() + "#k is dropped by:\r\n";
try {
Connection con = DatabaseConnection.getConnection();
PreparedStatement ps = con.prepareStatement("SELECT dropperid FROM drop_data WHERE itemid = ? LIMIT 50");
ps.setInt(1, data.getLeft());
ResultSet rs = ps.executeQuery();
while (rs.next()) {
String resultName = MapleMonsterInformationProvider.getMobNameFromID(rs.getInt("dropperid"));
if (resultName != null) {
output += resultName + ", ";
}
}
rs.close();
ps.close();
con.close();
} catch (Exception e) {
player.dropMessage(6, "There was a problem retrieving the required data. Please try again.");
e.printStackTrace();
break;
}
output += "\r\n\r\n";
count++;
}
} else {
player.dropMessage(5, "The item you searched for doesn't exist.");
break;
}
c.announce(MaplePacketCreator.getNPCTalk(9010000, (byte) 0, output, "00 00", (byte) 0));
break;
case "dispose":
NPCScriptManager.getInstance().dispose(c);
c.announce(MaplePacketCreator.enableActions());
c.removeClickedNPC();
player.message("You've been disposed.");
break;
case "equiplv":
player.showAllEquipFeatures();
break;
case "showrates":
String showMsg = "#eEXP RATE#n" + "\r\n";
showMsg += "Server EXP Rate: #k" + c.getWorldServer().getExpRate() + "x#k" + "\r\n";
showMsg += "Player EXP Rate: #k" + player.getRawExpRate() + "x#k" + "\r\n";
if (player.getCouponExpRate() != 1)
showMsg += "Coupon EXP Rate: #k" + player.getCouponExpRate() + "x#k" + "\r\n";
showMsg += "EXP Rate: #e#b" + player.getExpRate() + "x#k#n" + "\r\n";
showMsg += "\r\n" + "#eMESO RATE#n" + "\r\n";
showMsg += "Server MESO Rate: #k" + c.getWorldServer().getMesoRate() + "x#k" + "\r\n";
showMsg += "Player MESO Rate: #k" + player.getRawMesoRate() + "x#k" + "\r\n";
if (player.getCouponMesoRate() != 1)
showMsg += "Coupon MESO Rate: #k" + player.getCouponMesoRate() + "x#k" + "\r\n";
showMsg += "MESO Rate: #e#b" + player.getMesoRate() + "x#k#n" + "\r\n";
showMsg += "\r\n" + "#eDROP RATE#n" + "\r\n";
showMsg += "Server DROP Rate: #k" + c.getWorldServer().getDropRate() + "x#k" + "\r\n";
showMsg += "Player DROP Rate: #k" + player.getRawDropRate() + "x#k" + "\r\n";
if (player.getCouponDropRate() != 1)
showMsg += "Coupon DROP Rate: #k" + player.getCouponDropRate() + "x#k" + "\r\n";
showMsg += "DROP Rate: #e#b" + player.getDropRate() + "x#k#n" + "\r\n";
if (ServerConstants.USE_QUEST_RATE) {
showMsg += "\r\n" + "#eQUEST RATE#n" + "\r\n";
showMsg += "Server QUEST Rate: #e#b" + c.getWorldServer().getQuestRate() + "x#k#n" + "\r\n";
}
player.showHint(showMsg, 300);
break;
case "rates":
String showMsg_ = "#eCHARACTER RATES#n" + "\r\n\r\n";
showMsg_ += "EXP Rate: #e#b" + player.getExpRate() + "x#k#n" + "\r\n";
showMsg_ += "MESO Rate: #e#b" + player.getMesoRate() + "x#k#n" + "\r\n";
showMsg_ += "DROP Rate: #e#b" + player.getDropRate() + "x#k#n" + "\r\n";
if (ServerConstants.USE_QUEST_RATE)
showMsg_ += "QUEST Rate: #e#b" + c.getWorldServer().getQuestRate() + "x#k#n" + "\r\n";
player.showHint(showMsg_, 300);
break;
case "online":
for (Channel ch : Server.getInstance().getChannelsFromWorld(player.getWorld())) {
player.yellowMessage("Players in Channel " + ch.getId() + ":");
for (MapleCharacter chr : ch.getPlayerStorage().getAllCharacters()) {
if (!chr.isGM()) {
player.message(" >> " + MapleCharacter.makeMapleReadable(chr.getName()) + " is at " + chr.getMap().getMapName() + ".");
}
}
}
break;
case "gm":
if (sub.length < 3) {
// #goodbye 'hi'
player.dropMessage(5, "Your message was too short. Please provide as much detail as possible.");
break;
}
String message = joinStringFrom(sub, 1);
Server.getInstance().broadcastGMMessage(c.getWorld(), MaplePacketCreator.sendYellowTip("[GM MESSAGE]:" + MapleCharacter.makeMapleReadable(player.getName()) + ": " + message));
Server.getInstance().broadcastGMMessage(c.getWorld(), MaplePacketCreator.serverNotice(1, message));
FilePrinter.printError("gm.txt", MapleCharacter.makeMapleReadable(player.getName()) + ": " + message + "\r\n");
player.dropMessage(5, "Your message '" + message + "' was sent to GMs.");
player.dropMessage(5, tips[Randomizer.nextInt(tips.length)]);
break;
case "bug":
if (sub.length < 2) {
player.dropMessage(5, "Message too short and not sent. Please do @bug <bug>");
break;
}
message = joinStringFrom(sub, 1);
Server.getInstance().broadcastGMMessage(c.getWorld(), MaplePacketCreator.sendYellowTip("[BUG]:" + MapleCharacter.makeMapleReadable(player.getName()) + ": " + message));
Server.getInstance().broadcastGMMessage(c.getWorld(), MaplePacketCreator.serverNotice(1, message));
FilePrinter.printError("bug.txt", MapleCharacter.makeMapleReadable(player.getName()) + ": " + message + "\r\n");
player.dropMessage(5, "Your bug '" + message + "' was submitted successfully to our developers. Thank you!");
break;
/*
case "points":
player.dropMessage(5, "You have " + c.getVotePoints() + " vote point(s).");
if (c.hasVotedAlready()) {
Date currentDate = new Date();
int time = (int) ((int) 86400 - ((currentDate.getTime() / 1000) - c.getVoteTime())); //ugly as fuck
hours = time / 3600;
minutes = time % 3600 / 60;
seconds = time % 3600 % 60;
player.yellowMessage("You have already voted. You can vote again in " + hours + " hours, " + minutes + " minutes, " + seconds + " seconds.");
} else {
player.yellowMessage("You are free to vote! Make sure to vote to gain a vote point!");
}
break;
*/
case "joinevent":
if (!FieldLimit.CANNOTMIGRATE.check(player.getMap().getFieldLimit())) {
MapleEvent event = c.getChannelServer().getEvent();
if (event != null) {
if (event.getMapId() != player.getMapId()) {
if (event.getLimit() > 0) {
player.saveLocation("EVENT");
if (event.getMapId() == 109080000 || event.getMapId() == 109060001)
player.setTeam(event.getLimit() % 2);
event.minusLimit();
player.changeMap(event.getMapId());
} else {
player.dropMessage(5, "The limit of players for the event has already been reached.");
}
} else {
player.dropMessage(5, "You are already in the event.");
}
} else {
player.dropMessage(5, "There is currently no event in progress.");
}
} else {
player.dropMessage(5, "You are currently in a map where you can't join an event.");
}
break;
case "leaveevent":
int returnMap = player.getSavedLocation("EVENT");
if (returnMap != -1) {
if (player.getOla() != null) {
player.getOla().resetTimes();
player.setOla(null);
}
if (player.getFitness() != null) {
player.getFitness().resetTimes();
player.setFitness(null);
}
player.changeMap(returnMap);
if (c.getChannelServer().getEvent() != null) {
c.getChannelServer().getEvent().addLimit();
}
} else {
player.dropMessage(5, "You are not currently in an event.");
}
break;
case "bosshp":
for (MapleMonster monster : player.getMap().getMonsters()) {
if (monster != null && monster.isBoss() && monster.getHp() > 0) {
long percent = monster.getHp() * 100L / monster.getMaxHp();
String bar = "[";
for (int i = 0; i < 100; i++) {
bar += i < percent ? "|" : ".";
}
bar += "]";
player.yellowMessage(monster.getName() + " (" + monster.getId() + ") has " + percent + "% HP left.");
player.yellowMessage("HP: " + bar);
}
}
break;
case "ranks":
PreparedStatement ps = null;
ResultSet rs = null;
Connection con = null;
try {
con = DatabaseConnection.getConnection();
ps = con.prepareStatement("SELECT `characters`.`name`, `characters`.`level` FROM `characters` LEFT JOIN accounts ON accounts.id = characters.accountid WHERE `characters`.`gm` = '0' AND `accounts`.`banned` = '0' ORDER BY level DESC, exp DESC LIMIT 50");
rs = ps.executeQuery();
player.announce(MaplePacketCreator.showPlayerRanks(9010000, rs));
ps.close();
rs.close();
con.close();
} catch (SQLException ex) {
ex.printStackTrace();
} finally {
try {
if (ps != null && !ps.isClosed()) {
ps.close();
}
if (rs != null && !rs.isClosed()) {
rs.close();
}
if (con != null && !con.isClosed()) {
con.close();
}
} catch (SQLException e) {
e.printStackTrace();
}
}
break;
default:
return false;
}
return true;
}
use of server.life.MonsterDropEntry in project HeavenMS by ronancpl.
the class MapleMap method dropItemsFromMonsterOnMap.
private byte dropItemsFromMonsterOnMap(List<MonsterDropEntry> dropEntry, Point pos, byte d, int chRate, byte droptype, int mobpos, MapleCharacter chr, MapleMonster mob) {
if (dropEntry.isEmpty()) {
return d;
}
Collections.shuffle(dropEntry);
Item idrop;
MapleItemInformationProvider ii = MapleItemInformationProvider.getInstance();
for (final MonsterDropEntry de : dropEntry) {
if (Randomizer.nextInt(999999) < (long) de.chance * chRate) {
if (droptype == 3) {
pos.x = (int) (mobpos + ((d % 2 == 0) ? (40 * ((d + 1) / 2)) : -(40 * (d / 2))));
} else {
pos.x = (int) (mobpos + ((d % 2 == 0) ? (25 * ((d + 1) / 2)) : -(25 * (d / 2))));
}
if (de.itemId == 0) {
// meso
int mesos = Randomizer.nextInt(de.Maximum - de.Minimum) + de.Minimum;
if (mesos > 0) {
if (chr.getBuffedValue(MapleBuffStat.MESOUP) != null) {
mesos = (int) (mesos * chr.getBuffedValue(MapleBuffStat.MESOUP).doubleValue() / 100.0);
}
mesos = mesos * chr.getMesoRate();
if (mesos <= 0)
mesos = Integer.MAX_VALUE;
spawnMesoDrop(mesos, calcDropPos(pos, mob.getPosition()), mob, chr, false, droptype);
}
} else {
if (ItemConstants.getInventoryType(de.itemId) == MapleInventoryType.EQUIP) {
idrop = ii.randomizeStats((Equip) ii.getEquipById(de.itemId));
} else {
idrop = new Item(de.itemId, (short) 0, (short) (de.Maximum != 1 ? Randomizer.nextInt(de.Maximum - de.Minimum) + de.Minimum : 1));
}
spawnDrop(idrop, calcDropPos(pos, mob.getPosition()), mob, chr, droptype, de.questid);
}
d++;
}
}
return d;
}
Aggregations