During a phase battle, there are times when I want the player's action to be automatically triggered via a script. i.e. rather than selecting an ability and target via button presses the choices come from another source.

Could somebody point me in the direction of what commands I should be issuing in my scripts to perform such an action? Bonus points for showing me how to end the player's phase on completion :-)

  • Ok, I think I've made some progress, but I'm now having another related problem...

    So I discovered I can use combatant.Actions.CastAbility(AbilityAction) to make a combatant perform a specific action during their phase, and this seems to work just as I need!

    The problem is that when the battle ends, I am now getting a stack overflow, as it seems that it gets stuck in a loop of starting and ending phase turns:
    StackOverflowException: The requested operation caused a stack overflow.
    ORKFramework.PhaseBattle.StartTurn ()
    ORKFramework.PhaseBattle.EventEnded ()
    ORKFramework.PhaseBattle.NextPhase ()
    ORKFramework.PhaseBattle.StartTurn ()
    ORKFramework.PhaseBattle.EventEnded ()...

    The method am calling is triggered from a combatant's phase start event, via the Playmaker actions asset from @tanohmz. Anybody any thoughts on what I should be doing to prevent this?
  • CastAbility isn't the correct function for that.

    You need to get the combatant's ability and call its Use function:
    AbilityShortcut ability = combatant.Abilities.Get(int index);
    ability.Use(Combatant user, List<Combatant> targets, bool useAction);

    index is the ID/index of the ability.
    user is the combatant using the ability.
    targets is a list of combatants that are targeted.
    Set useAction to true if the ability should be animated, i.e. use an actual action in battle.
    Please consider rating/reviewing my products on the Asset Store (hopefully positively), as that helps tremendously with getting found.
    If you're enjoying my products, updates and support, please consider supporting me on patreon.com!
  • Ohhhhh! Makes more sense.

    Just tested and...great! It works correctly and the strange stack overflow is gone. Not only that but you've helped me learn a bit more about your architecture; I was struggling to understand the iShortcut interface so this helps a little.

    Thanks again
Sign In or Register to comment.