I'm not sure how much programming experience you have, so I'll try to make it straight to the point.
For starters, whenever you do
self.SOMETHING, you're specifically calling the self's class method, which are the
def SOMETHING. A variable is represented with @SOMETHING. You might have noticed in Game_Battler 1 in the
initialize method @animation_id. In your sample code, you can use @animation_id instead of self.animation_id and the result would be the same.
But why? You might have noticed this line:
attr_accessor :animation_id # animation ID
attr_accessor essentially creates a GET and SET method for the variable @animation_id. Something like this:
def animation_id
return @animation_id
end
def animation_id=(id)
@animation_id = id
end
This is useful when you want to access this variable OUTSIDE of the Game_Battler class.
The reason for your
self.tempagi error is because you didn't define a tempagi method. The first thing you think would work would be to add this line to Game_Battler
...but not just yet. @tempagi will have a value equal to nil (equivalent of null in other languages), so it will error when you try to add a number to it in your += operator. So we need to initialize it. If you're just editing the default RMXP scripts (which isn't really recommended unless you know what you're doing), then just add this to the bottom of Game_Battler#initialize:
Now you're in business. If we're just using this variable inside the Game_Battler class and don't need it anywhere else, working with @tempagi is fine--as long as you change
self.tempagi to
@tempagi, you can remove the attr_accessor.
As for your idea, it is logical and correct. You will need to create another variable to keep track of this temporary addition to the actor's stat. What I don't agree with is the addition to
self.agi, which will add onto the equipment stat bonuses variable (you will definitely want to keep these two separate). You will want to change one line in your Game_Battler#agi method to something like this:
n = [[base_agi + @agi_plus + @tempagi, 1].max, 999].min
And then you can change your else-block in your sample to
With that, your code should be good to go. Hopefully you can pick up Ruby relatively quickly--to be determined in making a commercial game without it would be disastrous.