Fix statue unlocks, and probably other quests involving talks

This commit is contained in:
KingRainbow44 2023-06-01 18:13:41 -04:00
parent bb1729c227
commit 1940b22dc5
No known key found for this signature in database
GPG Key ID: FC2CB64B00D257BE
4 changed files with 37 additions and 31 deletions

View File

@ -1,12 +1,11 @@
package emu.grasscutter.data.excels; package emu.grasscutter.data.excels;
import com.google.gson.annotations.SerializedName; import com.google.gson.annotations.SerializedName;
import emu.grasscutter.data.GameResource; import emu.grasscutter.data.*;
import emu.grasscutter.data.ResourceType;
import emu.grasscutter.game.talk.TalkExec; import emu.grasscutter.game.talk.TalkExec;
import lombok.*;
import java.util.List; import java.util.List;
import lombok.Data;
import lombok.EqualsAndHashCode;
@ResourceType(name = "TalkExcelConfigData.json") @ResourceType(name = "TalkExcelConfigData.json")
@EqualsAndHashCode(callSuper = false) @EqualsAndHashCode(callSuper = false)
@ -38,6 +37,14 @@ public final class TalkConfigData extends GameResource {
this.finishExec == null this.finishExec == null
? List.of() ? List.of()
: this.finishExec.stream().filter(x -> x.getType() != null).toList(); : 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 @Data

View File

@ -15,10 +15,11 @@ import emu.grasscutter.scripts.data.SceneGroup;
import emu.grasscutter.server.packet.send.*; import emu.grasscutter.server.packet.send.*;
import emu.grasscutter.utils.Utils; import emu.grasscutter.utils.Utils;
import it.unimi.dsi.fastutil.ints.IntIntImmutablePair; import it.unimi.dsi.fastutil.ints.IntIntImmutablePair;
import java.util.*;
import javax.script.Bindings;
import lombok.*; import lombok.*;
import javax.script.Bindings;
import java.util.*;
@Entity @Entity
public class GameQuest { public class GameQuest {
@Transient @Getter @Setter private GameMainQuest mainQuest; @Transient @Getter @Setter private GameMainQuest mainQuest;
@ -142,7 +143,7 @@ public class GameQuest {
} }
public void setFinishProgress(int index, int value) { public void setFinishProgress(int index, int value) {
finishProgressList[index] = value; this.finishProgressList[index] = value;
} }
public void setFailProgress(int index, int value) { public void setFailProgress(int index, int value) {

View File

@ -1,12 +1,11 @@
package emu.grasscutter.game.quest.content; 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.data.excels.quest.QuestData;
import emu.grasscutter.game.quest.GameQuest; import emu.grasscutter.game.quest.*;
import emu.grasscutter.game.quest.QuestValueContent;
import lombok.val; import lombok.val;
import static emu.grasscutter.game.quest.enums.QuestContent.QUEST_CONTENT_COMPLETE_TALK;
@QuestValueContent(QUEST_CONTENT_COMPLETE_TALK) @QuestValueContent(QUEST_CONTENT_COMPLETE_TALK)
public class ContentCompleteTalk extends BaseContent { public class ContentCompleteTalk extends BaseContent {
@Override @Override

View File

@ -1,15 +1,13 @@
package emu.grasscutter.game.talk; 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.GameData;
import emu.grasscutter.data.binout.MainQuestData.TalkData; import emu.grasscutter.data.binout.MainQuestData.TalkData;
import emu.grasscutter.game.player.BasePlayerManager; import emu.grasscutter.game.player.*;
import emu.grasscutter.game.player.Player;
import lombok.NonNull; 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 final class TalkManager extends BasePlayerManager {
public TalkManager(@NonNull Player player) { public TalkManager(@NonNull Player player) {
super(player); super(player);
@ -22,10 +20,10 @@ public final class TalkManager extends BasePlayerManager {
* @param npcEntityId The entity ID of the NPC being talked to. * @param npcEntityId The entity ID of the NPC being talked to.
*/ */
public void triggerTalkAction(int talkId, int npcEntityId) { public void triggerTalkAction(int talkId, int npcEntityId) {
var talkData = GameData.getTalkConfigDataMap().get(talkId);
if (talkData == null) return;
var player = this.getPlayer(); var player = this.getPlayer();
var talkData = GameData.getTalkConfigDataMap().get(talkId);
if (talkData != null) {
// Check if the NPC id is valid. // Check if the NPC id is valid.
var entity = player.getScene().getEntityById(npcEntityId); var entity = player.getScene().getEntityById(npcEntityId);
if (entity != null) { if (entity != null) {
@ -38,14 +36,15 @@ public final class TalkManager extends BasePlayerManager {
.getFinishExec() .getFinishExec()
.forEach(e -> player.getServer().getTalkSystem().triggerExec(player, talkData, e)); .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. // Invoke the talking events for quests.
var questManager = player.getQuestManager(); var questManager = player.getQuestManager();
questManager.queueEvent(QUEST_CONTENT_COMPLETE_ANY_TALK, talkId); questManager.queueEvent(QUEST_CONTENT_COMPLETE_ANY_TALK, talkId);
questManager.queueEvent(QUEST_CONTENT_COMPLETE_TALK, talkId); questManager.queueEvent(QUEST_CONTENT_COMPLETE_TALK, talkId);
questManager.queueEvent(QUEST_COND_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) { public void saveTalkToQuest(int talkId, int mainQuestId) {