Help - Search - Members - Calendar
Full Version: adding new attributes to actor
RPG RPG Revolution Forums > Game Engines > RPG Maker XP Discussion
elliott20
so I wanted to add some new attributes to the characters in game, and I went online to look for some good practices on the subject. One guy suggested that for every new stat that you need to add, you make a module for it, and then just reference it so that when trouble shooting it'll be all in the same place, and then just reference that module as you need it.

So, say that I would want create a new stat called "Dark" for the character, which governs their affinity towards dark magic. (As opposed to using their INT score)

Here's what I ended up with

CODE

module Dark
Start = {1=>400}
Start.default = 100
def self.get(actor)
n = Start[actor.id]
return n
end
end


I then declare the variable
CODE

attr_reader :dark #darkness stat


then, in the setup area, I plug in this code
CODE

@dark = dark
def dark
return Dark.get(self)
end


now, this works all fine and dandy if I'm just making one new stat and that's it, but I'm making easily over two dozen new stats for the characters, not to mention the number of new stats I'm going to have to make for the monsters. I'm wondering if maybe there's a more efficient way to go about this.

i.e. there is a "get" method in every new stat module. Can I simply define this once elsewhere, and let that be it?
-dah0rst-
what about making an array with all the stats in it?
for example you do an array that contains all the stat names in it- but I'm sorry that I'm just doing VX scripts, so I don't know how to show you right.

But here's a standart example (maybe a little different in XP):

Module Stats

#to access their names, for example in the status window#
def self.name(id)
name=["Dark", "Light", "Fire", "Ice", "Thunder", "Armor Piercing", "Lifesteal"]
name.length=$stats_max
return name[id]
end

#Now you could do an array of stats, like:#

def self.stat(stat_id,actor)
for i in 0..$stats_max-1
stats=[]
#this should be made extra, but i don't know how you want to calculate the stats#
value = {1=>400}
value.default = 100
#until here#
stats.push(value)
read_value = stats[stat_id]
n = read_value[actor.id]
return n
end

This this just the idea, maybe full of mistakes. But you could try arrays with all the stats in it, so you have one module instead of thousand...





elliott20
newb question, but this part of the code I'm still unsure of


CODE
#this should be made extra, but i don't know how you want to calculate the stats#
value = {1=>400}
value.default = 100
#until here#
stats.push(value)
read_value = stats[stat_id]
n = read_value[actor.id]
return n
end

I already have all of the numbers generated. There's no algorithm as to how it is generated though, and all of the stats are preset. They also do not grow in anyway except for the skills (which is one point at a time), the HP, SP, and another mana like stat.

So would it be easier to just have all the arrays created and then just loaded one by one? (of course, this would make everything incredibly clunky should I want to add a new entry later)
-dah0rst-
You mean you want to have a constant abilty for every character? Like "Simon" is a "dark: 3, fire: 8 " character?
I don't understand what you really want. (Sorry)

You could write the attributes in the .note of the actors/ enemies and access them via script- I made a tutorial how to use this...
elliott20
It's okay. I'll just have to do some digging and gut my way through it.
This is a "lo-fi" version of our main content. To view the full version with more information, formatting and images, please click here.
Invision Power Board © 2001-2013 Invision Power Services, Inc.