Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix triggered Monster Tide spawn; fix Tower dungeon handoff #2397

Merged
merged 3 commits into from
Oct 14, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -131,7 +131,9 @@ public boolean handoffDungeon(
dungeonId);

if (player.getWorld().transferPlayerToScene(player, data.getSceneId(), data)) {
dungeonSettleListeners.forEach(player.getScene()::addDungeonSettleObserver);
var scene = player.getScene();
scene.setDungeonManager(new DungeonManager(scene, data));
dungeonSettleListeners.forEach(scene::addDungeonSettleObserver);
}
return true;
}
Expand Down
4 changes: 2 additions & 2 deletions src/main/java/emu/grasscutter/scripts/SceneScriptManager.java
Original file line number Diff line number Diff line change
Expand Up @@ -774,9 +774,9 @@ public void killGroupSuite(SceneGroup group, SceneSuite suite) {
}

public void startMonsterTideInGroup(
SceneGroup group, Integer[] ordersConfigId, int tideCount, int sceneLimit) {
String source, SceneGroup group, Integer[] ordersConfigId, int tideCount, int sceneLimit) {
this.scriptMonsterTideService =
new ScriptMonsterTideService(this, group, tideCount, sceneLimit, ordersConfigId);
new ScriptMonsterTideService(this, source, group, tideCount, sceneLimit, ordersConfigId);
}

public void unloadCurrentMonsterTide() {
Expand Down
6 changes: 3 additions & 3 deletions src/main/java/emu/grasscutter/scripts/ScriptLib.java
Original file line number Diff line number Diff line change
Expand Up @@ -310,14 +310,14 @@ public int AttachChildChallenge(int var1, int var2, int var3, int[] var4, LuaTab
// TODO: AttachGalleryAbilityGroup
// TODO: AttachGalleryTeamAbilityGroup

public int AutoMonsterTide(int challengeIndex, int groupId, Integer[] ordersConfigId, int tideCount, int sceneLimit, int param6) {
logger.debug("[LUA] Call AutoMonsterTide with {},{},{},{},{},{}", challengeIndex, groupId, ordersConfigId, tideCount, sceneLimit, param6);
public int AutoMonsterTide(int sourceId, int groupId, Integer[] ordersConfigId, int tideCount, int sceneLimit, int param6) {
logger.debug("[LUA] Call AutoMonsterTide with {},{},{},{},{},{}", sourceId, groupId, ordersConfigId, tideCount, sceneLimit, param6);
// Some fields are guessed
SceneGroup group = getSceneScriptManager().getGroupById(groupId);
if (group == null || group.monsters == null) {
return 1;
}
this.getSceneScriptManager().startMonsterTideInGroup(group, ordersConfigId, tideCount, sceneLimit);
this.getSceneScriptManager().startMonsterTideInGroup(Integer.toString(sourceId), group, ordersConfigId, tideCount, sceneLimit);
return 0;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,9 +20,11 @@ public final class ScriptMonsterTideService {
private final List<Integer> monsterConfigIds;
private final OnMonsterCreated onMonsterCreated = new OnMonsterCreated();
private final OnMonsterDead onMonsterDead = new OnMonsterDead();
private final String source;

public ScriptMonsterTideService(
SceneScriptManager sceneScriptManager,
String source,
SceneGroup group,
int tideCount,
int monsterSceneLimit,
Expand All @@ -35,6 +37,7 @@ public ScriptMonsterTideService(
this.monsterAlive = new AtomicInteger(0);
this.monsterConfigOrders = new ConcurrentLinkedQueue<>(List.of(ordersConfigId));
this.monsterConfigIds = List.of(ordersConfigId);
this.source = source;

this.sceneScriptManager
.getScriptMonsterSpawnService()
Expand Down Expand Up @@ -83,11 +86,10 @@ public void onNotify(EntityMonster sceneMonster) {
sceneScriptManager.createMonster(
currentGroup.id, currentGroup.block_id, getNextMonster()));
}
// spawn the last turn of monsters
// fix the 5-2
sceneScriptManager.callEvent(
new ScriptArgs(
currentGroup.id, EventType.EVENT_MONSTER_TIDE_DIE, monsterKillCount.get()));
// call registered events that may spawn in more monsters
var scriptArgs = new ScriptArgs(currentGroup.id, EventType.EVENT_MONSTER_TIDE_DIE, monsterKillCount.get());
scriptArgs.setEventSource(source);
sceneScriptManager.callEvent(scriptArgs);
}
}

Expand Down