Reformat and clean up "client" package
This commit is contained in:
@@ -25,15 +25,14 @@ import server.maps.MapleMap;
|
||||
import tools.PacketCreator;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author RonanLana
|
||||
*/
|
||||
public class BuybackProcessor {
|
||||
|
||||
|
||||
public static void processBuyback(Client c) {
|
||||
Character chr = c.getPlayer();
|
||||
boolean buyback;
|
||||
|
||||
|
||||
c.lockClient();
|
||||
try {
|
||||
buyback = !chr.isAlive() && chr.couldBuyback();
|
||||
@@ -43,7 +42,7 @@ public class BuybackProcessor {
|
||||
|
||||
if (buyback) {
|
||||
String jobString;
|
||||
switch(chr.getJobStyle()) {
|
||||
switch (chr.getJobStyle()) {
|
||||
case WARRIOR:
|
||||
jobString = "warrior";
|
||||
break;
|
||||
@@ -72,7 +71,7 @@ public class BuybackProcessor {
|
||||
chr.healHpMp();
|
||||
chr.purgeDebuffs();
|
||||
chr.broadcastStance(chr.isFacingLeft() ? 5 : 4);
|
||||
|
||||
|
||||
MapleMap map = chr.getMap();
|
||||
map.broadcastMessage(PacketCreator.playSound("Buyback/" + jobString));
|
||||
map.broadcastMessage(PacketCreator.earnTitleMessage(chr.getName() + " just bought back into the game!"));
|
||||
|
||||
@@ -42,12 +42,11 @@ import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author Ronan
|
||||
*/
|
||||
public class MakerProcessor {
|
||||
|
||||
private static ItemInformationProvider ii = ItemInformationProvider.getInstance();
|
||||
|
||||
private static final ItemInformationProvider ii = ItemInformationProvider.getInstance();
|
||||
|
||||
public static void makerAction(InPacket p, Client c) {
|
||||
if (c.tryacquireClient()) {
|
||||
@@ -61,26 +60,26 @@ public class MakerProcessor {
|
||||
Map<Integer, Short> reagentids = new LinkedHashMap<>();
|
||||
int stimulantid = -1;
|
||||
|
||||
if(type == 3) { // building monster crystal
|
||||
if (type == 3) { // building monster crystal
|
||||
int fromLeftover = toCreate;
|
||||
toCreate = ii.getMakerCrystalFromLeftover(toCreate);
|
||||
if(toCreate == -1) {
|
||||
if (toCreate == -1) {
|
||||
c.sendPacket(PacketCreator.serverNotice(1, ii.getName(fromLeftover) + " is unavailable for Monster Crystal conversion."));
|
||||
c.sendPacket(PacketCreator.makerEnableActions());
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
recipe = MakerItemFactory.generateLeftoverCrystalEntry(fromLeftover, toCreate);
|
||||
} else if(type == 4) { // disassembling
|
||||
} else if (type == 4) { // disassembling
|
||||
p.readInt(); // 1... probably inventory type
|
||||
pos = p.readInt();
|
||||
|
||||
Item it = c.getPlayer().getInventory(InventoryType.EQUIP).getItem((short) pos);
|
||||
if(it != null && it.getItemId() == toCreate) {
|
||||
if (it != null && it.getItemId() == toCreate) {
|
||||
toDisassemble = toCreate;
|
||||
|
||||
|
||||
Pair<Integer, List<Pair<Integer, Integer>>> pair = generateDisassemblyInfo(toDisassemble);
|
||||
if(pair != null) {
|
||||
if (pair != null) {
|
||||
recipe = MakerItemFactory.generateDisassemblyCrystalEntry(toDisassemble, pair.getLeft(), pair.getRight());
|
||||
} else {
|
||||
c.sendPacket(PacketCreator.serverNotice(1, ii.getName(toCreate) + " is unavailable for Monster Crystal disassembly."));
|
||||
@@ -93,20 +92,20 @@ public class MakerProcessor {
|
||||
return;
|
||||
}
|
||||
} else {
|
||||
if(ItemConstants.isEquipment(toCreate)) { // only equips uses stimulant and reagents
|
||||
if(p.readByte() != 0) { // stimulant
|
||||
if (ItemConstants.isEquipment(toCreate)) { // only equips uses stimulant and reagents
|
||||
if (p.readByte() != 0) { // stimulant
|
||||
stimulantid = ii.getMakerStimulant(toCreate);
|
||||
if(!c.getAbstractPlayerInteraction().haveItem(stimulantid)) {
|
||||
if (!c.getAbstractPlayerInteraction().haveItem(stimulantid)) {
|
||||
stimulantid = -1;
|
||||
}
|
||||
}
|
||||
|
||||
int reagents = Math.min(p.readInt(), getMakerReagentSlots(toCreate));
|
||||
for(int i = 0; i < reagents; i++) { // crystals
|
||||
for (int i = 0; i < reagents; i++) { // crystals
|
||||
int reagentid = p.readInt();
|
||||
if(ItemConstants.isMakerReagent(reagentid)) {
|
||||
if (ItemConstants.isMakerReagent(reagentid)) {
|
||||
Short rs = reagentids.get(reagentid);
|
||||
if(rs == null) {
|
||||
if (rs == null) {
|
||||
reagentids.put(reagentid, (short) 1);
|
||||
} else {
|
||||
reagentids.put(reagentid, (short) (rs + 1));
|
||||
@@ -115,18 +114,18 @@ public class MakerProcessor {
|
||||
}
|
||||
|
||||
List<Pair<Integer, Short>> toUpdate = new LinkedList<>();
|
||||
for(Map.Entry<Integer, Short> r : reagentids.entrySet()) {
|
||||
for (Map.Entry<Integer, Short> r : reagentids.entrySet()) {
|
||||
int qty = c.getAbstractPlayerInteraction().getItemQuantity(r.getKey());
|
||||
|
||||
if(qty < r.getValue()) {
|
||||
if (qty < r.getValue()) {
|
||||
toUpdate.add(new Pair<>(r.getKey(), (short) qty));
|
||||
}
|
||||
}
|
||||
|
||||
// remove those not present on player inventory
|
||||
if(!toUpdate.isEmpty()) {
|
||||
for(Pair<Integer, Short> rp : toUpdate) {
|
||||
if(rp.getRight() > 0) {
|
||||
if (!toUpdate.isEmpty()) {
|
||||
for (Pair<Integer, Short> rp : toUpdate) {
|
||||
if (rp.getRight() > 0) {
|
||||
reagentids.put(rp.getLeft(), rp.getRight());
|
||||
} else {
|
||||
reagentids.remove(rp.getLeft());
|
||||
@@ -134,8 +133,8 @@ public class MakerProcessor {
|
||||
}
|
||||
}
|
||||
|
||||
if(!reagentids.isEmpty()) {
|
||||
if(!removeOddMakerReagents(toCreate, reagentids)) {
|
||||
if (!reagentids.isEmpty()) {
|
||||
if (!removeOddMakerReagents(toCreate, reagentids)) {
|
||||
c.sendPacket(PacketCreator.serverNotice(1, "You can only use WATK and MATK Strengthening Gems on weapon items."));
|
||||
c.sendPacket(PacketCreator.makerEnableActions());
|
||||
return;
|
||||
@@ -148,7 +147,7 @@ public class MakerProcessor {
|
||||
|
||||
short createStatus = getCreateStatus(c, recipe);
|
||||
|
||||
switch(createStatus) {
|
||||
switch (createStatus) {
|
||||
case -1:// non-available for Maker itemid has been tried to forge
|
||||
FilePrinter.printError(FilePrinter.EXPLOITS, "Player " + c.getPlayer().getName() + " tried to craft itemid " + toCreate + " using the Maker skill.");
|
||||
c.sendPacket(PacketCreator.serverNotice(1, "The requested item could not be crafted on this operation."));
|
||||
@@ -174,14 +173,14 @@ public class MakerProcessor {
|
||||
c.sendPacket(PacketCreator.serverNotice(1, "You don't have enough Maker level to complete this operation."));
|
||||
c.sendPacket(PacketCreator.makerEnableActions());
|
||||
break;
|
||||
|
||||
|
||||
case 5: // inventory full
|
||||
c.sendPacket(PacketCreator.serverNotice(1, "Your inventory is full."));
|
||||
c.sendPacket(PacketCreator.makerEnableActions());
|
||||
break;
|
||||
|
||||
default:
|
||||
if(toDisassemble != -1) {
|
||||
if (toDisassemble != -1) {
|
||||
InventoryManipulator.removeFromSlot(c, InventoryType.EQUIP, (short) pos, (short) 1, false);
|
||||
} else {
|
||||
for (Pair<Integer, Integer> pair : recipe.getReqItems()) {
|
||||
@@ -190,9 +189,11 @@ public class MakerProcessor {
|
||||
}
|
||||
|
||||
int cost = recipe.getCost();
|
||||
if(stimulantid == -1 && reagentids.isEmpty()) {
|
||||
if(cost > 0) c.getPlayer().gainMeso(-cost, false);
|
||||
|
||||
if (stimulantid == -1 && reagentids.isEmpty()) {
|
||||
if (cost > 0) {
|
||||
c.getPlayer().gainMeso(-cost, false);
|
||||
}
|
||||
|
||||
for (Pair<Integer, Integer> pair : recipe.getGainItems()) {
|
||||
c.getPlayer().setCS(true);
|
||||
c.getAbstractPlayerInteraction().gainItem(pair.getLeft(), pair.getRight().shortValue(), false);
|
||||
@@ -200,15 +201,19 @@ public class MakerProcessor {
|
||||
}
|
||||
} else {
|
||||
toCreate = recipe.getGainItems().get(0).getLeft();
|
||||
|
||||
if(stimulantid != -1) c.getAbstractPlayerInteraction().gainItem(stimulantid, (short) -1, false);
|
||||
if(!reagentids.isEmpty()) {
|
||||
for(Map.Entry<Integer, Short> r : reagentids.entrySet()) {
|
||||
|
||||
if (stimulantid != -1) {
|
||||
c.getAbstractPlayerInteraction().gainItem(stimulantid, (short) -1, false);
|
||||
}
|
||||
if (!reagentids.isEmpty()) {
|
||||
for (Map.Entry<Integer, Short> r : reagentids.entrySet()) {
|
||||
c.getAbstractPlayerInteraction().gainItem(r.getKey(), (short) (-1 * r.getValue()), false);
|
||||
}
|
||||
}
|
||||
|
||||
if(cost > 0) c.getPlayer().gainMeso(-cost, false);
|
||||
if (cost > 0) {
|
||||
c.getPlayer().gainMeso(-cost, false);
|
||||
}
|
||||
makerSucceeded = addBoostedMakerItem(c, toCreate, stimulantid, reagentids);
|
||||
}
|
||||
|
||||
@@ -220,11 +225,11 @@ public class MakerProcessor {
|
||||
} else {
|
||||
c.sendPacket(PacketCreator.makerResult(makerSucceeded, recipe.getGainItems().get(0).getLeft(), recipe.getGainItems().get(0).getRight(), recipe.getCost(), recipe.getReqItems(), stimulantid, new LinkedList<>(reagentids.keySet())));
|
||||
}
|
||||
|
||||
|
||||
c.sendPacket(PacketCreator.showMakerEffect(makerSucceeded));
|
||||
c.getPlayer().getMap().broadcastMessage(c.getPlayer(), PacketCreator.showForeignMakerEffect(c.getPlayer().getId(), makerSucceeded), false);
|
||||
|
||||
if(toCreate == 4260003 && type == 3 && c.getPlayer().getQuestStatus(6033) == 1) {
|
||||
if (toCreate == 4260003 && type == 3 && c.getPlayer().getQuestStatus(6033) == 1) {
|
||||
c.getAbstractPlayerInteraction().setQuestProgress(6033, 1);
|
||||
}
|
||||
}
|
||||
@@ -233,25 +238,25 @@ public class MakerProcessor {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// checks and prevents hackers from PE'ing Maker operations with invalid operations
|
||||
private static boolean removeOddMakerReagents(int toCreate, Map<Integer, Short> reagentids) {
|
||||
Map<Integer, Integer> reagentType = new LinkedHashMap<>();
|
||||
List<Integer> toRemove = new LinkedList<>();
|
||||
|
||||
|
||||
boolean isWeapon = ItemConstants.isWeapon(toCreate) || YamlConfig.config.server.USE_MAKER_PERMISSIVE_ATKUP; // thanks Vcoc for finding a case where a weapon wouldn't be counted as such due to a bounding on isWeapon
|
||||
|
||||
for(Map.Entry<Integer, Short> r : reagentids.entrySet()) {
|
||||
|
||||
for (Map.Entry<Integer, Short> r : reagentids.entrySet()) {
|
||||
int curRid = r.getKey();
|
||||
int type = r.getKey() / 100;
|
||||
|
||||
if(type < 42502 && !isWeapon) { // only weapons should gain w.att/m.att from these.
|
||||
|
||||
if (type < 42502 && !isWeapon) { // only weapons should gain w.att/m.att from these.
|
||||
return false; //toRemove.add(curRid);
|
||||
} else {
|
||||
Integer tableRid = reagentType.get(type);
|
||||
|
||||
if(tableRid != null) {
|
||||
if(tableRid < curRid) {
|
||||
|
||||
if (tableRid != null) {
|
||||
if (tableRid < curRid) {
|
||||
toRemove.add(tableRid);
|
||||
reagentType.put(type, curRid);
|
||||
} else {
|
||||
@@ -262,92 +267,92 @@ public class MakerProcessor {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// removing less effective gems of repeated type
|
||||
for(Integer i : toRemove) {
|
||||
for (Integer i : toRemove) {
|
||||
reagentids.remove(i);
|
||||
}
|
||||
|
||||
|
||||
// the Maker skill will use only one of each gem
|
||||
for(Integer i : reagentids.keySet()) {
|
||||
for (Integer i : reagentids.keySet()) {
|
||||
reagentids.put(i, (short) 1);
|
||||
}
|
||||
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
private static int getMakerReagentSlots(int itemId) {
|
||||
try {
|
||||
int eqpLevel = ii.getEquipLevelReq(itemId);
|
||||
|
||||
if(eqpLevel < 78) {
|
||||
|
||||
if (eqpLevel < 78) {
|
||||
return 1;
|
||||
} else if(eqpLevel >= 78 && eqpLevel < 108) {
|
||||
} else if (eqpLevel >= 78 && eqpLevel < 108) {
|
||||
return 2;
|
||||
} else {
|
||||
return 3;
|
||||
}
|
||||
} catch(NullPointerException npe) {
|
||||
} catch (NullPointerException npe) {
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
private static Pair<Integer, List<Pair<Integer, Integer>>> generateDisassemblyInfo(int itemId) {
|
||||
int recvFee = ii.getMakerDisassembledFee(itemId);
|
||||
if(recvFee > -1) {
|
||||
if (recvFee > -1) {
|
||||
List<Pair<Integer, Integer>> gains = ii.getMakerDisassembledItems(itemId);
|
||||
if(!gains.isEmpty()) {
|
||||
if (!gains.isEmpty()) {
|
||||
return new Pair<>(recvFee, gains);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
|
||||
public static int getMakerSkillLevel(Character chr) {
|
||||
return chr.getSkillLevel((chr.getJob().getId() / 1000) * 10000000 + 1007);
|
||||
}
|
||||
|
||||
|
||||
private static short getCreateStatus(Client c, MakerItemCreateEntry recipe) {
|
||||
if(recipe.isInvalid()) {
|
||||
if (recipe.isInvalid()) {
|
||||
return -1;
|
||||
}
|
||||
|
||||
if(!hasItems(c, recipe)) {
|
||||
|
||||
if (!hasItems(c, recipe)) {
|
||||
return 1;
|
||||
}
|
||||
|
||||
if(c.getPlayer().getMeso() < recipe.getCost()) {
|
||||
|
||||
if (c.getPlayer().getMeso() < recipe.getCost()) {
|
||||
return 2;
|
||||
}
|
||||
|
||||
if(c.getPlayer().getLevel() < recipe.getReqLevel()) {
|
||||
|
||||
if (c.getPlayer().getLevel() < recipe.getReqLevel()) {
|
||||
return 3;
|
||||
}
|
||||
|
||||
if(getMakerSkillLevel(c.getPlayer()) < recipe.getReqSkillLevel()) {
|
||||
|
||||
if (getMakerSkillLevel(c.getPlayer()) < recipe.getReqSkillLevel()) {
|
||||
return 4;
|
||||
}
|
||||
|
||||
|
||||
List<Integer> addItemids = new LinkedList<>();
|
||||
List<Integer> addQuantity = new LinkedList<>();
|
||||
List<Integer> rmvItemids = new LinkedList<>();
|
||||
List<Integer> rmvQuantity = new LinkedList<>();
|
||||
|
||||
|
||||
for (Pair<Integer, Integer> p : recipe.getReqItems()) {
|
||||
rmvItemids.add(p.getLeft());
|
||||
rmvQuantity.add(p.getRight());
|
||||
}
|
||||
|
||||
|
||||
for (Pair<Integer, Integer> p : recipe.getGainItems()) {
|
||||
addItemids.add(p.getLeft());
|
||||
addQuantity.add(p.getRight());
|
||||
}
|
||||
|
||||
|
||||
if (!c.getAbstractPlayerInteraction().canHoldAllAfterRemoving(addItemids, addQuantity, rmvItemids, rmvQuantity)) {
|
||||
return 5;
|
||||
}
|
||||
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
@@ -360,58 +365,62 @@ public class MakerProcessor {
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
private static boolean addBoostedMakerItem(Client c, int itemid, int stimulantid, Map<Integer, Short> reagentids) {
|
||||
if(stimulantid != -1 && !ii.rollSuccessChance(90.0)) {
|
||||
if (stimulantid != -1 && !ItemInformationProvider.rollSuccessChance(90.0)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
Item item = ii.getEquipById(itemid);
|
||||
if(item == null) return false;
|
||||
if (item == null) {
|
||||
return false;
|
||||
}
|
||||
|
||||
Equip eqp = (Equip)item;
|
||||
if(ItemConstants.isAccessory(item.getItemId()) && eqp.getUpgradeSlots() <= 0) eqp.setUpgradeSlots(3);
|
||||
Equip eqp = (Equip) item;
|
||||
if (ItemConstants.isAccessory(item.getItemId()) && eqp.getUpgradeSlots() <= 0) {
|
||||
eqp.setUpgradeSlots(3);
|
||||
}
|
||||
|
||||
if(YamlConfig.config.server.USE_ENHANCED_CRAFTING == true) {
|
||||
if(!(c.getPlayer().isGM() && YamlConfig.config.server.USE_PERFECT_GM_SCROLL)) {
|
||||
eqp.setUpgradeSlots((byte)(eqp.getUpgradeSlots() + 1));
|
||||
if (YamlConfig.config.server.USE_ENHANCED_CRAFTING == true) {
|
||||
if (!(c.getPlayer().isGM() && YamlConfig.config.server.USE_PERFECT_GM_SCROLL)) {
|
||||
eqp.setUpgradeSlots((byte) (eqp.getUpgradeSlots() + 1));
|
||||
}
|
||||
item = ItemInformationProvider.getInstance().scrollEquipWithId(eqp, 2049100, true, 2049100, c.getPlayer().isGM());
|
||||
}
|
||||
|
||||
if(!reagentids.isEmpty()) {
|
||||
|
||||
if (!reagentids.isEmpty()) {
|
||||
Map<String, Integer> stats = new LinkedHashMap<>();
|
||||
List<Short> randOption = new LinkedList<>();
|
||||
List<Short> randStat = new LinkedList<>();
|
||||
|
||||
for(Map.Entry<Integer, Short> r : reagentids.entrySet()) {
|
||||
|
||||
for (Map.Entry<Integer, Short> r : reagentids.entrySet()) {
|
||||
Pair<String, Integer> reagentBuff = ii.getMakerReagentStatUpgrade(r.getKey());
|
||||
|
||||
if(reagentBuff != null) {
|
||||
|
||||
if (reagentBuff != null) {
|
||||
String s = reagentBuff.getLeft();
|
||||
|
||||
if(s.substring(0, 4).contains("rand")) {
|
||||
if(s.substring(4).equals("Stat")) {
|
||||
|
||||
if (s.substring(0, 4).contains("rand")) {
|
||||
if (s.substring(4).equals("Stat")) {
|
||||
randStat.add((short) (reagentBuff.getRight() * r.getValue()));
|
||||
} else {
|
||||
randOption.add((short) (reagentBuff.getRight() * r.getValue()));
|
||||
}
|
||||
} else {
|
||||
String stat = s.substring(3);
|
||||
|
||||
if(!stat.equals("ReqLevel")) { // improve req level... really?
|
||||
|
||||
if (!stat.equals("ReqLevel")) { // improve req level... really?
|
||||
switch (stat) {
|
||||
case "MaxHP":
|
||||
stat = "MHP";
|
||||
break;
|
||||
|
||||
|
||||
case "MaxMP":
|
||||
stat = "MMP";
|
||||
break;
|
||||
}
|
||||
|
||||
|
||||
Integer d = stats.get(stat);
|
||||
if(d == null) {
|
||||
if (d == null) {
|
||||
stats.put(stat, reagentBuff.getRight() * r.getValue());
|
||||
} else {
|
||||
stats.put(stat, d + (reagentBuff.getRight() * r.getValue()));
|
||||
@@ -420,22 +429,22 @@ public class MakerProcessor {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
ii.improveEquipStats(eqp, stats);
|
||||
|
||||
for(Short sh : randStat) {
|
||||
|
||||
ItemInformationProvider.improveEquipStats(eqp, stats);
|
||||
|
||||
for (Short sh : randStat) {
|
||||
ii.scrollOptionEquipWithChaos(eqp, sh, false);
|
||||
}
|
||||
|
||||
for(Short sh : randOption) {
|
||||
|
||||
for (Short sh : randOption) {
|
||||
ii.scrollOptionEquipWithChaos(eqp, sh, true);
|
||||
}
|
||||
}
|
||||
|
||||
if(stimulantid != -1) {
|
||||
|
||||
if (stimulantid != -1) {
|
||||
eqp = ii.randomizeUpgradeStats(eqp);
|
||||
}
|
||||
|
||||
|
||||
InventoryManipulator.addFromDrop(c, item, false, -1);
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -35,34 +35,33 @@ import tools.PacketCreator;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author Ronan - multi-pot consumption feature
|
||||
*/
|
||||
public class PetAutopotProcessor {
|
||||
|
||||
|
||||
private static class AutopotAction {
|
||||
|
||||
private Client c;
|
||||
|
||||
private final Client c;
|
||||
private short slot;
|
||||
private int itemId;
|
||||
|
||||
private final int itemId;
|
||||
|
||||
private Item toUse;
|
||||
private List<Item> toUseList;
|
||||
|
||||
private boolean hasHpGain, hasMpGain;
|
||||
private int maxHp, maxMp, curHp, curMp;
|
||||
private double incHp, incMp;
|
||||
|
||||
|
||||
private boolean cursorOnNextAvailablePot(Character chr) {
|
||||
if(toUseList == null) {
|
||||
if (toUseList == null) {
|
||||
toUseList = chr.getInventory(InventoryType.USE).linkedListById(itemId);
|
||||
}
|
||||
|
||||
toUse = null;
|
||||
while(!toUseList.isEmpty()) {
|
||||
while (!toUseList.isEmpty()) {
|
||||
Item it = toUseList.remove(0);
|
||||
|
||||
if(it.getQuantity() > 0) {
|
||||
if (it.getQuantity() > 0) {
|
||||
toUse = it;
|
||||
slot = it.getPosition();
|
||||
|
||||
@@ -72,13 +71,13 @@ public class PetAutopotProcessor {
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
public AutopotAction(Client c, short slot, int itemId) {
|
||||
this.c = c;
|
||||
this.slot = slot;
|
||||
this.itemId = itemId;
|
||||
}
|
||||
|
||||
|
||||
public void run() {
|
||||
Client c = this.c;
|
||||
Character chr = c.getPlayer();
|
||||
@@ -86,10 +85,10 @@ public class PetAutopotProcessor {
|
||||
c.sendPacket(PacketCreator.enableActions());
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
int useCount = 0, qtyCount = 0;
|
||||
StatEffect stat = null;
|
||||
|
||||
|
||||
maxHp = chr.getCurrentMaxHp();
|
||||
maxMp = chr.getCurrentMaxMp();
|
||||
|
||||
@@ -119,12 +118,16 @@ public class PetAutopotProcessor {
|
||||
stat = ItemInformationProvider.getInstance().getItemEffect(toUse.getItemId());
|
||||
hasHpGain = stat.getHp() > 0 || stat.getHpRate() > 0.0;
|
||||
hasMpGain = stat.getMp() > 0 || stat.getMpRate() > 0.0;
|
||||
|
||||
|
||||
incHp = stat.getHp();
|
||||
if(incHp <= 0 && hasHpGain) incHp = Math.ceil(maxHp * stat.getHpRate());
|
||||
if (incHp <= 0 && hasHpGain) {
|
||||
incHp = Math.ceil(maxHp * stat.getHpRate());
|
||||
}
|
||||
|
||||
incMp = stat.getMp();
|
||||
if(incMp <= 0 && hasMpGain) incMp = Math.ceil(maxMp * stat.getMpRate());
|
||||
if (incMp <= 0 && hasMpGain) {
|
||||
incMp = Math.ceil(maxMp * stat.getMpRate());
|
||||
}
|
||||
|
||||
if (YamlConfig.config.server.USE_COMPULSORY_AUTOPOT) {
|
||||
if (hasHpGain) {
|
||||
@@ -140,7 +143,7 @@ public class PetAutopotProcessor {
|
||||
qtyCount = Math.max(qtyCount, (int) Math.ceil(mpRatio / incMp));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
if (qtyCount < 0) { // thanks Flint, Kevs for noticing an issue where negative counts were getting achieved
|
||||
qtyCount = 0;
|
||||
}
|
||||
@@ -158,10 +161,10 @@ public class PetAutopotProcessor {
|
||||
useCount += qtyToUse;
|
||||
qtyCount -= qtyToUse;
|
||||
|
||||
if(toUse.getQuantity() == 0 && qtyCount > 0) {
|
||||
if (toUse.getQuantity() == 0 && qtyCount > 0) {
|
||||
// depleted out the current slot, fetch for more
|
||||
|
||||
if(!cursorOnNextAvailablePot(chr)) {
|
||||
if (!cursorOnNextAvailablePot(chr)) {
|
||||
break; // no more pots available
|
||||
}
|
||||
} else {
|
||||
@@ -182,10 +185,10 @@ public class PetAutopotProcessor {
|
||||
chr.sendPacket(PacketCreator.enableActions());
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public static void runAutopotAction(Client c, short slot, int itemid) {
|
||||
AutopotAction action = new AutopotAction(c, slot, itemid);
|
||||
action.run();
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
@@ -34,18 +34,19 @@ import tools.PacketCreator;
|
||||
import java.awt.*;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author RonanLana - just added locking on OdinMS' SpawnPetHandler method body
|
||||
*/
|
||||
public class SpawnPetProcessor {
|
||||
private static final DataProvider dataRoot = DataProviderFactory.getDataProvider(WZFiles.ITEM);
|
||||
|
||||
|
||||
public static void processSpawnPet(Client c, byte slot, boolean lead) {
|
||||
if (c.tryacquireClient()) {
|
||||
try {
|
||||
Character chr = c.getPlayer();
|
||||
Pet pet = chr.getInventory(InventoryType.CASH).getItem(slot).getPet();
|
||||
if (pet == null) return;
|
||||
if (pet == null) {
|
||||
return;
|
||||
}
|
||||
|
||||
int petid = pet.getItemId();
|
||||
if (petid == 5000028 || petid == 5000047) //Handles Dragon AND Robos
|
||||
@@ -63,7 +64,7 @@ public class SpawnPetProcessor {
|
||||
long expiration = chr.getInventory(InventoryType.CASH).getItem(slot).getExpiration();
|
||||
InventoryManipulator.removeById(c, InventoryType.CASH, petid, (short) 1, false, false);
|
||||
InventoryManipulator.addById(c, evolveid, (short) 1, null, petId, expiration);
|
||||
|
||||
|
||||
c.sendPacket(PacketCreator.enableActions());
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -468,7 +468,7 @@ public class DueyProcessor {
|
||||
c.add(Calendar.DATE, -30);
|
||||
final Timestamp ts = new Timestamp(c.getTime().getTime());
|
||||
|
||||
try (Connection con = DatabaseConnection.getConnection()){
|
||||
try (Connection con = DatabaseConnection.getConnection()) {
|
||||
List<Integer> toRemove = new LinkedList<>();
|
||||
try (PreparedStatement ps = con.prepareStatement("SELECT `PackageId` FROM dueypackages WHERE `TimeStamp` < ?")) {
|
||||
ps.setTimestamp(1, ts);
|
||||
|
||||
@@ -45,27 +45,26 @@ import java.util.LinkedList;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author RonanLana - synchronization of Fredrick modules and operation results
|
||||
*/
|
||||
public class FredrickProcessor {
|
||||
|
||||
private static int[] dailyReminders = new int[]{2, 5, 10, 15, 30, 60, 90, Integer.MAX_VALUE};
|
||||
|
||||
|
||||
private static final int[] dailyReminders = new int[]{2, 5, 10, 15, 30, 60, 90, Integer.MAX_VALUE};
|
||||
|
||||
private static byte canRetrieveFromFredrick(Character chr, List<Pair<Item, InventoryType>> items) {
|
||||
if (!Inventory.checkSpotsAndOwnership(chr, items)) {
|
||||
List<Integer> itemids = new LinkedList<>();
|
||||
for (Pair<Item, InventoryType> it : items) {
|
||||
itemids.add(it.getLeft().getItemId());
|
||||
}
|
||||
|
||||
|
||||
if (chr.canHoldUniques(itemids)) {
|
||||
return 0x22;
|
||||
} else {
|
||||
return 0x20;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
int netMeso = chr.getMerchantNetMeso();
|
||||
if (netMeso > 0) {
|
||||
if (!chr.canHoldMeso(netMeso)) {
|
||||
@@ -76,26 +75,26 @@ public class FredrickProcessor {
|
||||
return 0x21;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
return 0x0;
|
||||
}
|
||||
|
||||
|
||||
public static int timestampElapsedDays(Timestamp then, long timeNow) {
|
||||
return (int) ((timeNow - then.getTime()) / (1000 * 60 * 60 * 24));
|
||||
}
|
||||
|
||||
|
||||
private static String fredrickReminderMessage(int daynotes) {
|
||||
String msg;
|
||||
|
||||
|
||||
if (daynotes < 4) {
|
||||
msg = "Hi customer! I am Fredrick, the Union Chief of the Hired Merchant Union. A reminder that " + dailyReminders[daynotes] + " days have passed since you used our service. Please reclaim your stored goods at FM Entrance.";
|
||||
} else {
|
||||
msg = "Hi customer! I am Fredrick, the Union Chief of the Hired Merchant Union. " + dailyReminders[daynotes] + " days have passed since you used our service. Consider claiming back the items before we move them away for refund.";
|
||||
}
|
||||
|
||||
|
||||
return msg;
|
||||
}
|
||||
|
||||
|
||||
public static void removeFredrickLog(int cid) {
|
||||
try (Connection con = DatabaseConnection.getConnection()) {
|
||||
removeFredrickLog(con, cid);
|
||||
@@ -103,14 +102,14 @@ public class FredrickProcessor {
|
||||
sqle.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
private static void removeFredrickLog(Connection con, int cid) throws SQLException {
|
||||
try (PreparedStatement ps = con.prepareStatement("DELETE FROM `fredstorage` WHERE `cid` = ?")) {
|
||||
ps.setInt(1, cid);
|
||||
ps.executeUpdate();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public static void insertFredrickLog(int cid) {
|
||||
try (Connection con = DatabaseConnection.getConnection()) {
|
||||
|
||||
@@ -124,11 +123,11 @@ public class FredrickProcessor {
|
||||
sqle.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public static void removeFredrickReminders(int cid) {
|
||||
removeFredrickReminders(Collections.singletonList(new Pair<>(cid, 0)));
|
||||
}
|
||||
|
||||
|
||||
private static void removeFredrickReminders(List<Pair<Integer, Integer>> expiredCids) {
|
||||
List<String> expiredCnames = new LinkedList<>();
|
||||
for (Pair<Integer, Integer> id : expiredCids) {
|
||||
@@ -150,7 +149,7 @@ public class FredrickProcessor {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public static void runFredrickSchedule() {
|
||||
try (Connection con = DatabaseConnection.getConnection()) {
|
||||
List<Pair<Integer, Integer>> expiredCids = new LinkedList<>();
|
||||
@@ -263,7 +262,7 @@ public class FredrickProcessor {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public static void fredrickRetrieveItems(Client c) { // thanks Gustav for pointing out the dupe on Fredrick handling
|
||||
if (c.tryacquireClient()) {
|
||||
try {
|
||||
@@ -272,20 +271,21 @@ public class FredrickProcessor {
|
||||
List<Pair<Item, InventoryType>> items;
|
||||
try {
|
||||
items = ItemFactory.MERCHANT.loadItems(chr.getId(), false);
|
||||
|
||||
|
||||
byte response = canRetrieveFromFredrick(chr, items);
|
||||
if (response != 0) {
|
||||
chr.sendPacket(PacketCreator.fredrickMessage(response));
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
chr.withdrawMerchantMesos();
|
||||
|
||||
|
||||
if (deleteFredrickItems(chr.getId())) {
|
||||
HiredMerchant merchant = chr.getHiredMerchant();
|
||||
|
||||
if(merchant != null)
|
||||
if (merchant != null) {
|
||||
merchant.clearItems();
|
||||
}
|
||||
|
||||
for (Pair<Item, InventoryType> it : items) {
|
||||
Item item = it.getLeft();
|
||||
|
||||
@@ -38,170 +38,171 @@ import tools.FilePrinter;
|
||||
import tools.PacketCreator;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author Matze
|
||||
* @author Ronan - inventory concurrency protection on storing items
|
||||
*/
|
||||
public class StorageProcessor {
|
||||
|
||||
public static void storageAction(InPacket p, Client c) {
|
||||
ItemInformationProvider ii = ItemInformationProvider.getInstance();
|
||||
Character chr = c.getPlayer();
|
||||
Storage storage = chr.getStorage();
|
||||
byte mode = p.readByte();
|
||||
|
||||
if (chr.getLevel() < 15){
|
||||
chr.dropMessage(1, "You may only use the storage once you have reached level 15.");
|
||||
public static void storageAction(InPacket p, Client c) {
|
||||
ItemInformationProvider ii = ItemInformationProvider.getInstance();
|
||||
Character chr = c.getPlayer();
|
||||
Storage storage = chr.getStorage();
|
||||
byte mode = p.readByte();
|
||||
|
||||
if (chr.getLevel() < 15) {
|
||||
chr.dropMessage(1, "You may only use the storage once you have reached level 15.");
|
||||
c.sendPacket(PacketCreator.enableActions());
|
||||
return;
|
||||
}
|
||||
|
||||
if (c.tryacquireClient()) {
|
||||
try {
|
||||
if (mode == 4) { // take out
|
||||
byte type = p.readByte();
|
||||
byte slot = p.readByte();
|
||||
if (slot < 0 || slot > storage.getSlots()) { // removal starts at zero
|
||||
AutobanFactory.PACKET_EDIT.alert(c.getPlayer(), c.getPlayer().getName() + " tried to packet edit with storage.");
|
||||
FilePrinter.print(FilePrinter.EXPLOITS + c.getPlayer().getName() + ".txt", c.getPlayer().getName() + " tried to work with storage slot " + slot);
|
||||
c.disconnect(true, false);
|
||||
return;
|
||||
}
|
||||
slot = storage.getSlot(InventoryType.getByType(type), slot);
|
||||
Item item = storage.getItem(slot);
|
||||
if (item != null) {
|
||||
if (ii.isPickupRestricted(item.getItemId()) && chr.haveItemWithId(item.getItemId(), true)) {
|
||||
c.sendPacket(PacketCreator.getStorageError((byte) 0x0C));
|
||||
return;
|
||||
}
|
||||
|
||||
int takeoutFee = storage.getTakeOutFee();
|
||||
if (chr.getMeso() < takeoutFee) {
|
||||
c.sendPacket(PacketCreator.getStorageError((byte) 0x0B));
|
||||
return;
|
||||
} else {
|
||||
chr.gainMeso(-takeoutFee, false);
|
||||
}
|
||||
|
||||
if (InventoryManipulator.checkSpace(c, item.getItemId(), item.getQuantity(), item.getOwner())) {
|
||||
if (storage.takeOut(item)) {
|
||||
chr.setUsedStorage();
|
||||
|
||||
KarmaManipulator.toggleKarmaFlagToUntradeable(item);
|
||||
InventoryManipulator.addFromDrop(c, item, false);
|
||||
|
||||
String itemName = ii.getName(item.getItemId());
|
||||
FilePrinter.print(FilePrinter.STORAGE + c.getAccountName() + ".txt", c.getPlayer().getName() + " took out " + item.getQuantity() + " " + itemName + " (" + item.getItemId() + ")");
|
||||
|
||||
storage.sendTakenOut(c, item.getInventoryType());
|
||||
} else {
|
||||
c.sendPacket(PacketCreator.enableActions());
|
||||
return;
|
||||
}
|
||||
} else {
|
||||
c.sendPacket(PacketCreator.getStorageError((byte) 0x0A));
|
||||
}
|
||||
}
|
||||
} else if (mode == 5) { // store
|
||||
short slot = p.readShort();
|
||||
int itemId = p.readInt();
|
||||
short quantity = p.readShort();
|
||||
InventoryType invType = ItemConstants.getInventoryType(itemId);
|
||||
Inventory inv = chr.getInventory(invType);
|
||||
if (slot < 1 || slot > inv.getSlotLimit()) { //player inv starts at one
|
||||
AutobanFactory.PACKET_EDIT.alert(c.getPlayer(), c.getPlayer().getName() + " tried to packet edit with storage.");
|
||||
FilePrinter.print(FilePrinter.EXPLOITS + c.getPlayer().getName() + ".txt", c.getPlayer().getName() + " tried to store item at slot " + slot);
|
||||
c.disconnect(true, false);
|
||||
return;
|
||||
}
|
||||
if (quantity < 1) {
|
||||
c.sendPacket(PacketCreator.enableActions());
|
||||
return;
|
||||
}
|
||||
|
||||
if (c.tryacquireClient()) {
|
||||
}
|
||||
if (storage.isFull()) {
|
||||
c.sendPacket(PacketCreator.getStorageError((byte) 0x11));
|
||||
return;
|
||||
}
|
||||
|
||||
int storeFee = storage.getStoreFee();
|
||||
if (chr.getMeso() < storeFee) {
|
||||
c.sendPacket(PacketCreator.getStorageError((byte) 0x0B));
|
||||
} else {
|
||||
Item item;
|
||||
|
||||
inv.lockInventory(); // thanks imbee for pointing a dupe within storage
|
||||
try {
|
||||
if (mode == 4) { // take out
|
||||
byte type = p.readByte();
|
||||
byte slot = p.readByte();
|
||||
if (slot < 0 || slot > storage.getSlots()) { // removal starts at zero
|
||||
AutobanFactory.PACKET_EDIT.alert(c.getPlayer(), c.getPlayer().getName() + " tried to packet edit with storage.");
|
||||
FilePrinter.print(FilePrinter.EXPLOITS + c.getPlayer().getName() + ".txt", c.getPlayer().getName() + " tried to work with storage slot " + slot);
|
||||
c.disconnect(true, false);
|
||||
return;
|
||||
}
|
||||
slot = storage.getSlot(InventoryType.getByType(type), slot);
|
||||
Item item = storage.getItem(slot);
|
||||
if (item != null) {
|
||||
if (ii.isPickupRestricted(item.getItemId()) && chr.haveItemWithId(item.getItemId(), true)) {
|
||||
c.sendPacket(PacketCreator.getStorageError((byte) 0x0C));
|
||||
return;
|
||||
}
|
||||
|
||||
int takeoutFee = storage.getTakeOutFee();
|
||||
if (chr.getMeso() < takeoutFee) {
|
||||
c.sendPacket(PacketCreator.getStorageError((byte) 0x0B));
|
||||
return;
|
||||
} else {
|
||||
chr.gainMeso(-takeoutFee, false);
|
||||
}
|
||||
|
||||
if (InventoryManipulator.checkSpace(c, item.getItemId(), item.getQuantity(), item.getOwner())) {
|
||||
if (storage.takeOut(item)) {
|
||||
chr.setUsedStorage();
|
||||
|
||||
KarmaManipulator.toggleKarmaFlagToUntradeable(item);
|
||||
InventoryManipulator.addFromDrop(c, item, false);
|
||||
|
||||
String itemName = ii.getName(item.getItemId());
|
||||
FilePrinter.print(FilePrinter.STORAGE + c.getAccountName() + ".txt", c.getPlayer().getName() + " took out " + item.getQuantity() + " " + itemName + " (" + item.getItemId() + ")");
|
||||
|
||||
storage.sendTakenOut(c, item.getInventoryType());
|
||||
} else {
|
||||
c.sendPacket(PacketCreator.enableActions());
|
||||
return;
|
||||
}
|
||||
} else {
|
||||
c.sendPacket(PacketCreator.getStorageError((byte) 0x0A));
|
||||
}
|
||||
}
|
||||
} else if (mode == 5) { // store
|
||||
short slot = p.readShort();
|
||||
int itemId = p.readInt();
|
||||
short quantity = p.readShort();
|
||||
InventoryType invType = ItemConstants.getInventoryType(itemId);
|
||||
Inventory inv = chr.getInventory(invType);
|
||||
if (slot < 1 || slot > inv.getSlotLimit()) { //player inv starts at one
|
||||
AutobanFactory.PACKET_EDIT.alert(c.getPlayer(), c.getPlayer().getName() + " tried to packet edit with storage.");
|
||||
FilePrinter.print(FilePrinter.EXPLOITS + c.getPlayer().getName() + ".txt", c.getPlayer().getName() + " tried to store item at slot " + slot);
|
||||
c.disconnect(true, false);
|
||||
return;
|
||||
}
|
||||
if (quantity < 1) {
|
||||
c.sendPacket(PacketCreator.enableActions());
|
||||
return;
|
||||
}
|
||||
if (storage.isFull()) {
|
||||
c.sendPacket(PacketCreator.getStorageError((byte) 0x11));
|
||||
return;
|
||||
}
|
||||
|
||||
int storeFee = storage.getStoreFee();
|
||||
if (chr.getMeso() < storeFee) {
|
||||
c.sendPacket(PacketCreator.getStorageError((byte) 0x0B));
|
||||
} else {
|
||||
Item item;
|
||||
|
||||
inv.lockInventory(); // thanks imbee for pointing a dupe within storage
|
||||
try {
|
||||
item = inv.getItem(slot);
|
||||
if (item != null && item.getItemId() == itemId && (item.getQuantity() >= quantity || ItemConstants.isRechargeable(itemId))) {
|
||||
if (ItemConstants.isWeddingRing(itemId) || ItemConstants.isWeddingToken(itemId)) {
|
||||
c.sendPacket(PacketCreator.enableActions());
|
||||
return;
|
||||
}
|
||||
|
||||
if (ItemConstants.isRechargeable(itemId)) {
|
||||
quantity = item.getQuantity();
|
||||
}
|
||||
|
||||
InventoryManipulator.removeFromSlot(c, invType, slot, quantity, false);
|
||||
} else {
|
||||
c.sendPacket(PacketCreator.enableActions());
|
||||
return;
|
||||
}
|
||||
|
||||
item = item.copy(); // thanks Robin Schulz & BHB88 for noticing a inventory glitch when storing items
|
||||
} finally {
|
||||
inv.unlockInventory();
|
||||
}
|
||||
|
||||
chr.gainMeso(-storeFee, false, true, false);
|
||||
|
||||
KarmaManipulator.toggleKarmaFlagToUntradeable(item);
|
||||
item.setQuantity(quantity);
|
||||
|
||||
storage.store(item); // inside a critical section, "!(storage.isFull())" is still in effect...
|
||||
chr.setUsedStorage();
|
||||
|
||||
String itemName = ii.getName(item.getItemId());
|
||||
FilePrinter.print(FilePrinter.STORAGE + c.getAccountName() + ".txt", c.getPlayer().getName() + " stored " + item.getQuantity() + " " + itemName + " (" + item.getItemId() + ")");
|
||||
|
||||
storage.sendStored(c, ItemConstants.getInventoryType(itemId));
|
||||
}
|
||||
} else if (mode == 6) { // arrange items
|
||||
if(YamlConfig.config.server.USE_STORAGE_ITEM_SORT) storage.arrangeItems(c);
|
||||
c.sendPacket(PacketCreator.enableActions());
|
||||
} else if (mode == 7) { // meso
|
||||
int meso = p.readInt();
|
||||
int storageMesos = storage.getMeso();
|
||||
int playerMesos = chr.getMeso();
|
||||
if ((meso > 0 && storageMesos >= meso) || (meso < 0 && playerMesos >= -meso)) {
|
||||
if (meso < 0 && (storageMesos - meso) < 0) {
|
||||
meso = Integer.MIN_VALUE + storageMesos;
|
||||
if (meso < playerMesos) {
|
||||
c.sendPacket(PacketCreator.enableActions());
|
||||
return;
|
||||
}
|
||||
} else if (meso > 0 && (playerMesos + meso) < 0) {
|
||||
meso = Integer.MAX_VALUE - playerMesos;
|
||||
if (meso > storageMesos) {
|
||||
c.sendPacket(PacketCreator.enableActions());
|
||||
return;
|
||||
}
|
||||
}
|
||||
storage.setMeso(storageMesos - meso);
|
||||
chr.gainMeso(meso, false, true, false);
|
||||
chr.setUsedStorage();
|
||||
FilePrinter.print(FilePrinter.STORAGE + c.getPlayer().getName() + ".txt", c.getPlayer().getName() + (meso > 0 ? " took out " : " stored ") + Math.abs(meso) + " mesos");
|
||||
storage.sendMeso(c);
|
||||
} else {
|
||||
c.sendPacket(PacketCreator.enableActions());
|
||||
return;
|
||||
}
|
||||
} else if (mode == 8) {// close... unless the player decides to enter cash shop!
|
||||
storage.close();
|
||||
item = inv.getItem(slot);
|
||||
if (item != null && item.getItemId() == itemId && (item.getQuantity() >= quantity || ItemConstants.isRechargeable(itemId))) {
|
||||
if (ItemConstants.isWeddingRing(itemId) || ItemConstants.isWeddingToken(itemId)) {
|
||||
c.sendPacket(PacketCreator.enableActions());
|
||||
return;
|
||||
}
|
||||
|
||||
if (ItemConstants.isRechargeable(itemId)) {
|
||||
quantity = item.getQuantity();
|
||||
}
|
||||
|
||||
InventoryManipulator.removeFromSlot(c, invType, slot, quantity, false);
|
||||
} else {
|
||||
c.sendPacket(PacketCreator.enableActions());
|
||||
return;
|
||||
}
|
||||
|
||||
item = item.copy(); // thanks Robin Schulz & BHB88 for noticing a inventory glitch when storing items
|
||||
} finally {
|
||||
c.releaseClient();
|
||||
inv.unlockInventory();
|
||||
}
|
||||
|
||||
chr.gainMeso(-storeFee, false, true, false);
|
||||
|
||||
KarmaManipulator.toggleKarmaFlagToUntradeable(item);
|
||||
item.setQuantity(quantity);
|
||||
|
||||
storage.store(item); // inside a critical section, "!(storage.isFull())" is still in effect...
|
||||
chr.setUsedStorage();
|
||||
|
||||
String itemName = ii.getName(item.getItemId());
|
||||
FilePrinter.print(FilePrinter.STORAGE + c.getAccountName() + ".txt", c.getPlayer().getName() + " stored " + item.getQuantity() + " " + itemName + " (" + item.getItemId() + ")");
|
||||
|
||||
storage.sendStored(c, ItemConstants.getInventoryType(itemId));
|
||||
}
|
||||
} else if (mode == 6) { // arrange items
|
||||
if (YamlConfig.config.server.USE_STORAGE_ITEM_SORT) {
|
||||
storage.arrangeItems(c);
|
||||
}
|
||||
c.sendPacket(PacketCreator.enableActions());
|
||||
} else if (mode == 7) { // meso
|
||||
int meso = p.readInt();
|
||||
int storageMesos = storage.getMeso();
|
||||
int playerMesos = chr.getMeso();
|
||||
if ((meso > 0 && storageMesos >= meso) || (meso < 0 && playerMesos >= -meso)) {
|
||||
if (meso < 0 && (storageMesos - meso) < 0) {
|
||||
meso = Integer.MIN_VALUE + storageMesos;
|
||||
if (meso < playerMesos) {
|
||||
c.sendPacket(PacketCreator.enableActions());
|
||||
return;
|
||||
}
|
||||
} else if (meso > 0 && (playerMesos + meso) < 0) {
|
||||
meso = Integer.MAX_VALUE - playerMesos;
|
||||
if (meso > storageMesos) {
|
||||
c.sendPacket(PacketCreator.enableActions());
|
||||
return;
|
||||
}
|
||||
}
|
||||
storage.setMeso(storageMesos - meso);
|
||||
chr.gainMeso(meso, false, true, false);
|
||||
chr.setUsedStorage();
|
||||
FilePrinter.print(FilePrinter.STORAGE + c.getPlayer().getName() + ".txt", c.getPlayer().getName() + (meso > 0 ? " took out " : " stored ") + Math.abs(meso) + " mesos");
|
||||
storage.sendMeso(c);
|
||||
} else {
|
||||
c.sendPacket(PacketCreator.enableActions());
|
||||
return;
|
||||
}
|
||||
} else if (mode == 8) {// close... unless the player decides to enter cash shop!
|
||||
storage.close();
|
||||
}
|
||||
} finally {
|
||||
c.releaseClient();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -41,27 +41,31 @@ import java.util.Collections;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author RonanLana - synchronization of AP transaction modules
|
||||
*/
|
||||
public class AssignAPProcessor {
|
||||
|
||||
|
||||
public static void APAutoAssignAction(InPacket inPacket, Client c) {
|
||||
Character chr = c.getPlayer();
|
||||
if (chr.getRemainingAp() < 1) return;
|
||||
|
||||
if (chr.getRemainingAp() < 1) {
|
||||
return;
|
||||
}
|
||||
|
||||
Collection<Item> equippedC = chr.getInventory(InventoryType.EQUIPPED).list();
|
||||
|
||||
|
||||
c.lockClient();
|
||||
try {
|
||||
int[] statGain = new int[4];
|
||||
int[] statUpdate = new int[4];
|
||||
statGain[0] = 0; statGain[1] = 0; statGain[2] = 0; statGain[3] = 0;
|
||||
statGain[0] = 0;
|
||||
statGain[1] = 0;
|
||||
statGain[2] = 0;
|
||||
statGain[3] = 0;
|
||||
|
||||
int remainingAp = chr.getRemainingAp();
|
||||
inPacket.skip(8);
|
||||
|
||||
if(YamlConfig.config.server.USE_SERVER_AUTOASSIGNER) {
|
||||
if (YamlConfig.config.server.USE_SERVER_AUTOASSIGNER) {
|
||||
// --------- Ronan Lana's AUTOASSIGNER ---------
|
||||
// This method excels for assigning APs in such a way to cover all equipments AP requirements.
|
||||
byte opt = inPacket.readByte(); // useful for pirate autoassigning
|
||||
@@ -74,20 +78,26 @@ public class AssignAPProcessor {
|
||||
Equip nEquip;
|
||||
|
||||
for (Item item : equippedC) { //selecting the biggest AP value of each stat from each equipped item.
|
||||
nEquip = (Equip)item;
|
||||
if(nEquip.getStr() > 0) eqpStrList.add(nEquip.getStr());
|
||||
nEquip = (Equip) item;
|
||||
if (nEquip.getStr() > 0) {
|
||||
eqpStrList.add(nEquip.getStr());
|
||||
}
|
||||
str += nEquip.getStr();
|
||||
|
||||
if(nEquip.getDex() > 0) eqpDexList.add(nEquip.getDex());
|
||||
if (nEquip.getDex() > 0) {
|
||||
eqpDexList.add(nEquip.getDex());
|
||||
}
|
||||
dex += nEquip.getDex();
|
||||
|
||||
if(nEquip.getLuk() > 0) eqpLukList.add(nEquip.getLuk());
|
||||
if (nEquip.getLuk() > 0) {
|
||||
eqpLukList.add(nEquip.getLuk());
|
||||
}
|
||||
luk += nEquip.getLuk();
|
||||
|
||||
//if(nEquip.getInt() > 0) eqpIntList.add(nEquip.getInt()); //not needed...
|
||||
int_ += nEquip.getInt();
|
||||
}
|
||||
|
||||
|
||||
statUpdate[0] = chr.getStr();
|
||||
statUpdate[1] = chr.getDex();
|
||||
statUpdate[2] = chr.getLuk();
|
||||
@@ -108,25 +118,33 @@ public class AssignAPProcessor {
|
||||
|
||||
Job stance = c.getPlayer().getJobStyle(opt);
|
||||
int prStat = 0, scStat = 0, trStat = 0, temp, tempAp = remainingAp, CAP;
|
||||
if (tempAp < 1) return;
|
||||
if (tempAp < 1) {
|
||||
return;
|
||||
}
|
||||
|
||||
Stat primary, secondary, tertiary = Stat.LUK;
|
||||
switch(stance) {
|
||||
switch (stance) {
|
||||
case MAGICIAN:
|
||||
CAP = 165;
|
||||
scStat = (chr.getLevel() + 3) - (chr.getLuk() + luk - eqpLuk);
|
||||
if(scStat < 0) scStat = 0;
|
||||
if (scStat < 0) {
|
||||
scStat = 0;
|
||||
}
|
||||
scStat = Math.min(scStat, tempAp);
|
||||
|
||||
if(tempAp > scStat) tempAp -= scStat;
|
||||
else tempAp = 0;
|
||||
if (tempAp > scStat) {
|
||||
tempAp -= scStat;
|
||||
} else {
|
||||
tempAp = 0;
|
||||
}
|
||||
|
||||
prStat = tempAp;
|
||||
int_ = prStat;
|
||||
luk = scStat;
|
||||
str = 0; dex = 0;
|
||||
str = 0;
|
||||
dex = 0;
|
||||
|
||||
if(YamlConfig.config.server.USE_AUTOASSIGN_SECONDARY_CAP && luk + chr.getLuk() > CAP) {
|
||||
if (YamlConfig.config.server.USE_AUTOASSIGN_SECONDARY_CAP && luk + chr.getLuk() > CAP) {
|
||||
temp = luk + chr.getLuk() - CAP;
|
||||
scStat -= temp;
|
||||
prStat += temp;
|
||||
@@ -141,18 +159,24 @@ public class AssignAPProcessor {
|
||||
case BOWMAN:
|
||||
CAP = 125;
|
||||
scStat = (chr.getLevel() + 5) - (chr.getStr() + str - eqpStr);
|
||||
if(scStat < 0) scStat = 0;
|
||||
if (scStat < 0) {
|
||||
scStat = 0;
|
||||
}
|
||||
scStat = Math.min(scStat, tempAp);
|
||||
|
||||
if(tempAp > scStat) tempAp -= scStat;
|
||||
else tempAp = 0;
|
||||
if (tempAp > scStat) {
|
||||
tempAp -= scStat;
|
||||
} else {
|
||||
tempAp = 0;
|
||||
}
|
||||
|
||||
prStat = tempAp;
|
||||
dex = prStat;
|
||||
str = scStat;
|
||||
int_ = 0; luk = 0;
|
||||
int_ = 0;
|
||||
luk = 0;
|
||||
|
||||
if(YamlConfig.config.server.USE_AUTOASSIGN_SECONDARY_CAP && str + chr.getStr() > CAP) {
|
||||
if (YamlConfig.config.server.USE_AUTOASSIGN_SECONDARY_CAP && str + chr.getStr() > CAP) {
|
||||
temp = str + chr.getStr() - CAP;
|
||||
scStat -= temp;
|
||||
prStat += temp;
|
||||
@@ -167,18 +191,24 @@ public class AssignAPProcessor {
|
||||
case CROSSBOWMAN:
|
||||
CAP = 120;
|
||||
scStat = chr.getLevel() - (chr.getStr() + str - eqpStr);
|
||||
if(scStat < 0) scStat = 0;
|
||||
if (scStat < 0) {
|
||||
scStat = 0;
|
||||
}
|
||||
scStat = Math.min(scStat, tempAp);
|
||||
|
||||
if(tempAp > scStat) tempAp -= scStat;
|
||||
else tempAp = 0;
|
||||
if (tempAp > scStat) {
|
||||
tempAp -= scStat;
|
||||
} else {
|
||||
tempAp = 0;
|
||||
}
|
||||
|
||||
prStat = tempAp;
|
||||
dex = prStat;
|
||||
str = scStat;
|
||||
int_ = 0; luk = 0;
|
||||
int_ = 0;
|
||||
luk = 0;
|
||||
|
||||
if(YamlConfig.config.server.USE_AUTOASSIGN_SECONDARY_CAP && str + chr.getStr() > CAP) {
|
||||
if (YamlConfig.config.server.USE_AUTOASSIGN_SECONDARY_CAP && str + chr.getStr() > CAP) {
|
||||
temp = str + chr.getStr() - CAP;
|
||||
scStat -= temp;
|
||||
prStat += temp;
|
||||
@@ -193,9 +223,11 @@ public class AssignAPProcessor {
|
||||
CAP = 160;
|
||||
|
||||
scStat = 0;
|
||||
if(chr.getDex() < 80) {
|
||||
if (chr.getDex() < 80) {
|
||||
scStat = (2 * chr.getLevel()) - (chr.getDex() + dex - eqpDex);
|
||||
if(scStat < 0) scStat = 0;
|
||||
if (scStat < 0) {
|
||||
scStat = 0;
|
||||
}
|
||||
|
||||
scStat = Math.min(80 - chr.getDex(), scStat);
|
||||
scStat = Math.min(tempAp, scStat);
|
||||
@@ -203,16 +235,20 @@ public class AssignAPProcessor {
|
||||
}
|
||||
|
||||
temp = (chr.getLevel() + 40) - Math.max(80, scStat + chr.getDex() + dex - eqpDex);
|
||||
if(temp < 0) temp = 0;
|
||||
if (temp < 0) {
|
||||
temp = 0;
|
||||
}
|
||||
temp = Math.min(tempAp, temp);
|
||||
scStat += temp;
|
||||
tempAp -= temp;
|
||||
|
||||
// thieves will upgrade STR as well only if a level-based threshold is reached.
|
||||
if(chr.getStr() >= Math.max(13, (int)(0.4 * chr.getLevel()))) {
|
||||
if(chr.getStr() < 50) {
|
||||
if (chr.getStr() >= Math.max(13, (int) (0.4 * chr.getLevel()))) {
|
||||
if (chr.getStr() < 50) {
|
||||
trStat = (chr.getLevel() - 10) - (chr.getStr() + str - eqpStr);
|
||||
if(trStat < 0) trStat = 0;
|
||||
if (trStat < 0) {
|
||||
trStat = 0;
|
||||
}
|
||||
|
||||
trStat = Math.min(50 - chr.getStr(), trStat);
|
||||
trStat = Math.min(tempAp, trStat);
|
||||
@@ -220,7 +256,9 @@ public class AssignAPProcessor {
|
||||
}
|
||||
|
||||
temp = (20 + (chr.getLevel() / 2)) - Math.max(50, trStat + chr.getStr() + str - eqpStr);
|
||||
if(temp < 0) temp = 0;
|
||||
if (temp < 0) {
|
||||
temp = 0;
|
||||
}
|
||||
temp = Math.min(tempAp, temp);
|
||||
trStat += temp;
|
||||
tempAp -= temp;
|
||||
@@ -232,12 +270,12 @@ public class AssignAPProcessor {
|
||||
str = trStat;
|
||||
int_ = 0;
|
||||
|
||||
if(YamlConfig.config.server.USE_AUTOASSIGN_SECONDARY_CAP && dex + chr.getDex() > CAP) {
|
||||
if (YamlConfig.config.server.USE_AUTOASSIGN_SECONDARY_CAP && dex + chr.getDex() > CAP) {
|
||||
temp = dex + chr.getDex() - CAP;
|
||||
scStat -= temp;
|
||||
prStat += temp;
|
||||
}
|
||||
if(YamlConfig.config.server.USE_AUTOASSIGN_SECONDARY_CAP && str + chr.getStr() > CAP) {
|
||||
if (YamlConfig.config.server.USE_AUTOASSIGN_SECONDARY_CAP && str + chr.getStr() > CAP) {
|
||||
temp = str + chr.getStr() - CAP;
|
||||
trStat -= temp;
|
||||
prStat += temp;
|
||||
@@ -252,7 +290,7 @@ public class AssignAPProcessor {
|
||||
case BRAWLER:
|
||||
default: //warrior, beginner, ...
|
||||
CAP = 300;
|
||||
|
||||
|
||||
boolean highDex = false; // thanks lucasziron & Vcoc for finding out DEX autoassigning poorly for STR-based characters
|
||||
if (chr.getLevel() < 40) {
|
||||
if (chr.getDex() >= (2 * chr.getLevel()) + 2) {
|
||||
@@ -263,13 +301,15 @@ public class AssignAPProcessor {
|
||||
highDex = true;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// other classes will start favoring more DEX only if a level-based threshold is reached.
|
||||
if(!highDex) {
|
||||
if (!highDex) {
|
||||
scStat = 0;
|
||||
if(chr.getDex() < 80) {
|
||||
if (chr.getDex() < 80) {
|
||||
scStat = (2 * chr.getLevel()) - (chr.getDex() + dex - eqpDex);
|
||||
if(scStat < 0) scStat = 0;
|
||||
if (scStat < 0) {
|
||||
scStat = 0;
|
||||
}
|
||||
|
||||
scStat = Math.min(80 - chr.getDex(), scStat);
|
||||
scStat = Math.min(tempAp, scStat);
|
||||
@@ -277,34 +317,41 @@ public class AssignAPProcessor {
|
||||
}
|
||||
|
||||
temp = (chr.getLevel() + 40) - Math.max(80, scStat + chr.getDex() + dex - eqpDex);
|
||||
if(temp < 0) temp = 0;
|
||||
if (temp < 0) {
|
||||
temp = 0;
|
||||
}
|
||||
temp = Math.min(tempAp, temp);
|
||||
scStat += temp;
|
||||
tempAp -= temp;
|
||||
} else {
|
||||
scStat = 0;
|
||||
if(chr.getDex() < 96) {
|
||||
scStat = (int)(2.4 * chr.getLevel()) - (chr.getDex() + dex - eqpDex);
|
||||
if(scStat < 0) scStat = 0;
|
||||
if (chr.getDex() < 96) {
|
||||
scStat = (int) (2.4 * chr.getLevel()) - (chr.getDex() + dex - eqpDex);
|
||||
if (scStat < 0) {
|
||||
scStat = 0;
|
||||
}
|
||||
|
||||
scStat = Math.min(96 - chr.getDex(), scStat);
|
||||
scStat = Math.min(tempAp, scStat);
|
||||
tempAp -= scStat;
|
||||
}
|
||||
|
||||
temp = 96 + (int)(1.2 * (chr.getLevel() - 40)) - Math.max(96, scStat + chr.getDex() + dex - eqpDex);
|
||||
if(temp < 0) temp = 0;
|
||||
temp = 96 + (int) (1.2 * (chr.getLevel() - 40)) - Math.max(96, scStat + chr.getDex() + dex - eqpDex);
|
||||
if (temp < 0) {
|
||||
temp = 0;
|
||||
}
|
||||
temp = Math.min(tempAp, temp);
|
||||
scStat += temp;
|
||||
tempAp -= temp;
|
||||
}
|
||||
|
||||
|
||||
prStat = tempAp;
|
||||
str = prStat;
|
||||
dex = scStat;
|
||||
int_ = 0; luk = 0;
|
||||
int_ = 0;
|
||||
luk = 0;
|
||||
|
||||
if(YamlConfig.config.server.USE_AUTOASSIGN_SECONDARY_CAP && dex + chr.getDex() > CAP) {
|
||||
if (YamlConfig.config.server.USE_AUTOASSIGN_SECONDARY_CAP && dex + chr.getDex() > CAP) {
|
||||
temp = dex + chr.getDex() - CAP;
|
||||
scStat -= temp;
|
||||
prStat += temp;
|
||||
@@ -322,7 +369,7 @@ public class AssignAPProcessor {
|
||||
extras = gainStatByType(secondary, statGain, scStat + extras, statUpdate);
|
||||
extras = gainStatByType(tertiary, statGain, trStat + extras, statUpdate);
|
||||
|
||||
if(extras > 0) { //redistribute surplus in priority order
|
||||
if (extras > 0) { //redistribute surplus in priority order
|
||||
extras = gainStatByType(primary, statGain, extras, statUpdate);
|
||||
extras = gainStatByType(secondary, statGain, extras, statUpdate);
|
||||
extras = gainStatByType(tertiary, statGain, extras, statUpdate);
|
||||
@@ -336,23 +383,23 @@ public class AssignAPProcessor {
|
||||
|
||||
c.sendPacket(PacketCreator.serverNotice(1, "Better AP applications detected:\r\nSTR: +" + statGain[0] + "\r\nDEX: +" + statGain[1] + "\r\nINT: +" + statGain[3] + "\r\nLUK: +" + statGain[2]));
|
||||
} else {
|
||||
if(inPacket.available() < 16) {
|
||||
if (inPacket.available() < 16) {
|
||||
AutobanFactory.PACKET_EDIT.alert(chr, "Didn't send full packet for Auto Assign.");
|
||||
|
||||
|
||||
c.disconnect(true, false);
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
for (int i = 0; i < 2; i++) {
|
||||
int type = inPacket.readInt();
|
||||
int tempVal = inPacket.readInt();
|
||||
if (tempVal < 0 || tempVal > remainingAp) {
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
gainStatByType(Stat.getBy5ByteEncoding(type), statGain, tempVal, statUpdate);
|
||||
}
|
||||
|
||||
|
||||
chr.assignStrDexIntLuk(statGain[0], statGain[1], statGain[3], statGain[2]);
|
||||
c.sendPacket(PacketCreator.enableActions());
|
||||
}
|
||||
@@ -360,14 +407,16 @@ public class AssignAPProcessor {
|
||||
c.unlockClient();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
private static int getNthHighestStat(List<Short> statList, short rank) { // ranks from 0
|
||||
return(statList.size() <= rank ? 0 : statList.get(rank));
|
||||
return (statList.size() <= rank ? 0 : statList.get(rank));
|
||||
}
|
||||
|
||||
|
||||
private static int gainStatByType(Stat type, int[] statGain, int gain, int[] statUpdate) {
|
||||
if(gain <= 0) return 0;
|
||||
|
||||
if (gain <= 0) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
int newVal = 0;
|
||||
if (type.equals(Stat.STR)) {
|
||||
newVal = statUpdate[0] + gain;
|
||||
@@ -406,18 +455,20 @@ public class AssignAPProcessor {
|
||||
statUpdate[1] = newVal;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
if (newVal > YamlConfig.config.server.MAX_AP) {
|
||||
return newVal - YamlConfig.config.server.MAX_AP;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
private static Stat getQuaternaryStat(Job stance) {
|
||||
if(stance != Job.MAGICIAN) return Stat.INT;
|
||||
if (stance != Job.MAGICIAN) {
|
||||
return Stat.INT;
|
||||
}
|
||||
return Stat.STR;
|
||||
}
|
||||
|
||||
|
||||
public static boolean APResetAction(Client c, int APFrom, int APTo) {
|
||||
c.lockClient();
|
||||
try {
|
||||
@@ -473,14 +524,14 @@ public class AssignAPProcessor {
|
||||
}
|
||||
break;
|
||||
case 2048: // HP
|
||||
if(YamlConfig.config.server.USE_ENFORCE_HPMP_SWAP) {
|
||||
if (YamlConfig.config.server.USE_ENFORCE_HPMP_SWAP) {
|
||||
if (APTo != 8192) {
|
||||
player.message("You can only swap HP ability points to MP.");
|
||||
c.sendPacket(PacketCreator.enableActions());
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
if (player.getHpMpApUsed() < 1) {
|
||||
player.message("You don't have enough HPMP stat points to spend on AP Reset.");
|
||||
c.sendPacket(PacketCreator.enableActions());
|
||||
@@ -494,24 +545,24 @@ public class AssignAPProcessor {
|
||||
c.sendPacket(PacketCreator.enableActions());
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
int curHp = player.getHp();
|
||||
int hplose = -takeHp(player.getJob());
|
||||
player.assignHP(hplose, -1);
|
||||
if (!YamlConfig.config.server.USE_FIXED_RATIO_HPMP_UPDATE) {
|
||||
player.updateHp(Math.max(1, curHp + hplose));
|
||||
}
|
||||
|
||||
|
||||
break;
|
||||
case 8192: // MP
|
||||
if(YamlConfig.config.server.USE_ENFORCE_HPMP_SWAP) {
|
||||
if (YamlConfig.config.server.USE_ENFORCE_HPMP_SWAP) {
|
||||
if (APTo != 2048) {
|
||||
player.message("You can only swap MP ability points to HP.");
|
||||
c.sendPacket(PacketCreator.enableActions());
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
if (player.getHpMpApUsed() < 1) {
|
||||
player.message("You don't have enough HPMP stat points to spend on AP Reset.");
|
||||
c.sendPacket(PacketCreator.enableActions());
|
||||
@@ -538,7 +589,7 @@ public class AssignAPProcessor {
|
||||
c.sendPacket(PacketCreator.enableActions());
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
int curMp = player.getMp();
|
||||
int mplose = -takeMp(job);
|
||||
player.assignMP(mplose, -1);
|
||||
@@ -557,7 +608,7 @@ public class AssignAPProcessor {
|
||||
c.unlockClient();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public static void APAssignAction(Client c, int num) {
|
||||
c.lockClient();
|
||||
try {
|
||||
@@ -566,7 +617,7 @@ public class AssignAPProcessor {
|
||||
c.unlockClient();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
private static boolean addStat(Character chr, int apTo, boolean usedAPReset) {
|
||||
switch (apTo) {
|
||||
case 64:
|
||||
@@ -621,17 +672,18 @@ public class AssignAPProcessor {
|
||||
private static int calcHpChange(Character player, boolean usedAPReset) {
|
||||
Job job = player.getJob();
|
||||
int MaxHP = 0;
|
||||
|
||||
|
||||
if (job.isA(Job.WARRIOR) || job.isA(Job.DAWNWARRIOR1)) {
|
||||
if(!usedAPReset) {
|
||||
if (!usedAPReset) {
|
||||
Skill increaseHP = SkillFactory.getSkill(job.isA(Job.DAWNWARRIOR1) ? DawnWarrior.MAX_HP_INCREASE : Warrior.IMPROVED_MAXHP);
|
||||
int sLvl = player.getSkillLevel(increaseHP);
|
||||
|
||||
if(sLvl > 0)
|
||||
if (sLvl > 0) {
|
||||
MaxHP += increaseHP.getEffect(sLvl).getY();
|
||||
}
|
||||
}
|
||||
|
||||
if(YamlConfig.config.server.USE_RANDOMIZE_HPMP_GAIN) {
|
||||
|
||||
if (YamlConfig.config.server.USE_RANDOMIZE_HPMP_GAIN) {
|
||||
if (usedAPReset) {
|
||||
MaxHP += 20;
|
||||
} else {
|
||||
@@ -640,8 +692,8 @@ public class AssignAPProcessor {
|
||||
} else {
|
||||
MaxHP += 20;
|
||||
}
|
||||
} else if(job.isA(Job.ARAN1)) {
|
||||
if(YamlConfig.config.server.USE_RANDOMIZE_HPMP_GAIN) {
|
||||
} else if (job.isA(Job.ARAN1)) {
|
||||
if (YamlConfig.config.server.USE_RANDOMIZE_HPMP_GAIN) {
|
||||
if (usedAPReset) {
|
||||
MaxHP += 20;
|
||||
} else {
|
||||
@@ -651,7 +703,7 @@ public class AssignAPProcessor {
|
||||
MaxHP += 28;
|
||||
}
|
||||
} else if (job.isA(Job.MAGICIAN) || job.isA(Job.BLAZEWIZARD1)) {
|
||||
if(YamlConfig.config.server.USE_RANDOMIZE_HPMP_GAIN) {
|
||||
if (YamlConfig.config.server.USE_RANDOMIZE_HPMP_GAIN) {
|
||||
if (usedAPReset) {
|
||||
MaxHP += 6;
|
||||
} else {
|
||||
@@ -661,7 +713,7 @@ public class AssignAPProcessor {
|
||||
MaxHP += 6;
|
||||
}
|
||||
} else if (job.isA(Job.THIEF) || job.isA(Job.NIGHTWALKER1)) {
|
||||
if(YamlConfig.config.server.USE_RANDOMIZE_HPMP_GAIN) {
|
||||
if (YamlConfig.config.server.USE_RANDOMIZE_HPMP_GAIN) {
|
||||
if (usedAPReset) {
|
||||
MaxHP += 16;
|
||||
} else {
|
||||
@@ -670,8 +722,8 @@ public class AssignAPProcessor {
|
||||
} else {
|
||||
MaxHP += 16;
|
||||
}
|
||||
} else if(job.isA(Job.BOWMAN) || job.isA(Job.WINDARCHER1)) {
|
||||
if(YamlConfig.config.server.USE_RANDOMIZE_HPMP_GAIN) {
|
||||
} else if (job.isA(Job.BOWMAN) || job.isA(Job.WINDARCHER1)) {
|
||||
if (YamlConfig.config.server.USE_RANDOMIZE_HPMP_GAIN) {
|
||||
if (usedAPReset) {
|
||||
MaxHP += 16;
|
||||
} else {
|
||||
@@ -681,15 +733,16 @@ public class AssignAPProcessor {
|
||||
MaxHP += 16;
|
||||
}
|
||||
} else if (job.isA(Job.PIRATE) || job.isA(Job.THUNDERBREAKER1)) {
|
||||
if(!usedAPReset) {
|
||||
if (!usedAPReset) {
|
||||
Skill increaseHP = SkillFactory.getSkill(job.isA(Job.PIRATE) ? Brawler.IMPROVE_MAX_HP : ThunderBreaker.IMPROVE_MAX_HP);
|
||||
int sLvl = player.getSkillLevel(increaseHP);
|
||||
|
||||
if(sLvl > 0)
|
||||
if (sLvl > 0) {
|
||||
MaxHP += increaseHP.getEffect(sLvl).getY();
|
||||
}
|
||||
}
|
||||
|
||||
if(YamlConfig.config.server.USE_RANDOMIZE_HPMP_GAIN) {
|
||||
|
||||
if (YamlConfig.config.server.USE_RANDOMIZE_HPMP_GAIN) {
|
||||
if (usedAPReset) {
|
||||
MaxHP += 18;
|
||||
} else {
|
||||
@@ -701,23 +754,23 @@ public class AssignAPProcessor {
|
||||
} else if (usedAPReset) {
|
||||
MaxHP += 8;
|
||||
} else {
|
||||
if(YamlConfig.config.server.USE_RANDOMIZE_HPMP_GAIN) {
|
||||
if (YamlConfig.config.server.USE_RANDOMIZE_HPMP_GAIN) {
|
||||
MaxHP += Randomizer.rand(8, 12);
|
||||
} else {
|
||||
MaxHP += 10;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
return MaxHP;
|
||||
}
|
||||
|
||||
private static int calcMpChange(Character player, boolean usedAPReset) {
|
||||
Job job = player.getJob();
|
||||
int MaxMP = 0;
|
||||
|
||||
|
||||
if (job.isA(Job.WARRIOR) || job.isA(Job.DAWNWARRIOR1) || job.isA(Job.ARAN1)) {
|
||||
if(YamlConfig.config.server.USE_RANDOMIZE_HPMP_GAIN) {
|
||||
if(!usedAPReset) {
|
||||
if (YamlConfig.config.server.USE_RANDOMIZE_HPMP_GAIN) {
|
||||
if (!usedAPReset) {
|
||||
MaxMP += (Randomizer.rand(2, 4) + (player.getInt() / 10));
|
||||
} else {
|
||||
MaxMP += 2;
|
||||
@@ -726,16 +779,17 @@ public class AssignAPProcessor {
|
||||
MaxMP += 3;
|
||||
}
|
||||
} else if (job.isA(Job.MAGICIAN) || job.isA(Job.BLAZEWIZARD1)) {
|
||||
if(!usedAPReset) {
|
||||
if (!usedAPReset) {
|
||||
Skill increaseMP = SkillFactory.getSkill(job.isA(Job.BLAZEWIZARD1) ? BlazeWizard.INCREASING_MAX_MP : Magician.IMPROVED_MAX_MP_INCREASE);
|
||||
int sLvl = player.getSkillLevel(increaseMP);
|
||||
|
||||
if(sLvl > 0)
|
||||
if (sLvl > 0) {
|
||||
MaxMP += increaseMP.getEffect(sLvl).getY();
|
||||
}
|
||||
}
|
||||
|
||||
if(YamlConfig.config.server.USE_RANDOMIZE_HPMP_GAIN) {
|
||||
if(!usedAPReset) {
|
||||
|
||||
if (YamlConfig.config.server.USE_RANDOMIZE_HPMP_GAIN) {
|
||||
if (!usedAPReset) {
|
||||
MaxMP += (Randomizer.rand(12, 16) + (player.getInt() / 20));
|
||||
} else {
|
||||
MaxMP += 18;
|
||||
@@ -744,8 +798,8 @@ public class AssignAPProcessor {
|
||||
MaxMP += 18;
|
||||
}
|
||||
} else if (job.isA(Job.BOWMAN) || job.isA(Job.WINDARCHER1)) {
|
||||
if(YamlConfig.config.server.USE_RANDOMIZE_HPMP_GAIN) {
|
||||
if(!usedAPReset) {
|
||||
if (YamlConfig.config.server.USE_RANDOMIZE_HPMP_GAIN) {
|
||||
if (!usedAPReset) {
|
||||
MaxMP += (Randomizer.rand(6, 8) + (player.getInt() / 10));
|
||||
} else {
|
||||
MaxMP += 10;
|
||||
@@ -753,9 +807,9 @@ public class AssignAPProcessor {
|
||||
} else {
|
||||
MaxMP += 10;
|
||||
}
|
||||
} else if(job.isA(Job.THIEF) || job.isA(Job.NIGHTWALKER1)) {
|
||||
if(YamlConfig.config.server.USE_RANDOMIZE_HPMP_GAIN) {
|
||||
if(!usedAPReset) {
|
||||
} else if (job.isA(Job.THIEF) || job.isA(Job.NIGHTWALKER1)) {
|
||||
if (YamlConfig.config.server.USE_RANDOMIZE_HPMP_GAIN) {
|
||||
if (!usedAPReset) {
|
||||
MaxMP += (Randomizer.rand(6, 8) + (player.getInt() / 10));
|
||||
} else {
|
||||
MaxMP += 10;
|
||||
@@ -764,8 +818,8 @@ public class AssignAPProcessor {
|
||||
MaxMP += 10;
|
||||
}
|
||||
} else if (job.isA(Job.PIRATE) || job.isA(Job.THUNDERBREAKER1)) {
|
||||
if(YamlConfig.config.server.USE_RANDOMIZE_HPMP_GAIN) {
|
||||
if(!usedAPReset) {
|
||||
if (YamlConfig.config.server.USE_RANDOMIZE_HPMP_GAIN) {
|
||||
if (!usedAPReset) {
|
||||
MaxMP += (Randomizer.rand(7, 9) + (player.getInt() / 10));
|
||||
} else {
|
||||
MaxMP += 14;
|
||||
@@ -774,8 +828,8 @@ public class AssignAPProcessor {
|
||||
MaxMP += 14;
|
||||
}
|
||||
} else {
|
||||
if(YamlConfig.config.server.USE_RANDOMIZE_HPMP_GAIN) {
|
||||
if(!usedAPReset) {
|
||||
if (YamlConfig.config.server.USE_RANDOMIZE_HPMP_GAIN) {
|
||||
if (!usedAPReset) {
|
||||
MaxMP += (Randomizer.rand(4, 6) + (player.getInt() / 10));
|
||||
} else {
|
||||
MaxMP += 6;
|
||||
@@ -784,48 +838,48 @@ public class AssignAPProcessor {
|
||||
MaxMP += 6;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
return MaxMP;
|
||||
}
|
||||
|
||||
|
||||
private static int takeHp(Job job) {
|
||||
int MaxHP = 0;
|
||||
|
||||
|
||||
if (job.isA(Job.WARRIOR) || job.isA(Job.DAWNWARRIOR1) || job.isA(Job.ARAN1)) {
|
||||
MaxHP += 54;
|
||||
} else if (job.isA(Job.MAGICIAN) || job.isA(Job.BLAZEWIZARD1)) {
|
||||
MaxHP += 10;
|
||||
} else if (job.isA(Job.THIEF) || job.isA(Job.NIGHTWALKER1)) {
|
||||
MaxHP += 20;
|
||||
} else if(job.isA(Job.BOWMAN) || job.isA(Job.WINDARCHER1)) {
|
||||
} else if (job.isA(Job.BOWMAN) || job.isA(Job.WINDARCHER1)) {
|
||||
MaxHP += 20;
|
||||
} else if (job.isA(Job.PIRATE) || job.isA(Job.THUNDERBREAKER1)) {
|
||||
MaxHP += 42;
|
||||
} else {
|
||||
MaxHP += 12;
|
||||
}
|
||||
|
||||
|
||||
return MaxHP;
|
||||
}
|
||||
|
||||
|
||||
private static int takeMp(Job job) {
|
||||
int MaxMP = 0;
|
||||
|
||||
|
||||
if (job.isA(Job.WARRIOR) || job.isA(Job.DAWNWARRIOR1) || job.isA(Job.ARAN1)) {
|
||||
MaxMP += 4;
|
||||
} else if (job.isA(Job.MAGICIAN) || job.isA(Job.BLAZEWIZARD1)) {
|
||||
MaxMP += 31;
|
||||
} else if (job.isA(Job.BOWMAN) || job.isA(Job.WINDARCHER1)) {
|
||||
MaxMP += 12;
|
||||
} else if(job.isA(Job.THIEF) || job.isA(Job.NIGHTWALKER1)) {
|
||||
} else if (job.isA(Job.THIEF) || job.isA(Job.NIGHTWALKER1)) {
|
||||
MaxMP += 12;
|
||||
} else if (job.isA(Job.PIRATE) || job.isA(Job.THUNDERBREAKER1)) {
|
||||
MaxMP += 16;
|
||||
} else {
|
||||
MaxMP += 8;
|
||||
}
|
||||
|
||||
|
||||
return MaxMP;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
@@ -34,11 +34,10 @@ import tools.FilePrinter;
|
||||
import tools.PacketCreator;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author RonanLana - synchronization of SP transaction modules
|
||||
*/
|
||||
public class AssignSPProcessor {
|
||||
|
||||
|
||||
public static boolean canSPAssign(Client c, int skillid) {
|
||||
if (skillid == Aran.HIDDEN_FULL_DOUBLE || skillid == Aran.HIDDEN_FULL_TRIPLE || skillid == Aran.HIDDEN_OVER_DOUBLE || skillid == Aran.HIDDEN_OVER_TRIPLE) {
|
||||
c.sendPacket(PacketCreator.enableActions());
|
||||
@@ -53,21 +52,21 @@ public class AssignSPProcessor {
|
||||
c.disconnect(true, false);
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
public static void SPAssignAction(Client c, int skillid) {
|
||||
c.lockClient();
|
||||
try {
|
||||
if (!canSPAssign(c, skillid)) {
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
Character player = c.getPlayer();
|
||||
int remainingSp = player.getRemainingSps()[GameConstants.getSkillBook(skillid/10000)];
|
||||
int remainingSp = player.getRemainingSps()[GameConstants.getSkillBook(skillid / 10000)];
|
||||
boolean isBeginnerSkill = false;
|
||||
|
||||
|
||||
if (skillid % 10000000 > 999 && skillid % 10000000 < 1003) {
|
||||
int total = 0;
|
||||
for (int i = 0; i < 3; i++) {
|
||||
@@ -75,23 +74,23 @@ public class AssignSPProcessor {
|
||||
}
|
||||
remainingSp = Math.min((player.getLevel() - 1), 6) - total;
|
||||
isBeginnerSkill = true;
|
||||
}
|
||||
}
|
||||
Skill skill = SkillFactory.getSkill(skillid);
|
||||
int curLevel = player.getSkillLevel(skill);
|
||||
if ((remainingSp > 0 && curLevel + 1 <= (skill.isFourthJob() ? player.getMasterLevel(skill) : skill.getMaxLevel()))) {
|
||||
if (!isBeginnerSkill) {
|
||||
player.gainSp(-1, GameConstants.getSkillBook(skillid/10000), false);
|
||||
player.gainSp(-1, GameConstants.getSkillBook(skillid / 10000), false);
|
||||
} else {
|
||||
player.sendPacket(PacketCreator.enableActions());
|
||||
}
|
||||
if (skill.getId() == Aran.FULL_SWING) {
|
||||
player.changeSkillLevel(skill, (byte) (curLevel + 1), player.getMasterLevel(skill), player.getSkillExpiration(skill));
|
||||
player.changeSkillLevel(SkillFactory.getSkill(Aran.HIDDEN_FULL_DOUBLE), player.getSkillLevel(skill), player.getMasterLevel(skill), player.getSkillExpiration(skill));
|
||||
player.changeSkillLevel(SkillFactory.getSkill(Aran.HIDDEN_FULL_TRIPLE), player.getSkillLevel(skill), player.getMasterLevel(skill), player.getSkillExpiration(skill));
|
||||
player.changeSkillLevel(SkillFactory.getSkill(Aran.HIDDEN_FULL_DOUBLE), player.getSkillLevel(skill), player.getMasterLevel(skill), player.getSkillExpiration(skill));
|
||||
player.changeSkillLevel(SkillFactory.getSkill(Aran.HIDDEN_FULL_TRIPLE), player.getSkillLevel(skill), player.getMasterLevel(skill), player.getSkillExpiration(skill));
|
||||
} else if (skill.getId() == Aran.OVER_SWING) {
|
||||
player.changeSkillLevel(skill, (byte) (curLevel + 1), player.getMasterLevel(skill), player.getSkillExpiration(skill));
|
||||
player.changeSkillLevel(SkillFactory.getSkill(Aran.HIDDEN_OVER_DOUBLE), player.getSkillLevel(skill), player.getMasterLevel(skill), player.getSkillExpiration(skill));
|
||||
player.changeSkillLevel(SkillFactory.getSkill(Aran.HIDDEN_OVER_TRIPLE), player.getSkillLevel(skill), player.getMasterLevel(skill), player.getSkillExpiration(skill));
|
||||
player.changeSkillLevel(SkillFactory.getSkill(Aran.HIDDEN_OVER_DOUBLE), player.getSkillLevel(skill), player.getMasterLevel(skill), player.getSkillExpiration(skill));
|
||||
player.changeSkillLevel(SkillFactory.getSkill(Aran.HIDDEN_OVER_TRIPLE), player.getSkillLevel(skill), player.getMasterLevel(skill), player.getSkillExpiration(skill));
|
||||
} else {
|
||||
player.changeSkillLevel(skill, (byte) (curLevel + 1), player.getMasterLevel(skill), player.getSkillExpiration(skill));
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user