MZ Jump designation with variables

Hello, It's possible in “transfer player” to use designation with variables, and for jump no…

It's possible to do this in javascript? (I don't find a thread in this topic)
Hi there!
yeah, it is ^^

You can use the script call:

character.jump( $gameVariables.value(varId), $gameVariables.value(varId) )

Replace character with $gamePlayer or $gameMap.event(eventId)
Thank you #Eliaquim for the moment it does not work what does not work?

Capture d’écran 2021-07-28 à 17.27.19.png
Thank you #Eliaquim for the moment it does not work what does not work?

View attachment 197129
Hi!
What do you mean by doesn't work? The player did not jump at all? Or does it jumps to a different coordinate?

I just realized that the character.jump(x, y) function does not make the character jump to a specific coordinate. But instead, it adds a plus value for the character to jump.

So if the player is on coordinates (10, 13) and you call the function $gamePlayer.jump(2,2)
The player will not jump to the coordinates (2, 2), but it will jump on (10 + 2, 13 + 2)

So, in your case, I believe you have to set the value of variables 47 and 48, to be a difference between the player distance and the event.
hi! Eliaquim,
it jumps to a different coordinate,
in my case 47 = x of this event, 48 = y of this event
47 and 48 are the variables I want to look for for my jump.

I was wondering if we can do this with the jump:
Capture d’écran 2021-07-29 à 08.03.17.png
hi! Eliaquim,
it jumps to a different coordinate,
in my case 47 = x of this event, 48 = y of this event
47 and 48 are the variables I want to look for for my jump.

I was wondering if we can do this with the jump:
View attachment 197198
Yeah, with script call you can(Assuming that you want to make the player jump to a specific coordinate). But you have to take into consideration that part of my previous comment:

I just realized that the character.jump(x, y) function does not make the character jump to a specific coordinate. But instead, it adds a plus value for the character to jump.

So if the player is on coordinates (10, 13) and you call the function $gamePlayer.jump(2,2)
The player will not jump to the coordinates (2, 2), but it will jump on (10 + 2, 13 + 2)

So, in your case, I believe you have to set the value of variables 47 and 48, to be a difference between the player distance and the event.
This little snippet I just made might be useful:

Spoiler
nq6wuaa.png


JavaScript:
/*:
 * @command jumpToPos
 * @text Jump To Position
 * @desc Makes the defined character jump to the defined coordinates.
 *
 * @arg ownerId
 * @text Char Id
 * @type number
 * @default 0
 * @desc Set the character that will jump.
 *
 * @arg x
 * @text Position X
 * @type text
 * @default 0
 * @desc Set the X position the character will jump.
 *
 * @arg y
 * @text Position Y
 * @type text
 * @default 0
 * @desc Set the Y position the character will jump.
 *
 * @command jumpToPosByVar
 * @text Jump To Position (By Variables)
 * @desc Makes the defined character jump to the defined coordinates.
 *
 * @arg ownerId
 * @text Char Id
 * @type variable
 * @default 1
 * @desc Set the variable character that will jump.
 *
 * @arg x
 * @text Position X
 * @type variable
 * @default 1
 * @desc Set the variable X position the character will jump.
 *
 * @arg y
 * @text Position Y
 * @type variable
 * @default 1
 * @desc Set the variable Y position the character will jump.
 *
 * @command jumpToEvent
 * @text Jump To The Position Of An Event
 * @desc Makes the defined character jump to the coordinates of the defined event.
 *
 * @arg ownerId
 * @text Char Id
 * @type number
 * @default 0
 * @desc Set the character that will jump.
 *
 * @arg targetId
 * @text Event ID
 * @type number
 * @default 1
 * @desc Set the target Event.
 *
 * @command jumpToEventByVar
 * @text Jump To The Position Of An Event (By Variables)
 * @desc Makes the defined character jump to the coordinates of the defined event.
 *
 * @arg ownerId
 * @text Char Id
 * @type variable
 * @default 1
 * @desc Set the variable character that will jump.
 *
 * @arg targetId
 * @text Event ID
 * @type variable
 * @default 1
 * @desc Set the variable target Event.
 *
 */

(() => {
    //=============================================================================
    // ** Plugin Definitions
    //=============================================================================    
    "use strict";
    const pluginName = "JumpSnippet";

    const getCharById = (id) => {
        if (id < 0) {
            return $gamePlayer;
        } else if (id === 0) {
            return $gameMap.event($gameMap._interpreter._eventId);
        } else if (id > 0) {
            return $gameMap.event(id);
        }
    }

    //=============================================================================
    // ** PluginManager
    //-----------------------------------------------------------------------------
    // The static class that manages the plugins.
    //=============================================================================    

    PluginManager.registerCommand(pluginName, "jumpToPos", (args) => {
        const
        owner  = getCharById(parseInt(args.ownerId)),
        target = [parseInt(args.x), parseInt(args.y)]; 
        owner.jumpToPos(...target);
    });

    PluginManager.registerCommand(pluginName, "jumpToPosByVar", (args) => {
        const
        owner  = getCharById($gameVariables.value(parseInt(args.ownerId))),
        target = [$gameVariables.value(parseInt(args.x)), $gameVariables.value(parseInt(args.y))]; 
        owner.jumpToPos(...target);
    });

    PluginManager.registerCommand(pluginName, "jumpToEvent", (args) => {
        const
        owner  = getCharById(parseInt(args.ownerId)),
        target = getCharById(parseInt(args.targetId));
        owner.jumpToChar(target);
    });

    PluginManager.registerCommand(pluginName, "jumpToEventByVar", (args) => {
        const
        owner  = getCharById($gameVariables.value(parseInt(args.ownerId))),
        target = getCharById($gameVariables.value(parseInt(args.targetId)));
        owner.jumpToChar(target);
    });
    
    //=============================================================================
    // ** Game_CharacterBase
    //-----------------------------------------------------------------------------
    // The superclass of Game_Character. It handles basic information, such as
    // coordinates and images, shared by all characters.
    //=============================================================================

    Object.assign(Game_CharacterBase.prototype, {
        //------------------------------------------------------------------------
        // * jumpToPos
        // - New function
        //------------------------------------------------------------------------
        jumpToPos(x, y) {
            this.jump(x - this.x, y - this.y);
        },
        //------------------------------------------------------------------------
        // * jumpToChar
        // - New function
        //------------------------------------------------------------------------
        jumpToChar(char) {
            this.jumpToPos(char.x, char.y);
        },
        //------------------------------------------------------------------------
        // * jumpToEvent
        // - New function
        //------------------------------------------------------------------------
        jumpToEvent(eventId) {
            this.jumpToChar($gameMap.event(eventId));
        },
    });
})();
Eliaquim, JorgeMaker, thank you

I don't know the x, y of my events, I don't know its identifier (spawn event)

I will look for them, they are stored in these two variables (47, 48 in my case)

47, 48 it's not a position, I wanted a formula to get them
I'm sure you can use the plugin I sent you to make any character jump to a position stored in a variable.
JorgeMaker, How? can you explain to me?
JorgeMaker, How? can you explain to me?
Download the plugin he made and take a look at the plugin commands
He posted a screenshot of it
I have already tested it, it is a logic that I do not yet master.
I don't understand what its variables refer to.
Install the plugin.
Set the event position on two variables(just like you did before, on variable 47 and 48).
Then call the plugin command: Jump To Position (By Variables)
Fill the plugin command arguments
And then the player should jump on the coordinates stored on the variables.
If you don't manage to do it, post a screenshot of your event here
Here, what do you think?
Char Id = who jump? -1 = player
Capture d’écran 2021-07-31 à 14.58.26.png


for the moment it does not work
Here, what do you think?
Char Id = who jump? -1 = player
View attachment 197376

for the moment it does not work
Have no idea 😳
As I read the plugin, it should work =/

Original thread: https://forums.rpgmakerweb.com/threads/jump-designation-with-variables.139019/