N.A.S.T.Y Extra Stats

Nelderson

Coding *****
Veteran
Joined
Mar 17, 2012
Messages
164
Reaction score
164
First Language
English
Primarily Uses
RMMV
N.A.S.T.Y. Extra Stats(Version 1.1)




By: Nelderson




Updated: 3/27/12


Introduction

This script gives actors and enemies extra stats that you can use anywhere in your game!

Features

- New Stats for your game.

- Define a formula for each new stat you make.

- Use these new stats in skill formulas, or whatever else you feel like.

- See your extra stats on the Status screen (Up to 6).

- Equipment can increase these stats with a notetag.

How to Use

The instructions on the script itself has everything you need!

Demo

I'll make one if you guys want one!

Script

#===============================================================================
# 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 = [:str,:con,:dex,:int,:wis,:cha]

#Default xstat formulas for ACTORS
DEFAULT_LEVEL_FORMULA =
{
:str => '(level/3.5) + 16 + atk',
: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',
}

#Default xstat formulas for ENEMIES
DEFAULT_FOR_ENEMIES =
{
:str => 0,
:con => 0,
:dex => 0,
:int => 0,
:wis => 0,
:cha => 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_equipments(344, y)#288
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

Code:
FAQ

Q: What does N.A.S.T.Y. stand for?

A: Nelderson's Awesome Scripts to You!

Credit and Thanks

- Nelderson

- Zetu, for her original script, and showing me the value of Structs <3
 
Last edited by a moderator:

kwanzaabot

Veteran
Veteran
Joined
Apr 6, 2012
Messages
62
Reaction score
13
First Language
English
Primarily Uses
Sounds interesting, although would it be possible for you to post a screenshot? I wouldn't mind seeing what it'd look like in the menu.
 

Bird Eater

Boredom is just another thing you want to avoid
Veteran
Joined
Mar 22, 2012
Messages
272
Reaction score
27
First Language
Dutch
Primarily Uses
Great script, liking it a lot ^^!

Is there a way to check the base xstat of an actor?

@actor.xstat.str is really great, but it'd be awesome if I could find the base xstat parameter for the level the actor is currently at...
 

Quigon

electric boogaloo
Veteran
Joined
Mar 17, 2012
Messages
1,982
Reaction score
951
First Language
English
Primarily Uses
N/A
Apologies for reviving this, but is there any way to increase an actor's extra stat by means of an item? I tried using the equipment tag in the item notebox but that didn't work. If there's some script call I can link to a common event then that would be great.
 

Zetu

Level 99 Stabomancer
Veteran
Joined
Apr 28, 2012
Messages
247
Reaction score
99
First Language
English
Primarily Uses
N/A
I don't think so, based on how I remember my original... not sure how much editing Neld did. This was while I was still nubby at scripting, so I may remake this to allow such features.
 

Quigon

electric boogaloo
Veteran
Joined
Mar 17, 2012
Messages
1,982
Reaction score
951
First Language
English
Primarily Uses
N/A
That'd be pretty cool if you ever have the time :)
 

KDLMaj

Villager
Member
Joined
Mar 6, 2013
Messages
18
Reaction score
1
First Language
English
Primarily Uses
Yeah, I'm currently trying to create a game system based on these xstats, and I'm no code ninja, so I've spent days pouring over threads and new codes to try to find some way to incorporate the xstats into my battle system.


Basically, I need abilities that can change the xstats of targets and users during battle, but I can't for the life of me figure out how to get it to work. I could do it with a common event, but I have no idea how to get a common event script to pull up the ID of the caster or target. The one way I've managed to do this is to create a script that checks the base xstat of that enemy plus the stat increase of the spell, but it doesn't store the increase, and so damage can't be cumulative. I did try to create a variable that was set to the original xstat of the target and that could be continually added to, but the battle script apparently didn't like it.


Am I trying to do something that just isn't feasible with the current setup?
 

pyrose17

Warper
Member
Joined
Mar 24, 2013
Messages
2
Reaction score
0
First Language
English
Primarily Uses
Hi! I'm not very good with scripting or programming of any kind, so I apologize if this is a stupid question. Is it possible to use a variable to define one of these statistics? And, if so, how could I make that work? That way I could show a variable directly related to an actor, and also be able to easily control a statistic. But I don't know if that's possible or not. Either way, I'd appreciate any help you could give me.
 

Andar

Veteran
Veteran
Joined
Mar 5, 2013
Messages
29,469
Reaction score
6,852
First Language
German
Primarily Uses
RMMV
Hi! I'm not very good with scripting or programming of any kind, so I apologize if this is a stupid question. Is it possible to use a variable to define one of these statistics? And, if so, how could I make that work? That way I could show a variable directly related to an actor, and also be able to easily control a statistic. But I don't know if that's possible or not. Either way, I'd appreciate any help you could give me.
That description does not make it clear what you want to achieve.

You can do a lot in RM, and especially define variables in a lot of ways.

Do you want to make a switch that makes a stat invisible on status screen if it's turned off? You can use and access the general variables from script, so this would just require some careful planning on what to do in which part of the game and where to use the events which controls the variable.

Do you want to make the stat based on a variable value? also possible with careful scripting (you'll have to make sure that the variable can't break the stat in its ingame function, but those functions are defined by you anyway)
 

ugokeka

Warper
Member
Joined
Apr 5, 2013
Messages
1
Reaction score
1
First Language
Francais
Primarily Uses
Nelderson, My question is, I have created more than 6 xstats because I would like characters to have only 4 extra but have different stats then others. Like a warrior with (str, end, vit, sze), rogue with (dex, spd, aim, cun) and a mage with (int, wis, con, arc). Maybe there could be a way to notetag to only show 4 or remove all extra undesirerable stats?

Thanks,

Ugo
 

pyrose17

Warper
Member
Joined
Mar 24, 2013
Messages
2
Reaction score
0
First Language
English
Primarily Uses
That description does not make it clear what you want to achieve.

You can do a lot in RM, and especially define variables in a lot of ways.

Do you want to make a switch that makes a stat invisible on status screen if it's turned off? You can use and access the general variables from script, so this would just require some careful planning on what to do in which part of the game and where to use the events which controls the variable.

Do you want to make the stat based on a variable value? also possible with careful scripting (you'll have to make sure that the variable can't break the stat in its ingame function, but those functions are defined by you anyway)
Thanks for the reply, and sorry it's taken me forever to get back to this.

The second one. Essentially, what I want is to be able to keep track of certain character-related statistics (the number of times the player has spoken to them, for instance, or a numeric value to show their relationship, or a "number of houses owned" sort of thing, something along those lines) and have it show up in that character's status menu, using variables so I can edit these statistics (both in game and while debugging) pretty much any time I need to. I tried it a couple of times on my own, using what little scripting language I know, and it either crashed on entering the status menu, or it just showed zero regardless of the variable's value.

So how would I go about phrasing that in Ruby? I've tried it about a dozen different ways.

And thanks for the help! I appreciate it.
 

Probotector 200X

Probotect and Serve
Veteran
Joined
Mar 14, 2012
Messages
890
Reaction score
147
Primarily Uses
This looks awesome! I love this kind of thing, always look for it but never able to find it, really...

I have some questions though...Actors and enemies can have values (and growth formulas) for these stats, and equipment can affect it too. You can put 'em in formulas too! But what about traits/features? How about a state that changes DEX to 130%? Also, buffs and debuffs for other stats? Some way to assign icon(s) for these new stats (buffs and debuffs act like states, using default icons). How about Grow Effects that permanently boost an extra stat? I'd love to see these new stats do everything normal stats can do!
 

exodus1386

Villager
Member
Joined
Jul 18, 2013
Messages
20
Reaction score
0
Primarily Uses
nvm figured out my issue.
 
Last edited by a moderator:

rahlevi

Villager
Member
Joined
Oct 30, 2013
Messages
22
Reaction score
1
First Language
English
Primarily Uses
Does anyone know if it's possible to use this script to restructure the complete stat system? I want the stat structure of str, dex, con, int, wis, cha since my game is based off 3.5e dnd but the old stats are still showing under status in the game. I want to make the default stats of MaxHP etc completely disappear and not even be needed anymore. Basically when Con is increased, the characters HP increases and so on. Also to maybe figure out a way to make this work with TDS stat distribution?
 

ArkhamVI

Villager
Member
Joined
Dec 13, 2013
Messages
18
Reaction score
2
First Language
English
Primarily Uses
RMMV
this is my biggest question: is there a way to make this compatible with Yanfly's 'Ace Status Menu' script?
 

Nesokas

Villager
Member
Joined
Nov 30, 2013
Messages
19
Reaction score
0
Primarily Uses
Hello,

Great script by the way. I only have one problem... the force_change_equip function is not defined in your script. I wanted to get this effect:

But I'm getting this instead:

I'm changing the draw_new_param method to look like this:

def draw_new_param(x, y, param_id) if param_id == 6 new_value = @temp_luck change_color(param_change_color(new_value - @actor.xstat.str)) else new_value = @temp_actor.param(param_id) change_color(param_change_color(new_value - @actor.param(param_id))) end draw_text(x, y, 32, line_height, new_value, 2) end
if I change on the update_help function of Window_EquipItem from force_change_equip to change_equip I get what I want but it leads to incorrect behavior later on:

class Window_EquipItem < Window_ItemList def update_help super if @actor && @status_window temp_actor = Marshal.load(Marshal.dump(@actor)) temp_actor.force_change_equip(@slot_id, item) @status_window.set_temp_actor(temp_actor) @status_window.set_temp_luck(temp_actor.xstat.str) end end end
Can anyone tell me what can I change to get the correct behavior?
 
Last edited by a moderator:

Nesokas

Villager
Member
Joined
Nov 30, 2013
Messages
19
Reaction score
0
Primarily Uses
Nevermind, I got it.

Just add this to the script inside the Game_Actor class:

alias z26_force_change_equip force_change_equipdef force_change_equip(equip_type, item, test = false) last_item = equips[equip_type] z26_force_change_equip(equip_type, item) z26variate_equip(item) z26variate_equip(last_item, false)end
And you can simply change the draw_new_param method to look like this:

Code:
def draw_new_param(x, y, param_id)  if param_id == 6    new_value = @temp_actor.xstat.str    change_color(param_change_color(new_value - @actor.xstat.str))  else    new_value = @temp_actor.param(param_id)    change_color(param_change_color(new_value - @actor.param(param_id)))  end      draw_text(x, y, 32, line_height, new_value, 2)end
 
Last edited by a moderator:

Zoltor

Veteran
Veteran
Joined
Jan 18, 2014
Messages
1,550
Reaction score
210
First Language
English
Primarily Uses
This could definitely be cool in certain games, I don't think I'll need/use this for the current game I'm making, but this is awesome.
 

rpgwizard1984

Villager
Member
Joined
Aug 29, 2014
Messages
11
Reaction score
0
First Language
English
Primarily Uses
Hi I used this script to create base parameters like baseAtk etc....  is there anyway I can set it so the parameter growth curve for lets say attack increases this new parameter instead at level up.
 

AzraeLXIX

Villager
Member
Joined
Jun 18, 2015
Messages
9
Reaction score
1
Primarily Uses
Sorry for my mad necro skills, but I have no idea how to add to stats using a consumable item (xstat growth consumable items), if anyone could modify the original script to include this, I would be very grateful :D

Edit: for clarification on what I'm asking for. There is nothing wrong with the script, I would just like a little more scripting to allow the usage of consumable items (such as a growth potion or something of the like) to permanently increase the xstat that was created. Similar to equipping weapons or armor and having that increase the specified xstat, except instead of equipping, using items and having it increase the xstat permanently.
 
Last edited by a moderator:

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

Latest Threads

Latest Posts

Latest Profile Posts

It's weird I actually have MORE work to do when stuck at home than before.
The No Travel Game Jam is here! Jump in to make a game in the month of April that takes place all in one town!


Decided to take a stab at video editing.... Even made a clickbait screen. I'm so proud of my sellout ways. :LZSexcite:

Forum statistics

Threads
95,469
Messages
929,369
Members
125,707
Latest member
Mimus
Top