use of client.inventory.Equip in project HeavenMS by ronancpl.
the class PetAutoPotHandler method calcEffectivePool.
private Pair<Short, Short> calcEffectivePool(MapleCharacter chr) {
short hp = 0, mp = 0;
if (ServerConstants.USE_EQUIPS_ON_AUTOPOT) {
for (Item i : chr.getInventory(MapleInventoryType.EQUIPPED).list()) {
Equip e = (Equip) i;
hp += e.getHp();
mp += e.getMp();
}
}
hp = (short) Math.min(chr.getMaxHp() + hp, 30000);
mp = (short) Math.min(chr.getMaxMp() + mp, 30000);
return new Pair<>(hp, mp);
}
use of client.inventory.Equip in project HeavenMS by ronancpl.
the class ScrollHandler method handlePacket.
@Override
public final void handlePacket(SeekableLittleEndianAccessor slea, MapleClient c) {
// whatever...
slea.readInt();
short slot = slea.readShort();
short dst = slea.readShort();
byte ws = (byte) slea.readShort();
// white scroll being used?
boolean whiteScroll = false;
// legendary spirit skill
boolean legendarySpirit = false;
if ((ws & 2) == 2) {
whiteScroll = true;
}
MapleItemInformationProvider ii = MapleItemInformationProvider.getInstance();
Equip toScroll = (Equip) c.getPlayer().getInventory(MapleInventoryType.EQUIPPED).getItem(dst);
Skill LegendarySpirit = SkillFactory.getSkill(1003);
if (c.getPlayer().getSkillLevel(LegendarySpirit) > 0 && dst >= 0) {
legendarySpirit = true;
toScroll = (Equip) c.getPlayer().getInventory(MapleInventoryType.EQUIP).getItem(dst);
}
byte oldLevel = toScroll.getLevel();
byte oldSlots = toScroll.getUpgradeSlots();
MapleInventory useInventory = c.getPlayer().getInventory(MapleInventoryType.USE);
Item scroll = useInventory.getItem(slot);
Item wscroll = null;
if (((Equip) toScroll).getUpgradeSlots() < 1 && !ItemConstants.isCleanSlate(scroll.getItemId())) {
c.announce(MaplePacketCreator.getInventoryFull());
return;
}
List<Integer> scrollReqs = ii.getScrollReqs(scroll.getItemId());
if (scrollReqs.size() > 0 && !scrollReqs.contains(toScroll.getItemId())) {
c.announce(MaplePacketCreator.getInventoryFull());
return;
}
if (whiteScroll) {
wscroll = useInventory.findById(2340000);
if (wscroll == null || wscroll.getItemId() != 2340000) {
whiteScroll = false;
}
}
if (!ItemConstants.isChaosScroll(scroll.getItemId()) && !ItemConstants.isCleanSlate(scroll.getItemId())) {
if (!canScroll(scroll.getItemId(), toScroll.getItemId())) {
return;
}
}
if (ItemConstants.isCleanSlate(scroll.getItemId()) && !(toScroll.getLevel() + toScroll.getUpgradeSlots() < ii.getEquipStats(toScroll.getItemId()).get("tuc"))) {
// upgrade slots can be over because of hammers
return;
}
Equip scrolled = (Equip) ii.scrollEquipWithId(toScroll, scroll.getItemId(), whiteScroll, 0, c.getPlayer().isGM());
// fail
ScrollResult scrollSuccess = Equip.ScrollResult.FAIL;
if (scrolled == null) {
scrollSuccess = Equip.ScrollResult.CURSE;
} else if (scrolled.getLevel() > oldLevel || (ItemConstants.isCleanSlate(scroll.getItemId()) && scrolled.getUpgradeSlots() == oldSlots + 1) || ItemConstants.isFlagModifier(scroll.getItemId(), scrolled.getFlag())) {
scrollSuccess = Equip.ScrollResult.SUCCESS;
}
MapleInventoryManipulator.removeFromSlot(c, MapleInventoryType.USE, scroll.getPosition(), (short) 1, false);
if (whiteScroll && !ItemConstants.isCleanSlate(scroll.getItemId())) {
MapleInventoryManipulator.removeFromSlot(c, MapleInventoryType.USE, wscroll.getPosition(), (short) 1, false, false);
}
final List<ModifyInventory> mods = new ArrayList<>();
if (scrollSuccess == Equip.ScrollResult.CURSE) {
mods.add(new ModifyInventory(3, toScroll));
if (dst < 0) {
c.getPlayer().getInventory(MapleInventoryType.EQUIPPED).removeItem(toScroll.getPosition());
} else {
c.getPlayer().getInventory(MapleInventoryType.EQUIP).removeItem(toScroll.getPosition());
}
} else {
mods.add(new ModifyInventory(3, scrolled));
mods.add(new ModifyInventory(0, scrolled));
}
c.announce(MaplePacketCreator.modifyInventory(true, mods));
c.getPlayer().getMap().broadcastMessage(MaplePacketCreator.getScrollEffect(c.getPlayer().getId(), scrollSuccess, legendarySpirit));
if (dst < 0 && (scrollSuccess == Equip.ScrollResult.SUCCESS || scrollSuccess == Equip.ScrollResult.CURSE)) {
c.getPlayer().equipChanged();
}
}
use of client.inventory.Equip in project HeavenMS by ronancpl.
the class MapleMap method dropGlobalItemsFromMonsterOnMap.
private byte dropGlobalItemsFromMonsterOnMap(List<MonsterGlobalDropEntry> globalEntry, Point pos, byte d, byte droptype, int mobpos, MapleCharacter chr, MapleMonster mob) {
Collections.shuffle(globalEntry);
Item idrop;
MapleItemInformationProvider ii = MapleItemInformationProvider.getInstance();
for (final MonsterGlobalDropEntry de : globalEntry) {
if (Randomizer.nextInt(999999) < de.chance) {
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) {
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;
}
use of client.inventory.Equip 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