Invoke the 'not equal' events

This commit is contained in:
KingRainbow44 2023-05-01 21:45:56 -04:00
parent b0605f6ac2
commit 8b84360724
No known key found for this signature in database
GPG Key ID: FC2CB64B00D257BE
4 changed files with 31 additions and 60 deletions

View File

@ -104,19 +104,7 @@ public class GameQuest {
// Some subQuests and talks become active when some other subQuests are unfinished (even from
// different MainQuests)
getOwner()
.getQuestManager()
.queueEvent(
QuestContent.QUEST_CONTENT_QUEST_STATE_EQUAL,
getSubQuestId(),
getState().getValue(),
0,
0,
0);
getOwner()
.getQuestManager()
.queueEvent(
QuestCond.QUEST_COND_STATE_EQUAL, getSubQuestId(), getState().getValue(), 0, 0, 0);
this.triggerStateEvents();
getQuestData()
.getBeginExec()
@ -127,6 +115,24 @@ public class GameQuest {
this.save();
}
/**
* Triggers events:
* 'QUEST_COND_STATE_EQUAL',
* 'QUEST_COND_STATE_NOT_EQUAL',
* 'QUEST_CONTENT_QUEST_STATE_EQUAL',
* 'QUEST_CONTENT_QUEST_STATE_NOT_EQUAL'
*/
public void triggerStateEvents() {
var questManager = this.getOwner().getQuestManager();
var questId = this.getSubQuestId();
var state = this.getState().getValue();
questManager.queueEvent(QuestCond.QUEST_COND_STATE_EQUAL, questId, state, 0, 0, 0);
questManager.queueEvent(QuestCond.QUEST_COND_STATE_NOT_EQUAL, questId, state, 0, 0, 0);
questManager.queueEvent(QuestContent.QUEST_CONTENT_QUEST_STATE_EQUAL, questId, state, 0, 0, 0);
questManager.queueEvent(QuestContent.QUEST_CONTENT_QUEST_STATE_NOT_EQUAL, questId, state, 0, 0, 0);
}
public String getTriggerNameById(int id) {
TriggerExcelConfigData trigger = GameData.getTriggerExcelConfigDataMap().get(id);
if (trigger != null) {
@ -214,10 +220,7 @@ public class GameQuest {
this.getOwner()
.getQuestManager()
.queueEvent(QuestContent.QUEST_CONTENT_FINISH_PLOT, this.subQuestId, 0);
this.getOwner()
.getQuestManager()
.queueEvent(
QuestCond.QUEST_COND_STATE_EQUAL, this.subQuestId, this.state.getValue(), 0, 0, 0);
this.triggerStateEvents();
this.getOwner()
.getScene()
.triggerDungeonEvent(DungeonPassConditionType.DUNGEON_COND_FINISH_QUEST, getSubQuestId());
@ -250,19 +253,7 @@ public class GameQuest {
this.getOwner().sendPacket(new PacketQuestListUpdateNotify(this));
// Some subQuests have conditions that subQuests fail (even from different MainQuests)
this.getOwner()
.getQuestManager()
.queueEvent(
QuestContent.QUEST_CONTENT_QUEST_STATE_EQUAL,
this.subQuestId,
this.state.getValue(),
0,
0,
0);
this.getOwner()
.getQuestManager()
.queueEvent(
QuestCond.QUEST_COND_STATE_EQUAL, this.subQuestId, this.state.getValue(), 0, 0, 0);
this.triggerStateEvents();
this.getQuestData()
.getFailExec()

View File

@ -4,9 +4,7 @@ import static emu.grasscutter.game.quest.enums.QuestCond.QUEST_COND_STATE_EQUAL;
import emu.grasscutter.data.excels.QuestData;
import emu.grasscutter.game.player.Player;
import emu.grasscutter.game.quest.GameQuest;
import emu.grasscutter.game.quest.QuestValueCond;
import lombok.val;
@QuestValueCond(QUEST_COND_STATE_EQUAL)
public class ConditionStateEqual extends BaseCondition {
@ -18,17 +16,10 @@ public class ConditionStateEqual extends BaseCondition {
QuestData.QuestAcceptCondition condition,
String paramStr,
int... params) {
val questId = condition.getParam()[0];
val questStateValue = condition.getParam()[1];
GameQuest checkQuest = owner.getQuestManager().getQuestById(questId);
if (checkQuest == null) {
/*
Will spam the console
*/
// Grasscutter.getLogger().debug("Warning: quest {} hasn't been started yet!",
// condition.getParam()[0]);
return false;
}
return checkQuest.getState().getValue() == questStateValue;
var questId = condition.getParam()[0];
var questStateValue = condition.getParam()[1];
var checkQuest = owner.getQuestManager().getQuestById(questId);
return checkQuest != null && checkQuest.getState().getValue() == questStateValue;
}
}

View File

@ -4,9 +4,7 @@ import static emu.grasscutter.game.quest.enums.QuestCond.QUEST_COND_STATE_NOT_EQ
import emu.grasscutter.data.excels.QuestData;
import emu.grasscutter.game.player.Player;
import emu.grasscutter.game.quest.GameQuest;
import emu.grasscutter.game.quest.QuestValueCond;
import lombok.val;
@QuestValueCond(QUEST_COND_STATE_NOT_EQUAL)
public class ConditionStateNotEqual extends BaseCondition {
@ -18,18 +16,11 @@ public class ConditionStateNotEqual extends BaseCondition {
QuestData.QuestAcceptCondition condition,
String paramStr,
int... params) {
val questId = condition.getParam()[0];
val questStateValue = condition.getParam()[1];
GameQuest checkQuest = owner.getQuestManager().getQuestById(questId);
if (checkQuest == null) {
/*
Will spam the console
*/
// Grasscutter.getLogger().debug("Warning: quest {} hasn't been started yet!",
// condition.getParam()[0]);
var questId = condition.getParam()[0];
var questStateValue = condition.getParam()[1];
var checkQuest = owner.getQuestManager().getQuestById(questId);
return false;
}
return checkQuest.getState().getValue() != questStateValue;
return checkQuest != null &&
checkQuest.getState().getValue() != questStateValue;
}
}

View File

@ -12,8 +12,6 @@ public class ContentEnterMyWorld extends BaseContent {
@Override
public boolean execute(
GameQuest quest, QuestData.QuestContentCondition condition, String paramStr, int... params) {
System.out.printf("ContentEnterMyWorld, QuestData: %s; ExecParams: %s%n",
condition.getParam()[0], params[0]);
return quest.getOwner().getSceneId() == params[0];
}
}