mirror of
https://github.com/Grasscutters/Grasscutter.git
synced 2025-12-13 23:44:55 +01:00
Merge remote-tracking branch 'origin/development' into development
This commit is contained in:
@@ -112,7 +112,7 @@ public final class QuestCommand implements CommandHandler {
|
||||
var shouldAdd = !loggedQuests.contains(questId);
|
||||
|
||||
if (shouldAdd) loggedQuests.add(questId);
|
||||
else loggedQuests.remove(questId);
|
||||
else loggedQuests.remove(loggedQuests.indexOf(questId));
|
||||
|
||||
CommandHandler.sendMessage(
|
||||
sender,
|
||||
|
||||
@@ -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;
|
||||
|
||||
@@ -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];
|
||||
}
|
||||
}
|
||||
|
||||
@@ -629,7 +629,7 @@ public class SceneScriptManager {
|
||||
getScene().getEntities().values().stream()
|
||||
.filter(
|
||||
e ->
|
||||
e.getEntityType() == EntityType.Avatar.getValue()
|
||||
e.getEntityType() == EntityType.Avatar
|
||||
&& region.getMetaRegion().contains(e.getPosition()))
|
||||
.toList();
|
||||
entities.forEach(region::addEntity);
|
||||
@@ -644,6 +644,7 @@ public class SceneScriptManager {
|
||||
.trace("Call EVENT_ENTER_REGION_{}", region.getMetaRegion().config_id);
|
||||
this.callEvent(
|
||||
new ScriptArgs(region.getGroupId(), EventType.EVENT_ENTER_REGION, region.getConfigId())
|
||||
.setEventSource(EntityType.Avatar.getValue())
|
||||
.setSourceEntityId(region.getId())
|
||||
.setTargetEntityId(targetId));
|
||||
|
||||
@@ -660,6 +661,7 @@ public class SceneScriptManager {
|
||||
if (region.entityHasLeft()) {
|
||||
this.callEvent(
|
||||
new ScriptArgs(region.getGroupId(), EventType.EVENT_LEAVE_REGION, region.getConfigId())
|
||||
.setEventSource(EntityType.Avatar.getValue())
|
||||
.setSourceEntityId(region.getId())
|
||||
.setTargetEntityId(region.getFirstEntityId()));
|
||||
|
||||
@@ -810,8 +812,7 @@ public class SceneScriptManager {
|
||||
.stream()
|
||||
.filter(
|
||||
t ->
|
||||
!t.getCondition().isEmpty()
|
||||
&& t.getCondition().substring(29).equals(String.valueOf(params.param1))
|
||||
t.getName().substring(13).equals(String.valueOf(params.param1))
|
||||
&& (t.getSource().isEmpty()
|
||||
|| t.getSource().equals(params.getEventSource())))
|
||||
.collect(Collectors.toSet());
|
||||
|
||||
@@ -18,6 +18,7 @@ import emu.grasscutter.game.quest.enums.QuestContent;
|
||||
import emu.grasscutter.game.quest.enums.QuestState;
|
||||
import emu.grasscutter.game.world.SceneGroupInstance;
|
||||
import emu.grasscutter.net.proto.EnterTypeOuterClass;
|
||||
import emu.grasscutter.net.proto.VisionTypeOuterClass.VisionType;
|
||||
import emu.grasscutter.scripts.constants.EventType;
|
||||
import emu.grasscutter.scripts.constants.GroupKillPolicy;
|
||||
import emu.grasscutter.scripts.data.SceneGroup;
|
||||
@@ -152,18 +153,17 @@ public class ScriptLib {
|
||||
logger.debug("[LUA] Call SetWorktopOptions with {}", printTable(table));
|
||||
var callParams = this.callParams.getIfExists();
|
||||
var group = this.currentGroup.getIfExists();
|
||||
if(callParams == null || group == null){
|
||||
if (callParams == null || group == null) {
|
||||
return 1;
|
||||
}
|
||||
var configId = callParams.param1;
|
||||
var entity = getSceneScriptManager().getScene().getEntityByConfigId(configId);
|
||||
|
||||
|
||||
int[] worktopOptions = new int[table.length()];
|
||||
for(int i = 1 ;i<=table.length() ;i++){
|
||||
var worktopOptions = new int[table.length()];
|
||||
for (int i = 1; i<=table.length(); i++) {
|
||||
worktopOptions[i-1] = table.get(i).optint(-1);
|
||||
}
|
||||
if(!(entity instanceof EntityGadget gadget)|| worktopOptions.length == 0){
|
||||
if (!(entity instanceof EntityGadget gadget) || worktopOptions.length == 0) {
|
||||
return 2;
|
||||
}
|
||||
|
||||
@@ -172,9 +172,11 @@ public class ScriptLib {
|
||||
}
|
||||
|
||||
worktop.addWorktopOptions(worktopOptions);
|
||||
|
||||
var scene = getSceneScriptManager().getScene();
|
||||
scene.broadcastPacket(new PacketWorktopOptionNotify(gadget));
|
||||
var scene = this.getSceneScriptManager().getScene();
|
||||
// Done in order to synchronize with addEntities in Scene.class.
|
||||
synchronized (this.getSceneScriptManager().getScene()) {
|
||||
scene.broadcastPacket(new PacketWorktopOptionNotify(gadget));
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
@@ -401,7 +403,7 @@ public class ScriptLib {
|
||||
|
||||
val old = variables.getOrDefault(var, value);
|
||||
variables.put(var, value);
|
||||
getSceneScriptManager().callEvent(new ScriptArgs(groupId, EventType.EVENT_VARIABLE_CHANGE, value, old));
|
||||
getSceneScriptManager().callEvent(new ScriptArgs(groupId, EventType.EVENT_VARIABLE_CHANGE, value, old).setEventSource(var));
|
||||
return 0;
|
||||
}
|
||||
|
||||
@@ -416,7 +418,7 @@ public class ScriptLib {
|
||||
variables.put(var, old + value);
|
||||
logger.debug("[LUA] Call ChangeGroupVariableValue with {},{}",
|
||||
old, old+value);
|
||||
getSceneScriptManager().callEvent(new ScriptArgs(groupId, EventType.EVENT_VARIABLE_CHANGE, old+value, old));
|
||||
getSceneScriptManager().callEvent(new ScriptArgs(groupId, EventType.EVENT_VARIABLE_CHANGE, old+value, old).setEventSource(var));
|
||||
return LuaValue.ZERO;
|
||||
}
|
||||
|
||||
@@ -609,6 +611,11 @@ public class ScriptLib {
|
||||
logger.debug("[LUA] Call CreateGadget with {}",
|
||||
printTable(table));
|
||||
var configId = table.get("config_id").toint();
|
||||
//TODO: figure out what creating gadget configId 0 does
|
||||
if (configId == 0){
|
||||
Grasscutter.getLogger().warn("Tried to CreateGadget with config_id 0: {}", printTable(table));
|
||||
return 0;
|
||||
}
|
||||
|
||||
var group = getCurrentGroup();
|
||||
|
||||
@@ -703,7 +710,7 @@ public class ScriptLib {
|
||||
return EntityType.None.getValue();
|
||||
}
|
||||
|
||||
return entity.getEntityType();
|
||||
return entity.getEntityType().getValue();
|
||||
}
|
||||
|
||||
public int GetQuestState(int entityId, int questId){
|
||||
@@ -738,11 +745,11 @@ public class ScriptLib {
|
||||
|
||||
val entity = getSceneScriptManager().getScene().getEntityByConfigId(configId, groupId);
|
||||
|
||||
if(entity == null || entity.getEntityType() != entityType){
|
||||
if(entity == null || entity.getEntityType().getValue() != entityType){
|
||||
return 1;
|
||||
}
|
||||
|
||||
getSceneScriptManager().getScene().removeEntity(entity);
|
||||
getSceneScriptManager().getScene().removeEntity(entity, VisionType.VISION_TYPE_REMOVE);
|
||||
|
||||
return 0;
|
||||
}
|
||||
@@ -816,17 +823,17 @@ public class ScriptLib {
|
||||
//TODO implement
|
||||
return 0;
|
||||
}
|
||||
public int IsPlayerAllAvatarDie(int sceneUid){
|
||||
public boolean IsPlayerAllAvatarDie(int sceneUid){
|
||||
logger.warn("[LUA] Call unimplemented IsPlayerAllAvatarDie {}", sceneUid);
|
||||
var playerEntities = getSceneScriptManager().getScene().getEntities().values().stream().filter(e -> e.getEntityType() == EntityIdType.AVATAR.getId()).toList();
|
||||
var playerEntities = getSceneScriptManager().getScene().getEntities().values().stream().filter(e -> e.getEntityType() == EntityType.Avatar).toList();
|
||||
for (GameEntity p : playerEntities){
|
||||
var player = (EntityAvatar)p;
|
||||
if(player.isAlive()){
|
||||
return 0;
|
||||
return false;
|
||||
}
|
||||
}
|
||||
//TODO check
|
||||
return 1;
|
||||
return true;
|
||||
}
|
||||
|
||||
public int sendShowCommonTipsToClient(String title, String content, int closeTime) {
|
||||
@@ -862,6 +869,11 @@ public class ScriptLib {
|
||||
//TODO implement var6 object has int success, int fail, bool fail_on_wipe
|
||||
return 0;
|
||||
}
|
||||
public int StopChallenge(int var1, int var2){
|
||||
logger.warn("[LUA] Call unimplemented StopChallenge with {} {}", var1, var2);
|
||||
//TODO implement
|
||||
return 0;
|
||||
}
|
||||
public int CreateEffigyChallengeMonster(int var1, int[] var2){
|
||||
logger.warn("[LUA] Call unimplemented CreateEffigyChallengeMonster with {} {}", var1, var2);
|
||||
//TODO implement
|
||||
|
||||
Reference in New Issue
Block a user