Any way to have a SE play if a player receives a rare drop from a battle?

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
Everything in game seems to lag really hard when I open the console. (To a point where I can't even check that short instance)
EDIT: Ok I got it to not lag, a plugin was causing console lag... however I'm not sure where I should be looking for the $gameParty.rareDrop in the console.
This is assuming the F8 console is the one you're talking about and not something else
yeah, that one. my bad, i kinda just assumed you knew

although
paste in "BattleManager.displayDropItems" and confirm that the function is being ran by the game as it is above
this is mostly irrelevant in hindsight. you had the previous version target the same function and it worked, so im confident that its being ran if you replaced it.
if you run a playtest, get that drop to happen, and then use an event that has
Code:
\evalText<<if ($gameParty.rareDrop) {delete $gameParty.rareDrop; AudioManager.playSe({name: "Applause1", pan: 0, pitch: 100, volume: 90});} '';>>
in a textbox, does the sound play?

Everything in game seems to lag really hard when I open the console. (To a point where I can't even check that short instance)
not sure how to approach that one.
in my experience, thats usually from things repeatedly being printed in the console. The nwjs version might be a factor here? its been a long time since ive used the version MV ships with but i vaguely remember something like that. Generally speaking id say its in your interest to update it, but im not saying it as a fix to that specifically

Edit: your edit loaded in, so thats a better place to start. once youve killed the last enemy, but before you start seeing the item drop messages, open up the console and just type in
Code:
$gameParty.rareDrop
and hit enter. if the plugin worked, the console should say true, if not, it should say undefined
Looking like undefined (Tried it with the 3 different variations of the item.meta if statements)
only thing i can think of is that the message box eval is *also* being ran immediately at the end of the fight instead of when the message box is being drawn somehow. the message boxes are all created at the same time and are played as a queue later. I am not familiar enough with how they work to be certain or to suggest a workaround at the moment
only thing i can think of is that the message box eval is *also* being ran immediately at the end of the fight instead of when the message box is being drawn somehow. the message boxes are all created at the same time and are played as a queue later. I am not familiar enough with how they work to be certain or to suggest a workaround at the moment
That's ok, I appreciate the help!
try replacing the if (item.meta["rare"]) line with
Code:
if (item.meta.contains("rare"))
or
Code:
if (item.meta.rare)
i cant remeber how exactly the meta property is set up and cant check right now
item.meta.rare and item.meta["rare"] should produce identical results, just using the brackets method allows you to address multi-word members - e.g. if the notetag were <rare drop> you'd be able to look at item.meta["rare drop"]

only thing i can think of is that the message box eval is *also* being ran immediately at the end of the fight instead of when the message box is being drawn somehow.
Unfortunately, that's my guess also. You could reverse the lines in the plugin code, but that would just result in the prior situation where the sound effect happens before any messages are displayed.
item.meta.rare and item.meta["rare"] should produce identical results, just using the brackets method allows you to address multi-word members - e.g. if the notetag were <rare drop> you'd be able to look at item.meta["rare drop"]


Unfortunately, that's my guess also. You could reverse the lines in the plugin code, but that would just result in the prior situation where the sound effect happens before any messages are displayed.
Well regardless, thanks again for your help. Perhaps I'll take what I learned here and see if any plugins that affect the victory screen can work with these ideas. I didn't think a fun small quirk like this could be so complicated xD. (Though to be fair I did put off adding in what I thought might be more difficult to implement features)

EDIT:

:blush:So uhhh... the code in the second solution IS reading properly but some absolute idiot (Me) put the JS in the plugins folder but didn't put it into the plugin manager list.

However as Robro33 mentioned it does seem to run everything immediately at the end of the fight. Instead of when the second text box appears.
Perhaps I'll take what I learned here and see if any plugins that affect the victory screen can work with these ideas.
for what its worth, i took your idea and adapted it to the yanfly victory aftermath plugin yesterday because its the one i use.
so like, if you chose to use that one... 😉
for what its worth, i took your idea and adapted it to the yanfly victory aftermath plugin yesterday because its the one i use.
so like, if you chose to use that one... 😉
I'd be down to know how that works, because I noticed that plugin also allows for colored text to show up in the victory screen via reading the database which is another way to indicate rarity that I'm already using for items.
because I noticed that plugin also allows for colored text to show up in the victory screen via reading the database
that one actually isnt victory aftermath. its probably the item core. it provides a notetag to recolor the text for items

Spoiler
Code:
var _extractDrops = Window_VictoryDrop.prototype.extractDrops
Window_VictoryDrop.prototype.extractDrops = function() {
  _extractDrops.call(this);
  if (this._dropItems.some(item => $dataItems[item].meta.rare) ||
      this._dropWeapons.some(item => $dataWeapons[item].meta.rare) ||
      this._dropArmors.some(item => $dataArmors[item].meta.rare))
    AudioManager.playSe({name: "Flash2", pan: 0, pitch: 100, volume: 90})
};
that one actually isnt victory aftermath. its probably the item core. it provides a notetag to recolor the text for items

Spoiler
Code:
var _extractDrops = Window_VictoryDrop.prototype.extractDrops
Window_VictoryDrop.prototype.extractDrops = function() {
  _extractDrops.call(this);
  if (this._dropItems.some(item => $dataItems[item].meta.rare) ||
      this._dropWeapons.some(item => $dataWeapons[item].meta.rare) ||
      this._dropArmors.some(item => $dataArmors[item].meta.rare))
    AudioManager.playSe({name: "Flash2", pan: 0, pitch: 100, volume: 90})
};
Right right, I suppose I meant to say it's compatible with the other plugin since the colored text for items didn't automatically appear in the post battle drop items unless I was using the victoryaftermath. Thank you for this I'll try it out tomorrow and see how it goes!

EDIT: Thank you! Worked like a charm. I never messed with this Yanfly plugin much but I'm sure it has a lot more potential than the default screen anyway so I was bound to use it at some point.

(I consider this solved now if a mod wants to close it thank you @Robro33 and @ATT_Turan for your efforts and patience with me!)

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/