Set actor position in the battle arena using notetags

Status
Not open for further replies.

RPG_itch_Studio

Veteran
Veteran
Joined
Jan 20, 2018
Messages
77
Reaction score
15
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.
 

caethyril

^_^
Veteran
Joined
Feb 21, 2018
Messages
1,535
Reaction score
1,015
First Language
EN
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
 

bgillisp

Global Moderators
Global Mod
Joined
Jul 2, 2014
Messages
12,959
Reaction score
13,316
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.

 
Status
Not open for further replies.

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

Latest Threads

Latest Profile Posts

Another weekend. Still have not opened rpgmaker in a while LOL. How is everyone doing?
Check out SpokenWord- my text-to-speech plugin for RPG Maker MV!
just watched spacex launch. was awesome.
Jumping and gravitation 0.1 build - RPG Maker MV
Currently playing final fantasy 3 on DS. It's an old one but its a classic.

Forum statistics

Threads
97,959
Messages
948,128
Members
129,205
Latest member
5harkla5er5
Top