RMMZ [SOLVED] Visustella Battle Core - Customizing Critical Hit Damage Multiplier

Status
Not open for further replies.

J_Heider

Warper
Member
Joined
Nov 29, 2021
Messages
3
Reaction score
2
First Language
Portuguese
Primarily Uses
RMMZ
Hello everyone!

I'm using VisuStella's amazing plugins in my project and so far I'm loving that they are giving me new and interesting options to customize gameplay. I'm running into a stone wall though, and that is I can't customize the damage formula in the way I'm intending. Inside the Battle Core plugin, in Damage Settings > Critical Hits > Damage Formula, I've customized the formula into this:

// Declare Constants

const user = this.subject();
let damage = arguments[0];

let multiplier = 1 + ((this.subject().luk)/(300));

let bonusDamage = 0;

// let multiplier = 2.0;
// let bonusDamage = this.subject().luk * this.subject().cri;

// Return Damage

return damage * multiplier + bonusDamage;

This is my current formula. It works great so far as LUK has a very significant effect on critical hit damage. The problem with it, though, is that I would really like LUK to be both an offensive and a defensive stat (similar to how it already slightly increases the chances of you inflicting a negative status as well as avoiding it).

Then my idea was to change this formula into the following:

let multiplier = Math.min(1 + ((this.subject().luk)/(TARGET's LUK)), 4)

In this formula, the damage dealt by critical hits would float between x1 to x4 the amount of a normal hit, depending on both the attacker's and the target's LUK stats.

This could give a much necessary edge to my feeblish Rogue and Healer classes with their high LUK stats, in that they would be dealing more damage with critical hits (DPS edge over Warrior classes considering the high AGI of Rogues) while also taking less damage from them (so they can withstand damage from high-critical hit enemies better than Mage classes).

The problem is I don't know how to reference the "TARGET'S LUK" part in this formula, I've tried "target.luk", as I've seen other parts of the script use this type of notation to use target's stats in calculations. However, that simply returned an error when I playtested it.

What should I do? I have little to no knowledge of Javascript and the RMMZ base engine plugins (scripts?), nothing besides the mathematical operations/notations and a rudimentary understanding of how some functions work, so I don't know if this is a stupid question (I'm sorry, if that's the case). Thanks in advance!
 

caethyril

^_^
Global Mod
Joined
Feb 21, 2018
Messages
3,045
Reaction score
2,358
First Language
EN
Primarily Uses
RMMZ
By default the critical damage method applyCritical doesn't receive a reference to the current target, so I'm guessing no target variable is available. Unfortunately, each target gets shifted out of the queue just before the action is invoked on that target, so there's no convenient global reference unless you store the target list at an earlier point.

In case you're interested, I've implemented a workaround for this in my OnUseEffects plugin:
With this, you should be able to customise the critical damage formula via the corresponding parameter. Remember to save your project to apply Plugin Manager changes before testing. Hopefully it's compatible with VisuStella. :kaoswt:
 

NaosoX

Veteran
Veteran
Joined
Feb 28, 2013
Messages
351
Reaction score
185
First Language
English
Primarily Uses
RMMZ
you just haven't defined target...
Code:
// Declare Constants
const user = this.subject();
let damage = arguments[0];
const target = arguments[1];

let multiplier = Math.min(1 + ((this.subject().luk)/(target.luk)), 4);
let bonusDamage = 0;
 

caethyril

^_^
Global Mod
Joined
Feb 21, 2018
Messages
3,045
Reaction score
2,358
First Language
EN
Primarily Uses
RMMZ
@NaosoX: I just tested this with VisuStella MZ Battle Core version 1.43 (July 2021):
JavaScript:
console.log('crit target:', arguments[1]);
It logs crit target: undefined on crit for me. Is that just because I'm testing on the older version, or do you see the same thing? :kaoswt:
 

NaosoX

Veteran
Veteran
Joined
Feb 28, 2013
Messages
351
Reaction score
185
First Language
English
Primarily Uses
RMMZ
@NaosoX: I just tested this with VisuStella MZ Battle Core version 1.43 (July 2021):
JavaScript:
console.log('crit target:', arguments[1]);
It logs crit target: undefined on crit for me. Is that just because I'm testing on the older version, or do you see the same thing? :kaoswt:
hrmm, I didn't return any error. let me try again

Edit: Since I didn't save what I did previously, i pasted it in and it now returns undefined.
Sorry guys :kaoswt:
 
Last edited:

J_Heider

Warper
Member
Joined
Nov 29, 2021
Messages
3
Reaction score
2
First Language
Portuguese
Primarily Uses
RMMZ
@caethyril I'll try your solution, but my guts tell me that plugin won't be compatible with Visustella's. Let's hope, I'll reply later with whatever I find.

you just haven't defined target...
Code:
// Declare Constants
const user = this.subject();
let damage = arguments[0];
const target = arguments[1];

let multiplier = Math.min(1 + ((this.subject().luk)/(target.luk)), 4);
let bonusDamage = 0;
I've tried that and it gives me the same error message.

"TypeError"
"Cannot read property 'luk' of undefined"
EDIT:@caethyril Your plugin works perfectly, my formula returned the expected values during my playtest, but guess what? It seems it's not compatible with VisuStella's Battle Core... at least as far as I tried messing with it. I tried to "//" all the parts of that plugin regarding Critical Damage but it didn't work. I get the same error message mentioning the undefined variable. It only works if I turn Battle Core off.

So now I either ditch Visustella's plugin completely (including I don't know how many features I'm already counting on to develop my project), or I go with Cae's plugin instead (which also has an immense amount of interesting applications, just not ones that can overlap VisuStella's features). If you guys have alternative plugins or strategies I should consider, I'm accepting all suggestions. Nevertheless, thank you Caethyril for your awesome work and help!
 
Last edited:

NaosoX

Veteran
Veteran
Joined
Feb 28, 2013
Messages
351
Reaction score
185
First Language
English
Primarily Uses
RMMZ
Critical Damage Formula calculates like this:
Code:
// Return Damage
return damage * multiplier + bonusDamage;

Try this: instead of modifying critical multiplier, set multiplier to 1, keeping the original damage value.

your bonus damage is 0.
Code:
// Declare Constants
const user = this.subject();
let damage = arguments[0];

let bonusDamage = 0;
let multiplier = 1;

then in overall formula, under //Apply Critical Modifiers
Code:
// Apply Critical Modifiers
if (critical) {
    value = this.applyCritical(value * Math.min(1 + ((this.subject().luk) / target.luk)), 4);
}

This basically calculates the multiplier here, instead of only returning value set out by the Critical calculation section.
Let me know if this functions the way you were looking for.
 
Last edited:

J_Heider

Warper
Member
Joined
Nov 29, 2021
Messages
3
Reaction score
2
First Language
Portuguese
Primarily Uses
RMMZ
Critical Damage Formula calculates like this:
Code:
// Return Damage
return damage * multiplier + bonusDamage;

Try this: instead of modifying critical multiplier, set multiplier to 1, keeping the original damage value.

your bonus damage is 0.
Code:
// Declare Constants
const user = this.subject();
let damage = arguments[0];

let bonusDamage = 0;
let multiplier = 1;

then in overall formula, under //Apply Critical Modifiers
Code:
// Apply Critical Modifiers
if (critical) {
    value = this.applyCritical(value * Math.min(1 + ((this.subject().luk) / target.luk)), 4);
}

This basically calculates the multiplier here, instead of only returning value set out by the Critical calculation section.
Let me know if this functions the way you were looking for.
You're a genius! That worked like a charm! I suppose I could still use Caethyril's plugin and its other functions as long as I don't create new formulas... I don't know, I'll keep on testing on it. But as far as my problem was concerned, this thread can be closed now. Problem solved. Thanks everyone!
 

caethyril

^_^
Global Mod
Joined
Feb 21, 2018
Messages
3,045
Reaction score
2,358
First Language
EN
Primarily Uses
RMMZ
Nice workaround! :kaojoy:
EDIT:@caethyril Your plugin works perfectly, my formula returned the expected values during my playtest, but guess what? It seems it's not compatible with VisuStella's Battle Core ... I get the same error message mentioning the undefined variable. It only works if I turn Battle Core off.
Ah well, good to know. I think VisuStella might apply its overrides after all plugins have loaded (?). In that case it should be possible to rewrite my stuff in a way that is compatible with their stuff...maybe an optional "patch after load" parameter or something. I'm not planning to experiment with that any time soon, though. :kaoslp:

This thread is being closed, due to being solved. If for some reason you would like this thread re-opened, please report this post and leave a message why. Thank you.

 
Status
Not open for further replies.

Latest Threads

Latest Posts

Latest Profile Posts

I have never felt so attacked by a tree before :LZSlol: it took 10++ hours to make but at least it looks pretty LOL

Untitled-1.png
now seems like the worst time for me to need a better computer with how much stuff is costing. that and I don't thing there's much else I can do to make MV run any better with what I have.
Sigh... to have some variety in this weather. More than just sun and rain and wind and thunder.
In the meantime, I've discovered that I'm slowly becoming fatigued from the many sleepless nights my neighbors cause. Or at least their dogs. Always barking at something.
I might need a day to just sleep and recharge.
After the initial success with one event, I set up four different events on the same map to detect who is in which slot in my current party, and fortunately it managed to work as intended, with the events changing image to match the party members even as I swapped their positions around in formation. This will be a great tool for immersive scene design.

Forum statistics

Threads
118,450
Messages
1,116,073
Members
155,425
Latest member
thealchemist222
Top