N.A.S.T.Y. Extra Stats not updating in-game

Ninjakillzu

Veteran
Veteran
Joined
Aug 19, 2013
Messages
265
Reaction score
223
First Language
English
Primarily Uses
RMVXA
In my never-ending struggle with this script, I have come across another problem. Formulas that rely on default stats such as atk, agi, etc. in calculations don't update on the status page when gear that increases said stats are equipped (or unequipped). For instance, the formula for an extra stat named Persuasion Skill (which is based on luk) looks like this:
Code:
:pers => '(luk - 10) / 2',
. All characters start with 10 for their default stats, so 10 atk, 10 def, etc. Let's say I have a piece of gear that increases luk by 10. Total luk should be 20. When calculating the outcome using the formula, my persuasion skill should be 5. Unfortunately, when I equip the gear in-game, both my persuasion skill's displayed number and actual number doesn't change. I am using Yanfly's Status page, but I have also tested this with the default status page and the numbers still don't change.
 

Ninjakillzu

Veteran
Veteran
Joined
Aug 19, 2013
Messages
265
Reaction score
223
First Language
English
Primarily Uses
RMVXA
No one has any ideas? I don't know ruby so I can't troubleshoot it myself. Here's the script for reference:
Code:
#===============================================================================
# N.A.S.T.Y. Extra Stats
# Nelderson's Awesome Scripts To You
# By: Nelderson
# Made On: 12/19/2011
# Last Updated : 3/27/2012
#===============================================================================
# Update History:
# - Version 1.1 - Cleaned up some ****, and added enemies xstats for Enemies!
# - Version 1.0 - Initial release, made for the **** of it :p
#===============================================================================
# *Notes:
# - This script can be used to make all sorts of stats that can derive from
# an actor's level, and base stats.
#
# - This thing can be a pain to set up, but once it's done, it can be a very
# powerful way to include new stats into your game!
#
# - Made a quick edit to the status screen to show up to 6 stats!
#
# *Usage
#
# -First is the STATS section. This is an array that holds all the new
# stats that everything else gets info from.
#
# - Next fill out the Default Level formula(Use Example Below as a guide)
# *ANYTHING that an actor has, you can base it off of (Except other XSTATS!)
# (level, hp, mp, atk, spi, agi, maxhp, etc.)
#
# -You can use the ACTOR and ENEMY NOTETAGS to customize
# the formulas for each actor.
#
# Examples:
# Place the following in an actor's notebox(You must make one for each stat):
# <xstat>
# :str => '(level/3.5) + 16',
# :con => '(level/5.6) + 12',
# :dex => '(level/5.25) + 15 + agi',
# :int => '(level/10.5) + 10',
# :wis => '(level/10.5) + 10',
# :cha => '(level/10.5) + 10',
# <xstat_end>
#
# Or you can place this in an actor's/enemy's notebox
# <xstat>
# :str => 15,
# :con => 14,
# :dex => 13,
# :int => 12,
# :wis => 11,
# :cha => 0,
# <xstat_end>
#
# - This script also uses notetags for weapons and armors to increase xstats
# if you want. Just place in a notebox:
#
# <weapon_xstat: STAT x> , where STAT is th name of the new stat
#
# Ex. <weapon_xstat: str 5> , would raise the actor's str +5
#
# *For Scripters
#
# -If you want to access the stats, just use:
# actor.xstat.STAT - Where STAT is the name of the new stat
#
# Ex. $game_actors[1].xstat.str , will return actor 1's str
#
#===============================================================================
# Credits:
# -Nelderson and Zetu
# Original Script was made by Zetu, and I spiced the **** out of it!
#===============================================================================

module Z26

STATS = [:mdcs,:secs,:cps,:demo,:reps,:itd,:pers]

#Default xstat formulas for ACTORS
DEFAULT_LEVEL_FORMULA =
{
:mdcs => '(mdf - 10) / 2',
:secs => '(mat - 10) / 2',
:cps => '(mat - 10) / 2',
:demo => '(mat - 10) / 2',
:reps => '(mdf - 10) / 2',
:itd => '(atk - 10) / 2',
:pers => '(luk - 10) / 2',
}

#Default xstat formulas for ENEMIES
DEFAULT_FOR_ENEMIES =
{
:mdcs => 0,
:secs => 0,
:cps => 0,
:demo => 0,
:reps => 0,
:itd => 0,
:pers => 0,
}

def self.actor_level_formulas(actor_id)
jhh = ""
strin = $data_actors[actor_id].get_start_end_cache
strin.each do |i|
jhh += i
end
return DEFAULT_LEVEL_FORMULA if strin == "" or strin == []
return eval("{#{jhh}}")
end

def self.enemy_stats(enemy_id)
jhh = ""
strin = $data_enemies[enemy_id].get_start_end_cache
strin.each do |i|
jhh += i
end
return DEFAULT_FOR_ENEMIES if strin == "" or strin == []
return eval("{#{jhh}}")
end

#=============================================================================
SYMBOLS = []
for stat in STATS
SYMBOLS.push(stat)
end
Xstats = Struct.new(*SYMBOLS)
end

class Game_Enemy < Game_Battler
attr_accessor :xstat

alias z26_enemy_set initialize unless $@
def initialize(*args)
z26_enemy_set(*args)
@xstat = Z26::Xstats.new(*([0]*Z26::STATS.size))
for stat in Z26::STATS
z26variate_stats(stat)
end
end

def z26variate_stats(stat)
return if Z26.enemy_stats(@enemy_id)[stat].nil?
if Z26.enemy_stats(@enemy_id)[stat].is_a?(String)
set_in = eval(Z26.enemy_stats(@enemy_id)[stat]).to_i
eval("@xstat.#{stat} += #{set_in}")
else
set_in = Z26.enemy_stats(@enemy_id)[stat]
@xstat[stat] += set_in
end
end
end

class Game_Actor < Game_Battler
attr_accessor :xstat

alias z26_s setup unless $@
def setup(actor_id)
z26_s(actor_id)
@xstat = Z26::Xstats.new(*([0]*Z26::STATS.size))
for item in equips.compact
z26variate_equip(item)
end
for stat in Z26::STATS
z26variate_stats(stat, @level)
end
end

alias z26_change_equip change_equip
def change_equip(equip_type, item, test = false)
last_item = equips[equip_type]
z26_change_equip(equip_type, item)
z26variate_equip(item)
z26variate_equip(last_item, false)
end

#=====================#
##EDITED BY NELDERSON##
#=====================#
def z26variate_equip(item, adding = true)
return if item.nil?
for line in item.note.split(/[\r\n]+/).each{ |a|
case a
when /<weapon_xstat:[ ](.*)[ ](\d+)>/i
if Z26::STATS.include?(eval(":" + $1))
if adding
eval("@xstat.#{$1} += #{$2}")
else
eval("@xstat.#{$1} -= #{$2}")
end
end
end
}
end
end

def z26variate_stats(stat, level, adding = true)
return if Z26.actor_level_formulas(@actor_id)[stat].nil?
if Z26.actor_level_formulas(@actor_id)[stat].is_a?(String)
amount = eval(Z26.actor_level_formulas(@actor_id)[stat]).to_i
else
amount = Z26.actor_level_formulas(@actor_id)[stat]
end
if adding
eval("@xstat.#{stat} += #{amount}")
else
eval("@xstat.#{stat} -= #{amount}")
end
end

alias z26level_up level_up unless $@
def level_up
for stat in Z26::STATS
z26variate_stats(stat, @level, false)
end
z26level_up
for stat in Z26::STATS
z26variate_stats(stat, @level)
end
end
end

class Window_Status < Window_Selectable
def draw_block3(y)
draw_parameters(0, y)
draw_xstat_parameters(172, y)
end

def draw_xstat_parameters(x, y)
@actor.xstat.size.times {|i|
draw_actor_xstat_param(@actor, x, y + line_height * i, i) }
end
end

class Window_Base < Window
def draw_actor_xstat_param(actor, x, y, param_id)
id = Z26::STATS[param_id]
change_color(system_color)
draw_text(x, y, 120, line_height, id.capitalize)
change_color(normal_color)
draw_text(x + 120, y, 36, line_height, actor.xstat[id], 2)
end
end

class RPG::BaseItem
def get_start_end_cache
record = false
temp = []
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
return nil if temp == ""
temp.delete_at(0)
temp
end
end
 

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
At first glance the problem is that the script only updates stats upon level up or when you equip an item that adds to an xstat.. It doesnt actually calculate the stats in real time.

Sadly (after reading the whole script code), that is how the script was meant to be used, the formulas if you take a close look says LEVEL_FORMULAS, and that is because it was always meant to be only adjusting the extra stats upon evel up.

What the script does is that when you level up:

-it reduces your xstat by the current formula and values (meaning its effectively 0 afterwards aside from xstat gained from equipments with the xstat notetag)
-then it does the normal level up method (so your stats increase)
-then it calculates the formula and gives you the new xstat

So your pers xstat not updating upon equipping an item that increases luk isnt a bug but is simply the way the script was meant to work.

Ofc, it could be changed to calculate in real time instead of increasing upon level up.
 
Last edited:

Ninjakillzu

Veteran
Veteran
Joined
Aug 19, 2013
Messages
265
Reaction score
223
First Language
English
Primarily Uses
RMVXA
At first glance the problem is that the script only updates stats upon level up or when you equip an item that adds to an xstat.. It doesnt actually calculate the stats in real time.

Sadly (after reading the whole script code), that is how the script was meant to be used, the formulas if you take a close look says LEVEL_FORMULAS, and that is because it was always meant to be only adjusting the extra stats upon evel up.

What the script does is that when you level up:

-it reduces your xstat by the current formula and values (meaning its effectively 0 afterwards aside from xstat gained from equipments with the xstat notetag)
-then it does the normal level up method (so your stats increase)
-then it calculates the formula and gives you the new xstat

So your pers xstat not updating upon equipping an item that increases luk isnt a bug but is simply the way the script was meant to work.

Ofc, it could be changed to calculate in real time instead of increasing upon level up.
It would be amazing if someone changed it for me! Would that be difficult to do? Should ask in the script request forum?
 
Last edited:

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
Hmmm IMHO, its actually easy to do for someone with basic understanding of rgss because it will just be deleting the old stuff that you dont need and putting some very simple function instead.

I could do it for you if only I had access to RM right now (so that I can test the edits first), but that wont be for hours or a day maybe.

You could probably just let this thread and wait for someone else than to make a new thread for the request
 
Last edited:

Ninjakillzu

Veteran
Veteran
Joined
Aug 19, 2013
Messages
265
Reaction score
223
First Language
English
Primarily Uses
RMVXA
I'll let this wait some and see what happens. I'll be grateful if you were able to make the changes!
 

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
BTW where are you using the extra stats, and is it really necessary that they are visible to the player? Because I am thinking that depending on where you are using them, it might be easier for you to just compute for them directly before you use them, that way you wont even need a full script.

Anyway, right now I'm more inclined to just write a new one than edit this one..
 

Ninjakillzu

Veteran
Veteran
Joined
Aug 19, 2013
Messages
265
Reaction score
223
First Language
English
Primarily Uses
RMVXA
BTW where are you using the extra stats, and is it really necessary that they are visible to the player? Because I am thinking that depending on where you are using them, it might be easier for you to just compute for them directly before you use them, that way you wont even need a full script.

Anyway, right now I'm more inclined to just write a new one than edit this one..
I'm using the extra stats to simulate skills similar to how they work in the Star Wars: Knights of the Old Republic games (my game takes heavy inspiration from KOTOR and DnD for it's systems) so yes, they need to be visible to the player. I don't know if you have played them, but they use a modified version of Dnd 3.0 rules. In KOTOR, skills such as Computer Use, Persuade, Security, Repair, etc. gained a bonus from certain main stats. These skills would govern some interactions in the game. I do want to eventually have these skills also available to level up through the V's Level Up Stats script (which is being used for my main stats), but that probably won't be happening since I don't know how to script.
 

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
I see, then the script should also provide a value that you can modify so that you can eventually make it upgradable using V's script, alongside the formulas.
 

Sixth

Veteran
Veteran
Joined
Jul 4, 2014
Messages
2,162
Reaction score
823
First Language
Hungarian
Primarily Uses
RMVXA
I made a script for custom parameters too. It supports changing the parameters with any database items that have features, and you can also change them with script calls if needed, and it has many optional advanced features too, if you know how to code a little.
Although I haven't made a visual display for these new stats in the equipment menu, only for the status menu. I suppose I can make an addon for that too tomorrow.

Anyway, if you want to check it out, the link to that script should be in my signature somewhere.
 

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
Does it support formulas? This guy needs to have the extra stats based on formulas..

PS: somehow I cant see your sig, or any sig for that matter. Is it a feature of the mobile version of the forums?
 

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
I see.. this should do it then, saved me from writing my own (for now at least) xD
 

Ninjakillzu

Veteran
Veteran
Joined
Aug 19, 2013
Messages
265
Reaction score
223
First Language
English
Primarily Uses
RMVXA
I got Sixth's scripts set up, but when I go the the status page on a character, I get an error that says "Script 'Vocab' Line 95: TypeError occurred. Can't convert String into Integer."

EDIT: Nevermind, it's because one of the keys on the status display script and the custom parameter script didn't match.

EDIT 2: I have a DnD script that converts EVA into armor class and HIT into attack bonus with new methods. Am I doing this right?

The new parameters using the new methods:
Code:
    'ab' => {
      :name => "Attack Bonus", :short => "Attack Bonus",
      :default => :attack_bonus,
      :min => 0, :max => 999, :update => [:value],
    },
    'ac' => {
      :name => "Armor Class", :short => "Armor Class",
      :default => :armor_class,
      :min => 0, :max => 999, :update => [:value],
    },
The new methods which I copied and pasted into the "custom parameter methods" section:
Code:
    #Armor class method from Dnd Script
    def armor_class(user, item)
    base = 10 + (item_eva(user, item)*20).to_i
      return base
    end
  
  
    #Attack Bonus from Dnd Script
    def attack_bonus(user, item, override=nil)
    base = (item_hit(user, item)*20).to_i
    base += user.mod(user.hitmod(override)) if item.physical?
    base += user.mod(user.skillmod(override)) if item.magical?
    if user.actor?; base += user.proficiency; end
    return base
    end
 
Last edited:

Sixth

Veteran
Veteran
Joined
Jul 4, 2014
Messages
2,162
Reaction score
823
First Language
Hungarian
Primarily Uses
RMVXA
That won't work. Simply copying a method over won't make it work, I mean, in general, not only in my script.

My script won't connect the used item in battle to the custom parameters, it can't even do that, since that would make it impossible to display visually (in case you want to display them somewhere).
I assume that the item argument in those methods refer to the used item in the battle, but if it's not, you will have to add more details on what that method really does and where is it placed/used originally in that other script you copied it from.

If you want to use arguments other than the mandatory user argument for your parameter methods, you will have to use an array and specify the method and your custom arguments in that array under the :default setting option. Using only a symbol would make the parameter use the specified method, but without any custom arguments (and your methods got custom arguments, so you will get an error.when those parameters are requested during the game). This should be written in that giant documentation I wrote for that script.
 

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
Your armor_class method seem to be copied from the way the battle sytem checks for evasion, which will most probably not work here as Sixth said because item doesnt exist when his script evaluates the formulas.

Actually you have used a bad way to add eva to your armor in that armor_class method of yours.. Instead of using item_eva which requires an item/skill you would normally just use user.eva for that assuming you want to get that value anywhere in the game, not just in battles.

Also iirc, the only reason why item_eva takes an item argument is because it checks if the item/skill being used is magical or physical since if its physical it returns user.eva but if its magical it returns user.mev. So since your goal is to add EVA to the armor value, you should probably just be using user.eva directly

Sure if your armor_class is run inside the battle flow (which I dont know if it does since you said you have a script for that, but if that method is from the script itself then it probably is) then the formula would work, but in the case of the custom parameters it won't.

Your armor_class for the custom parameter should simply be

Code:
def armor_class(user)
  return 10 + (20*user.eva).to_i
end
Its practically the same way for the attack bonus

I suggest that before you copy any method from anywhere you must first understand where/when/how its being called because that will help you understand why it was made that way and know if it will actually work where you will be putting it in.

For example in this very code you copied, you copied a code that is made to be called inside specific parts of the battle flow, while you're trying to copy it into a place which can be called anywhere. Ofc there are ways to make it work (like supplying an item/skill for the argument) but imagine you're calling it to show it on the Status Window, what item/skill will you feed it then?

"I know, lets feed it an arbitrary item."

Okay that will work but since you know on the first place if your arbitrary item is physical or magical, then there's no use doing the item_eva method check at all, its more efficient to just call user.eva or user.mev.

It practically makes no sense to keep the item argument and use item_eva for this kind of usage.

Code-wise, in your DnD system, the armor and attack bonuses only exist in the realm of action processing and are highly affected by the item/skill being used at that very moment, while the custom parameters in this script exists virtually everywhere in the game.

Take note too that the "user" in these two cases are different.. The user on the DnD armor bonus and item_eva is the user of the skill/item while the evasion being returned to you is actually evaluated from "self" which is the target (because ofc its the target that will evade not the user). While the "user" in the custom parameter is actually the "self"
 
Last edited:

Ninjakillzu

Veteran
Veteran
Joined
Aug 19, 2013
Messages
265
Reaction score
223
First Language
English
Primarily Uses
RMVXA
Your armor_class method seem to be copied from the way the battle sytem checks for evasion, which will most probably not work here as Sixth said because item doesnt exist when his script evaluates the formulas.

Actually you have used a bad way to add eva to your armor in that armor_class method of yours.. Instead of using item_eva which requires an item/skill you would normally just use user.eva for that assuming you want to get that value anywhere in the game, not just in battles.

Also iirc, the only reason why item_eva takes an item argument is because it checks if the item/skill being used is magical or physical since if its physical it returns user.eva but if its magical it returns user.mev. So since your goal is to add EVA to the armor value, you should probably just be using user.eva directly

Sure if your armor_class is run inside the battle flow (which I dont know if it does since you said you have a script for that, but if that method is from the script itself then it probably is) then the formula would work, but in the case of the custom parameters it won't.

Your armor_class for the custom parameter should simply be

Code:
def armor_class(user)
  return 10 + (20*user.eva).to_i
end
Its practically the same way for the attack bonus

I suggest that before you copy any method from anywhere you must first understand where/when/how its being called because that will help you understand why it was made that way and know if it will actually work where you will be putting it in.

For example in this very code you copied, you copied a code that is made to be called inside specific parts of the battle flow, while you're trying to copy it into a place which can be called anywhere. Ofc there are ways to make it work (like supplying an item/skill for the argument) but imagine you're calling it to show it on the Status Window, what item/skill will you feed it then?

"I know, lets feed it an arbitrary item."

Okay that will work but since you know on the first place if your arbitrary item is physical or magical, then there's no use doing the item_eva method check at all, its more efficient to just call user.eva or user.mev.

It practically makes no sense to keep the item argument and use item_eva for this kind of usage.

Code-wise, in your DnD system, the armor and attack bonuses only exist in the realm of action processing and are highly affected by the item/skill being used at that very moment, while the custom parameters in this script exists virtually everywhere in the game.

Take note too that the "user" in these two cases are different.. The user on the DnD armor bonus and item_eva is the user of the skill/item while the evasion being returned to you is actually evaluated from "self" which is the target (because ofc its the target that will evade not the user). While the "user" in the custom parameter is actually the "self"
I'm not the one who made the DnD script, but this is a helpful explanation for me. I have an EXTREMELY minimal knowledge of ruby. Basically I know how to install and configure scripts with instructions, but don't know how the code actually makes it work.

As for the code you posted, I tried it out and it works just like I want it to! I tried the same thing with attack bonus:
Code:
    def attack_bonus(user)
      return (20*user.hit).to_i
    end
It seems to work as well.
 

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
Yeah, which is why I tried to explain as clearly as possible, though it turned out to be soooooooo long yet I wasnt sure if it was clear enough hahahahaha

PS: Now come to the script side!!! Wahahahaha
 
Last edited:

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

Latest Threads

Latest Posts

Latest Profile Posts

Our latest feature is an interview with... me?!

People4_2 (Capelet off and on) added!

Just beat the last of us 2 last night and starting jedi: fallen order right now, both use unreal engine & when I say i knew 80% of jedi's buttons right away because they were the same buttons as TLOU2 its ridiculous, even the same narrow hallway crawl and barely-made-it jump they do. Unreal Engine is just big budget RPG Maker the way they make games nearly identical at its core lol.
Can someone recommend some fun story-heavy RPGs to me? Coming up with good gameplay is a nightmare! I was thinking of making some gameplay platforming-based, but that doesn't work well in RPG form*. I also was thinking of removing battles, but that would be too much like OneShot. I don't even know how to make good puzzles!
one bad plugin combo later and one of my followers is moonwalking off the screen on his own... I didn't even more yet on the new map lol.

Forum statistics

Threads
106,035
Messages
1,018,456
Members
137,821
Latest member
Capterson
Top