Help with Todd's Difficulty Selection

I am using todd's Difficulty Selection script, contained in this post (not a separate download) http://forums.rpgmakerweb.com/index.php?/topic/2789-difficulty-selection/?p=99001

I see from a post that Todd has now more or less retired from scripting, which leaves a problem I posted about unresolved, and so am wondering if anyone else can help.

When you select a difficulty other than 'Normal' the script multiplies all enemy stats, Exp gained and gold dropped by a percentage.  The problem is that this means that the player is told they have just gained e.g. 28.5899952 exp and 30.5 gold.

I would like to be able to show this as rounded figures.  deilin also spotted this and proposed the following:

since you are multiplying decimals, you are getting decimals in outcomes. You need to add some .to_i if possible.

class Game_Enemy < Game_Battler #-------------------------------------------------------------------------- # * Get Base Value of Parameter #-------------------------------------------------------------------------- def param_base(param_id) case $difficulty when 0 (enemy.params[param_id] * TODDDIFFICULTY::EASYM).to_i when 1 enemy.params[param_id] when 2 (enemy.params[param_id] * TODDDIFFICULTY::HEROICM).to_i when 3 enemy.params[param_id] * TODDDIFFICULTY::HARDM else enemy.params[param_id] end endendor in the other case:

#--------------------------------------------------------------------------113. # * Get Base Value of Parameter114. #--------------------------------------------------------------------------115. alias todd_difficulty_gmen_param_base param_base116. def param_base(param_id, *args)117. n1 = todd_difficulty_gmen_param_base(param_id, *args)118. n2 = case $game_system.todd_difficulty119. when 0 then TODDDIFFICULTY::EASYM120. when 1 then 1121. when 2 then TODDDIFFICULTY::HEROICM122. when 3 then TODDDIFFICULTY::HARDM123. end124. return (n1 * n2).to_i125.endI think the first part of the suggestion is for the earlier version of the script, as mine lacks that section entirely, and I have tried altering what he suggests for line 124, but it still returns large decimals.

Does anyone have any idea how this might be fixed?

Thanks
Well, that section of code only deals with enemy parameters. Are your enemy parameters (I suppose, visible through damage) still coming back with decimals?


To remove decimals in gold, exp and drop items, you would need to make the same .to_i change to those new methods.
There is no way to see the enemy stats in-game so I can't answer your first query, except to say that damage dealt to them is shown in round numbers, so I suppose the answer is yes.

For the gold etc., the only place I can find the piece of code

[SIZE=10pt]return n1 * n2[/SIZE]

is where deilin refers to it.  I am, therefore, unsure how to change things elsewhere.
That method (return n1 * n2) is for calculating enemy params ONLY. It has nothing to do with the gold calculation.


On the next page at that link, is an addition for adjusting gold, exp and inventory items. The methods are called exp, gold and make_drop_items. In each of those methods, the quantity is multiplied by a value, depending on the difficulty setting. You need to make the same .to_i changes in each of those methods. The ones you've included in your post above are already done. You have to do the rest.
This is so shaming, but I cannot get this to work.  I have been play testing it in what the script calls Heroic as that multiplies by 1.5, so reveals any problems.  The script section for parameters and exp (as that is the next thing to be varied) is as follows:

class Game_Enemy < Game_Battler #-------------------------------------------------------------------------- # * Get Base Value of Parameter #-------------------------------------------------------------------------- alias todd_difficulty_gmen_param_base param_base def param_base(param_id, *args) n1 = todd_difficulty_gmen_param_base(param_id, *args) n2 = case $game_system.todd_difficulty when 0 then TODDDIFFICULTY::EASYM when 1 then 1 when 2 then TODDDIFFICULTY::HEROICM when 3 then TODDDIFFICULTY::HARDM end return (n1 * n2).to_iend #-------------------------------------------------------------------------- # * Get Experience #-------------------------------------------------------------------------- def exp case $game_system.todd_difficulty when 0 enemy.exp * TODDDIFFICULTY::EASYEXPM when 1 enemy.exp when 2 enemy.exp * TODDDIFFICULTY::HEROICEXPM when 3 enemy.exp * TODDDIFFICULTY::HARDEXPM end endAdding .to_i to the line for parameters works without any problem.  However, adding it to any line in the Get Experience section reduces the exp awarded to that of the 'Normal' selection i.e. 19 instead of the 28.5 it displays when the script is unmodified.

Please can someone tell me what I should be doing.  I feel such a fool on this, but I can't think of any more variations of where to put the .to_I

EDIT

When I stopped thinking "this is a script, I don't know about scripts" and started thinking "that's just an algebraic formula" I could immediately see what to do, so now fixed.

Just in case anyone else every has this problem:

    when 2
    (enemy.exp * TODDDIFFICULTY::HEROICEXPM).to_I

Yup, just put in the ( ) before the .to_I
This thread is being closed, due to being solved. If for some reason you would like this thread re-opened, please report this post and leave a message why. Thank you.

Original thread: https://forums.rpgmakerweb.com/threads/help-with-todds-difficulty-selection.19826/