Hey guys,
332211, I have been using your attribute script for a bit now, and I enjoyed it up to a point where it has now completely stopped any progress I can do in testing my game.
I found on this forum that you mentioned to someone to change a few values in their system so that they would be able to customize the amount of points they recieved per level instead of being handed their level in points...
When I made that change, I am not faced with this error EVERY time I level, or every time I start my troop battle test:
Script'Attribute System 2.2.3'line 157: NoMethodError occured.
undefined method '(box)' for nil:Class
When I delete your script and I mean (everything having to do with your script) from my game.... I still get that same error (that baffles me the most)
I replaced all the changed code that I made, to the original (that came with the demo)... , with your original code. And I am still getting the error. And I completely removed and re-added all the contents of the code as it was originally unaltered. Still the same error.
Here is the code that I have right now that started the entire problem when I made the one change to the points per level up.
CODE
#======================================================================
=========
# Version 2.2.3
# Author: 332211 / uresk
# Date: 5th April 2009
#===============================================================================
# Start Configuration
#===============================================================================
module Attibute_Def
ATTRIBUTES = [
# Attribute 0
[
# Name: "Name"
"2-Wpn Fighting",
# Bonus Values: [HP, MP, ATK, DEF, SPI, AGI],
[0,0,1,1,0,1], # each new level grants more bonus * level
# Eg: 6HP - Level 1: +6; Level 2: +12; Level 3: +18
# Damage Boost: [element id(s)],
[1], # base damage is multiplied by attribute level/12
# Teaches skills: {attribute level => skill id}
nil,
# May activate skill skill id (none = nil)
51, # Chance of activating the skill = 2 * attribute level
# Description: " text here "
"Two-Weapon Fighting: Displays a small combat bonus to
a harvester that is using two weapons. May grant a
cross strike while attacking.",
# Satus Protection: [status id(s)],
nil, # Decreases the probability of a certain status
# Icon Index: being inflicted by twice the attribute level
4,
# Max Level:
4
],
# Attribute 1
[
# Name: "Name"
"Craft Prof.",
# Bonus Values: [HP, MP, ATK, DEF, SPI, AGI],
[0,0,1,1,1,1],
# Damage Boost: [element id(s)],
nil,
# Teaches skills: {attribute level => skill id}
{6 => 6},
# May activate skill skill id (none = nil)
nil,
# Description (line 1):
"Crafting Proficiency: Trains your mind and body to be better suited
for crafting materials.",
# Satus Protection: [status id(s)],
nil, # Decreases the probability of a certain status
# Icon Index: being inflicted by twice the attribute level
4,
# Max Level:
10,
],
# Attribute 2
[
# Name: "Name"
"Hunters Cunning",
# Bonus Values: [HP, MP, ATK, DEF, SPI, AGI],
[2,1,1,0,1,2],
# Damage Boost: [element id(s)],
nil,
# Teaches skills: {attribute level => skill id}
{5 => 11},
# May activate skill skill id (none = nil)
nil,
# Description (line 1):
"Hunters Cunning: Focuses on developing the combat prowse of the hunter.",
# Icon Index:
4,
# Max Level:
8
]
]
Class_Based_Attr = true
# true : actor's attributes depend on their class
# false: actor's attributes depend on their Id
Actor_attributes =
{
# Actor/Class Id 1
1 => {
# level => [attribite ids...]
2 => [0],
5 => [2],
8 => [1]
}
# Actor/Class Id 2
# Actor/Class Id 3
}
# Upgrade Cost Formula
def cost?(level)
cost = (level * level + level)/2
return cost
end
end
imported = {} if imported.nil?
imported["Attributes"] = true
#==============================================================================
# ** Game_Actor
#------------------------------------------------------------------------------
# This class handles actors. It's used within the Game_Actors class
# ($game_actors) and referenced by the Game_Party class ($game_party).
#==============================================================================
class Game_Actor < Game_Battler
include Attibute_Def
#--------------------------------------------------------------------------
# * Public Instance Variables
#--------------------------------------------------------------------------
attr_accessor :attributes # attributes
attr_accessor :attr_levels # attribute levels
attr_accessor :attr_points # points
#--------------------------------------------------------------------------
# * Setup
# actor_id : actor ID
#--------------------------------------------------------------------------
alias attributes_setup setup
def setup(actor_id)
attributes_setup(actor_id)
@attributes = []
@attr_levels = []
@attr_points = 0
Class_Based_Attr ? based_on = @class_id : based_on = actor_id
for a in 1..@level
@attr_points += a
if !Actor_attributes[based_on].nil? and !Actor_attributes[based_on][a].nil?
for attr_i in Actor_attributes[based_on][a]
start_attributes(attr_i)
end
end
end
end
#--------------------------------------------------------------------------
# * Attributes
# attribute : attribute name
# new_level : attribute level
#--------------------------------------------------------------------------
def start_attributes(attribute)
unless self.attributes.include?(attribute)
attr = ATTRIBUTES[attribute]
attr_bonus = attr[1]
if !attr_bonus.nil?
@maxhp_plus += attr_bonus[0]
@maxmp_plus += attr_bonus[1]
@atk_plus += attr_bonus[2]
@def_plus += attr_bonus[3]
@spi_plus += attr_bonus[4]
@agi_plus += attr_bonus[5]
end
attr_skills = attr[3][0]
learn_skill(attr_skills) if !attr_skills.nil?
@attributes.push(attribute)
@attributes.sort!
@attr_levels[attribute] = 0
end
end
def remove_attribute(attribute_id)
while @attr_levels[attribute_id] > 0
attribute_down(attribute_id)
end
end
def attribute_up(attribute_id)
@attr_levels[attribute_id] += 1
l = @attr_levels[attribute_id]
attr = ATTRIBUTES[attribute_id]
attr_bonus = attr[1]
if !attr_bonus.nil?
@maxhp_plus += attr_bonus[0] * l
@maxmp_plus += attr_bonus[1] * l
@atk_plus += attr_bonus[2] * l
@def_plus += attr_bonus[3] * l
@spi_plus += attr_bonus[4] * l
@agi_plus += attr_bonus[5] * l
end
attr_skills = attr[3][@attr_levels[attribute_id]]
learn_skill(attr_skills) if !attr_skills.nil?
end
def attribute_down(attribute_id)
l = @attr_levels[attribute_id]
@attr_levels[attribute_id] -= 1
attr = ATTRIBUTES[attribute_id]
attr_bonus = attr[1]
if !attr_bonus.nil?
@maxhp_plus -= attr_bonus[0] * l
@maxmp_plus -= attr_bonus[1] * l
@atk_plus -= attr_bonus[2] * l
@def_plus -= attr_bonus[3] * l
@spi_plus -= attr_bonus[4] * l
@agi_plus -= attr_bonus[5] * l
end
attr_skills = attr[3][@attr_levels[attribute_id]+1]
forget_skill(attr_skills) if !attr_skills.nil?
if l == 0
@attributes.delete(attribute_id)
@attributes.sort!
end
end
#--------------------------------------------------------------------------
# * Level Up
#--------------------------------------------------------------------------
alias attr_level_up level_up
def level_up
attr_level_up
@attr_points += 2
Class_Based_Attr ? based_on = @class_id : based_on = @actor_id
if !Actor_attributes[based_on].nil? and !Actor_attributes[based_on][@level].nil?
for attr_i in Actor_attributes[based_on][@level]
start_attributes(attr_i)
end
end
end
#--------------------------------------------------------------------------
# * Level Down
#--------------------------------------------------------------------------
alias attr_level_down level_down
def level_down
attr_level_down
Class_Based_Attr ? based_on = @class_id : based_on = @actor_id
if !Actor_attributes[based_on].nil? and !Actor_attributes[based_on][@level].nil?
for attr_i in Actor_attributes[based_on][@level]
remove_attribute(attr_i)
end
end
@attr_points -= @level
@attr_points = 0 if @attr_points < 0
end
#--------------------------------------------------------------------------
# * Upgrade Attribute
#--------------------------------------------------------------------------
def upgrade_attr(attribute_index)
level = attr_levels[attribute_index]
cost = cost?(level)
self.attr_points -= cost
attribute_up(attribute_index)
end
#--------------------------------------------------------------------------
# * Get Added State Success Rate
# state_id : state ID
#--------------------------------------------------------------------------
def state_probability(state_id)
if $data_states[state_id].nonresistance
return 100
else
rank = self.class.state_ranks[state_id]
probability = [0,100,80,60,40,20,0][rank]
for attr_id in @attributes
next if ATTRIBUTES[attr_id][6].nil?
if ATTRIBUTES[attr_id][6].include?(state_id)
probability -= @attr_levels[attr_id] * 2
end
end
end
return probability
end
end
#==============================================================================
# ** Game_Battler
#------------------------------------------------------------------------------
# This class deals with battlers. It's used as a superclass of the Game_Actor
# and Game_Enemy classes.
#==============================================================================
class Game_Battler
include Attibute_Def
#--------------------------------------------------------------------------
# * Calculation of Damage Caused by Skills or Items
# user : User of skill or item
# obj : Skill or item (for normal attacks, this is nil)
# The results are substituted for @hp_damage or @mp_damage.
#--------------------------------------------------------------------------
alias attr_make_obj_damage_value make_obj_damage_value
def make_obj_damage_value(user, obj)
if user.is_a?(Game_Actor) and !user.attributes.nil?
mult = 1
for element_id in obj.element_set
for attr in user.attributes
next if ATTRIBUTES[attr][2].nil?
for element_boost in ATTRIBUTES[attr][2]
mult += user.attr_levels[attr] / 12 if element_boost == element_id
end
end
end
obj.base_damage *= mult
end
attr_make_obj_damage_value(user, obj)
end
end
#==============================================================================
# ** Game_BattleAction
#------------------------------------------------------------------------------
# This class handles battle actions. This class is used within the
# Game_Battler class.
#==============================================================================
class Game_BattleAction
include Attibute_Def
#--------------------------------------------------------------------------
# * Set Normal Attack
#--------------------------------------------------------------------------
alias attr_set_attack set_attack
def set_attack
activated_special_skill = false
if !battler.attributes.nil?
for attr in battler.attributes
auto_skill_id = ATTRIBUTES[attr][4]
if rand(48) < battler.attr_levels[attr] and !auto_skill_id.nil?
set_skill(auto_skill_id)
battler.last_skill_id = auto_skill_id
battler.action.forcing = true
activated_special_skill = true
break
end
end
end
if activated_special_skill
activated_special_skill = false
else
attr_set_attack
end
end
end
#==============================================================================
# ** Game_Enemy
#------------------------------------------------------------------------------
# This class handles enemy characters. It's used within the Game_Troop class
# ($game_troop).
#==============================================================================
class Game_Enemy < Game_Battler
def attributes
return nil
end
end
Hope you (332211) or someone else who might understand script better than me, can help me figure out what the heck went wrong and how to fix it.... Cause as I said.... I can't battle test, and when I try to test my game by walking around I am greeted with the exact same error.
Many thanks.