How to make an item have a different effect for each actor?

Mylkie

Villager
Member
Joined
Oct 7, 2021
Messages
7
Reaction score
1
First Language
English
Primarily Uses
RMMV
I want an item to restore MP for 3 actors, but have the same item restore TP for the fourth actor (because this actor does not use MP).
 

ATT_Turan

Forewarner of the Black Wind
Veteran
Joined
Jul 2, 2014
Messages
2,843
Reaction score
1,666
First Language
English
Primarily Uses
RMMV
Set the item's Scope to All Allies. In the damage formula box, do:
Code:
$gameActors.actor(id1).gainMp(X); $gameActors.actor(id2).gainMp(X2); $gameActors.actor(id3).gainMp(X3); $gameActors.actor(id4).gainTp(Y); 0
Where it says id1-4 you put the appropriate actor ID. Where it says X-X3 you put how much you want that actor to gain for MP. Where it says Y you put how much TP you want the fourth actor to gain.

Ooh. I don't know if setting it to all allies will make that formula execute for each actor. If it does, let me know and I'll give you a longer, corrected version. If you need that, you can let me know whether the MP actors are getting different amounts of MP back or the same amount.
 

Mylkie

Villager
Member
Joined
Oct 7, 2021
Messages
7
Reaction score
1
First Language
English
Primarily Uses
RMMV
Set the item's Scope to All Allies. In the damage formula box, do:
Code:
$gameActors.actor(id1).gainMp(X); $gameActors.actor(id2).gainMp(X2); $gameActors.actor(id3).gainMp(X3); $gameActors.actor(id4).gainTp(Y); 0
Where it says id1-4 you put the appropriate actor ID. Where it says X-X3 you put how much you want that actor to gain for MP. Where it says Y you put how much TP you want the fourth actor to gain.

Ooh. I don't know if setting it to all allies will make that formula execute for each actor. If it does, let me know and I'll give you a longer, corrected version. If you need that, you can let me know whether the MP actors are getting different amounts of MP back or the same amount.
Hello! I tested this with 1 ally and all allies and it gives the certain amount of MP and TP that I wanted! But the item restores MP for all the 3 actors, including TP for that fourth actor. I want it so that it only restores it to one targeted actor only! I would really like the longer version though!
 

ATT_Turan

Forewarner of the Black Wind
Veteran
Joined
Jul 2, 2014
Messages
2,843
Reaction score
1,666
First Language
English
Primarily Uses
RMMV
I want it so that it only restores it to one targeted actor only! I would really like the longer version though!
Ah. That's not how I interpreted your first post, it creates a few extra steps. You also didn't answer my question about the MP gain.
 

Mylkie

Villager
Member
Joined
Oct 7, 2021
Messages
7
Reaction score
1
First Language
English
Primarily Uses
RMMV
Ah. That's not how I interpreted your first post, it creates a few extra steps. You also didn't answer my question about the MP gain.
I did answer o.o
I said that it gave me the same amount of MP for the 3 actors
Sorry if I made you confused, my english is bad sometimes >_<
 

ATT_Turan

Forewarner of the Black Wind
Veteran
Joined
Jul 2, 2014
Messages
2,843
Reaction score
1,666
First Language
English
Primarily Uses
RMMV
I said that it gave me the same amount of MP for the 3 actors
You did not - you just said that the item gave MP to the 3 actors, indicating that the code worked correctly. But it's no problem, I just wanted to ask before I wrote out code that was more complicated than it needed to be.

So here's what you need to do.

1) Create a new state in your database. It doesn't need an icon or anything filled in on the page. It doesn't matter what you call it, I will call it Restore.

2) On the right-hand side of the item screen, where it says Effects, add 2 effects - one that gives the Restore state, and then the second takes Restore back off.

(This is necessary for the TP actor. If you have the item's damage formula set to restore MP or restore HP and his MP/HP is full, you can't target him with the item since it wouldn't change any stats. Putting a state on the item means you can still target any actor.)

3) Put this in the damage formula:
Code:
(a._actorId==id1 || a._actorId==id2 || a._actorId==id3 ? a.gainMp(X) : a._actorId==id4 ? a.gainTp(Y) : 0); 0

Follow the same instructions before for id1-4, X and Y. This will work even if you have more than those 4 actors in your game, it just will have no effect if it's used on someone else.
 

Mylkie

Villager
Member
Joined
Oct 7, 2021
Messages
7
Reaction score
1
First Language
English
Primarily Uses
RMMV
You did not - you just said that the item gave MP to the 3 actors, indicating that the code worked correctly. But it's no problem, I just wanted to ask before I wrote out code that was more complicated than it needed to be.

So here's what you need to do.

1) Create a new state in your database. It doesn't need an icon or anything filled in on the page. It doesn't matter what you call it, I will call it Restore.

2) On the right-hand side of the item screen, where it says Effects, add 2 effects - one that gives the Restore state, and then the second takes Restore back off.

(This is necessary for the TP actor. If you have the item's damage formula set to restore MP or restore HP and his MP/HP is full, you can't target him with the item since it wouldn't change any stats. Putting a state on the item means you can still target any actor.)

3) Put this in the damage formula:
Code:
(a._actorId==id1 || a._actorId==id2 || a._actorId==id3 ? a.gainMp(X) : a._actorId==id4 ? a.gainTp(Y) : 0); 0

Follow the same instructions before for id1-4, X and Y. This will work even if you have more than those 4 actors in your game, it just will have no effect if it's used on someone else.
I followed your instructions, and I only get actor ID 1 to restore MP. If I select the other actors to use the item it only restores MP to actor ID 1. What did I do wrong?
Screenshot 2021-10-19 215211.png
 

ATT_Turan

Forewarner of the Black Wind
Veteran
Joined
Jul 2, 2014
Messages
2,843
Reaction score
1,666
First Language
English
Primarily Uses
RMMV
What did I do wrong?
I have no idea, your screenshot doesn't show your full damage formula.

Are you using this outside of battle?
 

Mylkie

Villager
Member
Joined
Oct 7, 2021
Messages
7
Reaction score
1
First Language
English
Primarily Uses
RMMV
I have no idea, your screenshot doesn't show your full damage formula.

Are you using this outside of battle?
Yes, I want the item to be used outside of battle too
 

ATT_Turan

Forewarner of the Black Wind
Veteran
Joined
Jul 2, 2014
Messages
2,843
Reaction score
1,666
First Language
English
Primarily Uses
RMMV
I don't know. If you copied the code I gave you, it should work regardless. My only suggestion is to actually copy and paste what you have in the damage formula, instead of a screenshot of just a small part.
 

Mylkie

Villager
Member
Joined
Oct 7, 2021
Messages
7
Reaction score
1
First Language
English
Primarily Uses
RMMV
I don't know. If you copied the code I gave you, it should work regardless. My only suggestion is to actually copy and paste what you have in the damage formula, instead of a screenshot of just a small part.
Oh! It works during battle! But it still doesn't work outside of battle...
Thank you for being patient with me and helping me this far >u<;;
 

Andar

Veteran
Veteran
Joined
Mar 5, 2013
Messages
34,358
Reaction score
8,772
First Language
German
Primarily Uses
RMMV
instead of using the damage formula you can use a common event. That will work everywhere but has the disadvantage of delaying the effect to the end of turn in battle (unless you have battleplugins that allow you to specify when a common event is executed).

have one effect "target" state - that state does nothing, it is only to identify the target that used the item.
then have the common event as the second effect.
in the common event, you'll need one branch for each actor checking if that actor has the state.
if yes, apply the effect for that actor to it and remove the state from the actor
 

ATT_Turan

Forewarner of the Black Wind
Veteran
Joined
Jul 2, 2014
Messages
2,843
Reaction score
1,666
First Language
English
Primarily Uses
RMMV
Code:
var member=$gameParty.inBattle() ? a : $gameActors.actor($gameParty._targetActorId); (member._actorId==id1 || member._actorId==id2 || member._actorId==id3 ? member.gainMp(X) : member._actorId==id4 ? member.gainTp(Y) : 0); 0

That should work in and out of battle.
 

Mylkie

Villager
Member
Joined
Oct 7, 2021
Messages
7
Reaction score
1
First Language
English
Primarily Uses
RMMV
instead of using the damage formula you can use a common event. That will work everywhere but has the disadvantage of delaying the effect to the end of turn in battle (unless you have battleplugins that allow you to specify when a common event is executed).

have one effect "target" state - that state does nothing, it is only to identify the target that used the item.
then have the common event as the second effect.
in the common event, you'll need one branch for each actor checking if that actor has the state.
if yes, apply the effect for that actor to it and remove the state from the actor
Code:
var member=$gameParty.inBattle() ? a : $gameActors.actor($gameParty._targetActorId); (member._actorId==id1 || member._actorId==id2 || member._actorId==id3 ? member.gainMp(X) : member._actorId==id4 ? member.gainTp(Y) : 0); 0

That should work in and out of battle.
Both of these worked!! Thank you so much :D
 

Latest Threads

Latest Posts

Latest Profile Posts

aww man, color hex code #C4C4C4 doesn't work for the tint value in this scene I need something darker, which stinks just because I liked that one it was my favorite plastic explosive three times...#696969 (nice) should work better (WHY IS MY BRAIN LIKE THIS)
Tell it to me straight, doc. If I've been trying to piece together a "shorter" game to learn stuff outside of game jams... am I just running away from my WIP? :v
Well, I've got a party tomorrow, and my friends are coming over. I wanted to work a bit on the Fandom Scouts assets so I can be ready when that update arrives... in other news, Pizza Time Horror is getting a second teaser, and it shows Cabaret Helen's last performance before the location closed.
Also who used to be scared of Chuck E as a kid? I was! Now I love him!
The new cards and what they do:

(I am clearly not a youtuber... Haha)

Forum statistics

Threads
117,282
Messages
1,106,096
Members
153,456
Latest member
tomdavies
Top