From 0175e207af3d1847680bdefa8b1ed58ff37bb4af Mon Sep 17 00:00:00 2001 From: KingRainbow44 Date: Sun, 13 Aug 2023 18:01:41 -0400 Subject: [PATCH] Fix errors in chasm --- .../emu/grasscutter/game/world/Scene.java | 4 +-- .../scripts/SceneScriptManager.java | 17 +++++++++--- .../emu/grasscutter/scripts/ScriptLib.java | 26 +++++++++++++++++++ 3 files changed, 41 insertions(+), 6 deletions(-) diff --git a/src/main/java/emu/grasscutter/game/world/Scene.java b/src/main/java/emu/grasscutter/game/world/Scene.java index 878dbaea6..2fbde7719 100644 --- a/src/main/java/emu/grasscutter/game/world/Scene.java +++ b/src/main/java/emu/grasscutter/game/world/Scene.java @@ -910,8 +910,8 @@ public final class Scene { public int loadDynamicGroup(int group_id) { SceneGroup group = getScriptManager().getGroupById(group_id); - if (group == null || getScriptManager().getGroupInstanceById(group_id) != null) - return -1; // Group not found or already instanced + if (group == null) + return -1; // Group not found this.onLoadGroup(new ArrayList<>(List.of(group))); diff --git a/src/main/java/emu/grasscutter/scripts/SceneScriptManager.java b/src/main/java/emu/grasscutter/scripts/SceneScriptManager.java index 622355671..c9f470930 100644 --- a/src/main/java/emu/grasscutter/scripts/SceneScriptManager.java +++ b/src/main/java/emu/grasscutter/scripts/SceneScriptManager.java @@ -395,7 +395,11 @@ public class SceneScriptManager { var instance = cachedSceneGroupsInstances.getOrDefault(groupId, null); if (instance == null) { instance = DatabaseHelper.loadGroupInstance(groupId, scene.getWorld().getHost()); - if (instance != null) cachedSceneGroupsInstances.put(groupId, instance); + if (instance != null){ + cachedSceneGroupsInstances.put(groupId, instance); + this.cachedSceneGroupsInstances.get(groupId).setCached(false); + this.cachedSceneGroupsInstances.get(groupId).setLuaGroup(getGroupById(groupId)); + } } return instance; @@ -609,6 +613,8 @@ public class SceneScriptManager { var instance = new SceneGroupInstance(group, getScene().getWorld().getHost()); this.sceneGroupsInstances.put(group.id, instance); this.cachedSceneGroupsInstances.put(group.id, instance); + this.cachedSceneGroupsInstances.get(group.id).setCached(false); + this.cachedSceneGroupsInstances.get(group.id).setLuaGroup(group); instance.save(); // Save the instance } @@ -652,6 +658,7 @@ public class SceneScriptManager { entities.forEach(region::addEntity); for (var targetId : enterEntities) { + if (EntityIdType.toEntityType(targetId >> 24).getValue() == 19) continue; Grasscutter.getLogger() .trace("Call EVENT_ENTER_REGION_{}", region.getMetaRegion().config_id); this.callEvent( @@ -669,6 +676,7 @@ public class SceneScriptManager { } for (var targetId : leaveEntities) { + if (EntityIdType.toEntityType(targetId >> 24).getValue() == 19) continue; this.callEvent( new ScriptArgs(region.getGroupId(), EventType.EVENT_LEAVE_REGION, region.getConfigId()) .setEventSource(EntityIdType.toEntityType(targetId >> 24).getValue()) @@ -820,9 +828,10 @@ public class SceneScriptManager { .stream() .filter( t -> - t.getName().substring(13).equals(String.valueOf(params.param1)) - && (t.getSource().isEmpty() - || t.getSource().equals(params.getEventSource()))) + (t.getName().length() <= 12 + || t.getName().substring(13).equals(String.valueOf(params.param1))) + && (t.getSource().isEmpty() + || t.getSource().equals(params.getEventSource()))) .collect(Collectors.toSet()); default -> this.getTriggersByEvent(eventType).stream() .filter( diff --git a/src/main/java/emu/grasscutter/scripts/ScriptLib.java b/src/main/java/emu/grasscutter/scripts/ScriptLib.java index c881f95dc..d55ebf7a1 100644 --- a/src/main/java/emu/grasscutter/scripts/ScriptLib.java +++ b/src/main/java/emu/grasscutter/scripts/ScriptLib.java @@ -1241,6 +1241,11 @@ public class ScriptLib { return dungeonManager.activateRespawnPoint(var1) ? 0:2; } + public int[] GetOpeningDungeonListByRosterId(int var1){ + logger.warn("[LUA] Call unimplemented GetOpeningDungeonListByRosterId with {}", var1); + return new int[] {0,0}; + } + //TODO check public int SetWeatherAreaState(int var1, int var2){ logger.warn("[LUA] Call unimplemented SetWeatherAreaState with {} {}", var1, var2); @@ -1254,6 +1259,17 @@ public class ScriptLib { return 0; } + public int ModifyClimatePolygonParamTable(int var1, LuaTable var2){ + logger.warn("[LUA] Call unimplemented ModifyClimatePolygonParamTable with {} {}", var1, printTable(var2)); + //TODO implement + return 0; + } + + public int SetEnvironmentEffectState(int var1, String var2, int[] var3, int[] var4){ + logger.warn("[LUA] Call unimplemented SetEnvironmentEffectState with {} {} {} {}", var1, var2, var3, var4); + return 0; + } + //TODO check public boolean CheckIsInMpMode(){ logger.debug("[LUA] Call CheckIsInMpMode"); @@ -1523,6 +1539,16 @@ public class ScriptLib { return result; } + public int GetRegionConfigId(LuaTable var1){ + logger.warn("[LUA] Call untested GetRegionConfigId with {}", printTable(var1)); + var EntityId = var1.get("region_eid").toint(); + var entity = getSceneScriptManager().getScene().getScriptManager().getRegionById(EntityId); + if (entity == null){ + return -1; + } + return entity.getConfigId(); + } + public int GetGameHour(){ return getSceneScriptManager().getScene().getWorld().getGameTimeHours(); }