Assigning variable to actor ID during battle.

Wisestwol

Villager
Member
Joined
Nov 6, 2017
Messages
7
Reaction score
0
First Language
English
Primarily Uses
RMMV
I'm having trouble with assigning variables to an actor's ID during battles.

At the moment, I have an item that, when used, sets a variable (35) to the ID of the actor using it, and then calls a common event that does conditional processing.

It works great outside of battles, but does not function in the battle scene.

The formula in the damage box is:

(SceneManager._scene.constructor == Scene_Battle) ? $gameVariables.setValue(35, $gameParty._actors[this._targetIndex]) : $gameVariables.setValue(35, $gameParty._targetActorId);

Image1.png

Image4.png

When the item is used in battles, it just reads "Actor lost no HP"
 

Tiamat-86

old jrpg gamer
Veteran
Joined
Dec 5, 2017
Messages
343
Reaction score
138
First Language
english
Primarily Uses
RMMV
alternate way of doing this is having item apply a blank placeholder state on the user and then the event checks for the state instead of variable number. remember to have the event also remove the placeholder state.
formula a.addState(n)
 
Last edited:

Shaz

Veteran
Veteran
Joined
Mar 2, 2012
Messages
38,815
Reaction score
12,229
First Language
English
Primarily Uses
RMMV
$gameParty._actors[this._targetIndex]) is going to give you the actor, not the actor id.

In damage formula, a is the user and b is the target. You can use a OR b in this case, because the item's target is the user. So you can just do this, and not worry about if you're in battle or not:

Code:
$gameVariables.setValue(35, a.actorId());
Now, you've got that set as HP Recover, but you're not actually returning anything. So maybe something like this:

Code:
$gameVariables.setValue(35, a.actorId()); 0
which will return 0 as the actual damage.



formula a.addState(n)
If you do it via a state, just make the item apply a state. Don't need to worry about doing it in a damage formula.
 

Tiamat-86

old jrpg gamer
Veteran
Joined
Dec 5, 2017
Messages
343
Reaction score
138
First Language
english
Primarily Uses
RMMV
i do it in formula because items i use this mechanic with aren't always self target
 

Shaz

Veteran
Veteran
Joined
Mar 2, 2012
Messages
38,815
Reaction score
12,229
First Language
English
Primarily Uses
RMMV
But the OP IS using an item that's self-target, and they want a solution for THEIR issue :)
 

Tiamat-86

old jrpg gamer
Veteran
Joined
Dec 5, 2017
Messages
343
Reaction score
138
First Language
english
Primarily Uses
RMMV
thats why i said "alternate way." just switching variable for placeholder state. same state can be used as markers for user, ally and/or enemy targeted common events triggered by skills or items.

and truth be told i still dont understand script, but knew a method to fix his issue.
but thanks for giving him the version that work for his current method.
 

Wisestwol

Villager
Member
Joined
Nov 6, 2017
Messages
7
Reaction score
0
First Language
English
Primarily Uses
RMMV
Thanks for the help! I had tried this before:
$gameVariables.setValue(35, a.actorId());
but I had no luck, which I guess is because I was missing the 0 value at the end.

In the end I went with:

(SceneManager._scene.constructor == Scene_Battle) ? $gameVariables.setValue(35, a.actorId()) : $gameVariables.setValue(35, $gameParty._targetActorId); a.mhp*0.3+10
I then made a few changes to the common event to incorporate luck attributes and so on, and shuffle some things around.

And I actually used
a.addState(n)
to solve another problem I was having with a skill that I wanted to target an enemy, but also have a passive effect on the user, so that was super helpful too!
 

Users Who Are Viewing This Thread (Users: 0, Guests: 1)

Latest Threads

Latest Posts

Latest Profile Posts

Hope y'all are staying healthy, safe and informed. Maybe pick up a new hobby or skill while you're at it.
Wanted to post a video of location i've finished but it doesn't work...
The game jam has done a lot of good in actually kicking my butt into action. I've even gotten over my crippling hatred of mapping thanks to it! :LZSexcite:

(Okay, there's also schoolwork forcing me to get on the computer, but I like to give credit where credit is due.)
Decided to start working on my second biome/area...


I'm sure I'll end up hating and changing things a whole lot over the next week. :LZSexcite:
I feel bad sometimes around others, I hate, and I mean HATE being touched, and I know they don't know I hate it so much

Forum statistics

Threads
95,656
Messages
930,810
Members
125,991
Latest member
harleyquinn
Top