mirror of
https://github.com/Grasscutters/Grasscutter.git
synced 2025-12-15 08:25:21 +01:00
Fix statue unlocks, and probably other quests involving talks
This commit is contained in:
@@ -1,15 +1,13 @@
|
||||
package emu.grasscutter.game.talk;
|
||||
|
||||
import static emu.grasscutter.game.quest.enums.QuestCond.QUEST_COND_COMPLETE_TALK;
|
||||
import static emu.grasscutter.game.quest.enums.QuestContent.QUEST_CONTENT_COMPLETE_ANY_TALK;
|
||||
import static emu.grasscutter.game.quest.enums.QuestContent.QUEST_CONTENT_COMPLETE_TALK;
|
||||
|
||||
import emu.grasscutter.data.GameData;
|
||||
import emu.grasscutter.data.binout.MainQuestData.TalkData;
|
||||
import emu.grasscutter.game.player.BasePlayerManager;
|
||||
import emu.grasscutter.game.player.Player;
|
||||
import emu.grasscutter.game.player.*;
|
||||
import lombok.NonNull;
|
||||
|
||||
import static emu.grasscutter.game.quest.enums.QuestCond.QUEST_COND_COMPLETE_TALK;
|
||||
import static emu.grasscutter.game.quest.enums.QuestContent.*;
|
||||
|
||||
public final class TalkManager extends BasePlayerManager {
|
||||
public TalkManager(@NonNull Player player) {
|
||||
super(player);
|
||||
@@ -22,30 +20,31 @@ public final class TalkManager extends BasePlayerManager {
|
||||
* @param npcEntityId The entity ID of the NPC being talked to.
|
||||
*/
|
||||
public void triggerTalkAction(int talkId, int npcEntityId) {
|
||||
var talkData = GameData.getTalkConfigDataMap().get(talkId);
|
||||
if (talkData == null) return;
|
||||
|
||||
var player = this.getPlayer();
|
||||
// Check if the NPC id is valid.
|
||||
var entity = player.getScene().getEntityById(npcEntityId);
|
||||
if (entity != null) {
|
||||
// The config ID of the entity is the NPC's ID.
|
||||
if (!talkData.getNpcId().contains(entity.getConfigId())) return;
|
||||
}
|
||||
|
||||
// Execute the talk action on associated handlers.
|
||||
talkData
|
||||
var talkData = GameData.getTalkConfigDataMap().get(talkId);
|
||||
if (talkData != null) {
|
||||
// Check if the NPC id is valid.
|
||||
var entity = player.getScene().getEntityById(npcEntityId);
|
||||
if (entity != null) {
|
||||
// The config ID of the entity is the NPC's ID.
|
||||
if (!talkData.getNpcId().contains(entity.getConfigId())) return;
|
||||
}
|
||||
|
||||
// Execute the talk action on associated handlers.
|
||||
talkData
|
||||
.getFinishExec()
|
||||
.forEach(e -> player.getServer().getTalkSystem().triggerExec(player, talkData, e));
|
||||
|
||||
// Save the talk value to the quest's data.
|
||||
this.saveTalkToQuest(talkId, talkData.getQuestId());
|
||||
}
|
||||
|
||||
// Invoke the talking events for quests.
|
||||
var questManager = player.getQuestManager();
|
||||
questManager.queueEvent(QUEST_CONTENT_COMPLETE_ANY_TALK, talkId);
|
||||
questManager.queueEvent(QUEST_CONTENT_COMPLETE_TALK, talkId);
|
||||
questManager.queueEvent(QUEST_COND_COMPLETE_TALK, talkId);
|
||||
|
||||
// Save the talk value to the quest's data.
|
||||
this.saveTalkToQuest(talkId, talkData.getQuestId());
|
||||
}
|
||||
|
||||
public void saveTalkToQuest(int talkId, int mainQuestId) {
|
||||
|
||||
Reference in New Issue
Block a user