Jump to content
Fomar0153

How to make the most of custom formulae. Part #1

Recommended Posts

Okay, I'm almost entirely certain that I'm just stupid, but I can't get this to work for the life of me.

 

 

The formula boxes read "a.MainSpell(a, b, 1~9, 1~5)".

 

 

class Game_Battler < Game_BattlerBase

 

  def MainSpell(a, b, ele, pow)

    x = (15 * (2**pow)) + a.mat * (1.5 ** pow)

    p 'ele = ' + ele

    p 'x = ' + x

    for i in [20+ele, 30+ele, 40+ele, 50+ele, 60+ele, 70+ele, 80+ele]

      p 'i = ' + i

      if (b.state_id == (i))

        b.remove_state(21 .. 90)

        if (i >= 81)

          if (i=90)

            b.add_state(81)

            p '90 command'

          else

            b.add_state(i+1)

            p '<90 command'

          end

        elsif (ele = 9)

          b.add_state(i+1)

          p 'ele = 9 so state is ID ' + (i+1)

        else

          b.add_state(i+11)

          p 'ele != 9 so state is ID ' + (i+11)

        end

        d = i

        while d / 10 != (d/10).to_i

          d -= 1

          p 'd = ' + d

        end

        x *= (d/10).to_i

        p 'x = ' + x

      end

    end

    return (x * (d/10).to_i).to_i

  end

end

 

 

Now what this is SUPPOSED to do is check to see if a state is applied, and increase the damage of the skill if a state is applied that corresponds to the element used. The reason why it checks others (besides just being 20+ele, that is) is because as you continually chain the elements the damage increase will get stronger and stronger.

 

Buuut it doesn't actually return any results and I don't get any messages printed to the console. Am I calling it wrong? Did I name the method incorrectly? Is that not a valid for loop?

 

;_;" (I have already checked the documentation and as far as I can tell this is syntactically correct.)

Share this post


Link to post
Share on other sites

What is x? Nothing in your formula (as that is how you built it) is referenced anywhere within the game battler or battler base. In fact using b for your target will not actually define your target. You actually created a whole new thing. Also I'm not quite sure if it is possible to make your own battler stat in this particular way. Sorry I can't fix your skill but well I'm not exactly a master scripter. Those kinds of people can be found in the script request section.

Share this post


Link to post
Share on other sites

Okay, I'm almost entirely certain that I'm just stupid, but I can't get this to work for the life of me.

 

 

The formula boxes read "a.MainSpell(a, b, 1~9, 1~5)".

 

 

class Game_Battler < Game_BattlerBase

 

  def MainSpell(a, b, ele, pow)

    x = (15 * (2**pow)) + a.mat * (1.5 ** pow)

    p 'ele = ' + ele

    p 'x = ' + x

    for i in [20+ele, 30+ele, 40+ele, 50+ele, 60+ele, 70+ele, 80+ele]

      p 'i = ' + i

      if (b.state_id == (i))

        b.remove_state(21 .. 90)

        if (i >= 81)

          if (i=90)

            b.add_state(81)

            p '90 command'

          else

            b.add_state(i+1)

            p '<90 command'

          end

        elsif (ele = 9)

          b.add_state(i+1)

          p 'ele = 9 so state is ID ' + (i+1)

        else

          b.add_state(i+11)

          p 'ele != 9 so state is ID ' + (i+11)

        end

        d = i

        while d / 10 != (d/10).to_i

          d -= 1

          p 'd = ' + d

        end

        x *= (d/10).to_i

        p 'x = ' + x

      end

    end

    return (x * (d/10).to_i).to_i

  end

end

 

 

Now what this is SUPPOSED to do is check to see if a state is applied, and increase the damage of the skill if a state is applied that corresponds to the element used. The reason why it checks others (besides just being 20+ele, that is) is because as you continually chain the elements the damage increase will get stronger and stronger.

 

Buuut it doesn't actually return any results and I don't get any messages printed to the console. Am I calling it wrong? Did I name the method incorrectly? Is that not a valid for loop?

 

;_;" (I have already checked the documentation and as far as I can tell this is syntactically correct.)

 

i had a quick look and a few things.

 

you want b.state?(state_id) not b.state_id ==

b.remove_state does not take more than 1 argument meaning you have to loop through 21..90 through other means

a few of the if checks only have 1 = not 2

 

and im not sure what you're trying to do with this

 

while d / 10 != (d/10).to_i
 
          d -= 1
 
          p 'd = ' + d
 
        end

Share this post


Link to post
Share on other sites

@Eliwan,

It doesn't print because you can't add text and numbers. Gotta convert all numbers into strings when printing.

    p 'ele = ' + ele.to_s

    p 'x = ' + x.to_s

There's also quite a few other problems in the script.

Share this post


Link to post
Share on other sites

What is x? Nothing in your formula (as that is how you built it) is referenced anywhere within the game battler or battler base. In fact using b for your target will not actually define your target. You actually created a whole new thing. Also I'm not quite sure if it is possible to make your own battler stat in this particular way. Sorry I can't fix your skill but well I'm not exactly a master scripter. Those kinds of people can be found in the script request section.

x is the damage that the skill does, which is why the value is returned (way at the bottom).

 

The formula is referenced in the formula box for the skill... ?_?

 

I had previously gotten something to work with similar syntax (er, using 'b.' in a script and getting the target), which is why I used that syntax. Is there a better way to acquire the user and target of the skill besides passing those values through the formula box and then using them in the expanded script?

 

i had a quick look and a few things.

 

you want b.state?(state_id) not b.state_id ==

b.remove_state does not take more than 1 argument meaning you have to loop through 21..90 through other means

a few of the if checks only have 1 = not 2

Doesn't "b.state?(id)" remove the state? That's what I thought it did, which is why I didn't use it...

 

[Thanks... Sorry for not knowing something so simple. ,_,]

 

"1 = not 2"? I'm sorry, I don't know what that means.

 

and im not sure what you're trying to do with this

 

while d / 10 != (d/10).to_i
 
          d -= 1
 
          p 'd = ' + d
 
        end

 

I want to be sure that d/10 is the proper integer. For example, 29/10 = 2.9, which could be read as a 3. That would be unacceptable as state 29 is used as a first-level, not second-level, state (*1.2 not *1.25).

 

I'm not explaining myself well enough, I'm sure...

 

[also I just realized re-reading this that I did the multiplier such that chaining is actually going to be *2/3/4/5/6/7/8 damage which while good for testing is not the actual formula I want]

 

@Eliwan,

It doesn't print because you can't add text and numbers. Gotta convert all numbers into strings when printing.

    p 'ele = ' + ele.to_s

    p 'x = ' + x.to_s

 

Oh. Thank you.

 

 

I'm stupid, in short. Ambition only goes so far, alas. This is what the method looks like now

 

 

  def MainSpell(a, b, ele, pow)
    x = (15 * (2**pow)) + a.mat * (1.5 ** pow)
    p 'ele = ' + ele.to_s
    p 'x = ' + x.to_s
    yocto = 2
    zetta = 21
    while yocto < 9
      p 'yocto = ' + yocto.to_s
      i = yocto*10+ele
      if (b.state?(i))
        while zetta < 90
          if zetta != i
            b.remove_state(zetta)
          end
          zetta += 1
        end
        if (i >= 81) #if the element level is maximum
          if (i=90) 
            b.add_state(81)
            p '90 command'
          else #i >=81 but !90
            b.add_state(i+1)
            p '<90 command'
          end
        elsif (ele = 10) #if the element is the last one on the list, Poison/Ill
          b.add_state(i+1) #29 -> 30
          p 'ele = 10/Poison so new state is ID ' + (i+1).to_s
        else #If the current element level is not maximum && current element is not poison
          b.add_state(i+11) #21 -> 32 -> 43 -> 54 -> 65 -> 76 -> 87
          p 'ele != 10/Poison so new state is ID ' + (i+11).to_s
        end
        if i >= 21 && i <= 30
          x = x*(1.2)
        end
        if i >= 31 && i <= 40
          x = x*(1.25)
        end
        if i >= 41 && i <= 50
          x = x*(1.3)
        end
        if i >= 51 && i <= 60
          x = x*(1.35)
        end
        if i >= 61 && i <= 70
          x = x*(1.4)
        end
        if i >= 71 && i <= 80
          x = x*(1.45)
        end
        if i >= 81 && i <= 90
          x = x*(1.5)
        end
        p 'x = ' + x.to_s
      end
      yocto += 1
    end
    return x
  end

 

 

Um, what I'm trying to do with this; though, is make a battle system that highly rewards chaining elemental abilities in a certain order. Breaking that order, though, causes the user to jump back down to the lowest level in the chain.

 

The states 21-30 are the first level, 31-40 are second, 41-50 are third... and 81-90 are seventh, the final rank. The states are organized in the order of the elements, so a state that ends in a 1 corresponds to the first element, ending in a 8 corresponds to the 8th element.

 

I'm actually not sure what I need to explain and have run out of time to write now. ><

Share this post


Link to post
Share on other sites

what i meant by a few of the if checks only have 1 = not 2 is

if (i=90) should be if (i==90)

1 = sets i to 90

2 = checks i against 90

 

for your rounding 

integers do not round

2.9 will always be 2

4.9999999 will be 4

Share this post


Link to post
Share on other sites

I have a problem with one of my formulas. The idea behind the attack is it uses the user's speed to deliver a fatal blow if the target is too slow to block it while the attack on enemies that are fast enough get hit from 9 directions at once hence why it's narrowly unblock-able, I've been using custom formulas for about a month now and had very few issues that were easily sorted, but this one has me stumped.

 

This brings me to my formula of $gane_actors[2].agi*2>b.agi;add_state(1);else;a.atk+a.agi*9/b.def+b.agi

 

I've used before this a.agi*2>b.agi;add_state(1);else; a.atk+a.agi*9/b.def+agi and still it crashes the game

 

Even applying if $gane_actors[2].agi*2>b.agi;add_state(1);else;a.atk+a.agi*9/b.def+b.agi

or if a.agi*2>b.agi;add_state(1);else; a.atk+a.agi*9/b.def+agi

 

And I keep getting a syntx error at line 352 of game_battler, I looked at line 352 but I don't fully understand either RUBY or RGSS and so it doesn't help me at all. Can someone please explain to me what I've done wrong?

Share this post


Link to post
Share on other sites

@Azurae,

Okay, let's expand your formula.

a.agi*2>b.agi;add_state(1);else; a.atk+a.agi*9/b.def+agi

#expands to
a.agi * 2 > b.agi
add_state(1)
else
a.atk + a.agi * 9 / b.def + agi

# That's no good
# 1 - Condition doesn't have an if,
# 2 - add_state doesn't have a battler,
# 3 - b.def + agi - agi doesn't have a battler, too
# 4 - there's no end to the if statement
# So it should look something like this:

if a.agi * 2 > b.agi
  b.add_state(1)
else
  (a.atk + a.agi * 9) / (b.def + b.agi)
end

# now let's condense this
if a.agi * 2 > b.agi ; b.add_state(1) ; else ; (a.atk + a.agi * 9) / (b.def + b.agi) ; end

# it works! let's make it 'high-tech'
a.agi * 2 > b.agi ? b.add_state(1) : (a.atk + a.agi * 9) / (b.def + b.agi)

# and it works!

Share this post


Link to post
Share on other sites

Man, I am kind of disappointed. The damage system doesn't handle Infinity (1/0.0) well. It didn't seem to give an error when I tried NaN (0/0.0) though, but I think it just rescues it as zero, even though it should return a proper NaN. :P

Share this post


Link to post
Share on other sites

Awesome, can multiple state resists be checked in one formula?

e.g. if battle immune to x state and x state

and also if battler is immune to x state or x state

Share this post


Link to post
Share on other sites


# Multiple immunities:

b.state_resist?(2) && b.state_resist(3) ? a.atk * 6 - b.def * 2 : a.atk * 4 - b.def * 2

 

# One of immunities:

b.state_resist?(2) || b.state_resist(3) ? a.atk * 6 - b.def * 2 : a.atk * 4 - b.def * 2

Share this post


Link to post
Share on other sites

You guys/gals are so smart.  The custom formula box is super awesome and powerful, just like your brains!

 

I'll probably be asking more questions soon, I'm getting much farther in my database work.

Share this post


Link to post
Share on other sites

How about a skill which does damage equal to an actors current hp and than kills them?

 

I've tried add state death with a.hp but this results in 0 damage as you character has obviously 0 health when the damage calculation takes place

Share this post


Link to post
Share on other sites

This is a great thread. I come here in search of help, i think it's quite simple my request but i just don't know how to do it xD

 

All i want to do is the damage be a variable. Wait, not an actual variable, i mean... a random BETWEEN two values. For example: 2-15 (the skill will damage a minimum of 2 and a maximum of 12, or whatever number is between those two min and max values) what is the command i have to put in order to do that in the custom formula box?

 

Thanks in advance.

Share this post


Link to post
Share on other sites

I'll test it right now, Kurashi. Thanks for the quick answer

 

Edit: it deals no damage o.o

 

Yes, testing in a blank project.

Edited by InvariableZ

Share this post


Link to post
Share on other sites

Yeah rand(2..15) will work... as well as 2+rand(13).  You might want to set the "variance" at zero if you use formulas with random numbers in them.

 

Edit: Not sure how .. will work if you are using other variables instead of numbers. You might need to do rand((value1)..(value2)) or rand(Range.new(value1, value2))

Edited by KilloZapit

Share this post


Link to post
Share on other sites

Funny, ranges should be excepted by rand... maybe that's only in higher versions of ruby.

 

Anyway, I think this little script might be helpful to some people when testing formulas, maybe:

 

class RPG::UsableItem::Damage

  def eval(a, b, v)
    [Kernel.eval(@formula), 0].max * sign
  end

end
Just makes formulas give actual errors instead of always returning zero. It might help you figure out why a formula isn't working.

Share this post


Link to post
Share on other sites

Aww shucks... *sprinkles fairy dust on you* Not sure how good it will work with all scripts. I can't really think of any scripts that might interfere with it (besides one I made in my skill system demo) though.

Edited by KilloZapit

Share this post


Link to post
Share on other sites

So you want a kamikazi sill? That's easy

c=a.HP; a.add_state(1); c

Cool got it working just a note for any views it's case sensitive so it should be hp and not HP

Share this post


Link to post
Share on other sites

Your content will need to be approved by a moderator

Guest
You are commenting as a guest. If you have an account, please sign in.
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.


  • Recently Browsing   0 members

    No registered users viewing this page.

×