[MV]Help how to store actor ID in variable?

Discussion in 'RPG Maker MV' started by Nerdboy, Feb 4, 2017.

    Tags:
  1. Nerdboy

    Nerdboy Veteran Veteran

    Messages:
    78
    Likes Received:
    7
    Hi im trying to store the active actor in actorID in variable during battle using "Script" event command. then apply a state to the actor. I'm trying to make it transparent so that each actor that is active, their actorID is stored in variable to trigger the state.

    var subject = this._subject;
    $gameVariables.setValue(20, subject._actorId);
    $gameActors.actor($gameVariables.value(20)).addState(118);
    problem here is ._actorID isn't defined, but thats what the core .js uses, so not sure why its not working.

    the only way i can make this work currently is if i use

    $gameActors.actor(ID).addState(ID);

    but the way i want it to work is, so ID is transparent, an uses a variable equal to the active actor in this case using a command in battle.

    question now is, does "this._subject" equal the active actor?

    ive tried this also
    $gameVariables.setValue(20, this._subject);
    $gameActors.actor($gameVariables.value(20)).addState(118);

    but actor is null... so how does one go about in storing active actor id in variable then calling it in $gameActors.actor() instead of specifying ID in ()
     
    #1
  2. Andar

    Andar Veteran Veteran

    Messages:
    28,155
    Likes Received:
    6,375
    Location:
    Germany
    First Language:
    German
    Primarily Uses:
    RMMV
    One question:
    Who is the active actor and when/where exactly are you using that command?

    Most likely this problem is caused by a wrong assumption on "this" - as an instance, that can be anything and not always the actor you want...
     
    #2
  3. Nerdboy

    Nerdboy Veteran Veteran

    Messages:
    78
    Likes Received:
    7
    what i mean by active actor, is current actor using the command. the command is a 'Script' call from event commands, in a troop event, which happens to be a multiple choice option, that triggers the 'script' call. in this case addState to actorID. that's why i want it transparent, and the way mv is set up, you can only call the specific actorID based on the # of the actor in database. the closest way to making it transparent is to use this code

    $gameActors.actor($gameVariables.value(x)).addState(id);

    but i dont know how to store the current/active actor id using the command in a variable. that way when i do figure it out, i can just use the forementioned code to store it in $gameVariables(x), so that actor gets the addState. does that make sense? i tried my best to describe what im doing. like how does one store actorID in variable for instance?
     
    #3
  4. Shaz

    Shaz Veteran Veteran

    Messages:
    37,360
    Likes Received:
    11,153
    Location:
    Australia
    First Language:
    English
    Primarily Uses:
    RMMV
    The 'current actor' can only be determined when a skill or action is actually being executed. Troop events run outside of the execution of skills or actions, so there is no 'current actor' in that context. You can use a in a damage formula to get the actor who is using the skill, action, item.
     
    #4
  5. Andar

    Andar Veteran Veteran

    Messages:
    28,155
    Likes Received:
    6,375
    Location:
    Germany
    First Language:
    German
    Primarily Uses:
    RMMV
    I would suggest you don't use a script call at all for this, but a combination of control variable to get game data and conditional branches.
    That should be able to get you the correct ID (either based on member# with two control variable commands or directly from database ID.

    As shaz said, you cannot get a "current actor" directly inside a common event, because the event doesn't have an actor.
    But the community has found several workarounds - just tell us what you want to do instead of how you want to do it, and we can point you into the correct direction.

    So again, how does the player select who the current actor is? Is that part of the multiple choice you wrote of?
     
    #5
  6. Nerdboy

    Nerdboy Veteran Veteran

    Messages:
    78
    Likes Received:
    7
    "a combination of control variable to get game data and conditional branches. That should be able to get you the correct ID (either based on member# with two control variable commands or directly from database ID."

    Not quite understanding how i'd do this in mv using only "2" control variables set to game data party actor id 1-8. my battles only use 4 members, so 1 to 4.

    Basically i have a multiple choice option command in battle, called Action, that list Hide, Feint, Sneak, Charge, Escape, Perform. this is triggered through a common event that turns the switch on, and in troop events the multiple choice appears when Action is used.

    That all works to that point. Now for the effect. which i would have addState to actorID of actor using the type of Action, whether it be Hide, Feint, etc. called inside the Troop Event. since thats the only way to use multiple choice options in battle.

    What i dont understand is if i use control variables set to game data party actor id 1-4, how would i call it to actor.addState? in damage formula you can use a.addState, but not so sure in conditional branches?
     
    #6
  7. Andar

    Andar Veteran Veteran

    Messages:
    28,155
    Likes Received:
    6,375
    Location:
    Germany
    First Language:
    German
    Primarily Uses:
    RMMV
    that sounds as if you use an extremely complicated way of doing it.

    Why don't you make a skill type "command choice", have it contain the six different skills Hide, Feint, Sneak, Charge, Escape and Perform, and then use the damage formula and effects in those skills directly?

    The skill type automatically becomes a command header on the actor command menu, when selected it gives the option of choosing all skills in that skill type that the actor has learned (make sure all actors have learned those skills and the skill type).
    And then you can have the skill affect the user or any target as normal, no need at all for scripts, troop events or whatever else.

    But if you really need your complex structure for something you haven't mentioned here yet, you better post screenshots of your troop events and common events and whatever is involved there.
     
    #7
  8. Nerdboy

    Nerdboy Veteran Veteran

    Messages:
    78
    Likes Received:
    7
    im a dummy lol. thank you andar! yes i was definitely doing it way to complicated. i was working on another battle function and used that method. problem solved. plus its way more versatile then my previous overcomplex method of doing it.
     
    #8

Share This Page