Hello,
I've been using a some RGSSx Script to add a state to an actor and it does that with no doubts, however it doesn't say it applies the state when in battle. My example script line is below.
b.add_state(state_id)I want something that simply adds a state and then displays a Battle log message saying it has done so. I presume it might have to do with order rather than what I use since I'm using this in the custom formula field of a skill, but inside a function that is called in the custom formula field.
Thank you for help in advance,
Shabbur
No, the add_state method isn't where the message is sent. Look through the Scene_Battle class, and maybe Game_Battler / Game_BattlerBase. There will be methods there to apply skill or item effects. SOMEWHERE in there, there will be a command to add a state, and a command to display a message that a state's been added.
You will have to do the same thing.
I just can't look it up for you myself as I'm at work, without my laptop.
You'd have to add the state AND post the message to the log file. Just see what commands are used by the default battle system. You may need to write a little method in Game_BattlerBase to add the state AND post the message, because the damage formula may not be long enough to do all that as well as actually calculate damage.
#-------------------------------------------------------------------------- # * Display Added State #-------------------------------------------------------------------------- def display_added_states(target) target.result.added_state_objects.each do |state| state_msg = target.actor? ? state.message1 : state.message2 target.perform_collapse_effect if state.id == target.death_state_id next if state_msg.empty? replace_text(target.name + state_msg) wait wait_for_effect end endThis code here doesn't have the state listed in target.result.added_state_objects (in which I don't know what that is), I'm guessing its a hash which I know nothing about. Is there a way to insert the state in there (from the custom formula box that calls a function in BattleBase or whatever) so it does list it as done in battle logs?
Do a global search for added_state_objects and see what puts states into it. b.add_state probably isn't calling what it needs to - whatever adds to added_state_objects probably does the adding of the states. It'll be in one of the Game_Battler or Game_BattlerBase classes. You just need to keep following your nose back further until you get to the part where the state is added.
It is not in those classes.
Game_ActionResult is the correct class which holds the states added with the last action executed.
The default add_state method does display the messages automatically. You can check that in the definition of that method. It adds the state to the above mentioned @added_states list for the @result of the action.
But if you call your method after the execution of the display method, it will not display them, obviously.
You need to add your extra states before the display method executes but after the skill's hit calculation.