I just implemented the setup to create the Libra skill, as outlined on Yanfly's tips and tricks page, but I am wondering if there is an way to add to the list of displayed information the possible items the party can receive from defeating the target.
I have a very limited understanding of javascript and I have attempted to reference the drops by adding to the code supplied from Yanfly, but I have not been able to figure it out.
I have tried looking through the plugin and source code files in Visual Code Studio but I have not been able to figure out how to reference the possible drops. I am using many yanfly plugins but the one I am hoping to work with here is YEP_ExtraEnemyDrops, as it allows me to set the possible drops within each enemy's notetag box.
I tried simply adding:
to the end of the supplied code and that didn't do it.
I tried swapping enemy.drops out for pretty much anything I could find in the plugin and source code files, but I couldn't figure out. I thought I was headed in the right direction when my search brought me to Yanfly's Steal & Snatch plugin, since it provides an option to include the drops into the pool of steal-able items. The plugin also provides an option to remove a stolen item from the targets drop pool.
I found the code that handles that and I'm hoping the answer lies here somewhere:
I also looked into some of the core files and found this:
As well as this:
I just don't know how to put it all together to do what I want to do, which is simply add the items in an enemy's drop pool to the Libra skill text window.
Any help with this would be greatly appreciated as enemy drops are pretty important to my current project and if the player could see them during battle it would probably make a great deal of difference in the long run.
I just checked CGMV Encyclopedia and it does in fact show the drops added through the notetags, if I can figure out how this plugin is referencing the notetag drops, I might be able to figure it out...I am too tired at this point to keep working on it but at least I have a starting point for tomorrow.
Well...just before calling it quits I looked into CGMV Encyclopedia plugin a bit and found out how to reference the items drops...
$dataEnemies[enemyId].dropItems
Now I just need to figure out how to actually draw the correct information into the text window as putting:
$gameMessage.add('Loot: ' + $dataEnemies[1].dropItems)
Just shows: Loot: [Object][Object][Object][Object][Object] all the way across the text window.
I am definitely stopping there for the night, I'm glad I was able to make some progress.
I have a very limited understanding of javascript and I have attempted to reference the drops by adding to the code supplied from Yanfly, but I have not been able to figure it out.
JavaScript:
<Before Eval>
if (target.isEnemy()) {
var id = target._enemyId;
$gameSystem.addHpGaugeEnemy(id);
var text = target.name() + '\n';
text += '\\px[100]\\c[4]HP:\\c[0] ' + target.hp;
text += '/' + target.mhp;
text += '\\px[400]\\c[4]MP:\\c[0] ' + target.mp;
text += '/' + target.mmp;
text += '\\px[700]\\c[4]TP:\\c[0] ' + target.tp;
text += '\n';
text += '\\px[100]\\c[4]ATK:\\c[0] ' + target.atk;
text += '\\px[400]\\c[4]MAT:\\c[0] ' + target.mat;
text += '\\px[700]\\c[4]AGI:\\c[0] ' + target.agi;
text += '\n';
text += '\\px[100]\\c[4]DEF:\\c[0] ' + target.def;
text += '\\px[400]\\c[4]MDF:\\c[0] ' + target.mdf;
text += '\\px[700]\\c[4]LUK:\\c[0] ' + target.luk;
$gameMessage.add(text);
var weakness = '';
var resist = '';
var immune = '';
var absorb = '';
var elements = $dataSystem.elements;
for (var i = 1; i < elements.length; ++i) {
var name = elements[i];
var rate = target.elementRate(i);
if (rate > 1) {
weakness += name + ' ';
} else if (rate < 0) {
absorb += name + ' ';
} else if (rate === 0) {
immune += name + ' ';
} else if (rate < 1) {
resist += name + ' ';
}
}
if (weakness === '') weakness = 'None';
if (resist === '') resist = 'None';
if (immune === '') immune = 'None';
if (absorb === '') absorb = 'None';
weakness = '\\c[4]Weakness:\\c[0] ' + weakness + '\n';
resist = '\\c[4]Resist:\\c[0] ' + resist + '\n';
immune = '\\c[4]Immune:\\c[0] ' + immune + '\n';
absorb = '\\c[4]Absorb:\\c[0] ' + absorb;
text = weakness + resist + immune + absorb;
$gameMessage.add(text);
}
</Before Eval>
I have tried looking through the plugin and source code files in Visual Code Studio but I have not been able to figure out how to reference the possible drops. I am using many yanfly plugins but the one I am hoping to work with here is YEP_ExtraEnemyDrops, as it allows me to set the possible drops within each enemy's notetag box.
I tried simply adding:
JavaScript:
var drops = enemy.drops();
$gameMessage.add('Loot: ' + drops);
to the end of the supplied code and that didn't do it.
I tried swapping enemy.drops out for pretty much anything I could find in the plugin and source code files, but I couldn't figure out. I thought I was headed in the right direction when my search brought me to Yanfly's Steal & Snatch plugin, since it provides an option to include the drops into the pool of steal-able items. The plugin also provides an option to remove a stolen item from the targets drop pool.
I found the code that handles that and I'm hoping the answer lies here somewhere:
JavaScript:
if (Yanfly.Param.StealDropRemove) {
Yanfly.Steal.Game_Enemy_makeDropItems = Game_Enemy.prototype.makeDropItems;
Game_Enemy.prototype.makeDropItems = function() {
var drops = Yanfly.Steal.Game_Enemy_makeDropItems.call(this);
var max = this.stealableItems().length;
for (var i = 0; i < max; ++i) {
var stealable = this.stealableItems()[i];
if (stealable.type === 'gold') continue;
if (!stealable.isStolen) continue;
if (!stealable.isDrop) continue;
stealable.isDrop = false;
var id = stealable.id;
if (stealable.type === 'item') {
var item = $dataItems[id];
} else if (stealable.type === 'weapons') {
var item = $dataWeapons[id];
} else {
var item = $dataArmors[id];
}
var index = drops.indexOf(item);
drops.splice(index, 1);
}
return drops;
};
I also looked into some of the core files and found this:
JavaScript:
BattleManager.makeRewards = function() {
this._rewards = {};
this._rewards.gold = $gameTroop.goldTotal();
this._rewards.exp = $gameTroop.expTotal();
this._rewards.items = $gameTroop.makeDropItems();
};
As well as this:
JavaScript:
Game_Enemy.prototype.makeDropItems = function() {
return this.enemy().dropItems.reduce(function(r, di) {
if (di.kind > 0 && Math.random() * di.denominator < this.dropItemRate()) {
return r.concat(this.itemObject(di.kind, di.dataId));
} else {
return r;
}
}.bind(this), []);
};
I just don't know how to put it all together to do what I want to do, which is simply add the items in an enemy's drop pool to the Libra skill text window.
Any help with this would be greatly appreciated as enemy drops are pretty important to my current project and if the player could see them during battle it would probably make a great deal of difference in the long run.
I just checked CGMV Encyclopedia and it does in fact show the drops added through the notetags, if I can figure out how this plugin is referencing the notetag drops, I might be able to figure it out...I am too tired at this point to keep working on it but at least I have a starting point for tomorrow.
Well...just before calling it quits I looked into CGMV Encyclopedia plugin a bit and found out how to reference the items drops...
$dataEnemies[enemyId].dropItems
Now I just need to figure out how to actually draw the correct information into the text window as putting:
$gameMessage.add('Loot: ' + $dataEnemies[1].dropItems)
Just shows: Loot: [Object][Object][Object][Object][Object] all the way across the text window.
I am definitely stopping there for the night, I'm glad I was able to make some progress.