mirror of
https://github.com/Melledy/Grasscutter.git
synced 2024-11-22 20:03:21 +00:00
Fix statue unlocks, and probably other quests involving talks
This commit is contained in:
parent
bb1729c227
commit
1940b22dc5
@ -1,12 +1,11 @@
|
||||
package emu.grasscutter.data.excels;
|
||||
|
||||
import com.google.gson.annotations.SerializedName;
|
||||
import emu.grasscutter.data.GameResource;
|
||||
import emu.grasscutter.data.ResourceType;
|
||||
import emu.grasscutter.data.*;
|
||||
import emu.grasscutter.game.talk.TalkExec;
|
||||
import lombok.*;
|
||||
|
||||
import java.util.List;
|
||||
import lombok.Data;
|
||||
import lombok.EqualsAndHashCode;
|
||||
|
||||
@ResourceType(name = "TalkExcelConfigData.json")
|
||||
@EqualsAndHashCode(callSuper = false)
|
||||
@ -38,6 +37,14 @@ public final class TalkConfigData extends GameResource {
|
||||
this.finishExec == null
|
||||
? List.of()
|
||||
: this.finishExec.stream().filter(x -> x.getType() != null).toList();
|
||||
|
||||
if (this.questId <= 0) {
|
||||
var id = String.valueOf(this.getId());
|
||||
this.questId = Integer.parseInt(
|
||||
id.length() < 5 ? "0" :
|
||||
id.substring(0, 3)
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
@Data
|
||||
|
@ -15,10 +15,11 @@ import emu.grasscutter.scripts.data.SceneGroup;
|
||||
import emu.grasscutter.server.packet.send.*;
|
||||
import emu.grasscutter.utils.Utils;
|
||||
import it.unimi.dsi.fastutil.ints.IntIntImmutablePair;
|
||||
import java.util.*;
|
||||
import javax.script.Bindings;
|
||||
import lombok.*;
|
||||
|
||||
import javax.script.Bindings;
|
||||
import java.util.*;
|
||||
|
||||
@Entity
|
||||
public class GameQuest {
|
||||
@Transient @Getter @Setter private GameMainQuest mainQuest;
|
||||
@ -142,7 +143,7 @@ public class GameQuest {
|
||||
}
|
||||
|
||||
public void setFinishProgress(int index, int value) {
|
||||
finishProgressList[index] = value;
|
||||
this.finishProgressList[index] = value;
|
||||
}
|
||||
|
||||
public void setFailProgress(int index, int value) {
|
||||
|
@ -1,12 +1,11 @@
|
||||
package emu.grasscutter.game.quest.content;
|
||||
|
||||
import static emu.grasscutter.game.quest.enums.QuestContent.QUEST_CONTENT_COMPLETE_TALK;
|
||||
|
||||
import emu.grasscutter.data.excels.quest.QuestData;
|
||||
import emu.grasscutter.game.quest.GameQuest;
|
||||
import emu.grasscutter.game.quest.QuestValueContent;
|
||||
import emu.grasscutter.game.quest.*;
|
||||
import lombok.val;
|
||||
|
||||
import static emu.grasscutter.game.quest.enums.QuestContent.QUEST_CONTENT_COMPLETE_TALK;
|
||||
|
||||
@QuestValueContent(QUEST_CONTENT_COMPLETE_TALK)
|
||||
public class ContentCompleteTalk extends BaseContent {
|
||||
@Override
|
||||
|
@ -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) {
|
||||
|
Loading…
Reference in New Issue
Block a user