Extra Stats In Attribute Level Formula

Rinobi

Veteran
Veteran
Joined
Mar 24, 2014
Messages
579
Reaction score
219
First Language
English
Primarily Uses
RMVXA
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.
 

Another Fen

Veteran
Veteran
Joined
Jan 23, 2013
Messages
564
Reaction score
275
First Language
German
Primarily Uses
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*
 
Last edited by a moderator:

Engr. Adiktuzmiko

Chemical Engineer, Game Developer, Using BlinkBoy'
Veteran
Joined
May 15, 2012
Messages
14,682
Reaction score
3,003
First Language
Tagalog
Primarily Uses
RMVXA
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. :)
 

Rinobi

Veteran
Veteran
Joined
Mar 24, 2014
Messages
579
Reaction score
219
First Language
English
Primarily Uses
RMVXA
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
 
Last edited by a moderator:

Another Fen

Veteran
Veteran
Joined
Jan 23, 2013
Messages
564
Reaction score
275
First Language
German
Primarily Uses
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... ^^
 
Last edited by a moderator:

Rinobi

Veteran
Veteran
Joined
Mar 24, 2014
Messages
579
Reaction score
219
First Language
English
Primarily Uses
RMVXA
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?
 

Engr. Adiktuzmiko

Chemical Engineer, Game Developer, Using BlinkBoy'
Veteran
Joined
May 15, 2012
Messages
14,682
Reaction score
3,003
First Language
Tagalog
Primarily Uses
RMVXA
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
 
Last edited by a moderator:

Rinobi

Veteran
Veteran
Joined
Mar 24, 2014
Messages
579
Reaction score
219
First Language
English
Primarily Uses
RMVXA
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...
 

Engr. Adiktuzmiko

Chemical Engineer, Game Developer, Using BlinkBoy'
Veteran
Joined
May 15, 2012
Messages
14,682
Reaction score
3,003
First Language
Tagalog
Primarily Uses
RMVXA
example


$game_actors[1].class would return the class of actor 1
 

Tsukihime

Veteran
Veteran
Joined
Jun 30, 2012
Messages
8,564
Reaction score
3,846
First Language
English
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
 

Rinobi

Veteran
Veteran
Joined
Mar 24, 2014
Messages
579
Reaction score
219
First Language
English
Primarily Uses
RMVXA
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.
 
Last edited by a moderator:

Users Who Are Viewing This Thread (Users: 0, Guests: 1)

Latest Threads

Latest Posts

Latest Profile Posts

People3_5 and People3_8 added!

so hopefully tomorrow i get to go home from the hospital i've been here for 5 days already and it's driving me mad. I miss my family like crazy but at least I get to use my own toiletries and my own clothes. My mom is coming to visit soon i can't wait to see her cause i miss her the most. :kaojoy:
Couple hours of work. Might use in my game as a secret find or something. Not sure. Fancy though no? :D
Holy stink, where have I been? Well, I started my temporary job this week. So less time to spend on game design... :(
Cartoonier cloud cover that better fits the art style, as well as (slightly) improved blending/fading... fading clouds when there are larger patterns is still somewhat abrupt for some reason.

Forum statistics

Threads
105,868
Messages
1,017,085
Members
137,584
Latest member
Faustus2501
Top