formula to check for state before applying states

● ARCHIVED · READ-ONLY
Started by Countyoungblood 8 posts View original ↗
  1. how would you check if the user has a state? id like to do the following

    Code:
    if state 1 apply state 2
    elsif state 2 apply state 3
    elsif state 3 refresh state 3
    else apply state 1.
  2. that might barely fit into the damage formula - that field is long, but not unlimited.
    If that is the longest example you will ever use, then you can check the if syntax in the stickied topic about how to use the damage formula (sorry, it's been too long since I used Ace, don't remember it at the moment).

    However, if you consider longer conditions or checking for more than three or four states or so then I would suggest that you go to tsukihimes blog and use her script about conditional states and placeholder states - that would allow you to use as many conditions as you like.
  3. well actually i can put together most of it i just cant seem to find how id check for the state. would it be a.has_state(0)? i think i came across it recently but i cant find it.
  4. Countyoungblood said:
    how would you check if the user has a state? id like to do the following

    Code:
    if state 1 apply state 2
    elsif state 2 apply state 3
    elsif state 3 refresh state 3
    else apply state 1.

    Code:
    a.state?(1) ? a.add_state(2) : a.state?(2) : repeat many times you want
  5. The general check to see if a state is present and if it is, add another one, is
    if a.state?(x);a.add_state(y); end; damage formula here

    If you didn't want to use Tsukihime's script, you could do the usual alternative of a snippet which you would then call with the custom name in the damage formula. That would enable you to have several checks.

    EDIT
    ninja'd
  6. Thanks to all again for the help.

    ended up this:

    Code:
    x=14;a.state?(14) ? x=15 : a.state?(15) ? x=16 : a.state?(16) ? x=16 : a.add_state(x);a.add_state(x)

    it fits in the formula bar.. though i wish it didn't temporarily have both states between turns and im not quite sure how to fix that..
  7. Put as separate code on its own script slot.
    Code:
    def selection_state(a,b)
      #--------------------------------------------
      # State ID to check => State ID to add
      # Edit here:
      #--------------------------------------------
      states = {
        2 => 3,
        3 => 4,
        4 => 5,
      }
      #--------------------------------------------
      states.keys.each do |state_id|
        if a.state?(state_id)
          a.remove_state(state_id)
          a.add_state(states[state_id])
          return <damage formula here> # <-- Edit here
        end
      end
      # Else
      a.add_state(<whatever you want>) # <-- Also here
      return <damage formula here> # <-- Also here
    end
    Usage, write in damage formula
    Code:
    selection_state(a,b)
  8. am i understanding this corectly? i have 3 states i want to cycle through and i want to refresh the duration of 16 if 16 is already applied..

    i put this :
    Code:
      states = {
        14 => 15,
        15 => 16,
        16 => 16,
      }

    edit: this works beautifully until i run the attack with state 16 on.
    edit2: added a check for state 16 before running the function works perfect

    issue resolved