Making a message appear when a specific skill inflicts a status (or fails to do so)

I feel like this would be a very easy thing to figure out, or at least have some sort of clear answer, but I can't seem to find what I'm looking for.

The Goal
I have a certain hit skill that has a chance to inflict a state on an enemy target. I want this skill to display a message in the battle log depending on if it inflicted the state or not. It would display a "success" message if it worked, while it would display a "failure" message if it didn't.

What I have done so far
At first, I searched the forums and failed to really find anything that matched what I was going for, which is kinda weird, but not really something I could do anything about. But, I did gather that I should probably use a common event to pull it off.

I went ahead and created a common event that would check if the target of the skill was afflicted by the state and placed it underneath the effect that would inflict the state in the first place. In my head I thought that this would work perfectly fine, let the skill try and place the effect and allow the event to react accordingly.

Although the skill worked in inflicting the state, it failed to present the "success" message and would always react with the "failure" message. I wasn't entirely sure why this wasn't working and attempted a few different formats of basically the same thing to see if that was the issue.

I made the conditional branch use the drop down (if enemy is affected by state) for the first test, so I tried to replace it with a damage formula type code that I kinda doubted would work: ( if [b.isStateAffected(state)] ). This also didn't work, and I tried to use the troop tab's battle events to write the same event codes for two separate tests that both failed.

Currently...
I'm a bit worried that I can't figure this out myself, nor find anything in the forums that say much about this type of situation. This is definitely a simple thing I know is going to be common for my project if I make more skills that have special messages at all, and I don't want to really scrap it because it just adds more character to the battle system in general. It would be a real shame if I couldn't put things like this in at all.

If anyone can explain how to go about solving this, I will be very grateful. Whether it be a plugin or something I can already do without them, I don't mind much either way, but I would prefer the latter. Also, if anymore information is needed to come to a solution, I'll be happy to elaborate.
Are you using MV (as your profile says) or MZ (where you posted this thread)?
Oh darn, I'm using MV, that's my bad, it's really late for me so I must have blurred the titles together in my mind :v

How would I go about moving it to the right place?
Only mods can move threads. I'll move it for you, since I'm here anyway 🙂 But in case it happens again, you can just report your post and ask for it be moved.

I've moved this thread to MV Support. Thank you.

That makes sense, thanks!
Although the skill worked in inflicting the state, it failed to present the "success" message and would always react with the "failure" message. I wasn't entirely sure why this wasn't working and attempted a few different formats of basically the same thing to see if that was the issue.
Could you post a screencap of what code you used to show the failure message?
Could you post a screencap of what code you used to show the failure message?


Yeah, sorry, I couldn't take a screenshot at first because my program crashed while I was typing up the initial post and I was pretty tired already, but rewriting it isn't hard at all.

(Keep in mind that both of these common events I wrote were placed in the skill effect after it executes the chance to inflict the state)

This was my first attempt, the aforementioned drop down if statement for if an enemy is afflicted with the state. I can see how this probably doesn't work because there isn't a way for the event to tell what enemy it's looking for.

1689461782917.png


Then I tried this instead where I used a damage formula type of script within the if state to check if the target of the skill was afflicted to try and be more accurate. I'm not entirely sure why this didn't work either.

1689461931093.png


For the battle event, I basically copy pasted these same lines for a conditional event, but since it was on a specific troops page I could actually select specific enemies on the field for the drop down version, but it still didn't work in either format.
Are you using plugins that modify battle? Because MV does this by default.

See the bottom of the state entry in your database, it has all those text fields in the Messages section?

If you fill those out, and you don't modify the battle log via plugins, it will display the appropriate message when a battler is affected by the state.

Then I tried this instead where I used a damage formula type of script within the if state to check if the target of the skill was afflicted to try and be more accurate. I'm not entirely sure why this didn't work either.
Because a common event isn't a damage formula. There's no such thing as b just floating around the code. A common event has no simple point of reference to who you targeted with a skill.
Are you using plugins that modify battle? Because MV does this by default.

I am indeed, though the plugins that would change that (probably) are YEP Battle Engine Core, Animated SV Battlers, and SRD Battle Status Customizer, but I already changed the settings for them to display the battle log, though that isn't my issue.
See the bottom of the state entry in your database, it has all those text fields in the Messages section?

If you fill those out, and you don't modify the battle log via plugins, it will display the appropriate message when a battler is affected by the state.

I have already set up the status effect messages, they work perfectly fine. I'm not looking for the state to make messages, since that's what the message tab is for. I'm trying to make the skill itself trigger a message depending on if it worked.

The most accurate example of this I believe would probably be the Pirouette action in Deltarune, where each possible effect it can cause has its own flavor text. This isn't at that type of scope at all, but my main goal is to have a special flavor text that ONLY shows up with this specific skill.

The reason why I want to do this is because I know there will be other skills that can inflict the same state, and I want them to have different flavor texts if they work or not. Here is a small diagram that probably explains this much better than how I did initially:
Different skills same state.png


Though, while typing this and reading your response, I'm starting to get the feeling that a way to pull this off is, instead of make a conditional statement, I would have to multiple states that act as the two branches for different skills. This is kinda hard to explain, so here is another diagram:

Different skills dummy states.png


Hopefully this clears things up, and I wonder if this new idea is what I should be doing. I'll try it, though it seems like it's going to be very confusing if I make too many skills that have unique flavor text. I would also have to prevent both states being inflicted by chance, but that seems like a far easier thing to figure out than this situation.

Because a common event isn't a damage formula. There's no such thing as b just floating around the code. A common event has no simple point of reference to who you targeted with a skill.

Ah, that makes sense. I assumed that it would be able to process it within the skill tab, but oh well.
@SANDstormed I admittedly haven't read through this super thoroughly, but if I'm understanding you correctly based on a quick glance, you want skill-based success/failure messages for state application that differs from the success/failure messages for the states themselves. Is that correct?

If so, you'd probably need one of two things:
  • A plugin that hooks into the state application process of the action code to print your desired message based on whether or not the state was successfully applied by the action.
  • A Yanfly notetag that otherwise does the same thing, though I'm not sure what kind of functionality is available there as I'm not a user.
That's absolutely correct! Glad I was clear enough 🙂

I'll look into your suggestions, though I'm unsure how fruitful my search will be since it seems it's already difficult enough to find a thread about this in general, but fingers crossed.
I know there will be other skills that can inflict the same state, and I want them to have different flavor texts
I understand.

Using Yanfly's Buffs and States Core, give the state the notetag:
Code:
<Custom Apply Effect>
if (this.item().id==42)
    SceneManager._scene._logWindow.addText("This was applied by Skill #1!");
else if (this.item().id==69)
    SceneManager._scene._logWindow.addText("This was applied by Skill #2!");
</Custom Apply Effect>

where the number after id is the ID of the skill applying the state. Edit the text in the quotations to say whatever you like. Add as many else if statements as you like.
I didn't initially have the Buffs and States Core placed into the project, and I'm kinda surprised I didn't see that this could be executed this way. Though, I'm not sure if it's the code you wrote or not, but it seems to just not work at all.

It doesn't mess with anything else in the battle system or anything (on an unintentional standpoint), but it seems to not be process at all. I even checked through the plugin comments to see if the notetag was written in the wrong case, and it looks like this was written correctly, but I don't actually know how to write in javascript so maybe I'm missing something?

EDIT: I forgot to mention that I did indeed change the ID number like what you specified in case that comes to mind first.
It's because the state notetag is a property of the battlers, not the action.

Change it to:
Code:
<Custom Apply Effect>
if (BattleManager._action.item().id==42)
    SceneManager._scene._logWindow.addText("This was applied by Skill #1!");
else if (BattleManager._action.item().id==69)
    SceneManager._scene._logWindow.addText("This was applied by Skill #2!");
</Custom Apply Effect>
It's because the state notetag is a property of the battlers, not the action.

Change it to:
Code:
<Custom Apply Effect>
if (BattleManager._action.item().id==42)
    SceneManager._scene._logWindow.addText("This was applied by Skill #1!");
else if (BattleManager._action.item().id==69)
    SceneManager._scene._logWindow.addText("This was applied by Skill #2!");
</Custom Apply Effect>

Thank you! This works perfectly 🙂

Though, I want to ask what exactly the last code did instead of this. Was it meant to be placed on the skill notes? What I got from your brief explanation is just that the first code wasn't checking the skill used to place the effect, though by adding the specification of the [.item] it was actually able to do that.

I'm asking this because this code solved half of my problem, as although this makes a "success" message work perfectly, would I do something similar in the skill notes to pull off the "failure" message?
So, I've been trying to look around at the other Lunatic Mode parts of the Yanfly plugins I have that could possibly help with displaying a "failure" message, and the closest I think I've gotten is within the YEP Skill Core.

There is a notetag that allows you to manipulate what happens during the certain phases of a skill being executed. By using the <After Eval> notetag, I can potentially write a similar code to place an if statement in the skill's notes in the case that the skill fails to place the state on the target.

I'll try figuring this out, but I'm still not completely sure how to write in javascript so any suggestions in regards to this situation would be well appreciated in the case that my attempts end in failure.
Wow, alright, that was actually exactly what I needed to do! Alright, let me wrap this thread up in a nice bow in case anyone else wants to do this in their projects.

With the Yanfly Buffs and States Core plugin installed, place this code in the notes of any state that needs to display different success messages for different skills in the battle log. Make sure to edit the ID number to match the skill the resulting text applies to. The else if section is not mandatory in the case you just want an extra message apart from what you can place in the state's default messages:

<Custom Apply Effect> if (BattleManager._action.item().id==42) SceneManager._scene._logWindow.addText("This was applied by Skill #1!"); else if (BattleManager._action.item().id==69) SceneManager._scene._logWindow.addText("This was applied by Skill #2!"); </Custom Apply Effect>

With the Yanfly Skill Core plugin installed, place this code in the notes of any skill that needs to display a failure message if it fails to inflict a state. Make sure to edit the ID number to match the state the skill is meant to inflict:

<After Eval> if (!b.isStateAffected(9)) SceneManager._scene._logWindow.addText("This move failed!"); </After Eval>

If you are looking to make more failure and success messages that don't concern states, or have more complex requirements to be triggered, look over the Damage Formula 101 and/or Script Call List to see the commands you can use to pull it off.

Thank you folks for helping me out so much! I hope this can help someone out in the future 🙂

This thread is being closed, due to being solved. If for some reason you would like this thread re-opened, please report this post and leave a message why. Thank you.

Original thread: https://forums.rpgmakerweb.com/threads/making-a-message-appear-when-a-specific-skill-inflicts-a-status-or-fails-to-do-so.159341/