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
502
Reaction score
192
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
39,966
Reaction score
13,602
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
502
Reaction score
192
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
39,966
Reaction score
13,602
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
502
Reaction score
192
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

I have a riddle for you all, I wonder if you can solve it!

I stumbled upon 2 articles about why time goes faster as we age, and how to "slow down time".
Check them out, very interesting read. :D
Faster Time
Slower Time
Anyone can recommend a good gaming mouse? My mouse wheel has given up. Last mouse was steel series diablo iii edition (I know, it's been a while)

Forum statistics

Threads
104,271
Messages
1,005,172
Members
135,785
Latest member
olu_shango
Top