Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- //=============================================================================
- // MalAddExtraState
- // MalAddExtraState.js
- // version 1.2
- //=============================================================================
- /*:
- * @plugindesc Allows Devs to give to give Battlers unique state reactions.
- * These reactions are expressed as secondary states which can be set per Battler.
- *
- * @author Maliki79
- *
- * @param ExChainable
- * @desc Type 1 to allow Ex States to add other Ex States.
- * Default: 0
- * @default 0
- *
- * @param ProgChainable
- * @desc Type 1 to allow Progressive Primary states to trigger from the right-most active state.
- * Default: 0
- * @default 0
- *
- * @help
- * Actor or Enemy Notetags :
- * <addExtraState: x, y, z>
- * with x being the original state, y the "extra" state and z being the chance to
- * add the state from 0 to 100.
- * Multiple sets of the tag can be used to give a single original state multiple
- * extra states.
- *
- * You can make y a negative number to remove that state.
- * For example, if poison was state ID 5 and Blind was state ID 6, using
- * <addExtraState: 5, 6, 100> would add the Blind state to the enemy any time
- * Poison is added to it.
- * <addExtraState: 5, -6, 100> would REMOVE the Blind state if the enemy has it
- * and Poison is then added.
- *
- * The order of the tags in the database determine when the Extra states are added,
- * so using tags carefully, various combinations of states can be added or removed.
- *
- * By changing the plugin param ExChainable to 1, all extra states will behave
- * like original states and can have other ex states added to them in the same attack.
- * (This does not apply to Progressive State Chains.)
- *
- * <addProgState: A, b, c...>
- * with A, b and c being different different state Ids.
- * Adds Progressive states. After successfully adding the first "intial" state on the list to a battler,
- * the plugin will attempt to add the next unafflicted state to the battler every time the initial state
- * is successfully readded.
- * (Only one state will be added at a time and it will ALWAYS be the leftmost one that is not already
- * on the battler.)
- * You can make the chain as long as you like, but copies of the same Id will NOT work.
- * You can use Ids that were in another chain as a new initial Id.
- * Example: <addProgState: 5, 6, 7, 8, 9, 10>
- * and
- * <addProgState: 8, 9 , 5>
- * can both be successfully used on one enemy.
- *
- * By changing the plugin param ProgChainable to 1, the plugin will look for
- * the most advanced state in the state list (the rightmost one) that is already added, then add
- * the next state.
- * (This does not apply to Progressive State Chains.)
- * Ex: <addProgState: 5, 6, 7, 8, 9 ,10>
- * Normally, you would have to add state 5 before 6, then 7, etc., but if another attack was
- * to add state 8, the next time state 5 was attemped to be added, it would apply state 9 whether
- * states 5, 6 or 7 were previously added or not.
- * Note that these Extra States only work in battle.
- */
- //Begin database setup
- var MalAddExStDatabaseLoad = DataManager.isDatabaseLoaded;
- DataManager.isDatabaseLoaded = function() {
- if (!MalAddExStDatabaseLoad.call(this)) return false;
- if (!DataManager._MalExSt_DatabaseLoaded) {
- this.processExStNotetags($dataEnemies);
- this.processExStNotetags($dataActors);
- DataManager._MalExSt_DatabaseLoaded = true;
- }
- return true;
- };
- DataManager.processExStNotetags = function(group) {
- for (var n = 1; n < group.length; n++) {
- var obj = group[n];
- obj.extraState = [];
- obj.exStates = [];
- obj.exProgStates = new Array($dataStates.length + 1);
- this.createExtraStateArray(obj);
- }
- };
- DataManager.createExtraStateArray = function(object) {
- var noteread = object.note;
- while(noteread.indexOf("addExtraState") > -1)
- {
- var notereg = noteread.split("<addExtraState: ");
- var match = notereg[1].split(", ");
- var match2 = match[2].split(">");
- object.extraState.push([parseInt(match[0]), parseInt(match[1]), parseInt(match2[0])]);
- object.exStates.push(parseInt(match[0]));
- noteread = noteread.replace("<addExtraState: ", " ");
- }
- noteread = object.note;
- while(noteread.indexOf("addProgState") > -1)
- {
- var notereg2 = noteread.split("<addProgState: ");
- var match = notereg2[1].split(">");
- var match2 = match[0].split(", ");
- for (var n = 1; n < match2.length; n++) {
- if (!object.exProgStates[match2[0]]) object.exProgStates[match2[0]] = [];
- object.exProgStates[match2[0]].push(parseInt(match2[n]));
- }
- noteread = noteread.replace("<addProgState: ", " ");
- }
- };
- //End Database Setup
- var MalExChains = PluginManager.parameters('MalAddExtraState')['ExChainable'];
- var MalProgChain = PluginManager.parameters('MalAddExtraState')['ProgChainable'];
- var MalAddExStActorSetup = Game_Actor.prototype.setup;
- Game_Actor.prototype.setup = function(actorId) {
- MalAddExStActorSetup.call(this, actorId);
- this.extraState = $dataActors[this._actorId].extraState;
- this.exStates = $dataActors[this._actorId].exStates;
- this.exProgStates = $dataActors[this._actorId].exProgStates;
- this._exStates = [];
- };
- var MalAddExStEnemySetup = Game_Enemy.prototype.setup;
- Game_Enemy.prototype.setup = function(enemyId, x, y) {
- MalAddExStEnemySetup.call(this, enemyId, x, y);
- this.extraState = $dataEnemies[this._enemyId].extraState;
- this.exStates = $dataEnemies[this._enemyId].exStates;
- this.exProgStates = $dataEnemies[this._enemyId].exProgStates;
- this._exStates = [];
- };
- var mal_addState = Game_Battler.prototype.addState;
- Game_Battler.prototype.addState = function(stateId) {
- var stateId = stateId;
- var lock = -1;
- var prog = this.exProgStates[stateId];
- if ($gameParty.inBattle() && prog) { // ) {
- if (MalProgChain == 0) {
- if (this._states.contains(stateId)) {
- for (var i = 0; i < prog.length; i++) {
- if (!this._states.contains(prog[i])) {
- lock = prog[i];
- break;
- }
- }
- }
- } else {
- for (var i = prog.length - 1; i > -1; i--) {
- if (this._states.contains(prog[i])) {
- lock = prog[(i + 1)];
- break;
- }
- }
- if(lock == -1 && this._states.contains(stateId)) lock = prog[0];
- }
- if (lock != -1) stateId = lock;
- mal_addState.call(this, stateId);
- } else {
- mal_addState.call(this, stateId);
- }
- if ($gameParty.inBattle() && this.exStates.contains(stateId) && !this._exStates.contains(stateId)) this.addExState(stateId);
- };
- Game_Battler.prototype.addExState = function (stateId) {
- for (var i = 0; i < this.extraState.length; i++) {
- var ex = this.extraState[i];
- if (ex[0] == stateId) {
- if (Math.randomInt(100) < ex[2]) {
- if (MalExChains == 0 && ex[1] > 0) this._exStates.push(ex[1]);
- if (ex[1] < 0) {
- this.removeState(ex[1] * -1);
- } else {
- this.addState(ex[1]);
- }
- }
- }
- }
- };
- var MalExStateClearResult = Game_Battler.prototype.clearResult;
- Game_Battler.prototype.clearResult = function() {
- MalExStateClearResult.call(this);
- this._exStates = [];
- };
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement