mirror of
https://github.com/Grasscutters/Grasscutter.git
synced 2025-12-15 08:25:21 +01:00
Merge remote-tracking branch 'origin/development' into development
This commit is contained in:
@@ -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();
|
||||
|
||||
@@ -134,7 +134,16 @@ 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 +196,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;
|
||||
}
|
||||
|
||||
@@ -52,8 +52,8 @@ public abstract class GameEntity {
|
||||
|
||||
public abstract void initAbilities();
|
||||
|
||||
public int getEntityType() {
|
||||
return this.getId() >> 24;
|
||||
public EntityType getEntityType() {
|
||||
return EntityIdType.toEntityType(this.getId() >> 24);
|
||||
}
|
||||
|
||||
public abstract int getEntityTypeId();
|
||||
|
||||
@@ -14,6 +14,8 @@ import emu.grasscutter.net.proto.GadgetInteractReqOuterClass.GadgetInteractReq;
|
||||
import emu.grasscutter.net.proto.GatherGadgetInfoOuterClass.GatherGadgetInfo;
|
||||
import emu.grasscutter.net.proto.InteractTypeOuterClass.InteractType;
|
||||
import emu.grasscutter.net.proto.SceneGadgetInfoOuterClass.SceneGadgetInfo;
|
||||
import emu.grasscutter.scripts.constants.EventType;
|
||||
import emu.grasscutter.scripts.data.ScriptArgs;
|
||||
import emu.grasscutter.server.packet.send.PacketGadgetInteractRsp;
|
||||
import emu.grasscutter.utils.Utils;
|
||||
|
||||
@@ -57,6 +59,13 @@ public final class GadgetGatherObject extends GadgetContent {
|
||||
GameItem item = new GameItem(itemData, 1);
|
||||
player.getInventory().addItem(item, ActionReason.Gather);
|
||||
|
||||
getGadget()
|
||||
.getScene()
|
||||
.getScriptManager()
|
||||
.callEvent(
|
||||
new ScriptArgs(
|
||||
getGadget().getGroupId(), EventType.EVENT_GATHER, getGadget().getConfigId()));
|
||||
|
||||
getGadget()
|
||||
.getScene()
|
||||
.broadcastPacket(
|
||||
|
||||
@@ -1,5 +1,8 @@
|
||||
package emu.grasscutter.game.props;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
public enum EntityIdType {
|
||||
AVATAR(0x01),
|
||||
MONSTER(0x02),
|
||||
@@ -12,10 +15,27 @@ public enum EntityIdType {
|
||||
|
||||
private final int id;
|
||||
|
||||
private static final Map<Integer, EntityType> map = new HashMap<>();
|
||||
|
||||
static {
|
||||
map.put(EntityIdType.AVATAR.getId(), EntityType.Avatar);
|
||||
map.put(EntityIdType.MONSTER.getId(), EntityType.Monster);
|
||||
map.put(EntityIdType.NPC.getId(), EntityType.NPC);
|
||||
map.put(EntityIdType.GADGET.getId(), EntityType.Gadget);
|
||||
map.put(EntityIdType.REGION.getId(), EntityType.Region);
|
||||
map.put(EntityIdType.WEAPON.getId(), EntityType.Equip);
|
||||
map.put(EntityIdType.TEAM.getId(), EntityType.Team);
|
||||
map.put(EntityIdType.MPLEVEL.getId(), EntityType.MPLevel);
|
||||
}
|
||||
|
||||
EntityIdType(int id) {
|
||||
this.id = id;
|
||||
}
|
||||
|
||||
public static EntityType toEntityType(int entityId) {
|
||||
return map.getOrDefault(entityId, EntityType.None);
|
||||
}
|
||||
|
||||
public int getId() {
|
||||
return id;
|
||||
}
|
||||
|
||||
@@ -75,6 +75,7 @@ public enum EntityType implements IntValueEnum {
|
||||
Screen(64),
|
||||
EchoShell(65),
|
||||
UIInteractGadget(66),
|
||||
Region(98),
|
||||
PlaceHolder(99);
|
||||
|
||||
private static final Int2ObjectMap<EntityType> map = new Int2ObjectOpenHashMap<>();
|
||||
|
||||
@@ -1,10 +1,10 @@
|
||||
package emu.grasscutter.game.quest.content;
|
||||
|
||||
import static emu.grasscutter.game.quest.enums.QuestContent.QUEST_CONTENT_FINISH_PLOT;
|
||||
|
||||
import emu.grasscutter.data.excels.quest.QuestData;
|
||||
import emu.grasscutter.game.quest.*;
|
||||
|
||||
import static emu.grasscutter.game.quest.enums.QuestContent.QUEST_CONTENT_FINISH_PLOT;
|
||||
|
||||
@QuestValueContent(QUEST_CONTENT_FINISH_PLOT)
|
||||
public class ContentFinishPlot extends BaseContent {
|
||||
@Override
|
||||
|
||||
@@ -1,10 +1,10 @@
|
||||
package emu.grasscutter.game.quest.content;
|
||||
|
||||
import static emu.grasscutter.game.quest.enums.QuestContent.QUEST_CONTENT_NOT_FINISH_PLOT;
|
||||
|
||||
import emu.grasscutter.data.excels.quest.QuestData;
|
||||
import emu.grasscutter.game.quest.*;
|
||||
|
||||
import static emu.grasscutter.game.quest.enums.QuestContent.QUEST_CONTENT_NOT_FINISH_PLOT;
|
||||
|
||||
@QuestValueContent(QUEST_CONTENT_NOT_FINISH_PLOT)
|
||||
public class ContentNotFinishPlot extends BaseContent {
|
||||
@Override
|
||||
@@ -13,6 +13,6 @@ public class ContentNotFinishPlot extends BaseContent {
|
||||
var talkData = quest.getMainQuest().getTalks().get(params[0]);
|
||||
var subQuest = quest.getMainQuest().getChildQuestById(params[0]);
|
||||
return (talkData == null && subQuest != null || condition.getParamStr().equals(paramStr))
|
||||
&& condition.getParam()[0] == params[0];
|
||||
&& condition.getParam()[0] == params[0];
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user