bluebooth

Regular
Regular
Joined
Nov 12, 2015
Messages
95
Reaction score
123
First Language
English
Primarily Uses
N/A
 This is pretty cool, can't wait to try it out!


Just wanted to drop a comment that I was banging my head against the wall for a while trying to get the plugin to work. I used the plugin command indicated in the help file (RandomConversation getRandomMsg category topic faceset faceNum) and couldn't get it running forever, but then I realized your example posted in this thread is "RandomConversations getRandomMsg category topic faceset faceNum". Added the 's' to the command and it works like a charm now! Don't know if it's a typo or what, but I thought I'd just point it out in case it helps someone.


Thanks for this great plugin!


Edit: Quick question/request, is it possible to break the text into different windows? Like if I want to control the 'page breaks' for my long gossips, if that makes sense! 



Hey Veralisa, I'm glad you like it!  In light of your struggle, v1.01a adds in a check that will output an error message to console if you use RandomConversation instead of RandomConversations in your plugin command.  I hope that this will make it easier to use.  I also added in explicit instructions and and examples of how to use \ and other message codes in the Rumors.json.





 





Currently, gossips are limited to a single window, although it was my original intent not to have that limitation.  The issue I'm having there is that it means the plugin becomes much more complicated.  Consider; in the current form, you can set a variety of message box options outside the plugin using default
RMMV functions.  If I make a chain of message boxes, each message may potentially have different message settings.  Therefore, I'd need to include all those options on a per message basis in the JSON and script logic. My other worry is how to include multiple dialogues for each random dialogue in the JSON file without it getting so big it causes performance issues.  





 





Thoughts, anyone?
 

cmgamesofficial

Learner
Regular
Joined
Feb 14, 2015
Messages
34
Reaction score
16
First Language
Taglish
Primarily Uses
One of my fave plugin. I like the diversity in games. Hope you have a step by step tutorials for noobs. Thanks.
 

bluebooth

Regular
Regular
Joined
Nov 12, 2015
Messages
95
Reaction score
123
First Language
English
Primarily Uses
N/A
One of my fave plugin. I like the diversity in games. Hope you have a step by step tutorials for noobs. Thanks.



Hey thanks, man.  The positive feedback means a lot.  What kind of tutorial would you be looking for exactly?
 

cmgamesofficial

Learner
Regular
Joined
Feb 14, 2015
Messages
34
Reaction score
16
First Language
Taglish
Primarily Uses
Hey thanks, man.  The positive feedback means a lot.  What kind of tutorial would you be looking for exactly?

A very detailed and beginner friendly kind of tutorial would be great. This is not just for me but for those people who are just starting to learn the basic of RMMV and JavaScript.


If you want, after I learn more about your plugin, I will make a simple guide for beginners in pdf form so that people will just download it. Of course credits goes to you and your plugin. Again, hope you can think of things to improve more because one of the things that lack role-playing games in my observation are diversity and randomness.


If you can't make it, that's fine still love this plugin. CM
 
Last edited by a moderator:

bluebooth

Regular
Regular
Joined
Nov 12, 2015
Messages
95
Reaction score
123
First Language
English
Primarily Uses
N/A
A very detailed and beginner friendly kind of tutorial would be great. This is not just for me but for those people who are just starting to learn the basic of RMMV and JavaScript.


If you want, after I learn more about your plugin, I will make a simple guide for beginners in pdf form so that people will just download it. Of course credits goes to you and your plugin. Again, hope you can think of things to improve more because one of the things that lack role-playing games in my observation are diversity and randomness.


If you can't make it, that's fine still love this plugin. CM



Hey thanks, man.  That would be really cool of you.  I'm currently swamped at university, so I haven't had time to put together better documentation yet.  You're welcome to PM me, I can explain how everything works to you.  That much I can do.  Later on, I'll try and work out a video with my volunteer editor.
 

Anthony Xue

Ancient Architect
Regular
Joined
May 9, 2016
Messages
144
Reaction score
144
First Language
German
Primarily Uses
Well, since I very much liked this plugin but also found documentation a little lacking, I eventually overcame inertia (fancy way to say laziness) and wrote a small demo. You can find it here:

http://ancient-architects.com/files/Conversation Demo.zip

To play: Set up a new project in RMMV, then copy the files from the zip into the project folder (overwrite wherever necessary). Have fun!
 

Raptorking

Warper
Member
Joined
Dec 20, 2017
Messages
1
Reaction score
0
First Language
English
Primarily Uses
RMMV
Great plugin, this is (almost) exactly what I was looking for. I only have one problem, while it works perfectly on the map, it doesn't work when it comes to trying to run the plugin command during a battle (it ends up showing a "TypeError: undefined is not a function" message), which is exactly what I need. Is it possible to tweak it somehow so that it can pull up a random message during a fight event?
 

ClassDev

Warper
Member
Joined
Feb 28, 2019
Messages
1
Reaction score
0
First Language
English
Primarily Uses
RMMV
Random Dialogue v1.03a
Author: Michael Morris @Blue Booth Studios
Demo thanks to Anthony Xue: http://ancient-architects.com/files/Conversation Demo.zip

Introduction
Sometimes you just need NPCs to say random stuff. Not completely random, per say, but for example, let's say you have an NPC who shares rumors with the player. As long as said rumor is unlocked, you don't care which rumor the NPC cares to share. Likewise, you may have a series of lines kids can say "you look funny!", "Mister, where do babies come from?" or something else inane. You might even have the kids say smart things. But again, you simply care that one intelligent option is chosen, not which specific line activates. While you can do all of this manually using conditional branches... you can also use this script and not have that nasty conditional mess to check every time something goes wonky. This script takes care of all the issues above for you, so you can spend less time checking random kid 36b says the right thing. In fact, this can even be used to improve world immersion, as your NPCs will now say different, but appropriate things!

Features
  • Select a dialogue line at random from a series of dialogue lines. This has many uses, but for example, allows you to easily replicate Fi's "rumors" system from Skyward Sword.
  • Dialogue lines can be limited based on real-time conditions - for example, "I know where the cave is" will only show if a game switch is active, which indicates the player has heard about the cave.
  • Dialogue lines separated into categories and topics. This means you can have rumors, game tips, and a whole bunch of other stuff in rumors.json, and select "rumors" to only choose from rumor dialogue lines.
  • Random dialogue lines use the message box without additional modification, so any changes to the message box you make before calling the Plugin Command (position, windowskin, etc.) will carry over to affect the appearance of the dialogue lines.
  • Dialogue lines can be restricted by a further condition - "available" is intended to track when a line is unlocked (for example, if the player kills a bandit, dialogue about that bandit being dangerous won't show). "restriction" is intended to further restrict dialogue lines to be appropriate to a speaker. For example, you can use a game variable with a manually tracked index (ie. Widow = 1, Guard = 2, Veteran = 3), so that an NPC will not say a random line that would be out of character.
  • Random will now avoid consecutive repetition of a given dialogue line, provided more than one random dialogue line is available to choose from.
  • Faceset support!
  • NPCs will not resume movement while a random dialogue line is displayed.
  • Plugin now displays user-friendly error messages for an incorrect number of parameters, misspelling of command, etc.
  • Plugin now supports case insensitive checks (requires rumors.json having all Category and Topic values in lower-case).

Screenshots
None.


How to Use
  • Copy script into your game js/plugins directory.
  • Create a Rumors.json file in your game data directory.
  • Import this script into your project and set all two parameters.
  • Use the Plugin Command to get a random dialogue line output into message box.

Demo
Thanks to Anthony Xue, a demo is available here:
http://ancient-architects.com/files/Conversation Demo.zip

Create a new project, and then extract this archive into that new project.


Script
Code:
//=============================================================================
// Bluebooth Plugins - Random Conversations
// BBS_RandomConversations.js
//=============================================================================

//=============================================================================
 /*:
 * @title Random Conversations Plugin
 * @author Michael Morris (https://www.*******.com/bluebooth)
 * @date Feb 19, 2016
 * @filename BBS_RandomConversations.js
 * If you enjoy/benefit from my work, please support me on *******!
 *
 * https://www.*******.com/bluebooth
 *
 * @plugindesc v1.03a Add random dialogue for a specific topic to your game.
 * This allows you to pick a random (unlocked) rumor to share, pick a hint at random, given
 * general dialogue on a specific point, etc.  There's a lot of exciting things you can
 * do with this!  Original design was merged with elements of Iavra's Achievements
 * file parsing and then new enhancements / reworkings were added on top of that.
 * Special Thanks to Tsukihime for all the help.
 * Special Thanks to Anthony Xue for bug fixes and documentation help.
 * Special Thanks to Iavra, the file parse handling is modified from his own (awesome) Achievements plugin.
 *  You should pick it up, it's really well done.
 *
 * ============================================================================
 * Terms of Use
 * ============================================================================
 *   - Free for use in non-commercial projects with credits
 *   - Contact me for commercial use
 *
 * ============================================================================
 * Parameters
 * ============================================================================
 * @param Configuration File
 * @desc Name of an external configuration file to load at game start. Default: data/Rumors.json
 * @default data/Rumors.json
 *
 * @param Case Insensitive
 * @desc Enable to use case insensitive string comparisons.  You will need to manually
 * convert Rumors.json Categories and Topics values to lower case.
 * @default false
 *
 * @param Debug Mode
 * @desc Enable to activate console variable logging.  Use for debugging odd behaviour.
 * true to enable console variable logging.
 * @default false
 *
 * @help
 * ============================================================================
 * Description
 * ============================================================================
 * Add random dialogue for a specific topic to your game.  This allows you to pick a random (unlocked) rumor to share,
 * pick a hint at random, given general dialogue on a specific point, etc.  There's a lot of exciting things you can
 * do with this!  Original design was merged with elements of Iavra's Achievements file parsing and then new
 * enhancements / reworkings were added on top of that.
 *
 * To add random dialogue to your game, create a txt file in your data directory called rumors.json.  This is
 * a very flexible system that can be used from anything to random dialogue to selecting one random rumor from a series of many,
 * to doing the same for hints, and so on.  To support having multiple topics (each with an item that can be selected at random),
 * these dialogue items are split into both Topics (ie. "The Temple Puzzle") and "Categories" (ie. "Puzzles").  Each dialogue
 * entry consists of multiple properties:
 *
 * id           A unique numeric id, that may not contain commas or whitespaces.
 * topic        Topic name.
 * category        Category name.
 * dialogue        Dialogue box contents associated with this topic.  To add \c[], \v[], \i... or other message shortcuts, you must use two slashes \\ in JSON.  See examples below.
 * available    Eval condition as string.  If true, this dialogue item is available.
 * restriction  Eval condition as string.  If false, this dialogue item is available.  Used to restrict random conversation items
 *                for specific NPCs (ie. "adventurer only", "widow only", etc.)
 *
 * This is a sample file, containing one of each achievement types:
 *
 * [
 *    {
 *         "id":0,
 *         "topic":"SantaCompana",
 *            "category":"Toledo",
 *         "dialogue":"They say the \\c[3]Santa Compana\\c[0] has been spotted near the \\c[3]Old Monastery\\c[0].  I hope it doesn't get any closer to town.",
 *         "available":"$gameSwitches.value(297) === false",
 *         "restriction":"false"
 *    },
 *    {
 *         "id":1,
 *         "topic":"SantaCompana",
 *             "category":"Toledo",
 *         "dialogue":"I haven't heard any news about \\c[3]Santa Compana\\c[0] sightings.  Maybe the reaper has moved on?",
 *         "available":"$gameSwitches.value(297) === true",
 *         "restriction":"false"
 *    },
 *    {
 *         "id":2,
 *         "topic":"Culebre",
 *             "category":"Toledo",
 *         "dialogue":"I don't know how my family is going to stay fed with that damned \\c[3]Culebre\\c[0] at large.",
 *         "available":"$gameSwitches.value(126) === false",
 *         "restriction":"$gameVariables.value(77) === 2"
 *    }
 * ]
 *
 * ============================================================================
 * Plugin Commands
 * ============================================================================
 * Use the following plugin commands to manipulate custom controls.
 *
 * Plugin Commands:
 *
 *     RandomConversation getRandomMsg category topic faceset faceNum        # Get a random dialogue entry with corresponding category, and topic.  Optional faceset and faceNum may be specified.
 *
 * ============================================================================
 * Change Log
 * ============================================================================
 * 1.03a - Fixed short-list bug.
 * 1.03  - Category and Topic search now has added case insensitivity mode for more user-friendly usage.
 * 1.02a - Fixed some typos and bugs courtesy of Steffen (Anthony Xue).  Thanks man!  User friendly check added for # args.
 * 1.02  - Added in lastconv check to avoid repeating random dialogue when other entries can be played instead.
 * 1.01a - Common mispelling now detected to be more dev friendly.
 *         - Finally found out and documented how to add \... codes as in native Messagebox.
 * 1.01  - Faceset and faceNum are now optional parameters.
 * 1.00a - Fixed references to bad element in help.
 * 1.00  - Plugin finished.
 *
 */
//=============================================================================

//=============================================================================
var Imported = Imported || {} ;
var BBS = BBS || {};
Imported.RandomConversations = 1;
BBS.RandomConversations = BBS.RandomConversations || {};

(function() {

    // Stores all rumors.
    var _rumors;
    var curCategory;
    var curTopic;
    var lastConv;
 
    //=============================================================================
    // Parameter Variables
    //=============================================================================
    var parameters = PluginManager.parameters('BBS_RandomConversations');
    var pConfiguration      = String(parameters['Configuration File'] || 'data/Rumors.json');
    var pLowerCaseChecks  = eval(String(parameters['Case Insensitive'] || 'false'));
    var pDebugging          = eval(String(parameters['Debug Mode'] || 'false'));
 
    //=============================================================================
    // Rumor Class
    //=============================================================================
    function Rumor() {
        this.initialize.apply(this, arguments);
    };
 
    Rumor.prototype.initialize = function(data) {
        this._id = Number(data.id);
        this._topic = String(data.topic);
        this._category = String(data.category);
        this._dialogue = String(data.dialogue);
        this._availableStr = String(data.available);
        this._restrictionStr = String(data.restriction);
    };
 
    Rumor.prototype._isUnlocked = function() {
        return eval(this._availableStr);
    };
 
    Rumor.prototype._isRestricted = function() {
        return eval(this._restrictionStr);
    };
 
    Rumor.prototype.isAvailable = function() {
        return (this._isUnlocked() && !this._isRestricted());
    };
 
    Rumor.prototype = Object.create(Rumor.prototype);
    Rumor.prototype.constructor = Rumor;
 
    /**
     * Creates rumors from the given data and loads their current state, afterwards.
     */
    var _create = function(data) {
        var temp = [];
        for(var i = 0, max = data.length; i < max; ++i) {
            entry = data[i];
            temp.push(new Rumor(entry));
        }
 
        _rumors = temp;
        curCategory = '';
        curTopic = '';
        lastConv = -1;
 
        if (pDebugging) {
            console.log(_rumors);
        }
    };
 
    //=============================================================================
    // Game_Interpreter
    //=============================================================================
    var BBS_RC_Game_Interpreter_pluginCommand = Game_Interpreter.prototype.pluginCommand;
    Game_Interpreter.prototype.pluginCommand = function(command, args) {
        // User friendly correction
        if (command === 'RandomConversation') {
            console.log("BBS_RandomConversations plugin command not called correctly.  Did you mean RandomConversations?");
        }
 
        if (command === 'RandomConversations')
        {
            switch (args[0]) {
                case 'getRandomMsg':
                    SceneManager._scene.getRandomDialogue(args);
                    break;
            };
        }
        else {
            BBS_RC_Game_Interpreter_pluginCommand.call(this, command, args);
        }
    };
 
    //=============================================================================
    // Game_Temp
    //=============================================================================
 
    /* Tsukihime - Generates a random number from the given interval.
     You can customize the algorithm used to generate a
     random number if needed */
    Game_Temp.prototype._generateRandomValue = function(min, max) {
        if (min === max) {
          return min;
        }
        else {
          // Maybe you can customize this
          return Math.floor(Math.random() * (max - min + 1)) + min
        }
    };
 
    //=============================================================================
    // Scene_Map
    //=============================================================================
    Scene_Map.prototype._createShortlist = function(category, topic) {
        var temp = [];
        this.shortlist = [];
        lastConv = -1;
 
        for (var i = 0; i < _rumors.length; i++)
        {
            if (_rumors[i]._category === category && _rumors[i]._topic === topic)
            {
                if (_rumors[i].isAvailable()) {
                    temp.push(_rumors[i]);
                }
            }
        }
 
        if (temp.length > 1) {
            // Remove last conversation entry, only if there are sufficient entries to remove it.
            for (var j = 0; j < temp.length; j++) {
                if (temp[j]._id != lastConv) {
                    this.shortlist.push(temp[j]);
                }
            }
        }
        else {
            this.shortlist = temp;
        }
 
        // For debugging sake.
        if (this.shortlist.length <= 0) {
            console.log("ERROR: No random conversations options for Category: '" + category + "' ; Topic: '" + topic + "'");
        }

        curCategory = category;
        curTopic = topic;
    };
 
    Scene_Map.prototype.getRandomDialogue = function(args) {
        if (args.length < 2) {
            console.log("ERROR: Too few parameters passed into getRandomMsg(...).  Minimum args: 2.");
        }
 
        var category = String(args[1]);
        var topic = String(args[2]);
 
        // User sanity; remove need for matching capitalization.
        if (pLowerCaseChecks === true) {
            category = category.toLowerCase();
            topic = topic.toLowerCase();
        }
 
        this._createShortlist(category, topic);
        if (this.shortlist.length <= 0) return;
 
        var randomIndex = $gameTemp._generateRandomValue(0, (this.shortlist.length - 1));
 
        $gameMap._interpreter.setWaitMode('message');
 
        if (args.length > 3) {
            var faceFile = String(args[3]);
     
            var faceNum = 0;
            if (args.length > 4) {
                faceNum = Number(args[4]);
            }
     
            $gameMessage.setFaceImage(faceFile, faceNum);
        }
 
        $gameMessage.addText(this.shortlist[randomIndex]._dialogue);
        lastConv = this.shortlist[randomIndex]._id;
    };
 
    //=============================================================================
    // class Scene_Boot
    //=============================================================================
    var BBS_RC_Scene_Boot_create = Scene_Boot.prototype.create;
    Scene_Boot.prototype.create = function() {
        BBS_RC_Scene_Boot_create.call(this);
        this._loadFile(pConfiguration, _create);
    };
 
    Scene_Boot.prototype._loadFile = function(url, callback) {
        var request = new XMLHttpRequest();
        request.open('GET', url);
        request.overrideMimeType('application/json');
        request.onload = function() { callback(JSON.parse(request.responseText)); }
        request.onerror = function() { throw new Error('There was an error loading the file ' + url); }
        request.send();
    };
 
    var BBS_RC_Scene_Boot_isReady = Scene_Boot.prototype.isReady;
    Scene_Boot.prototype.isReady = function() {
        return !!_rumors && BBS_RC_Scene_Boot_isReady.call(this);
    };
 
})(BBS.RandomConversations);
//=============================================================================
// End of File
//=============================================================================

Known Bugs / TODO
Make your suggestions or report bugs here!

Requirements
  1. Yanfly's Message Core plugin - YEP_MessageCore.js. Set the "Word Wrap" plugin parameter to true.

History
v1.03a
- Fixed bug with availability and restriction conditions due to shortlist caching.
v1.03
- Category and Topic search now has added case insensitivity mode for more user-friendly usage.
v1.02a
- Fixed typos and bugs courtesy of Steffen (Anthony Xue). Thanks man! User friendly check added for # args.
v1.02

- Added in lastconv check to avoid repeating random dialogue when other entries can be played instead.
v1.01a
- Finally found out and documented how to add \... codes as in native Messagebox.
- Common misspelling now detected to be more developer friendly.
v1.01
- Faceset and faceNum are now optional parameters.
- Squashed some bugs.
- Fixed the last few documentation errors.
v1.00a
- Fixed documentation errors.
v1.00
- Plugin released.

Suggestions, bug reports, and feature requests are welcomed!


Compatibility Issues
None known. Compatible with Klaus Map Overlays, Terrax Lighting System, and most (if not all) of Yanfly's plugins.

FAQ
Q: The demo won't open, how to open it?
A: Download Winrar and try again.


Credit and Thanks
  • Micheal Morris @Blue Booth Studios
  • Credit to Tsukihime for continuing to be so helpful!
  • Special Thanks to Anthony Xue for bug fixes and documentation help.
  • Iavra for the JSON handling code, based on that from achievements.js.

Author's Notes
Free for non-commercial usage as long as credit is given, contact me for commercial use.
Hi, i’m A bit late but, what if I don’t want to use a topic. I’m making a math game and I don’t want it to be the same problems every time. I have a list of problems but I would love it if I could find a way to not use a topic and just make it have a random problem and some choices for the answers. Thank you!
 

KARAKURT

Villager
Member
Joined
Nov 3, 2016
Messages
24
Reaction score
5
First Language
Russian
Primarily Uses
RMMZ
Hello. Is there this plugin on MZ?
 

fizzly

Regular
Regular
Joined
Mar 23, 2012
Messages
1,665
Reaction score
1,254
First Language
Polish
Primarily Uses
RMMZ
Amazing jon, this should be a part of newer RM engine :)
(is this MV or MZ, or maybe both?)
 

Latest Threads

Latest Profile Posts

Knocked out two more cutscenes. Think that leaves me at 6? Last two are the two endings though so don't know if that counts as a "cutscene" but still.
Begrudgingly watched the first episode of Oshi No Ko. I didn't want to at first, but it came highly recommended.
Yeah, not a fun show
707.jpg
ATT_Turan wrote on Puppet Knight's profile.
castinganim.gif


Boring: Using RPG Maker's default inventory function.
Based: Using SRD's Skill Extender to make submenus that split up items based on their use.

... Also I plan to use this for containing different levels of the same skill into one place.
Couple shots of my own window and button set stuff in action.

Forum statistics

Threads
135,053
Messages
1,253,336
Members
178,031
Latest member
A-mn3
Top