Войти на сайт

Авторизация, ждите ...
×

ТЕМА: Совм раб. GALV_CamControlMZ и GALV_VisibilityRange

Совм раб. GALV_CamControlMZ и GALV_VisibilityRange 5 мес. 2 нед. назад #125501

  • Alexandr_7
  • Alexandr_7 аватар
  • Вне сайта
  • Светлый дракон
  • Сообщений: 957
  • Спасибо получено: 380
  • Проект месяца 2 местоПроект месяца 3 местоУчительВетеранПроект месяца 1 место
Здравствуйте.
Помогите заставить совместно работать 2 этих плагина.
На Галва расчитывать не приходится ибо на связь он не выходит. (Я и так скинул ему GALV_VisibilityRange адаптированный под MZ неделю назад и никакого ответа. Он даже сообщение не читал.)
Короче надеюсь на скриптеров здесь.
И так. Что значит подружить. Это значит привязать GALV_VisibilityRange к камере а не к игроку.
GALV_VisibilityRange делает ограниченный обзор для игрока чтобы не отображать все разрешение экрана.

disk.yandex.ru/d/gWKJ7Qk1u701Hw

GALV_VisibilityRange:
//-----------------------------------------------------------------------------
//  Galv's Visibility Range
//-----------------------------------------------------------------------------
//  For: RPGMAKER MZ
//  GALV_VisibilityRangeMZ.js
//-----------------------------------------------------------------------------
//  2021-11-19 - Version 1.0 - release
//-----------------------------------------------------------------------------
// Terms can be found at:
// galvs-scripts.com
//-----------------------------------------------------------------------------
 
var Imported = Imported || {};
Imported.Galv_VisibilityRange = true;
 
var Galv = Galv || {};        // Galv's main object
Galv.pCmd = Galv.pCmd || {};  // Plugin Command manager
Galv.VR = Galv.VR || {};      // Galv's plugin stuff
Galv.VR.pluginName = "GALV_VisibilityRangeMZ";
 
//-----------------------------------------------------------------------------
/*:
 * @plugindesc (v.1.0) Use an image to display a visibility range image around the player's position
 * @url http://galvs-scripts.com
 * @target MZ
 * @author Galv - galvs-scripts.com
 * 
 * @command Visrange
 * @text Add visrange
 * @desc Add visrange
 * 
 * @arg imageName
 * @type file
 * @dir img/system/
 * @text Image
 * @desc Image file closing visrange
 * 
 * @command VisrangeRemove
 * @text Remove visrange
 * @desc Remove visrange
 
 
 * @param Zoom Variable
 * @type variable
 * @desc In-Game variable ID used for zooming the visibility range in and out.
 * @default 0
 * 
 * @param Opacity Variable
 * @type variable
 * @desc In-Game variable ID used for opacity of the visibility range image.
 * @default 0
 *
 * @param Z Position
 * @desc The layer the visibility image displays at. Lower if it appears above objects you dont want it to.
 * @default 10
 *
 * @help
 *   Galv's Visibility Range
 * ----------------------------------------------------------------------------
 * This plugin allows you to display a solid colour above a character with an
 * image cut out in the middle.
 * The idea is to give the impression of visibility range. This image will
 * follow the player and can zoom and change opacity by setting the variable
 * ID's in the plugin config and then using the 'Control Variables' event
 * command to change them.
 *
 * NOTE: VARIABLES ARE SET TO 0 BY DEFAULT. YOU WILL NEED TO CHANGE THEM IN
 * ORDER TO USE THIS FUNCTIONALITY.
 *
 * The Zoom variable that controls the growing/shrinking works as follows:
 * Set the variable to the desired ID you will use.
 * The zoom level is 50% + variable%.
 * For this example, assuming we set the config to use Variable #1.
 * When variable #1 is equal or less than 0, the visibility range will be
 * displayed at 50% of it's normal size. This is the smallest size possible.
 * When variable is set to 50, it will be shown at 100% (50 + 50 = 100).
 * 
 * The opacity variable can be 0 - 255 and controls how transparent the
 * visibility range is.
 *
 * The image used for the transparency is taken from:
 * YourProject/img/system/
 * And will only appear if the plugin command has created it. The visrange
 * image will persist across maps, so must be removed on maps you do not want
 * it to appear on.
 * This image must have transparency to show the map under it. You can change
 * the image during game with the plugin command found further below.
 *
 * Advanced Info:
 * The top left pixel of the graphic specifies what colour the rest of the
 * 'darkness' will be. The example image uses black with a blurred transparent
 * circle, the top left black pixel indicates the colour of the rest of the
 * surrounding.
 * ----------------------------------------------------------------------------
 *   PLUGIN COMMAND
 * ----------------------------------------------------------------------------
 *
 *   VISRANGE imageName           // set the visrange image to a new image from
 *                                // /img/system/ folder in your project.
 *                                // Make sure to have correct capitalization
 *                                // Use X for imageName to remove vis image
 *
 * Example:
 * VISRANGE VisibilityRange2    // add visrange using VisibilityRange2 image
 * VISRANGE X                   // remove visibility range
 *
 * ----------------------------------------------------------------------------
 *   SCRIPT
 * ----------------------------------------------------------------------------
 *
 *    $gameSystem.galvVis   // returns the image name of the current vis range.
 *
 */
 
//-----------------------------------------------------------------------------
//  CODE STUFFS
//-----------------------------------------------------------------------------
 
(function() {
 
// GALV'S PLUGIN MANAGEMENT. INCLUDED IN ALL GALV PLUGINS THAT HAVE PLUGIN COMMAND CALLS, BUT ONLY RUN ONCE.
if (!Galv.aliased) {
	var Galv_Game_Interpreter_pluginCommand = Game_Interpreter.prototype.pluginCommand;
	Game_Interpreter.prototype.pluginCommand = function(command, args) {
		if (Galv.pCmd[command]) {
			Galv.pCmd[command](args);
			return;
		};
		Galv_Game_Interpreter_pluginCommand.call(this, command, args);
	};
	Galv.aliased = true; // Don't keep aliasing for other Galv scripts.
};
 
if (Utils.RPGMAKER_NAME === "MZ") {
 
PluginManager.registerCommand(Galv.VR.pluginName, "Visrange", (args) => {
    Galv.pCmd["VISRANGE"]([args.imageName]);
});
 
PluginManager.registerCommand(Galv.VR.pluginName, "VisrangeRemove", () => {
    Galv.pCmd["VISRANGE"](["X"]);
});
 
}
 
// Direct to Plugin Object
Galv.pCmd.VISRANGE = function(arguments) {
	Galv.VR.setImage(arguments[0]);
};
// END GALV'S PLUGIN MANAGEMENT
 
 
Galv.VR.setImage = function(image) {
	if (SceneManager._scene.constructor.name == 'Scene_Map') {
		if (SceneManager._scene._spriteset) SceneManager._scene._spriteset.doVisSprite(image);
	}
};
 
 
Galv.VR.zoom = Number(PluginManager.parameters(Galv.VR.pluginName)["Zoom Variable"]);
Galv.VR.opacity = Number(PluginManager.parameters(Galv.VR.pluginName)["Opacity Variable"]);
Galv.VR.z = Number(PluginManager.parameters(Galv.VR.pluginName)["Z Position"]);
 
//-----------------------------------------------------------------------------
// Spriteset_Map
 
var Galv_Spriteset_Map_createLowerLayer = Spriteset_Map.prototype.createLowerLayer;
Spriteset_Map.prototype.createLowerLayer = function() {
	Galv_Spriteset_Map_createLowerLayer.call(this);
	this.doVisSprite($gameSystem.galvVis);
};
 
Spriteset_Map.prototype.doVisSprite = function(img) {
	if (!img || img == "X") {
		this.removeVisibilityRange();
	} else {
		this.setVisibilityRange(img);
	}
};
 
Spriteset_Map.prototype.setVisibilityRange = function(image) {
	$gameSystem.galvVis = image;
	if (!this._galvVisRange) {
		this._galvVisRange = new Sprite_GalvVisRange();
		this._tilemap.addChild(this._galvVisRange);
	};
};
 
Spriteset_Map.prototype.removeVisibilityRange = function() {
	$gameSystem.galvVis = null;
	if (this._galvVisRange) {
		this._tilemap.removeChild(this._galvVisRange);
		this._galvVisRange = null;
	};
};
 
 
//-----------------------------------------------------------------------------
// Sprite_GalvVisRange
 
function Sprite_GalvVisRange() {
    this.initialize.apply(this, arguments);
}
 
Sprite_GalvVisRange.prototype = Object.create(Sprite.prototype);
Sprite_GalvVisRange.prototype.constructor = Sprite_GalvVisRange;
 
Sprite_GalvVisRange.prototype.initialize = function() {
    Sprite.prototype.initialize.call(this);
	this.name = null;
	this.opacity = 0;
    this.update();
};
 
Sprite_GalvVisRange.prototype.update = function() {
    Sprite.prototype.update.call(this);
    if (this.name != $gameSystem.galvVis) this.loadBitmap();  // If image changed, reload bitmap
	this.opacity = $gameVariables.value(Galv.VR.opacity);
	if (this.opacity <= 0) return;
 
	this.x = $gamePlayer.screenX();
	this.y = $gamePlayer.screenY() - 24;
	var zoom = Math.max($gameVariables.value(Galv.VR.zoom) * 0.01 + 0.5,0.5);
	this.scale.x = zoom;
	this.scale.y = zoom;
};
 
Sprite_GalvVisRange.prototype.loadBitmap = function() {
	var img = ImageManager.loadSystem($gameSystem.galvVis);
	if (img.isReady()) {
		if (this.bitmap) {
			//this._destroyCachedSprite();
			this.bitmap = null;
		};
 
		// Middle Graphic
		var tempSprite = new Sprite();
		tempSprite.bitmap = ImageManager.loadSystem($gameSystem.galvVis);
		var iw = tempSprite.bitmap.width;
		var ih = tempSprite.bitmap.height;
		var color = tempSprite.bitmap.getPixel(0,0);
 
		// Background Color
		this.bitmap = new Bitmap(Graphics.boxWidth * 4,Graphics.boxHeight * 4);
		this.bitmap.fillRect(0, 0, Graphics.boxWidth * 4, Graphics.boxHeight * 4, color);
 
		// Position
		this.anchor.x = 0.5;
		this.anchor.y = 0.5;
		this.x = $gamePlayer.screenX();
		this.y = $gamePlayer.screenY();
		this.z = Galv.VR.z;
 
		// Join Bitmaps
		var cx = ((Graphics.boxWidth * 4) / 2) - (iw / 2);
		var cy = ((Graphics.boxHeight * 4) / 2) - (ih / 2);
		this.bitmap.clearRect(cx, cy, iw, ih);
		this.bitmap.blt(tempSprite.bitmap, 0, 0, iw, ih, cx, cy);
 
		this.name = $gameSystem.galvVis;
	};
};
})();

GALV_CamControlMZ:
//-----------------------------------------------------------------------------
//  Galv's Cam Control MZ
//-----------------------------------------------------------------------------
//  For: RPGMAKER MV
//  GALV_CamControlMZ.js
//-----------------------------------------------------------------------------
//  2020-11-23 - Version 1.7 - Added 'wait for camera' plugin command
//  2020-11-21 - Version 1.6 - Fixed speed not working when targeting player
//  2020-09-14 - Version 1.5 - Disabled battle zooming due to conflicts
//  2020-09-11 - Version 1.4 - Fixed bugs with save/loading data
//  2020-09-10 - Version 1.3 - Added zooming functionality
//  2020-09-07 - Version 1.2 - Minor code tweaks but no actual changes.
//  2020-09-01 - Version 1.1 - Minor code tweaks due to even position issue.
//  2020-08-26 - Version 1.0 - release
//-----------------------------------------------------------------------------
//  Terms can be found at:
//  galvs-scripts.com
//-----------------------------------------------------------------------------
 
var Imported = Imported || {};
Imported.Galv_CamControl = true;
 
var Galv = Galv || {};          // Galv's main object
Galv.CC = Galv.CC || {};        // This plugin object
Galv.CC.pluginName = "GALV_CamControlMZ";
 
//-----------------------------------------------------------------------------
/*:
 * @plugindesc (v.1.7) Allows greater control over where the game camera is focused. View documentation for plugin commands.
 * @url http://galvs-scripts.com
 * @target MZ
 * @author Galv
 *
 * @param useZoom
 * @text Enable Zoom Functions
 * @type boolean
 * @desc Make this false if you are using another zoom plugin so they don't conflict
 * @default true
 *
 * @param bZoom
 * @text Default Battle Zoom
 * @desc The zoom scale battle will begin at.
 * Default: 1 (100%)
 * @default 1
 *
 *
 * @command focusCharacter
 * @text Focus Character
 * @desc Set the camera's focus to a character
 *
 * @arg charId
 * @default 0
 * @text Character Id
 * @desc Target event id for camera focus or use 0 for player
 *
 * @arg speed
 * @default 800
 * @text Scroll Speed
 * @desc The speed in which the camera scrolls to the target (higher is slower)
 *
 *
 * @command focusXY
 * @text Focus Map Tile
 * @desc Set the camera's focus to a map tile's X,Y position
 *
 * @arg posX
 * @default 0
 * @text X Position
 * @desc The tile's X position
 *
 * @arg posY
 * @default 0
 * @text Y Position
 * @desc The tile's Y position
 *
 * @arg speed
 * @default 800
 * @text Scroll Speed
 * @desc The speed in which the camera scrolls to the target (higher is slower)
 *
 *
 * @command disable
 * @text Disable Focus
 * @desc Remove the camera focus and back to default camera on player. Do this to use Scroll Map event commands
 *
 * @command waitForCam
 * @text Wait For Camera
 * @desc Use after declaring a target to wait for the camera to reach the target before doing next event command
 *
 *
 * @command zoom
 * @text Zoom
 * @desc Zoom the center of the screen to a specified scale
 *
 * @arg zScale
 * @default 1
 * @text Zoom Scale
 * @desc 1 = 100%. 2.5 = 250%, etc.
 *
 * @arg zDuration
 * @default 60
 * @text Zoom Duration
 * @desc The amount of frames it takes to zoom into the selected scale
 *
 * @help
 *   Galv's Cam Control MZ
 * ----------------------------------------------------------------------------
 * This plugin creates a sliding movement for the camera as well as allows you
 * to set the target position of it to wherever required. (Player, event, xy)
 *
 * ----------------------------------------------------------------------------
 *   PLUGIN COMMANDS
 * ----------------------------------------------------------------------------
 *   Focus Character              // Set camera focus to a character.
 *                                // 0 for player, higher numbers for event ids
 *                                // Higher speed is slower camera
 *
 *   Focus Map Tile               // Set camera focus to an event.
 *                                // As above but instead of a character target
 *                                // you can set x,y tile position on the map
 *                                // Higher speed is slower camera
 *
 *
 *   Disable Focus                // Sets the focus on player and disables the
 *                                // sliding motion. (RPGMaker default)
 *                                // Using any command above will enable again
 *
 *   Wait For Camera              // Waits for the camera to stop moving before
 *                                // executing the next event command. Caution
 *                                // if using a moving target that never stops
 *
 *   Zoom                         // Set a zoom scale to zoom in and out
 *                                // Duration is many frames the zoom takes
 *
 * NOTES: 
 * - Not recommended to use speeds that are too fast.
 * - v# to use a variable's value in these options, where # is the variable id.
 * - Zooming out does not create more map so might be best to zoom in only
 * - Zooming only zooms to the center of the screen, so if your screen is at 
 *   the edge of the map, it won't zoom on the target. If you need to do this,
 *   increase the size of your map so the camera isn't at the edge.
 */
 
//-----------------------------------------------------------------------------
//  CODE STUFFS
//-----------------------------------------------------------------------------
 
// PLUGIN COMMANDS
//-----------------------------------------------------------------------------
 
PluginManager.registerCommand(Galv.CC.pluginName, "focusCharacter", args => {
	if ($gameMap.waitForCam && $gameMap.camIsMoving) return;
	const type = Galv.CC.getValue(args.charId) > 0 ? ["event"] : ["player"];
	const settings = type.concat(Object.values(args));
    Galv.CC.camControl(settings);  // Send an array of the setting values
});
 
PluginManager.registerCommand(Galv.CC.pluginName, "focusXY", args => {
	if ($gameMap.waitForCam && $gameMap.camIsMoving) return;
	const settings = Object.values(args);
    Galv.CC.camControl(settings);  // Send an array of the setting values
});
 
PluginManager.registerCommand(Galv.CC.pluginName, "disable", args => {
    Galv.CC.camControl(["disable"]);  // Send an array of the setting values
});
 
PluginManager.registerCommand(Galv.CC.pluginName, "waitForCam", args => {
    $gameMap._interpreter.waitForCam();
});
 
 
 
 
// PLUGIN FUNCTIONS
//-----------------------------------------------------------------------------
 
Galv.CC.camControl = function(args) {
	let key = args[0].toLowerCase();
	let speed = 800;
	let target = $gamePlayer;
 
	switch (key) {
		case "player":
			if (args[2]) speed = Galv.CC.getValue(args[2]);
			break;
		case "event":
			let eId = Galv.CC.getValue(args[1]);
			target = $gameMap.event(eId);
			if (args[2]) speed = Galv.CC.getValue(args[2]);
			break;
		case "disable":
			$gameMap.camTarget = $gamePlayer;
			$gameMap.camNorm = true;
			$gameMap.savedCamTarget = null;
			return;
		default:
			let px = Galv.CC.getValue(args[0]);
			let py = Galv.CC.getValue(args[1]);
			if (args[2]) speed = Galv.CC.getValue(args[2]);
			target = {
				x: px,
				y: py,
				_realX: px,
				_realY: py,
				screenX: Game_CharacterBase.prototype.screenX,
				screenY: function() {
					let th = $gameMap.tileHeight();
					return Math.round(this.scrolledY() * th + th);
				},
				scrolledX: Game_CharacterBase.prototype.scrolledX,
				scrolledY: Game_CharacterBase.prototype.scrolledY
			};
	};
	$gameMap.camTargetSet(target,speed);
	$gameMap.savedCamTarget = args;
};
 
 
// OTHER
//-----------------------------------------------------------------------------
 
Galv.CC.getValue = function(string) {
	if (string[0].toLowerCase() === "v") {
		// Use variable
		let varId = Number(string.replace("v",""));
		return $gameVariables.value(varId);
	} else {
		return Number(string);
	};
};
 
 
// GAME MAP
//-----------------------------------------------------------------------------
 
// OVERWRITE
Game_Map.prototype.displayX = function() {return Math.ceil(this._displayX * Galv.CC.size) / Galv.CC.size};
Game_Map.prototype.displayY = function() {return Math.ceil(this._displayY * Galv.CC.size) / Galv.CC.size};
 
Galv.CC.Game_Map_initialize = Game_Map.prototype.initialize;
Game_Map.prototype.initialize = function() {
	Galv.CC.size = this.tileWidth();
	this._camWidth = Graphics.width / 2;
	this._camHeight = Graphics.height / 2;
	Galv.CC.Game_Map_initialize.call(this);
};
 
Galv.CC.Game_Map_setup = Game_Map.prototype.setup;
Game_Map.prototype.setup = function(mapId) {
	this.zoom = this.zoom || new PIXI.Point(1,1);
	if (!this.camNorm) {
		this.camTargetSet($gamePlayer,800);
		this.savedCamTarget = ["player"];
	};
	Galv.CC.Game_Map_setup.call(this,mapId);
};
 
Game_Map.prototype.camTargetSet = function(target,speed) {
	this.camIsMoving = true;
    this.camTarget = target;
    this.camNorm = false;
    this.camSpeed = speed || 800;
};
 
Galv.CC.Game_Map_updateScroll = Game_Map.prototype.updateScroll;
Game_Map.prototype.updateScroll = function() {
	if (this.camNorm) return Galv.CC.Game_Map_updateScroll.call(this);
 
	this._scrollRest = 0;
    const cw = this._camWidth;
    const ch = this._camHeight;
	const screenX = this.camTarget.screenX() * this.zoom.x;
	const screenY = this.camTarget.screenY() * this.zoom.y;
	let sx = Math.abs(screenX - cw) / this.camSpeed;
	let sy = Math.abs(screenY - ch) / this.camSpeed;
 
	if (sx < 0.01) (sx = 0);
	if (sy < 0.01) (sy = 0);
 
	this.camIsMoving = $gameMap.waitForCam ? sx + sy != 0 : false;
 
	if (screenY < ch) {
      this.scrollUp(sy);
	} else if (screenY > ch) {
      this.scrollDown(sy);
	};
 
    if (screenX < cw) {
      this.scrollLeft(sx);
	} else if (screenX > cw) {
      this.scrollRight(sx);
	};
};
 
 
//  GAME INTERPRETER
//-----------------------------------------------------------------------------
 
Game_Interpreter.prototype.waitForCam = function() {
    if ($gameMap.camIsMoving) {
		$gameMap.waitForCam = true;
		this.wait(1);
		this._index--;
	} else {
		$gameMap.waitForCam = false;
	}
    return true;
};
 
 
// SCENE MAP
//-----------------------------------------------------------------------------
 
Galv.CC.Scene_Map_onMapLoaded = Scene_Map.prototype.onMapLoaded;
Scene_Map.prototype.onMapLoaded = function() {
	Galv.CC.Scene_Map_onMapLoaded.call(this);
	if (!$gameMap.camNorm) {
		$gameMap.savedCamTarget = $gameMap.savedCamTarget || ["player"];
		Galv.CC.camControl($gameMap.savedCamTarget);
	};
};
 
 
// GAME PLAYER
//-----------------------------------------------------------------------------
 
Galv.CC.Game_Player_updateScroll = Game_Player.prototype.updateScroll;
Game_Player.prototype.updateScroll = function(lastScrolledX, lastScrolledY) {
	if ($gameMap.camNorm) return Galv.CC.Game_Player_updateScroll.call(this,lastScrolledX, lastScrolledY);
};
 
Galv.CC.Game_Player_center = Game_Player.prototype.center;
Game_Player.prototype.center = function(x, y) {
	if ($gameMap.camTarget == $gamePlayer || $gameMap.camNorm) {
    	return Galv.CC.Game_Player_center.call(this,x,y);
	};
};
 
 
Game_Player.prototype.centerX = function() {
    return ((Graphics.width / $gameMap.tileWidth() - $gameMap.zoom.x) / 2.0) / $gameMap.zoom.x;
};
 
Game_Player.prototype.centerY = function() {
    return ((Graphics.height / $gameMap.tileHeight() - 1.75 * $gameMap.zoom.y) / 2.0) / $gameMap.zoom.y;
};
 
 
//-----------------------------------------------------------------------------
//  ZOOM FUNCTIONALITY
//-----------------------------------------------------------------------------
 
PluginManager.registerCommand(Galv.CC.pluginName, "zoom", args => {
	const scale = Galv.CC.getValue(args.zScale);
	const duration = Math.max(Galv.CC.getValue(args.zDuration),1);
	Galv.CC.zoom(scale,duration);
});
 
Galv.CC.battleScale = Number(PluginManager.parameters(Galv.CC.pluginName)["bZoom"]);
Galv.CC.useZoom = PluginManager.parameters(Galv.CC.pluginName)["useZoom"] == 'true';
Galv.CC.halfWidth = 0;
Galv.CC.halfHeight = 0;
 
Galv.CC.zoom = function(scale,duration) {
	if (!Galv.CC.useZoom) return;
	const x = Galv.CC.halfWidth;
	const y = Galv.CC.halfHeight + 12;
	$gameScreen.startZoom(x,y,scale,duration);
};
 
Galv.CC.saveZoomData = function() {
	$gameSystem._savedZoom.x = $gameScreen._zoomX;
	$gameSystem._savedZoom.xTarget = $gameScreen._zoomXTarget;
	$gameSystem._savedZoom.y = $gameScreen._zoomY;
	$gameSystem._savedZoom.yTarget = $gameScreen._zoomYTarget;
	$gameSystem._savedZoom.scale = $gameScreen._zoomScale;
	$gameSystem._savedZoom.scaleTarget = $gameScreen._zoomScaleTarget;
	$gameSystem._savedZoom.duration = $gameScreen._zoomDuration;
};
 
 
//  GAME SYSTEM
//-----------------------------------------------------------------------------
 
Galv.CC.Game_System_initialize = Game_System.prototype.initialize;
Game_System.prototype.initialize = function() {
	Galv.CC.halfWidth = Math.floor(Graphics.width / 2);
	Galv.CC.halfHeight = Math.floor(Graphics.height / 2);
	this.buildSavedZoom();
	Galv.CC.Game_System_initialize.call(this);
};
 
Game_System.prototype.buildSavedZoom = function() {
	const cx = Galv.CC.halfWidth;
	const cy = Galv.CC.halfHeight
	this._savedZoom = {
		x: cx,
		y: cy,
		xTarget: cx,
		yTarget: cy,
		scale: 1,
		scaleTarget: 1,
		duration: 0
	}
};
 
 
//  GAME SCREEN
//-----------------------------------------------------------------------------
 
if (Galv.CC.useZoom) {
// Overwrite
Galv.CC.Game_Screen_startZoom = Game_Screen.prototype.startZoom;
Game_Screen.prototype.startZoom = function(x, y, scale, duration) {
	if ($gameParty.inBattle()) return Galv.CC.Game_Screen_startZoom.call(this,x, y, scale, duration); // don't use in battle
	this._zoomXTarget = Math.min(Graphics.width,Math.max(x,0));
	this._zoomYTarget = Math.min(Graphics.height,Math.max(y,0));
	this._zoomScaleTarget = scale < 0 ? this._zoomScale : scale;
	this._zoomDuration = duration || 60;
};
 
Galv.CC.Game_Screen_clearZoom = Game_Screen.prototype.clearZoom;
Game_Screen.prototype.clearZoom = function() {
	if ($gameSystem._savedZoom) {
		this._zoomX = $gameSystem._savedZoom.x;
		this._zoomXTarget = $gameSystem._savedZoom.xTarget;
		this._zoomY = $gameSystem._savedZoom.y;
		this._zoomYTarget = $gameSystem._savedZoom.yTarget;
		this._zoomScale = $gameSystem._savedZoom.scale;
		this._zoomScaleTarget = $gameSystem._savedZoom.scaleTarget;
		this._zoomDuration = $gameSystem._savedZoom.duration;
		return;
	}
	Galv.CC.Game_Screen_clearZoom.call(this);
};
 
Galv.CC.Game_Screen_onBattleStart = Game_Screen.prototype.onBattleStart;
Game_Screen.prototype.onBattleStart = function() {
	Galv.CC.saveZoomData();
	Galv.CC.dontSave = true;
	Galv.CC.Game_Screen_onBattleStart.call(this);
};
 
Game_Screen.prototype.resetBattleZoom = function() {
	this._zoomX = Galv.CC.halfWidth;
	this._zoomXTarget = Galv.CC.halfWidth;
	this._zoomY = Galv.CC.halfHeight;
	this._zoomYTarget = Galv.CC.halfHeight;
	this._zoomScale = Galv.CC.battleScale;
	this._zoomScaleTarget = Galv.CC.battleScale;
	this._zoomDuration = 0;
};
 
 
//  SCENE MAP
//-----------------------------------------------------------------------------
 
Galv.CC.Scene_Map_start = Scene_Map.prototype.start;
Scene_Map.prototype.start = function() {
	$gameScreen.clearZoom();
	Galv.CC.Scene_Map_start.call(this);
};
 
Galv.CC.Scene_Map_terminate = Scene_Map.prototype.terminate;
Scene_Map.prototype.terminate = function() {
	if (!Galv.CC.dontSave) Galv.CC.saveZoomData();
	Galv.CC.Scene_Map_terminate.call(this);
};
 
 
//  SCENE BATTLE
//-----------------------------------------------------------------------------
 
Galv.CC.Scene_Battle_start = Scene_Battle.prototype.start;
Scene_Battle.prototype.start = function() {
	$gameScreen.resetBattleZoom();
	Galv.CC.Scene_Battle_start.call(this);
};
 
Galv.CC.Scene_Battle_terminate = Scene_Battle.prototype.terminate;
Scene_Battle.prototype.terminate = function() {
	Galv.CC.dontSave = false;
	Galv.CC.Scene_Battle_terminate.call(this);
};
}; // End if Galv.CC.useZoom
Мой вк: vk.com/borisov_alexandr_5
Мой дискорд: Alexandr_5#6523
Последнее редактирование: 5 мес. 2 нед. назад от Alexandr_7.
Администратор запретил публиковать записи гостям.

Совм раб. GALV_CamControlMZ и GALV_VisibilityRange 5 мес. 2 нед. назад #125506

  • Alexandr_7
  • Alexandr_7 аватар
  • Вне сайта
  • Светлый дракон
  • Сообщений: 957
  • Спасибо получено: 380
  • Проект месяца 2 местоПроект месяца 3 местоУчительВетеранПроект месяца 1 место
Короче то что я выяснил в $gameMap.camTarget параметры камеры.
screenX() и screenY() это объект к которому движется камера. Формула высчитывания движения вот:
const cw = this._camWidth;
    const ch = this._camHeight;
	const screenX = this.camTarget.screenX() * this.zoom.x;
	const screenY = this.camTarget.screenY() * this.zoom.y;
	let sx = Math.abs(screenX - cw) / this.camSpeed;
	let sy = Math.abs(screenY - ch) / this.camSpeed;
Но я не силен в математики. Нужно както для видимости имея эти данные вычислять позицию для видитмости относительно уже данных камеры а не просто позиция объекта.
Тоесть к this.camTarget.screenX() и this.camTarget.screenY() прибавлять или вычитать значение которое при движении камеры бы довало 0.
Но как уже сказал я не силен в математики.
Мой вк: vk.com/borisov_alexandr_5
Мой дискорд: Alexandr_5#6523
Администратор запретил публиковать записи гостям.

Совм раб. GALV_CamControlMZ и GALV_VisibilityRange 5 мес. 2 нед. назад #125509

  • DarchanKaen
  • DarchanKaen аватар
  • Вне сайта
  • Мастер
  • Сообщений: 227
  • Спасибо получено: 207
  • 3 место в Обучающем конкурсеРазработчикПроект месяца 1 местоВетеран
Не претендую на полное решение, но если в Galv's Visibility Range по тексту плагина (то есть в Sprite_GalvVisRange.prototype.update и Sprite_GalvVisRange.prototype.loadBitmap) поменять:

$gamePlayer.screenX()
$gamePlayer.screenY()
на
$gameMap.camTarget.screenX()
$gameMap.camTarget.screenY()

то при использовании команд из Galv's Cam Control MZ, "темнота" перемещается за камерой. Малость дергано, если карта больше 17х13, но перемещается.

Может это послужит отправной точкой для полного решения.
Мои игры [ Нажмите, чтобы развернуть ]
Последнее редактирование: 5 мес. 2 нед. назад от DarchanKaen.
Администратор запретил публиковать записи гостям.

Совм раб. GALV_CamControlMZ и GALV_VisibilityRange 5 мес. 2 нед. назад #125510

  • Alexandr_7
  • Alexandr_7 аватар
  • Вне сайта
  • Светлый дракон
  • Сообщений: 957
  • Спасибо получено: 380
  • Проект месяца 2 местоПроект месяца 3 местоУчительВетеранПроект месяца 1 место
DarchanKaen пишет:
Не претендую на полное решение, но если в Galv's Visibility Range по тексту плагина (то есть в Sprite_GalvVisRange.prototype.update и Sprite_GalvVisRange.prototype.loadBitmap) поменять:

$gamePlayer.screenX()
$gamePlayer.screenY()
на
$gameMap.camTarget.screenX()
$gameMap.camTarget.screenY()

то при использовании команд из Galv's Cam Control MZ, "темнота" перемещается за камерой. Малость дергано, если карта больше 17х13, но перемещается.

Может это послужит отправной точкой для полного решения.
Да это блин понятно что перемещается. Нужно заставить ее перемещаться плавно а не резко. Учитывая что разрешение экрана 1280 x 720 а ограничиваю область видимости я до 500 x 500.
Нужно анимировать это через GALV_CamControlMZ и тут я вообще без понятия что делать. Короче я доработал этих 2 плагина вот так:
GALV_VisibilityRange:
//-----------------------------------------------------------------------------
//  Galv's Visibility Range
//-----------------------------------------------------------------------------
//  For: RPGMAKER MZ
//  GALV_VisibilityRangeMZ.js
//-----------------------------------------------------------------------------
//  2021-11-19 - Version 1.0 - release
//-----------------------------------------------------------------------------
// Terms can be found at:
// galvs-scripts.com
//-----------------------------------------------------------------------------
 
var Imported = Imported || {};
Imported.Galv_VisibilityRange = true;
 
var Galv = Galv || {};        // Galv's main object
Galv.pCmd = Galv.pCmd || {};  // Plugin Command manager
Galv.VR = Galv.VR || {};      // Galv's plugin stuff
Galv.VR.pluginName = "GALV_VisibilityRangeMZ";
 
//-----------------------------------------------------------------------------
/*:
 * @plugindesc (v.1.0) Use an image to display a visibility range image around the player's position
 * @url http://galvs-scripts.com
 * @target MZ
 * @author Galv - galvs-scripts.com
 * 
 * @command Visrange
 * @text Add visrange
 * @desc Add visrange
 * 
 * @arg imageName
 * @type file
 * @dir img/system/
 * @text Image
 * @desc Image file closing visrange
 * 
 * @command VisrangeRemove
 * @text Remove visrange
 * @desc Remove visrange
 
 
 * @param Zoom Variable
 * @type variable
 * @desc In-Game variable ID used for zooming the visibility range in and out.
 * @default 0
 * 
 * @param Opacity Variable
 * @type variable
 * @desc In-Game variable ID used for opacity of the visibility range image.
 * @default 0
 *
 * @param Z Position
 * @desc The layer the visibility image displays at. Lower if it appears above objects you dont want it to.
 * @default 10
 *
 * @help
 *   Galv's Visibility Range
 * ----------------------------------------------------------------------------
 * This plugin allows you to display a solid colour above a character with an
 * image cut out in the middle.
 * The idea is to give the impression of visibility range. This image will
 * follow the player and can zoom and change opacity by setting the variable
 * ID's in the plugin config and then using the 'Control Variables' event
 * command to change them.
 *
 * NOTE: VARIABLES ARE SET TO 0 BY DEFAULT. YOU WILL NEED TO CHANGE THEM IN
 * ORDER TO USE THIS FUNCTIONALITY.
 *
 * The Zoom variable that controls the growing/shrinking works as follows:
 * Set the variable to the desired ID you will use.
 * The zoom level is 50% + variable%.
 * For this example, assuming we set the config to use Variable #1.
 * When variable #1 is equal or less than 0, the visibility range will be
 * displayed at 50% of it's normal size. This is the smallest size possible.
 * When variable is set to 50, it will be shown at 100% (50 + 50 = 100).
 * 
 * The opacity variable can be 0 - 255 and controls how transparent the
 * visibility range is.
 *
 * The image used for the transparency is taken from:
 * YourProject/img/system/
 * And will only appear if the plugin command has created it. The visrange
 * image will persist across maps, so must be removed on maps you do not want
 * it to appear on.
 * This image must have transparency to show the map under it. You can change
 * the image during game with the plugin command found further below.
 *
 * Advanced Info:
 * The top left pixel of the graphic specifies what colour the rest of the
 * 'darkness' will be. The example image uses black with a blurred transparent
 * circle, the top left black pixel indicates the colour of the rest of the
 * surrounding.
 * ----------------------------------------------------------------------------
 *   PLUGIN COMMAND
 * ----------------------------------------------------------------------------
 *
 *   VISRANGE imageName           // set the visrange image to a new image from
 *                                // /img/system/ folder in your project.
 *                                // Make sure to have correct capitalization
 *                                // Use X for imageName to remove vis image
 *
 * Example:
 * VISRANGE VisibilityRange2    // add visrange using VisibilityRange2 image
 * VISRANGE X                   // remove visibility range
 *
 * ----------------------------------------------------------------------------
 *   SCRIPT
 * ----------------------------------------------------------------------------
 *
 *    $gameSystem.galvVis   // returns the image name of the current vis range.
 *
 */
 
//-----------------------------------------------------------------------------
//  CODE STUFFS
//-----------------------------------------------------------------------------
 
(function() {
 
// GALV'S PLUGIN MANAGEMENT. INCLUDED IN ALL GALV PLUGINS THAT HAVE PLUGIN COMMAND CALLS, BUT ONLY RUN ONCE.
if (!Galv.aliased) {
	var Galv_Game_Interpreter_pluginCommand = Game_Interpreter.prototype.pluginCommand;
	Game_Interpreter.prototype.pluginCommand = function(command, args) {
		if (Galv.pCmd[command]) {
			Galv.pCmd[command](args);
			return;
		};
		Galv_Game_Interpreter_pluginCommand.call(this, command, args);
	};
	Galv.aliased = true; // Don't keep aliasing for other Galv scripts.
};
 
if (Utils.RPGMAKER_NAME === "MZ") {
 
PluginManager.registerCommand(Galv.VR.pluginName, "Visrange", (args) => {
    Galv.pCmd["VISRANGE"]([args.imageName]);
});
 
PluginManager.registerCommand(Galv.VR.pluginName, "VisrangeRemove", () => {
    Galv.pCmd["VISRANGE"](["X"]);
});
 
}
 
// Direct to Plugin Object
Galv.pCmd.VISRANGE = function(arguments) {
	Galv.VR.setImage(arguments[0]);
};
// END GALV'S PLUGIN MANAGEMENT
 
 
Galv.VR.setImage = function(image) {
	if (SceneManager._scene.constructor.name == 'Scene_Map') {
		if (SceneManager._scene._spriteset) SceneManager._scene._spriteset.doVisSprite(image);
	}
};
 
 
Galv.VR.zoom = Number(PluginManager.parameters(Galv.VR.pluginName)["Zoom Variable"]);
Galv.VR.opacity = Number(PluginManager.parameters(Galv.VR.pluginName)["Opacity Variable"]);
Galv.VR.z = Number(PluginManager.parameters(Galv.VR.pluginName)["Z Position"]);
 
Galv.VR.posX = -1;
Galv.VR.posY = -1;
 
//-----------------------------------------------------------------------------
// Spriteset_Map
 
var Galv_Spriteset_Map_createLowerLayer = Spriteset_Map.prototype.createLowerLayer;
Spriteset_Map.prototype.createLowerLayer = function() {
	Galv_Spriteset_Map_createLowerLayer.call(this);
	this.doVisSprite($gameSystem.galvVis);
};
 
Spriteset_Map.prototype.doVisSprite = function(img) {
	if (!img || img == "X") {
		this.removeVisibilityRange();
	} else {
		this.setVisibilityRange(img);
	}
};
 
Spriteset_Map.prototype.setVisibilityRange = function(image) {
	$gameSystem.galvVis = image;
	if (!this._galvVisRange) {
		this._galvVisRange = new Sprite_GalvVisRange();
		Galv.VR.visR = this._galvVisRange;
		this._tilemap.addChild(this._galvVisRange);
	};
};
 
Spriteset_Map.prototype.removeVisibilityRange = function() {
	$gameSystem.galvVis = null;
	Galv.VR.visR = null;
	if (this._galvVisRange) {
		this._tilemap.removeChild(this._galvVisRange);
		this._galvVisRange = null;
	};
};
 
 
//-----------------------------------------------------------------------------
// Sprite_GalvVisRange
 
function Sprite_GalvVisRange() {
    this.initialize.apply(this, arguments);
}
 
Sprite_GalvVisRange.prototype = Object.create(Sprite.prototype);
Sprite_GalvVisRange.prototype.constructor = Sprite_GalvVisRange;
 
Sprite_GalvVisRange.prototype.initialize = function() {
    Sprite.prototype.initialize.call(this);
	this.name = null;
	this.opacity = 0;
    this.update();
};
 
Sprite_GalvVisRange.prototype.update = function() {
    Sprite.prototype.update.call(this);
    if (this.name != $gameSystem.galvVis) this.loadBitmap();  // If image changed, reload bitmap
	this.opacity = $gameVariables.value(Galv.VR.opacity);
	if (this.opacity <= 0) return;
 
	this.x = $gameMap.camTarget.visRX || $gamePlayer.screenX();
	this.y = ($gameMap.camTarget.visRY || $gamePlayer.screenY()) - 24;
	var zoom = Math.max($gameVariables.value(Galv.VR.zoom) * 0.01 + 0.5,0.5);
	this.scale.x = zoom;
	this.scale.y = zoom;
};
 
Sprite_GalvVisRange.prototype.loadBitmap = function() {
	var img = ImageManager.loadSystem($gameSystem.galvVis);
	if (img.isReady()) {
		if (this.bitmap) {
			//this._destroyCachedSprite();
			this.bitmap = null;
		};
 
		// Middle Graphic
		var tempSprite = new Sprite();
		tempSprite.bitmap = ImageManager.loadSystem($gameSystem.galvVis);
		var iw = tempSprite.bitmap.width;
		var ih = tempSprite.bitmap.height;
		var color = tempSprite.bitmap.getPixel(0,0);
 
		// Background Color
		this.bitmap = new Bitmap(Graphics.boxWidth * 4,Graphics.boxHeight * 4);
		this.bitmap.fillRect(0, 0, Graphics.boxWidth * 4, Graphics.boxHeight * 4, color);
 
		// Position
		this.anchor.x = 0.5;
		this.anchor.y = 0.5;
		this.x = $gamePlayer.screenX();
		this.y = $gamePlayer.screenY();
		this.z = Galv.VR.z;
 
		// Join Bitmaps
		var cx = ((Graphics.boxWidth * 4) / 2) - (iw / 2);
		var cy = ((Graphics.boxHeight * 4) / 2) - (ih / 2);
		this.bitmap.clearRect(cx, cy, iw, ih);
		this.bitmap.blt(tempSprite.bitmap, 0, 0, iw, ih, cx, cy);
 
		this.name = $gameSystem.galvVis;
	};
};
})();
GALV_CamControlMZ:
//-----------------------------------------------------------------------------
//  Galv's Cam Control MZ
//-----------------------------------------------------------------------------
//  For: RPGMAKER MV
//  GALV_CamControlMZ.js
//-----------------------------------------------------------------------------
//  2020-11-23 - Version 1.7 - Added 'wait for camera' plugin command
//  2020-11-21 - Version 1.6 - Fixed speed not working when targeting player
//  2020-09-14 - Version 1.5 - Disabled battle zooming due to conflicts
//  2020-09-11 - Version 1.4 - Fixed bugs with save/loading data
//  2020-09-10 - Version 1.3 - Added zooming functionality
//  2020-09-07 - Version 1.2 - Minor code tweaks but no actual changes.
//  2020-09-01 - Version 1.1 - Minor code tweaks due to even position issue.
//  2020-08-26 - Version 1.0 - release
//-----------------------------------------------------------------------------
//  Terms can be found at:
//  galvs-scripts.com
//-----------------------------------------------------------------------------
 
var Imported = Imported || {};
Imported.Galv_CamControl = true;
 
var Galv = Galv || {}; // Galv's main object
Galv.CC = Galv.CC || {}; // This plugin object
Galv.CC.pluginName = "GALV_CamControlMZ";
 
//-----------------------------------------------------------------------------
/*:
 * @plugindesc (v.1.7) Allows greater control over where the game camera is focused. View documentation for plugin commands.
 * @url http://galvs-scripts.com
 * @target MZ
 * @author Galv
 *
 * @param useZoom
 * @text Enable Zoom Functions
 * @type boolean
 * @desc Make this false if you are using another zoom plugin so they don't conflict
 * @default true
 *
 * @param bZoom
 * @text Default Battle Zoom
 * @desc The zoom scale battle will begin at.
 * Default: 1 (100%)
 * @default 1
 *
 *
 * @command focusCharacter
 * @text Focus Character
 * @desc Set the camera's focus to a character
 *
 * @arg charId
 * @default 0
 * @text Character Id
 * @desc Target event id for camera focus or use 0 for player
 *
 * @arg speed
 * @default 800
 * @text Scroll Speed
 * @desc The speed in which the camera scrolls to the target (higher is slower)
 *
 *
 * @command focusXY
 * @text Focus Map Tile
 * @desc Set the camera's focus to a map tile's X,Y position
 *
 * @arg posX
 * @default 0
 * @text X Position
 * @desc The tile's X position
 *
 * @arg posY
 * @default 0
 * @text Y Position
 * @desc The tile's Y position
 *
 * @arg speed
 * @default 800
 * @text Scroll Speed
 * @desc The speed in which the camera scrolls to the target (higher is slower)
 *
 *
 * @command disable
 * @text Disable Focus
 * @desc Remove the camera focus and back to default camera on player. Do this to use Scroll Map event commands
 *
 * @command waitForCam
 * @text Wait For Camera
 * @desc Use after declaring a target to wait for the camera to reach the target before doing next event command
 *
 *
 * @command zoom
 * @text Zoom
 * @desc Zoom the center of the screen to a specified scale
 *
 * @arg zScale
 * @default 1
 * @text Zoom Scale
 * @desc 1 = 100%. 2.5 = 250%, etc.
 *
 * @arg zDuration
 * @default 60
 * @text Zoom Duration
 * @desc The amount of frames it takes to zoom into the selected scale
 *
 * @help
 *   Galv's Cam Control MZ
 * ----------------------------------------------------------------------------
 * This plugin creates a sliding movement for the camera as well as allows you
 * to set the target position of it to wherever required. (Player, event, xy)
 *
 * ----------------------------------------------------------------------------
 *   PLUGIN COMMANDS
 * ----------------------------------------------------------------------------
 *   Focus Character              // Set camera focus to a character.
 *                                // 0 for player, higher numbers for event ids
 *                                // Higher speed is slower camera
 *
 *   Focus Map Tile               // Set camera focus to an event.
 *                                // As above but instead of a character target
 *                                // you can set x,y tile position on the map
 *                                // Higher speed is slower camera
 *
 *
 *   Disable Focus                // Sets the focus on player and disables the
 *                                // sliding motion. (RPGMaker default)
 *                                // Using any command above will enable again
 *
 *   Wait For Camera              // Waits for the camera to stop moving before
 *                                // executing the next event command. Caution
 *                                // if using a moving target that never stops
 *
 *   Zoom                         // Set a zoom scale to zoom in and out
 *                                // Duration is many frames the zoom takes
 *
 * NOTES:
 * - Not recommended to use speeds that are too fast.
 * - v# to use a variable's value in these options, where # is the variable id.
 * - Zooming out does not create more map so might be best to zoom in only
 * - Zooming only zooms to the center of the screen, so if your screen is at
 *   the edge of the map, it won't zoom on the target. If you need to do this,
 *   increase the size of your map so the camera isn't at the edge.
 */
 
//-----------------------------------------------------------------------------
//  CODE STUFFS
//-----------------------------------------------------------------------------
 
// PLUGIN COMMANDS
//-----------------------------------------------------------------------------
 
PluginManager.registerCommand(Galv.CC.pluginName, "focusCharacter", (args) => {
    if ($gameMap.waitForCam && $gameMap.camIsMoving) return;
    const type = Galv.CC.getValue(args.charId) > 0 ? ["event"] : ["player"];
    const settings = type.concat(Object.values(args));
    Galv.CC.camControl(settings); // Send an array of the setting values
});
 
PluginManager.registerCommand(Galv.CC.pluginName, "focusXY", (args) => {
    if ($gameMap.waitForCam && $gameMap.camIsMoving) return;
    const settings = Object.values(args);
    Galv.CC.camControl(settings); // Send an array of the setting values
});
 
PluginManager.registerCommand(Galv.CC.pluginName, "disable", (args) => {
    Galv.CC.camControl(["disable"]); // Send an array of the setting values
});
 
PluginManager.registerCommand(Galv.CC.pluginName, "waitForCam", (args) => {
    $gameMap._interpreter.waitForCam();
});
 
// PLUGIN FUNCTIONS
//-----------------------------------------------------------------------------
 
Galv.CC.camControl = function (args) {
    let key = args[0].toLowerCase();
    let speed = 800;
    let target = $gamePlayer;
    let oldTarget = target;
 
    switch (key) {
        case "player":
            if (args[2]) speed = Galv.CC.getValue(args[2]);
            break;
        case "event":
            let eId = Galv.CC.getValue(args[1]);
            oldTarget = target;
            target = $gameMap.event(eId);
            if (args[2]) speed = Galv.CC.getValue(args[2]);
            break;
        case "disable":
            $gameMap.camTarget = $gamePlayer;
            $gameMap.camNorm = true;
            $gameMap.savedCamTarget = null;
            return;
        default:
            let px = Galv.CC.getValue(args[0]);
            let py = Galv.CC.getValue(args[1]);
            if (args[2]) speed = Galv.CC.getValue(args[2]);
            oldTarget = target;
            target = {
                x: px,
                y: py,
                _realX: px,
                _realY: py,
                screenX: Game_CharacterBase.prototype.screenX,
                screenY: function () {
                    let th = $gameMap.tileHeight();
                    return Math.round(this.scrolledY() * th + th);
                },
                scrolledX: Game_CharacterBase.prototype.scrolledX,
                scrolledY: Game_CharacterBase.prototype.scrolledY,
            };
    }
    $gameMap.camTargetSet(target, speed, oldTarget);
    $gameMap.savedCamTarget = args;
};
 
// OTHER
//-----------------------------------------------------------------------------
 
Galv.CC.getValue = function (string) {
    if (string[0].toLowerCase() === "v") {
        // Use variable
        let varId = Number(string.replace("v", ""));
        return $gameVariables.value(varId);
    } else {
        return Number(string);
    }
};
 
// GAME MAP
//-----------------------------------------------------------------------------
 
// OVERWRITE
Game_Map.prototype.displayX = function () {
    return Math.ceil(this._displayX * Galv.CC.size) / Galv.CC.size;
};
Game_Map.prototype.displayY = function () {
    return Math.ceil(this._displayY * Galv.CC.size) / Galv.CC.size;
};
 
Galv.CC.Game_Map_initialize = Game_Map.prototype.initialize;
Game_Map.prototype.initialize = function () {
    Galv.CC.size = this.tileWidth();
    this._camWidth = Graphics.width / 2;
    this._camHeight = Graphics.height / 2;
    Galv.CC.Game_Map_initialize.call(this);
};
 
Galv.CC.Game_Map_setup = Game_Map.prototype.setup;
Game_Map.prototype.setup = function (mapId) {
    this.zoom = this.zoom || new PIXI.Point(1, 1);
    if (!this.camNorm) {
        this.camTargetSet($gamePlayer, 800);
        this.savedCamTarget = ["player"];
    }
    Galv.CC.Game_Map_setup.call(this, mapId);
};
 
Game_Map.prototype.camTargetSet = function (target, speed, oldTarget) {
    this.camIsMoving = true;
    this.camTarget = target;
    this.camOldTarget = oldTarget;
    this.camNorm = false;
    this.camSpeed = speed || 800;
};
 
Galv.CC.Game_Map_updateScroll = Game_Map.prototype.updateScroll;
Game_Map.prototype.updateScroll = function () {
    if (this.camNorm) return Galv.CC.Game_Map_updateScroll.call(this);
 
    this._scrollRest = 0;
    const cw = this._camWidth;
    const ch = this._camHeight;
    const screenX = this.camTarget.screenX() * this.zoom.x;
    const screenY = this.camTarget.screenY() * this.zoom.y;
    let sx = Math.abs(screenX - cw) / this.camSpeed;
    let sy = Math.abs(screenY - ch) / this.camSpeed;
 
    if (sx < 0.01) sx = 0;
    if (sy < 0.01) sy = 0;
 
    this.camIsMoving = $gameMap.waitForCam ? sx + sy != 0 : false;
 
    if (screenY < ch) {
        this.scrollUp(sy);
    } else if (screenY > ch) {
        this.scrollDown(sy);
    }
 
    if (screenX < cw) {
        this.scrollLeft(sx);
    } else if (screenX > cw) {
        this.scrollRight(sx);
    }
};
 
//  GAME INTERPRETER
//-----------------------------------------------------------------------------
 
Game_Interpreter.prototype.waitForCam = function () {
    if ($gameMap.camIsMoving) {
        $gameMap.waitForCam = true;
        this.wait(1);
        this._index--;
    } else {
        $gameMap.waitForCam = false;
    }
    return true;
};
 
// SCENE MAP
//-----------------------------------------------------------------------------
 
Galv.CC.Scene_Map_onMapLoaded = Scene_Map.prototype.onMapLoaded;
Scene_Map.prototype.onMapLoaded = function () {
    Galv.CC.Scene_Map_onMapLoaded.call(this);
    if (!$gameMap.camNorm) {
        $gameMap.savedCamTarget = $gameMap.savedCamTarget || ["player"];
        Galv.CC.camControl($gameMap.savedCamTarget);
    }
};
 
// GAME PLAYER
//-----------------------------------------------------------------------------
 
Galv.CC.Game_Player_updateScroll = Game_Player.prototype.updateScroll;
Game_Player.prototype.updateScroll = function (lastScrolledX, lastScrolledY) {
    if ($gameMap.camNorm)
        return Galv.CC.Game_Player_updateScroll.call(
            this,
            lastScrolledX,
            lastScrolledY
        );
};
 
Galv.CC.Game_Player_center = Game_Player.prototype.center;
Game_Player.prototype.center = function (x, y) {
    if ($gameMap.camTarget == $gamePlayer || $gameMap.camNorm) {
        return Galv.CC.Game_Player_center.call(this, x, y);
    }
};
 
Game_Player.prototype.centerX = function () {
    return (
        (Graphics.width / $gameMap.tileWidth() - $gameMap.zoom.x) /
        2.0 /
        $gameMap.zoom.x
    );
};
 
Game_Player.prototype.centerY = function () {
    return (
        (Graphics.height / $gameMap.tileHeight() - 1.75 * $gameMap.zoom.y) /
        2.0 /
        $gameMap.zoom.y
    );
};
 
//-----------------------------------------------------------------------------
//  ZOOM FUNCTIONALITY
//-----------------------------------------------------------------------------
 
PluginManager.registerCommand(Galv.CC.pluginName, "zoom", (args) => {
    const scale = Galv.CC.getValue(args.zScale);
    const duration = Math.max(Galv.CC.getValue(args.zDuration), 1);
    Galv.CC.zoom(scale, duration);
});
 
Galv.CC.battleScale = Number(
    PluginManager.parameters(Galv.CC.pluginName)["bZoom"]
);
Galv.CC.useZoom =
    PluginManager.parameters(Galv.CC.pluginName)["useZoom"] == "true";
Galv.CC.halfWidth = 0;
Galv.CC.halfHeight = 0;
 
Galv.CC.zoom = function (scale, duration) {
    if (!Galv.CC.useZoom) return;
    const x = Galv.CC.halfWidth;
    const y = Galv.CC.halfHeight + 12;
    $gameScreen.startZoom(x, y, scale, duration);
};
 
Galv.CC.saveZoomData = function () {
    $gameSystem._savedZoom.x = $gameScreen._zoomX;
    $gameSystem._savedZoom.xTarget = $gameScreen._zoomXTarget;
    $gameSystem._savedZoom.y = $gameScreen._zoomY;
    $gameSystem._savedZoom.yTarget = $gameScreen._zoomYTarget;
    $gameSystem._savedZoom.scale = $gameScreen._zoomScale;
    $gameSystem._savedZoom.scaleTarget = $gameScreen._zoomScaleTarget;
    $gameSystem._savedZoom.duration = $gameScreen._zoomDuration;
};
 
//  GAME SYSTEM
//-----------------------------------------------------------------------------
 
Galv.CC.Game_System_initialize = Game_System.prototype.initialize;
Game_System.prototype.initialize = function () {
    Galv.CC.halfWidth = Math.floor(Graphics.width / 2);
    Galv.CC.halfHeight = Math.floor(Graphics.height / 2);
    this.buildSavedZoom();
    Galv.CC.Game_System_initialize.call(this);
};
 
Game_System.prototype.buildSavedZoom = function () {
    const cx = Galv.CC.halfWidth;
    const cy = Galv.CC.halfHeight;
    this._savedZoom = {
        x: cx,
        y: cy,
        xTarget: cx,
        yTarget: cy,
        scale: 1,
        scaleTarget: 1,
        duration: 0,
    };
};
 
//  GAME SCREEN
//-----------------------------------------------------------------------------
 
if (Galv.CC.useZoom) {
    // Overwrite
    Galv.CC.Game_Screen_startZoom = Game_Screen.prototype.startZoom;
    Game_Screen.prototype.startZoom = function (x, y, scale, duration) {
        if ($gameParty.inBattle())
            return Galv.CC.Game_Screen_startZoom.call(
                this,
                x,
                y,
                scale,
                duration
            ); // don't use in battle
        this._zoomXTarget = Math.min(Graphics.width, Math.max(x, 0));
        this._zoomYTarget = Math.min(Graphics.height, Math.max(y, 0));
        this._zoomScaleTarget = scale < 0 ? this._zoomScale : scale;
        this._zoomDuration = duration || 60;
    };
 
    Galv.CC.Game_Screen_clearZoom = Game_Screen.prototype.clearZoom;
    Game_Screen.prototype.clearZoom = function () {
        if ($gameSystem._savedZoom) {
            this._zoomX = $gameSystem._savedZoom.x;
            this._zoomXTarget = $gameSystem._savedZoom.xTarget;
            this._zoomY = $gameSystem._savedZoom.y;
            this._zoomYTarget = $gameSystem._savedZoom.yTarget;
            this._zoomScale = $gameSystem._savedZoom.scale;
            this._zoomScaleTarget = $gameSystem._savedZoom.scaleTarget;
            this._zoomDuration = $gameSystem._savedZoom.duration;
            return;
        }
        Galv.CC.Game_Screen_clearZoom.call(this);
    };
 
    Galv.CC.Game_Screen_onBattleStart = Game_Screen.prototype.onBattleStart;
    Game_Screen.prototype.onBattleStart = function () {
        Galv.CC.saveZoomData();
        Galv.CC.dontSave = true;
        Galv.CC.Game_Screen_onBattleStart.call(this);
    };
 
    Game_Screen.prototype.resetBattleZoom = function () {
        this._zoomX = Galv.CC.halfWidth;
        this._zoomXTarget = Galv.CC.halfWidth;
        this._zoomY = Galv.CC.halfHeight;
        this._zoomYTarget = Galv.CC.halfHeight;
        this._zoomScale = Galv.CC.battleScale;
        this._zoomScaleTarget = Galv.CC.battleScale;
        this._zoomDuration = 0;
    };
 
    //  SCENE MAP
    //-----------------------------------------------------------------------------
 
    Galv.CC.Scene_Map_start = Scene_Map.prototype.start;
    Scene_Map.prototype.start = function () {
        $gameScreen.clearZoom();
        Galv.CC.Scene_Map_start.call(this);
    };
 
    Galv.CC.Scene_Map_terminate = Scene_Map.prototype.terminate;
    Scene_Map.prototype.terminate = function () {
        if (!Galv.CC.dontSave) Galv.CC.saveZoomData();
        Galv.CC.Scene_Map_terminate.call(this);
    };
 
    //  SCENE BATTLE
    //-----------------------------------------------------------------------------
 
    Galv.CC.Scene_Battle_start = Scene_Battle.prototype.start;
    Scene_Battle.prototype.start = function () {
        $gameScreen.resetBattleZoom();
        Galv.CC.Scene_Battle_start.call(this);
    };
 
    Galv.CC.Scene_Battle_terminate = Scene_Battle.prototype.terminate;
    Scene_Battle.prototype.terminate = function () {
        Galv.CC.dontSave = false;
        Galv.CC.Scene_Battle_terminate.call(this);
    };
} // End if Galv.CC.useZoom
Нужно через $gameMap.camTarget.visRX и $gameMap.camTarget.visRY в GALV_CamControlMZ анимировать передвижение круга видимости. Вообще не могу понять как это сделать. Единственное что понятно это необходимость знать предыдущий объект следовательно oldTarget хотя скорее неправильно сделал.
Мой вк: vk.com/borisov_alexandr_5
Мой дискорд: Alexandr_5#6523
Администратор запретил публиковать записи гостям.

Совм раб. GALV_CamControlMZ и GALV_VisibilityRange 5 мес. 2 нед. назад #125511

  • Alexandr_7
  • Alexandr_7 аватар
  • Вне сайта
  • Светлый дракон
  • Сообщений: 957
  • Спасибо получено: 380
  • Проект месяца 2 местоПроект месяца 3 местоУчительВетеранПроект месяца 1 место
Пробовал так но опять ничего не выходит.
GALV_CamControlMZ
//-----------------------------------------------------------------------------
//  Galv's Cam Control MZ
//-----------------------------------------------------------------------------
//  For: RPGMAKER MV
//  GALV_CamControlMZ.js
//-----------------------------------------------------------------------------
//  2020-11-23 - Version 1.7 - Added 'wait for camera' plugin command
//  2020-11-21 - Version 1.6 - Fixed speed not working when targeting player
//  2020-09-14 - Version 1.5 - Disabled battle zooming due to conflicts
//  2020-09-11 - Version 1.4 - Fixed bugs with save/loading data
//  2020-09-10 - Version 1.3 - Added zooming functionality
//  2020-09-07 - Version 1.2 - Minor code tweaks but no actual changes.
//  2020-09-01 - Version 1.1 - Minor code tweaks due to even position issue.
//  2020-08-26 - Version 1.0 - release
//-----------------------------------------------------------------------------
//  Terms can be found at:
//  galvs-scripts.com
//-----------------------------------------------------------------------------
 
var Imported = Imported || {};
Imported.Galv_CamControl = true;
 
var Galv = Galv || {}; // Galv's main object
Galv.CC = Galv.CC || {}; // This plugin object
Galv.CC.pluginName = "GALV_CamControlMZ";
 
//-----------------------------------------------------------------------------
/*:
 * @plugindesc (v.1.7) Allows greater control over where the game camera is focused. View documentation for plugin commands.
 * @url http://galvs-scripts.com
 * @target MZ
 * @author Galv
 *
 * @param useZoom
 * @text Enable Zoom Functions
 * @type boolean
 * @desc Make this false if you are using another zoom plugin so they don't conflict
 * @default true
 *
 * @param bZoom
 * @text Default Battle Zoom
 * @desc The zoom scale battle will begin at.
 * Default: 1 (100%)
 * @default 1
 *
 *
 * @command focusCharacter
 * @text Focus Character
 * @desc Set the camera's focus to a character
 *
 * @arg charId
 * @default 0
 * @text Character Id
 * @desc Target event id for camera focus or use 0 for player
 *
 * @arg speed
 * @default 800
 * @text Scroll Speed
 * @desc The speed in which the camera scrolls to the target (higher is slower)
 *
 *
 * @command focusXY
 * @text Focus Map Tile
 * @desc Set the camera's focus to a map tile's X,Y position
 *
 * @arg posX
 * @default 0
 * @text X Position
 * @desc The tile's X position
 *
 * @arg posY
 * @default 0
 * @text Y Position
 * @desc The tile's Y position
 *
 * @arg speed
 * @default 800
 * @text Scroll Speed
 * @desc The speed in which the camera scrolls to the target (higher is slower)
 *
 *
 * @command disable
 * @text Disable Focus
 * @desc Remove the camera focus and back to default camera on player. Do this to use Scroll Map event commands
 *
 * @command waitForCam
 * @text Wait For Camera
 * @desc Use after declaring a target to wait for the camera to reach the target before doing next event command
 *
 *
 * @command zoom
 * @text Zoom
 * @desc Zoom the center of the screen to a specified scale
 *
 * @arg zScale
 * @default 1
 * @text Zoom Scale
 * @desc 1 = 100%. 2.5 = 250%, etc.
 *
 * @arg zDuration
 * @default 60
 * @text Zoom Duration
 * @desc The amount of frames it takes to zoom into the selected scale
 *
 * @help
 *   Galv's Cam Control MZ
 * ----------------------------------------------------------------------------
 * This plugin creates a sliding movement for the camera as well as allows you
 * to set the target position of it to wherever required. (Player, event, xy)
 *
 * ----------------------------------------------------------------------------
 *   PLUGIN COMMANDS
 * ----------------------------------------------------------------------------
 *   Focus Character              // Set camera focus to a character.
 *                                // 0 for player, higher numbers for event ids
 *                                // Higher speed is slower camera
 *
 *   Focus Map Tile               // Set camera focus to an event.
 *                                // As above but instead of a character target
 *                                // you can set x,y tile position on the map
 *                                // Higher speed is slower camera
 *
 *
 *   Disable Focus                // Sets the focus on player and disables the
 *                                // sliding motion. (RPGMaker default)
 *                                // Using any command above will enable again
 *
 *   Wait For Camera              // Waits for the camera to stop moving before
 *                                // executing the next event command. Caution
 *                                // if using a moving target that never stops
 *
 *   Zoom                         // Set a zoom scale to zoom in and out
 *                                // Duration is many frames the zoom takes
 *
 * NOTES:
 * - Not recommended to use speeds that are too fast.
 * - v# to use a variable's value in these options, where # is the variable id.
 * - Zooming out does not create more map so might be best to zoom in only
 * - Zooming only zooms to the center of the screen, so if your screen is at
 *   the edge of the map, it won't zoom on the target. If you need to do this,
 *   increase the size of your map so the camera isn't at the edge.
 */
 
//-----------------------------------------------------------------------------
//  CODE STUFFS
//-----------------------------------------------------------------------------
 
// PLUGIN COMMANDS
//-----------------------------------------------------------------------------
 
PluginManager.registerCommand(Galv.CC.pluginName, "focusCharacter", (args) => {
    if ($gameMap.waitForCam && $gameMap.camIsMoving) return;
    const type = Galv.CC.getValue(args.charId) > 0 ? ["event"] : ["player"];
    const settings = type.concat(Object.values(args));
    Galv.CC.camControl(settings); // Send an array of the setting values
});
 
PluginManager.registerCommand(Galv.CC.pluginName, "focusXY", (args) => {
    if ($gameMap.waitForCam && $gameMap.camIsMoving) return;
    const settings = Object.values(args);
    Galv.CC.camControl(settings); // Send an array of the setting values
});
 
PluginManager.registerCommand(Galv.CC.pluginName, "disable", (args) => {
    Galv.CC.camControl(["disable"]); // Send an array of the setting values
});
 
PluginManager.registerCommand(Galv.CC.pluginName, "waitForCam", (args) => {
    $gameMap._interpreter.waitForCam();
});
 
// PLUGIN FUNCTIONS
//-----------------------------------------------------------------------------
 
Galv.CC.camControl = function (args) {
    let key = args[0].toLowerCase();
    let speed = 800;
    let target = $gamePlayer;
    let oldTarget = target;
 
    switch (key) {
        case "player":
            if (args[2]) speed = Galv.CC.getValue(args[2]);
            break;
        case "event":
            let eId = Galv.CC.getValue(args[1]);
            oldTarget = $gameMap.camTarget || target || $gamePlayer;
            target = $gameMap.event(eId);
            if (args[2]) speed = Galv.CC.getValue(args[2]);
            break;
        case "disable":
            $gameMap.camTarget = $gamePlayer;
            $gameMap.camNorm = true;
            $gameMap.savedCamTarget = null;
            return;
        default:
            let px = Galv.CC.getValue(args[0]);
            let py = Galv.CC.getValue(args[1]);
            if (args[2]) speed = Galv.CC.getValue(args[2]);
            oldTarget = $gameMap.camTarget || target || $gamePlayer;
            target = {
                x: px,
                y: py,
                _realX: px,
                _realY: py,
                screenX: Game_CharacterBase.prototype.screenX,
                screenY: function () {
                    let th = $gameMap.tileHeight();
                    return Math.round(this.scrolledY() * th + th);
                },
                scrolledX: Game_CharacterBase.prototype.scrolledX,
                scrolledY: Game_CharacterBase.prototype.scrolledY,
            };
    }
    $gameMap.camTargetSet(target, speed, oldTarget);
    $gameMap.savedCamTarget = args;
};
 
// OTHER
//-----------------------------------------------------------------------------
 
Galv.CC.getValue = function (string) {
    if (string[0].toLowerCase() === "v") {
        // Use variable
        let varId = Number(string.replace("v", ""));
        return $gameVariables.value(varId);
    } else {
        return Number(string);
    }
};
 
// GAME MAP
//-----------------------------------------------------------------------------
 
// OVERWRITE
Game_Map.prototype.displayX = function () {
    return Math.ceil(this._displayX * Galv.CC.size) / Galv.CC.size;
};
Game_Map.prototype.displayY = function () {
    return Math.ceil(this._displayY * Galv.CC.size) / Galv.CC.size;
};
 
Galv.CC.Game_Map_initialize = Game_Map.prototype.initialize;
Game_Map.prototype.initialize = function () {
    Galv.CC.size = this.tileWidth();
    this._camWidth = Graphics.width / 2;
    this._camHeight = Graphics.height / 2;
    Galv.CC.Game_Map_initialize.call(this);
};
 
Galv.CC.Game_Map_setup = Game_Map.prototype.setup;
Game_Map.prototype.setup = function (mapId) {
    this.zoom = this.zoom || new PIXI.Point(1, 1);
    if (!this.camNorm) {
        this.camTargetSet($gamePlayer, 800, $gamePlayer);
        this.savedCamTarget = ["player"];
    }
    Galv.CC.Game_Map_setup.call(this, mapId);
};
 
Game_Map.prototype.camTargetSet = function (target, speed, oldTarget) {
    this.camIsMoving = true;
    this.camTarget = target;
    this.camOldTarget = oldTarget;
    this.camNorm = false;
    this.camSpeed = speed || 800;
    Galv.CC.posOldObj = new Point(oldTarget.screenX(), oldTarget.screenY());
};
 
Galv.CC.Game_Map_updateScroll = Game_Map.prototype.updateScroll;
Game_Map.prototype.updateScroll = function () {
    if (this.camNorm) return Galv.CC.Game_Map_updateScroll.call(this);
 
    this._scrollRest = 0;
    const cw = this._camWidth;
    const ch = this._camHeight;
    const screenX = this.camTarget.screenX() * this.zoom.x;
    const screenY = this.camTarget.screenY() * this.zoom.y;
    let sx = Math.abs(screenX - cw) / this.camSpeed;
    let sy = Math.abs(screenY - ch) / this.camSpeed;
 
    let visRX1 =
        (this.camTarget.screenX() - this.camOldTarget.screenX()) /
        this.camSpeed;
    let visRY1 =
        (this.camTarget.screenY() - this.camOldTarget.screenY()) /
        this.camSpeed;
 
    Galv.CC.posOldObj.x += visRX1;
    Galv.CC.posOldObj.y += visRY1;
 
    let visRX2 = this.camTarget.screenX() - Galv.CC.posOldObj.x;
    let visRY2 = this.camTarget.screenY() - Galv.CC.posOldObj.y;
 
    if (sx < 0.01) sx = 0;
    if (sy < 0.01) sy = 0;
 
    this.camIsMoving = $gameMap.waitForCam ? sx + sy != 0 : false;
 
    if (screenY < ch) {
        this.scrollUp(sy);
    } else if (screenY > ch) {
        this.scrollDown(sy);
    }
 
    if (screenX < cw) {
        this.scrollLeft(sx);
    } else if (screenX > cw) {
        this.scrollRight(sx);
    }
 
    this.camTarget.visRX = this.camTarget.screenX() + visRX2;
    this.camTarget.visRY = this.camTarget.screenY() + visRY2;
};
 
//  GAME INTERPRETER
//-----------------------------------------------------------------------------
 
Game_Interpreter.prototype.waitForCam = function () {
    if ($gameMap.camIsMoving) {
        $gameMap.waitForCam = true;
        this.wait(1);
        this._index--;
    } else {
        $gameMap.waitForCam = false;
    }
    return true;
};
 
// SCENE MAP
//-----------------------------------------------------------------------------
 
Galv.CC.Scene_Map_onMapLoaded = Scene_Map.prototype.onMapLoaded;
Scene_Map.prototype.onMapLoaded = function () {
    Galv.CC.Scene_Map_onMapLoaded.call(this);
    if (!$gameMap.camNorm) {
        $gameMap.savedCamTarget = $gameMap.savedCamTarget || ["player"];
        Galv.CC.camControl($gameMap.savedCamTarget);
    }
};
 
// GAME PLAYER
//-----------------------------------------------------------------------------
 
Galv.CC.Game_Player_updateScroll = Game_Player.prototype.updateScroll;
Game_Player.prototype.updateScroll = function (lastScrolledX, lastScrolledY) {
    if ($gameMap.camNorm)
        return Galv.CC.Game_Player_updateScroll.call(
            this,
            lastScrolledX,
            lastScrolledY
        );
};
 
Galv.CC.Game_Player_center = Game_Player.prototype.center;
Game_Player.prototype.center = function (x, y) {
    if ($gameMap.camTarget == $gamePlayer || $gameMap.camNorm) {
        return Galv.CC.Game_Player_center.call(this, x, y);
    }
};
 
Game_Player.prototype.centerX = function () {
    return (
        (Graphics.width / $gameMap.tileWidth() - $gameMap.zoom.x) /
        2.0 /
        $gameMap.zoom.x
    );
};
 
Game_Player.prototype.centerY = function () {
    return (
        (Graphics.height / $gameMap.tileHeight() - 1.75 * $gameMap.zoom.y) /
        2.0 /
        $gameMap.zoom.y
    );
};
 
//-----------------------------------------------------------------------------
//  ZOOM FUNCTIONALITY
//-----------------------------------------------------------------------------
 
PluginManager.registerCommand(Galv.CC.pluginName, "zoom", (args) => {
    const scale = Galv.CC.getValue(args.zScale);
    const duration = Math.max(Galv.CC.getValue(args.zDuration), 1);
    Galv.CC.zoom(scale, duration);
});
 
Galv.CC.battleScale = Number(
    PluginManager.parameters(Galv.CC.pluginName)["bZoom"]
);
Galv.CC.useZoom =
    PluginManager.parameters(Galv.CC.pluginName)["useZoom"] == "true";
Galv.CC.halfWidth = 0;
Galv.CC.halfHeight = 0;
 
Galv.CC.zoom = function (scale, duration) {
    if (!Galv.CC.useZoom) return;
    const x = Galv.CC.halfWidth;
    const y = Galv.CC.halfHeight + 12;
    $gameScreen.startZoom(x, y, scale, duration);
};
 
Galv.CC.saveZoomData = function () {
    $gameSystem._savedZoom.x = $gameScreen._zoomX;
    $gameSystem._savedZoom.xTarget = $gameScreen._zoomXTarget;
    $gameSystem._savedZoom.y = $gameScreen._zoomY;
    $gameSystem._savedZoom.yTarget = $gameScreen._zoomYTarget;
    $gameSystem._savedZoom.scale = $gameScreen._zoomScale;
    $gameSystem._savedZoom.scaleTarget = $gameScreen._zoomScaleTarget;
    $gameSystem._savedZoom.duration = $gameScreen._zoomDuration;
};
 
//  GAME SYSTEM
//-----------------------------------------------------------------------------
 
Galv.CC.Game_System_initialize = Game_System.prototype.initialize;
Game_System.prototype.initialize = function () {
    Galv.CC.halfWidth = Math.floor(Graphics.width / 2);
    Galv.CC.halfHeight = Math.floor(Graphics.height / 2);
    this.buildSavedZoom();
    Galv.CC.Game_System_initialize.call(this);
};
 
Game_System.prototype.buildSavedZoom = function () {
    const cx = Galv.CC.halfWidth;
    const cy = Galv.CC.halfHeight;
    this._savedZoom = {
        x: cx,
        y: cy,
        xTarget: cx,
        yTarget: cy,
        scale: 1,
        scaleTarget: 1,
        duration: 0,
    };
};
 
//  GAME SCREEN
//-----------------------------------------------------------------------------
 
if (Galv.CC.useZoom) {
    // Overwrite
    Galv.CC.Game_Screen_startZoom = Game_Screen.prototype.startZoom;
    Game_Screen.prototype.startZoom = function (x, y, scale, duration) {
        if ($gameParty.inBattle())
            return Galv.CC.Game_Screen_startZoom.call(
                this,
                x,
                y,
                scale,
                duration
            ); // don't use in battle
        this._zoomXTarget = Math.min(Graphics.width, Math.max(x, 0));
        this._zoomYTarget = Math.min(Graphics.height, Math.max(y, 0));
        this._zoomScaleTarget = scale < 0 ? this._zoomScale : scale;
        this._zoomDuration = duration || 60;
    };
 
    Galv.CC.Game_Screen_clearZoom = Game_Screen.prototype.clearZoom;
    Game_Screen.prototype.clearZoom = function () {
        if ($gameSystem._savedZoom) {
            this._zoomX = $gameSystem._savedZoom.x;
            this._zoomXTarget = $gameSystem._savedZoom.xTarget;
            this._zoomY = $gameSystem._savedZoom.y;
            this._zoomYTarget = $gameSystem._savedZoom.yTarget;
            this._zoomScale = $gameSystem._savedZoom.scale;
            this._zoomScaleTarget = $gameSystem._savedZoom.scaleTarget;
            this._zoomDuration = $gameSystem._savedZoom.duration;
            return;
        }
        Galv.CC.Game_Screen_clearZoom.call(this);
    };
 
    Galv.CC.Game_Screen_onBattleStart = Game_Screen.prototype.onBattleStart;
    Game_Screen.prototype.onBattleStart = function () {
        Galv.CC.saveZoomData();
        Galv.CC.dontSave = true;
        Galv.CC.Game_Screen_onBattleStart.call(this);
    };
 
    Game_Screen.prototype.resetBattleZoom = function () {
        this._zoomX = Galv.CC.halfWidth;
        this._zoomXTarget = Galv.CC.halfWidth;
        this._zoomY = Galv.CC.halfHeight;
        this._zoomYTarget = Galv.CC.halfHeight;
        this._zoomScale = Galv.CC.battleScale;
        this._zoomScaleTarget = Galv.CC.battleScale;
        this._zoomDuration = 0;
    };
 
    //  SCENE MAP
    //-----------------------------------------------------------------------------
 
    Galv.CC.Scene_Map_start = Scene_Map.prototype.start;
    Scene_Map.prototype.start = function () {
        $gameScreen.clearZoom();
        Galv.CC.Scene_Map_start.call(this);
    };
 
    Galv.CC.Scene_Map_terminate = Scene_Map.prototype.terminate;
    Scene_Map.prototype.terminate = function () {
        if (!Galv.CC.dontSave) Galv.CC.saveZoomData();
        Galv.CC.Scene_Map_terminate.call(this);
    };
 
    //  SCENE BATTLE
    //-----------------------------------------------------------------------------
 
    Galv.CC.Scene_Battle_start = Scene_Battle.prototype.start;
    Scene_Battle.prototype.start = function () {
        $gameScreen.resetBattleZoom();
        Galv.CC.Scene_Battle_start.call(this);
    };
 
    Galv.CC.Scene_Battle_terminate = Scene_Battle.prototype.terminate;
    Scene_Battle.prototype.terminate = function () {
        Galv.CC.dontSave = false;
        Galv.CC.Scene_Battle_terminate.call(this);
    };
} // End if Galv.CC.useZoom
Работает это дело неправильно. Точнее поведение области видимости черти что.
Мой вк: vk.com/borisov_alexandr_5
Мой дискорд: Alexandr_5#6523
Администратор запретил публиковать записи гостям.

Совм раб. GALV_CamControlMZ и GALV_VisibilityRange 5 мес. 2 нед. назад #125513

  • Burserandr
  • Burserandr аватар
  • Вне сайта
  • Путник
  • Сообщений: 3
  • Спасибо получено: 1
А это плагин не подойдёт
castiger.itch.io/kotc-optimized-roguelike-line-of-sight-mvmz
вместо GALV_VisibilityRange?
Администратор запретил публиковать записи гостям.

Совм раб. GALV_CamControlMZ и GALV_VisibilityRange 5 мес. 2 нед. назад #125514

  • Alexandr_7
  • Alexandr_7 аватар
  • Вне сайта
  • Светлый дракон
  • Сообщений: 957
  • Спасибо получено: 380
  • Проект месяца 2 местоПроект месяца 3 местоУчительВетеранПроект месяца 1 место
Burserandr пишет:
А это плагин не подойдёт
castiger.itch.io/kotc-optimized-roguelike-line-of-sight-mvmz
вместо GALV_VisibilityRange?
Возможно если конечно можно настроить видимость просто кругом.

Нет. Проверил. Не работает. Ну и сама область выглядит фигово.
Мой вк: vk.com/borisov_alexandr_5
Мой дискорд: Alexandr_5#6523
Последнее редактирование: 5 мес. 2 нед. назад от Alexandr_7.
Администратор запретил публиковать записи гостям.
Модераторы: NeKotZima
Время создания страницы: 0.450 секунд