Firstly, "1 / 100" will not work, because it will be rounded. Insteand of (1 + 1 / 100) use
1.01 . For having values after the point, you have to use Float objects, that include the "." in their declaration.
Secondly, ruby hasn't the "inject" method you used there, have you declarated it for the Range class?
class Range
def inject(n = 0)
each { |value| n = yield(n, value) }
n
end
end
Third, you should make your coding more clearly, all that code is a really mess, hehe. Do things like this:
hp = 35 + 5 * base_maxhp
hp_factor = $hp_factor[$data_classes[@class_id]]
hp_factor *= (1..base_maxhp).inject {|a, b| a + b}
hp_factor *= 1.01
[[hp + hp_factor, 1].max, 9999].min
It will look much more clear and understandable, and also easy for debuging.
Well, about your problem. The NoMethodError for NilClass is a really common error, just get used to it, if you script you will see it a lot. That error says that it can't call the method "*"(multiply) for a NilClass, or in other words for a non declared object.
Maybe you have some trouble with the inject method. Or maybe $hp_factor[$data_classes[@class_id]] is returning this Nil object, because $hp_factor is bad declared. It is a Hash? I see it difficult to have as index value a RPG::Class object, the result from "$data_classes[@class_id]". You should use @class_id directly. I don't know what do you want to do, if you explain a bit more the situation, it would be easier.