mirror of
https://github.com/Grasscutters/Grasscutter.git
synced 2024-11-23 12:29:52 +00:00
Fix some more dungeons (#2449)
* Monds weapon mats domain: Fix time between kill not refreshing * Inaz husk domain: Fix broken domain challenge * `EVENT_ANY_MONSTER_LIVE` is likely sent on tick, not on create. See scene40801_group240801001.lua: 1. `condition_EVENT_ANY_MONSTER_LIVE_1023` checks for mob 1008 to spawn AND for variable `challenge` to be 1 2. Mob 1008 spawns during `action_EVENT_SELECT_OPTION_1003`, at `ScriptLib.AddExtraGroupSuite(context, 240801001, 2)` 3. This spawn triggers `EVENT_ANY_MONSTER_LIVE` for mob 1008 but still fails the condition because `challenge` is still 0. 4. `challenge` is set to 1 at the end of `action_EVENT_SELECT_OPTION_1003`. By now, `EVENT_ANY_MONSTER_LIVE` for mob 1008 no longer fires, causing the domain challenge to fail to start.
This commit is contained in:
parent
5ebad71e9d
commit
c4402cc287
@ -29,7 +29,7 @@ public class WorldChallenge {
|
|||||||
private final AtomicInteger score;
|
private final AtomicInteger score;
|
||||||
private boolean progress;
|
private boolean progress;
|
||||||
private boolean success;
|
private boolean success;
|
||||||
private long startedAt;
|
private int startedAt;
|
||||||
private int finishedTime;
|
private int finishedTime;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -36,6 +36,6 @@ public class KillMonsterCountInTimeIncChallengeFactoryHandler implements Challen
|
|||||||
List.of(
|
List.of(
|
||||||
new KillMonsterCountTrigger(),
|
new KillMonsterCountTrigger(),
|
||||||
new InTimeTrigger(),
|
new InTimeTrigger(),
|
||||||
new KillMonsterTimeIncTrigger(timeInc)));
|
new KillMonsterTimeIncTrigger(timeLimit, timeInc)));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,11 +1,12 @@
|
|||||||
package emu.grasscutter.game.dungeons.challenge.factory;
|
package emu.grasscutter.game.dungeons.challenge.factory;
|
||||||
|
|
||||||
|
import emu.grasscutter.data.GameData;
|
||||||
import emu.grasscutter.game.dungeons.challenge.WorldChallenge;
|
import emu.grasscutter.game.dungeons.challenge.WorldChallenge;
|
||||||
import emu.grasscutter.game.dungeons.challenge.enums.ChallengeType;
|
import emu.grasscutter.game.dungeons.challenge.enums.ChallengeType;
|
||||||
import emu.grasscutter.game.dungeons.challenge.trigger.*;
|
import emu.grasscutter.game.dungeons.challenge.trigger.*;
|
||||||
import emu.grasscutter.game.world.Scene;
|
import emu.grasscutter.game.world.Scene;
|
||||||
import emu.grasscutter.scripts.data.SceneGroup;
|
import emu.grasscutter.scripts.data.SceneGroup;
|
||||||
import java.util.List;
|
import java.util.*;
|
||||||
import lombok.val;
|
import lombok.val;
|
||||||
|
|
||||||
public class KillMonsterTimeChallengeFactoryHandler implements ChallengeFactoryHandler {
|
public class KillMonsterTimeChallengeFactoryHandler implements ChallengeFactoryHandler {
|
||||||
@ -28,6 +29,15 @@ public class KillMonsterTimeChallengeFactoryHandler implements ChallengeFactoryH
|
|||||||
Scene scene,
|
Scene scene,
|
||||||
SceneGroup group) {
|
SceneGroup group) {
|
||||||
val realGroup = scene.getScriptManager().getGroupById(groupId);
|
val realGroup = scene.getScriptManager().getGroupById(groupId);
|
||||||
|
val challengeTriggers = new ArrayList<ChallengeTrigger>();
|
||||||
|
challengeTriggers.addAll(List.of(new KillMonsterCountTrigger(), new InTimeTrigger()));
|
||||||
|
|
||||||
|
val challengeData = GameData.getDungeonChallengeConfigDataMap().get(challengeId);
|
||||||
|
val challengeType = challengeData.getChallengeType();
|
||||||
|
if (challengeType == ChallengeType.CHALLENGE_KILL_COUNT_FAST) {
|
||||||
|
challengeTriggers.add(new KillMonsterTimeIncTrigger(timeLimit, 0 /* refresh to original limit on kill */));
|
||||||
|
}
|
||||||
|
|
||||||
return new WorldChallenge(
|
return new WorldChallenge(
|
||||||
scene,
|
scene,
|
||||||
realGroup,
|
realGroup,
|
||||||
@ -36,6 +46,6 @@ public class KillMonsterTimeChallengeFactoryHandler implements ChallengeFactoryH
|
|||||||
List.of(targetCount, timeLimit),
|
List.of(targetCount, timeLimit),
|
||||||
timeLimit, // Limit
|
timeLimit, // Limit
|
||||||
targetCount, // Goal
|
targetCount, // Goal
|
||||||
List.of(new KillMonsterCountTrigger(), new InTimeTrigger()));
|
challengeTriggers);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -6,22 +6,31 @@ import emu.grasscutter.server.packet.send.PacketChallengeDataNotify;
|
|||||||
|
|
||||||
public class KillMonsterTimeIncTrigger extends ChallengeTrigger {
|
public class KillMonsterTimeIncTrigger extends ChallengeTrigger {
|
||||||
|
|
||||||
private int increment;
|
private final int maxTime;
|
||||||
|
private final int increment;
|
||||||
|
|
||||||
public KillMonsterTimeIncTrigger(int increment) {
|
public KillMonsterTimeIncTrigger(int maxTime, int increment) {
|
||||||
|
this.maxTime = maxTime;
|
||||||
this.increment = increment;
|
this.increment = increment;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onBegin(WorldChallenge challenge) {
|
public void onBegin(WorldChallenge challenge) { }
|
||||||
// challenge.getScene().broadcastPacket(new PacketChallengeDataNotify(challenge, 0,
|
|
||||||
// challenge.getScore().get()));
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onMonsterDeath(WorldChallenge challenge, EntityMonster monster) {
|
public void onMonsterDeath(WorldChallenge challenge, EntityMonster monster) {
|
||||||
challenge.getScene().broadcastPacket(new PacketChallengeDataNotify(challenge, 0, increment));
|
var scene = challenge.getScene();
|
||||||
|
var elapsed = scene.getSceneTimeSeconds() - challenge.getStartedAt();
|
||||||
|
var timeLeft = challenge.getTimeLimit() - elapsed;
|
||||||
|
var increment = this.increment;
|
||||||
|
if (increment == 0) {
|
||||||
|
// Refresh time limit back to max
|
||||||
|
increment = maxTime - timeLeft;
|
||||||
|
} else if (maxTime < timeLeft + increment) {
|
||||||
|
// Don't add back more time than original limit
|
||||||
|
increment -= timeLeft + increment - maxTime;
|
||||||
|
}
|
||||||
challenge.setTimeLimit(challenge.getTimeLimit() + increment);
|
challenge.setTimeLimit(challenge.getTimeLimit() + increment);
|
||||||
|
scene.broadcastPacket(new PacketChallengeDataNotify(challenge, 2, timeLeft + increment + scene.getSceneTimeSeconds()));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -222,7 +222,9 @@ public class EntityMonster extends GameEntity {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onCreate() {
|
public void onTick(int sceneTime) {
|
||||||
|
super.onTick(sceneTime);
|
||||||
|
|
||||||
// Lua event
|
// Lua event
|
||||||
getScene()
|
getScene()
|
||||||
.getScriptManager()
|
.getScriptManager()
|
||||||
|
Loading…
Reference in New Issue
Block a user