Anime-Game-Servers / Grasscutter-Quests

A server software implementation, ineroperable with a certain anime game client. The code in this repository is fully custom made for edyoucational purposes and future preservation, no copyrighted code is allowed in this repository.
https://grasscutters.xyz/grasscutter
GNU Affero General Public License v3.0
137 stars 31 forks source link

[Feature Request] QUEST_EXEC_REGISTER_DYNAMIC_GROUP_ONLY #157

Open scooterboo opened 2 months ago

scooterboo commented 2 months ago

QUEST_EXEC_REGISTER_DYNAMIC_GROUP_ONLY is not implemented. It makes it so that these bushes do not spawn in quest 1201202 (Yoimiya's story quest): image

After pretty much copying the code from QUEST_EXEC_REGISTER_DYNAMIC_GROUP:

package emu.grasscutter.game.quest.exec;

import emu.grasscutter.data.common.quest.SubQuestData.QuestExecParam;
import emu.grasscutter.game.quest.GameQuest;
import emu.grasscutter.game.quest.QuestGroupSuite;
import emu.grasscutter.game.quest.QuestSystem;
import emu.grasscutter.game.quest.QuestValueExec;
import emu.grasscutter.game.quest.enums.QuestExec;
import emu.grasscutter.game.quest.handlers.QuestExecHandler;
import emu.grasscutter.game.world.Scene;

@QuestValueExec(QuestExec.QUEST_EXEC_REGISTER_DYNAMIC_GROUP_ONLY)
public class ExecRegisterDynamicGroupOnly extends QuestExecHandler {

    @Override
    public boolean execute(GameQuest quest, QuestExecParam condition, String... paramStr) {
        var sceneId = quest.getOwner().getSceneId();
        var groupId = Integer.parseInt(paramStr[0]);

        QuestSystem.getLogger().info("Registering group {}", groupId);

        Scene scene = quest.getOwner().getWorld().getSceneById(sceneId);
        if (scene == null) return false;

        int suiteId = scene.loadDynamicGroup(groupId);
        if (suiteId == -1) return false;

        quest.getMainQuest().getQuestGroupSuites().add(QuestGroupSuite.of()
            .scene(sceneId)
            .group(groupId)
            .suite(suiteId)
            .build());

        QuestSystem.getLogger().debug("Registered group {}, suite {} in scene {}", groupId, suiteId, scene.getId());

        return true;
    }

}

The bushes spawn: image

The bushes can be cut and the quest continues, but the arrows do not go away (probably a separate issue): image