Extra Stats In Attribute Level Formula

● ARCHIVED · READ-ONLY
Started by Rinobi 11 posts View original ↗
  1. I'm using a combination of N.A.S.T.Y. Extra Stats and Crystal Engine -  Stat Formulas.

    I want to use the extra stats provided by the first script within the stat formula of the second script.

    (notetag for Extra Stats)

    <xstat>
    :str => '0',
    :con => '0',
    :dex => '0',
    :int => '0',
    :wis => '0',
    :cha => '0',
    <xstat_end>

    (notetag for Stat Formulas)

    <stat> # Sets the stat formulas up.
    stat => formula, # Be sure to put a colon on the stats.
    </stat> # The formula can be any valid ruby expression that returns a number.

    So, if I wanted a Stat Formula to work like this:

    2 * xstat.str * xstat.str / 120 + (2 * xstat.con) * level

    How would I get this to actually work?

    <stat>

    0 => '2 * xstat.str * xstat.str / 120 + (2 * xstat.con) * level',

    </stat>

    I'd just get a NameError saying something about an undefined local variable.
  2. Mind linking the scripts you are using? :)
    Depending on the context the formula is evaluated in, level or xstat might not be defined.

    When does the error appear, what is the exact error message?

    *Will be edited*
  3. When posting a topic about requesting help about a script error:


    1) Post a link to the threads of the scripts


    2) Post the exact error message


    Without it, it would be hard for people to help you. :)
  4. Fair enough.

    N.A.S.T.Y. Extra Stats: http://forums.rpgmakerweb.com/index.php?/topic/998-nasty-extra-stats/

    Crystal Engine - Stat Formulas: http://forums.rpgmakerweb.com/index.php?/topic/15866-crystal-engine-%E2%80%93-stat-formulas/

    Errors:

    If I try this. (Using classes notetags)

    <stat>
    0 => '2 * xstat.ghp * xstat.str / 120 + (2 * xstat.str) * level',
    </stat>


    Then I get this error immediately after selecting the new game button.

    Script'Crystal - Stat Formulas' line 174: NoMethodError occurred.

    undefined method 'str' for nil:NilClass

    If I try this. (Using classes notetags)

    <stat>
    0 => '2 * $game_actors[1].xstat.str * $game_actors[1].xstat.str / 120 + (2 * $game_actors[1].xstat.str) * level',
    </stat>


    Then this happens shortly after selecting new game.

    SystemStackError occurred.

    stack level too deep
  5. I didn't test it, but a problem might be that the mhp parameter is used too early in the initialization process (when healing the battler completely), before xstat is defined.

    You could try to modify the N.A.S.T.Y. script by swapping these two lines (158/159):
    z26_s(actor_id)
    @xstat = Z26::Xstats.new(*([0]*Z26::STATS.size))


    While I don't think it would be an issue here you could repeat that for line 134/135:

    z26_enemy_set(*args)
    @xstat = Z26::Xstats.new(*([0]*Z26::STATS.size))


    I'm not entirely sure about it, but as far as I can read your stat formulas have to fit in one line or they'll get ignored.

    As for the system stack error: I remember Tsukihime came up with this issue recently: http://forums.rpgmakerweb.com/index.php?/topic/32351-bug-finding-actor-initialization/

    The problem is that since the formula is evaluated before the actor is completely initialized, $game_actors will create a new actor over and over again. I'd never thought this issue would come up again that quickly... ^^
  6. Another Fen said:
    I'm not entirely sure about it, but as far as I can read your stat formulas have to fit in one line or they'll get ignored.
    This is actually a pretty huge issue. I won't be able to use this script the way I thought. My actual stat formula would take at least 4 lines to fit within the note box.

    I wanted to test whether or not I could use a script call in place of the formula.

    module StatForm def self.knight ghp = rand(120) bhp = 100 thp = 0 php = 1 level = 1 ((2 * ghp * ghp / 120 + (2 * bhp) + (680 - thp) / 50 + 1 * thp / 4 + 100) * level / 100 + 10) * php endend<stat>

    0 => 'StatForm.knight',

    </stat>

    It works the way it is of course, but it isn't at all what I need.

    I need to trade out those local variables with the stats defined in the NASTY Extra Stats script. I would like it if these stats were only set for the class housing the script call within its notetag.

    To clarify, we can use things like $game_actors[id] to refer to a particular actor, or $game_party.members[id] for party members. How would you do this for classes?

    Like the notetag above, how is it able to identify which class it is affecting based on which note box it is placed within? And is there any way I can replicate this?
  7. You can make the method take the actor or class id as a parameter.


    also, actor_object.class would return the class object while actor_object.class_id would give you the id of it's class
  8. Engr. Adiktuzmiko said:
    You can make the method take the actor or class id as a parameter.

    also, actor_object.class would return the class object while actor_object.class_id would give you the id of it's class
    I have tried, but I honestly do not know how to apply this. Care to give an example? I literally started coding days ago...
  9. example


    $game_actors[1].class would return the class of actor 1
  10. Another Fen said:
    I'm not entirely sure about it, but as far as I can read your stat formulas have to fit in one line or they'll get ignored.
    Yes. For those that aren't sure why

    Code:
    self.note.split(/[\r\n]+/).each do |line| #<---	  if line =~ /<xstat>/i		record = true	  elsif line =~ /<xstat_end>/i		record = false	  end	  if record		temp << line	  end	end
  11. Hmm... I wonder if I can just set those variables to equal 0 and change them later somehow?

    I'm not really sure, but it seems this stat formula isn't working because the xstat I'm trying to use aren't initiated yet?

    The Self Data Suite: http://forums.rpgmakerweb.com/index.php?/topic/1567-the-self-data-suite-self-switches-variables-and-metadata-for-everything/

    I tried something similar using this script to set up self variables for classes and actors, but I'm getting the same problem.

    module StatForm def self.knight ghp = 0 # bhp = 0 # could I change these later? thp = 0 # php = 1 # level = 1 ((2 * ghp * ghp / 120 + (2 * bhp) + (680 - thp) / 50 + 1 * thp / 4 + 100) * level / 100 + 10) * php endendEdit - I could do this: bhp = $game_variables[id], and it works fine.

    Though I'm not sure how well a global variable will do here. I'm gonna try a few things and get back to you guys.