I'm using Phase Battles system and I would like to have control over who's playing first at the battle start (the player or the ennemy). It must be determine at runtime based on various variable. How could I achieve this, either through the StartBattle event or via C# scripting ?
  • @frednorm2000 in the Phase Battle settings you can choose combatant order based on variables.

    Makinom->Battles->Battle System->Phase (assuming that's what you left the name of your battle system as) -> Phase Order

    There you can do Phase Order -> check the box for Calculate order
    That can use a Formula, which can use variables. That would be for which faction's Phase goes first.

    Then Combatant order you can set to almost anything, including variables to decide which combatant goes first. Same thing, check the box for Calculate order.

  • edited January 10
    Thank you for your reply

    I forgot to mention that our project is using ORK2. But I found similar parameters. However it looks like the formula is applied on each faction, and that the one getting the highest value will begin its phase first. Since my formula is based on a variable, the formula returns the same result for each faction which led the combat to allow phase start for both faction at the same time.

    But it's a good start, I will continue investigating this way. I might find a workaround. In the meantime if you have any advice that would be greatly appreciated
    Post edited by frednorm2000 on
  • edited January 10
    @frednorm2000 sounds like you need more logic in the formula. Without knowing what your variable signifies it's hard to say how to do it. Might have to wait for the expert to answer :)

    If the variable is choosing the faction like a flag, it's already chosen in your script which faction, so like variable == 0 means FactionX goes first, and 1 means FactionY goes first, then you can do something like Variable Fork -> 0 -> Check Faction == FactionX -> Success -> Add 100 to formula. Fail -> Add 1 to formula

    Here is an Ork2 link about it. https://orkframework.com/ork-2/tutorial/howto/phase-battles/

    Says When using the Phase Calculation formula, the value will be calculated for each member of the individual factions that isn’t dead. Either the highest value of a faction’s members or the sum of all faction member values will be used. The faction with the highest value will get the first phase, the faction with the lowest value the last phase.

    If you're only using the variable AS the value of the formula, then yes it will be the same for all factions. You have to somehow use the variable to check against the faction of the combatant being checked. I think it's meant more to be use like add up the Initiative stat of the factions and highest initiative goes first. But it should be able to be used for what you're doing.

    Post edited by GeneralK on
  • edited January 13
    Similar to turn based battles, phase battles calculate a value for each combatant - based on your settings the faction with the highest combined value will have the first phase, and if you don't use e.g. player selection to select which combatant goes first, the one with the highest value will go first in a faction.

    To influence this, e.g. having a specific combatant of a faction having the first turn, you can build this into the formula that calculates the value. E.g. check for a status condition (e.g. being combatant X) or set a bool object variable on the combatant as a flag and check variables in the formula. If the condition is valid, just set the formula to a very high value to ensure the combatant goes first.
    If it's a one time thing or only at specific times, I'd recommend using variables for this, i.e. setting it before battle (or in the battle start event) and removing it after use (e.g. in the formula or a turn start event on your combatants).
    Post edited by gamingislove on
    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!
  • Thank you both

    At first it was not working but then I figure out there was something wrong prior to the formula. But now it is working perfectly fine.

    Thanks again !
Sign In or Register to comment.