# Custom Parameters - v1.5 (22/04/2018)

#### Sixth

##### Veteran
- Script:

- Demo:
Nahh, not really!

Custom Parameter Display in the status menu:

- Author's Notes:
Just another script for making custom parameters.
No one can say that I did not write enough instructions for this script!
The instructions are 3 times longer than the actual script, not because it's hard to use, but because there are a lot of (optional) features included in it! >.>
Ohh, and don't watch the movie called "The Signal"! Ohh, man, never seen so many questions unanswered and such a cliffhanger ending in my entire life! o.o
This was totally related, right?

Last edited:

#### Rikifive

##### Bringer of Happiness
I see the script got updated!

I'm kinda confused by that wall of text of explanation. =P

I'll try toying with this. =P

<removed>

Or forget about all of this ~ I see how that works. ^^

Though I have a question ~ how to make an equipment/state, that raises a custom parameter by let's say 10%?

I know I could use <maxdmg: +10> to raise MAX DMG by 10, but what if I'd want to raise it by 10%, so that it would be counted like:

TOTAL MAX DMG = BASE ([@actor.param_base] coming from :default value) + BONUS PTS ([@actor.param_plus] from equipment) + BONUS RATE ([@actor.param_equip_rate] from equipment) + BONUS RATE ([@actor.param_rate] from states)

Should I use formulas? =P

How the maths look like exactly?

Sorry if this is confusing. =P

Last edited by a moderator:

#### Sixth

##### Veteran
I am not sure that I get what you want.

Migth be the formatting, it looks kinda bad on my mobile.

Anyway, if you use "actor.spi" anywhere, it will count everything, the base, the equips, the states, and so on, all of these are added together automatically. The actual values gained from equips, states, etc are not separated, you will have to make your own methods for that. To get the base value (from the actor object only), you can get the id of the actor and use it in \$data_actors[ID].spi, for example. This gets the base value from the actor object only.

This works the same for equipment and states, just get their object and call .spi on them.

But yes, you will either need formulas or custom methods. I suggest making you own methods and use those, they are faster than the eval formulas.

Using "(user.spi * 0.1).to_i" will get 10% of the actor's total SPI in integer. Separating the values gained by different objects will need new methods.

Sorry if this seems a bit confusing, kinda hard to write codes without my laptop. Will check it when I get home, and will post some concrete examples.

#### Rikifive

##### Bringer of Happiness
I see ~ that would require toying with default stuff, which I'm not good at. =P

But it's not that important~

"(user.spi * 0.1).to_i"  ~ I was thinking about this, but if I'm not mistaking, equipping a second part of equipment with the same multiplier would multiply the previous one as well, right?

For example:

- my base SPI is 100.

Equips item with "(user.spi * 0.1).to_i"  #=> 100 + (100 * 0.1) = 100 + 10 = 110. OK!

Equips item with "(user.spi * 0.1).to_i"  #=> 110 + (110 * 0.1) = 110 + 11 = 121. Hmm.. ~ technically that's how it should work... I guess...

Actually I'll give it some tests and see what will be happening with bigger values and such~

Or even worse ~ I'm receiving a Stack Level Too Deep Error.

Is it because the value changes forever?

For example I have 100 SPI

Item raises SPI by 10% using a method:

def maxdmg_rate(user)
return user.maxdmg * 0.1 # ~~SPI in our example
end

BUT when I equip this item, then SPI raises, so the bonus parameter is recalculated, which basically results in endlessly multiplying itself.

That's why?

Hmmm... But I always could make a new parameter just to handle the rate right?

For example

"maxdmg" :default => "user.atk * 0.8 * user.maxdmg_rate"

and then:

"maxdmg_rate" :default => "1"

and then multiply the maxdmg value by adding maxdmg_rate bonuses to equipment/states, correct?

But is it safe? Would that be good for performance and such?

Last edited by a moderator:

#### Sixth

##### Veteran
Yeah, you can't base a bonus on the same parameter that way, that will result in a loop, like you already noticed.

You can base any bonus on other parameters safely thou using that method.

But why would you have a custom param for maximum damage separately from the damage parameter?

You have the value of the damage parameter. That parameter got an editable maximum allowed value, and an editable minimum value. You can add bonuses for the minimum and maximum values the same way, so there should be no reason to make a separate parameter for maximum damage, unless you use that for an entirely different purpose.

Anyway, here is how you can make a base percentage bonus value based on the same parameter:

def base_percent(user,cprm,percent="0.1",round_it="true")
if user.is_a?(Game_Actor)
val = user.actor.cparam(cprm,user) # Base cparam value (Actor object)
val += user.class.cparam(cprm,user) # Class cparam value (Class object)
else
val = user.enemy.cparam(cprm,user) # Base cparam value (Enemy object)
end
val *= percent.to_f
val = val.to_i if round_it == "true"
return val
end

In this method, I just get the base value of the parameters directly from the objects instead of getting the whole value.

This negates the loop problem, since it gets the values from another method, so it won't be a recursive loop, and it gets you the values you requested, only the base value.

Additionally, you can add the parameter gain from the script calls as well (those are permanent changes, so they can be considered as part of the base value, right?) if you want.

That would look like:

def base_percent(user,cprm,percent="0.1",round_it="true")
if user.is_a?(Game_Actor)
val = user.actor.cparam(cprm,user) # Base cparam value (Actor object)
val += user.class.cparam(cprm,user) # Class cparam value (Class object)
else
val = user.enemy.cparam(cprm,user) # Base cparam value (Enemy object)
end
val += user.cparam_bonus(cprm) # The cparam value gained from script calls
val *= percent.to_f
val = val.to_i if round_it == "true"
return val
end

The above method would add the values gained from these script calls as well.

It is highly unlikely that your enemies will gain parameters from the script call (unless you actually do that in your game), so if you want, you can put it in the Game_Actor part only. I note this, because, by default, each enemy you encounter will be a new Game_Enemy instance, so all these parameter gains from the script call would be reset for each enemy. Although it can be good in some evented battles, I guess.

To use this method, you must place it into the module for your custom methods in this script (named CustomParamMethods, found right below the parameter setting part).

After this, you can simply note-tag your equipment and states (only these, otherwise, you will get into a loop again!) with the following:

<dex method: base_percent, dex, 0.15>
<dex value update>

This note-tag example would make the equipment/state have 15% DEX bonus based on the base value of the actor's/enemy's DEX (without equipment and state bonuses).

I think this is what you wanted, right?

You can use what you suggested, another custom parameter to handle the percentage values. I wouldn't do this if it is not necessary, and I think it is not.

As for performance, if possible, use custom methods instead of string evals (formulas). Their usage is actually the same (you need to write the logic in code in both cases), but the method usage is quicker than the eval one. The only minor difference is the note-tag used for them, but I think, it is still easy to use (even easier, considering the fact that you only need to put in the method name and the arguments you want versus the whole code).

Overall, you won't notice much difference unless you call the custom parameter in every frame (in some rare cases, that is inevitable), that might be noticeable, but I never really tested. It is proven that running an eval formula (strings evaluated during runtime) is slower than running a method which is already defined on start-up (mostly noticeable with longer/more complex strings/methods), that's why I always note that using your own custom methods is the best thing to do if you can choose between eval and normal method usage.

#### Rikifive

##### Bringer of Happiness
But why would you have a custom param for maximum damage separately from the damage parameter?

I'm not sure what you mean ~ was that possible (excluding formula box)? =P

The thing with the damage in my game is like this:

Min DMG and Max DMG are two different values ~ their base value is based of atk parameter and is changed with equipment and stuff like this:

There was a wall of text, so I decided to replace it with images ~ they'll explain that even better:

<edit> Tried to use spoiler - it broke - sorry, but I'm just not going to use them ~ What a terribly programmed text editor =/ </edit>

Same goes with Magic Power ~

As you can see, the equipment changes the damage's variance in many, many ways. Generally I'll be not using damage formulas that much ~ everything will be scripted and my own calculations will be put. (You probably know, that I'm planning to write my own battle system~)

Also, skills etc. will deal % of damage~ for example a skill, that will have 200% phys dmg will deal 30-60 damage, assuming, that actor currently has 15-30 damage.

So that's why I asked for ~ as example let's take cutting off the minimum value by 50%.

Anyway ~ I see ~ I'll try few things and even if- it's not that important.

Thanks~! (=

Last edited by a moderator:

#### dii

##### Villager
Hi, before I will test it I would like to ask if self.cha (if I make a custom param charisma) will work if I use it in a different script to evaluate something? I wish to replace self.mp with self.cha ( or any other custom param I will create)

P.S. Riki bardzo podobają mi się twoje equip sceny

Last edited:

#### Sixth

##### Veteran
Assuming you are doing that in the correct class(es), yes, it should work.
You can also replace it by using 'mp' for the setting key of a custom parameter, in case you want to setup what it does in those settings instead of directly rewriting the mp method. But if you do that, some note-tag from other custom scripts dealing with MP related stuffs can interfere with your new mp method.

I just made a very basic status screen edit to display these custom parameters in the status menu.
I will link it in the opening post, in case someone needs it. Can speed up the testing of these parameters, if nothing else.

#### dii

##### Villager
Quick replay. Hmm I try to better explain it later. I wish to replace self.mp that is in the different sript. Different one uses this to eval something and I hoped that after instaling your script I will be able to go to the other script guts I choose in the rpg maker and replace self.mp with self.custom_param_I_made in not your script THX for update, I will be testing it later in the week.

### Latest Profile Posts

Another Friday and another Zoom call that could have been an email. Working from home is awesome.
Finished with the semester; finally have some time to play around with MV
Started work on the fishing Mini-Game
The Dark Toon art style is now available as Steam branches. (Both for the main game and the demo)

There are 2 versions. One only affects combat, cutscene, and portraits. The other one changes more.
So, technically, the game now has 7 versions on steam.
ON ITCH