Set actor position in the battle arena using notetags

Discussion in 'JS Plugin Requests' started by RPG_itch_Studio, Jun 18, 2019.

Thread Status:
Not open for further replies.
  1. RPG_itch_Studio

    RPG_itch_Studio Veteran Veteran

    Messages:
    71
    Likes Received:
    14
    First Language:
    English
    Primarily Uses:
    RMMV
    Is it possible to create a script or plugin that would get the (x,y) coordinates, by reading the actor notetag, and then place that actor at those coordinates in the battle arena (side-view).

    For example:

    <ActorPosition>
    position1 x1 y1
    position2 x2 y2
    position3 x3 y3
    position4 x4 y4
    </ActorPosition>

    If the actor is in position 1 in the party, he must be placed at the coordinates (x1,y1) in the battle arena; if the actor is in position 2 in the party, he must be placed at the coordinates (x2,y2) in the battle arena; and so on...

    It would be nice if this script would be compatible with Yanfly Party System and Actor Party Switch plugins.
     
    #1
  2. caethyril

    caethyril ^_^ Veteran

    Messages:
    946
    Likes Received:
    586
    Location:
    UK
    First Language:
    English
    Primarily Uses:
    RMMV
    If you're using Yanfly's Battle Engine Core (?) then you can probably achieve this via BEC's parameters: "Home Position X" and "Home Position Y", under "---Sideview---". E.g. fixed positions per index:
    Code:
    [450, 460, 470, 480][index]
    This will return a value of 450 for actor index 0 (party leader), 460 for the next actor ("position 2"), 470 for the next, etc.

    However, since you say you want notetags & different positions for each actor, you may want to try this sort of thing for the BEC parameters instead:
    • Home Position X:
      Code:
      parseInt($gameParty.members()[index].actor().meta['ActorPosition' + index].split(',')[0]) || 0
    • Home Position Y:
      Code:
      parseInt($gameParty.members()[index].actor().meta['ActorPosition' + index].split(',')[1]) || 0
    Then something like this for the actor notetags:
    Code:
    <ActorPosition0: 400, 300>
    <ActorPosition1: 400, 400>
    <ActorPosition2: 500, 300>
    <ActorPosition3: 500, 400>
    The formulae look pretty hideous, but I think they should work (did a quick test and it seemed OK for me). :kaoswt:

    Basically, unless you're using a particularly old version of RMMV, simple notetags are automatically read into the database objects' meta properties by the engine on startup. Step-by-step translation of this snippet into English:
    • parseInt( - convert the following from text to integer
      • $gameParty.members() - list of all party members
      • [index] - get member at relevant index (the code is run once for each index)
      • .actor() - get relevant database record for this actor
      • .meta - get notetag data...
      • ['ActorPosition' + index] - ...of notetag named "ActorPositionX", where X is the index of the actor in the party
      • .split(',') - interpret the text as a list of items separated by commas
      • [0] - get the first item in the list (or [1] to get the second item...programmers start counting at 0)
      )
    • || 0 - if the result was falsy (e.g. no appropriate notetag or not-a-number), return zero instead of the tag value
     
    #2
    RPG_itch_Studio likes this.
  3. RPG_itch_Studio

    RPG_itch_Studio Veteran Veteran

    Messages:
    71
    Likes Received:
    14
    First Language:
    English
    Primarily Uses:
    RMMV
    Awesome! It works, thank you!
     
    #3
    caethyril likes this.
  4. bgillisp

    bgillisp Global Moderators Global Mod

    Messages:
    11,609
    Likes Received:
    11,598
    Location:
    USA
    First Language:
    English
    Primarily Uses:
    RMVXA

    This thread is being closed, due to being solved. If for some reason you would like this thread re-opened, please report this post and leave a message why. Thank you.

     
    #4
Thread Status:
Not open for further replies.

Share This Page