How to check who is the actor using the item

Arthur França

Veteran
Veteran
Joined
Nov 3, 2017
Messages
40
Reaction score
27
First Language
Portuguese
Primarily Uses
RMMV
Hellow everybody!

I'm trying to make a "Hungry" status for my actors. This stat will buff or debuff their power during the battle. So, to fill this stat, the actor need to eat food. I made variables to each actor to set their hungry status, and put it on the main menu using some Yanfly's plugins.

Now, I'm trying to make these foods to heal the hungry variable of the actor who eat it, but im gotting troubles with the code. I think it should be something like this:

When the actor uses an apple on himself or an ally:

Check if the target is the actor(1):
then increase +10 (for exemple) in the variable 0011;
else
if the target is the actor(2)?
then increase +10 in the variable 0012;
else
...[and there it goes].

Is there someway to made it?
 

Kes

Veteran
Veteran
Joined
Aug 3, 2012
Messages
22,299
Reaction score
11,712
First Language
English
Primarily Uses
RMVXA
'Plugin Releases' is where people who have written a plugin which they want to share with others can post them. It might be that you need a plugin for this, but at the moment, it looks like you just need to event it correctly.

[move]RPGMaker MV[/move]
 

Llareian

Jack of All Trades, Master of None
Veteran
Joined
Jan 26, 2017
Messages
604
Reaction score
1,421
First Language
English
Primarily Uses
RMMV
You can do this part with a variable, the damage box, and a common event. I've assumed here that the food items are usable both in and out of battle.

Step 1) Store the target actor ID in a variable using the item's damage box.
In the damage box for the item, put the following, with x being whatever variable ID you want to use:
(SceneManager._scene.constructor == Scene_Battle) ? $gameVariables.setValue(x, $gameParty._actors[this._targetIndex]) : $gameVariables.setValue(x, $gameParty._targetActorId);

Step 2) Use a common event to do the conditional processing.
Have the item call a common event. In the common event, use a conditional branch to check the target's actor ID (using the variable you set in Step 1), then increase the appropriate variable under that branch.
 

Arthur França

Veteran
Veteran
Joined
Nov 3, 2017
Messages
40
Reaction score
27
First Language
Portuguese
Primarily Uses
RMMV
guess I got it. Tell me if its right:

The step on I put the code on the damage box, using type "HP Regen". The variable used will be set as 1, or 2, etc, according to the actor ID selected as target. The item call a common event, just like u said on step 2. So, after I check what's the value of the variable "x", then I add the variable "hungry" of the respective actor, and set the variable "x" again to 0.

Am I right?
 
Last edited:

Arthur França

Veteran
Veteran
Joined
Nov 3, 2017
Messages
40
Reaction score
27
First Language
Portuguese
Primarily Uses
RMMV
"Failed do execute 'createLinearGradient' on 'CanvasRenderingContext2D': float parameter 3 is non-finite."

It showed the above message.
 

Shaz

Veteran
Veteran
Joined
Mar 2, 2012
Messages
40,098
Reaction score
13,704
First Language
English
Primarily Uses
RMMV
That is a known issue. I don't recall the cause or the solution, but if you copy/paste that error into the search box, you should be able to find it.

Also, if you want to know who is using the item, you are after the user, not the target. The target is the person the item was used on. You can also use a and b in the damage formula to refer to the user and target. Don't need to go to $gameParty._actors[this._targetIndex] (which would put an actor object into the variable, not an actor id).
 

Arthur França

Veteran
Veteran
Joined
Nov 3, 2017
Messages
40
Reaction score
27
First Language
Portuguese
Primarily Uses
RMMV
IT WORKED!

When u told "in the damage box", I didn't understand exaclty, despite I could read the code at least. When i used <post-damage eval>, then it worked perfectly! Thanks everyone, and thank u Llareian for ur help!
 

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

Latest Threads

Latest Posts

Latest Profile Posts

so hopefully tomorrow i get to go home from the hospital i've been here for 5 days already and it's driving me mad. I miss my family like crazy but at least I get to use my own toiletries and my own clothes. My mom is coming to visit soon i can't wait to see her cause i miss her the most. :kaojoy:
Couple hours of work. Might use in my game as a secret find or something. Not sure. Fancy though no? :D
Holy stink, where have I been? Well, I started my temporary job this week. So less time to spend on game design... :(
Cartoonier cloud cover that better fits the art style, as well as (slightly) improved blending/fading... fading clouds when there are larger patterns is still somewhat abrupt for some reason.
Do you Find Tilesetting or Looking for Tilesets/Plugins more fun? Personally I like making my tileset for my Game (Cretaceous Park TM) xD

Forum statistics

Threads
105,868
Messages
1,017,074
Members
137,578
Latest member
JamesLightning
Top