Skip to content

Commit

Permalink
dungeon drop implementation (#2215)
Browse files Browse the repository at this point in the history
* 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>
  • Loading branch information
eternalcomet and KingRainbow44 committed Jun 17, 2023
1 parent 06d5bf7 commit 4ebe6fb
Show file tree
Hide file tree
Showing 4 changed files with 17 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
8 changes: 8 additions & 0 deletions src/main/java/emu/grasscutter/game/drop/DropSystem.java
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,14 @@ private int queryDropData(String dropTag, int level, Map<String, List<BaseDropDa
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();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -134,7 +134,12 @@ public boolean getStatueDrops(Player player, boolean useCondensed, int groupId)
}

// 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));
Expand Down Expand Up @@ -187,7 +192,7 @@ private List<GameItem> rollRewards(boolean useCondensed) {
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;
}
Expand Down
Original file line number Diff line number Diff line change
@@ -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;
Expand Down

0 comments on commit 4ebe6fb

Please sign in to comment.