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
83
Reaction score
16
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
2,088
Reaction score
1,508
First Language
EN
Primarily Uses
RMMZ
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
13,522
Reaction score
14,255
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: 1)

Latest Threads

Latest Posts

Latest Profile Posts

Couple hours of work. Might use in my game as a secret find or something. Not sure. Fancy though no? :D
Holy stink, where have I been? Well, I started my temporary job this week. So less time to spend on game design... :(
Cartoonier cloud cover that better fits the art style, as well as (slightly) improved blending/fading... fading clouds when there are larger patterns is still somewhat abrupt for some reason.
Do you Find Tilesetting or Looking for Tilesets/Plugins more fun? Personally I like making my tileset for my Game (Cretaceous Park TM) xD
How many parameters is 'too many'??

Forum statistics

Threads
105,865
Messages
1,017,059
Members
137,575
Latest member
akekaphol101
Top