mirror of
https://github.com/Grasscutters/Grasscutter.git
synced 2026-06-11 17:05:09 +08:00
Fixes for alchemy dude's quest (#2352)
* Add drops for gadgets Gadgets only have drop_id when they are not chests (chest_drop_id). When drop_id is not set (0), handleChestDrop quickly exits * Implement QUEST_COND_ITEM_GIVING_FINISHED Took the oppertunity to Rename ContentFinishGivingItem to ItemGiving * Store accept conditions like fail and finish content are Took the oppertunity to clean up some old code as well conditions are stored in QuestManager * Update src/main/java/emu/grasscutter/game/quest/QuestManager.java Co-authored-by: Magix <27646710+KingRainbow44@users.noreply.github.com> * Update ConditionItemGivingFinished.java --------- Co-authored-by: Magix <27646710+KingRainbow44@users.noreply.github.com>
This commit is contained in:
committed by
GitHub
Unverified
parent
47c96fd964
commit
fbe2b138ee
@@ -169,23 +169,6 @@ public class GameMainQuest {
|
||||
this.state = ParentQuestState.PARENT_QUEST_STATE_FINISHED;
|
||||
}
|
||||
|
||||
/*
|
||||
* We also need to check for unfinished childQuests in this MainQuest
|
||||
* force them to complete and send a packet about this to the user,
|
||||
* because at some points there are special "invisible" child quests that control
|
||||
* some situations.
|
||||
*
|
||||
* For example, subQuest 35312 is responsible for the event of leaving the territory
|
||||
* of the island with a statue and automatically returns the character back,
|
||||
* quest 35311 completes the main quest line 353 and starts 35501 from
|
||||
* new MainQuest 355 but if 35312 is not completed after the completion
|
||||
* of the main quest 353 - the character will not be able to leave place
|
||||
* (return again and again)
|
||||
*/
|
||||
// this.getChildQuests().values().stream()
|
||||
// .filter(p -> p.state != QuestState.QUEST_STATE_FINISHED)
|
||||
// .forEach(GameQuest::finish);
|
||||
|
||||
this.getOwner().getSession().send(new PacketFinishedParentQuestUpdateNotify(this));
|
||||
this.getOwner().getSession().send(new PacketCodexDataUpdateNotify(this));
|
||||
|
||||
@@ -383,46 +366,6 @@ public class GameMainQuest {
|
||||
}
|
||||
}
|
||||
|
||||
public void tryAcceptSubQuests(QuestCond condType, String paramStr, int... params) {
|
||||
try {
|
||||
List<GameQuest> subQuestsWithCond =
|
||||
getChildQuests().values().stream()
|
||||
.filter(
|
||||
p ->
|
||||
p.getState() == QuestState.QUEST_STATE_UNSTARTED
|
||||
|| p.getState() == QuestState.UNFINISHED)
|
||||
.filter(
|
||||
p ->
|
||||
p.getQuestData().getAcceptCond().stream()
|
||||
.anyMatch(
|
||||
q ->
|
||||
condType == QuestCond.QUEST_COND_NONE || q.getType() == condType))
|
||||
.toList();
|
||||
var questSystem = owner.getServer().getQuestSystem();
|
||||
|
||||
for (GameQuest subQuestWithCond : subQuestsWithCond) {
|
||||
var acceptCond = subQuestWithCond.getQuestData().getAcceptCond();
|
||||
int[] accept = new int[acceptCond.size()];
|
||||
|
||||
for (int i = 0; i < subQuestWithCond.getQuestData().getAcceptCond().size(); i++) {
|
||||
var condition = acceptCond.get(i);
|
||||
boolean result =
|
||||
questSystem.triggerCondition(
|
||||
getOwner(), subQuestWithCond.getQuestData(), condition, paramStr, params);
|
||||
accept[i] = result ? 1 : 0;
|
||||
}
|
||||
|
||||
boolean shouldAccept =
|
||||
LogicType.calculate(subQuestWithCond.getQuestData().getAcceptCondComb(), accept);
|
||||
|
||||
if (shouldAccept) subQuestWithCond.start();
|
||||
}
|
||||
this.save();
|
||||
} catch (Exception e) {
|
||||
Grasscutter.getLogger().error("An error occurred while trying to accept quest.", e);
|
||||
}
|
||||
}
|
||||
|
||||
public void tryFailSubQuests(QuestContent condType, String paramStr, int... params) {
|
||||
try {
|
||||
List<GameQuest> subQuestsWithCond =
|
||||
@@ -437,7 +380,7 @@ public class GameMainQuest {
|
||||
for (GameQuest subQuestWithCond : subQuestsWithCond) {
|
||||
val failCond = subQuestWithCond.getQuestData().getFailCond();
|
||||
|
||||
for (int i = 0; i < subQuestWithCond.getQuestData().getFailCond().size(); i++) {
|
||||
for (int i = 0; i < failCond.size(); i++) {
|
||||
val condition = failCond.get(i);
|
||||
if (condition.getType() == condType) {
|
||||
boolean result =
|
||||
@@ -445,7 +388,7 @@ public class GameMainQuest {
|
||||
.getServer()
|
||||
.getQuestSystem()
|
||||
.triggerContent(subQuestWithCond, condition, paramStr, params);
|
||||
subQuestWithCond.getFailProgressList()[i] = result ? 1 : 0;
|
||||
subQuestWithCond.setFailProgress(i, result ? 1 : 0);
|
||||
if (result) {
|
||||
getOwner().getSession().send(new PacketQuestProgressUpdateNotify(subQuestWithCond));
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user