Failing at being Crafty with Stats...

I have failed at the one thing I have a tiny amount of experience with to be able to handle. I thought. RIP.

Alright, here is the issue. While it is rather simple and trivial I am brainless enough to solve this conundrum.

I am using Nelderson'
s Extra Stats script, and I was rubbing my hands at the thought of what I could have done with them. The first was simple, Boosting a character's stats through the xstats given by Nelderson.
I am no novice, and I know a tiny bit of what is needed, although, I have gone and fetched the snippet where the base Parameters are defined and calculated(I want to hope), and attempted to make an edit so that it would have factored a very short and simple formula to provide such boosts.

(Sneaky link to Nelderson's Script: https://forums.rpgmakerweb.com/index.php?threads/n-a-s-t-y-extra-stats.998/)

What happens... As soon as I boot up the game, Is this. https://i.gyazo.com/952ec5f8d39f3f4105a037b9997c1441.png
However, I know where the problem lies-I just cannot think of a way to not cause this error.
This is the snippet I altered, please forgive the mess I have created. Some of you might be bashing your heads against the wall. Please do. https://i.gyazo.com/1870826b753648d70601fc9addc2d7f4.png

How would I go about making the edits work? I am certain those of you with expert scripting knowledge easily understood what I am trying to do.

In short, in a "Lame man's terms"(Blame TFS Goku), I am attempting to convert a portion of these xstats into bonuses to 6 of the 7 basic stats. (No affecting Luck. No reason to.)

I would immensely appreciate any help with this conundrum as it is extremely bothersome.

~Daena Grey
Hi there,

First of all, you made a syntax error: If you use multiple "if" statements, you have to finish each of them with an "end". Alternatively, you can replace "else if" with "elsif":
Code:
if param_id == 0
  ...
else
  if param_id == 1
    ...
  end
end
Code:
if param_id == 0
  ...
elsif param_id == 1
  ...
end
You could also use a case-statement, which is useful when you want to compare a variable to multiple different values:
Code:
case param_id
when 0
  ...
when 1
  ...
else
  ...
end


Apart from that, you should probably remove the square brackets from your
extra = ...
commands. Square brackets are used to create Arrays (lists of multiple entries), which have different functionalities (like [...].max can be used to calculate the maximum of multiple values) but can't be added directly to a number. If you want to use brackets here, you should use round brackets instead.


Right now your code would also disregard the minimum and maximum parameter value, since this line
[[value, param_max(param_id)].min, param_min(param_id)].max.to_i
is no longer the last statement in your method. I'd suggest to remove it and replace your result with
[[value + extra, param_max(param_id)].min, param_min(param_id)].max.to_i
instead.

Since you add the "extra" to your "value" after the latter has been multiplied with the battlers parameter rate, your "extra" will not be affected by features that change a parameter by a certain percentage. I'm not sure if that was your intention.


(Hope this is somewhat understandable^^)
It was perfectly understandable and I owe you a Million thanks! However, one of the things you mentioned has actually halted me upon applying the changes, rather immediately.

I have changed the snippet to a Case-When scenario, which I deem to be probably the more efficient of the three, Hoping I am assuming right, buuuuut.

Since you add the "extra" to your "value" after the latter has been multiplied with the battlers parameter rate, your "extra" will not be affected by features that change a parameter by a certain percentage. I'm not sure if that was your intention.

That was really not my intention, not exactly. I would like for the total amount to be the "Base", including the Extra deriving from stats like Strength, Vitality Etc. which then can be multiplied by other factors such as buffs, passives etc without leaving the Extra to be doomed to always be a flat amount and contribute little to nothing.

So, with that explained... How would I go about doing that? Would I have to add the Extra on top of the default calculation, after they're done, or somewhere in the middle, or even rather, before all that? Thank you so much though, I dun goofd really hard there... ( ^ - ^ " )

~Daena Grey


Edit: I keep getting more errors which seem to be more hassle than it is worth... So It seems I am scrapping the idea-but thank you so much, still! That issue was indeed solved... ( x - x )
You can do the extra addition in the param_base method instead.
Spoiler
Code:
  def param_base(param_id)
    base  = self.class.params[param_id, @level]
    case param_id
    when 0; extra = self.xstats.vit * 15
    when 1; extra = self.xstats.wil * 7
    # And so on....
    else; extra = 0
    end
    return base + extra
  end
Note that I have no idea if the method actually looks like this in XP or not, I don't own RPG Maker XP, so I took the method from Ace.
The base is basically the original line, and you add the extra value to that.
Make sure to have that else branch if you don't use all of the params for these extra calculations, or you will get an error with that code when an excluded param is calculated.
This will account for the param limits automatically, as well as any other calculations for the params, like buff rate, and param feature changes.

Original thread: https://forums.rpgmakerweb.com/threads/failing-at-being-crafty-with-stats.83750/