Hello all.
I'm working on a steal skill plugin that reads the enemy drops instead of requiring any notes added in the enemy or troop fields.
After a few weeks of working on it, I finally got an item to show up in the player's party. Only problem is, it gives the player all the drops the troop has, as opposed to giving them one item. I've played around with the code a bit as you can see in the comments
I'm working on a steal skill plugin that reads the enemy drops instead of requiring any notes added in the enemy or troop fields.
After a few weeks of working on it, I finally got an item to show up in the player's party. Only problem is, it gives the player all the drops the troop has, as opposed to giving them one item. I've played around with the code a bit as you can see in the comments
Code:
Game_Enemy.prototype.makeStealDrops = function () { return this.enemy().dropItems.reduce(function(r, di) { if (di.kind > 0) { return r.concat(this.itemObject(di.kind, di.dataId)); } else { return r; } }.bind(this), []); };Game_Troop.prototype.steal = function(){ var items = this.makeStealDrops(); $gameMessage.add("Testing 1 & 2 "); //debug line items.forEach(function(item) { $gameParty.gainItem(item, 1); });};Game_Troop.prototype.makeStealDrops = function() { return this.aliveMembers().reduce(function(r, enemy) { return r.concat(0, 0, enemy.makeStealDrops()); }, []); };////// This one doesn't work but doesn't crash///*Game_Troop.prototype.makeStealDrops = function() { return this.aliveMembers().reduce(function(r, enemy) { return r.splice(0, 0, enemy.makeStealDrops()); }, []); };*/ /////// This one crashes the game with undefined function error////*Game_Troop.prototype.makeStealDrops = function() { return this.aliveMembers().reduce(function(r, enemy) { return r.inject(enemy.makeStealDrops()); }, []); };*/