MV Looking for feedback for battle mechanic idea - too complicated?

A few things to unpack here

<Custom battle effect>

var <<Aska>>\i[320]\c[30]Delusion\c[0] = user.tp;

</Custom battle effect>

<custom regenerate effect>

var <<Aska>>\i[320]\c[30]Delusion\c[0] = user.tp;

</custom regenerate effect>

these dont actually do anything. when you make a JS variable, it doesnt correlate to a gameVariable and it only exists within the scope its called. Youre creating 2 new variables and doing nothing with them between both of those tags
you cant make a js variable by that name either. many of those characters arent allowed to be used in a variable identifier because theyre used in js for other things. <<Aska>>\i[320]\c[30]Delusion\c[0] when being used as a value is going to cause an error.

Outside of battle, during in game events etc. I'm able to accomplish this by, so let's say I have an event that changes his Delusion value to 200:

1704594595805.png
when you run that, press f8 beforehand and check the console. put some text boxes to display those variables between each line there and see what values those actually produce. im fairly certain that first and fourth lines should produce an error for the same reason as above, so by the time the change tp command is ran it wont do anything as itll add 0 to their tp. variables 6 and 7 being named that might be fine, but its also just their names. you could have just named them Delusion and Acceptance and it would make zero difference. the names are for your sake, unless you have some plugin to read that to do some function

My question is this. if that actor is the only one to use TP, and their TP is supposed to be their mood, why have a variable for it? why not just directly use their tp values wherever you would use the delusion variable?

if you keep using the variable though, youd want that state to sync the gameVariable with the actor's TP, not a js variable. it sounds like the important ones would be battle start, after skill use, after being targetted, and turn end
Code:
<Custom battle effect>
$gameVariables.setValue(86, user.tp);
</Custom battle effect>

<Custom Conclude effect>
$gameVariables.setValue(86, user.tp);
</Custom Conclude effect>

<Custom Deselect effect>
$gameVariables.setValue(86, target.tp);
</Custom Deselect effect>

<custom regenerate effect>
$gameVariables.setValue(86, user.tp);
</custom regenerate effect>
A few things to unpack here



these dont actually do anything. when you make a JS variable, it doesnt correlate to a gameVariable and it only exists within the scope its called. Youre creating 2 new variables and doing nothing with them between both of those tags
you cant make a js variable by that name either. many of those characters arent allowed to be used in a variable identifier because theyre used in js for other things. <<Aska>>\i[320]\c[30]Delusion\c[0] when being used as a value is going to cause an error.


when you run that, press f8 beforehand and check the console. put some text boxes to display those variables between each line there and see what values those actually produce. im fairly certain that first and fourth lines should produce an error for the same reason as above, so by the time the change tp command is ran it wont do anything as itll add 0 to their tp. variables 6 and 7 being named that might be fine, but its also just their names. you could have just named them Delusion and Acceptance and it would make zero difference. the names are for your sake, unless you have some plugin to read that to do some function

My question is this. if that actor is the only one to use TP, and their TP is supposed to be their mood, why have a variable for it? why not just directly use their tp values wherever you would use the delusion variable?

if you keep using the variable though, youd want that state to sync the gameVariable with the actor's TP, not a js variable. it sounds like the important ones would be battle start, after skill use, after being targetted, and turn end
Code:
<Custom battle effect>
$gameVariables.setValue(86, user.tp);
</Custom battle effect>

<Custom Conclude effect>
$gameVariables.setValue(86, user.tp);
</Custom Conclude effect>

<Custom Deselect effect>
$gameVariables.setValue(86, target.tp);
</Custom Deselect effect>

<custom regenerate effect>
$gameVariables.setValue(86, user.tp);
</custom regenerate effect>

So the weird name on the variables is for a yanfly plugin. It allows me to display the variables in a status menu with a specific icon and color. That I've verified is working on the event level. The code is basically allowing me to do this in the status menu.

1704613803777.png


The reason I don't use the TP as just the mood itself is because I'm wanting to give the mood states the flexibility to be impacted by things like skills, items, in game events etc. and I started this on the presumption that directly tieing all that to the TP ... that I wouldn't be able to have the flexibility to do all that. But that could be my inexperience talking.

That code though, that may be what I was looking for. I didn't know how to tie it to the in game variables and that example I linked was the only way I knew to try it. I'll give it a try and see if it works. And thank you again!

**EDIT IT WORKED AND YOU ARE AWESOME!**

I only have one other thing to finish designing these battle mechanics and it's the thing I've been saving for last, but I think I'll save the details for later when I have time to work on it. Basically, I'm trying to figure out if there's a way to have an equipment that prevents one of these variables from going below x, as an example, "too tight shoes" or something that prevents a character from getting below 20 rage. Problem with that is ...well it's several problems as far as I can tell. I'll stumble in the dark for a while and only bother you guys if I can't figure it out. In the meantime you have my absolute gratefulness.
So the weird name on the variables is for a yanfly plugin. It allows me to display the variables in a status menu with a specific icon and color. That I've verified is working on the event level. The code is basically allowing me to do this in the status menu.
ah. ok, that makes sense. I knew plugins could be written to read variable names and do things from there, but i wasnt sure if that was what was going on there and thought that maybe you named it that because of something else

The reason I don't use the TP as just the mood itself is because I'm wanting to give the mood states the flexibility to be impacted by things like skills, items, in game events etc. and I started this on the presumption that directly tieing all that to the TP ... that I wouldn't be able to have the flexibility to do all that. But that could be my inexperience talking.
so long as you keep in mind that that actor's tp is being used as that resource in your events and you interact with it the same ways you do the other mood varaiables, you should be able to do the same things as well. But if what you have already works then it works, theres no need to spend the time to make changes that dont have to be made

one further question to ask though. it makes sense to sync the variable at the end of combat since thats how you get your status menu working. do you use your variable directly in battles, or do you just use the tp?
If youre not using the variable in combat, then theres no need for the deselect and the conclude effect, and you can just change the timings to battle and victory (or possibly only ever sync the variable as that menu gets opened and let it be tp everywhere else)

Basically doing this. I can't do it as a common event so I had to rewrite that whole little section to update TP with even since game only gives you the option to add or subtract a variable, it doesn't let you set the TP to a variable. If anybody happens to know a better way, let m know.
i missed that the first read through. the MV editor doesnt have a default option for it, but you can still access it. For future reference you can select script, put in
Code:
$gameActors.actor(x).tp
and change the x to their actor id to get their tp. Since its only that actor that works like that, you can use that reference without any issue.
ah. ok, that makes sense. I knew plugins could be written to read variable names and do things from there, but i wasnt sure if that was what was going on there and thought that maybe you named it that because of something else


so long as you keep in mind that that actor's tp is being used as that resource in your events and you interact with it the same ways you do the other mood varaiables, you should be able to do the same things as well. But if what you have already works then it works, theres no need to spend the time to make changes that dont have to be made

one further question to ask though. it makes sense to sync the variable at the end of combat since thats how you get your status menu working. do you use your variable directly in battles, or do you just use the tp?
If youre not using the variable in combat, then theres no need for the deselect and the conclude effect, and you can just change the timings to battle and victory (or possibly only ever sync the variable as that menu gets opened and let it be tp everywhere else)


i missed that the first read through. the MV editor doesnt have a default option for it, but you can still access it. For future reference you can select script, put in
Code:
$gameActors.actor(x).tp
and change the x to their actor id to get their tp. Since its only that actor that works like that, you can use that reference without any issue.
So the only thing I really use the variable for during combat is that there's a similar status menu you can pull up in combat, per another Yanfly plugin. Also I need to update the variable so I can check to make sure the state hasn't changed in battle.

With regard to your last paragraph, I get getting tp using that script, but how would I set that as the variable? I'm not at the editor right now, so not sure if there's an option to do it?
You'd use the control variables event command like you normally do and use that line as the operand with script selected.

1704649626276.png


alternatively, if you look at the tags i had given you earlier, it has the command to set a variable's value in it. you could replace user/target for $gameActors.actor(x) there and run that anywhere that accepts JS code, like script sections, any yanfly "lunatic" tag, the console, etc.
You'd use the control variables event command like you normally do and use that line as the operand with script selected.

View attachment 291070

alternatively, if you look at the tags i had given you earlier, it has the command to set a variable's value in it. you could replace user/target for $gameActors.actor(x) there and run that anywhere that accepts JS code, like script sections, any yanfly "lunatic" tag, the console, etc.
Brilliant! I don't suppose I could ask you for advice on one other thing I'm trying to implement? Thing is, I don't think I can just solve this next problem with a Yanfly plugin. At least I didn't see any Yanfly equipment plugins that would be relevant for this?

What I'm basically trying to do is make it so there's an equipment that prevents a given player mood from going below a certain value. As an example, let's say I have an item that when equipped, prevents the delusion variable 86 from going below 20. I could probably do some if delusion < 20 then delusion= 20 logic, but the problem is 1) how to get that onto an equipment? And 2) how do I get it to check frequently enough that it overrides whatever effect in an event or battle might lower it? Like if the character has this equipped and an enemy uses a skill that lowers their delusion to 0, how do I get this effect to check for that and move it back to 20?

I was thinking maybe there's a state I could do with a custom effect that triggers if an actor has x equipment, or I could even do a set of equipment that use one state and the state checks for any of the said equipment in the set. If I did it that way, I would also need an effect to make the state go away once it was unequipped.

But if that's a viable option, I'm not really sure where to start with it.

*Edit* I'm pretty sure if I can get help on this one, it will be the last thing I'll need help on because I can pretty much use what I've already learned to implement everything else.
how to get that onto an equipment?
you make a passive state and you attach the passive to a piece of gear with the notetag to do so

how do I get it to check frequently enough that it overrides whatever effect in an event or battle might lower it
youd use the same idea as the delusion sync. check which actor the user is, and change their variable values if theyre below 20 to make it 20 at the important timings like turn end, action end, etc.

I could probably do some if delusion < 20 then delusion= 20 logic
exactly when and how are you checking the moods for the final mood state? that idea will work, but it may be easier to just change whatever you do to check the moods in battle to see if an actor has the thing equipped and and set the value of their mood to 20 before it does the final mood stuff if it was below 20.

The alternatives i can think of would be:
doing the same thing as the delusion sync where at important points, you check the actor the mood low enough to work, but how that should work depends on when your mood check happens
Changing every skill that can impact a mood, and adding a bit of logic to make it so that if the target has the item equipped and is below 20, set it to 20, which is exactly what you want by the description, but will suck to add retroactively depending on how much you did already
you make a passive state and you attach the passive to a piece of gear with the notetag to do so


youd use the same idea as the delusion sync. check which actor the user is, and change their variable values if theyre below 20 to make it 20 at the important timings like turn end, action end, etc.


exactly when and how are you checking the moods for the final mood state? that idea will work, but it may be easier to just change whatever you do to check the moods in battle to see if an actor has the thing equipped and and set the value of their mood to 20 before it does the final mood stuff if it was below 20.

The alternatives i can think of would be:
doing the same thing as the delusion sync where at important points, you check the actor the mood low enough to work, but how that should work depends on when your mood check happens
Changing every skill that can impact a mood, and adding a bit of logic to make it so that if the target has the item equipped and is below 20, set it to 20, which is exactly what you want by the description, but will suck to add retroactively depending on how much you did already
Okay, so the code below works:

I have an armor with passive state 107 in the notetag.
Passive state 107 has the following in the notetags:

game variable is 71 is the "rage" mood for Will. I tested and it's working.

<Custom battle effect>

if ($gameActors.actor(1) && (gameVariables.value(71) < 20){$gameVariables.setValue(71, 20);}

</Custom battle effect>

<Custom Conclude effectz>
if ($gameActors.actor(1) && (gameVariables.value(71) < 20){$gameVariables.setValue(71, 20);}
</Custom Conclude effect>

<Custom Deselect effect>

if ($gameActors.actor(1) && (gameVariables.value(71) < 20){$gameVariables.setValue(71, 20);}

</Custom Deselect effect>

<custom regenerate effect>

if ($gameActors.actor(1) && (gameVariables.value(71) < 20){$gameVariables.setValue(71, 20);}

</custom regenerate effect>

But there's still one last thing to work out. How do I get it to update the variable and state when he equips it? Like if his rage is zero, and he equips it, it should make his rage 20. That is the only thing not working now.

EDIT: I mostly got this this to work. I use Yanfly's Utility common events to run my mood update common event whenever the menu closes. It will still show weird at first, but once the menu closes it updates. I suppose technically I would like it to show as soon as it's equipped, but I suppose this will work for now.

EDIT # 2: I got this to work with a fixed version of Gilgamar's code. Technically it forces the menu to close to do the update, which is a little irksome, but apparently that problem has to do with scene management and I imagine is much trickier to fix. Hime had a fix for an earlier version of rpgmaker, but to my knowledge there isn't a plugin that does it in MV without kicking you out of the menu screen. I think this is good enough to call this solved though. THANK YOU EVERYONE for all your help. I now am feeling really confident about what I can do with this game. I really appreciate this community for helping me.
is that equipment unique to the one actor, or is can any actor wear it an gain that state? the way it is, if another actor equips it and the timings occur, the variable for actor 1 will update, even if lets say actor 3 is wearing it. your if conditional basically says "if actor 1 exists and that variable is under 20, set it to 20" when the fight starts, actor 3 acts, gets acted on, and when the fight ends.
if that state can only ever be on actor 1, then it isnt a issue, but if others can have it, itll need changes like seeing which actor is the current "user / target(deselect only)".

But there's still one last thing to work out. How do I get it to update the variable and state when he equips it? Like if his rage is zero, and he equips it, it should make his rage 20. That is the only thing not working now.
theres a plugin to run js at the time something is equipped. the equip eval one. you can make it so that equipping it as actor 1 sets that variable to 20 from the get-go.
is that equipment unique to the one actor, or is can any actor wear it an gain that state? the way it is, if another actor equips it and the timings occur, the variable for actor 1 will update, even if lets say actor 3 is wearing it. your if conditional basically says "if actor 1 exists and that variable is under 20, set it to 20" when the fight starts, actor 3 acts, gets acted on, and when the fight ends.
if that state can only ever be on actor 1, then it isnt a issue, but if others can have it, itll need changes like seeing which actor is the current "user / target(deselect only)".


theres a plugin to run js at the time something is equipped. the equip eval one. you can make it so that equipping it as actor 1 sets that variable to 20 from the get-go.
So the state is not unique and would apply to multiple actors, but I neglected to mention I have a similar line of code for each actor with their own unique variable. I just did that one first to test it.

Original thread: https://forums.rpgmakerweb.com/threads/looking-for-feedback-for-battle-mechanic-idea-too-complicated.164073/