I'm just curious if it's possible (With or without plugins) if you can have a Sound Effect play when a player obtains certain rare items in the battle results text box. I want to be able to draw attention to a player receiving a rare drop or a drop via some special method. Thank you.
Any way to have a SE play if a player receives a rare drop from a battle?
RPG Maker MV SupportTry this. Paste the below into a text editor, save as a *.js file, include as a plugin.
Change the settings on the line that starts with AudioManager to have whichever SE you want, with the appropriate parameters. Then give any drops the notetag <rare>
Code:
BattleManager.displayDropItems = function() {
var items = this._rewards.items;
if (items.length > 0) {
$gameMessage.newPage();
items.forEach(function(item) {
$gameMessage.add(TextManager.obtainItem.format(item.name));
if (item.meta["rare"])
AudioManager.playSe({name: "Applause1", pan: 0, pitch: 100, volume: 90});
});
}
};
Change the settings on the line that starts with AudioManager to have whichever SE you want, with the appropriate parameters. Then give any drops the notetag <rare>
Getting this error message. (Thank you for the very quick response btw!)
(I was testing in the troops tab, which I assume should still work fine for testing this)
(I was testing in the troops tab, which I assume should still work fine for testing this)
Yeah, I was referencing the wrong item type. I've corrected the mistake, @Robro33 told me at the same time 😛
Thanks! Follow up questions if you're ok with me doing that here. Is it possible to have the SE play specifically when that item is listed? The SE plays as battle ends when the EXP etc is showing which could certainly confuse some players since it occurs before the item drops.
(OR if there is a way to color the text of the rare item or signify it with a graphic that would suffice with this plugin... most of my rare/unique items are color coded but the colored text does not show up in the post battle text)
(OR if there is a way to color the text of the rare item or signify it with a graphic that would suffice with this plugin... most of my rare/unique items are color coded but the colored text does not show up in the post battle text)
I'm...not sure what to say to that. You may be able to see I put the code for the sound effect immediately after the code which adds the item's name to the game message.
That code shouldn't even have been run at the time exp is being displayed.
Edit: Can confirm. I'll look into it.
That code shouldn't even have been run at the time exp is being displayed.
Edit: Can confirm. I'll look into it.
I'll try turning off some plugins and seeing if it pops up at the correct timing. Though I don't know how many plugins I have that would affect that part of the game if any.
(Just read your edit, glad you're getting the same result on your end, thanks again)
(Just read your edit, glad you're getting the same result on your end, thanks again)
No, it's not any plugins. It's the way the sequence works...all of the game messages are created and shoved into the message window as a queue before it even finishes printing the first letter.
The only way I can think of to change that would be to take my code back out and use a plugin that evaluates code during a message (I think both Yanfly and Eli have one), use that to play the sound effect when the item message is actually printed.
The only way I can think of to change that would be to take my code back out and use a plugin that evaluates code during a message (I think both Yanfly and Eli have one), use that to play the sound effect when the item message is actually printed.
Ok, I have a couple plugins I've used for SE during messages just not sure where to go to make that happen in the post battle text but I'll look into it. Thanks again! This will work for now until I come up with an ideal solution.
It's right in your database settings, the Terms tab lists all the system messages. I'm not sure what plugin you're using or how it formats its code evaluation.
Ok, thanks for that bit of info...that certainly helped a lot.
I can replicate the result I want now...however I don't know how to make it conditional for specific items. (The color text as well... )
(Calling it a day so won't be responding until tomorrow on this)
I can replicate the result I want now...however I don't know how to make it conditional for specific items. (The color text as well... )
(Calling it a day so won't be responding until tomorrow on this)
Oh, okay, so you're not doing what I suggested and using a plugin to evaluate code in the text.
You can't make it conditional if you're just saying "play this SE."
You can't make it conditional if you're just saying "play this SE."
Erm well... I was just testing if I could get it working at all by forcing it to see if the plugins worked in the terms tab boxes since I didn't realize they would. I really don't know how to do a lot of stuff with code unless I've done it before. I apologize if it looked like I was ignoring your advice in that moment, you've been incredibly helpful so far.
I suppose the issue now is that I don't know what I need to know to even ask the right questions.
Based on what you're saying I need a plugin to evaluate if the %1 text in that box is the correct item?
Would it be strictly looking at the text or would there be some way to mark the items in the database to similar to your previous code to tell it to perform the SE? (I'm also assuming if I figure that out then I could use the same type of thing to tell it to color the text of the %1 item if it matches)
I wasn't trying to get you to apologize for something, just pointing out that wouldn't do what you want.
Kind of? Step 1 is choose a plugin.
For example, if you go with Yanfly's Message Eval Text, this is what we'd do.
You've already deleted any previous code I gave you above, that's not helpful to what you want.
You'll put this plugin in:
Code:
BattleManager.displayDropItems = function() {
var items = this._rewards.items;
if (items.length > 0) {
$gameMessage.newPage();
items.forEach(function(item) {
$gameMessage.add(TextManager.obtainItem.format(item.name));
if (item.meta["rare"])
$gameParty.rareDrop = true;
});
}
};
Then, in your item drop message, put anywhere
Code:
\evalText<<<if ($gameParty.rareDrop) {delete $gameParty.rareDrop; AudioManager.playSe({name: "Applause1", pan: 0, pitch: 100, volume: 90});} '';>>>
Got a Syntax Error.
yanfly's eval text uses 2 <'s and 2>'s on opening and closing. remove the extras
Thanks, it doesn't seem to be doing what was intended however it no longer displays the error message.
try replacing the if (item.meta["rare"]) line with
or
i cant remeber how exactly the meta property is set up and cant check right now
Code:
if (item.meta.contains("rare"))
Code:
if (item.meta.rare)
Hmmm...still nothing. Didn't break though, just didn't do anything.
i dont think anything there looks out of place then...
quick test. right after you beat the last enemy in that troop, check the console for $gameParty.rareDrop before you open any of the item drop message boxes, or paste in "BattleManager.displayDropItems" and confirm that the function is being ran by the game as it is above. the eval text line should be working if it is being ran on those item drop message boxes
quick test. right after you beat the last enemy in that troop, check the console for $gameParty.rareDrop before you open any of the item drop message boxes, or paste in "BattleManager.displayDropItems" and confirm that the function is being ran by the game as it is above. the eval text line should be working if it is being ran on those item drop message boxes
Original thread: https://forums.rpgmakerweb.com/threads/any-way-to-have-a-se-play-if-a-player-receives-a-rare-drop-from-a-battle.172610/