Custom aftermath for Yanfly's Victory Aftermath

Michael Caiola

The Stone Bull
Veteran
Joined
Sep 14, 2016
Messages
392
Reaction score
76
First Language
English
Primarily Uses
I'd like to add a custom item to the "drops" screen of Yanfly's Victory Aftermath.


I'd like one of the "drops" to check if variable ArrowsRetrieved (ID 76) is greater than 1, and if it it is, display the text, "Retrieved x arrows"  with X being the variable, and run comment event 44. If it can't be done as a drop, I know Victory Aftermath allows for extensions. I'd be fine with it being an extension.


Thanks in advance to anyone who helps!


EDIT: Come to think of it, I'd like to be able to do this for more than one thing, if possible.
 
Last edited by a moderator:

bgillisp

Global Moderators
Global Mod
Joined
Jul 2, 2014
Messages
13,528
Reaction score
14,261
First Language
English
Primarily Uses
RMVXA

I've moved this thread to Plug-In Requests. Please be sure to post your threads in the correct forum next time. Thank you.

 

Magnus0808

Software Developer
Veteran
Joined
Feb 2, 2019
Messages
147
Reaction score
166
First Language
Danish
Primarily Uses
RMMV
Here you go. This should do it. You just have to add the variable id and the text you wish to be played as a plugin parameter e.g. 72 "Retrieved %1 arrows"; 5 "This is another variable with value: %1";

After a victory the common event specified as a plugin parameter will be played.

If anything does not work as you wanted please let me know :)

Code:
//=============================================================================
// CustomAfterMath_SpecialLoot.js
//=============================================================================

/*:
 * @plugindesc This plugin is an extension for YEP_VictoryAftermath. That allows
 * to add special loot to the post victory drop table.
 * @author Magnus0808
 * @help The special items are added with this format: var1 "text1"; var2 "text2";
 * use %1 to display the value stored in the variable.
 * E.g. 76 "Retrived %1 arrows"; 2 "Cut of %1 ears"
 *
 * ------------------------
 * @param Special Items
 * @parent ---Special Items---
 * @desc This is the the special items
 * The special items are added with this format: var1 "text1"; var2 "text2";
 * use %1 to display the value stored in the variable.
 * E.g. 76 "Retrived %1 arrows"; 2 "Cut of %1 ears"
 
 * @param Common Event
 * @desc Common Event to be called after displaying items
 */
 (function() {
    
    SpecialLoot = {};
    SpecialLoot.Parameters = PluginManager.parameters('CustomAfterMath_SpecialLoot');
    SpecialLoot.specialItems = String(SpecialLoot.Parameters['Special Items']);
    SpecialLoot.specialItemsIndex = [];
    SpecialLoot.specialItemsString = [];
    SpecialLoot.commonEventID = Number(SpecialLoot.Parameters['Common Event']);
    
    var myRe = /(\d+) "(.*?)";?/g;
    var m;
    do {
        m = myRe.exec(SpecialLoot.specialItems);
        if (m) {
            SpecialLoot.specialItemsIndex.push(m[1]);
            SpecialLoot.specialItemsString.push(m[2]);
        }
    } while (m);
    
    Scene_Battle.prototype.processVictoryFinish = function() {
        this._victoryTitleWindow.close();
        BattleManager.processVictoryFinish();
        if(SpecialLoot.commonEventID){
            $gameTemp.reserveCommonEvent(SpecialLoot.commonEventID);
        }
    };


    Window_VictoryDrop.prototype.makeItemList = function() {
        if (BattleManager._rewards.gold > 0) {
          this._data = ['gold', null];
        } else {
          this._data = [];
        }
        var special = false;
        for(var i = 0; i < SpecialLoot.specialItemsIndex.length; i++) {
            if($gameVariables.value(SpecialLoot.specialItemsIndex[i]) >= 1) {
                special = true;
                var item = {};
                item.index = SpecialLoot.specialItemsIndex[i];
                item.name = SpecialLoot.specialItemsString[i];
                this._data.push(item);
            }
        }
        if(special) {
            this._data.push(null);
        }
        
        this._dropItems = [];
        this._dropWeapons = [];
        this._dropArmors = [];
        this.extractDrops();
    };
    
    Window_VictoryDrop.prototype.drawItem = function(index) {
        var item = this._data[index];
        if (!item) return;
        this.drawGold(item, index);
        this.drawDrop(item, index);
        this.drawSpecial(item, index);
    };
    
    Window_VictoryDrop.prototype.drawSpecial = function(item, index) {
        if (DataManager.isItem(item) || DataManager.isWeapon(item) ||
        DataManager.isArmor(item) || item == 'gold') return;
        
        var rect = this.itemRect(index);
        rect.width -= this.textPadding();
        this.drawSpecialItemName(item, rect.x, rect.y, rect.width);
    };
    
    Window_VictoryDrop.prototype.drawSpecialItemName = function(item, x, y, width) {
        width = width || 312;
        if (item) {
            var iconBoxWidth = Window_Base._iconWidth + 4;
            this.resetTextColor();
            var name = item.name.replace('%1', $gameVariables.value(item.index));
            this.drawText(name, x + iconBoxWidth, y, width - iconBoxWidth);
        }
    };
    

 })();
 

Attachments

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

Latest Threads

Latest Posts

Latest Profile Posts

On my journey of character rework: I had this character, she was meant to be just a princess that joins your party. And at long term she was just uninteresting... So I tweaked her to be a rebel agaisn't the royalty before meeting up with the party.

Quick tip for any other ametuer pixel artists! When trying to create a colour palette, enabling Antialiasing can speed up the process of creating different shades! Just place your lightest colour and your darkest colour next to each other, select both pixels, and stretch it out!
Revolutionizing the JRPG Industry: Knocking on Doors.

Take that, murderhobos.
Don't forget, aspiring writers: Personality isn't what your characters do, it is WHY they do it.

Forum statistics

Threads
106,054
Messages
1,018,580
Members
137,843
Latest member
Betwixt000
Top