Optimize Equipment on Class Change

Good day.


I'm trying to make a little script snippet to force an actor to optimize their equipment when they change classes. I am using Yanfly's class change core plugin.


I found a script call that will optimize equipment on the actor it is called by ($gameActors.actor(id).optimizeEquiments()), but any attempt I've made to insert it into yanfly's plugin has failed. The most success I've seen actually had it working, but it was re-optimizing equips every time you scrolled through classes on the class change menu, instead of when actually changing classes. This caused a lot of lag as well.


I also tried modifying the Game_Actor.prototype.changeClass function from rpg_objects.js, but had the same issue, in that yanfly's class change plugin was causing it to attempt to optimize by scrolling through the menu of classes, instead of actually when changing them. Additionally, while the optimize seemed like it would happen on job change (the stat preview information on the right side of the screen updated as if it were being optimized), it actually didn't happen, but still caused massive lag afterwards.


So here's what I want:

  • When you change classes using yanfly's class change core, (or optionally when doing it manually as well) the actor who just changed classes gets their equipment optimized.
  • Obviously needs to be compatible with Yanfly's class change core plugin
  • The stat preview window on the right side of the class change menu should update to show what the actors stats will be after the equipment optimize after changing classes (if possible).
  • (Optional) Pops a window up after class change that advises that equips have been optimized
  • (Super Optional) Add-on to the options menu to disable auto-optimizing equipment on class change
  • Should not optimize the equips of any actor unless that actor has just changed classes. (no lag)



Thanks in advance, anyone who takes a look at this.
I was able to get the optimize to work by adding it to Scene_Class.prototype.onItemOk.


You'll likely wanna move that refresh there around too.
You're right on there. I also managed to get the popup dialogue to work through Iavra Generic Popup


Now all I have to do is find a way to add that to the options menu.
You're right on there. I also managed to get the popup dialogue to work through Iavra Generic Popup


Now all I have to do is find a way to add that to the options menu.

Add the popup?


If it's the popup, you'll have to see if someone else can help as I have no knowledge of how that plugin works.


If it's the class change, the plugin already allows use via the menu, no?
Add the popup?


If it's the popup, you'll have to see if someone else can help as I have no knowledge of how that plugin works.


If it's the class change, the plugin already allows use via the menu, no?

Actually both. The plugin is called from a function call, which I just tacked onto the end of the optimization call, in class change core. I just want the ability for a player to turn that optimization off (and the popup, as it won't be necessary), from the in-game options menu. In the class change it';s a simple matter of checking if the option is on or off before optimizing equips, I'm just not sure how to add an option to the menu, or check whether it's on or off.
I see.  Adding options to the Options menu is a pain, but not impossible.


I made a plugin a little while ago which lets you change encounter rates via the option menu.


You could look at that to see how I did it.
I have taken a look and have succeeded in adding it to the options menu, and it seems to work. Thanks to your assistance. 🙂
No problem.
No problem.

I just noticed an issue with it where the title screen causes it to return to its default state, and it doesn't update when a game is loaded to return to the way it was in the save game. Any ideas how to fix this @Maliki79?


Edit: loading a savegame without hitting the title screen saves the value. Any of the other options on the options menu retain the value, including your own. I'm at a loss here.


edit2: false alarm. typo'd a capital letter so it never applied the change, and always reverted to the default.
No worries. ;-)
Good day.


I'm trying to make a little script snippet to force an actor to optimize their equipment when they change classes. I am using Yanfly's class change core plugin.


I found a script call that will optimize equipment on the actor it is called by ($gameActors.actor(id).optimizeEquiments()), but any attempt I've made to insert it into yanfly's plugin has failed. The most success I've seen actually had it working, but it was re-optimizing equips every time you scrolled through classes on the class change menu, instead of when actually changing classes. This caused a lot of lag as well.


I also tried modifying the Game_Actor.prototype.changeClass function from rpg_objects.js, but had the same issue, in that yanfly's class change plugin was causing it to attempt to optimize by scrolling through the menu of classes, instead of actually when changing them. Additionally, while the optimize seemed like it would happen on job change (the stat preview information on the right side of the screen updated as if it were being optimized), it actually didn't happen, but still caused massive lag afterwards.


So here's what I want:

  • When you change classes using yanfly's class change core, (or optionally when doing it manually as well) the actor who just changed classes gets their equipment optimized.

  • Obviously needs to be compatible with Yanfly's class change core plugin

  • The stat preview window on the right side of the class change menu should update to show what the actors stats will be after the equipment optimize after changing classes (if possible).

  • (Optional) Pops a window up after class change that advises that equips have been optimized

  • (Super Optional) Add-on to the options menu to disable auto-optimizing equipment on class change

  • Should not optimize the equips of any actor unless that actor has just changed classes. (no lag)



Thanks in advance, anyone who takes a look at this.

Hate to necro an old thread, but I am working on this exact same functionality in my game. I got it working but experienced the same issues you mention, as well as noticing that changeEquip was causing duplicate items to be created while it was comparing them.

Did you ever finish this plugin? I am at the stage where I am adding my code to onItemOk, however I do not know how to get Scene_Class.prototype.onItemOk = function() { to recognize this. as the active actor like it was doing when placed under Game_Actor.prototype.changeClass
I did eventually get it some semblance of working, in the end. I think I probably even moved past having the iavra popup thing too. Unfortunately, that was a long time ago, and the project I did it for is long dead.

Having done a lot more work with menus since this was posted, I can tell you that the class change scene likely has the current actor saved to a value in the actual scene, likely something like SceneManager._scene._actor, but I can't be sure without looking at the plugin. The equip and skill scenes also have the current actor saved in a similar way, and I see no reason why Yanfly wouldn't have done so with the class change scene as well.

Additionally, my mention in this topic of how it was constantly optimizing when scrolling through the class list was actually because it was being applied to the temp actor, for the purpose of updating the param changes shown in that window. I think adding the optimize to the onItemOk() function probably circumvented that problem for you already though.
Thanks, and yea you are right on the money with where I am at. Think I have it just about finished, as well as even swapping what eTypes the actor can wear as to allow passive equip states (Lancer class = can wield javelin as sidearm, etc).

This is working perfectly for my purposes, but I do think there is also a demand for such a feature for anyone inspired by FFT. I doubt I could export my plugin for anything besides my own project, but if you are still making plugins, I think something like this could be a hit for those who are unable to do so themselves.

Appreciate the work you have done with things like the block plugin btw. Keep it up and long live Ivalice :awink:

Original thread: https://forums.rpgmakerweb.com/threads/optimize-equipment-on-class-change.64565/