Altering the formula for Speed.

Hey, I've been searching around and I cannot figure out how to change the formula that speed uses.

I know the formula is:
Game_Action.prototype.speed = function() {
var agi = this.subject().agi;
var speed = agi + Math.randomInt(Math.floor(5 + agi / 4));
if (this.item()) {
speed += this.item().speed;
}
if (this.isAttack()) {
speed += this.subject().attackSpeed();
}
return speed;


Basically I just want to know how to change it to combine the user's agility, magic attack, magic defense, and luck. I'll probably remove the random aspect of it but either way I'll deal with that later.
I tried altering the line:
var speed = agi + Math.randomInt(Math.floor(5 + agi / 4));
to
var speed = agi + mat + mdf + luk;
But, that didn't work.
So I don't know exactly how this line works:
var agi = this.subject().agi;
And, if it should be altered somehow. Any help would be appreciated.
u want something like this?
Code:
var agi = this.subject().agi;
var mat = this.subject().mat;
var mdf = this.subject().mdf;
var luk = this.subject().luk;
var speed = agi + mat + mdf + luk;
I tried it out but it still doesn't seem to matter what the other stats are. It still only seems to take into account what the agility is and ignores everything else. I test battled with 4 actors and 5 mobs all with base stats of 1, turned up a few actors stats to 50, 100, 10 and the only one that actually changes the order is altering their Agility stat.
Console log the value of speed after your formula to see if it really works or not. If not, then there's something wrong when calling the other stats' functions.
I cannot figure out how to change the formula that speed uses.
I just want to know how to change it to combine the user's agility, magic attack, magic defense, and luck

what for?

because, I believe you're confusing battle order with action execution.

Original thread: https://forums.rpgmakerweb.com/threads/altering-the-formula-for-speed.103391/