Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- //=============================================================================
- // Maliki's Confusion Control MZ
- // MalConfusionControl.js
- // version 1.2
- //=============================================================================
- /*:
- * @target MZ
- *
- * @plugindesc ver1.2 - Allows devs to specify skills other than basic attack
- * for confused battlers to use.
- * @author Maliki79
- *
- * @help To use this plugin, simply add the following tag to enemy, actor or class notes:
- *
- * <conAttacks: x, y, z...>
- *
- * with x, y, or z being the id number of the desired skill(s) in your database.
- * (All actor skills will be added as well, so seal skills you do not wish to be used while confused)
- * Note that while the battler does not need to have normal access to that skill to use it,
- * the battler will need sufficent MP/TP to do so.
- * Also note that actors will need to be able to use the skills normally.
- * (If a sword skill is on the list but the actor does not have a sword equipped,
- * the skill will not be useable.)
- *
- * When creating Confusion states, you can use the tag
- *
- * <charm>
- *
- * When used, friendly and offensive skills will be totally reversed.
- * In other words, a "charmed" enemy will NEVER use a heal spell on another enemy.
- * Note that charmed states will take presidance over regular confusion states.
- * Also, direct user skills will still target ONLY the user.
- */
- var MalCControlDatabaseLoad = DataManager.isDatabaseLoaded;
- DataManager.isDatabaseLoaded = function() {
- if (!MalCControlDatabaseLoad.call(this)) return false;
- if (!DataManager._malCControl_DatabaseLoaded) {
- this.processCControlNotetags($dataActors);
- this.processCControlNotetags($dataEnemies);
- this.processCControlNotetags($dataClasses);
- DataManager._malCControl_DatabaseLoaded = true;
- }
- return true;
- };
- DataManager.processCControlNotetags = function(group) {
- for (var n = 1; n < group.length; n++) {
- var obj = group[n];
- if(!obj) continue;
- obj.conAttacks = [];
- var noteread = obj.note;
- while(noteread.indexOf("conAttacks") > -1) {
- var match = noteread.split("<conAttacks: ");
- var match2 = match[1].split(">");
- var match3 = match2[0].split(",");
- for(var cc = 0; cc < match3.length; cc++) {
- obj.conAttacks.push(parseInt(match3[cc]));
- }
- noteread = noteread.replace("<conAttacks:", " ");
- };
- };
- };
- Game_Action.prototype.setConfusion = function() {
- this.setConfAttack();
- };
- Game_Action.prototype.setConfAttack = function() {
- var skills = [];
- var skill = 0;
- if(this.subject().isActor()) {
- skills = this.subject().currentClass().conAttacks;
- skills = skills.concat($dataActors[this.subject()._actorId].conAttacks);
- var skillset = this.subject().usableSkills();
- for (var ii = 0; ii < skillset.length; ii++){
- if(this.subject().addedSkillTypes().includes(skillset[ii].stypeId)) skills.push(skillset[ii].id);
- };
- } else {
- skills = skills.concat($dataEnemies[this.subject()._enemyId].conAttacks);
- }
- skill = skills[Math.randomInt(skills.length)];
- if (skills.length > 0) {
- this.setSkill(skill);
- } else {
- this.setSkill(this.subject().attackSkillId());
- }
- };
- Game_Action.prototype.makeTargets = function() {
- const targets = [];
- if (!this._forcing && this.subject().isConfused() && !this.subject().isCharmed()) {
- targets.push(this.confusionTarget());
- } else if (this.isForEveryone()) {
- targets.push(...this.targetsForEveryone());
- } else if (this.isForOpponent()) {
- targets.push(...this.targetsForOpponents());
- } else if (this.isForFriend()) {
- targets.push(...this.targetsForFriends());
- }
- return this.repeatTargets(targets);
- };
- Game_Action.prototype.confusionTarget = function() {
- if (this.isForUser()) return this.subject();
- switch (this.subject().confusionLevel()) {
- case 1:
- return this.opponentsUnit().randomTarget();
- case 2:
- if (Math.randomInt(2) === 0) {
- return this.opponentsUnit().randomTarget();
- }
- return this.friendsUnit().randomTarget();
- default:
- return this.friendsUnit().randomTarget();
- }
- };
- Game_Actor.prototype.friendsUnit = function() {
- if (this.isCharmed()) return $gameTroop;
- return $gameParty;
- };
- Game_Actor.prototype.opponentsUnit = function() {
- if (this.isCharmed()) return $gameParty;
- return $gameTroop;
- };
- Game_Enemy.prototype.friendsUnit = function() {
- if (this.isCharmed()) return $gameParty;
- return $gameTroop;
- };
- Game_Enemy.prototype.opponentsUnit = function() {
- if (this.isCharmed()) return $gameTroop;
- return $gameParty;
- };
- Game_BattlerBase.prototype.isCharmed = function() {
- var states = this.states();
- for (i = 0; i < states.length; i++) {
- if(states[i].meta.charm) return true;
- };
- return false;
- };
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement