Substitute protects from Magic attack

DarkAdria

Villager
Member
Joined
Jul 29, 2020
Messages
23
Reaction score
1
First Language
Spanish
Primarily Uses
RMMV
I am embarrassed to ask again, you have already helped me a lot in this forum, but I have a problem with the configuration of a skill again.
I have searched the forum and I have not found any topic that asked exactly what I need.
The thing is, I've created a skill that aims to protect the rest of the characters.
For this, I have created a state like this:
Sin título.png

The problem is that the character that uses the skill, He protects her from magic attacks. I would like "Substitute" to only affect physical attacks. Is there any way to do it?

@Aesica Could you help me one last time? >. <
 

Oddball

Veteran
Veteran
Joined
Sep 4, 2014
Messages
1,918
Reaction score
529
First Language
English
Primarily Uses
N/A
Would making magical attacks certain hit work?
 

DarkAdria

Villager
Member
Joined
Jul 29, 2020
Messages
23
Reaction score
1
First Language
Spanish
Primarily Uses
RMMV

Oddball

Veteran
Veteran
Joined
Sep 4, 2014
Messages
1,918
Reaction score
529
First Language
English
Primarily Uses
N/A
Here it is in English

There's functinallity that let's you specify which skills ignore substitute

//================================================ =============================
// SubstituteExtend.js
// ------------------------------------------------ ----------------------------
// (C)2017 Triacontane
// This software is released under the MIT License.
// http://opensource.org/licenses/mit-license.php
// ------------------------------------------------ ----------------------------
// Version
// 1.4.1 2020/06/10 Corrected the problem that the parameter "Substitution condition _ other than inevitable" disappeared with the modification of 1.4.0.
// 1.4.0 2020/05/19 Addition of setting to change existing specifications so that substitution is activated even in the state of action restriction "cannot act"
// 1.3.0 2020/04/14 Add setting to change existing specifications so that substitution is not activated when the state of confusion system is valid
// 1.2.0 2019/12/22 Changed the judgment specification of substitution and added the function of counterattack and magic reflection after substitution
// 1.1.0 2018/09/09 Add the ability to directly specify the skill or item to disable substitution
// 1.0.2 2017/08/22 Fixed an issue that even if you disable the sham condition "other than sneak attack", the sneak attack for the Sneak attack may not be activated.
// 1.0.1 2017/02/07 Deleted the device-dependent description
// 1.0.0 2017/02/05 First edition
// ------------------------------------------------ ----------------------------
// [Blog]: https://triacontane.blogspot.jp/
// [Twitter]: https://twitter.com/triacontane/
// [GitHub]: https://github.com/triacontane/
//================================================ =============================

/*:
* @plugindesc SubstituteExtendPlugin
* @Author triacontane
*
* @param CondDying
* @desc Enables the default substitution condition "dying". Turn it off to disable it. (ON/OFF)
* @Default true
* @type boolean
*
* @param CondNonCertainHit
* @desc Enables the default surrogate condition, "Not Necessary". Turn it off to disable it. (ON/OFF)
* @Default true
* @type boolean
*
* @param SubstituteCounter
* @desc The judgment specification for substitution has been changed so that counterattacks and magic reflections after substitution are enabled.
* @Default false
* @type boolean
*
* @param InvalidConfused
* @desc In the case of a state of confusion (state where the action constraint is "attack XX"), the activation of substitution is invalidated.
* @Default false
* @type boolean
*
* @param ValidRestriction
* @desc Even if you are incapable of action (state in which the action constraint is "inaction impossible"), the activation of substitution is enabled.
* @Default false
* @type boolean
*
* @Help Change the substitution specifications.
* First, I will explain the substitute specifications of the RPG Maker MV body.
* ・Substitute side
* Alive
* The action constraint is not in the "cannot act" state
* Holds the "substitution" feature
* ・Substitute side
* Dying (HP less than 1/4)
* Not the same butler as the substitute
* Skills that activate substitution
* Hit type is not "must"
* ・Substitution priority
* From the beginning of the party, judge the "substitute butler" in order
* ・Specifications that are easily misunderstood
* Even if you are in the state of action restriction "attack XX", you can substitute
* The "range" of the skill and the user of the skill have nothing to do with the substitution judgment.
* (If the hit type is not necessary, substitution will be activated for recovery and defense)
*Since the judgment is made only once, the substitution will not be activated in the following cases.
* ・The 1st and 2nd butlers can be replaced
* ・The first butler is a substitute
*
* 1. You can disable the following default substitution conditions.
* Dying (HP is less than 1/4)
* ・The hit type is not "necessary"
* ・The action constraint is not in the state of "cannot act"
*
* If you remove the condition that "hit type is not "necessary"", defense etc. is irrelevant
* Substitution will be activated indiscriminately even for skills.
* Please set it carefully.
*
* 2. You can set detailed activation conditions for substitution.
* Please describe as follows in the memo column of the database with characteristics.
* Substitution will be triggered when "all conditions" in the memo column are met.
* Basically, describe as a set of "feature" and "substitution".
*
* What is the memo column of the database that has features?
* It is a memo field of one of actor, occupation, weapon, armor, state, and enemy character.
*
* <SE_ executor HP rate: 50> # Activates only when the executor's HP is 50% or higher.
* <SE_SubjectHPRate:50> # Same as above
* <SE_ target HP rate: 50> # Activates only when the target HP is 50% or less. (*1)
* <SE_TargetHPRate:50> # Same as above
* <SE_ Substitution target only: 1> # Substitution target is limited to [1]. (*2)
* <SE_TargetRestriction:1> # Same as above
* <SE_ Substitute switch: 4> # Activates only when switch [4] is ON.
* <SE_SubstituteSwitch:4> # Same as above
* <SE_ Substitution formula: f> # Fires only when the result of formula [f] is true. (*3)
* <SE_SubstituteFormula:f> # Same as above
*
* *1 "Dying" which is the default substitution condition from the parameters
* Judges only when disabled.
*
* *2 If you want to set the target of the tag of <SE_ Substitute target only: n>,
* Describe as follows in the memo column of the database that has features.
*
* <SE_ Substitute Target: 1> # <SE_ Substitute Only: 1>.
* <SE_SubstituteTarget:1> # Same as above
*
* If you match the parameter specified in "Substitution target only", it will be a substitution target.
* For example, if you enter <SE_Substitution target: 2> in the memo field, also in the memo field
* Only for actors with features marked <SE_Substitute Target: 2>
* Perform substitutions.
*
* *3 This function is for advanced users.
* If you want to use the inequality sign in the formula, please describe as follows.
* <→ <
*> → >
*
* Example: <SE_ Substitution formula: \v[2] > 3> # Triggers if the variable [2] is greater than [3].
*
* You can refer to the Action object of the target skill by "action" in the formula.
* If you use it properly, you can finely limit the skill to activate substitution.
*
* Below is an example.
* <SE_ Substitution calculation formula: action.isAttack()> # Substitute only normal attacks
* <SE_ Substitution calculation formula: action.isPhysical()> # Substitute only physical attacks
* <SE_ Substitution formula: action.isForOne()> # Substitute only for single target
*
* 3. When the substitution is activated, the skill effect of the specified ID is given to the substitution person.
* Can be applied.
* <SE_ Substitution Skill ID: 5> # Apply Skill [5] to the performer when substituting. (*1)
* <SE_SubstituteSkillId:5> # Same as above
*
* *1 Effects such as damage popups and animations are not displayed.
*
* 4. You can individually specify the skills for which you want to disable substitution.
* Please specify as follows in the memo field of skill or item.
* <SE_Substitute disabled>
* <SE_SubstituteInvalid>
*
* There are no plugin commands for this plugin.
*
* Terms of service:
* It can be modified or redistributed without permission of the author, and the usage form (commercial use, 18 prohibited use, etc.)
* There is no limit.
* This plugin is already yours.
*
* This plugin is released under the MIT License.
*/
/*:ja
* @plugindesc Substitute extension plugin
* @Author Triacontin
*
* @param Substitution condition _ moribund
* @desc Enables the default substitution condition "dying". Turn it off to disable it. (ON/OFF)
* @Default true
* @type boolean
*
* @param Substitution condition_other than essential
* @desc Enables the default surrogate condition, "Not Necessary". Turn it off to disable it. (ON/OFF)
* @Default true
* @type boolean
*
* @param Substitute counterattack
* @desc The judgment specification for substitution has been changed so that counterattacks and magic reflections after substitution are enabled.
* @Default false
* @type boolean
*
* @param Substitution in case of confusion is disabled
* @desc In the state of confusion (state where the action constraint is "attack XX"), the activation of substitution is disabled.
* @Default false
* @type boolean
*
* @param Substitute when disabled
* @desc Even if you are incapable of action (state in which the action constraint is "inaction impossible"), the activation of substitution is enabled.
* @Default false
* @type boolean
*
* @Help Change the substitution specifications.
* First, I will explain the substitute specifications of the RPG Maker MV body.
* ・Substitute side
* Alive
* The action constraint is not in the "cannot act" state
* Holds the "substitution" feature
* ・Substitute side
* Dying (HP less than 1/4)
* Not the same butler as the substitute
* Skills that activate substitution
* Hit type is not "must"
* ・Substitution priority
* From the beginning of the party, judge the "substitute butler" in order
* ・Specifications that are easily misunderstood
* Even if you are in the state of action restriction "attack XX", you can substitute
* The "range" of the skill and the user of the skill have nothing to do with the substitution judgment.
* (If the hit type is not necessary, substitution will be activated for recovery and defense)
*Since the judgment is made only once, the substitution will not be activated in the following cases.
* ・The 1st and 2nd butlers can be replaced
* ・The first butler is a substitute
*
* 1. You can disable the following default substitution conditions.
* Dying (HP is less than 1/4)
* ・The hit type is not "necessary"
* ・The action constraint is not in the state of "cannot act"
*
* If you remove the condition that "hit type is not "necessary"", defense etc. is irrelevant
* Substitution will be activated indiscriminately even for skills.
* Please set it carefully.
*
* 2. You can set detailed activation conditions for substitution.
* Please describe as follows in the memo column of the database with characteristics.
* Substitution will be triggered when "all conditions" in the memo column are met.
* Basically, describe as a set of "feature" and "substitution".
*
* What is the memo column of the database that has features?
* It is a memo field of one of actor, occupation, weapon, armor, state, and enemy character.
*
* <SE_ executor HP rate: 50> # Activates only when the executor's HP is 50% or higher.
* <SE_SubjectHPRate:50> # Same as above
* <SE_ target HP rate: 50> # Activates only when the target HP is 50% or less. (*1)
* <SE_TargetHPRate:50> # Same as above
* <SE_ Substitution target only: 1> # Substitution target is limited to [1]. (*2)
* <SE_TargetRestriction:1> # Same as above
* <SE_ Substitute switch: 4> # Activates only when switch [4] is ON.
* <SE_SubstituteSwitch:4> # Same as above
* <SE_ Substitution formula: f> # Fires only when the result of formula [f] is true. (*3)
* <SE_SubstituteFormula:f> # Same as above
*
* *1 "Dying" which is the default substitution condition from the parameters
* Judges only when disabled.
*
* *2 If you want to set the target of the tag of <SE_ Substitute target only: n>,
* Describe as follows in the memo column of the database that has features.
*
* <SE_ Substitute Target: 1> # <SE_ Substitute Only: 1>.
* <SE_SubstituteTarget:1> # Same as above
*
* If you match the parameter specified in "Substitution target only", it will be a substitution target.
* For example, if you enter <SE_Substitution target: 2> in the memo field, also in the memo field
* Only for actors with features marked <SE_Substitute Target: 2>
* Perform substitutions.
*
* *3 This function is for advanced users.
* If you want to use the inequality sign in the formula, please describe as follows.
* <→ <
*> → >
*
* Example: <SE_ Substitution formula: \v[2] > 3> # Triggers if the variable [2] is greater than [3].
*
* You can refer to the Action object of the target skill by "action" in the formula.
* If you use it properly, you can finely limit the skill to activate substitution.
*
* Below is an example.
* <SE_ Substitution calculation formula: action.isAttack()> # Substitute only normal attacks
* <SE_ Substitution calculation formula: action.isPhysical()> # Substitute only physical attacks
* <SE_ Substitution formula: action.isForOne()> # Substitute only for single target
*
* 3. When the substitution is activated, the skill effect of the specified ID is given to the substitution person.
* Can be applied.
* <SE_ Substitution Skill ID: 5> # Apply Skill [5] to the performer when substituting. (*1)
* <SE_SubstituteSkillId:5> # Same as above
*
* *1 Effects such as damage popups and animations are not displayed.
*
* 4. You can individually specify the skills for which you want to disable substitution.
* Please specify as follows in the memo field of skill or item.
* <SE_Substitute disabled>
* <SE_SubstituteInvalid>
*
* There are no plugin commands for this plugin.
*
* Terms of service:
* It can be modified or redistributed without permission of the author, and the usage form (commercial use, 18 prohibited use, etc.)
* There is no limit.
* This plugin is already yours.
*/

(function() {
'use strict';
var pluginName ='SubstituteExtend';
var metaTagPrefix ='SE_';

//================================================ =============================
// local function
// Format and check plugin parameters and plugin command parameters
//================================================ =============================
var getParamString = function(paramNames) {
if (!Array.isArray(paramNames)) paramNames = [paramNames];
for (var i = 0; i <paramNames.length; i++) {
var name = PluginManager.parameters(pluginName)[paramNames];
if (name) return name;
}
return ``;
};

var getParamBoolean = function(paramNames) {
var value = getParamString(paramNames);
return value.toUpperCase() ==='ON' || value.toUpperCase() ==='TRUE';
};

var getMetaValue = function(object, name) {
var metaTagName = metaTagPrefix + name;
return object.meta.hasOwnProperty(metaTagName) ?convertEscapeCharacters(object.meta[metaTagName]): undefined;
};

var getMetaValues = function(object, names) {
for (var i = 0, n = names.length; i <n; i++) {
var value = getMetaValue(object, names);
if (value !== undefined) return value;
}
return undefined;
};

var convertEscapeCharacters = function(text) {
if (text == null) {
text = ``;
}
if (text === true) {
return text;
}
var windowLayer = SceneManager._scene._windowLayer;
return windowLayer ?windowLayer.children[0].convertEscapeCharacters(text) :text;
};

var convertEscapeTags = function(text) {
if (text == null || text === true) text = ``;
text = text.replace(/>?/gi,'>');
text = text.replace(/<?/gi,'<');
return text;
};

//================================================ =============================
// Get and format parameters
//================================================ =============================
var param = {};
param.condDying = getParamBoolean(['CondDying','Substitution condition_dying']);
param.condNonCertainHit = getParamBoolean(['CondNonCertainHit','Substitution condition_not essential']);
param.substituteCounter = getParamBoolean(['SubstituteCounter','Substitute Counterattack']);
param.invalidConfused = getParamBoolean(['InvalidConfused','Valid in confusion']);
param.validRestriction = getParamBoolean(['ValidRestriction','ValidRestriction enabled']);

//================================================ =============================
// Game_BattlerBase
// Extend the determination of whether or not to perform substitution.
//================================================ =============================
var _Game_BattlerBase_isSubstitute = Game_BattlerBase.prototype.isSubstitute;
Game_BattlerBase.prototype.isSubstitute = function() {
if (param.validRestriction) {
this._suppressRestriction = true;
}
var result = _Game_BattlerBase_isSubstitute.apply(this, arguments) && this.isSubstituteExtend();
this._suppressRestriction = false;
return result;
};

var _Game_BattlerBase_restriction = Game_BattlerBase.prototype.restriction;
Game_BattlerBase.prototype.restriction = function() {
return this._suppressRestriction ?0 :_Game_BattlerBase_restriction.apply(this, arguments);
};

Game_BattlerBase.prototype.isSubstituteExtend = function() {
if (param.invalidConfused && this.isConfused()) {
return false;
}
return this.isValidSubstituteHpRate() &&
(param.condDying || this.isValidSubstituteTargetHpRate()) &&
this.isValidSubstituteSwitch() &&
this.isValidSubstituteRestriction() &&
this.isValidSubstituteFormula() &&
this.isValidSubstituteSkill();
};

Game_BattlerBase.prototype.isValidSubstituteHpRate = function() {
var subjectHpRate = this.getSubstituteMetaInfo(['SubjectHPRate','executor HP rate'], true);
if (subjectHpRate) {
return this.hpRate() >= subjectHpRate / 100;
}
return true;
};

Game_BattlerBase.prototype.isValidSubstituteTargetHpRate = function() {
var targetHpRate = this.getSubstituteMetaInfo(['TargetHPRate','Target HP rate'], true);
if (targetHpRate) {
return BattleManager.checkSubstituteTargetHpRate(targetHpRate);
}
return true;
};

Game_BattlerBase.prototype.isValidSubstituteRestriction = function() {
var restrictionId = this.getSubstituteMetaInfo(['TargetRestriction','Substitution target restriction'], true);
if (restrictionId) {
return BattleManager.checkSubstituteRestriction(restrictionId);
}
return true;
};

Game_BattlerBase.prototype.isValidSubstituteSwitch = function() {
var switchId = this.getSubstituteMetaInfo(['SubstituteSwitch','SubstituteSwitch'], true);
if (switchId) {
return $gameSwitches.value(switchId);
}
return true;
};

Game_BattlerBase.prototype.isValidSubstituteFormula = function() {
var formula = this.getSubstituteMetaInfo(['SubstituteFormula','SubstituteFormula'], false);
if (formula) {
var action = BattleManager.getSubstituteAction();
return eval(convertEscapeTags(formula));
}
return true;
};

Game_BattlerBase.prototype.isValidSubstituteSkill = function() {
return !getMetaValues(BattleManager.getSubstituteAction().item(), ['SubstituteInvalid','SubstituteInvalid']);
};

Game_BattlerBase.prototype.isEqualSubstituteRestrictionId = function(restrictionId) {
var restrictionTargetId = this.getSubstituteMetaInfo(['SubstituteTarget','Substitute Target'], true);
return restrictionTargetId === restrictionId;
};

Game_BattlerBase.prototype.getSubstituteSkillId = function() {
return this.getSubstituteMetaInfo(['SubstituteSkillId','Substitute Skill ID'], true);
};

Game_BattlerBase.prototype.getSubstituteMetaInfo = function(tagNames, isNumber) {
var metaValue;
this.traitObjects().some(function(traitObject) {
metaValue = getMetaValues(traitObject, tagNames);
return !!metaValue;
});
return (metaValue && isNumber) ?parseInt(metaValue) :metaValue;
};

//================================================ =============================
// BattleManager
// Hold the information of the substitute person and evaluate if necessary.
//================================================ =============================
var _BattleManager_invokeAction = BattleManager.invokeAction;
BattleManager.invokeAction = function(subject, target) {
if (param.substituteCounter) {
var realTarget = this.applySubstitute(target);
_BattleManager_invokeAction.call(this, subject, realTarget);
} else {
_BattleManager_invokeAction.apply(this, arguments);
}
};

var _BattleManager_applySubstitute = BattleManager.applySubstitute;
BattleManager.applySubstitute = function(target) {
this._substituteTarget = target;
var substitute = _BattleManager_applySubstitute.apply(this, arguments);
this._substituteTarget = null;
if (substitute !== target) {
this.applySubstituteEffect(substitute);
}
return substitute;
};

BattleManager.applySubstituteEffect = function(substitute) {
var skillId = substitute.getSubstituteSkillId();
if (!skillId) return;
var action = new Game_Action(substitute);
action.setSkill(skillId);
action.apply(substitute);
};

BattleManager.checkSubstituteTargetHpRate = function(hpRate) {
return this._substituteTarget ?this._substituteTarget.hpRate() <= hpRate / 100 :true;
};

BattleManager.checkSubstituteRestriction = function(restrictionId) {
return this._substituteTarget ?this._substituteTarget.isEqualSubstituteRestrictionId(restrictionId): true;
};

BattleManager.getSubstituteAction = function() {
return this._action;
};

var _BattleManager_checkSubstitute = BattleManager.checkSubstitute;
BattleManager.checkSubstitute = function(target) {
var resultSubstitute = _BattleManager_checkSubstitute.apply(this, arguments);
if (!resultSubstitute) {
return this.checkSubstituteDefault(target);
}
return resultSubstitute;
};

BattleManager.checkSubstituteDefault = function(target) {
return this.isValidSubstituteDying(target) && this.isValidSubstituteCertainHit();
};

BattleManager.isValidSubstituteDying = function(target) {
return !param.condDying || target.isDying();
};

BattleManager.isValidSubstituteCertainHit = function() {
return !param.condNonCertainHit || !this._action.isCertainHit();
};
})();
[spoiler/]
 

Aesica

undefined
Veteran
Joined
May 12, 2018
Messages
1,477
Reaction score
1,369
First Language
English
Primarily Uses
RMMV
Not gonna lie, I know almost nothing about how substitute works so I'll have to defer to others on this. ;)
 

DarkAdria

Villager
Member
Joined
Jul 29, 2020
Messages
23
Reaction score
1
First Language
Spanish
Primarily Uses
RMMV
Here it is in English

There's functinallity that let's you specify which skills ignore substitute

//================================================ =============================* Puedes referirte al objeto Acción de la habilidad objetivo por "acción" en la fórmula.
* If you use it properly, you can finely limit the skill to activate substitution.
*
* Below is an example.
* <SE_ Substitution calculation formula: action.isAttack()> # Substitute only normal attacks
* <SE_ Substitution calculation formula: action.isPhysical()> # Substitute only physical attacks
* <SE_ Substitution formula: action.isForOne()> # Substitute only for single target
*
* 4. You can individually specify the skills for which you want to disable substitution.
* Please specify as follows in the memo field of skill or item.
* <SE_Substitute disabled>
* <SE_SubstituteInvalid>
I've seen these two options and I think I could make them work with them. But I am not sure what I should write and where I should write it :/

Could you help me please?
 

Oddball

Veteran
Veteran
Joined
Sep 4, 2014
Messages
1,918
Reaction score
529
First Language
English
Primarily Uses
N/A
Sorry, i don't know much about scripting. Try reading the instructions to the script
 

DarkAdria

Villager
Member
Joined
Jul 29, 2020
Messages
23
Reaction score
1
First Language
Spanish
Primarily Uses
RMMV
Nothing, I have not been able to configure it U.U
If you know someone who knows about scripting or substitute, tell them to come over this topic, please.
Thank you!

Edit:
Finally, I couldn't set the skill. I decided to change the skill, so this topic can now be closed. I wanted to thank all the people on this forum who have helped me, especially Aesica. Thank you!
 
Last edited:

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

Latest Threads

Latest Profile Posts

I stumbled upon 2 articles about why time goes faster as we age, and how to "slow down time".
Check them out, very interesting read. :D
Faster Time
Slower Time
Anyone can recommend a good gaming mouse? My mouse wheel has given up. Last mouse was steel series diablo iii edition (I know, it's been a while)
And then I figured out a way to doing a "regular animation" that's affected by PIXI particles. So now each frame of the animation gets particle effects. Soon my dreams of a world without QSprite will be realized. :kaopride:
Currently every NPC in my RPG gets a name, its kinda useless to name all, but Its also cool, somehow.
Biggest prob is to come up with different names. xD
I'm back from my visit to my family. Was really great to see them again after a year even if I had to get tested for covid for the visit.

Forum statistics

Threads
104,268
Messages
1,005,111
Members
135,778
Latest member
Moguta
Top