Compare commits

...

7 Commits

Author SHA1 Message Date
Ponk
aab9823a06 Merge pull request #227 from HarkuLi/feat/fix-ariant-coliseum #patch
Ariant Coliseum: Fix score counting and trade conversation
2024-06-19 17:58:38 +02:00
HarkuLi
3f800c4a68 Ignore .DS_Store files 2024-06-19 18:43:26 +08:00
HarkuLi
31e901ab6d Ariant Coliseum: Fix score counting and trade conversation 2024-06-19 18:42:31 +08:00
Ponk
238c01baf4 Merge pull request #245 from P0nk/fix/energy-charge-crash #patch
Fix Energy charge crashing certain other players
2024-06-16 19:13:03 +02:00
P0nk
5a4bdd343c Fix Energy charge crashing certain other players
Crabo in #bug-report (2024-06-10):
"(...) this will crash everyone in the map besides the bucc and 1 character, when a bucc (or TB) charges energy and a character with an ID that's a multiple of 102 is in the same map (and the energy reaches that number so if character ID is 204 it will reach that after 2 hits and DC the whole map besides the bucc and that char with id 204).
 Thanks to others for helping me fix it. Thought I'd report it!"
2024-06-16 19:09:21 +02:00
Ponk
d916502f58 Merge pull request #244 from P0nk/fix/cash-shop-surprise-package #patch
Fix able to get package from Cash shop surprise
2024-06-16 16:15:30 +02:00
P0nk
1791365e0f Fix able to get package from Cash shop surprise
Packages aren't real items and crash the client.
2024-06-16 16:06:29 +02:00
7 changed files with 50 additions and 35 deletions

3
.gitignore vendored
View File

@@ -21,3 +21,6 @@
# Database
database/docker-db-data
database/docker-pg-db-data
# macOS files
.DS_Store

View File

@@ -32,14 +32,14 @@ function action(mode, type, selection) {
} else if (status == 1) {
if (selection == 0) {
apqpoints = cm.getPlayer().getAriantPoints();
if (apqpoints < 100) {
cm.sendOk("Your Battle Arena score: #b" + apqpoints + "#k points. You need to surpass #b100 points#k so that I can give you the #bPalm Tree Beach Chair#k. Talk to me again when you have enough points.");
cm.dispose();
if (apqpoints >= 100) {
cm.sendNext("Wow, it looks like you got the #b100#k points ready to trade, let's trade?!");
} else if (apqpoints + arena.getAriantRewardTier(cm.getPlayer()) >= 100) {
cm.sendOk("Your Battle Arena score: #b" + apqpoints + "#k points and you pratically already have that score! Talk to my wife, #p2101016#to get them and then re-chat with me!");
cm.sendOk("Your Battle Arena score: #b" + apqpoints + "#k points and you pratically already have that score! Talk to my wife, #p2101016# to get them and then re-chat with me!");
cm.dispose();
} else {
cm.sendNext("Wow, it looks like you got the #b100#k points ready to trade, let's trade?!");
cm.sendOk("Your Battle Arena score: #b" + apqpoints + "#k points. You need to surpass #b100 points#k so that I can give you the #bPalm Tree Beach Chair#k. Talk to me again when you have enough points.");
cm.dispose();
}
} else if (selection == 1) {
cm.sendOk("The main objective of the Battle Arena is to allow the player to accumulate points so that they can be traded honorably for the highest prize: the #bPalm Tree Beach Chair#k. Collect points during the battles and talk to me when it's time to get the prize. In each battle, the player is given the opportunity to score points based on the amount of jewelry that the player has at the end. But be careful! If your points distance from other players #ris too high#k, this will have been all for nothing and you will earn mere #r1 point#k only.");

View File

@@ -6063,7 +6063,8 @@ public class Character extends AbstractCharacterObject {
sendPacket(PacketCreator.giveBuff(energybar, 0, stat));
sendPacket(PacketCreator.showOwnBuffEffect(energycharge.getId(), 2));
getMap().broadcastPacket(this, PacketCreator.showBuffEffect(id, energycharge.getId(), 2));
getMap().broadcastPacket(this, PacketCreator.giveForeignBuff(energybar, stat));
getMap().broadcastPacket(this, PacketCreator.giveForeignPirateBuff(id, energycharge.getId(),
ceffect.getDuration(), stat));
}
if (energybar >= 10000 && energybar < 11000) {
energybar = 15000;

View File

@@ -312,6 +312,10 @@ public class ItemId {
return itemId == NX_CARD_100 || itemId == NX_CARD_250;
}
public static boolean isCashPackage(int itemId) {
return itemId / 10000 == 910;
}
// Face expression
private static final int FACE_EXPRESSION_MIN = 5160000;
private static final int FACE_EXPRESSION_MAX = 5160014;

View File

@@ -93,6 +93,7 @@ public final class UseCatchItemHandler extends AbstractPacketHandler {
mob.getMap().killMonster(mob, null, false);
InventoryManipulator.removeById(c, InventoryType.USE, itemId, 1, true, true);
InventoryManipulator.addById(c, ItemId.ARPQ_SPIRIT_JEWEL, (short) 1, "", -1);
chr.updateAriantScore();
} else {
chr.getMap().broadcastMessage(PacketCreator.catchMonster(monsterid, itemId, (byte) 0));
}

View File

@@ -49,6 +49,7 @@ import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.Optional;
import java.util.Random;
import java.util.concurrent.locks.Lock;
import java.util.concurrent.locks.ReentrantLock;
@@ -231,7 +232,6 @@ public class CashShop {
public static class CashItemFactory {
private static volatile Map<Integer, CashItem> items = new HashMap<>();
private static volatile List<Integer> randomitemsns = new ArrayList<>();
private static volatile Map<Integer, List<Integer>> packages = new HashMap<>();
private static volatile List<SpecialCashItem> specialcashitems = new ArrayList<>();
@@ -239,7 +239,6 @@ public class CashShop {
DataProvider etc = DataProviderFactory.getDataProvider(WZFiles.ETC);
Map<Integer, CashItem> loadedItems = new HashMap<>();
List<Integer> onSaleItems = new ArrayList<>();
for (Data item : etc.getData("Commodity.img").getChildren()) {
int sn = DataTool.getIntConvert("SN", item);
int itemId = DataTool.getIntConvert("ItemId", item);
@@ -248,13 +247,8 @@ public class CashShop {
short count = (short) DataTool.getIntConvert("Count", item, 1);
boolean onSale = DataTool.getIntConvert("OnSale", item, 0) == 1;
loadedItems.put(sn, new CashItem(sn, itemId, price, period, count, onSale));
if (onSale) {
onSaleItems.add(sn);
}
}
CashItemFactory.items = loadedItems;
CashItemFactory.randomitemsns = onSaleItems;
Map<Integer, List<Integer>> loadedPackages = new HashMap<>();
for (Data cashPackage : etc.getData("CashPackage.img").getChildren()) {
@@ -281,13 +275,20 @@ public class CashShop {
CashItemFactory.specialcashitems = loadedSpecialItems;
}
public static CashItem getRandomCashItem() {
if (randomitemsns.isEmpty()) {
return null;
public static Optional<CashItem> getRandomCashItem() {
if (items.isEmpty()) {
return Optional.empty();
}
int rnd = (int) (Math.random() * randomitemsns.size());
return items.get(randomitemsns.get(rnd));
List<CashItem> itemPool = items.values().stream()
.filter(CashItem::isOnSale)
.filter(cashItem -> !ItemId.isCashPackage(cashItem.itemId))
.toList();
return Optional.of(getRandomItem(itemPool));
}
private static CashItem getRandomItem(List<CashItem> items) {
return items.get(new Random().nextInt(items.size()));
}
public static CashItem getItem(int sn) {
@@ -311,20 +312,6 @@ public class CashShop {
public static List<SpecialCashItem> getSpecialCashItems() {
return specialcashitems;
}
public static void reloadSpecialCashItems() {//Yay?
List<SpecialCashItem> loadedSpecialItems = new ArrayList<>();
try (Connection con = DatabaseConnection.getConnection();
PreparedStatement ps = con.prepareStatement("SELECT * FROM specialcashitems");
ResultSet rs = ps.executeQuery()) {
while (rs.next()) {
loadedSpecialItems.add(new SpecialCashItem(rs.getInt("sn"), rs.getInt("modifier"), rs.getByte("info")));
}
} catch (SQLException ex) {
ex.printStackTrace();
}
CashItemFactory.specialcashitems = loadedSpecialItems;
}
}
public record CashShopSurpriseResult(Item usedCashShopSurprise, Item reward) {
@@ -545,8 +532,8 @@ public class CashShop {
return Optional.empty();
}
CashItem cashItemReward = CashItemFactory.getRandomCashItem();
if (cashItemReward == null) {
Optional<CashItem> cashItemReward = CashItemFactory.getRandomCashItem();
if (cashItemReward.isEmpty()) {
return Optional.empty();
}
@@ -556,7 +543,7 @@ public class CashShop {
removeFromInventory(cashShopSurprise);
}
Item itemReward = cashItemReward.toItem();
Item itemReward = cashItemReward.get().toItem();
addToInventory(itemReward);
return Optional.of(new CashShopSurpriseResult(cashShopSurprise, itemReward));

View File

@@ -0,0 +1,19 @@
package constants.id;
import org.junit.jupiter.api.Test;
import static org.junit.jupiter.api.Assertions.assertFalse;
import static org.junit.jupiter.api.Assertions.assertTrue;
class ItemIdTest {
@Test
void isCashPackage() {
assertTrue(ItemId.isCashPackage(9102237));
}
@Test
void isNotCashPackage() {
assertFalse(ItemId.isCashPackage(4000000));
}
}