Hello!
I'm hoping I've not put this in the wrong place - apologies if so. Is anyone able to help? 🙂
I'm using RPG Maker MZ, ver 1.5.0.
Current Plugins:
VisuMZ CoreEngine
VisuMZ SkillsStatesCore
My call for help is because I don't think the "common" suite of plugins has the facility to do what I'm after doing... please correct me if I am wrong - I've not found anything close in those so far.
What I'm trying to achieve:
(I'm of the belief that this will require a new plugin, hence picking this forum to post.)
In battle: If one specific actor (Let's call him Dave) is going to die from a hit, I want another specific actor (Let's call her Jane) to take that hit and protect Dave from the deathblow.
Of course the condition is that both Dave and Jane are in the battle party, and I'd only want this to trigger once per battle. (It's fine if Jane dying resets this - I just don't want this to be too overpowered.)
I've had a good rummage around, and found similar, but my Javascript is very lacking outside of simple web design, there's this old thread here, where a person named SEK did an incredible plugin:
forums.rpgmakerweb.com
But this is for any member to defend, and is very excessive for what I'm after.
I'm wondering if there's anyone on here who can advise what I need to change, I'd like the opportunity to at least try to learn and put the pieces together myself if possible. As I understand it, I need to specify the protector and trim out the general defender stuff if I use SEK's code as a starter?
SEK's plugin code below. for reference.
Thank-you for reading, hope I didn't confuse things! 🙂
I'm hoping I've not put this in the wrong place - apologies if so. Is anyone able to help? 🙂
I'm using RPG Maker MZ, ver 1.5.0.
Current Plugins:
VisuMZ CoreEngine
VisuMZ SkillsStatesCore
My call for help is because I don't think the "common" suite of plugins has the facility to do what I'm after doing... please correct me if I am wrong - I've not found anything close in those so far.
What I'm trying to achieve:
(I'm of the belief that this will require a new plugin, hence picking this forum to post.)
In battle: If one specific actor (Let's call him Dave) is going to die from a hit, I want another specific actor (Let's call her Jane) to take that hit and protect Dave from the deathblow.
Of course the condition is that both Dave and Jane are in the battle party, and I'd only want this to trigger once per battle. (It's fine if Jane dying resets this - I just don't want this to be too overpowered.)
I've had a good rummage around, and found similar, but my Javascript is very lacking outside of simple web design, there's this old thread here, where a person named SEK did an incredible plugin:
Party Member Sacrifice
Good day everyone, I've been scouring the internet for a few, and haven't been able to turn up a plugin or method to do what I'm needing to do, so I wanted to request it here: In a game I'm helping to make, we're in need of a plugin that would allow for a specific member of our party to...
forums.rpgmakerweb.com
But this is for any member to defend, and is very excessive for what I'm after.
I'm wondering if there's anyone on here who can advise what I need to change, I'd like the opportunity to at least try to learn and put the pieces together myself if possible. As I understand it, I need to specify the protector and trim out the general defender stuff if I use SEK's code as a starter?
SEK's plugin code below. for reference.
JavaScript:
//=============================================================================
// SEK_BodyGuards.js
//=============================================================================
/*:
* @plugindesc With this plugin you can make your party members act like bodyguard for one of them!
* @author SEK
*
*
*@param Actor to defend
*@desc The Id of the actor that will be defended. Default is "1".
*@default 1
*
*@param Enabled
*@desc If true, the plugin will be enabled. Default is "true".
*@default true
*
*@param Guard Chance
*@desc If false, guard chance will be enabled (will still be true for hits that kill the actor). Default is "true".
*@default true
*
*@param Block Chance
*@desc If true, block chance will be enabled. Default is "true".
*@default true
*
*@param Guard Chance Rate
*@desc Determines how likely it is for the character to be protected from a non-lethal attack. Default is 40%.
*@default 40
*
*@param Block Chance Rate
*@desc Block Chance % Rate. Default is 30%.
*@default 30
*
* @help
* Every actor has a percentage of success in defending the selected actor.
* If the selected actor would die if hit, he will be protected for sure.
* To set the message to be shown when an actor defends, write in its notetags
* "<gbodyg:Text to be shown>" (without quotation marks)
* To set the message to be shown when an actor counterattacks, write in its notetags
* "<cbodyg:Text to be shown>" (without quotation marks)
* Plugin Commands:
*
* bodyg on Activates the plugin
* bodyg off Deactivates the plugin
*
* bodyg gon Activates Guard Chance
* bodyg goff Deactivates Guard Chance except for attacks that would kill
* the selected actor.
*
* bodyg bon Activates Block Chance
* bodyg boff Deactivates Block Chance
*
* bodyg perc x Success percentage becomes x (from 0 to 100).
* bodyg actor x Actor x will be defended
* bodyg block x Sets block chance to x%
*
*You are free to use this plugin. If you do use it, I'd like to have my name and my plugin's name included in credits.
*/
var params=PluginManager.parameters('SEK_BodyGuards');
var actor=Number(params['Actor to defend'] || 1);
var enabled=(params['Enabled'] || "true").toLowerCase()==="true";
var benabled=(params['Block Chance'] || "true").toLowerCase()==="true";
var genabled=(params['Guard Chance'] || "true").toLowerCase()==="true";
var perc=Number(params['Guard Chance Rate'] || 40);
var brate=Number(params['Block Chance Rate'] || 30);
var intrptr = Game_Interpreter.prototype.pluginCommand;
Game_Interpreter.prototype.pluginCommand = function(command, args) {
intrptr.call(this, command, args);
if (command.toLowerCase() === "bodyg") {
switch (args[0].toLowerCase())
{
case 'on':
{
enabled=true;
} break;
case 'off':
{
enabled=false;
} break;
case 'bon':
{
benabled=true;
} break;
case 'boff':
{
benabled=false;
} break;
case 'gon':
{
genabled=true;
} break;
case 'goff':
{
genabled=false;
} break;
case 'perc':
{
perc=args[1];
} break;
case 'actor':
{
actors=args[1];
} break;
case 'block':
{
brate=args[1];
} break;
}
}
};
var danno;
var bg=false;
Game_Action.prototype.bodyGuard = function(target,value) {
if (target.isActor()&&enabled&&target.actorId()===actor)
{
var shield=this.choseGuard();
shield? bg=true:bg=false;
if (bg&&(value>target.hp))
{
target=shield;
}
else if (bg&&genabled&&this.processDefend())
{
target=shield;
}
else bg=false;
return target
}
bg=false;
return target;
};
Game_Action.prototype.choseGuard = function ()
{
// Select alive fighting members that can defend actor
var avaliableMembers=[];
for (var i=0;i<$gameParty.members().length;i++)
{
if ($gameParty.members()[i].actorId()!=actor&&$gameParty.members()[i].hp>0)
{
avaliableMembers.push($gameParty.members()[i]);
}
}
if (avaliableMembers.length==0) return null;
// Obtain their defending percent
var membersPercent=this.setPercents(avaliableMembers);
// Chose who should defend
var defenderIndex = this.defenderIndex(membersPercent);
// Return the defender chosen or the one that will take his place if
// He would die.
var shield=avaliableMembers[defenderIndex];
var critical = (Math.random() < this.itemCri(shield));
var value = this.makeDamageValue(shield, critical);
avaliableMembers.splice(defenderIndex,1);
var ret=this.Defender(avaliableMembers, shield);
if (ret==null)
{
danno=value;
return shield;
}
return ret;
};
Game_Action.prototype.Defender = function (membri, shield)
{
var critical = (Math.random() < this.itemCri(shield));
var value = this.makeDamageValue(shield, critical);
if (value>=shield.hp)
{
// If this is the last defender and would die too, return null so
// The first chosen will defend and die.
if (membri.length==0) return null;
// Else
// Obtain their defending percent
var membersPercent=this.setPercents(membri);
// Chose who should defend
var defenderIndex = this.defenderIndex(membersPercent);
var ret=membri[defenderIndex];
// Return the defender chosen or the one that will take his place if
// He would die.
return this.Defender(membri.splice(defenderIndex,1), ret);
}
bg=true;
danno=value;
return shield;
};
Game_Action.prototype.defenderIndex = function (percents)
{
var i=0;
// Check wich is chosen:
while (true)
{
if (Math.random()*100 < percents[i])
return i;
i++;
if (i==percents.length) i=0;
}
};
Game_Action.prototype.setPercents = function (membri)
{
var agitot=0;
var hptot=0;
var ret=[];
// Calculate totals
for (var i=0;i<membri.length; i++)
{
agitot+=membri[i].agi;
hptot+=membri[i].hp;
}
// Assign a percentage to each member
for (var i=0;i<membri.length; i++)
{
ret[i]=(membri[i].agi*100/agitot+membri[i].hp*100/hptot)/2;
}
return ret;
};
Game_Action.prototype.apply = function(target) {
var result = target.result();
this.subject().clearResult();
result.clear();
result.used = this.testApply(target);
result.missed = (result.used && Math.random() >= this.itemHit(target));
result.evaded = (!result.missed && Math.random() < this.itemEva(target));
result.physical = this.isPhysical();
result.drain = this.isDrain();
if (result.isHit()) {
if (this.item().damage.type > 0) {
result.critical = (Math.random() < this.itemCri(target));
var value = this.makeDamageValue(target, result.critical);
danno=value;
target=this.bodyGuard(target, danno);
if (bg){
if (benabled&&brate>=Math.random()*100)
{
var counterMsg=$dataActors[target.actorId()].meta.cbodyg;
if (counterMsg){
$gameMessage.setFaceImage(target._faceName,target._faceIndex);
$gameMessage.add(counterMsg);}
danno*=Math.random();
target=this.subject();
this.executeDamage(target, danno);
target.performDamage();
target.startDamagePopup();
this.executeDamage(target, danno);
}
else
var testo=$dataActors[target.actorId()].meta.gbodyg;
if (testo){
$gameMessage.setFaceImage(target._faceName,target._faceIndex);
$gameMessage.add(testo);}
this.apply(target);
target.performDamage();
target.startDamagePopup();
if (target.hp<=0)
target.performCollapse();
}
else
this.executeDamage(target, danno);
}
this.item().effects.forEach(function(effect) {
this.applyItemEffect(target, effect);
}, this);
this.applyItemUserEffect(target);
}
};
Game_Action.prototype.processDefend = function() {
var success = (Math.random()*100 < perc);
return success;
};
Thank-you for reading, hope I didn't confuse things! 🙂