Compare commits

..

8 Commits

Author SHA1 Message Date
Ponk
eb603e7ee9 Merge pull request #242 from P0nk/fix/cash-shop-surprise-count #patch
Fix cash shop surprise count not properly updated on usage
2024-06-15 08:35:58 +02:00
P0nk
b67b29def5 Fix cash shop surprise count not properly updated on usage
This reverts the hacky solution made in db82cbcfae
2024-06-15 08:31:24 +02:00
Ponk
d22d9b603b Merge pull request #228 from HarkuLi/feat/fix-npc-gain-meso #patch
NPC: Fix type casting error for `gainMeso()` method
2024-06-14 21:44:10 +02:00
Ponk
16b0a36c86 Merge pull request #238 from channarit1994/master #patch
Surprise Box Implementation
2024-06-14 21:33:08 +02:00
Ponk
313f48d4ce Merge pull request #237 from peamy/master #patch
Check if the amount of damage lines doesn't exceed the max (autoban)
2024-06-14 20:11:39 +02:00
Channarit Sittiparat
db82cbcfae Surprise Box Implementation
- Added showCashInventory after a successful gachapon opening in the CashShopSurpriseHandler.
- Added getItemsSize() condition to check the inventory size before proceeding with the cash shop surprise opening
2024-06-13 20:02:40 +07:00
remsus
eed47a9064 Check if the amount of damage lines doesn't exceed the max (autoban) 2024-06-11 18:44:47 +02:00
HarkuLi
0d684c1400 NPC: Fix type casting error for gainMeso() method
Number type values might be passed into the `gainMeso()` method in js
scripts, and thus it expects a `gainMeso(Double gain)` method in the
`NPCConversationManager` class.
2024-03-02 15:38:22 +08:00
4 changed files with 33 additions and 6 deletions

View File

@@ -689,9 +689,10 @@ public abstract class AbstractDealDamageHandler extends AbstractPacketHandler {
calcDmgMax = chr.calculateMaxBaseDamage(chr.getTotalWatk());
}
StatEffect effect = null;
if (ret.skill != 0) {
Skill skill = SkillFactory.getSkill(ret.skill);
StatEffect effect = skill.getEffect(ret.skilllevel);
effect = skill.getEffect(ret.skilllevel);
if (magic) {
// Since the skill is magic based, use the magic formula
@@ -930,6 +931,16 @@ public abstract class AbstractDealDamageHandler extends AbstractPacketHandler {
damage = -Integer.MAX_VALUE + damage - 1;
}
if(effect != null) {
int maxattack = Math.max(effect.getBulletCount(), effect.getAttackCount());
if (shadowPartner) {
maxattack = maxattack * 2;
}
if (ret.numDamage > maxattack) {
AutobanFactory.DAMAGE_HACK.addPoint(chr.getAutobanManager(), "Too many lines: " + ret.numDamage + " Max lines: " + maxattack + " SID: " + ret.skill + " MobID: " + (monster != null ? monster.getId() : "null") + " Map: " + chr.getMap().getMapName() + " (" + chr.getMapId() + ")");
}
}
allDamageNumbers.add(damage);
}
if (ret.skill != Corsair.RAPID_FIRE || ret.skill != Aran.HIDDEN_FULL_DOUBLE || ret.skill != Aran.HIDDEN_FULL_TRIPLE || ret.skill != Aran.HIDDEN_OVER_DOUBLE || ret.skill != Aran.HIDDEN_OVER_TRIPLE) {

View File

@@ -40,7 +40,7 @@ public class CashShopSurpriseHandler extends AbstractPacketHandler {
if (cssResult != null) {
Item cssItem = cssResult.getLeft(), cssBox = cssResult.getRight();
c.sendPacket(PacketCreator.onCashGachaponOpenSuccess(c.getAccID(), cssBox.getSN(), cssBox.getQuantity(), cssItem, cssItem.getItemId(), cssItem.getQuantity(), true));
c.sendPacket(PacketCreator.onCashGachaponOpenSuccess(c.getAccID(), cssBox.getCashId(), cssBox.getQuantity(), cssItem, cssItem.getItemId(), cssItem.getQuantity(), true));
} else {
c.sendPacket(PacketCreator.onCashItemGachaponOpenFailed());
}

View File

@@ -278,6 +278,10 @@ public class NPCConversationManager extends AbstractPlayerInteraction {
getPlayer().gainMeso(gain);
}
public void gainMeso(Double gain) {
getPlayer().gainMeso(gain.intValue());
}
public void gainExp(int gain) {
getPlayer().gainExp(gain, true, true);
}

View File

@@ -36,6 +36,7 @@ import provider.DataProviderFactory;
import provider.DataTool;
import provider.wz.WZFiles;
import tools.DatabaseConnection;
import tools.PacketCreator;
import tools.Pair;
import java.sql.Connection;
@@ -407,6 +408,17 @@ public class CashShop {
}
}
public int getItemsSize() {
int size = 0;
lock.lock();
try {
size = inventory.size();
} finally {
lock.unlock();
}
return size;
}
public List<Integer> getWishList() {
return wishList;
}
@@ -544,14 +556,14 @@ public class CashShop {
Item css = getCashShopItemByItemid(ItemId.CASH_SHOP_SURPRISE);
if (css != null) {
if (getItemsSize() >= 100) {
return null;
}
CashItem cItem = CashItemFactory.getRandomCashItem();
if (cItem != null) {
if (css.getQuantity() > 1) {
/* if(NOT ENOUGH SPACE) { looks like we're not dealing with cash inventory limit whatsoever, k then
return null;
} */
css.setQuantity((short) (css.getQuantity() - 1));
} else {
removeFromInventory(css);