Hello, I am making an item which runs a common event script. From inside the common event's script, is there a way to reference the actor ID of the actor that the item was used on? I basically just need the item to do stuff to whichever actor it is used on, but I don't know how to get the actor ID to use in scripts. It will only be used outside of combat, if that matters. I am still learning the basics of Ruby. I know Java, and I am struggling a bit with the lack of obvious "getter" functions in Ruby. Thank you
@Malchar Sure, here is some event code and javascript that should grab the actorId whether you are in battle or on the map. Code: ◆Comment:// Determine if Party is in Battle ◆If:Script:$gameParty.inBattle() ◆Comment:// Party in Battle; store 'BattleManager._targetId' into variable 1 ◆Control Variables:#0001 = BattleManager._action._subjectActorId + 1 ◆ :Else ◆Comment:// Party is on Map; store '$gameParty._targetActorId' into variable 1 ◆Control Variables:#0001 = $gameParty._targetActorId ◆ :End From there you can use the 'variable' option instead of the 'fixed' option when selecting actors in certain event commands, or you can grab the actor data directly via $gameActors.actor($gameVariables.value(variableId))
@Ossra I like that how many times that you answer VXA question with Javascript @Malchar the simplest thing would be assigning your actor id into a variable. You can use the damage formula for that. Even if you don't use the damage formula to deal damage or heal, but it is enough as script call. Write this in your formula box Code: v[x] = a.id Replace x with the variable id you want to use to store the actor id. Then in common event, use that variable to check.
@TheoAllen Bah! Whenever I check the sub-forum of the post it is MV, and whenever I do not check the sub-forum of the post it is always VXA. I will learn someday.
Thank you for the reply. I did some additional reading and I found that a.id returns the id of the item user, and b.id returns the id of the target. In my case, I needed to use b.id, and I got it working now. Thank you