Random Gold Variance

Status
Not open for further replies.

Silenity

Veteran
Veteran
Joined
Dec 17, 2013
Messages
677
Reaction score
271
First Language
English
Primarily Uses
RMMV
Hello.

I'd like to request a plugin that can change how much gold is dropped by an enemy.

Here's what it could look like notetagged:

<Gold: 5% 1000-1500><Gold: 10% 400-700><Gold: 50% 100-250><Gold: 75% 1-50>
Code:
<Gold: 100% 0-500>
Code:
<Gold: 50% 0-120><Gold: 1% 8000-22000>
The gold drops do not stack. So if you killed an enemy it would land on one of the Gold%s and then give you Gold = to the variance.

So if I killed a slime and it landed on the <Gold: 10% 400-700> it would give me anywhere between 400-700 gold.
 
Last edited by a moderator:

izyees

My Secret Santa
Veteran
Joined
Oct 24, 2015
Messages
248
Reaction score
67
First Language
english
please make sure you search it before requesting.
 

Silenity

Veteran
Veteran
Joined
Dec 17, 2013
Messages
677
Reaction score
271
First Language
English
Primarily Uses
RMMV
please make sure you search it before requesting.
Hmm. I looked on here and VXAce.net

I didn't see one. If you know of one, please let me know and I can get someone to close this.
 

izyees

My Secret Santa
Veteran
Joined
Oct 24, 2015
Messages
248
Reaction score
67
First Language
english
The gold drops do not stack. So if you killed an enemy it would land on one of the Gold%s and then give you Gold = to the variance.

So if I killed a slime and it landed on the <Gold: 10% 400-700> it would give me anywhere between 400-700 gold.
what the suppose of the percentage? if <Gold: 50% 400-700> it will still give you between 400-700 right?
 

Silenity

Veteran
Veteran
Joined
Dec 17, 2013
Messages
677
Reaction score
271
First Language
English
Primarily Uses
RMMV
what the suppose of the percentage? if <Gold: 50% 400-700> it will still give you between 400-700 right?
Killing an enemy would get you a 50% rate of dropping gold at all.

But that can be totally optional.

I'm more looking for the random amount aspect of it.
 

DreamX

Veteran
Veteran
Joined
May 30, 2015
Messages
816
Reaction score
826
First Language
English
Primarily Uses
Here you go:

/*: * @plugindesc v1.0 Adds gold variance. * @author DreamX * @help  If the enemy does not have any correct gold notetags, the default way will be used instead. Notetags must be in this exact same format, including spaces: <Gold: X% Y-Z> X is the percentage chance. Y is the minimum. Z is the maximum. The minimum must be equal to or less than the maximum or the notetag will be ignored. Some examples of correct notetags are: <Gold: 5% 9999-9999> <Gold: 30% 1000-1500> <Gold: 65% 1-5000>  The algorithm that decides gold rewards adds notetags sequentially from top to bottom. Any notetag with a percent that exceeds the current ratio will be ignored.  For example: <Gold: 50% 1000-1000> <Gold: 51% 2000-2000>  In this example, the second notetag will be ignored. In other words, do not exceed 100% in sum with your notetag percents.  It is fine, however, not to reach 100% in percent sums. If the sum of the percents is not 100%, there is a chance that the player may not receive any gold. The chance of not receiving gold would be 100% minus the sum of the percents. * ============================================================================ * Terms Of Use * ============================================================================ * Free to use and modify for commercial and noncommercial games, with credit. * ============================================================================ * Credits * ============================================================================ * DreamX * */var Imported = Imported || {};Imported.DreamX_GoldVariance = true;var DreamX = DreamX || {};DreamX.GoldVariance = DreamX.GoldVariance || {};(function () {    DreamX.GoldVariance.Game_Enemy_gold = Game_Enemy.prototype.gold;    Game_Enemy.prototype.gold = function () {        var variantGoldReward = DreamX.GoldVariance.getGold(this.enemy())        if (variantGoldReward !== -1) {            return variantGoldReward;        }        else {            return DreamX.GoldVariance.Game_Enemy_gold.call(this);        }    };    DreamX.GoldVariance.getGold = function (enemy) {        var correctGoldTags = enemy.note.split("\n").filter(function (note) {            return note.match("\<Gold: [0-9]{1,}% [0-9]{1,}-[0-9]{1,}\>");        });        if (correctGoldTags.length <= 0) {            return -1;        }        var goldSlots = [];        var totalPercentage = 0;        correctGoldTags.forEach(function (tag) {            var percentage = parseInt(tag.split(" ")[1].split("%")[0]);            addPercentage = totalPercentage;            if (addPercentage + percentage <= 100) {                totalPercentage += percentage;                percentage += addPercentage;                var low = tag.split(" ")[2].split("-")[0];                var high = tag.split(" ")[2].split("-")[1].split("\>")[0];                if (parseInt(high) >= parseInt(low)) {                    goldSlots.push({percentage: percentage, low: low, high: high});                }            }        });        if (goldSlots.length <= 0) {            return -1;        }        var diceRoll = Math.floor((Math.random() * 100) + 1);        var gotGoldPrize = false;        var prizeIndex;        if (diceRoll <= goldSlots[goldSlots.length - 1].percentage) {            for (i = 0; i < goldSlots.length && !gotGoldPrize; i++) {                if (goldSlots.percentage >= diceRoll) {                    prizeIndex = i;                    gotGoldPrize = true;                }            }        }        if (!gotGoldPrize) {            return 0;        }        if (goldSlots[prizeIndex].high === goldSlots[prizeIndex].low)            return goldSlots[prizeIndex].low;        return Math.floor((Math.random() * goldSlots[prizeIndex].high)                + goldSlots[prizeIndex].low);    };})();
Terms of Use: Credit DreamX
 

Silenity

Veteran
Veteran
Joined
Dec 17, 2013
Messages
677
Reaction score
271
First Language
English
Primarily Uses
RMMV
Here you go:

/*: * @plugindesc v1.0 Adds gold variance. * @author DreamX * @help  If the enemy does not have any correct gold notetags, the default way will be used instead. Notetags must be in this exact same format, including spaces: <Gold: X% Y-Z> X is the percentage chance. Y is the minimum. Z is the maximum. The minimum must be equal to or less than the maximum or the notetag will be ignored. Some examples of correct notetags are: <Gold: 5% 9999-9999> <Gold: 30% 1000-1500> <Gold: 65% 1-5000>  The algorithm that decides gold rewards adds notetags sequentially from top to bottom. Any notetag with a percent that exceeds the current ratio will be ignored.  For example: <Gold: 50% 1000-1000> <Gold: 51% 2000-2000>  In this example, the second notetag will be ignored. In other words, do not exceed 100% in sum with your notetag percents.  It is fine, however, not to reach 100% in percent sums. If the sum of the percents is not 100%, there is a chance that the player may not receive any gold. The chance of not receiving gold would be 100% minus the sum of the percents. * ============================================================================ * Terms Of Use * ============================================================================ * Free to use and modify for commercial and noncommercial games, with credit. * ============================================================================ * Credits * ============================================================================ * DreamX * */var Imported = Imported || {};Imported.DreamX_GoldVariance = true;var DreamX = DreamX || {};DreamX.GoldVariance = DreamX.GoldVariance || {};(function () {    DreamX.GoldVariance.Game_Enemy_gold = Game_Enemy.prototype.gold;    Game_Enemy.prototype.gold = function () {        var variantGoldReward = DreamX.GoldVariance.getGold(this.enemy())        if (variantGoldReward !== -1) {            return variantGoldReward;        }        else {            return DreamX.GoldVariance.Game_Enemy_gold.call(this);        }    };    DreamX.GoldVariance.getGold = function (enemy) {        var correctGoldTags = enemy.note.split("\n").filter(function (note) {            return note.match("\<Gold: [0-9]{1,}% [0-9]{1,}-[0-9]{1,}\>");        });        if (correctGoldTags.length <= 0) {            return -1;        }        var goldSlots = [];        var totalPercentage = 0;        correctGoldTags.forEach(function (tag) {            var percentage = parseInt(tag.split(" ")[1].split("%")[0]);            addPercentage = totalPercentage;            if (addPercentage + percentage <= 100) {                totalPercentage += percentage;                percentage += addPercentage;                var low = tag.split(" ")[2].split("-")[0];                var high = tag.split(" ")[2].split("-")[1].split("\>")[0];                if (parseInt(high) >= parseInt(low)) {                    goldSlots.push({percentage: percentage, low: low, high: high});                }            }        });        if (goldSlots.length <= 0) {            return -1;        }        var diceRoll = Math.floor((Math.random() * 100) + 1);        var gotGoldPrize = false;        var prizeIndex;        if (diceRoll <= goldSlots[goldSlots.length - 1].percentage) {            for (i = 0; i < goldSlots.length && !gotGoldPrize; i++) {                if (goldSlots.percentage >= diceRoll) {                    prizeIndex = i;                    gotGoldPrize = true;                }            }        }        if (!gotGoldPrize) {            return 0;        }        if (goldSlots[prizeIndex].high === goldSlots[prizeIndex].low)            return goldSlots[prizeIndex].low;        return Math.floor((Math.random() * goldSlots[prizeIndex].high)                + goldSlots[prizeIndex].low);    };})();


Terms of Use: Credit DreamX


Thanks a ton! <3 You're a beast!
 

Andar

Veteran
Veteran
Joined
Mar 5, 2013
Messages
31,359
Reaction score
7,672
First Language
German
Primarily Uses
RMMV
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.
 
Status
Not open for further replies.

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

Latest Threads

Latest Posts

Latest Profile Posts

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'??
Yay, now back in action Happy Christmas time, coming back!






Back in action to develop the indie game that has been long overdue... Final Fallacy. A game that keeps on giving! The development never ends as the developer thinks to be the smart cookie by coming back and beginning by saying... "Oh bother, this indie game has been long overdue..." How could one resist such? No-one c

Forum statistics

Threads
105,857
Messages
1,017,018
Members
137,563
Latest member
MinyakaAeon
Top