Turning luck into a different attribute?

Dark_Ansem

Regular
Regular
Joined
Jun 16, 2020
Messages
593
Reaction score
145
First Language
English
Primarily Uses
RMMZ
If you're confused, I just don't understand why you're messing with it at all. It takes seconds to copy and paste a formula between different skills, so the whole damage styles thing saves you such minimal effort to begin with (in my opinion).
I'm doing that as well, just need to focus the math.

It doesn't seem to have anything to do with your original question with the Luck stuff.

If you've moved onto how the damage styles in this specific plugin work, that seems like that's about carefully reading the documentation or doing some really simple testing that would take, like, three minutes (make a style do 10 damage, overwrite one sklll to do 15 damage, see whether it does 10 or 15 damage in game. Done. :wink:).
I mean it does and it's all related. I've just not had chance to playtest since I've just been working most of the day and when I wasnt i was asset editing/hunting, hence why I've asked in the forum.. am trying to multitask as much as possible. Thank you for your help.

Ps: I've read the documentation but it doesn't provide the reply I need, hence why I'm asking. I hope that is not too much trouble.
 

Dark_Ansem

Regular
Regular
Joined
Jun 16, 2020
Messages
593
Reaction score
145
First Language
English
Primarily Uses
RMMZ
If you've moved onto how the damage styles in this specific plugin work, that seems like that's about carefully reading the documentation or doing some really simple testing that would take, like, three minutes (make a style do 10 damage, overwrite one sklll to do 15 damage, see whether it does 10 or 15 damage in game. Done. :wink:).
So, there is an override system in place which works just for me - as it works on a single-skill basis.
Now, just need to work out the math for the default formula!
 

Dark_Ansem

Regular
Regular
Joined
Jun 16, 2020
Messages
593
Reaction score
145
First Language
English
Primarily Uses
RMMZ
So, this is the damage formula syntax

JavaScript:
if (this.isPhysical() && (this.isDamage() || this.isDrain())) {
    value = (((a.atk ** 3) / 32) + 32) * power / 16;
} else if (this.isMagical() && (this.isDamage() || this.isDrain())) {
    value = power * ((a.mat ** 2 / 6) + power) / 4;
} else if (this.isPhysical() && this.isRecover()) {
    value = power * ((a.def + power) / 2);
} else if (this.isMagical() && this.isRecover()) {
    value = power * ((a.mdf + power) / 2);
}

two things: first off, I think a parenthesis is missing in row 4, secondly, would this be the correct syntax for making it most similar to how it works in FFT?

27ff0339d0359cc1937e7753a7a988be2b3d10a7


JavaScript:
} else if (this.isMagical() && (this.isDamage() || this.isDrain())) {
    value = power * (((a.mat ** 2 / 6) + power) / 4) * a.luk * b.luk;

JavaScript:
} else if (this.isMagical() && this.isRecover()) {
    value = power * ((a.mdf + power) / 2) * a.luk * b.luk;
 
Last edited:

Dark_Ansem

Regular
Regular
Joined
Jun 16, 2020
Messages
593
Reaction score
145
First Language
English
Primarily Uses
RMMZ
So, a little update. Turns out that with the Core VS plugins it IS possible to make an entirely new attribute AND make it work in formulas.

However, the idea of using luck as a "new" attribute kind of grew on me, I like the idea of influencing events inside and outside battle. Sort of making the strength of your belief work for you!
 

Dark_Ansem

Regular
Regular
Joined
Jun 16, 2020
Messages
593
Reaction score
145
First Language
English
Primarily Uses
RMMZ
remade it so that it's a bit more tidy?

JavaScript:
// Define Constants
const user = this.subject();
const target = arguments[0];
const item = this.item();
const a = this.subject();
const b = target;
const v = $gameVariables._data;
const sign = [3, 4].includes(item.damage.type) ? -1 : 1;

// Create Damage Constant
const power = Math.max(eval(item.damage.formula), 0);
if (this.isCertainHit()) {
    return (isNaN(power) ? 0 : power) * sign;
}

// Create Damage Offense Value
let value = power;

if (this.isPhysical() && (this.isDamage() || this.isDrain())) {
    value = (((a.atk ** 3) / 32) + 32) * power / 16;
} else if (this.isMagical() && (this.isDamage() || this.isDrain())) {
    value = power * ((a.mat ** 2 / 6) + power) / 4;
    value *= a.luk * b.luk; // Multiply by caster's and target's luck
} else if (this.isPhysical() && this.isRecover()) {
    value = power * ((a.def + power) / 2);
} else if (this.isMagical() && this.isRecover()) {
    value = power * ((a.mdf + power) / 2);
    value *= a.luk * b.luk; // Multiply by caster's and target's luck
}

// Apply Damage Defense Value
if (this.isDamage() || this.isDrain()) {
    let armor = this.isPhysical() ? b.def : b.mdf;
    armor = this.applyArmorModifiers(b, armor);
    armor = Math.max(armor, 1);
    value *= ((((armor - 280.4) ** 2) / 110) / 16) / 730;
    value *= (730 - (armor * 51 - (armor ** 2) / 11) / 10) / 730;
} else if (this.isRecover()) {
    value *= -1;
}

// Return Value
return isNaN(value) ? 0 : value;
 

Dark_Ansem

Regular
Regular
Joined
Jun 16, 2020
Messages
593
Reaction score
145
First Language
English
Primarily Uses
RMMZ
Updated so that hopefully it's clearer
JavaScript:
// Define Constants
const user = this.subject();
const target = arguments[0];
const item = this.item();
const a = this.subject();
const b = target;
const v = $gameVariables._data;
const sign = [3, 4].includes(item.damage.type) ? -1 : 1;

// Create Damage Constant
const power = Math.max(eval(item.damage.formula), 0);
if (this.isCertainHit()) {
    return (isNaN(power) ? 0 : power) * sign;
}

// Create Damage Offense Value
let value = power;

if (this.isPhysical() && (this.isDamage() || this.isDrain())) {
    value = (((a.atk ** 3) / 32) + 32) * power / 16;
} else if (this.isMagical() && (this.isDamage() || this.isDrain())) {
    value = power * ((a.mat ** 2 / 6) + power) / 4;
    value *= a.luk; // Add caster's luck as a multiplier
} else if (this.isPhysical() && this.isRecover()) {
    value = power * ((a.def + power) / 2);
} else if (this.isMagical() && this.isRecover()) {
    value = power * ((a.mdf + power) / 2);
    value *= a.luk; // Add caster's luck as a multiplier
}

// Apply Damage Defense Value
if (this.isDamage() || this.isDrain()) {
    let armor = this.isPhysical() ? b.def : b.mdf;
    armor = this.applyArmorModifiers(b, armor);
    armor = Math.max(armor, 1);
    value *= ((((armor - 280.4) ** 2) / 110) / 16) / 730;
    value *= (730 - (armor * 51 - (armor ** 2) / 11) / 10) / 730;
    if (this.isMagical()) {
        value *= b.luk; // Add target's luck as a multiplier
    }
} else if (this.isRecover()) {
    value *= -1;
}

// Return Value
return isNaN(value) ? 0 : value;
 

Dark_Ansem

Regular
Regular
Joined
Jun 16, 2020
Messages
593
Reaction score
145
First Language
English
Primarily Uses
RMMZ
Yet another variation.

JavaScript:
// Define Constants
const user = this.subject();
const target = arguments[0];
const item = this.item();
const a = this.subject();
const b = target;
const v = $gameVariables._data;
const sign = [3, 4].includes(item.damage.type) ? -1 : 1;

// Create Damage Constant
const power = Math.max(eval(item.damage.formula), 0);
if (this.isCertainHit()) {
    return (isNaN(power) ? 0 : power) * sign;
}

// Create Damage Offense Value
let value = power;

if (this.isPhysical() && (this.isDamage() || this.isDrain())) {
    value = (((a.atk ** 3) / 32) + 32) * power / 16;
} else if (this.isMagical() && (this.isDamage() || this.isDrain())) {
    value = power * ((a.mat ** 2 / 6) + power) / 4 * ((a.luk - 15) * (3 - 1) / (255 - 15) + 1);
} else if (this.isPhysical() && this.isRecover()) {
    value = power * ((a.def + power) / 2);
} else if (this.isMagical() && this.isRecover()) {
    value = power * ((a.mdf + power) / 2) * ((a.luk - 15) * (3 - 1) / (255 - 15) + 1);
}

// Apply Damage Defense Value
if (this.isDamage() || this.isDrain()) {
    let armor = this.isPhysical() ? b.def : b.mdf;
    if (this.isMagical()) {
        armor *= (1 + ((b.luk - 15) * (0.5 - 1) / (255 - 15)));
    }
    armor = this.applyArmorModifiers(b, armor);
    armor = Math.max(armor, 1);
    value *= ((((armor - 280.4) ** 2) / 110) / 16) / 730;
    value *= (730 - (armor * 51 - (armor ** 2) / 11) / 10) / 730;
} else if (this.isRecover()) {
    value *= -1;
}

// Return Value
return isNaN(value) ? 0 : value;
 
Last edited:

Dark_Ansem

Regular
Regular
Joined
Jun 16, 2020
Messages
593
Reaction score
145
First Language
English
Primarily Uses
RMMZ
More changes

JavaScript:
// Define Constants
const user = this.subject();
const target = arguments[0];
const item = this.item();
const a = this.subject();
const b = target;
const v = $gameVariables._data;
const sign = [3, 4].includes(item.damage.type) ? -1 : 1;

// Create Damage Constant
const power = Math.max(eval(item.damage.formula), 0);
if (this.isCertainHit()) {
    return (isNaN(power) ? 0 : power) * sign;
}

// Create Damage Offense Value
let value = power;

if (this.isPhysical() && (this.isDamage() || this.isDrain())) {
    value = (((a.atk ** 3) / 32) + 32) * power / 16;
} else if (this.isMagical() && (this.isDamage() || this.isDrain())) {
    value = power * ((a.mat ** 2 / 6) + power) / 4 * (a.luk <= 15 ? (a.luk / 15) : ((a.luk - 15) * (3 - 1) / (255 - 15) + 1));
} else if (this.isPhysical() && this.isRecover()) {
    value = power * ((a.def + power) / 2);
} else if (this.isMagical() && this.isRecover()) {
    value = power * ((a.mdf + power) / 2) * (a.luk <= 15 ? (a.luk / 15) : ((a.luk - 15) * (3 - 1) / (255 - 15) + 1));
}

// Apply Damage Defense Value
if (this.isDamage() || this.isDrain()) {
    let armor = this.isPhysical() ? b.def : b.mdf;
    if (this.isMagical()) {
        armor *= (1 + (b.luk <= 15 ? ((b.luk - 15) / 15) : ((b.luk - 15) * (0.5 - 1) / (255 - 15))));
    }
    armor = this.applyArmorModifiers(b, armor);
    armor = Math.max(armor, 1);
    value *= ((((armor - 280.4) ** 2) / 110) / 16) / 730;
    value *= (730 - (armor * 51 - (armor ** 2) / 11) / 10) / 730;
} else if (this.isRecover()) {
    value *= -1;
}

// Return Value
return isNaN(value) ? 0 : value;
 

Dark_Ansem

Regular
Regular
Joined
Jun 16, 2020
Messages
593
Reaction score
145
First Language
English
Primarily Uses
RMMZ
Boy math really isn't my strength
JavaScript:
// Define Constants
const user = this.subject();
const target = arguments[0];
const item = this.item();
const a = this.subject();
const b = target;
const v = $gameVariables._data;
const sign = [3, 4].includes(item.damage.type) ? -1 : 1;

// Create Damage Constant
const power = Math.max(eval(item.damage.formula), 0);
if (this.isCertainHit()) {
    return (isNaN(power) ? 0 : power) * sign;
}

// Create Damage Offense Value
let value = power;

if (this.isPhysical() && (this.isDamage() || this.isDrain())) {
    value = (((a.atk ** 3) / 32) + 32) * power / 16;
} else if (this.isMagical() && (this.isDamage() || this.isDrain())) {
    value = power * ((a.mat ** 2 / 6) + power) / 4 * (a.luk <= 15 ? (a.luk / 15) : ((a.luk - 15) * (3 - 1) / (255 - 15) + 1));
} else if (this.isPhysical() && this.isRecover()) {
    value = power * ((a.def + power) / 2);
} else if (this.isMagical() && this.isRecover()) {
    value = power * ((a.mdf + power) / 2) * (a.luk <= 15 ? (a.luk / 15) : ((a.luk - 15) * (3 - 1) / (255 - 15) + 1));
}

// Apply Damage Defense Value
if (this.isDamage() || this.isDrain()) {
    let armor = this.isPhysical() ? b.def : b.mdf;
    if (this.isMagical()) {
        armor *= (1 + (b.luk <= 15 ? ((15 - b.luk) / 15) : ((255 - b.luk) * (0.5 - 1) / (255 - 15))));
    }
    armor = this.applyArmorModifiers(b, armor);
    armor = Math.max(armor, 1);
    value *= ((((armor - 280.4) ** 2) / 110) / 16) / 730;
    value *= (730 - (armor * 51 - (armor ** 2) / 11) / 10) / 730;
} else if (this.isRecover()) {
    value *= -1;
}

// Return Value
return isNaN(value) ? 0 : value;
 

Dark_Ansem

Regular
Regular
Joined
Jun 16, 2020
Messages
593
Reaction score
145
First Language
English
Primarily Uses
RMMZ
JavaScript:
// Define Constants
const user = this.subject();
const target = arguments[0];
const item = this.item();
const a = this.subject();
const b = target;
const v = $gameVariables._data;
const sign = [3, 4].includes(item.damage.type) ? -1 : 1;

// Create Damage Constant
const power = Math.max(eval(item.damage.formula), 0);
if (this.isCertainHit()) {
    return (isNaN(power) ? 0 : power) * sign;
}

// Create Damage Offense Value
let value = power;

if (this.isPhysical() && (this.isDamage() || this.isDrain())) {
    value = (((a.atk ** 3) / 32) + 32) * power / 16;
} else if (this.isMagical() && (this.isDamage() || this.isDrain())) {
    value = power * ((a.mat ** 2 / 6) + power) / 4 * (a.luk <= 15 ? (a.luk / 15) : ((a.luk - 15) * (3 - 1) / (255 - 15) + 1));
} else if (this.isPhysical() && this.isRecover()) {
    value = power * ((a.def + power) / 2);
} else if (this.isMagical() && this.isRecover()) {
    value = power * ((a.mdf + power) / 2) * (a.luk <= 15 ? (a.luk / 15) : ((a.luk - 15) * (3 - 1) / (255 - 15) + 1));
}

// Apply Damage Defense Value
if (this.isDamage() || this.isDrain()) {
    let armor = this.isPhysical() ? b.def : b.mdf;
    armor = this.applyArmorModifiers(b, armor);
    armor = Math.max(armor, 1);
    value *= ((((armor - 280.4) ** 2) / 110) / 16) / 730;
    value *= (730 - (armor * 51 - (armor ** 2) / 11) / 10) / 730;
    if (this.isMagical()) {
        if (b.luk === 0) {
            value = 0; // no damage received
        } else if (b.luk < 15) {
            value *= b.luk / 15; // scales from 0 (at luck 1) to 1 (at luck 14)
        } else {
            value *= 1 + (b.luk - 15) * (2 - 1) / (255 - 15); // scales from 1 (at luck 15) to 2 (at luck 255)
        }
    }
} else if (this.isRecover()) {
    value *= -1;
}

// Return Value
return isNaN(value) ? 0 : value;
 
Last edited:

Dark_Ansem

Regular
Regular
Joined
Jun 16, 2020
Messages
593
Reaction score
145
First Language
English
Primarily Uses
RMMZ
JavaScript:
// Declare Constants
const target = arguments[0];
const critical = arguments[1];
const item = this.item();
const a = this.subject(); // Added this line to get the subject (user)

// Function to calculate luck-based scaling
function luckScaling(luk, maxScale) {
    return luk <= 15 ? (luk / 15) : ((luk - 15) * (maxScale - 1) / (255 - 15) + 1);
}

// Function to calculate MP-based scaling
function mpScaling(mmp) {
    return mmp * 0.1; // 10% of max MP
}

// Get Base Damage
let baseValue = this.evalDamageFormula(target);

// Add the luck-based scaling factor for magical attacks and recoveries
if (this.isMagical() && (this.isDamage() || this.isDrain() || this.isRecover())) {
    baseValue *= luckScaling(a.luk, 3); // max scaling factor for attack is 3
    baseValue += mpScaling(a.mmp); // Add MP-based scaling
}

// Calculate Element Modifiers
let value = baseValue * this.calcElementRate(target);

// Calculate Physical and Magical Modifiers
if (this.isPhysical()) {
    value *= target.pdr;
}
if (this.isMagical()) {
    value *= target.mdr;
    value *= luckScaling(target.luk, 2); // max scaling factor for defense is 2
}

// Apply Healing Modifiers
if (baseValue < 0) {
    value *= target.rec;
}

// Apply Critical Modifiers
if (critical) {
    value = this.applyCritical(value);
}

// Apply Variance and Guard Modifiers
value = this.applyVariance(value, item.damage.variance);
value = this.applyGuard(value, target);

// Finalize Damage
value = Math.round(value);
return value;
 
Last edited:

Dark_Ansem

Regular
Regular
Joined
Jun 16, 2020
Messages
593
Reaction score
145
First Language
English
Primarily Uses
RMMZ
JavaScript:
// Declare Constants
const target = arguments[0];
const critical = arguments[1];
const item = this.item();
const a = this.subject(); // The attacker

// Function to calculate faith-based scaling
function FaithScaling(luk, maxScale) {
    return luk <= 15 ? (luk / 15) : ((luk - 15) * (maxScale - 1) / (255 - 15) + 1);
}

// Function to calculate MP-based scaling
function MaxMpScaling(mmp) {
    return mmp * 0.1; // 10% of max MP
}

// Calculate Base Damage
let baseValue = this.evalDamageFormula(target);

// Apply Faith and MP Scaling for Magical Actions
if (this.isMagical() && (this.isDamage() || this.isDrain() || this.isRecover())) {
    const faithFactor = FaithScaling(a.luk, 3); // Max scaling factor for attack is 3
    const mpFactor = MaxMpScaling(a.mmp); // MP-based scaling
    baseValue = baseValue * faithFactor + mpFactor;
}

// Calculate Element Modifiers
let value = baseValue * this.calcElementRate(target);

// Apply Physical and Magical Modifiers
if (this.isPhysical()) {
    value *= target.pdr;
}
if (this.isMagical()) {
    value *= target.mdr;
    const defenseFaithFactor = FaithScaling(target.luk, 2); // Max scaling factor for defense is 2
    value *= defenseFaithFactor;
}

// Apply Healing Modifiers
if (baseValue < 0) {
    value *= target.rec;
}

// Apply Critical Modifiers
if (critical) {
    value = this.applyCritical(value);
}

// Apply Variance and Guard Modifiers
value = this.applyVariance(value, item.damage.variance);
value = this.applyGuard(value, target);

// Finalize and Return Damage
return Math.round(value);
 
Last edited:

Latest Threads

Latest Posts

Latest Profile Posts

I’m so lucky! Simone got referred to a feline cardiologist and had I not called this morning the moment there was a cancellation the next opening would have been SEVEN months from now! The other heart hospital would have been on the other side of Michigan. Who knew that animal specialty appointments were also terrible to get!?
Scalemail project is one step closer to completion. Ordered scales from a local metalworking company, ordered some split rings... now all I need is to wait. :>
And pray that the split rings will be flexible enough to handle that.
A spooky banner and a spooky pfp for a spooky season.
Spooky-Season.png
Broke: Actually making the stuff you need to make before the game can progress.
Woke: Wasting time instead by making a sidequest where you can recruit an imaginary friend to the party.
1696264391516.png
Day 1 I don't know where to start... I enjoy designing icons and brainstorming the abilities my video game will have

Forum statistics

Threads
134,991
Messages
1,252,685
Members
177,900
Latest member
LinkIncGames
Top