RGSS2 .NOTE

Posts

Pages: 1
Adon237
if i had an allowance, i would give it to rmn
1743
Ok, I was testing my game, and a script I was using uses an "undefined method"
I looked at it and it is .note.
It is a conditional skills and equipment script, and half of my skills rely on it.
So the problem is once you go into the skill menu, and press Z, it shows the skill error. And in battle, selecting skills like this happens too. Now this doesn't happen if there is a skill in the menu, or if you select a skill, but if you go to a blank skill, it happens. What I have on this line:
if has_tag?(skill.note, '<skill>')

Is .note an undefined method? It's for the notetags in the skillboxes.
Note is an attribute of RPG::Skill (well, BaseItem which Skill extends). If "Undefined Method" is occuring then the 'skill' object is curently not a RPG::Skill but it isn't a null object either else it'll report a different error. Please post the script your using here and the entire error message.
Adon237
if i had an allowance, i would give it to rmn
1743
Ok, I didn't understand any of that. lol
Script: It's large.

# ** Conditional Skills And Equipment
------------------------------------------------------------------------------
# By Syvkal
# Version 2.6.1
# 05-09-08
#==============================================================================
#
# - INTRODUCTION -
#
# This script can be used to set special use conditions to skills and equipment
# There are a number of different ones you can check:
#
#------------------------------------------------------------------------------
#
# - FEATURES -
#
# There are a number of different Conditional features that can be used
# These include:
#
# STATE - Whether certain states are inflicted
# WEAPON - Whether certain weapons are equipped
# ARMOUR - Whether certain armours are equipped
# ITEM - Whether certain items are in your inventory (which can be used up)
# HP - Whether HP is MORE or LESS than a percent of the MAXHP
# GOLD - Whether the party has a certain amount of gold (which can be used up)
# LEVEL - Whether the LEVEL is MORE or LESS than a certain point
# CLASS - Whether the actor is a certain class
# PARTYMEMBER - Whether a certain actor is in your party (and alive)
# PARTYNUMBER - Whether a certain amount of actors are in your party (and alive)
# FREEHAND - Whether the actor has 1 or 2 free hands
# ATK - Whether the actor has a certain amount of ATK
# DEF - Whether the actor has a certain amount of DEF
# SPI - Whether the actor has a certain amount of SPI
# AGI - Whether the actor has a certain amount of AGI
#
# NOSHOW - Add this to make a skill not appear when it can't be used
#
# More than one can be used on any skill or equipement
# However only some can be used for skills and only some for equipement
#
#------------------------------------------------------------------------------
#
# - USAGE -
#
# First make a skill/equipment in the Database and in it's note box place this:
#
# <skill> <equip>
# ..... or .....
# <skill> <equip>
#
# You must place any necessary Coding or tags in there
# Anything you place in there must be on a separate line
#
# Condition tags must be followed by a number, multiple numbers can be entered
# these must be separated by a comma ','
# Some conditions can use the '&' feature
#
# See EXAMPLES if you are unsure
#
#------------------------------------------------------------------------------
#
# - SKILLS -
#
# The special conditions that can be set to skills are as follows:
#
# STATE WEAPON ARMOUR HPLESS HPMORE
# FREEHAND ITEM ITEMUSE GOLD GOLDUSE
# LEVELLESS LEVELMORE CLASS
# PARTYNUMBER PARTYMEMBER
#
#------------------------------------------------------------------------------
#
# - EQUIPMENT -
#
# The special conditions that can be set to equipment are as follows:
#
# LEVELLESS LEVELMORE WEAPON ARMOUR
# ATK DEF SPI AGI
#
#------------------------------------------------------------------------------
#
# - EXAMPLES -
#
# Here is a list of examples to show you how to use each condition:
#
# STATE12 - State 12 must be inflicted to use the skill
# WEAPON1 - Weapon 1 must be equipped to use the skill
# ARMOUR2,9 - Both armours 2 and 9 must be equipped to use the skill
# FREEHAND2 - Both of the actors hands must be free to use the skill
# HPLESS25 - Health must be below 25% to use the skill
# HPMORE50 - Health must be above 50% to use the skill
# ITEM1,2 - Must have items 1, 2 and 3 to use the skill
# ITEMUSE1,2 - Must have and will use 1 of items 1 and 2 to use the skill
# ITEM1&3,2 - Must have 3 of item 1 and 1 of item 2 to use the skill
# ITEMUSE1&3 - Must have and will use 3 of item 1 to use the skill
# GOLD1000 - Must have 1000 Gold to use the skill
# GOLDUSE100 - Must have and will use 100 Gold to use the skill
# CLASS1,2 - Must be Class 1 or 2 (RTP : Paladin, Warrior) to use the skill
# LEVELLESS5 - Must be under Level 5 to use the skill
# LEVELMORE9 - Must be over level 9 to use the skill
# PARTYMEMBER4 - Must have Actor 4 (RTP : Ylva) to use the skill
# PARTYNUMBER3 - Must have 3 or more actors in the party to use the skill
# ATK100 - Must have ATK greater than or equal to 100
# DEF100 - Must have DEF greater than or equal to 100
# SPI100 - Must have SPI greater than or equal to 100
# AGI100 - Must have AGI greater than or equal to 100
#
#==============================================================================

#===================================================#
# ** C O N F I G U R A T I O N S Y S T E M ** #
#===================================================#

# Remove Equipment when conditions don't apply anymore?
REMOVE_EQUIP = true
# Show a message saying that the equipment has been removed?
SHOW_MESSAGE = true
# Speed at which the message will disappear
MESSAGE_SPEED = 2 # 1 = Slow 2 = Medium 3+ = Very Fast
# Amount of frames the message will stay for
MESSAGE_STAY = 20 # 20 is average - You want it lower if the speed is slow
# Use an Icon in the message?
USE_ICON = true
# Message that tells you what has been removed
EQUIP_REMOVE = "%s unequipped"
# Message explain's why
EQUIP_MESSAGE = "%s can't use it anymore."

#===================================================#
# ** E N D C O N F I G U R A T I O N ** #
#===================================================#

#==============================================================================
# ** Script Import
#------------------------------------------------------------------------------
# Added to make it work with or without Conditional Skills
#==============================================================================

$imported = {} if $imported == nil
$imported["ConditionalSkill"] = true

#==============================================================================
# ** Game_Battler
#------------------------------------------------------------------------------
# Added Checks for Conditional Skills And Equipment
#==============================================================================

class Game_Battler
#--------------------------------------------------------------------------
# * Alias Listings
#--------------------------------------------------------------------------
alias skill_use_original skill_can_use?
#--------------------------------------------------------------------------
# * Includes The NOTES Module
#--------------------------------------------------------------------------
include NOTES
#--------------------------------------------------------------------------
# * Determine Usable Skills
#--------------------------------------------------------------------------
def skill_can_use?(skill)
return false unless skill_condition_can_use?(skill)
skill_use_original(skill)
end
#--------------------------------------------------------------------------
# * Determine Usable Skill Conditions
#--------------------------------------------------------------------------
def skill_condition_can_use?(skill)
if has_tag?(skill.note, '<skill>')
@conditions = get_tag_area(skill.note, '<skill>')
if has_tag?(@conditions,'STATE')
@tags = get_tag(@conditions,'STATE')
for i in 0...@tags.size
return false unless state?(@tags[i].to_i)
end
end
if has_tag?(@conditions,'WEAPON')
@tags = get_tag(@conditions,'WEAPON')
for i in 0...@tags.size
return false unless weapons.include?($data_weapons[@tags[i].to_i])
end
end
if has_tag?(@conditions,'ARMOUR')
@tags = get_tag(@conditions,'ARMOUR')
for i in 0...@tags.size
return false unless armors.include?($data_armors[@tags[i].to_i])
end
end
if has_tag?(@conditions,'ITEM')
@tags = get_multiple_tag(@conditions,'ITEM','USE')
for i in 0...@tags.size
if @tags[i].is_a?(Array)
return false unless $game_party.item_number($data_items[@tags[i][0].to_i]) >= @tags[i][1].to_i
else
return false unless $game_party.item_number($data_items[@tags[i].to_i]) >= 1
end
end
end
if has_tag?(@conditions,'ITEM','USE')
@tags = get_multiple_tag(@conditions,'ITEM','USE')
for i in 0...@tags.size
if @tags[i].is_a?(Array)
return false unless $game_party.item_number($data_items[@tags[i][0].to_i]) >= @tags[i][1].to_i
else
return false unless $game_party.item_number($data_items[@tags[i].to_i]) >= 1
end
end
end
if has_tag?(@conditions,'HP','LESS')
@tags = get_tag(@conditions,'HP','LESS')
return false unless hp <= maxhp / (100 / @tags[0].to_i)
end
if has_tag?(@conditions,'HP','MORE')
@tags = get_tag(@conditions,'HP','MORE')
return false unless hp >= maxhp / (100 / @tags[0].to_i)
end
if has_tag?(@conditions,'LEVEL','LESS')
@tags = get_tag(@conditions,'LEVEL','LESS')
return false unless @level < @tags[0].to_i
end
if has_tag?(@conditions,'LEVEL','MORE')
@tags = get_tag(@conditions,'LEVEL','MORE')
return false unless @level > @tags[0].to_i
end
if has_tag?(@conditions,'CLASS')
@tags = get_tag(@conditions,'CLASS')
return false unless @class_id == @tags[0].to_i or @tags[1].to_i
end
if has_tag?(@conditions,'GOLD')
@tags = get_multiple_tag(@conditions,'GOLD','USE')
return false unless $game_party.gold >= @tags[0].to_i
end
if has_tag?(@conditions,'GOLD','USE')
@tags = get_multiple_tag(@conditions,'GOLD','USE')
return false unless $game_party.gold >= @tags[0].to_i
end
if has_tag?(@conditions,'PARTY','NUMBER')
@tags = get_multiple_tag(@conditions,'PARTY','NUMBER')
return false unless $game_party.existing_members.size >= @tags[0].to_i
end
if has_tag?(@conditions,'PARTY','MEMBER')
@tags = get_multiple_tag(@conditions,'PARTY','MEMBER')
return false unless $game_party.existing_members.include?($game_actors[@tags[0].to_i])
end
if has_tag?(@conditions,'FREEHAND')
@tags = get_tag(@conditions,'FREEHAND')
return false unless free_hands >= @tags[0].to_i
end
end
return true
end
#--------------------------------------------------------------------------
# * Determine Usable Equipment Conditions
#--------------------------------------------------------------------------
def equipment_can_use?(equip)
if equip != nil
if has_tag?(equip.note, '<equip>')
@conditions = get_tag_area(equip.note, '<equip>')
if has_tag?(@conditions,'LEVEL','LESS')
@tags = get_tag(@conditions,'LEVEL','LESS')
return false unless @level < @tags[0].to_i
end
if has_tag?(@conditions,'LEVEL','MORE')
@tags = get_tag(@conditions,'LEVEL','MORE')
return false unless @level > @tags[0].to_i
end
if has_tag?(@conditions,'WEAPON')
@tags = get_tag(@conditions,'WEAPON')
for i in 0...@tags.size
return false unless weapons.include?($data_weapons[@tags[i].to_i])
end
end
if has_tag?(@conditions,'ARMOUR')
@tags = get_tag(@conditions,'ARMOUR')
for i in 0...@tags.size
return false unless armors.include?($data_armors[@tags[i].to_i])
end
end
if has_tag?(@conditions,'ATK')
@tags = get_tag(@conditions,'ATK')
return false unless actor.parameters[2, @level] >= @tags[0].to_i
end
if has_tag?(@conditions,'DEF')
@tags = get_tag(@conditions,'DEF')
return false unless actor.parameters[3, @level] >= @tags[0].to_i
end
if has_tag?(@conditions,'SPI')
@tags = get_tag(@conditions,'SPI')
return false unless actor.parameters[4, @level] >= @tags[0].to_i
end
if has_tag?(@conditions,'AGI')
@tags = get_tag(@conditions,'AGI')
return false unless actor.parameters[5, @level] >= @tags[0].to_i
end
end
end
return true
end
#--------------------------------------------------------------------------
# * Determine Hidden Skills
#--------------------------------------------------------------------------
def show_skill?(skill)
return true if skill_can_use?(skill)
if has_tag?(skill.note,'NOSHOW')
return skill_condition_can_use?(skill)
end
return true
end
#--------------------------------------------------------------------------
# * Check For Free Hands
#--------------------------------------------------------------------------
def free_hands
@free_hands = 0
@free_hands += @weapon_id==0 ? 1 : 0
@free_hands += @armor1_id==0 ? 1 : 0
return @free_hands
end
end

#==============================================================================
# ** Scene_Battle
#------------------------------------------------------------------------------
# Added removal of necessary skill components
#==============================================================================

class Scene_Battle < Scene_Base
#--------------------------------------------------------------------------
# * Alias Listings
#--------------------------------------------------------------------------
alias execute_skill_original execute_action_skill
#--------------------------------------------------------------------------
# * Includes The NOTES Module
#--------------------------------------------------------------------------
include NOTES
#--------------------------------------------------------------------------
# * Execute Battle Action: Skill
#--------------------------------------------------------------------------
def execute_action_skill
execute_skill_original
skill = @active_battler.action.skill
if has_tag?(skill.note, '<skill>')
@conditions = get_tag_area(skill.note, '<skill>')
if has_tag?(@conditions,'ITEM','USE')
@tags = get_multiple_tag(@conditions,'ITEM','USE')
for i in 0...@tags.size
if @tags[i].is_a?(Array)
$game_party.lose_item($data_items[@tags[i][0].to_i],@tags[i][1].to_i,true)
else
$game_party.lose_item($data_items[@tags[i].to_i],1,true)
end
end
end
if has_tag?(@conditions,'GOLD','USE')
@tags = get_tag(@conditions,'GOLD','USE')
$game_party.lose_gold(@tags[0].to_i)
end
end
end
end

#==============================================================================
# ** Scene_Skill
#------------------------------------------------------------------------------
# Added removal of necessary skill components
#==============================================================================

class Scene_Skill < Scene_Base
#--------------------------------------------------------------------------
# * Alias Listings
#--------------------------------------------------------------------------
alias use_skill_original use_skill_nontarget
#--------------------------------------------------------------------------
# * Includes The NOTES Module
#--------------------------------------------------------------------------
include NOTES
#--------------------------------------------------------------------------
# * Use Skill (apply effects to non-ally targets)
#--------------------------------------------------------------------------
def use_skill_nontarget
if has_tag?(@skill.note, '<skill>')
@conditions = get_tag_area(@skill.note, '<skill>')
if has_tag?(@conditions,'ITEM','USE')
@tags = get_multiple_tag(@conditions,'ITEM','USE')
for i in 0...@tags.size
if @tags[i].is_a?(Array)
$game_party.lose_item($data_items[@tags[i][0].to_i],@tags[i][1].to_i,true)
else
$game_party.lose_item($data_items[@tags[i].to_i],1,true)
end
end
end
if has_tag?(@conditions,'GOLD','USE')
@tags = get_tag(@conditions,'GOLD','USE')
$game_party.lose_gold(@tags[0].to_i)
end
use_skill_original
end
end
end

#==============================================================================
# ** Window_EquipItem
#------------------------------------------------------------------------------
# Added Check for Conditional Equipment
#==============================================================================

class Window_EquipItem < Window_Item
#--------------------------------------------------------------------------
# * Alias Listings
#--------------------------------------------------------------------------
alias enable_original enable?
#--------------------------------------------------------------------------
# * Whether to display item in enabled state
#--------------------------------------------------------------------------
def enable?(item)
return false unless @actor.equipment_can_use?(item)
enable_original(item)
end
end

#==============================================================================
# ** Scene_Map
#------------------------------------------------------------------------------
# Added removal of Equipment when conditions don't apply anymore
#==============================================================================

class Scene_Map < Scene_Base
#--------------------------------------------------------------------------
# * Alias Listings
#--------------------------------------------------------------------------
alias update_original update
alias terminate_original terminate
alias start_original start
#--------------------------------------------------------------------------
# * Start processing
#--------------------------------------------------------------------------
def start
start_original
@stay = MESSAGE_STAY
end
#--------------------------------------------------------------------------
# * Termination Processing
#--------------------------------------------------------------------------
def terminate
terminate_original
@notify_window.dispose if @notify_window
end
#--------------------------------------------------------------------------
# * Frame Update
#--------------------------------------------------------------------------
def update
update_original
if @notify_window
@notify_window.update
@stay -= 1
if @stay <= 0
@notify_window.opacity -= MESSAGE_SPEED
@notify_window.contents_opacity -= MESSAGE_SPEED
end
if @notify_window.opacity == 0
@notify_window.dispose
@notify_window = nil
end
end
if REMOVE_EQUIP
update_equipment
end
end
#--------------------------------------------------------------------------
# * Update Equipment
#--------------------------------------------------------------------------
def update_equipment
for actor in $game_party.members
for i in 0...actor.equips.size
unless actor.equipment_can_use?(actor.equips[i])
if SHOW_MESSAGE
unless @notify_window
@notify_window = Window_Base.new(0, 0, 320, 80)
w = @notify_window.width-32; h = @notify_window.height-32
@notify_window.contents = Bitmap.new(w, h)
@notify_window.x = (544 - @notify_window.width) / 2
@notify_window.y = (416 - @notify_window.height) / 2
@notify_window.z = 9998
icon_index = actor.equips[i].icon_index
if USE_ICON
@notify_window.draw_icon(icon_index, 0, 4,true)
end
@notify_window.contents.draw_text(USE_ICON ? 24 : 0, 0, w, 24, sprintf(EQUIP_REMOVE, actor.equips[i].name), 0)
@notify_window.contents.draw_text(0, 24, w, 24, sprintf(EQUIP_MESSAGE, actor.name), 2)
@stay = MESSAGE_STAY
actor.change_equip(i, nil)
end
end
end
end
end
end
end

#==============================================================================
# ** Scene_Equip
#------------------------------------------------------------------------------
# Edited to add 'equipment_can_use?' function
#==============================================================================

class Scene_Equip < Scene_Base
#--------------------------------------------------------------------------
# * Update Item Selection
#--------------------------------------------------------------------------
def update_item_selection
if Input.trigger?(Input::B)
Sound.play_cancel
@equip_window.active = true
@item_window.active = false
@item_window.index = -1
elsif Input.trigger?(Input::C)
if @actor.equipment_can_use?(@item_window.item) # Added 'equipment_can_use?'
Sound.play_equip
@actor.change_equip(@equip_window.index, @item_window.item)
@equip_window.active = true
@item_window.active = false
@item_window.index = -1
@equip_window.refresh
for item_window in @item_windows
item_window.refresh
end
else
Sound.play_buzzer
end
end
end
end

#==============================================================================
# ** Window_Skill
#------------------------------------------------------------------------------
# Edited to hide certain skills
#==============================================================================

class Window_Skill < Window_Selectable
#--------------------------------------------------------------------------
# * Refresh
#--------------------------------------------------------------------------
def refresh
@data = []
for skill in @actor.skills
@data.push(skill) if @actor.show_skill?(skill) # Added 'If' statement
if skill.id == @actor.last_skill_id
self.index = @data.size - 1
end
end
@item_max = @data.size
create_contents
for i in 0...@item_max
draw_item(i)
end
end
end
What's weird is that the text is transparent!(In the script I just posted.)
Error Message:
Script '(Script Name)' line 168: NoMethodError occured.
undefined method `note' for nil:NilClass
Please, please use the {code} tag not the spoiler tag.
Huh, I thought using a nil object gave a different error. Oops. Something is passing a nil object to skill_condition_can_use? which causes the problem. Looking at it I'd assume the null object is pass via skill_can_use? assuming it's in this script but I can't say without looking at the whole thing.

A hackfix would be to add
return false if skill.nil?

To skill_can_use? right after the def, line 160. It's a hackfix though and it's patching the problem instead of actually fixing it. See if it works and if not upload a project that uses your scripts and causes the problem right away so I can take a look at it.

(abused mod powers to change hide to code tag)
Adon237
if i had an allowance, i would give it to rmn
1743
Amazing job.
It worked. I love it. Thanks.
The skill menu in the main menu is fixed, and the skill menu in battle.
Make sure it does work, not just not-crash the game. Just because the game starts doesn't mean everything is working!
Adon237
if i had an allowance, i would give it to rmn
1743
Yes, I have been testing the game, I will keep on testing for a couple of hours.
Adon237
if i had an allowance, i would give it to rmn
1743
Darn. I have another one. I think I did this to myself, but I screwed up this line of code:
ACTION.merge!(DASH_ATTACK_ACTION) this is line 36.
Script (script name) line 36 NameError occured.
uninitialized constant, N01::ACTION
I tried fixing it, but I am stuck to as what I am supposed to do. I am trying to learn RGSS2, but...
So if you can find what is wrong, and you give me the fix, can you tell me what this is doing, and how knew what to do? Would I have to use a different constant?
Fudge.
oops I forgot to post the script.

What's weird is all of this guy's scripts have the ACTION.merge! in it.
#==================================================================================
#"Dash" Element Script

module N01
# Element used to define a skill as a Dash skill
DASH_ELEMENT = 30 # Default is 30, my Dash Element.

SHOW_SKILL_ANIM_DASH = true #When true, if a skill has the Dash element it will have the magic animation before the dash. When false, it is the same as the
#weapon dash animation.
# Action Sequence
DASH_ATTACK_ACTION = {
"DASH_ATTACK_SKILL" => ["START_MAGIC_ANIM","45","JUMP_TO_TARGET","JUMP_AWAY","JUMP_AWAY","JUMP_AWAY","DASH_ATTACK","16","OBJ_ANIM_WEIGHT",
"One Wpn Only","16","Can Collapse","COORD_RESET"],
"DASH_ATTACK" => ["JUMP_TO_TARGET","JUMP_AWAY","JUMP_AWAY","JUMP_AWAY","DASH_ATTACK","16","OBJ_ANIM_WEIGHT","One Wpn Only","16","Can Collapse","COORD_RESET"],}
ACTION.merge(DASH_ATTACK_ACTION)
end

module RPG
class Skill
alias enelvon_dash_base_action base_action
def base_action
# If the Dash Element is checked on the skills tab in the database,
# the Dash attack action sequence is used.
if $data_skills[@id].element_set.include?(N01::DASH_ELEMENT) && N01::SHOW_SKILL_ANIM_DASH == true
return "DASH_ATTACK_SKILL"
elsif $data_skills[@id].element_set.include?(N01::DASH_ELEMENT) && N01::SHOW_SKILL_ANIM_DASH == false
return "DASH_ATTACK"
end
enelvon_dash_base_action
end
end
class Weapon
alias enelvon_dash_weapon_base_action base_action
def base_action
# If the Dash Element is checked on the weapons tab in the database,
# the Dash attack action sequence is used.
if $data_weapons[@id].element_set.include?(N01::DASH_ELEMENT)
return "DASH_ATTACK"
end
enelvon_dash_weapon_base_action
end
end
end
Adon237
if i had an allowance, i would give it to rmn
1743
Nevermind. I can live without the script. Though if you want to you can look at it.
If you do find the error, please tell me what it is so I can know for future reference.
ACTION isn't defined anywhere. That script might be depending on another script that isn't in your project.
Adon237
if i had an allowance, i would give it to rmn
1743
Hmm... That's weird.
Pages: 1