mirror of
https://github.com/Grasscutters/Grasscutter.git
synced 2025-01-24 17:53:52 +08:00
Fix talking not progressing quests & Add talk execution handlers
This commit is contained in:
parent
3ffa0a7478
commit
1c2bdff9dc
@ -23,7 +23,7 @@ public final class TalkManager extends BasePlayerManager {
|
||||
*/
|
||||
public void triggerTalkAction(int talkId) {
|
||||
var talkData = GameData.getTalkConfigDataMap().get(talkId);
|
||||
if (talkData == null || talkData.getFinishExec().isEmpty()) return;
|
||||
if (talkData == null) return;
|
||||
|
||||
var player = this.getPlayer();
|
||||
// Execute the talk action on associated handlers.
|
||||
|
@ -0,0 +1,21 @@
|
||||
package emu.grasscutter.game.talk.exec;
|
||||
|
||||
import emu.grasscutter.data.excels.TalkConfigData;
|
||||
import emu.grasscutter.data.excels.TalkConfigData.TalkExecParam;
|
||||
import emu.grasscutter.game.player.Player;
|
||||
import emu.grasscutter.game.talk.TalkExec;
|
||||
import emu.grasscutter.game.talk.TalkExecHandler;
|
||||
import emu.grasscutter.game.talk.TalkValueExec;
|
||||
|
||||
@TalkValueExec(TalkExec.TALK_EXEC_DEC_QUEST_GLOBAL_VAR)
|
||||
public final class ExecDecQuestGlobalVar extends TalkExecHandler {
|
||||
@Override
|
||||
public void execute(Player player, TalkConfigData talkData, TalkExecParam execParam) {
|
||||
if (execParam.getParam().length < 2) return;
|
||||
|
||||
player.getQuestManager().decQuestGlobalVarValue(
|
||||
Integer.parseInt(execParam.getParam()[0]),
|
||||
Integer.parseInt(execParam.getParam()[1])
|
||||
);
|
||||
}
|
||||
}
|
@ -0,0 +1,27 @@
|
||||
package emu.grasscutter.game.talk.exec;
|
||||
|
||||
import emu.grasscutter.data.excels.TalkConfigData;
|
||||
import emu.grasscutter.data.excels.TalkConfigData.TalkExecParam;
|
||||
import emu.grasscutter.game.player.Player;
|
||||
import emu.grasscutter.game.quest.GameMainQuest;
|
||||
import emu.grasscutter.game.talk.TalkExec;
|
||||
import emu.grasscutter.game.talk.TalkExecHandler;
|
||||
import emu.grasscutter.game.talk.TalkValueExec;
|
||||
|
||||
@TalkValueExec(TalkExec.TALK_EXEC_DEC_QUEST_VAR)
|
||||
public final class ExecDecQuestVar extends TalkExecHandler {
|
||||
@Override
|
||||
public void execute(Player player, TalkConfigData talkData, TalkExecParam execParam) {
|
||||
if (execParam.getParam().length < 3) return;
|
||||
|
||||
GameMainQuest mainQuest = player.getQuestManager().getMainQuestById(
|
||||
Integer.parseInt(execParam.getParam()[2])
|
||||
);
|
||||
if (mainQuest == null) return;
|
||||
|
||||
mainQuest.decQuestVar(
|
||||
Integer.parseInt(execParam.getParam()[0]),
|
||||
Integer.parseInt(execParam.getParam()[1])
|
||||
);
|
||||
}
|
||||
}
|
@ -0,0 +1,21 @@
|
||||
package emu.grasscutter.game.talk.exec;
|
||||
|
||||
import emu.grasscutter.data.excels.TalkConfigData;
|
||||
import emu.grasscutter.data.excels.TalkConfigData.TalkExecParam;
|
||||
import emu.grasscutter.game.player.Player;
|
||||
import emu.grasscutter.game.talk.TalkExec;
|
||||
import emu.grasscutter.game.talk.TalkExecHandler;
|
||||
import emu.grasscutter.game.talk.TalkValueExec;
|
||||
|
||||
@TalkValueExec(TalkExec.TALK_EXEC_INC_QUEST_GLOBAL_VAR)
|
||||
public final class ExecIncQuestGlobalVar extends TalkExecHandler {
|
||||
@Override
|
||||
public void execute(Player player, TalkConfigData talkData, TalkExecParam execParam) {
|
||||
if (execParam.getParam().length < 2) return;
|
||||
|
||||
player.getQuestManager().incQuestGlobalVarValue(
|
||||
Integer.parseInt(execParam.getParam()[0]),
|
||||
Integer.parseInt(execParam.getParam()[1])
|
||||
);
|
||||
}
|
||||
}
|
@ -0,0 +1,27 @@
|
||||
package emu.grasscutter.game.talk.exec;
|
||||
|
||||
import emu.grasscutter.data.excels.TalkConfigData;
|
||||
import emu.grasscutter.data.excels.TalkConfigData.TalkExecParam;
|
||||
import emu.grasscutter.game.player.Player;
|
||||
import emu.grasscutter.game.quest.GameMainQuest;
|
||||
import emu.grasscutter.game.talk.TalkExec;
|
||||
import emu.grasscutter.game.talk.TalkExecHandler;
|
||||
import emu.grasscutter.game.talk.TalkValueExec;
|
||||
|
||||
@TalkValueExec(TalkExec.TALK_EXEC_INC_QUEST_VAR)
|
||||
public final class ExecIncQuestVar extends TalkExecHandler {
|
||||
@Override
|
||||
public void execute(Player player, TalkConfigData talkData, TalkExecParam execParam) {
|
||||
if (execParam.getParam().length < 3) return;
|
||||
|
||||
GameMainQuest mainQuest = player.getQuestManager().getMainQuestById(
|
||||
Integer.parseInt(execParam.getParam()[2])
|
||||
);
|
||||
if (mainQuest == null) return;
|
||||
|
||||
mainQuest.incQuestVar(
|
||||
Integer.parseInt(execParam.getParam()[0]),
|
||||
Integer.parseInt(execParam.getParam()[1])
|
||||
);
|
||||
}
|
||||
}
|
@ -0,0 +1,18 @@
|
||||
package emu.grasscutter.game.talk.exec;
|
||||
|
||||
import emu.grasscutter.data.excels.TalkConfigData;
|
||||
import emu.grasscutter.data.excels.TalkConfigData.TalkExecParam;
|
||||
import emu.grasscutter.game.player.Player;
|
||||
import emu.grasscutter.game.talk.TalkExec;
|
||||
import emu.grasscutter.game.talk.TalkExecHandler;
|
||||
import emu.grasscutter.game.talk.TalkValueExec;
|
||||
|
||||
@TalkValueExec(TalkExec.TALK_EXEC_SET_GAME_TIME)
|
||||
public final class ExecSetGameTime extends TalkExecHandler {
|
||||
@Override
|
||||
public void execute(Player player, TalkConfigData talkData, TalkExecParam execParam) {
|
||||
if (execParam.getParam().length < 1) return;
|
||||
|
||||
player.getWorld().changeTime(Integer.parseInt(execParam.getParam()[0]), 0);
|
||||
}
|
||||
}
|
@ -0,0 +1,21 @@
|
||||
package emu.grasscutter.game.talk.exec;
|
||||
|
||||
import emu.grasscutter.data.excels.TalkConfigData;
|
||||
import emu.grasscutter.data.excels.TalkConfigData.TalkExecParam;
|
||||
import emu.grasscutter.game.player.Player;
|
||||
import emu.grasscutter.game.talk.TalkExec;
|
||||
import emu.grasscutter.game.talk.TalkExecHandler;
|
||||
import emu.grasscutter.game.talk.TalkValueExec;
|
||||
|
||||
@TalkValueExec(TalkExec.TALK_EXEC_SET_QUEST_GLOBAL_VAR)
|
||||
public final class ExecSetQuestGlobalVar extends TalkExecHandler {
|
||||
@Override
|
||||
public void execute(Player player, TalkConfigData talkData, TalkExecParam execParam) {
|
||||
if (execParam.getParam().length < 2) return;
|
||||
|
||||
player.getQuestManager().setQuestGlobalVarValue(
|
||||
Integer.parseInt(execParam.getParam()[0]),
|
||||
Integer.parseInt(execParam.getParam()[1])
|
||||
);
|
||||
}
|
||||
}
|
@ -0,0 +1,27 @@
|
||||
package emu.grasscutter.game.talk.exec;
|
||||
|
||||
import emu.grasscutter.data.excels.TalkConfigData;
|
||||
import emu.grasscutter.data.excels.TalkConfigData.TalkExecParam;
|
||||
import emu.grasscutter.game.player.Player;
|
||||
import emu.grasscutter.game.quest.GameMainQuest;
|
||||
import emu.grasscutter.game.talk.TalkExec;
|
||||
import emu.grasscutter.game.talk.TalkExecHandler;
|
||||
import emu.grasscutter.game.talk.TalkValueExec;
|
||||
|
||||
@TalkValueExec(TalkExec.TALK_EXEC_SET_QUEST_VAR)
|
||||
public final class ExecSetQuestVar extends TalkExecHandler {
|
||||
@Override
|
||||
public void execute(Player player, TalkConfigData talkData, TalkExecParam execParam) {
|
||||
if (execParam.getParam().length < 3) return;
|
||||
|
||||
var mainQuest = player.getQuestManager().getMainQuestById(
|
||||
Integer.parseInt(execParam.getParam()[2])
|
||||
);
|
||||
if (mainQuest == null) return;
|
||||
|
||||
mainQuest.setQuestVar(
|
||||
Integer.parseInt(execParam.getParam()[0]),
|
||||
Integer.parseInt(execParam.getParam()[1])
|
||||
);
|
||||
}
|
||||
}
|
@ -0,0 +1,39 @@
|
||||
package emu.grasscutter.game.talk.exec;
|
||||
|
||||
import emu.grasscutter.data.GameData;
|
||||
import emu.grasscutter.data.binout.ScriptSceneData;
|
||||
import emu.grasscutter.data.excels.TalkConfigData;
|
||||
import emu.grasscutter.data.excels.TalkConfigData.TalkExecParam;
|
||||
import emu.grasscutter.game.player.Player;
|
||||
import emu.grasscutter.game.talk.TalkExec;
|
||||
import emu.grasscutter.game.talk.TalkExecHandler;
|
||||
import emu.grasscutter.game.talk.TalkValueExec;
|
||||
import emu.grasscutter.utils.Position;
|
||||
|
||||
@TalkValueExec(TalkExec.TALK_EXEC_TRANS_SCENE_DUMMY_POINT)
|
||||
public final class ExecTransSceneDummyPoint extends TalkExecHandler {
|
||||
@Override
|
||||
public void execute(Player player, TalkConfigData talkData, TalkExecParam execParam) {
|
||||
// param[0] == sceneid, param[1] == position
|
||||
if (execParam.getParam().length < 2) return;
|
||||
|
||||
var fullGlobals = GameData.getScriptSceneDataMap().get("flat.luas.scenes.full_globals.lua.json");
|
||||
if (fullGlobals == null) return;
|
||||
|
||||
var dummyPointScript = fullGlobals.getScriptObjectList()
|
||||
.get(execParam.getParam()[0] + "/scene" + execParam.getParam()[0] + "_dummy_points.lua");
|
||||
if (dummyPointScript == null) return;
|
||||
|
||||
var dummyPointMap = dummyPointScript.getDummyPoints();
|
||||
if (dummyPointMap == null) return;
|
||||
|
||||
var transmitPosPos = dummyPointMap.get(execParam.getParam()[1] + ".pos");
|
||||
// List<Float> transmitPosRot = dummyPointMap.get(e.getParam()[1] + ".rot"); would be useful when transportation consider rotation
|
||||
if (transmitPosPos == null || transmitPosPos.isEmpty()) return;
|
||||
|
||||
player.getWorld().transferPlayerToScene(
|
||||
player,
|
||||
Integer.parseInt(execParam.getParam()[0]),
|
||||
new Position(transmitPosPos.get(0), transmitPosPos.get(1), transmitPosPos.get(2)));
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue
Block a user