Yanfly quest journal issue

Discussion in 'Javascript/Plugin Support' started by Callangoso, Dec 29, 2018.

  1. Callangoso

    Callangoso Warper Member

    Messages:
    3
    Likes Received:
    0
    First Language:
    Portuguese
    Primarily Uses:
    RMMV
    Hello everyone! I have been tinkering with some plugins for my test project on RPG Maker MV. Having a quest log is very useful, and I was planning on using Yanfly's, but I have found a small issue with it, and I am not sure if it's a bug or me doing something incorrectly.

    The plugin gives you the option to hide quest types (so Main quests, side quests, characters quests, etc), but it should still show quests (they should simply be all together, without being categorized), yet no quest shows in the log, despite the correct number of quests being listed in the category window (completed, failed, etc).

    I was wondering if anyone could help me with this, either if they can tell me it's a known issue, or if I am doing something wrong and if it's fixable. upload_2018-12-28_16-32-50.png
     
    #1
  2. Fornoreason1000

    Fornoreason1000 Black Sheep Veteran

    Messages:
    199
    Likes Received:
    92
    Location:
    Anor Londo
    First Language:
    English
    Primarily Uses:
    RMMV
    what exactly are you trying to achieve?
    it sound like you are trying to hide quest types and then wondering why they don't show up?

    is this the setting you are talking about?
    YEpQuestJournalTypes.png

    basically if you set Show Types to false for some reason all the quest do not appear, despite Yanfly saying it should.
    Interesting, not sure if its a bug yet or if I'm over looking something.

    Edit: after investigating it does appear to be a bug with the plugin, the good news I know where it is and why it happens.

    Basically when you select "False" on the variable and then open the Quest Menu in game, Yanfly's script will check it and if it returns false it will call addQuestCommands(category, type) but with no type parameter.

    Code:
    Window_QuestList.prototype.makeQuestList = function() {
      if (this.showType()) {
        var list = JSON.parse(this.settings('Type Order'));
        var length = list.length;
        for (var i = 0; i < length; ++i) {
          var listItem = list[i];
          var fmt = this.settings('Type Text Format');
          var type = listItem.replace(/\\I\[(\d+)\]/gi, '').trim();
          var type = listItem.replace(/\\C\[(\d+)\]/gi, '').trim();
          if (this._closedQuestTypes.contains(type)) {
            var closed = this.settings('List Closed Symbol');
          } else {
            var closed = this.settings('List Open Symbol');
          }
          var number = $gameSystem.getTypeQuests(this._currentCategory,
            type).length;
          if (!this.showEmptyTypes() && number <= 0) continue;
          number = Yanfly.Util.toGroup(number);
          var text = fmt.format(closed, listItem, number);
          this.addCommand(text, 'type', true, type);
          if (!this._closedQuestTypes.contains(type)) {
            this.addQuestCommands(this._currentCategory, type);
          }
        }
      } else {
        this.addQuestCommands(this._currentCategory) //when Show type is false!
      }
    };

    .in this function the type parameter will 'Default' to a Empty string as seen below

    Code:
    Window_QuestList.prototype.addQuestCommands = function(category, type) {
      category = category || this._currentCategory;
      type = type || ''; //since we provided 'undefined', we default to an empty string.
      var list = $gameSystem.getTypeQuests(category, type); //empty string is used here
      var length = list.length;
      for (var i = 0; i < length; ++i) {
        var questId = list[i];
        var questData = $dataQuests[questId];
        if (!questData) continue;
        var text = questData.name;
        this.addCommand(text, 'quest', true, questId);
      }
    };
    addQuestCommands will then call $gameSystem.getTypeQuest(category, type). type will again Default to an empty string.
    Based on the category provided, $gameSystem.getTypeQuest will call various Functions such as getAvalaibleQuest() to retrieve quest Data.
    after which is where the bug happens.

    Code:
    Game_System.prototype.getTypeQuests = function(category, type) {
      this.initQuestSettings();
      category = category || 'all';
      type = type || ''; //its already an empty string, but since thats a falsey value it will default again!
      var result = []; //this is the array of quest we want from this function
      if (category === 'available') {
        var quests = this.getQuestsAvailable();
      } else if (category === 'completed') {
        var quests = this.getQuestsCompleted();
      } else if (category === 'failed') {
        var quests = this.getQuestsFailed();
      } else {
        var quests = this.getAllQuests();
      }
      var length = quests.length;
    
      for (var i = 0; i < length; ++i) {
        var questId = quests[i];
        var questData = $dataQuests[questId];
        if (!questData) continue;
        //this is what causes the bug, Yanfly will only add the quest if the Quest Type matches, but since a
        //Empty string has been passed as the Quest Type, no quest will ever match
        if (questData.type === type) result.push(questId);
      }
      return result;
    };

    before returning the array of quest, yanfly will run a loop , only adding quest that matches the Quest Type, since he function already defaulted to an Empty string thanks to Show Types being false, none of the quest match and thus no Quest will be added to the array.

    Here is what's supposed to happen
    DS Engine 001 31-Dec-18 10_19_04 PM.png

    it should be noted that specifying an empty type in a Quest will default it to 'Main Quest" somehow. this mean you can't circumvent this bug be adding no quest types to Quest.
     
    Last edited: Dec 31, 2018
    #2

Share This Page