SkullZMinus

Warper
Member
Joined
Mar 3, 2020
Messages
2
Reaction score
1
First Language
English
Primarily Uses
RMMV
Sorry if I'm posting this in the wrong place--this is my first thread on the site--but I'm working on a game with quite a few plugins, and I've set the escape chance to 100% using Yanfly's battle core plugin mostly because I don't want to force players to fight battles they're tired of fighting. The only thing is, I want to add a bit of flair to the escape messages when they leave the battle, and while I've edited the one message in the Database > Terms > Messages menu, I was wondering if there was a way to add multiple escape messages that are chosen randomly every time the player escapes from a battle rather than having only one ever show up over and over again. Just the little things in life, y'know? I've tried googling various different terms to get a plugin I'm looking for, but all I'm getting are text box message plugins instead of system message plugins. Is this goal an achievable one, or no?
 

MushroomCake28

KAMO Studio
Global Mod
Joined
Nov 18, 2015
Messages
3,822
Reaction score
4,754
First Language
English
Primarily Uses
RMMZ
I was wondering if there was a way to add multiple escape messages that are chosen randomly every time the player escapes from a battle rather than having only one ever show up over and over again.
This will require a plugin since the default engine does not allow that. It would be a very simple plugin, but it's still a plugin nonetheless.

Moved to JS Plugin Requests.

 

caethyril

^_^
Veteran
Joined
Feb 21, 2018
Messages
2,272
Reaction score
1,681
First Language
EN
Primarily Uses
RMMZ
Stick this in a .js file (Save As > File Type: All Files, Filename: whateverYouLike.js) then import it as a plugin:
JavaScript:
(function(alias) {
'use strict';
	const SPLIT = '|';
	TextManager.message = function(messageId) {
		let msg = alias.apply(this, arguments) || '';
		let arr = msg.split(SPLIT);
		return arr[Math.randomInt(arr.length)] || '';
	};
})(TextManager.message);
This will let you write an Escape Start line like this, with multiple options separated by the | character:
  • %1 has started to escape!|%1 flees!|%1 decides to run away.
The actual flee message should be randomly picked from the available options, each option equally weighted. Note that due to the way I've coded it, this technically applies to every "Message" in that list on the Terms tab...not really suitable for some of them, but hey~ :kaothx:

If you happen to like using the | character in your messages, you can change the "split" character to something else by editing this line:
JavaScript:
	const SPLIT = '|';

Lastly: remember to save your project after making Plugin Manager changes, otherwise those changes won't be seen during play. :kaophew:
 

SkullZMinus

Warper
Member
Joined
Mar 3, 2020
Messages
2
Reaction score
1
First Language
English
Primarily Uses
RMMV
Stick this in a .js file (Save As > File Type: All Files, Filename: whateverYouLike.js) then import it as a plugin:
JavaScript:
(function(alias) {[/INDENT]
[INDENT]'use strict';[/INDENT]
[INDENT]    const SPLIT = '|';[/INDENT]
[INDENT]    TextManager.message = function(messageId) {[/INDENT]
[INDENT]        let msg = alias.apply(this, arguments) || '';[/INDENT]
[INDENT]        let arr = msg.split(SPLIT);[/INDENT]
[INDENT]        return arr[Math.randomInt(arr.length)] || '';[/INDENT]
[INDENT]    };[/INDENT]
[INDENT]})(TextManager.message);
This will let you write an Escape Start line like this, with multiple options separated by the | character:
  • %1 has started to escape!|%1 flees!|%1 decides to run away.
The actual flee message should be randomly picked from the available options, each option equally weighted. Note that due to the way I've coded it, this technically applies to every "Message" in that list on the Terms tab...not really suitable for some of them, but hey~ :kaothx:

If you happen to like using the | character in your messages, you can change the "split" character to something else by editing this line:
JavaScript:
    const SPLIT = '|';

Lastly: remember to save your project after making Plugin Manager changes, otherwise those changes won't be seen during play. :kaophew:
Thank you, this works wonderfully. I've got a list of credits to give for my project, so even though this is a simple script and I have no idea how much effort it actually took to make, I still want to make sure everyone that wrote something gets some recognition when I finally finish this game in twenty years. It's much appreciated!
 

Latest Threads

Latest Posts

Latest Profile Posts

I have an idea, I am making low polygon 3D resources for a package in itch. but it occurred to me that I could export these as images and make MV / MZ compatible tilesets. What do you think of this?
I hate seeing threads where less-experienced user's ask for an opinion of their project, and the thread is full of negative feedback by others who are clearly not the target audience. I feel bad for the OP, and I hope they understand that no game can appeal to everyone. :frown:
Hm, just found out I can't use loops, yay.
-Ele
I just wanna Covid to be over and I have my normal life back... Feeling so bad these days, what can I do?

Forum statistics

Threads
109,074
Messages
1,041,859
Members
141,572
Latest member
Romull01
Top