Jump to content
Nelderson

N.A.S.T.Y. Extra Stats

Recommended Posts

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 shit, and added enemies xstats for Enemies!
# - Version 1.0  - Initial release, made for the shit of it 
#===============================================================================
# *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 shit 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

 

 

 

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

Edited by Nelderson

Share this post


Link to post
Share on other sites

Meh, write me more codez. I'm too cheap to pay for Ace at its current price, and too lazy to bother with the "workarounds". Lol, jk. Life has a strange way of playing the thief. With rolls of 20 90% of the time. >.<

Share this post


Link to post
Share on other sites

This sounds super duper awesome! I've always wanted a script to make extra stats. I know I'll have a use for this at some point...

 

Just one question, how would you go about using these stats for anything? What determines what they do? Can they be used in skill formulas? How?

 

Sorry for my ignorance.

Share this post


Link to post
Share on other sites

Of course they can be used in skill formulas! Lets say you wanted to make the damage based off "str", a new stat that you created:

 

When you do the formula, it would be a.xstats.str (Remember, that in the skill formulas a = attacker, b = defender)

 

And I can probably make a quick thing for enemies as well later on today if you want :D

Edited by Nelderson

Share this post


Link to post
Share on other sites

excuse me, can i ask something? when i try make ten extra stats and i used the tenth stats in my skill formula, when the skill hit the enemy it become nullified. I mean every skill that use the tenth stats in their formula cannot damage the enemy, maybe anyone can help?

Share this post


Link to post
Share on other sites

Well first off I wanted to use actor base stats which grow by level as more of a modifier and use the extra stats idea to create gear-specific stats of attack defense magic attack resist, so that these stats exist but are augmented primarily by gear instead of level.

(AtkPwr, Defnse, MagPwr, Resist)

 

I added appropriate tags to the weapons and armor i was testing (so i believe)

 

Axe with: <weapon_xstat: AtkPwr 10>

 

and tagged the enemy i was testing against with

 

 

<xstat>

:AtkPwr => 10,

:Defnse => 5,

:MagPwr => 8,

:Resist => 3,

<xstat_end>

 

In addition to setting base stats.

 

The basic attack formula was

 

(a.AtkPwr) - (a.AtkPwr*(b.Defnse/100)

 

Was trying to make it so that Defense acts as a direct percentile reduction in damage. If i was able to make that work I wanted to add in a tag for making the actual def stat (renamed to vit) act as an additional reduction but I didn't get that far. When i tested this similar formula out using the default attack / defense values instead of added stats it worked just fine.

 

All i'm getting is allot of 0's though.

Edited by Mascarpone

Share this post


Link to post
Share on other sites

The problem is your formula....it should be like this:

 

(a.xstat.AtkPwr) - (a.xstat.AtkPwr*(b.Defnse/100)

 

 

Any stat you custom make, should have xstat.STAT, where STAT is you custom stat. Tell me if this works for you :)

Share this post


Link to post
Share on other sites

ah. I must have missed the note about needing that tag in there.

 

actually upon further inspection i don't see anything in the notes that say you need to tag new stats with .xstat in formulas. This might be obvious to some but I'm not very familiar with how RGSS works and it didn't occur to me that it would be necessary.

 

Thank you for clearing that up though~

Edited by Mascarpone

Share this post


Link to post
Share on other sites

#  *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 shit out of it!
#===============================================================================

 

It's in there, near the bottom of the instructions :P

 

I might need to write better documentation though....give me some time :)

Share this post


Link to post
Share on other sites

Nelderson, is it possible to create a stat that governs player movement in battle? In the battle system I'm trying to put together for my project, I would like to have a stat (like Move) that determines how far an enemy or player can move across the screen. I don't even know if this is possible to do. I am also using Victor's Animated Battles.

 

For reference, the inspiration from my battle system comes from the Lunar series, of course with my own modifications and tweaks to it.

Share this post


Link to post
Share on other sites

Very nice script.

 

By any chance, is there a way to make the default stats' value depends on extra stat value?

 

Like every str+1 will increase the char's atk +1.

 

I couldn't find how to do that in your instruction.

Share this post


Link to post
Share on other sites

I didn't find a use for this before, but earlier today, i was thinking

"Hmm, my summons should have different stats from the actors..."

And then i saw this!

Just wondering, is there a way to rename stats?

do you just change, let's say

:str to :pow

?

Thanks

Share this post


Link to post
Share on other sites

@Lyson - This script is just for extra stats....you still need to know how to use them for various things like your "movement". It's easy for someone to modify an existing script for use with xstats....it just requires the scripting knowledge!

 

@Ghee - You would need to make a change to the battler class. Specifically the atk method, for the example you provided. Remember, this script just gives the actors extra stats. Doing other things requires you to understand how to use the stats in other parts of the game!

 

@Anton - Absolutely! Try it out :D

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

  • Recently Browsing   0 members

    No registered users viewing this page.

×