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;
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

View File

@ -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) {

View File

@ -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

View File

@ -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,10 +20,10 @@ 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();
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) {
@ -38,14 +36,15 @@ public final class TalkManager extends BasePlayerManager {
.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) {