use of client.inventory.Item in project HeavenMS by ronancpl.
the class MapleItemInformationProvider method canWearEquipment.
public Collection<Item> canWearEquipment(MapleCharacter chr, Collection<Item> items) {
MapleInventory inv = chr.getInventory(MapleInventoryType.EQUIPPED);
if (inv.checked()) {
return items;
}
Collection<Item> itemz = new LinkedList<>();
if (chr.getJob() == MapleJob.SUPERGM || chr.getJob() == MapleJob.GM) {
for (Item item : items) {
Equip equip = (Equip) item;
equip.wear(true);
itemz.add(item);
}
return itemz;
}
boolean highfivestamp = false;
/* Removed because players shouldn't even get this, and gm's should just be gm job.
try {
for (Pair<Item, MapleInventoryType> ii : ItemFactory.INVENTORY.loadItems(chr.getId(), false)) {
if (ii.getRight() == MapleInventoryType.CASH) {
if (ii.getLeft().getItemId() == 5590000) {
highfivestamp = true;
}
}
}
} catch (SQLException ex) {
ex.printStackTrace();
}*/
int tdex = chr.getDex(), tstr = chr.getStr(), tint = chr.getInt(), tluk = chr.getLuk(), fame = chr.getFame();
if (chr.getJob() != MapleJob.SUPERGM || chr.getJob() != MapleJob.GM) {
for (Item item : inv.list()) {
Equip equip = (Equip) item;
tdex += equip.getDex();
tstr += equip.getStr();
tluk += equip.getLuk();
tint += equip.getInt();
}
}
for (Item item : items) {
Equip equip = (Equip) item;
int reqLevel = getEquipStats(equip.getItemId()).get("reqLevel");
if (highfivestamp) {
reqLevel -= 5;
if (reqLevel < 0) {
reqLevel = 0;
}
}
/*
int reqJob = getEquipStats(equip.getItemId()).get("reqJob");
if (reqJob != 0) {
Really hard check, and not really needed in this one
Gm's should just be GM job, and players cannot change jobs.
}*/
if (reqLevel > chr.getLevel()) {
continue;
} else if (getEquipStats(equip.getItemId()).get("reqDEX") > tdex) {
continue;
} else if (getEquipStats(equip.getItemId()).get("reqSTR") > tstr) {
continue;
} else if (getEquipStats(equip.getItemId()).get("reqLUK") > tluk) {
continue;
} else if (getEquipStats(equip.getItemId()).get("reqINT") > tint) {
continue;
}
int reqPOP = getEquipStats(equip.getItemId()).get("reqPOP");
if (reqPOP > 0) {
if (getEquipStats(equip.getItemId()).get("reqPOP") > fame) {
continue;
}
}
equip.wear(true);
itemz.add(equip);
}
inv.checked(true);
return itemz;
}
use of client.inventory.Item in project HeavenMS by ronancpl.
the class NPCConversationManager method doGachapon.
public void doGachapon() {
int[] maps = { 100000000, 101000000, 102000000, 103000000, 105040300, 800000000, 809000101, 809000201, 600000000, 120000000 };
MapleGachaponItem item = MapleGachapon.getInstance().process(npc);
// For normal potions, make it give 100.
Item itemGained = gainItem(item.getId(), (short) (item.getId() / 10000 == 200 ? 100 : 1), true, true);
sendNext("You have obtained a #b#t" + item.getId() + "##k.");
String map = c.getChannelServer().getMapFactory().getMap(maps[(getNpc() != 9100117 && getNpc() != 9100109) ? (getNpc() - 9100100) : getNpc() == 9100109 ? 8 : 9]).getMapName();
LogHelper.logGacha(getPlayer(), item.getId(), map);
if (item.getTier() > 0) {
// Uncommon and Rare
Server.getInstance().broadcastMessage(c.getWorld(), MaplePacketCreator.gachaponMessage(itemGained, map, getPlayer()));
}
}
use of client.inventory.Item in project HeavenMS by ronancpl.
the class ReactorActionManager method dropItems.
public void dropItems(boolean delayed, int posX, int posY, boolean meso, int mesoChance, final int minMeso, final int maxMeso, int minItems) {
if (c.getPlayer() == null)
return;
List<ReactorDropEntry> items = generateDropList(getDropChances(), c.getPlayer().getDropRate(), meso, mesoChance, minItems);
if (items.size() % 2 == 0)
posX -= 12;
final Point dropPos = new Point(posX, posY);
if (!delayed) {
MapleItemInformationProvider ii = MapleItemInformationProvider.getInstance();
byte p = 1;
for (ReactorDropEntry d : items) {
dropPos.x = (int) (posX + ((p % 2 == 0) ? (25 * ((p + 1) / 2)) : -(25 * (p / 2))));
p++;
if (d.itemId == 0) {
int range = maxMeso - minMeso;
int displayDrop = (int) (Math.random() * range) + minMeso;
int mesoDrop = (displayDrop * client.getWorldServer().getMesoRate());
reactor.getMap().spawnMesoDrop(mesoDrop, reactor.getMap().calcDropPos(dropPos, reactor.getPosition()), reactor, client.getPlayer(), false, (byte) 2);
} else {
Item drop;
if (ItemConstants.getInventoryType(d.itemId) != MapleInventoryType.EQUIP) {
drop = new Item(d.itemId, (short) 0, (short) 1);
} else {
drop = ii.randomizeStats((Equip) ii.getEquipById(d.itemId));
}
reactor.getMap().dropFromReactor(getPlayer(), reactor, drop, dropPos, (short) d.questid);
}
}
} else {
final MapleCharacter chr = client.getPlayer();
final MapleReactor r = reactor;
final List<ReactorDropEntry> dropItems = items;
final int worldMesoRate = client.getWorldServer().getMesoRate();
dropPos.x -= (12 * items.size());
sprayTask = TimerManager.getInstance().register(new Runnable() {
@Override
public void run() {
if (dropItems.isEmpty()) {
sprayTask.cancel(false);
return;
}
ReactorDropEntry d = dropItems.remove(0);
if (d.itemId == 0) {
int range = maxMeso - minMeso;
int displayDrop = (int) (Math.random() * range) + minMeso;
int mesoDrop = (displayDrop * worldMesoRate);
r.getMap().spawnMesoDrop(mesoDrop, r.getMap().calcDropPos(dropPos, r.getPosition()), r, chr, false, (byte) 2);
} else {
Item drop;
if (ItemConstants.getInventoryType(d.itemId) != MapleInventoryType.EQUIP) {
drop = new Item(d.itemId, (short) 0, (short) 1);
} else {
MapleItemInformationProvider ii = MapleItemInformationProvider.getInstance();
drop = ii.randomizeStats((Equip) ii.getEquipById(d.itemId));
}
r.getMap().dropFromReactor(getPlayer(), r, drop, dropPos, (short) d.questid);
}
dropPos.x += 25;
}
}, 100);
}
}
use of client.inventory.Item in project HeavenMS by ronancpl.
the class AbstractPlayerInteraction method gainItem.
public Item gainItem(int id, short quantity, boolean randomStats, boolean showMessage, long expires, MaplePet from) {
Item item = null;
MaplePet evolved;
int petId = -1;
if (quantity >= 0) {
if (ItemConstants.isPet(id)) {
petId = MaplePet.createPet(id);
if (from != null) {
evolved = MaplePet.loadFromDb(id, (short) 0, petId);
Point pos = getPlayer().getPosition();
pos.y -= 12;
evolved.setPos(pos);
evolved.setFh(getPlayer().getMap().getFootholds().findBelow(evolved.getPos()).getId());
evolved.setStance(0);
evolved.setSummoned(true);
evolved.setName(from.getName().compareTo(MapleItemInformationProvider.getInstance().getName(from.getItemId())) != 0 ? from.getName() : MapleItemInformationProvider.getInstance().getName(id));
evolved.setCloseness(from.getCloseness());
evolved.setFullness(from.getFullness());
evolved.setLevel(from.getLevel());
evolved.saveToDb();
}
// MapleInventoryManipulator.addById(c, id, (short) 1, null, petId, expires == -1 ? -1 : System.currentTimeMillis() + expires);
}
MapleItemInformationProvider ii = MapleItemInformationProvider.getInstance();
if (ItemConstants.getInventoryType(id).equals(MapleInventoryType.EQUIP)) {
item = ii.getEquipById(id);
if (item != null) {
Equip it = (Equip) item;
if (ItemConstants.isAccessory(item.getItemId()) && it.getUpgradeSlots() <= 0)
it.setUpgradeSlots(3);
if (ServerConstants.USE_ENHANCED_CRAFTING == true && c.getPlayer().getCS() == true) {
Equip eqp = (Equip) item;
if (!(c.getPlayer().isGM() && ServerConstants.USE_PERFECT_GM_SCROLL)) {
eqp.setUpgradeSlots((byte) (eqp.getUpgradeSlots() + 1));
}
item = MapleItemInformationProvider.getInstance().scrollEquipWithId(item, 2049100, true, 2049100, c.getPlayer().isGM());
}
}
} else {
item = new Item(id, (short) 0, quantity, petId);
}
if (expires >= 0)
item.setExpiration(System.currentTimeMillis() + expires);
item.setPetId(petId);
if (!MapleInventoryManipulator.checkSpace(c, id, quantity, "")) {
c.getPlayer().dropMessage(1, "Your inventory is full. Please remove an item from your " + ItemConstants.getInventoryType(id).name() + " inventory.");
return null;
}
if (ItemConstants.getInventoryType(id) == MapleInventoryType.EQUIP) {
if (randomStats) {
item = ii.randomizeStats((Equip) item);
MapleInventoryManipulator.addFromDrop(c, ii.randomizeStats((Equip) item), false, petId);
} else {
MapleInventoryManipulator.addFromDrop(c, (Equip) item, false, petId);
}
} else {
MapleInventoryManipulator.addFromDrop(c, item, false, petId);
}
} else {
MapleInventoryManipulator.removeById(c, ItemConstants.getInventoryType(id), id, -quantity, true, false);
}
if (showMessage) {
c.announce(MaplePacketCreator.getShowItemGain(id, quantity, true));
}
return item;
}
use of client.inventory.Item in project HeavenMS by ronancpl.
the class AbstractPlayerInteraction method getDriedPets.
public List<MaplePet> getDriedPets() {
List<MaplePet> list = new LinkedList<>();
long curTime = System.currentTimeMillis();
for (Item it : getPlayer().getInventory(MapleInventoryType.CASH).list()) {
if (ItemConstants.isPet(it.getItemId()) && it.getExpiration() < curTime) {
MaplePet pet = it.getPet();
if (pet != null) {
list.add(pet);
}
}
}
return list;
}
Aggregations