I'm trying to modify the Weapon Class so that I can add an sp_plus statistic to each weapon but do not know how to go about it.
I tried something like this but to no avail:
[spoiler]module RPG
class Weapon
attr_accessor :maxsp
def setup_additional_stats
@maxsp = 0
case @id
when 1
@maxsp = 5
end
end
end
end
class Game_Temp
alias setup initialize
def initialize
setup
for weapon in $data_weapons
weapon.setup_additional_stats
end
end
end
[/spoiler]
Strike 1, wrong forum.
http://rmrk.net/index.php/topic,19774.0.html
For starters, you're not aliasing the initialize method, which would most likely cause your error.
Here's how I went about adding a statistic when I needed to. First, I went into the database and stole Zeriab's module addon: http://rmrk.net/index.php/topic,21582.0.html
Then (and this might not be the best way to do it), I wrote in the additional stats like this:
attr_sec_accessor :hp_plus, 'get_additional_stats (0)'
attr_sec_accessor :sp_plus, 'get_additional_stats (1)'
and then I wrote a method in the class like this:
def get_additional_stats (parameter)
case @id
when 0 # Bronze Sword
hp_add = XX
sp_add = YY
return [hp_add, sp_add][parameter]
when 1 # ETC...
end
return 0
end
You could do that for as many stats as you want to, but like I said, it might not be the best way; it's just the way I did it.
Could this script perhaps do what you are looking for? http://rmrk.net/index.php/topic,18159.0.html
Either way you can also choose modern's solution ^_^