Hi, so I've recently picked up RPGMZ since it was on sale and thought it would be fun to put some stored game concepts into practice. Then, I found out that it's run on JS, a language I utilize the most (or as much as a non-professional student hobbyist would). So, I had fun with this particular concept I liked:
Class "Contractor" playstyle is based on their Skill "Create Contract" which the Caster will average its stats between the Ally Target and itself. It will also be able to learn all of the abilities that the Ally Target has.
For something like this, I'm quite sure that there is no pure vanilla "use the dropdowns" way of making this work, so I decided to code something. So far, I've only done the main concept and it technically works in test battles, but it feels messy (plus the fact I'll have to make sure the Contract---maybe turn into a state as Contractor and Contractee--ends and the Caster loses the stat boost and learned abilities). Although I feel like I can certainly do that as a Common Event that ends, it seems like it should be simpler if I learn to create a plug-in.
I haven't created a plug-in, but from what I see from messing around with function codes in the test battles and viewing a few lines of plugins, would something like this just require creating a function in form with MZ's style?
And the code for reference:
Class "Contractor" playstyle is based on their Skill "Create Contract" which the Caster will average its stats between the Ally Target and itself. It will also be able to learn all of the abilities that the Ally Target has.
For something like this, I'm quite sure that there is no pure vanilla "use the dropdowns" way of making this work, so I decided to code something. So far, I've only done the main concept and it technically works in test battles, but it feels messy (plus the fact I'll have to make sure the Contract---maybe turn into a state as Contractor and Contractee--ends and the Caster loses the stat boost and learned abilities). Although I feel like I can certainly do that as a Common Event that ends, it seems like it should be simpler if I learn to create a plug-in.
I haven't created a plug-in, but from what I see from messing around with function codes in the test battles and viewing a few lines of plugins, would something like this just require creating a function in form with MZ's style?
And the code for reference:
JavaScript:
let gtCs = $dataSystem.variables[98]; // Caster -->
let gtTg = $dataSystem.variables[99]; // Target --> kept in a variable through the formula (yes, I know it's bad, but it's quick and doesn't target an enemy instead)
if (JSON.stringify(gtCs) === JSON.stringify(gtTg)){
$gameMessage.add("A contract cannot be formed with this target.");
} // to make sure the user can't target themselves (haven't tested it on auto)
else {
// HP,MP,ATK,DEF,MAT,MDF,AGI,LUK
gtCs.addParam(0, Math.floor((gtCs.mhp + gtTg.mhp*1.2)/2 - gtCs.mhp));
gtCs.gainHp(Math.floor((gtCs.mhp + gtTg.mhp*1.2)/2 - gtCs.mhp)); // to supplement the boosted HP that doesn't regen
gtCs.addParam(1, Math.floor((gtCs.mmp + gtTg.mmp*1.2)/2 - gtCs.mmp));
gtCs.gainMp(Math.floor((gtCs.mmp + gtTg.mmp*1.2)/2 - gtCs.mmp)); // same as above (only kept the archaic code since I originally thought something was wrong with this code)
gtCs.addParam(2, (gtCs.atk + gtTg.atk*1.2)/2 - gtCs.atk);
gtCs.addParam(3, (gtCs.def + gtTg.def*1.2)/2 - gtCs.def);
gtCs.addParam(4, (gtCs.mat + gtTg.mat*1.2)/2 - gtCs.mat);
gtCs.addParam(5, (gtCs.mdf + gtTg.mdf*1.2)/2 - gtCs.mdf);
gtCs.addParam(6, (gtCs.agi + gtTg.agi*1.2)/2 - gtCs.agi);
gtCs.addParam(7, (gtCs.luk + gtTg.luk*1.2)/2 - gtCs.luk);
// ADD SKILLS
// Basically just looked at actor objects and just messed around and saw this worked
for (var i=0; i<gtTg.skills().length; i++){gtCs.learnSkill(gtTg.skills()[i].id);}
// If there was a simpler way to just make this a state, that would be actually great
// Maybe a plugin that makes a custom state and adds skills as traits with each use of the skill-- of course rewriting previous state (is this a good idea?)
// State -> Add Skill Type
let gtClassNM = $dataClasses.find(x => x !== null && gtTg._classId).name
// Since I couldn't find a particular way to fix this, I ended up finding that making this a state was much more efficient
// And the [] of just the Class to Skill Types matching because I forgot they all have IDs
if (["Soldier","Mercenary"].includes(gtClassNM)) {gtCs.addNewState(45);} // Sword
if (["Merchant"].includes(gtClassNM)) {gtCs.addNewState(46);} // Spear
if (["Archer","Hunter"].includes(gtClassNM)) {gtCs.addNewState(47);} // Bow
if (["Soldier","Mercenary","Merchant","Nomad"].includes(gtClassNM)) {gtCs.addNewState(48);} // Shield
if (["Nomad"].includes(gtClassNM)) {gtCs.addNewState(49);} // Fist
if (["Priest","Nomad"].includes(gtClassNM)) {gtCs.addNewState(50);} // Healing
$gameMessage.add(gtCs.nickname() + " formed a contract with " + gtTg.nickname()); // For text purposes
}