Fernyfer775

Veteran
Veteran
Joined
Oct 6, 2013
Messages
1,319
Reaction score
827
First Language
English
Hey all. So, in my current project, I reworked "LUCK" into a stat called "POWER" which serves as an indicator of a piece of gear's potential/strength/what-have-you. My question is two-fold:

  1. How exactly does the default optimize button work? How are stats weighed? Does it just put on the piece with the highest total amount of stats on it, skewing items with higher hp/mp to always be equipped?
  2. Is there a way to change the way the optimize formula works to be based off one stat instead: LUCK? If so, HOW?
If it helps, this is the code found within "rpg_objects" which is where, I'm sure, you would alter the formula:
Game_Actor.prototype.bestEquipItem = function(slotId) {
var etypeId = this.equipSlots()[slotId];
var items = $gameParty.equipItems().filter(function(item) {
return item.etypeId === etypeId && this.canEquip(item);
}, this);
var bestItem = null;
var bestPerformance = -1000;
for (var i = 0; i < items.length; i++) {
var performance = this.calcEquipItemPerformance(items);
if (performance > bestPerformance) {
bestPerformance = performance;
bestItem = items;
}
}
return bestItem;
};

Game_Actor.prototype.calcEquipItemPerformance = function(item) {
return item.params.reduce(function(a, b) {
return a + b;
});
};

Any/all help would be appreciated, thank you! ^_^
 
Last edited:

gstv87

Veteran
Veteran
Joined
Oct 20, 2015
Messages
2,708
Reaction score
1,779
First Language
Spanish
Primarily Uses
RMVXA
Code:
Window_EquipCommand.prototype.makeCommandList = function() {
    this.addCommand(TextManager.equip2,   'equip');
    this.addCommand(TextManager.optimize, 'optimize'); <-
    this.addCommand(TextManager.clear,    'clear');
};

Scene_Equip.prototype.createCommandWindow = function() {
    var wx = this._statusWindow.width;
    var wy = this._helpWindow.height;
    var ww = Graphics.boxWidth - this._statusWindow.width;
    this._commandWindow = new Window_EquipCommand(wx, wy, ww);
    this._commandWindow.setHelpWindow(this._helpWindow);
    this._commandWindow.setHandler('equip',    this.commandEquip.bind(this));
    this._commandWindow.setHandler('optimize', this.commandOptimize.bind(this)); <-
    this._commandWindow.setHandler('clear',    this.commandClear.bind(this));
    this._commandWindow.setHandler('cancel',   this.popScene.bind(this));
    this._commandWindow.setHandler('pagedown', this.nextActor.bind(this));
    this._commandWindow.setHandler('pageup',   this.previousActor.bind(this));
    this.addWindow(this._commandWindow);
};

Scene_Equip.prototype.commandOptimize = function() {
    SoundManager.playEquip();
    this.actor().optimizeEquipments(); <-
    this._statusWindow.refresh();
    this._slotWindow.refresh();
    this._commandWindow.activate();
};

Game_Actor.prototype.optimizeEquipments = function() {
    var maxSlots = this.equipSlots().length;
    this.clearEquipments();
    for (var i = 0; i < maxSlots; i++) {
        if (this.isEquipChangeOk(i)) {
            this.changeEquip(i, this.bestEquipItem(i)); <-
        }
    }
};

Game_Actor.prototype.bestEquipItem = function(slotId) {
    var etypeId = this.equipSlots()[slotId];
    var items = $gameParty.equipItems().filter(function(item) {
        return item.etypeId === etypeId && this.canEquip(item);
    }, this);
    var bestItem = null;
    var bestPerformance = -1000;
    for (var i = 0; i < items.length; i++) {
        var performance = this.calcEquipItemPerformance(items[i]); <-
        if (performance > bestPerformance) {
            bestPerformance = performance;
            bestItem = items[i];
        }
    }
    return bestItem;
};

Game_Actor.prototype.calcEquipItemPerformance = function(item) {
    return item.params.reduce(function(a, b) {  <-
        return a + b;  <-
    });
};

from the literal word "optimize" to the actual logic in 6 jumps.
sometimes, a simple search is all it takes.

short answer, yes, you can.
long answer, you'll have to grab that parameter Luck, and translate it to a simple number that you can use in an addition, or write a completely new formula that would suit you,... but yes, it can be done, it is all an addition of results.... wherever those results come from, for the function that processes them, is of no consequence to that function.... so you can feed it whatever numbers you want.
 

Fernyfer775

Veteran
Veteran
Joined
Oct 6, 2013
Messages
1,319
Reaction score
827
First Language
English
Thank you for taking the time to reply, but it doesn't quite get me to where I want to be with this.

See, I looked through that code, so I know where it would be altered, but I posted here because I don't know how to alter it. All the gear in my game already has the LUCK stat on it, which dictates how strong that piece of gear is. I am looking for help on how to change the code I posted in the OP to just cycle through the gear and slap on the piece that has the highest LUCK stat on it.

I'm a novice when it comes to javascript, so a lot of the stuff in that code is very foreign to me, and even with all my best attempts, I haven't managed to get it to just equip the pieces with the highest LUCK.
 

gstv87

Veteran
Veteran
Joined
Oct 20, 2015
Messages
2,708
Reaction score
1,779
First Language
Spanish
Primarily Uses
RMVXA
have calcItemPerformance() return the actual value of Luck then?

the comparison is made by bestEquipItem(), based on what calcItemPerformance() returns.
if your base for comparison is straight Luck,.... ?
 

Fernyfer775

Veteran
Veteran
Joined
Oct 6, 2013
Messages
1,319
Reaction score
827
First Language
English
Yeah, it's literally just the luck stat. So, I would just need the code to see the luck stat on the currently equipped item and then replace it with whatever other piece i have that has the highest luck .
 

gstv87

Veteran
Veteran
Joined
Oct 20, 2015
Messages
2,708
Reaction score
1,779
First Language
Spanish
Primarily Uses
RMVXA
actor.luk() ?

the base function should still be the same, even if you have renamed it.
 

Isabella Ava

Veteran
Veteran
Joined
Sep 13, 2016
Messages
635
Reaction score
756
First Language
English
Hey all. So, in my current project, I reworked "LUCK" into a stat called "POWER" which serves as an indicator of a piece of gear's potential/strength/what-have-you. My question is two-fold:

  1. How exactly does the default optimize button work? How are stats weighed? Does it just put on the piece with the highest total amount of stats on it, skewing items with higher hp/mp to always be equipped?
  2. Is there a way to change the way the optimize formula works to be based off one stat instead: LUCK? If so, HOW?
If it helps, this is the code found within "rpg_objects" which is where, I'm sure, you would alter the formula:
Game_Actor.prototype.bestEquipItem = function(slotId) {
var etypeId = this.equipSlots()[slotId];
var items = $gameParty.equipItems().filter(function(item) {
return item.etypeId === etypeId && this.canEquip(item);
}, this);
var bestItem = null;
var bestPerformance = -1000;
for (var i = 0; i < items.length; i++) {
var performance = this.calcEquipItemPerformance(items);
if (performance > bestPerformance) {
bestPerformance = performance;
bestItem = items;
}
}
return bestItem;
};

Game_Actor.prototype.calcEquipItemPerformance = function(item) {
return item.params.reduce(function(a, b) {
return a + b;
});
};

Any/all help would be appreciated, thank you! ^_^

Replace this:
Game_Actor.prototype.calcEquipItemPerformance = function(item) {
return item.params.reduce(function(a, b) {
return a + b;
});
};

with this:
Game_Actor.prototype.calcEquipItemPerformance = function(item) {
return item.params[7];
};
 

Fernyfer775

Veteran
Veteran
Joined
Oct 6, 2013
Messages
1,319
Reaction score
827
First Language
English
@Isabella Ava Works like a charm, thank you so much! :D (I have no idea what any of the function a, b, whatever means, so that's what was throwing me off)
 

Latest Threads

Latest Profile Posts

How is it called a rpg maker game without the default "pokemon-like" battle system?
Unfortunately, while trying to run an app I needed (curse you, Adobe!), my laptop blacked out, so my data got wiped when I got it repaired. Stuff like facesets are saved in my drive, but my sprites now only exist as screenshots I've taken in the past :kaocry:To be fair, I'm a little relieved, since I've been feeling unsatisfied with the visual style of the character sprites, and I guess I can now revamp them?

after lot's of edits to Mike's attacks (to make it seamless with movement, no EX versions, cost 1-ups), I finally got combo skills to work. had to do a lot moving tho to get the combo list to appear where it is lol. that actually took longer than setting up the moves.
What's kind of amazing is I've been in a developmental rut for the LONGEST time but putting a music mix on of video game soundtracks and specifically hearing the VX Ace music come up and it's nostalgia of me being excited to make my first game has REALLY got me going again!

Forum statistics

Threads
122,030
Messages
1,145,974
Members
160,292
Latest member
pkmngo
Top