So here's an odd one, and I'm not sure if it's a bug in my code or a quirk of RPGM MV I don't understand.
I have a block of states called starsigns. They modify your stats and each actor and enemy gets one (and only one). I just have 3 right now and all they do is mess with your max HP (for testing purposes).
I've added a "Change Character" option to top of the menu (it'll be moved later). Choosing it and an actor brings you to this submenu:
"Change Name" brings up the renaming window. "Change Appearance" calls up SomeRandomDude's character creator plugin. Both work as expected. "Change Starsign" brings you to this screen:
I've aliased the Window_Selectable.prototype.select function like so:
tempCharacterPage is the smaller status window in that last screenshot. The idea is that each time the player moves the menu cursor his previous starsign is immediately removed (by the for loop) and whatever one the cursor is over gets assigned. Then the character page is refreshed so he can immediately see what his stats will look like if he makes that choice.
Here's where it gets weird. This works, but only once per sign per character. Harold gets the water sign the first time I move the cursor to that option, but if I move it away and then back he's left with nothing. I have to restart the entire game to give it to him again. Even stranger is that the addState function is the only part that fails after the first time; the help window description always gets updated and the removeState loop always works. I've tried variations on the code, even going through the updateCursor function instead of select, and I always get the same results.
So, any ideas what's going on? I'm trying to attach a demo project but the forum is claiming the file size is too much. If it's not obvious what I'm doing wrong from what I've said so far I'll look for a place to host it.
I have a block of states called starsigns. They modify your stats and each actor and enemy gets one (and only one). I just have 3 right now and all they do is mess with your max HP (for testing purposes).
I've added a "Change Character" option to top of the menu (it'll be moved later). Choosing it and an actor brings you to this submenu:
"Change Name" brings up the renaming window. "Change Appearance" calls up SomeRandomDude's character creator plugin. Both work as expected. "Change Starsign" brings you to this screen:
I've aliased the Window_Selectable.prototype.select function like so:
Code:
var _Window_Selectable_select = Window_Selectable.prototype.select;
Window_MenuStarsign.prototype.select = function(index) {
_Window_Selectable_select.call(this, index);
tempActor = $gameParty._menuActorId;
tempExt = index + firstSign;
tempStarsignHelpWindow.setText($dataStates[tempExt].description);
for (i = firstSign; i <= lastSign; i++) {
$gameActors.actor(tempActor).removeState(i);
}
if ((tempExt <= lastSign) && (tempExt >= firstSign))
{$gameActors.actor(tempActor).addState(tempExt);
//alert(tempExt);
}
tempCharacterPage.refresh();
};
tempCharacterPage is the smaller status window in that last screenshot. The idea is that each time the player moves the menu cursor his previous starsign is immediately removed (by the for loop) and whatever one the cursor is over gets assigned. Then the character page is refreshed so he can immediately see what his stats will look like if he makes that choice.
Here's where it gets weird. This works, but only once per sign per character. Harold gets the water sign the first time I move the cursor to that option, but if I move it away and then back he's left with nothing. I have to restart the entire game to give it to him again. Even stranger is that the addState function is the only part that fails after the first time; the help window description always gets updated and the removeState loop always works. I've tried variations on the code, even going through the updateCursor function instead of select, and I always get the same results.
So, any ideas what's going on? I'm trying to attach a demo project but the forum is claiming the file size is too much. If it's not obvious what I'm doing wrong from what I've said so far I'll look for a place to host it.