/*:
* @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));
},
});
})();