dungeon drop implementation (#2215)

* dungeon drop implementation

* Update src/main/java/emu/grasscutter/game/dungeons/DungeonManager.java

Co-authored-by: Magix <27646710+KingRainbow44@users.noreply.github.com>

---------

Co-authored-by: Magix <27646710+KingRainbow44@users.noreply.github.com>
This commit is contained in:
dragon 2023-06-18 03:56:47 +08:00 committed by GitHub
parent 06d5bf7098
commit 4ebe6fbf63
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 17 additions and 2 deletions

View File

@ -32,6 +32,7 @@ public class DungeonData extends GameResource {
@Getter private int passRewardPreviewID;
@Getter private int statueCostID;
@Getter private int statueCostCount;
@Getter private int statueDrop;
// not part of DungeonExcelConfigData
@Getter private RewardPreviewData rewardPreviewData;

View File

@ -80,6 +80,14 @@ public final class DropSystem extends BaseGameSystem {
return dropData.getDropId();
}
public List<GameItem> handleDungeonRewardDrop(int dropId, boolean doubleReward) {
if (!dropTable.containsKey(dropId)) return List.of();
var dropData = dropTable.get(dropId);
List<GameItem> items = new ArrayList<>();
processDrop(dropData, doubleReward ? 2 : 1, items);
return items;
}
public boolean handleMonsterDrop(EntityMonster monster) {
int dropId;
int level = monster.getLevel();

View File

@ -134,7 +134,12 @@ public final class DungeonManager {
}
// Get and roll rewards.
List<GameItem> rewards = new ArrayList<>(this.rollRewards(useCondensed));
List<GameItem> rewards = player.getServer().getDropSystem().handleDungeonRewardDrop(dungeonData.getStatueDrop(), useCondensed);
if (rewards.isEmpty()) {
//fallback to legacy drop system
Grasscutter.getLogger().debug("dungeon drop failed for {}", dungeonData.getId());
rewards = new ArrayList<>(this.rollRewards(useCondensed));
}
// Add rewards to player and send notification.
player.getInventory().addItems(rewards, ActionReason.DungeonStatueDrop);
player.sendPacket(new PacketGadgetAutoPickDropInfoNotify(rewards));
@ -187,7 +192,7 @@ public final class DungeonManager {
amount += Utils.drawRandomListElement(candidateAmounts, entry.getProbabilities());
}
// Double rewards in multiplay mode, if specified.
// Double rewards in multiply mode, if specified.
if (entry.isMpDouble() && this.getScene().getPlayerCount() > 1) {
amount *= 2;
}

View File

@ -1,5 +1,6 @@
package emu.grasscutter.game.entity.gadget;
import emu.grasscutter.Grasscutter;
import emu.grasscutter.game.dungeons.challenge.DungeonChallenge;
import emu.grasscutter.game.entity.EntityGadget;
import emu.grasscutter.game.player.Player;