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.
* 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.",
* 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.
Known Bugs / TODO Make your suggestions or report bugs here!
Requirements
Yanfly's Message Core plugin - YEP_MessageCore.js. Set the "Word Wrap" plugin parameter to true.
History Spoilerv1.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.