I’m trying to make it so that when you select certain skills in the (in battle) menu, they automatically activate. While I am able to activate effects upon selecting the skills in question, I do not know what method is called to cast skills in battle. Any advice would be greatly appreciated, my current code is as follows:
Picking a skill in the battle menu doesn’t cast it. on_skill_ok only stores the skill on the actor’s action. Once the turn starts, process_action calls execute_action, which calls use_item in Scene_Battle. use_item is what pays the cost, plays the animation and applies the effects to each target.
use_item reads from @subject.current_action, and @subject is nil while you’re still choosing commands. So I think you’d need to set it to the actor first, then clear the action afterwards so it doesn’t fire a second time when the turn starts.
I’m also wondering if the autoSend calls after select_enemy_selection and select_actor_selection run before a target is chosen, since those only open the target window. What if you moved those into on_enemy_ok and on_actor_ok, after target_index gets set? I haven’t tested this, but maybe something like this:
class Scene_Battle < Scene_Base
def autoSend
item = BattleManager.actor.input.item
return unless item.is_a?(RPG::Skill) && item.canAutoSend
@subject = BattleManager.actor
execute_action
@subject.input.clear
@subject = nil
end
def on_enemy_ok
BattleManager.actor.input.target_index = @enemy_window.enemy.index
@enemy_window.hide
@skill_window.hide
@item_window.hide
autoSend
next_command
end
def on_actor_ok
BattleManager.actor.input.target_index = @actor_window.index
@actor_window.hide
@skill_window.hide
@item_window.hide
autoSend
next_command
end
end
Then in on_skill_ok you’d only keep the autoSend in the first branch. I had autoSend check the actor’s input instead of @skill because on_enemy_ok and on_actor_ok also run for Attack and items, and @skill could still be the last skill someone picked.
Your code did the trick, thanks so much for the help! There’s a few bugs that I’ll have to iron out, but that’s just how coding is
.
