You made a condition for a method which MUST return a value, but the condition will NOT be satisfied always (ex, when the actor is not class 3), and when it is not, nothing is returned.
You need to add an 'else' part for your 'if' statement, and put the return value for when the other conditions do not match there.
class Game_BattlerBase
def attack_skill_id
if @class_id == 2
return 3
else
return 1 # This is returned when the actor is not class 3.
end
end
end
Like the above code shows.
Note that regardless if the skill you set for normal attack needs target selection or not, you will still need to select a target for your "Attack" command, even if the skill is a healing spell which targets allies, you will be thrown to select enemies instead of actors.
YES! Thank you!
By the way, I have a book on coding Ruby from a Humble Bundle... that's what the script's use here, right? If so, I'm assuming it's going to incredibly helpful for me.
The engine uses RGSS3 which uses Ruby, yes. I forgot which version of Ruby it uses, but I know that it is not the most recent version.
You can open the script editor and press F1 to bring up the help files for scripting. There are a hell of a lot useful information there about the structure of the RPG database classes and about the properties and methods of most commonly used classes.
And yes, that Ruby book will surely help you to find out about some more advanced methods which aren't detailed in the help files of RPG Maker. Just note that many things are not usable in RGSS3 from Ruby (like gems and rails, and other advanced stuffs), at least not without some extra scripts and files added into the RPG Maker engine.