Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- // MapSlideTransfer.js
- // Map Slide Transfer (MV) WIP by Lain
- var Lain = Lain || {};
- Lain.mst_version = 1.0;
- /*:
- @plugindesc v1.0 Adds a Slide Effect for transitions and includes a Map Edge Transfer System using Map Notetags.
- @author Lain
- @param FadeType
- @desc 0 = Black, 1 = White, 2 = None, 3 = Slide Effect
- Default: 3
- @default 3
- @param SlideSpeed
- @desc The speed of the Slide Effect.
- Default: 12
- @default 12
- @param MouseMode
- @desc An alternative Map Edge Transfer mode that is compatible with mouse and touch controls. (Default: false)
- @default false
- @help
- Free to use. Credit me if you feel like it. Have a nice day.
- [~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~General Information~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~]
- Version History:
- 11.MAR.2017 -> 1.0 -> Work in Progress
- Features:
- Slide Effect Transition (like in the topdown Zelda games) (not included, yet)
- Map Edge Transfer system via Map Notetags
- Conflicts:
- I expect issues with the Slide Effect when using HUDs, Windows, Pictures and Parallax Mapping.
- Some incompatibilities are simple and some are almost impossible to solve.
- Report bugs, please.
- [~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~Notetags~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~]
- Map Notetag:
- <direction: mapid x y direction transition>
- direction = The cardinal direction you want automatic Map Edge Transfer to happen at
- (north, east, west, south)
- mapid = the ID of the map you want to transfer to
- Must be a Number
- x (OPTIONAL) = Forces the player to transfer to this x coordinate of the new map
- Number (0 = west edge) or false (false = the script will predict it)
- y (OPTIONAL) = Forces the player to transfer to this y coordinate of the new map
- Number (0 = north edge) or false (false = the script will predict it)
- direction (OPTIONAL) = Forces the player to face a certain direction after the transfer
- (8, 6, 4, 2) or false (false = no change)
- transition (OPTIONAL) = Force a transition effect
- 0 = Black, 1 = White, 2 = None, 3 = Slide Effect
- Examples:
- <north: 4>
- Transfers the player to map 4 when hitting the northern edge.
- <west: 90 false 10>
- Transfers the player to map 90 when hitting the western edge.
- Forces the player to come out at the Y coordinates of 10.
- <south: 1 false false 6 2>
- Transfers the player to map 1 when hitting the southern edge.
- The player will face to the right after transfering.
- Skips the transition effect that normally happens.
- */
- Lain.mst_params = PluginManager.parameters('MapSlideTransfer');
- Lain.mst_fadetype = Number(Lain.mst_params['FadeType'] || 3);
- Lain.mst_slidespeed = Number(Lain.mst_params['SlideSpeed'] || 12);
- Lain.mst_mousemode = eval(Lain.mst_params['MouseMode'] || false);
- Lain.mst_through = false;
- // **
- // * [Alias]
- // Game_CharacterBase.prototype.canPass : Makes it possible to move through the edge
- // Game_Player.prototype.update
- // * [New Methods]
- // Game_Player.prototype.mst_facepassableedge
- // Game_Player.prototype.mst_overedge
- // Game_Player.prototype.mst_autotransfer
- //=============================================================================
- // ** Game_CharacterBase
- //=============================================================================
- var alias_Game_CharacterBase_canPass = Game_CharacterBase.prototype.canPass;
- Game_CharacterBase.prototype.canPass = function(x, y, d) {
- if(Lain.mst_through){return true;}
- return alias_Game_CharacterBase_canPass.call(this,x,y,d);
- };
- //=============================================================================
- // ** Game_Player
- //=============================================================================
- var mst_gameplayer_update = Game_Player.prototype.update;
- Game_Player.prototype.update = function(sceneActive) {
- if(this.mst_overedge() && !this.isMoving()){this.mst_autotransfer();}
- mst_gameplayer_update.call(this, sceneActive);
- };
- var mst_gameplayer_movebyinput = Game_Player.prototype.moveByInput;
- Game_Player.prototype.moveByInput = function() {
- mst_gameplayer_movebyinput.call(this);
- if(this.mst_facepassableedge() && !this.isMoving()){
- if(Lain.mst_mousemode){
- var direction = this.direction();
- }
- if(!Lain.mst_mousemode){
- var direction = this.getInputDirection();
- if(!direction>0){return;}
- }
- Lain.mst_through = true;
- this.moveStraight(direction);
- Lain.mst_through = false;
- $gameTemp.clearDestination();
- }
- };
- Game_Player.prototype.mst_facepassableedge = function(){
- if (this.direction() == 8 && this.y == 0 && $dataMap.meta.north) {
- return 8;
- }
- if (this.direction() == 6 && this.x == $dataMap.width - 1 && $dataMap.meta.east) {
- return 6;
- }
- if (this.direction() == 4 && this.x == 0 && $dataMap.meta.west) {
- return 4;
- }
- if (this.direction() == 2 && this.y == $dataMap.height - 1 && $dataMap.meta.south) {
- return 2;
- }
- return false;
- };
- Game_Player.prototype.mst_overedge = function(){
- if(this.y+1==0&&this.direction()==8){return 8;}
- if(this.x==$dataMap.width&&this.direction()==6){return 6;}
- if(this.x+1==0&&this.direction()==4){return 4;}
- if(this.y==$dataMap.height&&this.direction()==2){return 2;}
- return false;
- };
- Game_Player.prototype.mst_autotransfer = function(){
- var edgedir = this.mst_overedge();
- if(edgedir==8){var mapmeta = $dataMap.meta.north;}
- if(edgedir==6){var mapmeta = $dataMap.meta.east;}
- if(edgedir==4){var mapmeta = $dataMap.meta.west;}
- if(edgedir==2){var mapmeta = $dataMap.meta.south;}
- var transinfo = mapmeta.trim().split(' ');
- var newmapid = eval(transinfo[0]);
- DataManager.mst_loadMapDataInfo(newmapid, function (result) {
- if(eval(transinfo[1])!==false){var new_x = eval(transinfo[1])+1;}else{var new_x = false;}
- if(eval(transinfo[2])!==false){var new_y = eval(transinfo[2])+1;}else{var new_y = false;}
- var new_dir = eval(transinfo[3]) || this.direction();
- var new_type = eval(transinfo[4])+1 || Lain.mst_fadetype+1;
- new_type--;
- if (edgedir == 8) {
- var new_x = new_x || this.x+1;
- var new_y = new_y || result.height;
- }
- if (edgedir == 6) {
- var new_x = new_x || 1;
- var new_y = new_y || this.y+1;
- }
- if (edgedir == 4) {
- var new_x = new_x || result.width;
- var new_y = new_y || this.y+1;
- }
- if (edgedir == 2) {
- var new_x = new_x || this.x+1;
- var new_y = new_y || 1;
- }
- new_x--;
- new_y--;
- this.reserveTransfer(newmapid, new_x, new_y, new_dir, new_type);
- }, this);
- };
- DataManager.mst_loadMapDataInfo = function(mapId, onload, context) {
- var src = 'Map%1.json'.format(mapId.padZero(3));
- var xhr = new XMLHttpRequest();
- var url = 'data/' + src;
- var result = null;
- xhr.open('GET', url);
- xhr.overrideMimeType('application/json');
- xhr.onload = function() {
- if (xhr.status < 400) {
- result = JSON.parse(xhr.responseText);
- onload.call(context, result)
- }
- };
- xhr.onerror = function(err) {
- console.log("Failed to load Map Info");
- };
- xhr.send();
- };
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement