Help with Yanfly Monster Level script

Ishan3083

Villager
Member
Joined
Nov 6, 2015
Messages
9
Reaction score
0
First Language
English
Primarily Uses
Hello,


I've decided to start using Yanfly's Monster Levels script which is amazing btw, but I've come across a little problem/bug not sure what it is.


My issue is this, in my game I'm trying to simulate things realistically from an economy stand point. For example, player fights slimes and loot dropped 


would be gel or slime jelly which could be sold or kept for crafting purposes, no gold drops what so ever unless off a humanoid mob like a goblin.


So the main source of economy would come from the player acting as a hunter or huntsman by killing mobs and gathering various materials to which


at player discretion uses said materials to sell off and make money or keep and craft items to make well more money. Now that's just a bit about how


my game works. The problem I'm encountering is this, no matter how I try to tweak the level parameters for the monsters or adjust it in the script database,


after lvl.1 all monsters drop some quantity of gold which goes against what I'm trying to do.


I have made sure monster gold drop in database is 0. If monster is lvl 1 no gold drops but as soon as the monster gains levels, they drop gold.


Question:


Can someone please help me out with this script in how I could possibly configure things to only allow to drop off monsters when they actually have gold as


a drop to begin with?


I add the script unedited as an attachment, hope it opens.


Default Settings:


 These settings adjust the default growth rates (not the base stat formula)
    # for each stat. These are the values that will exist for each enemy unless
    # defined otherwise by the tags inside their noteboxes.
    DEFAULT_GROWTH ={
    # ParamID => [:param, per%,       +set],
            0 => [:maxhp,       0.15,            50],
            1 => [:maxmp,      0.10,            10],
            2 => [  :atk,           0.05,              5],
            3 => [  :def,           0.05,               5],
            4 => [  :mat,          0.05,               5],
            5 => [  :mdf,          0.05,               5],
            6 => [  :agi,           0.05,               5],
            7 => [  :luk,           0.05,                5],
            8 => [ :gold,          0.15,               10],
            9 => [  :exp,          0.05,               10],
    } # Do not remove this.


I changed the +set under gold to 0 to prevent what I thought was gold increase per level. Didnt work.


# The following hash will adjust each of the formulas for each base stat.
    # Adjust them as you see fit but only if you know what you're doing.
    #   base  - The base stat from the enemy database.
    #   per   - Growth rate which has not been yet converted to a percent.
    #   set   - Set growth rate. Modified
    # Default:   "base * (1.00 + (level-1) * per) + (set * (level-1))"
    STAT_FORMULA = "base * (1.00 + (level-1) * per) + (set * (level-1))"


I also tried changing the formula around a bit still same result, by changing the * per to * set.

View attachment Monster Leveling.txt
 

mlogan

Global Moderators
Global Mod
Joined
Mar 18, 2012
Messages
15,354
Reaction score
8,533
First Language
English
Primarily Uses
RMMV
I've moved this thread to Script Support. Please be sure to post your threads in the correct forum next time. Thank you.
 

bgillisp

Global Moderators
Global Mod
Joined
Jul 2, 2014
Messages
13,522
Reaction score
14,255
First Language
English
Primarily Uses
RMVXA
What happens if you change the line under #8 in the hash to this?


 8 => [ :gold,          0.0,               0],
 

Ishan3083

Villager
Member
Joined
Nov 6, 2015
Messages
9
Reaction score
0
First Language
English
Primarily Uses
It seems that when I do change Line 8 => [ :gold,          0.0,               0],  It goes to some sort of default numeric value of 5. So a level 1 gives 0g but a level 2 gives 5g, Level 3 10g,


so and so forth...
 

bgillisp

Global Moderators
Global Mod
Joined
Jul 2, 2014
Messages
13,522
Reaction score
14,255
First Language
English
Primarily Uses
RMVXA
That shouldn't be happening. If line 8 is all 0's, then the equation the program is using is 0*the gold your enemy is dropping + 0, which is 0. Something else is giving it the 5 per level, but it doesn't sound like its this script.


Still, I think there is a way to fix it. Add this as a new script at the bottom of all of your scripts:

class Game_Enemy < Game_Battler


    def gold


        enemy.gold


    end


end



That will restore it to the defaults and override all scripts that affect the G enemies drop.
 

Ishan3083

Villager
Member
Joined
Nov 6, 2015
Messages
9
Reaction score
0
First Language
English
Primarily Uses
Alright entered the script. It worked. But it also prevents the humanoid monsters from scaling up their respective gold drops. But I think this will have to do.


I can just create a "loot bag" that will include various gold drops in addition to any items or gear said humanoids will be dropping as well.


Thank you so much for you help.
 

bgillisp

Global Moderators
Global Mod
Joined
Jul 2, 2014
Messages
13,522
Reaction score
14,255
First Language
English
Primarily Uses
RMVXA
Not a problem. You could edit the line that says enemy.gold in the snipped I provided to be a formula involving the enemies level if you want it to scale up with level. For example, if you want it to be a 5% additive increase with level use this:


(enemy.gold * (1 + 0.05 * (enemy.level - 1))).to_i


Tweak the 0.05 to be whatever you want the increase to be.
 
Last edited by a moderator:

Ishan3083

Villager
Member
Joined
Nov 6, 2015
Messages
9
Reaction score
0
First Language
English
Primarily Uses
OMG thanks so much! I'll give it a try.
 

bgillisp

Global Moderators
Global Mod
Joined
Jul 2, 2014
Messages
13,522
Reaction score
14,255
First Language
English
Primarily Uses
RMVXA
Let me know if that works (or doesn't work), as I wasn't able to test it (I'm at work), but in theory it should work.
 

Ishan3083

Villager
Member
Joined
Nov 6, 2015
Messages
9
Reaction score
0
First Language
English
Primarily Uses
Uh oh, the game crashed when I tried it.
 
Last edited by a moderator:

bgillisp

Global Moderators
Global Mod
Joined
Jul 2, 2014
Messages
13,522
Reaction score
14,255
First Language
English
Primarily Uses
RMVXA
Just took a break and tested it, seems to work. Maybe a ( didn't copy over? Anyways, try replacing my code snipped completely with this:

class Game_Enemy < Game_Battler


    def gold


       (enemy.gold * (1 + 0.05 * (enemy.level - 1))).to_i


    end


end

If you get an error message still, please let me know what the message is.
 
Last edited by a moderator:

Ishan3083

Villager
Member
Joined
Nov 6, 2015
Messages
9
Reaction score
0
First Language
English
Primarily Uses
Another error message.


Line 9 No method error Undefined method 'level'
 

bgillisp

Global Moderators
Global Mod
Joined
Jul 2, 2014
Messages
13,522
Reaction score
14,255
First Language
English
Primarily Uses
RMVXA
That should not occur unless you disabled the enemy level script completely. Make sure this is below the enemy level script (bottom of all scripts is best). If that is the case and you're still getting the error, you'll need to post a list of all of your scripts, as you have a conflict now, as that code snippet worked for me in my project when I put it last in my scripts (but still above Main).


Anyways, check that out and see what happens. I will be back on sometime tomorrow afternoon my time zone, so will return to this more then unless someone else is able to fix it first.
 
Last edited by a moderator:

Sixth

Veteran
Veteran
Joined
Jul 4, 2014
Messages
2,162
Reaction score
822
First Language
Hungarian
Primarily Uses
RMVXA
Yanfly's script functions properly. 


If you have set everything for the :gold option to 0 in the settings, you should not see any increase in gold at all for any enemies.


Even if you only set the additive bonus to 0 (the second option), enemies with 0 gold gained in the database should not give any gold, regardless of their levels.


In short, the extra gold is certainly not the work of Yanfly's script.


But I remember that a lot of difficulty changing scripts (Easy, Normal, Hard, etc) overwrite or alias the same method for changing the amount of gold dropped.


If you use one of these, make sure to set up the settings of that script accordingly too. If that doesn't help, remove the difficulty script temporary and test again.


If after removing, the gold gained is correct (so it stays on 0 for enemies with 0 gold gained in the database), than you have found the conflicting script. If it still won't work properly, you got another script altering the same method. In this case, do a full script list search (CTRL+SHIFT+F) for this line:


def gold


List all the scripts with this line here (excluding the default scripts), one of them is the culprit. 


Ohh, and make sure to double-check the gold gained in the database for your enemies. I know it sounds obvious, but it wouldn't be the first time people forgetting to check the most simple solution.
 

bgillisp

Global Moderators
Global Mod
Joined
Jul 2, 2014
Messages
13,522
Reaction score
14,255
First Language
English
Primarily Uses
RMVXA
Right, that's what I suspect too, because unless the formula for gold dropping was edited, it should be 0 all across the board with the set up used earlier. My snippet is a short term solution though in case that conflict cannot be found, but finding the conflict would be better if possible.
 

Ishan3083

Villager
Member
Joined
Nov 6, 2015
Messages
9
Reaction score
0
First Language
English
Primarily Uses
Alright so the error is happening in line 9 of bgillisp's snippet.


I did the (CTRL+SHIFT+F) and this is what popped up:


Game_Enemy (88)  :     def gold


Game_Party (397)   :     def gold_double?


Game_Troop (190)  :     def gold_total


Game_Troop (196)  :     def gold_rate


Yanfly Mob Lvls (503) :   def gold


bgillips fix (7)  :               def gold


Only two that modify gold looks like Yanfly's monster levels and bgillips.


But the initial snippet made:


class Game_Enemy < Game_Battler


    def gold


        enemy.gold


    end


end


Worked fine for removing unnecessary gold from dropping but removed the increase a monster should get at different levels if the monster had gold


in its database to begin with.


Could it be the order the script is in? I have the both of them at the bottom of the list. bg's being last under yanfly's.


Thank you for continuing to help me with this issue you all. :)
 
Last edited by a moderator:

bgillisp

Global Moderators
Global Mod
Joined
Jul 2, 2014
Messages
13,522
Reaction score
14,255
First Language
English
Primarily Uses
RMVXA
I don't see any other scripts then that mess with gold. Though, for level to be undefined, then Yanfly's script has to be disabled, as that is the script that defines level. Did you disable the script somehow?


Here is something to test and see if you can call level some other way. Change your damage formula for attack (back up the old one first) to this:


50 - b.level


If that throws an error or does 0 damage when you attack a low level enemy (make the enemy level 1 for purposes of testing, and set variance to 0), then somehow the define for level in Yanfly's script is not working, which means the script is disabled somehow. You'll need to reinstall that script to fix it.


The only other option is one of your other scripts has completely rewritten how Game_Enemy is used, which would also disable Yanfly's level script from ever working (and hence the error). We'll need a FULL list of all your scripts to have any shot of finding that though.
 
Last edited by a moderator:

Ishan3083

Villager
Member
Joined
Nov 6, 2015
Messages
9
Reaction score
0
First Language
English
Primarily Uses
Sorry for late response, been real busy at work and didn't have much time to work on my game. So I changed the damage formula to 50 - b.level as instructed and there was no crash.


Damage Calculated correctly from what I could tell.


Also in addition, I changed the position of the script to 2nd in the list and there was no change.


I also put a note tag in the note box of the monster in the database and I entered <GOLD: -100% per level> as indicated in the script to


enter if I wanted to change the outcome of a leveled up monster. I gave said monster 600xp and 0g as a reward for defeat.


First fight went well, but then on the second fight it gave me 20g <--not a good sign, then +/- 600xp and removed the 600xp my character gained from the fight before. Almost like the section that says GOLD in the list is actually pulling XP rather than gold.


I will changed all default numbers of the script to 0 and slowly go down the list to see which returns the gold increments of 5.
 
Last edited by a moderator:

Ishan3083

Villager
Member
Joined
Nov 6, 2015
Messages
9
Reaction score
0
First Language
English
Primarily Uses
After the test, it would seem the gold and xp values are switched on the list of edits provided in the script. I had changed the xp modifier to 5 and once I removed it and made it 0 the monsters at any level no longer dropped gold. I found the error starting on line 487 in the Monster level script when it started to alias gold and xp. It had the assigned numbers swapped. 8 which was the def for gold was in the alias for xp and 9 was in the gold alias. I swapped them out and they both work fine now.
 
Last edited by a moderator:

Users Who Are Viewing This Thread (Users: 0, Guests: 1)

Latest Threads

Latest Posts

Latest Profile Posts

Couple hours of work. Might use in my game as a secret find or something. Not sure. Fancy though no? :D
Holy stink, where have I been? Well, I started my temporary job this week. So less time to spend on game design... :(
Cartoonier cloud cover that better fits the art style, as well as (slightly) improved blending/fading... fading clouds when there are larger patterns is still somewhat abrupt for some reason.
Do you Find Tilesetting or Looking for Tilesets/Plugins more fun? Personally I like making my tileset for my Game (Cretaceous Park TM) xD
How many parameters is 'too many'??

Forum statistics

Threads
105,864
Messages
1,017,056
Members
137,573
Latest member
nikisknight
Top