Skip to content

Instantly share code, notes, and snippets.

@KageDesu
Created May 1, 2021 10:25
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save KageDesu/8d617f2c43618bf4f0856712d86e40ca to your computer and use it in GitHub Desktop.
Save KageDesu/8d617f2c43618bf4f0856712d86e40ca to your computer and use it in GitHub Desktop.
Pocket Events (MZ)
/*
* License
* Creative Commons 4.0 Attribution, Share Alike
* <https://creativecommons.org/licenses/by-sa/4.0/>
*
* Copyright (c) 2021 Vladimir Skrypnikov (Pheonix KageDesu)
* <https://http://kdworkshop.net//>
*
*/
// * CHANGELOG ===================
// v1.2 (11.02.2021)
// - Added new parameters to placement items:
// - On Cancel CE - common event called if player not placed item, just cancel placement (ESC or right mouse click)
// - Distance - Maximum allowed distance (from player) to place this item
// - Allow Y Offset? - If true, you can change object height offset by mouse scroll (when placing)
//
// v1.1 (27.10.2020)
// - Plugin parameter "Keyboard Moving?" - moving placement items by keyboard arrow keys
// - Plugin parameter "Event Drag Drop?" - events dragging system
// - Added new parameters to placement items:
// - On Placed CE - common event calls when item been placed
// - Place on Events? - place item above other map events
// - Pause Game? - pause game map when item placing
//
// v1.0 (11.09.2020)
// - Release
// ===============================
/*:
* @plugindesc (v.1.2)[BASIC] Allow you spawn Events during game with placement select
* @author Pheonix KageDesu
* @target MZ
* @url https://kdworkshop.net/plugins/pocket-events/
*
*
* @help
*
* This plugin allows player placing events from a specified 'template' map
* with placement selecting for them in the current map.
* This template map is designated with the "Templates Map" plugin setting.
*
* For create rules and setup placement events, see plugin parameter
* 'Placement Items'
*
* For place and removing events, use plugin commands.
*
*
*
* After update 1.1. you can create draggable events.
* Player can dragging those events by mouse to another place on map.
* Set plugin parameter "Event Drag Drop?" to true for activate dragging.
* Setup dragging event rules in "Draggable Templates" plugin parameter.
*
* Add comment "draggable:X" (without quotes) on event page
* where X - number of dragging template from plugin parameters
*
* This is BASIC plugin version and have some restrictions:
* - Player can place only 5 pocket events on map at same time
* - Placed events not keeps when you change maps
* - Plugin usage allowed only in Non-Commercial project
* - Only 3 draggable events on same map
*
* PRO version of plugin don't have this restrictions!
*
* Visit plugin web page for more information, also you can find Demo project.
*
* If you like my Plugins, want more and offten updates,
* please support me on Patreon!
*
* Patreon Page:
* https://www.patreon.com/KageDesu
* YouTube Channel:
* https://www.youtube.com/channel/UCA3R61ojF5vp5tGwJ1YqdgQ?
*
* You can use this plugin in your game thanks to all my Patrons!
*
* License: Creative Commons 4.0 Attribution, Share Alike, Non-Commercial
*
*
* @param TemplatesMap
* @text Templates Map
* @type number
* @min 1
* @default 1
* @desc Map ID with Placement Events templates
*
* @param GlobalExceptRegions
* @text Forbidden Regions
* @type number[]
* @min 1
* @max 255
* @desc Region ID's where placement items cannot be placed
* @default []
*
* @param PlacementsList
* @text Placement Items
* @type struct<PlacementItem>[]
* @desc Placement Items List
* @default []
*
* @param AllowArrowMove
* @text Keyboard Moving?
* @type boolean
* @default false
* @desc Allow moving placement item when place by arrow keys? (if false - only by mouse)
*
* @param AllowEventDragging
* @text Event Drag Drop?
* @type boolean
* @default true
* @desc Allow player dragging draggable (must have special comment) events?
*
* @param DraggableList
* @text Draggable Templates
* @type struct<DraggableItem>[]
* @desc Draggable Events Settings Templates List
* @default []
* @command PlacePocketEvent
* @text Place Pocket Event
* @desc Placing pocket event on map with placement select
*
* @arg placementItemId
* @text Placement Item
* @desc Placement Item Index from Placement Items plugin parameter
* @type number
* @min 1
* @default 1
*
* @arg gameItemId
* @text Consume Item
* @desc Item that's will be deleting from inventory when item is placed [optional]
* @type item
* @default 0
*
* @command RemovePocketEvent
* @text PickUp Pocket Event
* @desc PickUp (removing) pocket event from map
*
* @arg placementItemId
* @text Placement Item
* @desc Placement Item Index from Placement Items plugin parameter
* @type number
* @min 1
* @default 1
*
* @arg gameItemId
* @text Gain Item
* @desc Item that's will be added to inventory when item is removed from map [optional]
* @type item
* @default 0
*/
/*~struct~PlacementItem:
@param eventId
@text Event ID
@type number
@default 1
@min 1
@desc Event ID on Placements Templates Map
@param animationId
@text Place Animation
@type animation
@default 0
@desc Animation that will be playing after item placed
@param gridVisiblity
@text Grid
@type boolean
@default true
@desc Show map grid when this item placing?
@param sSwitch
@text Self Switch
@type combo
@option None
@option A
@option B
@option C
@option D
@default None
@desc Select which Self Switch will be turned ON when item been placed
@param exceptRegions
@text Forbidden Regions
@type number[]
@min 1
@max 255
@desc Region ID's where this item cannot be placed
@default []
@param onlyRegions
@text Allowed Only Regions
@type number[]
@min 1
@max 255
@desc Only Region ID's where this item can be placed
@default []
@param ceSpawnGood
@text On Placed CE
@type common_event
@default 0
@desc Common event called after item been placed
@param canSpawnOverEvents
@text Place On Events?
@type boolean
@default false
@desc Can be this item placed on (above) other map events?
@param ceSpawnCancel
@text On Cancel CE
@type common_event
@default 0
@desc Common event called if player not placed item, just cancel placement (ESC or right mouse click)
@param isShouldPauseMap
@text Pause Game?
@type boolean
@default false
@desc Pause game map when player placing this item?
@param maxDistance
@text Distance
@type number
@default 0
@min 0
@desc Maximum allowed distance (from player) to place this item. 0 - unlimited
@param allowMargin
@text Allow Y Offset?
@type boolean
@default false
@desc If true, you can change object height offset by mouse scroll (when placing)
@param marginStep
@parent allowMargin
@text Step
@type number
@default 1
@min 1
@desc Y coordinate changing step (in px)
@param marginMin
@parent allowMargin
@text Min Offset
@type number
@default -20
@min -100
@max -1
@desc Lower allowed height offset value
@param marginMax
@parent allowMargin
@text Max Offset
@type number
@default 20
@min 1
@max 100
@desc Upper allowed height offset value
*/
/*~struct~DraggableItem:
@param gridVisiblity
@text Grid
@type boolean
@default true
@desc Show map grid when this event dragging?
@param exceptRegions
@text Forbidden Regions
@type number[]
@min 1
@max 255
@desc Region ID's where this event cannot be placed after dragging
@default []
@param ceSpawnGood
@text On Placed CE
@type common_event
@default 0
@desc Common event called after event been placed (after dragging)
@param canSpawnOverEvents
@text Place On Events?
@type boolean
@default false
@desc Can be this event placed on (above) other map events?
@param isShouldPauseMap
@text Pause Game?
@type boolean
@default false
@desc Pause game map when player dragging this event?
@param image
@text Drag Image
@type struct<DraggableItemImage>
@default
@desc Change event graphic to this image when event is dragging, optional
*/
/*~struct~DraggableItemImage:
@param characterName
@text Graphic
@type file
@dir img/characters/
@require 1
@default
@desc Character graphic file
@param characterIndex
@text Index
@type number
@min 0
@desc Charcter Index on character graphics
@default 0
*/
var Imported = Imported || {};
Imported.PKD_EasyPlacement = true;
Imported.PKD_PocketEvents = true;
var PKD_EasyPlacement = {};
PKD_EasyPlacement.LIBS = {};
PKD_EasyPlacement.register = function (library) {
this.LIBS[library.name] = library;
};
var PKD_PocketEvents = PKD_EasyPlacement;
var KDCoreMini = {};
window.KDCoreMini = KDCoreMini;
KDCoreMini.Utils = {};
(function () {
Array.prototype.delete = function () {
var L, a, ax, what;
what = void 0;
a = arguments;
L = a.length;
ax = void 0;
while (L && this.length) {
what = a[--L];
while ((ax = this.indexOf(what)) !== -1) {
this.splice(ax, 1);
}
}
return this;
};
KDCoreMini.TimedUpdate = class TimedUpdate {
constructor(interval, method1) {
this.interval = interval;
this.method = method1;
this._timer = 0;
this._once = false;
}
update() {
if (this.interval == null) {
return;
}
this._timer++;
if (this._timer >= this.interval) {
if (this.method != null) {
this.method();
}
this._timer = 0;
if (this._once === true) {
return this.stop();
}
}
}
once() {
return this._once = true;
}
onUpdate(method1) {
this.method = method1;
}
stop() {
return this.interval = null;
}
isAlive() {
return this.interval != null;
}
};
KDCoreMini.Utils.getEventCommentValue = function (commentCode, list) {
var comment, e, item;
try {
if (list && list.length > 1) {
i = 0;
while (i < list.length) {
item = list[i++];
if (!item) {
continue;
}
if (item.code === 108) {
comment = item.parameters[0];
if (comment.contains(commentCode)) {
return comment;
}
}
}
}
} catch (error1) {
e = error1;
console.warn(e);
}
return null;
};
KDCoreMini.isMZ = function() {
return Utils.RPGMAKER_NAME.contains("MZ");
};
})();
(function(){
PKD_EasyPlacement.pluginName = "PKD_PocketEvents";
PKD_EasyPlacement.LoadPluginSettings = () => {
const params = PluginManager.parameters(PKD_EasyPlacement.pluginName);
//console.info(params);
PKD_EasyPlacement.ITEMS_MAP = parseInt(params.TemplatesMap) || 0;
PKD_EasyPlacement.PARAMS = {};
PKD_EasyPlacement.PARAMS.BAD_REGIONS = ParsePluginRegionArray(params.GlobalExceptRegions);
PKD_EasyPlacement.PARAMS.ITEMS = ParsePluginItemsList(params.PlacementsList);
PKD_EasyPlacement.PARAMS.ALLOW_ARROW_MOVE = JsonEx.parse(params.AllowArrowMove || "false");
PKD_EasyPlacement.PARAMS.ALLOW_DRAG = JsonEx.parse(params.AllowEventDragging || "true");
PKD_EasyPlacement.PARAMS.DRAG_ITEMS = ParsePluginDraggableList(params.DraggableList);
//console.info(PKD_EasyPlacement.PARAMS);
if(KDCoreMini.isMZ())
RegisterPluginCommnads();
ConfigurateClasses();
};
ParsePluginRegionArray = (arrayList) => {
let list = JsonEx.parse(arrayList);
list = list.map((e) => parseInt(e));
return list;
};
ParsePluginItemsList = (arrayList) => {
let lines = JsonEx.parse(arrayList);
let parsed = lines.map((l) => JsonEx.parse(l));
parsed.forEach(element => {
element.gridVisiblity = JsonEx.parse(element.gridVisiblity);
element.animationId = parseInt(element.animationId);
element.eventId = parseInt(element.eventId);
element.exceptRegions = ParsePluginRegionArray(element.exceptRegions);
element.onlyRegions = ParsePluginRegionArray(element.onlyRegions);
// * Проверка, так как параметры были добавлены в обновлениях
if(element.ceSpawnGood) {
element.ceSpawnGood = parseInt(element.ceSpawnGood);
} else {
element.ceSpawnGood = 0;
}
if(element.ceSpawnCancel) {
element.ceSpawnCancel = parseInt(element.ceSpawnCancel);
} else {
element.ceSpawnCancel = 0;
}
if(element.canSpawnOverEvents) {
element.canSpawnOverEvents = JsonEx.parse(element.canSpawnOverEvents);
} else {
element.canSpawnOverEvents = false;
}
if(element.isShouldPauseMap) {
element.isShouldPauseMap = JsonEx.parse(element.isShouldPauseMap);
} else {
element.isShouldPauseMap = false;
}
if(element.maxDistance) {
element.maxDistance = parseInt(element.maxDistance);
} else {
element.maxDistance = 0;
}
// * MARGINS
if(element.allowMargin) {
element.allowMargin = JsonEx.parse(element.allowMargin);
} else {
element.allowMargin = false;
}
if(element.marginStep) {
element.marginStep = parseInt(element.marginStep);
} else {
element.marginStep = 1;
}
if(element.marginMix) {
element.marginMix = parseInt(element.marginMix);
} else {
element.marginMin = -20;
}
if(element.marginMax) {
element.marginMax = parseInt(element.marginMax);
} else {
element.marginMax = 20;
}
});
parsed = [null].concat(parsed);
return parsed;
};
ParsePluginDraggableList = (arrayList) => {
if(!arrayList) return [];
let lines = JsonEx.parse(arrayList);
let parsed = lines.map((l) => JsonEx.parse(l));
parsed.forEach(element => {
element.gridVisiblity = JsonEx.parse(element.gridVisiblity);
element.exceptRegions = ParsePluginRegionArray(element.exceptRegions);
element.ceSpawnGood = parseInt(element.ceSpawnGood);
element.canSpawnOverEvents = JsonEx.parse(element.canSpawnOverEvents);
element.isShouldPauseMap = JsonEx.parse(element.isShouldPauseMap);
if(element.image) {
element.image = JsonEx.parse(element.image);
} else {
element.image = null;
}
});
parsed = [null].concat(parsed);
return parsed;
};
RegisterPluginCommnads = () => {
PluginManager.registerCommand(PKD_EasyPlacement.pluginName, 'PlacePocketEvent', args => {
try {
let pItemId = parseInt(args.placementItemId);
let gItemId = parseInt(args.gameItemId);
if(pItemId >= 0)
PKD_EPManager.Start(pItemId, gItemId);
} catch (e) {
console.warn(e);
}
});
PluginManager.registerCommand(PKD_EasyPlacement.pluginName, 'RemovePocketEvent', args => {
try {
let pItemId = parseInt(args.placementItemId);
let gItemId = parseInt(args.gameItemId);
if (pItemId >= 0)
PKD_EPManager.PickUpPlacedItem(pItemId, gItemId);
} catch (e) {
console.warn(e);
}
});
};
ConfigurateClasses = () => {
if(PKD_EasyPlacement.PARAMS.ALLOW_DRAG == false) {
Scene_Map.prototype.pProcessMapEventDragging = () => {};
}
};
})();
// Generated by CoffeeScript 2.5.1
// * MAIN
TouchInput.mapPoint = function() {
var x, y;
x = $gameMap.canvasToMapX(TouchInput.x);
y = $gameMap.canvasToMapY(TouchInput.y);
return {x, y};
};
TouchInput.mapScreenPoint = function() {
var t, th, tw, x, y;
({x, y} = TouchInput.mapPoint());
t = $gameMap.adjustX(x);
tw = $gameMap.tileWidth();
x = Math.round(t * tw + tw / 2);
t = $gameMap.adjustY(y);
th = $gameMap.tileHeight();
y = Math.round(t * th + th);
return {x, y};
};
// Generated by CoffeeScript 2.5.1
var PKD_EPManager;
PKD_EPManager = function() {};
(function() {
var _;
_ = PKD_EPManager;
_.Scene = function() {
return SceneManager._scene;
};
_.OnMapLoaded = function() {
this.isActive = false;
this.SetGridVisibility(false);
if (this.isShouldLoadEvents()) {
this.CreateEPEventsOnMap();
$gameSystem.pRestoreDraggableEventsPositions();
this.RestoreMargins();
return this.isNextMapLoaded = false;
}
};
_.OnNextMapLoaded = function() {
return this.isNextMapLoaded = true;
};
_.isShouldLoadEvents = function() {
return this.isNextMapLoaded === true;
};
_.IsGridVisible = function() {
return this.isGridVisible;
};
_.IsActive = function() {
return this.isActive === true;
};
_.IsPointIsGood = function() {
if (this.IsActive()) {
return this.IsPointIsGoodForPlacement();
} else if (this.IsEventDragStart()) {
return this.IsPointIsGoodForDrag();
} else {
return true;
}
};
_.IsPointIsGoodForPlacement = function() {
var x, y;
// * Потому что добавил движение стрелками
if ($gameTemp._epSpawned != null) {
({x, y} = $gameTemp._epSpawned);
} else {
({x, y} = TouchInput.mapPoint());
}
// * Только если нельзя спавнить на другие события (по умолчанию)
if (!$gameTemp._epSpawnModeOverEvents) {
// * > 1 because self under mouse
if ($gameMap.eventsXy(x, y).length > 1) {
return false;
}
}
if ($gamePlayer.pos(x, y)) {
return false;
}
if (Game_CharacterBase.prototype.isCollidedWithVehicles(x, y)) {
return false;
}
if (!this.CheckRegions(x, y)) {
return false;
}
return this.CheckDistance(x, y);
};
_.CheckRegions = function(x, y) {
var item, region, regionSet;
regionSet = PKD_EasyPlacement.PARAMS.BAD_REGIONS;
region = $gameMap.regionId(x, y);
if (regionSet.contains(region)) {
return false;
}
item = this.CurrentPlacementItemData();
if (item == null) {
return true;
}
if (item.onlyRegions.length > 0) {
if (!item.onlyRegions.contains(region)) {
return false;
}
} else if (item.exceptRegions.length > 0) {
if (item.exceptRegions.contains(region)) {
return false;
}
}
return true;
};
_.CheckDistance = function(x, y) {
var allowedDist, dist, item;
item = this.CurrentPlacementItemData();
if (item == null) {
return true;
}
allowedDist = item.maxDistance;
if (allowedDist > 0) {
dist = $gameMap.distance($gamePlayer.x, $gamePlayer.y, x, y);
return dist <= allowedDist;
} else {
return true;
}
};
_.SetGridVisibility = function(isGridVisible) {
this.isGridVisible = isGridVisible;
};
_.ItemData = function(pItemIndex) {
return PKD_EasyPlacement.PARAMS.ITEMS[pItemIndex];
};
_.CurrentPlacementItemData = function() {
var itemData;
if (!$gameTemp._epPlacementItemId) {
return null;
}
itemData = this.ItemData($gameTemp._epPlacementItemId);
return itemData;
};
//?VERSION
_.Start = function(pItemIndex, gItemId = 0) {};
_.Stop = function() {
//"STOP".p()
this.Scene().pEndEPMode();
this.SetGridVisibility(false);
this.isActive = false;
$gameTemp._epPlacementPartyItemId = null;
$gameTemp._epPlacementItemId = null;
};
_.PlaceItemOn = function(x, y) {
var animationId, commonEventId, evId, itemId;
evId = $gameTemp._epSpawned.eventId();
itemId = $gameTemp._epPlacementItemId;
$gameSystem.pRegisterEPItem(itemId, x, y, evId);
this.ActivatePlacedItem(itemId, evId);
this.ChangePlacementItem(-1);
animationId = this.ItemData(itemId).animationId;
if (animationId > 0) {
$gameTemp.requestAnimation([$gameTemp._epSpawned], animationId);
}
commonEventId = this.ItemData(itemId).ceSpawnGood;
if (commonEventId > 0) {
$gameTemp.reserveCommonEvent(commonEventId);
}
};
_.CallCancelCommonEvent = function() {
var commonEventId, itemId;
if ($gameTemp._epPlacementItemId == null) {
return;
}
itemId = $gameTemp._epPlacementItemId;
commonEventId = this.ItemData(itemId).ceSpawnCancel;
if (commonEventId > 0) {
$gameTemp.reserveCommonEvent(commonEventId);
}
};
_.ChangePlacementItem = function(count) {
var itemId;
itemId = $gameTemp._epPlacementPartyItemId;
if (itemId == null) {
return;
}
if ($dataItems[itemId] == null) {
return;
}
return $gameParty.gainItem($dataItems[itemId], count);
};
_.ActivatePlacedItem = function(itemId, eventId) {
var key, sSwitch;
sSwitch = this.ItemData(itemId).sSwitch;
if (sSwitch === "None" || sSwitch === "") {
return;
}
key = [$gameMap.mapId(), eventId, sSwitch];
$gameSelfSwitches.setValue(key, true);
return $gameMap.requestRefresh();
};
_.ClearSelfSwitches = function(eventId) {
var j, key, len, mapId, ref, s;
mapId = $gameMap.mapId();
ref = ['A', 'B', 'C', 'D'];
for (j = 0, len = ref.length; j < len; j++) {
s = ref[j];
key = [mapId, eventId, s];
$gameSelfSwitches.setValue(key, false);
}
return $gameMap.requestRefresh();
};
// * Удаляет по событию
_.PickUpPlacedItemByEvent = function(eventId, gItemId = 0) {
var ev;
ev = $gameMap.event(eventId);
if (ev == null) {
return;
}
if (ev.pGetEPDynamicObjId() < 0) {
return;
}
$gameSystem.pRemoveEPItem(eventId);
this.Scene().pUnSpawnEPEvent(eventId);
PKD_EPManager.ClearSelfSwitches(eventId);
if (gItemId <= 0) {
return;
}
$gameTemp._epPlacementPartyItemId = gItemId;
this.ChangePlacementItem(1);
return $gameTemp._epPlacementPartyItemId = null;
};
// * Удаляет по предмету, событие сам находит
_.PickUpPlacedItem = function(pItemIndex, gItemId) {
var db, item;
db = $gameSystem.pGetEPDB()[$gameMap.mapId()];
if (db == null) {
return;
}
item = db.find(function(i) {
return i[0] === pItemIndex;
});
if (item == null) {
return;
}
return this.PickUpPlacedItemByEvent(item[3], gItemId);
};
//?VERSION
_.CreateEPEventsOnMap = function() {};
(function() { // * EVENT DRAGGING SYSTEM
// * ==================================================================
_.IsEventDragStart = function() {
return $gameTemp.pLastDraggableEvent != null;
};
_.OnEventDragEnd = function() {
if ($gameTemp.pLastDraggableEvent == null) {
return;
}
this.Scene().pOnDragEnd();
$gameTemp.pLastDraggableEvent = null;
};
_.GetDraggableEventUnderMouse = function() {
var event;
event = null;
// * Поиск по событию
event = $gameMap.pGetDraggableEventInTouchPoint();
// * Если не найдено, поиск по спрайту события
if (event == null) {
event = this.Scene().pGetDraggableEventInTouchPoint();
}
return event;
};
_.StartEventDrag = function() {
$gameTemp.pPauseMap = false;
$gameTemp.pLastDraggableEvent = this.GetDraggableEventUnderMouse();
if ($gameTemp.pLastDraggableEvent == null) {
return;
}
this.Scene().pOnDragStart();
};
_.OnEventDragProcess = function() {}; // * EMPTY
_.IsPointIsGoodForDrag = function() {
var x, y;
({x, y} = TouchInput.mapPoint());
// * Только если нельзя спавнить на другие события (по умолчанию)
if (!$gameTemp._epSpawnModeOverEvents) {
// * Можно вернуть на своё место, поэтому доп. проверка на свою позицию
if ($gameMap.eventsXy(x, y).length > 0 && !$gameTemp.pLastDraggableEvent.pos(x, y)) {
return false;
}
}
if ($gamePlayer.pos(x, y)) {
return false;
}
if (Game_CharacterBase.prototype.isCollidedWithVehicles(x, y)) {
return false;
}
return $gameTemp.pLastDraggableEvent.pOnDragCheckRegion(x, y);
};
//?VERSION
return _.ExtractDraggableEventComment = function(list) {};
})();
})();
//Compressed by MV Plugin Builder
(function(){var a0_0x5870=['31371YcnlNp','Set\x20draggable\x20more\x20than\x203\x20events\x20allowed\x20in\x20[PRO]\x20version\x20of\x20the\x20plugin','bScEW','ExtractDraggableEventComment','RestoreMargins','15ONptqK','1351ABUVDP','157EAzIzs','draggable','rRwDG','isShouldPauseMap','mZAkr','TXNqK','25sgfDKK','zqFRj','361665etxOyJ','_epPlacementPartyItemId','JhoTv','pjDDu','ZHEJV','uJPyv','bHWpJ','pGetEPDB','Tveln','79114gFsKYW','shift','push','189877QWJuKh','KVBgZ','gridVisiblity','RSllx','2293rwHkPi','Utils','ItemData','CreateEPEventsOnMap','fSraT','IwbDs','wNaZl','JwjKC','isActive','167fMxYjQ','SetGridVisibility','pPauseMap','alert','556wwCTwp','bTRDU','canSpawnOverEvents','Rgmsw','SnbmS','3CexRvL','myLCF','length','Aifuf','split','53018ipQDPd','_draggableCount','mapId','1TXeKNC','103857DupXYf','23OcdpfJ','8TpQslt','730956rjARgP','1896553elmvfy','eventId','Scene'];var a0_0x213e=function(_0x2a206c,_0x79d098){_0x2a206c=_0x2a206c-0xfd;var _0x587059=a0_0x5870[_0x2a206c];return _0x587059;};(function(_0x26914c,_0x5a0c85){var _0x48cbbe=a0_0x213e;while(!![]){try{var _0x33b6f7=-parseInt(_0x48cbbe(0x13c))+parseInt(_0x48cbbe(0x13a))*-parseInt(_0x48cbbe(0x133))+parseInt(_0x48cbbe(0x126))+parseInt(_0x48cbbe(0x127))*parseInt(_0x48cbbe(0x12d))+-parseInt(_0x48cbbe(0x128))*-parseInt(_0x48cbbe(0x107))+parseInt(_0x48cbbe(0x129))+parseInt(_0x48cbbe(0x125))*-parseInt(_0x48cbbe(0x12a));if(_0x33b6f7===_0x5a0c85)break;else _0x26914c['push'](_0x26914c['shift']());}catch(_0x47298b){_0x26914c['push'](_0x26914c['shift']());}}}(a0_0x5870,0xbf409),function(){var _0x3d5f2f=a0_0x213e,_0x47e01b=[_0x3d5f2f(0x13b),_0x3d5f2f(0x121),_0x3d5f2f(0x134),'_draggableCount','pActivateEPMode',_0x3d5f2f(0x135),_0x3d5f2f(0x10d),'5127nIPMDV',_0x3d5f2f(0x10c),_0x3d5f2f(0x138),_0x3d5f2f(0x10b),'UGNbe',_0x3d5f2f(0x102),'209372wAiSev',_0x3d5f2f(0x10e),_0x3d5f2f(0x114),'695jOFoXp',_0x3d5f2f(0x11c),'warn','fTBmV',_0x3d5f2f(0x118),_0x3d5f2f(0x12e),'bqdTU',_0x3d5f2f(0x132),_0x3d5f2f(0x124),_0x3d5f2f(0x11d),_0x3d5f2f(0x12b),'getEventCommentValue','ygyqp',_0x3d5f2f(0x104),_0x3d5f2f(0x137),_0x3d5f2f(0x115),_0x3d5f2f(0x11f),'ZHEJV',_0x3d5f2f(0xfe),_0x3d5f2f(0x13d),_0x3d5f2f(0x109),_0x3d5f2f(0x117),_0x3d5f2f(0x12c),_0x3d5f2f(0x103),_0x3d5f2f(0x10f),_0x3d5f2f(0x113),_0x3d5f2f(0x120),'_epSpawnModeOverEvents',_0x3d5f2f(0x122),'Placement\x20more\x20than\x205\x20items\x20allowed\x20in\x20[PRO]\x20version\x20of\x20the\x20plugin','86214vJykPw'],_0x46396c=function(_0x75b2f1,_0x3142c6){_0x75b2f1=_0x75b2f1-0xcf;var _0x249f5f=_0x47e01b[_0x75b2f1];return _0x249f5f;},_0x2a50ce=_0x46396c;(function(_0x4a6f4e,_0x103b84){var _0x22b3ae=_0x3d5f2f,_0x3cf139=_0x46396c;while(!![]){try{var _0x1f6cd4=-parseInt(_0x3cf139(0xea))+parseInt(_0x3cf139(0xdb))*-parseInt(_0x3cf139(0xd7))+-parseInt(_0x3cf139(0xd2))*parseInt(_0x3cf139(0xfd))+parseInt(_0x3cf139(0xfa))+parseInt(_0x3cf139(0xef))*-parseInt(_0x3cf139(0xf4))+parseInt(_0x3cf139(0xf7))*parseInt(_0x3cf139(0xfc))+parseInt(_0x3cf139(0xec))*parseInt(_0x3cf139(0xd5));if(_0x1f6cd4===_0x103b84)break;else _0x4a6f4e[_0x22b3ae(0x106)](_0x4a6f4e[_0x22b3ae(0x105)]());}catch(_0x18b8fe){if(_0x22b3ae(0x12f)===_0x22b3ae(0x12f))_0x4a6f4e[_0x22b3ae(0x106)](_0x4a6f4e[_0x22b3ae(0x105)]());else{function _0x129182(){var _0x462b43=_0x31210d;return _0x3acc1e=_0x428385(_0x31b9ac[_0x462b43(0xee)](':')[0x1]),_0x2662cf!=null&&_0x236401>0x0&&this[_0x462b43(0xf0)]++,_0x524a63;}}}}}(_0x47e01b,0x62952),PKD_EPManager[_0x2a50ce(0xfb)]=function(){var _0x30ce01=_0x2a50ce,_0x2e445a,_0x11de17;_0x2e445a=$gameSystem[_0x30ce01(0xf9)](),_0x11de17=$gameMap[_0x30ce01(0xd6)]();if(!_0x2e445a[_0x11de17])return;return _0x2e445a[_0x11de17]=[];},PKD_EPManager['Start']=function(_0x1148f0,_0x100f13=0x0){var _0x334892=_0x3d5f2f,_0x39c1d6=_0x2a50ce,_0x3ebc18,_0x110f0c,_0x4799b9;if(_0x1148f0==null)return;if(_0x1148f0<0x0){if(_0x39c1d6(0xda)!==_0x39c1d6(0xda)){if(_0x334892(0x119)===_0x334892(0x119)){function _0x10bf6c(){var _0x30ef59=_0x334892;if(_0x30ef59(0x112)===_0x30ef59(0x112))this[_0x30ef59(0x123)]=0x0;else{function _0x4b3e4c(){var _0x559d9a=_0x30ef59,_0x2acbaa=_0x2893bc;_0x581fec=_0x152057[_0x2acbaa(0xf5)][_0x2acbaa(0xd9)](_0x2acbaa(0xf2),_0x55e493);if(_0x952e5b!=null)return _0x58c0a5=_0x20cd51(_0x5d60ad[_0x2acbaa(0xee)](':')[0x1]),_0x1eb52d!=null&&_0x576b9e>0x0&&this[_0x559d9a(0x123)]++,_0x23064f;}}}}else{function _0x8013d4(){var _0x4db348=_0x4c2eef;_0x597be2[_0x4db348(0xe3)](_0x4db348(0xeb));return;}}}else return;}_0x110f0c=this[_0x39c1d6(0xf3)](_0x1148f0);if(_0x110f0c==null){if(_0x334892(0xfd)==='igkeb'){function _0x163324(){return;}}else{if(_0x39c1d6(0xe6)===_0x39c1d6(0xe6))return;else{if(_0x334892(0x10a)===_0x334892(0x10a)){function _0x4e73bc(){var _0x4c6342=_0x39c1d6;return _0x258f53=_0x214e78(_0x5b4556[_0x4c6342(0xee)](':')[0x1]),_0x23d75a!=null&&_0x229ce2>0x0&&this[_0x4c6342(0xf0)]++,_0x2ef037;}}else{function _0x2ad7e6(){_0x19d23c=_0x495a04-0xcf;var _0x326a07=_0x4f83db[_0x3a3906];return _0x326a07;}}}}}if(_0x110f0c[_0x39c1d6(0xd8)]<=0x0){if(_0x39c1d6(0xdf)!==_0x334892(0xff)){if('tWQqE'!==_0x334892(0x100)){function _0x1c4316(){var _0x4ad741=_0x334892,_0x446654=_0x39c1d6;_0x6a7b45=_0x492802[_0x446654(0xf5)][_0x446654(0xd9)](_0x446654(0xf2),_0x4ac1e7);if(_0x53b6f0!=null)return _0x2bccc2=_0x5ca404(_0x2cc18a[_0x446654(0xee)](':')[0x1]),_0x53853b!=null&&_0x1eef32>0x0&&this[_0x4ad741(0x123)]++,_0x216d63;}}else{function _0x418c9b(){_0x2f4ac0[_0x151193(0xe3)](_0xa56085(0xeb));return;}}}else return;}_0x3ebc18=$gameSystem[_0x39c1d6(0xf9)](),_0x4799b9=$gameMap[_0x334892(0x124)]();if(_0x3ebc18[_0x4799b9]!=null&&_0x3ebc18[_0x4799b9][_0x39c1d6(0xde)]>=0x5){if(_0x39c1d6(0xd1)!==_0x39c1d6(0xd4)){window[_0x39c1d6(0xe3)](_0x39c1d6(0xeb));return;}else{if(_0x334892(0x11b)===_0x334892(0x111)){function _0x95f1e(){return null;}}else{function _0x58d640(){return;}}}}$gameTemp[_0x39c1d6(0xe1)]=_0x100f13,$gameTemp['_epPlacementItemId']=_0x1148f0,$gameTemp[_0x39c1d6(0xe9)]=_0x110f0c[_0x334892(0x11a)]===!![],$gameTemp[_0x334892(0x116)]=_0x110f0c[_0x39c1d6(0xdc)]===!![],this[_0x39c1d6(0xe4)]()[_0x39c1d6(0xf1)](_0x110f0c[_0x39c1d6(0xd8)]),this[_0x39c1d6(0xdd)](_0x110f0c[_0x39c1d6(0xe2)]),this[_0x39c1d6(0xe7)]=!![];},PKD_EPManager[_0x3d5f2f(0x130)]=function(_0x5dfdf0){var _0x57dc9f=_0x3d5f2f;if('DbTjz'!==_0x57dc9f(0x108)){var _0x3bce4d=_0x2a50ce,_0x50add5,_0x3b6c88,_0x20f2b3;if(this[_0x3bce4d(0xf0)]==null){if(_0x57dc9f(0x136)==='rRwDG'){if(_0x3bce4d(0xf6)!==_0x3bce4d(0xed))this[_0x3bce4d(0xf0)]=0x0;else{if(_0x57dc9f(0x101)!==_0x57dc9f(0x101)){function _0x4f2b97(){var _0x5218fe=_0x57dc9f;this[_0x5218fe(0x123)]=0x0;}}else{function _0x22e07a(){var _0x2d3708=_0x3bce4d;_0x34cb27[_0x2d3708(0xe3)](_0x2d3708(0xeb));return;}}}}else{function _0x2b0b24(){return;}}}if(this[_0x3bce4d(0xf0)]>=0x3){if(_0x3bce4d(0xcf)!==_0x3bce4d(0xf8))return console['warn'](_0x3bce4d(0xd3)),null;else{function _0x5ee8c1(){return null;}}}if(_0x5dfdf0==null){if(_0x3bce4d(0xe0)!==_0x3bce4d(0xe0)){function _0x3c54d0(){return;}}else return null;}try{_0x50add5=KDCoreMini[_0x3bce4d(0xf5)][_0x3bce4d(0xd9)](_0x3bce4d(0xf2),_0x5dfdf0);if(_0x50add5!=null){if(_0x3bce4d(0xe8)!==_0x3bce4d(0xe5))return _0x3b6c88=parseInt(_0x50add5[_0x3bce4d(0xee)](':')[0x1]),_0x3b6c88!=null&&_0x3b6c88>0x0&&this['_draggableCount']++,_0x3b6c88;else{if('TXNqK'===_0x57dc9f(0x139)){function _0x480916(){var _0x232755=_0x57dc9f;if(_0x232755(0x110)===_0x232755(0x11e)){function _0x3bb0ef(){_0xf5bd32['push'](_0x189c72['shift']());}}else{var _0x63487f=_0x3bce4d;this[_0x63487f(0xf0)]++;}}}else{function _0x4d025a(){return _0x3f459f=_0x4b5171,_0x4e20d2[_0x1e6a42(0xd0)](_0x126156),null;}}}}}catch(_0x2e6e42){return _0x20f2b3=_0x2e6e42,console[_0x3bce4d(0xd0)](_0x20f2b3),null;}return null;}else{function _0x82a792(){var _0x73d290=_0x4161d3,_0x1d2a54,_0x302d3e;_0x1d2a54=_0x588e6a[_0x73d290(0xf9)](),_0x302d3e=_0x4ea96f[_0x73d290(0xd6)]();if(!_0x1d2a54[_0x302d3e])return;return _0x1d2a54[_0x302d3e]=[];}}},PKD_EPManager[_0x3d5f2f(0x131)]=function(){});}());
})();
function Game_EPEvent() {
this.initialize.apply(this, arguments);
}
Game_EPEvent.prototype = Object.create(Game_Event.prototype);
Game_EPEvent.prototype.constructor = Game_EPEvent;
Game_EPEvent.prototype.initialize = function (templateEventId, eventId, epItemId) {
this._templateEventId = templateEventId;
this._epItemId = epItemId;
Game_Event.prototype.initialize.call(this, $gameMap.mapId(), eventId);
DataManager.extractMetadata(this.event());
this.setPosition(-1, -1);
};
Game_EPEvent.prototype.event = function () {
return $dataEPEventsMap.events[this._templateEventId];
};
Game_EPEvent.prototype.pGetEPDynamicObjId = function () {
return 1; // * JUST FOR CONDITIONS
};
// Generated by CoffeeScript 2.5.1
(function() {
var Sprite_GridCell;
Sprite_GridCell = class Sprite_GridCell extends Sprite {
constructor() {
super(new Bitmap($gameMap.tileWidth(), $gameMap.tileHeight()));
this.anchor.x = 0.5;
this.anchor.y = 1;
this.z = 1;
this.maxOpacity = 80;
this.minOpacity = 40;
this.opacity = this.maxOpacity;
this.setNormalColor();
this.updateOpacityChange = this.updateOpacityDown;
this.colorChangeThread = new KDCoreMini.TimedUpdate(2, this._colorChange.bind(this));
this._colorChange();
}
setNormalColor() {
return this.bitmap.fillAll('rgba(255, 255, 255, 1)');
}
setForbiddenColor() {
return this.bitmap.fillAll('rgba(255, 0, 0, 1)');
}
update() {
super.update();
if (this.visible === false) {
return;
}
this.updateOpacityChange();
return this.colorChangeThread.update();
}
_colorChange() {
if (!this.visible) {
return;
}
if (PKD_EPManager.IsPointIsGood()) {
return this.setNormalColor();
} else {
return this.setForbiddenColor();
}
}
updateOpacityChange() {} // * EMPTPY
updateOpacityDown() {
this.opacity -= 3;
if (this.opacity <= this.minOpacity) {
return this.updateOpacityChange = this.updateOpacityUp;
}
}
updateOpacityUp() {
this.opacity += 3;
if (this.opacity >= this.maxOpacity) {
return this.updateOpacityChange = this.updateOpacityDown;
}
}
};
PKD_EasyPlacement.register(Sprite_GridCell);
})();
(function(){
DataManager.pLoadEPEventData = function () {
var mapId = PKD_EasyPlacement.ITEMS_MAP;
if (mapId > 0) {
var filename = 'Map%1.json'.format(mapId.padZero(3));
this.loadDataFile('$dataEPEventsMap', filename);
} else {
console.warn("EasyPlacement.js: You didn't set a map ID for placement events!");
window.alert("EasyPlacement.js: You didn't set a map ID for placement events!");
}
};
//@[ALIAS]
var _alias_DataManager_loadDatabase = DataManager.loadDatabase;
DataManager.loadDatabase = function () {
PKD_EasyPlacement.LoadPluginSettings();
DataManager.pLoadEPEventData();
_alias_DataManager_loadDatabase.call(this);
};
})();
// Generated by CoffeeScript 2.5.1
//╒═════════════════════════════════════════════════════════════════════════╛
// ■ Game_CharacterBase.coffee
//╒═════════════════════════════════════════════════════════════════════════╛
//---------------------------------------------------------------------------
(function() {
var _;
//@[DEFINES]
_ = Game_CharacterBase.prototype;
// * DUMMY
_.pGetEPDynamicObjId = function() {
return -1;
};
// * DUMMY
_.epIsDraggable = function() {
return false;
};
})();
// ■ END Game_CharacterBase.coffee
//---------------------------------------------------------------------------
// Generated by CoffeeScript 2.5.1
//╒═════════════════════════════════════════════════════════════════════════╛
// ■ Game_Event.coffee
//╒═════════════════════════════════════════════════════════════════════════╛
//---------------------------------------------------------------------------
(function() {
var ALIAS__clearPageSettings, ALIAS__setupPageSettings, _;
//@[DEFINES]
_ = Game_Event.prototype;
//@[ALIAS]
ALIAS__setupPageSettings = _.setupPageSettings;
_.setupPageSettings = function() {
var e;
ALIAS__setupPageSettings.call(this);
try {
if (PKD_EasyPlacement.PARAMS.ALLOW_DRAG === true) {
this._epDragDataId = PKD_EPManager.ExtractDraggableEventComment(this.list());
this._epIsDraggableEvent = (this._epDragDataId != null) && this._epDragDataId > 0;
if (this._epIsDraggableEvent === true) {
return this.epSetupDragEvent();
}
} else {
return this._epIsDraggableEvent = false;
}
} catch (error) {
e = error;
this._epIsDraggableEvent = false;
return console.warn(e);
}
};
//@[ALIAS]
ALIAS__clearPageSettings = _.clearPageSettings;
_.clearPageSettings = function() {
ALIAS__clearPageSettings.call(this);
return this._epIsDraggableEvent = false;
};
// * Прочие настройки перемещения из параметров плагина
_.epSetupDragEvent = function() {
var e;
try {
this._epDragData = PKD_EasyPlacement.PARAMS.DRAG_ITEMS[this._epDragDataId];
this._epIsDraggableEvent = this._epDragData != null;
} catch (error) {
e = error;
console.warn(e);
}
};
_.epIsDraggable = function() {
return this._epIsDraggableEvent === true;
};
// * Параметры перемещения (сетка, регион, смена картинки, перемещение на другие события)
_.epGetDragSettings = function() {
return {};
};
// * Когда игрок начал двигать событие
_.pOnDragStart = function() {
var e;
$gameTemp._epSpawnModeOverEvents = this._epDragData.canSpawnOverEvents === true;
PKD_EPManager.SetGridVisibility(this._epDragData.gridVisiblity);
$gameTemp.pPauseMap = true;
this._opacity = 200;
try {
if (this._epDragData.image == null) {
return;
}
this._pStoredImageData = {};
this._pStoredImageData.characterIndex = this._characterIndex;
this._pStoredImageData.characterName = this._characterName;
this.pOnDragImageChange(this._epDragData.image);
} catch (error) {
e = error;
console.warn(e);
}
};
_.pOnDragImageChange = function(imageData) {
if (imageData == null) {
return;
}
if (imageData.characterName == null) {
return;
}
if (imageData.characterName === "") {
return;
}
return this.setImage(imageData.characterName, imageData.characterIndex);
};
// * Когда игрок отпустил мышку (закончить перемещение)
_.pOnDragEnd = function() {
var x, y;
PKD_EPManager.SetGridVisibility(false);
this._opacity = 255;
this.pOnDragImageChange(this._pStoredImageData);
this._pStoredImageData = null;
if (PKD_EPManager.IsPointIsGoodForDrag()) {
({x, y} = TouchInput.mapPoint());
this.locate(x, y);
$gameSystem.pSaveDraggableEventPosition(this.eventId(), this.x, this.y);
if (this._epDragData.ceSpawnGood > 0) {
$gameTemp.reserveCommonEvent(this._epDragData.ceSpawnGood);
}
} else {
SoundManager.playBuzzer();
}
// * just return to own place
$gameTemp._epSpawnModeOverEvents = false;
};
_.pOnDragCheckRegion = function(x, y) {
var region;
region = $gameMap.regionId(x, y);
return !this._epDragData.exceptRegions.contains(region);
};
_.pIsFacingPlayer = function() {
var dir, x, y;
({x, y} = $gamePlayer);
dir = $gamePlayer.direction();
switch (dir) {
case 8:
y -= 1;
break;
case 6:
x += 1;
break;
case 4:
x -= 1;
break;
default:
y += 1;
}
return this.pos(x, y);
};
_.setEPMargins = function(epMX, epMY) {
this.epMX = epMX;
this.epMY = epMY;
};
// * X пока не учитывается
_.pOnMargin = function(x, y) {
var _prevMY, itemSettings, step;
itemSettings = PKD_EPManager.CurrentPlacementItemData();
if (itemSettings == null) {
return;
}
if (!itemSettings.allowMargin) {
return;
}
if (this.epMY == null) {
this.epMY = 0;
}
step = itemSettings.marginStep;
_prevMY = this.epMY;
this.epMY += y * step;
if (this.epMY <= itemSettings.marginMin || this.epMY >= itemSettings.marginMax) {
this.epMY = _prevMY;
} else {
$gameSystem.pSaveEPMargins(this.eventId(), 0, this.epMY);
}
};
})();
// ■ END Game_Event.coffee
//---------------------------------------------------------------------------
// Generated by CoffeeScript 2.5.1
//╒═════════════════════════════════════════════════════════════════════════╛
// ■ Game_Map.coffee
//╒═════════════════════════════════════════════════════════════════════════╛
//---------------------------------------------------------------------------
(function() {
var ALIAS__setup, ALIAS__update, _;
//@[DEFINES]
_ = Game_Map.prototype;
//@[ALIAS]
ALIAS__setup = _.setup;
_.setup = function(mapId) {
ALIAS__setup.call(this, mapId);
return PKD_EPManager.OnNextMapLoaded();
};
_.pGetDraggableEventInTouchPoint = function() {
var events, x, y;
events = this.pGetAllDraggableEvents();
if (events.length > 0) {
({x, y} = TouchInput.mapPoint());
return events.find(function(e) {
return e.pos(x, y);
});
}
//return @eventsXy(x, y).find (e) -> e.epIsDraggable()
return null;
};
_.pGetAllDraggableEvents = function() {
return this.events().filter(function(e) {
return e.epIsDraggable();
});
};
//@[ALIAS]
ALIAS__update = _.update;
_.update = function(sceneActive) {
if ((PKD_EPManager.IsEventDragStart() || PKD_EPManager.IsActive()) && $gameTemp.pPauseMap === true) {
} else {
return ALIAS__update.call(this, sceneActive);
}
};
})();
// ■ END Game_Map.coffee
//---------------------------------------------------------------------------
// Generated by CoffeeScript 2.5.1
//╒═════════════════════════════════════════════════════════════════════════╛
// ■ Game_Player.coffee
//╒═════════════════════════════════════════════════════════════════════════╛
//---------------------------------------------------------------------------
(function() {
var ALIAS__canMove, _;
//@[DEFINES]
_ = Game_Player.prototype;
//@[ALIAS]
ALIAS__canMove = _.canMove;
_.canMove = function() {
if (PKD_EasyPlacement.PARAMS.ALLOW_ARROW_MOVE === true && PKD_EPManager.IsActive()) {
return false;
} else if (PKD_EPManager.IsEventDragStart()) {
return false;
} else {
return ALIAS__canMove.call(this, ...arguments);
}
};
})();
// ■ END Game_Player.coffee
//---------------------------------------------------------------------------
// Generated by CoffeeScript 2.5.1
//╒═════════════════════════════════════════════════════════════════════════╛
// ■ Game_System.coffee
//╒═════════════════════════════════════════════════════════════════════════╛
//---------------------------------------------------------------------------
(function() {
var ALIAS__initialize, _;
//@[DEFINES]
_ = Game_System.prototype;
//@[ALIAS]
ALIAS__initialize = _.initialize;
_.initialize = function() {
ALIAS__initialize.call(this);
this.pGetEPDB(); // * Pocket Events storage
this.pGetEPDB2(); // * Draggable positions
return this.pGetEPDB3(); // * Смещение
};
_.pGetEPDB = function() {
if (this.pEPDB == null) {
this.pEPDB = {};
}
return this.pEPDB;
};
_.pGetEPDB2 = function() {
if (this.pEPDB2 == null) {
this.pEPDB2 = {};
}
return this.pEPDB2;
};
_.pGetEPDB3 = function() {
if (this.pEPDB3 == null) {
this.pEPDB3 = {};
}
return this.pEPDB3;
};
_.pRegisterEPItem = function(itemId, x, y, eventId) {
var db, mapId;
// * Регестрирует созданный
db = this.pGetEPDB();
mapId = $gameMap.mapId();
if (db[mapId] == null) {
db[mapId] = [];
}
db[mapId].push([itemId, x, y, eventId]);
};
//"REGISTER".p(itemId)
_.pRemoveEPItem = function(eventId) {
var db, i, item, itemToDelete, len, mapId, ref;
// * Удаляет созданные
db = this.pGetEPDB();
mapId = $gameMap.mapId();
if (db[mapId] == null) {
return;
}
itemToDelete = null;
ref = db[mapId];
for (i = 0, len = ref.length; i < len; i++) {
item = ref[i];
//if item[1] is x && item[2] is y
// itemToDelete = item
if (item[3] === eventId) {
itemToDelete = item;
}
}
if (itemToDelete == null) {
return;
}
db[mapId].delete(itemToDelete);
};
_.pSaveDraggableEventPosition = function(eventId, x, y) {
var db, mapId;
// * Сохраняет позицию
db = this.pGetEPDB2();
mapId = $gameMap.mapId();
if (db[mapId] == null) {
db[mapId] = [];
}
db[mapId].push([eventId, x, y]);
};
_.pRestoreDraggableEventsPositions = function() {
var db, i, len, mapId, position, ref;
// * Возвращает позицию
db = this.pGetEPDB2();
mapId = $gameMap.mapId();
if (db[mapId] == null) {
return;
}
ref = db[mapId];
for (i = 0, len = ref.length; i < len; i++) {
position = ref[i];
if (position == null) {
continue;
}
$gameMap.event(position[0]).setPosition(position[1], position[2]);
}
};
_.pSaveEPMargins = function(eventId, x, y) {
var db, mapId;
db = this.pGetEPDB3();
mapId = $gameMap.mapId();
if (db[mapId] == null) {
db[mapId] = [];
}
db[mapId].push([eventId, x, y]);
};
_.pRestoreEPMargins = function(eventId) {
var db, i, len, mapId, margin, ref;
db = this.pGetEPDB3();
mapId = $gameMap.mapId();
if (db[mapId] == null) {
return null;
}
ref = db[mapId];
for (i = 0, len = ref.length; i < len; i++) {
margin = ref[i];
if (margin == null) {
continue;
}
$gameMap.event(margin[0]).setEPMargins(margin[1], margin[2]);
}
};
})();
// ■ END Game_System.coffee
//---------------------------------------------------------------------------
// Generated by CoffeeScript 2.5.1
//╒═════════════════════════════════════════════════════════════════════════╛
// ■ Scene_Map.coffee
//╒═════════════════════════════════════════════════════════════════════════╛
//---------------------------------------------------------------------------
(function() {
var ALIAS__isMenuEnabled, ALIAS__onMapLoaded, ALIAS__processMapTouch, ALIAS__update, ALIAS__updateDestination, _;
//@[DEFINES]
_ = Scene_Map.prototype;
// * evId - event to spawn and move
_.pActivateEPMode = function(evId) {
this._pInEPMode = true;
this._pIsSetupOk = false; // * User place Event?
return $gameTemp._epSpawned = this.pSpawnEPEvent(evId, 0, 0, $gameMap._events.length);
};
_.pEndEPMode = function() {
if (this._pIsSetupOk === false) {
PKD_EPManager.CallCancelCommonEvent();
this.pUnSpawnEPEvent($gameTemp._epSpawned._eventId);
}
$gameTemp._epSpawned = null;
return this._pInEPMode = false;
};
_.pIsEPMode = function() {
return this._pInEPMode === true;
};
_.pSpawnEPEvent = function(evId, x, y, newEvId) {
var ev;
ev = new Game_EPEvent(evId, newEvId, $gameTemp._epPlacementItemId);
$gameMap._events[newEvId] = ev;
this._spriteset.pAddNewPlacementEvent(ev._eventId);
ev.setPosition(x, y);
return ev;
};
_.pUnSpawnEPEvent = function(evId) {
var event;
this._spriteset.pRemovePlacementEvent(evId);
PKD_EPManager.ClearSelfSwitches(evId);
event = $gameMap.event(evId);
$gameMap._events[evId] = null;
$gameMap.requestRefresh();
};
//@[ALIAS]
ALIAS__onMapLoaded = _.onMapLoaded;
_.onMapLoaded = function() {
ALIAS__onMapLoaded.call(this);
return PKD_EPManager.OnMapLoaded();
};
//@[ALIAS]
ALIAS__updateDestination = _.updateDestination;
_.updateDestination = function() {
if (this.pIsEPMode()) {
$gamePlayer.turnTowardCharacter(TouchInput.mapPoint());
} else {
return ALIAS__updateDestination.call(this);
}
};
//@[ALIAS]
ALIAS__isMenuEnabled = _.isMenuEnabled;
_.isMenuEnabled = function() {
if (this.pIsEPMode() || PKD_EPManager.IsEventDragStart()) {
return false;
} else {
return ALIAS__isMenuEnabled.call(this);
}
};
//@[ALIAS]
ALIAS__update = _.update;
_.update = function() {
ALIAS__update.call(this);
if (this.pIsEPMode()) {
this.pUpdateEPArrowMove();
this.pUpdateEPCommon();
this.pUpdateMarginsScroll();
} else {
if (PKD_EPManager.IsEventDragStart()) {
this.pCheckDragStop();
}
}
};
//@[ALIAS]
ALIAS__processMapTouch = _.processMapTouch;
_.processMapTouch = function() {
if (this.pIsEPMode()) { // * В режиме placement нельзя draggable events movement!
return ALIAS__processMapTouch.call(this);
} else {
this.pProcessMapEventDragging();
if (!PKD_EPManager.IsEventDragStart()) {
return ALIAS__processMapTouch.call(this);
}
}
};
//?DYNAMIC
_.pProcessMapEventDragging = function() {
var draggable;
if ($gameMessage.isBusy()) {
return;
}
draggable = PKD_EPManager.GetDraggableEventUnderMouse();
if (draggable == null) {
return;
}
if (draggable.pIsFacingPlayer()) {
if (TouchInput.isLongPressed()) {
this.pCheckDraggableEventUnderMouse();
}
} else {
if (TouchInput.isPressed()) {
this.pCheckDraggableEventUnderMouse();
}
}
};
_.pCheckDraggableEventUnderMouse = function() {
if (!PKD_EPManager.IsEventDragStart()) {
PKD_EPManager.StartEventDrag(); // * Может не выполниться, если нет под курсором события
}
};
_.pCheckDragStop = function() {
if (TouchInput.isReleased()) {
PKD_EPManager.OnEventDragEnd();
}
};
_.pGetDraggableEventInTouchPoint = function() {
return this._spriteset.pGetDraggableEventInTouchPoint();
};
_.pOnDragStart = function() {
if ($gameTemp.pLastDraggableEvent == null) {
return;
}
$gameTemp.clearDestination();
this._spriteset.pSetDraggableEventState($gameTemp.pLastDraggableEvent, true);
$gameTemp.pLastDraggableEvent.pOnDragStart();
};
_.pOnDragEnd = function() {
if ($gameTemp.pLastDraggableEvent == null) {
return;
}
$gameTemp.pLastDraggableEvent.pOnDragEnd();
this._spriteset.pSetDraggableEventState($gameTemp.pLastDraggableEvent, false);
};
_.pUpdateEPCommon = function() {
var x, y;
if (this.isMenuCalled()) {
return PKD_EPManager.Stop();
} else {
if (!this.__pLTIX || (this.__pLTIX !== TouchInput.x || this.__pLTIY !== TouchInput.y)) {
({x, y} = TouchInput.mapPoint());
$gameTemp._epSpawned.setPosition(x, y);
this.__pLTIX = null; // * Достаточно сбросить X
} else {
}
// * NO MOVING BY MOUSE (arrow key moving before)
if (TouchInput.isTriggered() || Input.isTriggered('ok')) {
if (PKD_EPManager.IsPointIsGood()) {
this.pPlaceEPItemOnSpot(x, y);
return PKD_EPManager.Stop();
} else {
return SoundManager.playBuzzer();
}
}
}
};
_.pUpdateMarginsScroll = function() {
var threshold;
threshold = 20;
if (TouchInput.wheelY >= threshold) {
$gameTemp._epSpawned.pOnMargin(0, -1);
} else if (TouchInput.wheelY <= -threshold) {
$gameTemp._epSpawned.pOnMargin(0, +1);
}
};
_.pUpdateEPArrowMove = function() {
if (!PKD_EasyPlacement.PARAMS.ALLOW_ARROW_MOVE) {
return;
}
if ($gameTemp._epSpawned == null) {
return;
}
if (Input.isRepeated('left')) {
this.pMoveSpawnedByArrowKey(-1, 0);
}
if (Input.isRepeated('right')) {
this.pMoveSpawnedByArrowKey(1, 0);
}
if (Input.isRepeated('down')) {
this.pMoveSpawnedByArrowKey(0, 1);
}
if (Input.isRepeated('up')) {
this.pMoveSpawnedByArrowKey(0, -1);
}
};
_.pSetMouseLockWhenArrowMove = function() {
var x, y;
({x, y} = TouchInput);
this.__pLTIX = x;
return this.__pLTIY = y;
};
_.pMoveSpawnedByArrowKey = function(dx, dy) {
var x, y;
this.pSetMouseLockWhenArrowMove();
({x, y} = $gameTemp._epSpawned);
$gameTemp._epSpawned.setPosition(x + dx, y + dy);
};
_.pPlaceEPItemOnSpot = function(x, y) {
PKD_EPManager.PlaceItemOn(x, y);
return this._pIsSetupOk = true;
};
})();
// ■ END Scene_Map.coffee
//---------------------------------------------------------------------------
// Generated by CoffeeScript 2.5.1
//╒═════════════════════════════════════════════════════════════════════════╛
// ■ Sprite_Character.coffee
//╒═════════════════════════════════════════════════════════════════════════╛
//---------------------------------------------------------------------------
(function() {
var ALIAS__initMembers, ALIAS__updatePosition, _;
//@[DEFINES]
_ = Sprite_Character.prototype;
//@[ALIAS]
ALIAS__initMembers = _.initMembers;
_.initMembers = function() {
ALIAS__initMembers.call(this);
return this.p_dragMode = false;
};
_.pSetDragMode = function(p_dragMode) {
this.p_dragMode = p_dragMode;
};
//@[ALIAS]
ALIAS__updatePosition = _.updatePosition;
_.updatePosition = function() {
if (this.p_dragMode === true) {
this.x = TouchInput.x;
this.y = TouchInput.y;
this.z = this._character.screenZ();
} else {
ALIAS__updatePosition.call(this);
}
// * Смещение по Y, по X не учитываем пока что
if (this._character.epMY != null) {
this.y += this._character.epMY;
}
};
})();
// ■ END Sprite_Character.coffee
//---------------------------------------------------------------------------
// Generated by CoffeeScript 2.5.1
//╒═════════════════════════════════════════════════════════════════════════╛
// ■ Spriteset_Map.coffee
//╒═════════════════════════════════════════════════════════════════════════╛
//---------------------------------------------------------------------------
(function() {
var ALIAS__createTilemap, ALIAS__update, _;
//@[DEFINES]
_ = Spriteset_Map.prototype;
//@[ALIAS]
ALIAS__createTilemap = _.createTilemap;
_.createTilemap = function() {
ALIAS__createTilemap.call(this);
return this.pCreateEPGrid();
};
//@[ALIAS]
ALIAS__update = _.update;
_.update = function() {
ALIAS__update.call(this);
return this.pUpdateEPGridLayer();
};
_.pCreateEPGrid = function() {
var bitmap;
this._pEPGridLayer = new Sprite();
this._pEPGridLayer.opacity = 50;
bitmap = new Bitmap($gameMap.width() * $gameMap.tileWidth(), $gameMap.height() * $gameMap.tileHeight());
this._pEPGridLayer.bitmap = bitmap;
bitmap.addLoadListener(this.pDrawEPGrid.bind(this));
this._pEPGridLayer.z = 1;
this._tilemap.addChild(this._pEPGridLayer);
return this.pCreateEPHoverCell();
};
_.pCreateEPHoverCell = function() {
this._pEPCell = new PKD_EasyPlacement.LIBS.Sprite_GridCell();
return this._tilemap.addChild(this._pEPCell);
};
_.pDrawEPGrid = function() {
var drawLineHor, drawLineVert, i, j, k, l, ref, ref1, results;
drawLineVert = function(b, i) {
return b.fillRect(0, i * $gameMap.tileWidth(), b.width, 1, 'rgba(0, 0, 0, 1)');
};
drawLineHor = function(b, i) {
return b.fillRect(i * $gameMap.tileHeight(), 0, 1, b.height, 'rgba(0, 0, 0, 1)');
};
for (i = k = 0, ref = $gameMap.height(); (0 <= ref ? k < ref : k > ref); i = 0 <= ref ? ++k : --k) {
drawLineVert(this._pEPGridLayer.bitmap, i);
}
results = [];
for (j = l = 0, ref1 = $gameMap.width(); (0 <= ref1 ? l < ref1 : l > ref1); j = 0 <= ref1 ? ++l : --l) {
results.push(drawLineHor(this._pEPGridLayer.bitmap, j));
}
return results;
};
_.pUpdateEPGridLayer = function() {
var screenTouchPoint, screenX, screenY, th, tw, tw2;
this._pEPGridLayer.visible = PKD_EPManager.IsGridVisible();
this._pEPCell.visible = PKD_EPManager.IsGridVisible();
if (!this._pEPGridLayer.visible) {
return;
}
if (this._pEPGridLayer == null) {
return;
}
tw = $gameMap.tileWidth();
tw2 = tw / 2;
th = $gameMap.tileHeight();
screenX = Math.round($gameMap.adjustX(-0.5) * tw + tw2);
screenY = Math.round($gameMap.adjustY(-1) * th + th);
this._pEPGridLayer.move(screenX, screenY);
// * Так как добавлена возможность двигать стрелами, то берём координаты $gameTemp._epSpawned
if (PKD_EPManager.IsActive()) {
screenTouchPoint = $gameTemp._epSpawned;
if (screenTouchPoint == null) {
return;
}
this._pEPCell.move(screenTouchPoint.screenX(), screenTouchPoint.screenY());
} else {
screenTouchPoint = TouchInput.mapScreenPoint();
this._pEPCell.move(screenTouchPoint.x, screenTouchPoint.y);
}
};
_.pAddNewPlacementEvent = function(id) {
var event, spr;
event = $gameMap._events[id];
spr = new Sprite_Character(event);
this._characterSprites.push(spr);
this._tilemap.addChild(spr);
spr.update();
};
_.pRemovePlacementEvent = function(id) {
var spr;
spr = this._characterSprites.find(function(i) {
return (i._character != null) && i._character.pGetEPDynamicObjId() >= 0 && i._character._eventId === id;
});
if (spr == null) {
return;
}
spr.visible = false;
this._characterSprites.delete(spr);
//for animSpr in spr._animationSprites
// @_tilemap.removeChild animSpr
this._tilemap.removeChild(spr);
};
_.pGetDraggableEventInTouchPoint = function() {
var events, k, len, s, sprites;
events = $gameMap.pGetAllDraggableEvents();
if (events.length > 0) {
sprites = events.map((e) => {
return this.findTargetSprite(e);
});
for (k = 0, len = sprites.length; k < len; k++) {
s = sprites[k];
if (this.pTouchInEvDragRect(s)) {
return s._character;
}
}
}
return null;
};
_.pTouchInEvDragRect = function(item) {
var bRealX, bRealY, x, y;
({x, y} = TouchInput);
bRealX = item.x - item._frame.width / 2;
bRealY = item.y - item._frame.height;
return x >= bRealX && y >= bRealY && x < bRealX + item.width && y < item.height + bRealY;
};
_.pSetDraggableEventState = function(event, state) {
var sprite;
sprite = this.findTargetSprite(event);
sprite.pSetDragMode(state);
};
})();
// ■ END Spriteset_Map.coffee
//---------------------------------------------------------------------------
//Plugin PKD_PocketEvents automatic build by PKD PluginBuilder 1.9.2 11.02.2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment