-
I'm trying to modify the equippable? definition in Game_Actor so that it bypasses the need to select which equipment a class can equip, but instead is passed on certain skills/proficencies learnt. This is my coding I have:
module Equipment_Setup
armtypes = {}
armtypes[1] = "Cloth"
armtypes[2] = "Leather"
armtypes[3] = "Chain"
armtypes[4] = "Plate"
#armtypes = {"Cloth","Leather","Chain","Plate"}
armskills = {
1 => 98,
2 => 99,
3 => 100,
4 => 101
}
end
class Game_Actor < Game_Battler
include NOTES
def equippables?(item, actor)
@actor = actor
if item.is_a?(RPG::Weapon)
return self.class.weapon_set.include?(item.id)
elsif item.is_a?(RPG::Armor)
return false if two_swords_style and item.kind == 0
for i in 1...4
@armtype = Equipment_Setup::armtypes[i]
if has_tag?(item.note,@armtype) and @actor.skill_learn? (Equipment_Setup::armskills[i])
return self.class.armor_set.include?(item.id)
end
end
end
return false
end
end
I have tried to setup the armtypes array many ways but it still does not work. I am gettig an undefined method error for the line starting with @armtype =. I don't know what is going on because I have arrays like thsi setup elsewhere and it works no problem.
-
Well, if I had to take a guess, it's because armtypes is not a constant.
Also, why a hash?
Try:
ARMTYPES = []
ARMTYPES[1] = "Cloth"
ARMTYPES[2] = "Leather"
ARMTYPES[3] = "Chain"
ARMTYPES[4] = "Plate"
#ARMTYPES = ["Cloth","Leather","Chain","Plate"]
ARMSKILLS = []
ARMSKILLS[1] = 98
ARMSKILLS[2] = 99
ARMSKILLS[3] = 100
ARMSKILLS[4] = 101
And get back to me. There may be other problems too, but those are what stick out to me...
Naturally, you will also have to change any lines that call them to their capitalized variants.
so Equipment_Setup::ARMTYPES, not Equipment_Setup::armtypes
also equippables?
Where is the 's' coming from. I take it you must be calling it as a method separated from equippable? in any case.
-
Yes I am calling it as equippables as I don't want every other script which calls equippable to need actor info sent with it. It seems to like this way better, but I am now recieving an error in the NOTES file.
#==============================================================================
# ** Notes Field System
#------------------------------------------------------------------------------
# By Syvkal
# Version 1.6
# 05-29-08
#==============================================================================
module NOTES
def get_tag(field, tag, extra_tag = "")
note = ""+field
note = note.split("\r\n")
for i in 0...note.size
if note[i].include?(tag + extra_tag)
tags = note[i]
tags.slice!(tag)
if extra_tag != ""
tags.slice!(extra_tag)
end
tags = tags.split(/,\s*/)
return tags
end
end
return nil
end
def get_multiple_tag(field, tag, extra_tag = "")
note = ""+field
note = note.split("\r\n")
for i in 0...note.size
if note[i].include?(tag + extra_tag)
tags = note[i]
tags.slice!(tag)
if extra_tag != ""
tags.slice!(extra_tag)
end
tags = tags.split(/,\s*/)
for i in 0...tags.size
if tags[i].include?('&')
tags[i] = tags[i].split(/\s*\&\s*/)
end
end
return tags
end
end
return nil
end
def has_tag?(field, tag, extra_tag = "")
note = ""+field
if note.include?(tag + extra_tag)
return true
end
return false
end
def get_tag_area(field, area_tags)
note = ""+field
if note.include?(area_tags)
@yes = false
note = note.split(/#{area_tags}/)
note = note[1]
return note
else
return ""
end
end
end
More specifically this line: if note.include?(tag + extra_tag)
-
Your sending armtype as an integer. Send it as a string.
@armtype.to_s
-
Awesome that solved the errors. I am not getting anymore errors, but the script isn't working.
module Equipment_Setup
ARMTYPES = []
ARMTYPES[1] = "Cloth"
ARMTYPES[2] = "Leather"
ARMTYPES[3] = "Chain"
ARMTYPES[4] = "Plate"
#ARMTYPES = ["Cloth","Leather","Chain","Plate"]
ARMSKILLS = []
ARMSKILLS[1] = 98
ARMSKILLS[2] = 99
ARMSKILLS[3] = 100
ARMSKILLS[4] = 101
end
class Game_Actor < Game_Battler
include NOTES
def equippables?(item, actor)
@actor = actor
if item.is_a?(RPG::Weapon)
return self.class.weapon_set.include?(item.id)
elsif item.is_a?(RPG::Armor)
return false if two_swords_style and item.kind == 0
for i in 0...3
@armtype = Equipment_Setup::ARMTYPES[i].to_s
if has_tag?(item.note,@armtype) and @actor.skills_learn? (Equipment_Setup::ARMSKILLS[i], @actor)
return true
end
end
end
return false
end
def skills_learn?(skill_id,actor)
@actor = actor
return @actor.skills.include?(skill_id)
end
end
Basically the user picks up a Chain Coif, with Chain in the notes page. and then learns the skill Chain Mail (100). But it is not being displayed in the equipment screen. Any ideas>
-
return self.class.armor_set.include?(item.id)
That checks the class armor set. If the item is not in it, it will return false. Change it to: return true if you don't want that.
-
If you look, thats what I have, but it still doesn't seem to be working.
-
I did look. If you read, you'll note that I suspect the item is not showing up because he does not have the right class. You said you wanted to remove that restriction, so I am telling you - get rid of that condition and replace it with return true.
-
The weapon line is still there yes, but I have removed the check to see if the armor is within the class and in turn replaced it with return true. Unless I am completely missing something:S.
-
Alright, well right under the @armtype line, put this:
p has_tag?(item.note,@armtype), @actor.skills_learn? (Equipment_Setup::ARMSKILLS[i], @actor)
and tell me what comes out.
Also, can I see what your skills_learn? method looks like?
-
Do you not see the code in Reply #3? Im just curious cuz all of that is placed in there.
Basically my skills_learned method looks like this:
def skills_learn?(skill_id,actor)
@actor = actor
return @actor.skills.include?(skill_id)
end
Just want to check the skills and actor actually has. Don't know how the original skill_learned works, so I modified it like this.
EDIT: When I add the: p has_tag?(item.note,@armtype), @actor.skills_learn? (Equipment_Setup::ARMSKILLS[i], @actor)
I get an error immediately when I playtest, SyntaxError Occured
-
Sorry, I didn't see the skills_learn? method.
A lot of your code is confusing to me though. Why do you use the actor as an argument when the methods are in Game_Actor? Are you sending different actors into it? If so, why?
It's weird that that line gives a syntax error, since the line below it does not. Anyway, I'll look into it once I get back. I have to go for a little while.
EDIT::
Oh, and I can't believe I didn't notice this earlier, I should've the moment you got the addition error in the Notes script:
for i in 0...3
@armtype = Equipment_Setup::ARMTYPES[i].to_s
if has_tag?(item.note,@armtype) and @actor.skills_learn? (Equipment_Setup::ARMSKILLS[i], @actor)
return true
end
end
Should be for i in 1...5
- because you don't define 0 as an element of your array and you actually want it to iterate through 1, 2, 3 and 4. Also, you won't need to put the .to_s anymore - I had a notion for some reason that you were sending the skill ID. Actually, there's another fairly
Here's what the equippables? method should look like. Again I don't know why you have @actor as an argument, but I will assume it is for a good reason and keep it.
def equippables?(item, actor)
@actor = actor
if item.is_a?(RPG::Weapon)
return self.class.weapon_set.include?(item.id)
elsif item.is_a?(RPG::Armor)
return false if two_swords_style && item.kind == 0
for i in 1...5
@armtype = Equipment_Setup::ARMTYPES[i]
if has_tag?(item.note,@armtype) && @actor.skills_learn? (Equipment_Setup::ARMSKILLS[i], @actor)
return true
end
end
end
return false
end
-
I only have the @actor as an argument cuz well I am starting to play around with the scripts more and thought thats what was needed to be added. I've worked with programming languages before so I am not completely new with all this. Just unsure of how "global" the variables are within a class. So really from what you say, I don't need to include the actor argument.
EDIT: Got it to work. Had a problem with my skill_learn definition.