Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- //=============================================================================
- // Jump System
- // By GuilhermeSantos
- // GS_JumpSystem.js
- // Version: 2.0.1
- // Date: 05/01/2017
- // Update: 06/01/2017
- // ===========================================================================
- // Terms of use
- // ===========================================================================
- // Put the GS in the credits of your project.
- // Free for commercial and non commercial use.
- // ===========================================================================
- // Termos de uso
- // ===========================================================================
- // Coloque o GS nos créditos do seu projeto.
- // Livre para uso comercial e não comercial.
- //============================================================================
- /*:
- * @author GuilhermeSantos
- * @plugindesc Jump system (GS)
- *
- * @param ---Regions---
- * @default
- *
- * @param Region ID
- * @desc Choose jump region verification id
- * Pattern: 1, 2
- * @default 1, 2
- *
- * @param Region Position
- * @desc Choose the jump positions of the regions
- * Following the order of the list of id of the regions.
- * @default up-down, up-down
- *
- * @param ---Jumps---
- * @default
- *
- * @param Jump Down
- * @desc Set the jump down (x, y)
- * Following the order of the list of id of the regions.
- * @default 0 - 1, 0 - 3
- *
- * @param Jump Up
- * @desc Set the jump up (x, y)
- * Following the order of the list of id of the regions.
- * @default 0 - 1, 0 - 3
- *
- * @param Jump Left
- * @desc Set the jump left (x, y)
- * Following the order of the list of id of the regions.
- * @default 0 - 0, 6 - 2
- *
- * @param Jump Right
- * @desc Set the jump right (x, y)
- * Following the order of the list of id of the regions.
- * @default 0 - 2, 0 - 5
- *
- * @param ---Values---
- * @default
- *
- * @param Value Down
- * @desc Set the value type.
- * Following the order of the Jumps id list.
- * @default positive-positive, positive-positive
- *
- * @param Value Up
- * @desc Set the value type.
- * Following the order of the Jumps id list.
- * @default negative-negative, negative-negative
- *
- * @param Value Left
- * @desc Set the value type.
- * Following the order of the Jumps id list.
- * @default positive-positive, negative-negative
- *
- * @param Value Right
- * @desc Set the value type.
- * Following the order of the Jumps id list.
- * @default positive-positive, negative-negative
- *
- * @param ---Frames---
- * @default
- *
- * @param Frames Down
- * @desc Set the verification time down.
- * YES: Value | NO: False.
- * @default false
- *
- * @param Frames Up
- * @desc Set the verification time up.
- * YES: Value | NO: False.
- * @default false
- *
- * @param Frames Left
- * @desc Set the verification time left.
- * YES: Value | NO: False.
- * @default false
- *
- * @param Frames Right
- * @desc Set the verification time right.
- * YES: Value | NO: False.
- * @default false
- *
- * @help
- * ===========================================================================
- * Introduction:
- * Use this plugin to perform the jumps in your game, For a while using only
- * the game regions for the system.
- * ===========================================================================
- * Contact:
- * website http://lzogames.esy.es/
- * ===========================================================================
- * Regions ID: 1, 2, 3... Always placing the (,) When to change lines
- * Regions Position: 1 - 2, 3 - 6, 6 - 8... Always placing the (-) to change
- * axis (x, y), Always placing the (,) When to change lines
- * Jump Position: up, down, left e right
- * Jump Values: positive e negative
- * Frames: Use a value to leave active or false to leave disabled
- * ===========================================================================
- * Script:
- * * $gamePlayer.verific_Region(); - Leap region verification.
- * * $gamePlayer.verific_position(paramId); - Leap position check.
- *
- * Script Details:
- * * paramId: Region list ID, The count starts at 0
- * ===========================================================================
- * Update:
- * * Thanks for liking and using this plugin. I hope you have a lot of help
- * using this plugin ;)
- *
- * ===========================================================================
- */
- /*:pt
- * @author GuilhermeSantos
- * @plugindesc Sistema de salto (GS)
- *
- * @param ---Regions---
- * @default
- *
- * @param Region ID
- * @desc Escolha o id da região de verificação do salto
- * Padrão: 1, 2
- * @default 1, 2
- *
- * @param Region Position
- * @desc Escolha as posições de pulo das regiões
- * Seguindo a ordem da lista de id das regiões.
- * @default up-down, up-down
- *
- * @param ---Jumps---
- * @default
- *
- * @param Jump Down
- * @desc Defina o pulo para baixo (x, y)
- * Seguindo a ordem da lista de id das regiões.
- * @default 0 - 1, 0 - 3
- *
- * @param Jump Up
- * @desc Defina o pulo para cima (x, y)
- * Seguindo a ordem da lista de id das regiões.
- * @default 0 - 1, 0 - 3
- *
- * @param Jump Left
- * @desc Defina o pulo para esquerda (x, y)
- * Seguindo a ordem da lista de id das regiões.
- * @default 0 - 0, 6 - 2
- *
- * @param Jump Right
- * @desc Defina o pulo para direita (x, y)
- * Seguindo a ordem da lista de id das regiões.
- * @default 0 - 2, 0 - 5
- *
- * @param ---Values---
- * @default
- *
- * @param Value Down
- * @desc Defina o tipo de valor.
- * Seguindo a ordem da lista de id dos Jumps.
- * @default positive-positive, positive-positive
- *
- * @param Value Up
- * @desc Defina o tipo de valor.
- * Seguindo a ordem da lista de id dos Jumps.
- * @default negative-negative, negative-negative
- *
- * @param Value Left
- * @desc Defina o tipo de valor.
- * Seguindo a ordem da lista de id dos Jumps.
- * @default positive-positive, negative-negative
- *
- * @param Value Right
- * @desc Defina o tipo de valor.
- * Seguindo a ordem da lista de id dos Jumps.
- * @default positive-positive, negative-negative
- *
- * @param ---Frames---
- * @default
- *
- * @param Frames Down
- * @desc Defina o tempo de verificação para baixo.
- * SIM: Value | NÂO: False.
- * @default false
- *
- * @param Frames Up
- * @desc Defina o tempo de verificação para baixo.
- * SIM: Value | NÂO: False.
- * @default false
- *
- * @param Frames Left
- * @desc Defina o tempo de verificação para baixo.
- * SIM: Value | NÂO: False.
- * @default false
- *
- * @param Frames Right
- * @desc Defina o tempo de verificação para baixo.
- * SIM: Value | NÂO: False.
- * @default false
- *
- * @help
- * ===========================================================================
- * Introduction:
- * Utilize esse plugin para executar os saltos em seu jogo, por enquanto estou
- * utilizando apenas as regiões como gatilho para o sitema.
- * ===========================================================================
- * Contact:
- * website http://lzogames.esy.es/
- * ===========================================================================
- * Regions ID: 1, 2, 3... sempre colocando a (,) quando for trocar de linha
- * Regions Position: 1 - 2, 3 - 6, 6 - 8... sempre colocando o (-) para trocar
- * de eixo (x, y) e a (,) quando for trocar de linha
- * Jump Position: up, down, left e right
- * Jump Values: positive e negative
- * Frames: Utilize um valor para deixar ativo ou false para deixar desativado
- * ===========================================================================
- * Script:
- * * $gamePlayer.verific_Region(); - Verificação de região de pulo.
- * * $gamePlayer.verific_position(paramId); - Verificação de posição de pulo.
- *
- * Script Details:
- * * paramId: ID da lista de regiões, a contagem inicia em 0
- * ===========================================================================
- * Update:
- * * Obrigado por gostar e usar esse plugin. Espero que tenha uma enorme ajuda
- * utilizando esse sistema de pulo ;)
- *
- * ===========================================================================
- */
- (function() {
- "use strict";
- var GS = GS || {};
- GS.Core = GS.Core || {};
- //=============================================================================
- // CORE UTILS
- //=============================================================================
- GS.Core.metods = {
- replaceParamsPattern: function (param, type) {
- for (var item = 0, string = param, value = 0; item < string.length; item++) {
- if(typeof param === 'string')param = [];
- if(string[item] === ",")value++;
- if(string[item] != " " && string[item] != ",")
- {
- if(type == 0){
- param[value] = parseInt(string[item]);
- }
- else if(type == 1){
- param[value] = String(string[item]);
- }
- else{
- param[value] = string[item];
- };
- };
- };return param;
- },
- replaceParamsToArray: function (param, type) {
- for (var item = 0, string = param, value = 0, str = [""], strValue = 0, maxValue = string.length - 1;
- item < string.length; item++) {
- if(string[item] === "-")strValue++;
- if(string[item] != " " && string[item] != "," && string[item] != "-")
- {
- if(str[strValue] === undefined)str[strValue] = "";
- str[strValue] += string[item];
- };
- if(string[item] === "," || maxValue === item){
- if(typeof param === "string")param = [];
- param[value] = [];
- for (var sts in str) {
- if(type == 0){
- param[value].push(parseInt(str[sts]));
- }
- else if(type == 1){
- param[value].push(String(str[sts]));
- }
- else {
- param[value].push(str[sts]);
- };
- };
- str = [""];
- strValue = 0;
- value++;
- };
- };return param;
- },
- replaceParamsToNumber: function (param){
- if(!isNaN(parseFloat(param)) && isFinite(param)){
- return parseInt(param);
- }else{return param};
- }
- };
- //=============================================================================
- // Parameter Variables
- //=============================================================================
- GS.Parameters = PluginManager.parameters('GS_JumpSystem');
- GS.Parameters.regionId = String(GS.Parameters['Region ID']);
- GS.Parameters.regionPosition = String(GS.Parameters['Region Position']);
- GS.Parameters.jumpDown = String(GS.Parameters['Jump Down']);
- GS.Parameters.jumpUp = String(GS.Parameters['Jump Up']);
- GS.Parameters.jumpLeft = String(GS.Parameters['Jump Left']);
- GS.Parameters.jumpRight = String(GS.Parameters['Jump Right']);
- GS.Parameters.valueDown = String(GS.Parameters['Value Down']);
- GS.Parameters.valueUp = String(GS.Parameters['Value Up']);
- GS.Parameters.valueLeft = String(GS.Parameters['Value Left']);
- GS.Parameters.valueRight = String(GS.Parameters['Value Right']);
- GS.Parameters.framesDown = eval(String(GS.Parameters['Frames Down']));
- GS.Parameters.framesUp = eval(String(GS.Parameters['Frames Up']));
- GS.Parameters.framesLeft = eval(String(GS.Parameters['Frames Left']));
- GS.Parameters.framesRight = eval(String(GS.Parameters['Frames Right']));
- GS.Parameters.regionId = GS.Core.metods.replaceParamsPattern(GS.Parameters.regionId, 0);
- GS.Parameters.regionPosition = GS.Core.metods.replaceParamsToArray(GS.Parameters.regionPosition, 1);
- GS.Parameters.jumpDown = GS.Core.metods.replaceParamsToArray(GS.Parameters.jumpDown, 0);
- GS.Parameters.jumpUp = GS.Core.metods.replaceParamsToArray(GS.Parameters.jumpUp, 0);
- GS.Parameters.jumpLeft = GS.Core.metods.replaceParamsToArray(GS.Parameters.jumpLeft, 0);
- GS.Parameters.jumpRight = GS.Core.metods.replaceParamsToArray(GS.Parameters.jumpRight, 0);
- GS.Parameters.valueDown = GS.Core.metods.replaceParamsToArray(GS.Parameters.valueDown, 1);
- GS.Parameters.valueUp = GS.Core.metods.replaceParamsToArray(GS.Parameters.valueUp, 1);
- GS.Parameters.valueLeft = GS.Core.metods.replaceParamsToArray(GS.Parameters.valueLeft, 1);
- GS.Parameters.valueRight = GS.Core.metods.replaceParamsToArray(GS.Parameters.valueRight, 1);
- GS.Parameters.framesDown = GS.Core.metods.replaceParamsToNumber(GS.Parameters.framesDown);
- GS.Parameters.framesUp = GS.Core.metods.replaceParamsToNumber(GS.Parameters.framesUp);
- GS.Parameters.framesLeft = GS.Core.metods.replaceParamsToNumber(GS.Parameters.framesLeft);
- GS.Parameters.framesRight = GS.Core.metods.replaceParamsToNumber(GS.Parameters.framesRight);
- //=============================================================================
- // Game_Player
- //=============================================================================
- var Game_Player_initialize = Game_Player.prototype.initialize;
- Game_Player.prototype.initialize = function() {
- Game_Player_initialize.call(this);
- this.clearJumpFrames();
- };
- Game_Player.prototype.clearJumpFrames = function() {
- this._framesJumpDown = 0;
- this._framesJumpUp = 0;
- this._framesJumpLeft = 0;
- this._framesJumpRight = 0;
- };
- Game_Player.prototype.updateNonmoving = function(wasMoving) {
- if (!$gameMap.isEventRunning()) {
- if (wasMoving) {
- $gameParty.onPlayerWalk();
- this.checkEventTriggerHere([1,2]);
- if ($gameMap.setupStartingEvent()) {
- return;
- }
- }
- if (this.triggerAction()) {
- return;
- }
- if (wasMoving) {
- this.updateEncounterCount();
- } else {
- $gameTemp.clearDestination();
- }
- if(!wasMoving){ // if Not is moving
- switch($gamePlayer._direction){
- case 2:
- if(typeof GS.Parameters.framesDown != 'number')break;
- this._framesJumpDown++;
- if(this._framesJumpDown > GS.Parameters.framesDown){
- this._framesJumpDown = 0;
- this.verific_Region();
- };
- break;
- case 8:
- if(typeof GS.Parameters.framesUp != 'number')break;
- this._framesJumpUp++;
- if(this._framesJumpUp > GS.Parameters.framesUp){
- this._framesJumpUp = 0;
- this.verific_Region();
- };
- break;
- case 4:
- if(typeof GS.Parameters.framesLeft != 'number')break;
- this._framesJumpLeft++;
- if(this._framesJumpLeft > GS.Parameters.framesLeft){
- this._framesJumpLeft = 0;
- this.verific_Region();
- };
- break;
- case 6:
- if(typeof GS.Parameters.framesRight != 'number')break;
- this._framesJumpRight++;
- if(this._framesJumpRight > GS.Parameters.framesRight){
- this._framesJumpRight = 0;
- this.verific_Region();
- };
- break;
- };
- }else{this.clearJumpFrames()};
- }
- };
- var Game_Player_updateMove = Game_Player.prototype.updateMove;
- Game_Player.prototype.updateMove = function() {
- Game_Player_updateMove.call(this);
- this.verific_Region();
- };
- Game_Player.prototype.verific_Region = function() {
- for (var item = 0, array = GS.Parameters.regionId; item < array.length; item++) {
- if($gameMap.regionId($gamePlayer._x, $gamePlayer._y) === array[item]){
- this.verific_position(item);break;
- };
- };
- };
- Game_Player.prototype.verific_position = function(paramId) {
- switch ($gamePlayer._direction) {
- case 2:
- for (var item = 0, string = GS.Parameters.regionPosition[paramId]; item < string.length; item++) {
- if(string[item].toUpperCase() === "DOWN"){
- this.exe_jump(GS.Parameters.jumpDown, paramId, GS.Parameters.valueDown);break;
- };
- };
- break;
- case 8:
- for (var item = 0, string = GS.Parameters.regionPosition[paramId]; item < string.length; item++) {
- if(string[item].toUpperCase() === "UP"){
- this.exe_jump(GS.Parameters.jumpUp, paramId, GS.Parameters.valueUp);break;
- };
- };
- break;
- case 4:
- for (var item = 0, string = GS.Parameters.regionPosition[paramId]; item < string.length; item++) {
- if(string[item].toUpperCase() === "LEFT"){
- this.exe_jump(GS.Parameters.jumpLeft, paramId, GS.Parameters.valueLeft);break;
- };
- };
- break;
- case 6:
- for (var item = 0, string = GS.Parameters.regionPosition[paramId]; item < string.length; item++) {
- if(string[item].toUpperCase() === "RIGHT"){
- this.exe_jump(GS.Parameters.jumpRight, paramId, GS.Parameters.valueRight);break;
- };
- };
- break;
- };
- };
- Game_Player.prototype.exe_jump = function(param, paramId, paramValue) {
- var x = $gamePlayer._x, y = $gamePlayer._y;
- x += param[paramId][0], y += param[paramId][1];
- var p = [2, 8, 4, 6] // Directions (MV)
- for (var item in p) {
- if($gameMap.isPassable(x, y, p[item])){
- x = param[paramId][0], y = param[paramId][1];
- var value1 = paramValue[paramId][0].toUpperCase(),
- value2 = paramValue[paramId][1].toUpperCase();
- if(value1 === "POSITIVE" && value2 === "POSITIVE"){
- $gamePlayer.jump(x, y);break;
- }else if(value1 === "NEGATIVE" && value2 === "NEGATIVE"){
- $gamePlayer.jump(-x, -y);break;
- }else if(value1 === "POSITIVE" && value2 === "NEGATIVE"){
- $gamePlayer.jump(x, -y);break;
- }else if(value1 === "NEGATIVE" && value2 === "POSITIVE"){
- $gamePlayer.jump(-x, y);break;
- }else{break;};
- };
- };
- };
- })();
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement