mirror of
https://github.com/Melledy/Grasscutter.git
synced 2024-11-29 02:27:37 +00:00
Implement QUEST_EXEC_RANDOM_QUEST_VAR (#2284)
This commit is contained in:
parent
58d2650505
commit
0b0dcf9b8e
@ -16,6 +16,7 @@ import emu.grasscutter.net.proto.ChildQuestOuterClass.ChildQuest;
|
||||
import emu.grasscutter.net.proto.ParentQuestOuterClass.ParentQuest;
|
||||
import emu.grasscutter.server.packet.send.*;
|
||||
import emu.grasscutter.utils.ConversionUtils;
|
||||
import emu.grasscutter.utils.Utils;
|
||||
import java.util.*;
|
||||
import java.util.stream.Collectors;
|
||||
import lombok.*;
|
||||
@ -120,6 +121,16 @@ public class GameMainQuest {
|
||||
this.triggerQuestVarAction(i, this.questVars[i]);
|
||||
}
|
||||
|
||||
public void randomQuestVar(int i, int low, int high) {
|
||||
int previousValue = this.questVars[i];
|
||||
this.questVars[i] = Utils.random.nextInt(low, high);
|
||||
Grasscutter.getLogger()
|
||||
.debug(
|
||||
"questVar {} value randomized from {} to {}", i, previousValue, this.questVars[i]);
|
||||
|
||||
this.triggerQuestVarAction(i, this.questVars[i]);
|
||||
}
|
||||
|
||||
public void triggerQuestVarAction(int index, int value) {
|
||||
var questManager = this.getQuestManager();
|
||||
questManager.queueEvent(QuestCond.QUEST_COND_QUEST_VAR_EQUAL, index, value);
|
||||
|
@ -59,7 +59,7 @@ public enum QuestExec implements QuestTrigger {
|
||||
QUEST_EXEC_SET_QUEST_VAR(48),
|
||||
QUEST_EXEC_INC_QUEST_VAR(49),
|
||||
QUEST_EXEC_DEC_QUEST_VAR(50),
|
||||
QUEST_EXEC_RANDOM_QUEST_VAR(51), // missing
|
||||
QUEST_EXEC_RANDOM_QUEST_VAR(51),
|
||||
QUEST_EXEC_ACTIVATE_SCANNING_PIC(52), // missing, currently unused
|
||||
QUEST_EXEC_RELOAD_SCENE_TAG(53), // missing
|
||||
QUEST_EXEC_REGISTER_DYNAMIC_GROUP_ONLY(54), // missing
|
||||
|
@ -0,0 +1,16 @@
|
||||
package emu.grasscutter.game.quest.exec;
|
||||
|
||||
import emu.grasscutter.data.excels.quest.QuestData;
|
||||
import emu.grasscutter.game.quest.GameQuest;
|
||||
import emu.grasscutter.game.quest.QuestValueExec;
|
||||
import emu.grasscutter.game.quest.enums.QuestExec;
|
||||
import emu.grasscutter.game.quest.handlers.QuestExecHandler;
|
||||
|
||||
@QuestValueExec(QuestExec.QUEST_EXEC_RANDOM_QUEST_VAR)
|
||||
public class ExecRandomQuestVar extends QuestExecHandler {
|
||||
@Override
|
||||
public boolean execute(GameQuest quest, QuestData.QuestExecParam condition, String... paramStr) {
|
||||
quest.getMainQuest().randomQuestVar(Integer.parseInt(paramStr[0]), Integer.parseInt(paramStr[1]), Integer.parseInt(paramStr[2]));
|
||||
return true;
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue
Block a user