Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- //=============================================================================
- // Maliki's Attach Augments EX2 Augment Type Restrictions
- // Mal_AttachAugments_Ext2_AugRestictions.js
- // version 1.1
- //=============================================================================
- /*:
- * @plugindesc Version 1.1 Allows you to render groups of Augments unequippable
- * @author Maliki79
- * @param GlobalRestrictions
- * @desc Set of globally active restrict types separated by commas.
- *
- * @help With this Plugin Extension, YanFly's Attach Augments can now have
- * limitations placed on general Augment types that are defined by the Dev.
- * These limitations are linked to the specific Equipment being Augmented.
- *
- * The first step is to define a Augment Restrict Type.
- * This is done with the notetag:
- *
- * <augRestrictType: x>
- *
- * with x being a whole number above 0.
- * (These tags work independantly of the equip type used.)
- * You can tag anything with this tag, but the effect will only work with
- * Augmenting Items.
- *
- * To lock a set of Augments by type, use the following Script Call:
- *
- * $gameParty.addAugmentRestrictType(item, x);
- *
- * where "item" is the equipment to add the restriction to and x is the
- * Augment's restriction group number.
- * The easiest way to use this is within the Lunatic calls when adding
- * the Augment. For example:
- *
- * <Augment Attach Eval: Orb>
- * $gameParty.addAugmentRestrictType(item, 1);
- * </Augment Attach Eval: Orb>
- *
- * To remove the restriction, use the following Script Call:
- *
- * $gameParty.removeAugmentRestrictType(item, x);
- *
- * Again where "item" is the equipment to add the restriction to and x is
- * the Augment's restriction group number.
- * Example of use:
- *
- * <Augment Detach Eval: Orb>
- * $gameParty.removeAugmentRestrictType(item, 1);
- * </Augment Detach Eval: Orb>
- *
- * Note that this only restricts placing of new Augments on an equip.
- * Previously unrestricted items WILL REMAIN on the equip untill manually
- * removed.
- *
- * Added Global Restriction Types.
- * Global Restriction Types are Types you can added that will restrict Augments on
- * ALL Weapons/Armors without having to add them to each equip manually.
- * There are two ways to add these.
- * The first is by adding them to the plugin parameters.
- * This will take effect right at the start of your game and will persist until changed.
- * The second is to use the script call $gameParty.addGlobalRType(x);
- * with x being an integer abouve 0.
- * You can remove the global Restriction with the script call $gameParty.removeGlobalRType(x);
- * again with x being an integer.
- */
- var Mal = Mal || {};
- Mal.Augment2Parameters = PluginManager.parameters('Mal_AttachAugments_Ext2_AugRestictions');
- Mal.Param = Mal.Param || {};
- Mal.Param.A2_Global = [];
- var a2Params = Mal.Augment2Parameters['GlobalRestrictions']
- if (a2Params !== '') {
- if (a2Params.contains(',')) {
- var array = a2Params.split(',');
- console.log(array);
- array = array.map(function(str) {
- console.log("Converting!");
- return parseInt(str);
- }); } else {
- var array = [];
- array.push(parseInt(a2Params));
- };
- } else {
- var array = [];
- };
- var array2 = [];
- for (var x = 0; x < array.length; x++){
- if(array2.indexOf(array[x]) == -1) array2.push(array[x]);
- }
- Mal.Param.A2_Global = array2;
- console.log(Mal.Param.A2_Global);
- var MalDBPAN1 = DataManager.processAugmentNotetags1
- DataManager.processAugmentNotetags1 = function(group, isWeapon) {
- MalDBPAN1.call(this, group, isWeapon);
- for (var n = 1; n < group.length; n++) {
- var obj = group[n];
- if (obj) obj.augRestrict = [];
- }
- };
- var MalDBPAN2 = DataManager.processAugmentNotetags2
- DataManager.processAugmentNotetags2 = function(group, isWeapon) {
- MalDBPAN2.call(this, group, isWeapon);
- for (var n = 1; n < group.length; n++) {
- var obj = group[n];
- if (obj) obj.augRestrictType = -1;
- if (obj.meta.augRestrictType) obj.augRestrictType = Number(obj.meta.augRestrictType);
- }
- };
- var mal_gameParty_init = Game_Party.prototype.initialize;
- Game_Party.prototype.initialize = function() {
- mal_gameParty_init.call(this);
- this._globalAugRestricts = Mal.Param.A2_Global;
- };
- Game_Party.prototype.addGlobalRType = function (type) {
- var type = Number(type);
- if (this._globalAugRestricts.indexOf(type) == -1) {
- this._globalAugRestricts.push(Number(type));
- };
- };
- Game_Party.prototype.removeGlobalRType = function (type) {
- var type = Number(type);
- var pick = this._globalAugRestricts.indexOf(type);
- if (pick == -1) return;
- this._globalAugRestricts.splice(pick, 1);
- };
- Game_Party.prototype.addAugmentRestrictType = function(obj, type) {
- if (!obj) return;
- obj.augRestrict.push(type);
- };
- Game_Party.prototype.removeAugmentRestrictType = function(obj, type) {
- if (!obj) return;
- var pick = obj.augRestrict.indexOf(type);
- if (pick == -1) return;
- obj.augRestrict.splice(pick, 1);
- };
- Window_AugmentItemList.prototype.includes = function(item) {
- if (!item) return false;
- if (DataManager.isIndependent(item)) return false;
- if (!this.containsType(item)) return false;
- if (this.isAugTypeRestricted(item)) return false;
- return true;
- };
- Window_AugmentItemList.prototype.isAugTypeRestricted = function(item) {
- var pick = Number(item.augRestrictType);
- if (this._item.augRestrict.indexOf(pick) > -1) return true;
- if ($gameParty._globalAugRestricts.indexOf(pick) > -1) return true;
- return false;
- };
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement