| 赞 | 58 |
| VIP | |
| 好人卡 | |
| 积分 | 12 |
| 经验 | |
| 最后登录 | 2023-5-29 |
| 在线时间 | 1017 小时 |
- 梦石
- 0
- 星屑
- 1232
- 在线时间
- 1017 小时
- 注册时间
- 2011-4-30
- 回帖
- 1464
|
加入我们,或者,欢迎回来。
您需要 登录 才可以下载或查看,没有账号?注册会员
×
本帖最后由 汪汪 于 2015-12-3 21:45 编辑
单纯保存位置方向
- //=============================================================================
- // baocun_event_xyd.js
- //=============================================================================
- /*:
- * @plugindesc 保存事件位置朝向
- * @author wangwang
- *
- * @param baocunbl
- * @desc 默认保存地图事件的变量号
- * @default 1
- *
- * @help
- * 大概没用........
- * 保存事件的位置 和 朝向,
- *
- *
- */
- (function() {
- //====================修改默认部分=================
- //对 默认的 $gameMap.prototype.setupEvents 安装事件进行修改
- Game_Map.prototype.setupEvents = function() {
- this._events = [];
- for (var i = 0; i < $dataMap.events.length; i++) {
- if ($dataMap.events[i]) {
- this._events[i] = new Game_Event(this._mapId, i);
- }
- }
- this.ww_loadEvents()//添加部分,读取事件记录
- this._commonEvents = this.parallelCommonEvents().map(function(commonEvent) {
- return new Game_CommonEvent(commonEvent.id);
- });
- this.refreshTileEvents();
- };
- //转换场景时的处理(添加保存事件)
- Scene_Map.prototype.stop = function() {
- this.ww_saveEventsXyd()//添加部分,保存事件
-
- Scene_Base.prototype.stop.call(this);
- $gamePlayer.straighten();
- this._mapNameWindow.close();
- if (this.needsSlowFadeOut()) {
- this.startFadeOut(this.slowFadeSpeed(), false);
- } else if (SceneManager.isNextScene(Scene_Map)) {
- this.fadeOutForTransfer();
- } else if (SceneManager.isNextScene(Scene_Battle)) {
- this.launchBattle();
- }
- };
- //===================================================================
- //====================添加部分====================
- //读取事件记录
- Game_Map.prototype.ww_loadEvents = function() {
- //读取变量
- var blid = parseInt(PluginManager.parameters("baocun_event_xyd")["baocunbl"], 10);
- var value = $gameVariables._data[blid]
- //如果存在
- if (!!value){
- //如果这个地图有保存
- if (!!value[this._mapId]){
- //循环所有地图内的事件记录
- for (var i=0; i < value[this._mapId].length ;i++){
- //读取一条事件记录的内容
- var nr = value[this._mapId][i]
- //如果存在内容
- if (!!nr){
- //如果 事件x和y 是数字
- if (isFinite( nr.x ) && isFinite(nr.y) ){
- //设置事件的新位置
- this._events[i].setPosition(nr.x,nr.y)
- }
- //如果 事件方向是数字
- if (isFinite( nr.d )){
- //设置事件方向
- this._events[i].setDirection(nr.d)
- }
- }
- }
- }
- }
- };
- //保存事件记录
- Scene_Map.prototype.ww_saveEventsXyd= function () {
- //读取变量号
- var blid = parseInt(PluginManager.parameters("baocun_event_xyd")["baocunbl"], 10);
- //如果变量内容不存在,新建一个数组
- if (!$gameVariables._data[blid]){$gameVariables._data[blid] = []}
- var value = $gameVariables._data[blid]
- var mapid = $gameMap._mapId
- //变量中本地图的记录内容情况
- value[mapid] = []
- //循环在地图中的事件
- for (var i = 0; i < $gameMap._events.length; i++) {
- event = $gameMap._events[i]
- if (!!event){
- //设置保存内容
- nr ={
- x:event.x,
- y:event.y,
- d:event._direction
- }
- value[mapid][i] = nr
- }
- }
- }
- })();
复制代码
复制事件,离开地图保存事件位置和方向
修改独立开关使之支持
好像没什么用
然后谁能告诉我为什么操作开关改变事件页后的行走图设置问题.....为什么不能转变成我要的那个方向?
最后求大神教教简单快捷高效的读取某地图数据的方法,
好想制作出跨地图的事件复制啊....
- //=============================================================================
- // baocun_event_xyd.js
- //=============================================================================
- /*:
- * @plugindesc 复制事件,保存事件位置朝向
- * @author wangwang
- *
- * @param baocunbl
- * @desc 默认保存地图事件的变量号
- * @default 1
- *
- * @help
- * 大概没什么用........
- * 保存事件的位置 和 朝向,
- * 添加一个基于本地图上事件的 事件(复制)
- * addEvent (eventId,x,y,d)
- * eventId 复制的事件id
- * 事件的x,y
- * d 事件朝向,请在(2468)之中
- *
- */
- (function() {
- //====================修改默认部分=================
- //对 默认的 $gameMap.prototype.setupEvents 安装事件进行修改
- Game_Map.prototype.setupEvents = function() {
- this._events = [];
- for (var i = 0; i < $dataMap.events.length; i++) {
- if ($dataMap.events[i]) {
- this._events[i] = new Game_Event(this._mapId, i);
- }
- }
- this.ww_loadEvents()//添加部分,读取事件记录
- this._commonEvents = this.parallelCommonEvents().map(function(commonEvent) {
- return new Game_CommonEvent(commonEvent.id);
- });
- this.refreshTileEvents();
- };
- //修改事件的初始化
- Game_Event.prototype.initialize = function(mapId, eventId , id) {
- Game_Character.prototype.initialize.call(this);
- this._mapId = mapId;
- this._eventId = eventId;
- this._id = id || eventId //添加部分
- this.locate(this.event().x, this.event().y);
- this.refresh();
- };
- //转换场景时的处理(添加保存事件)
- Scene_Map.prototype.stop = function() {
- this.ww_saveEventsXyd()//添加部分,保存事件
- Scene_Base.prototype.stop.call(this);
- $gamePlayer.straighten();
- this._mapNameWindow.close();
- if (this.needsSlowFadeOut()) {
- this.startFadeOut(this.slowFadeSpeed(), false);
- } else if (SceneManager.isNextScene(Scene_Map)) {
- this.fadeOutForTransfer();
- } else if (SceneManager.isNextScene(Scene_Battle)) {
- this.launchBattle();
- }
- };
- Game_Interpreter.prototype.setup = function(list, eventId,id) {
- this.clear();
- this._mapId = $gameMap.mapId();
- this._eventId = eventId || 0;
- this._list = list;
- this._id = id || this._eventId
- };
- Game_Event.prototype.updateParallel = function() {
- if (this._interpreter) {
- if (!this._interpreter.isRunning()) {
- this._interpreter.setup(this.list(), this._eventId,this._id);
- }
- this._interpreter.update();
- }
- };
- //安装开始地图事件
- Game_Map.prototype.setupStartingMapEvent = function() {
- var events = this.events();
- for (var i = 0; i < events.length; i++) {
- var event = events[i];
- if (event.isStarting()) {
- event.clearStartingFlag();
- this._interpreter.setup(event.list(), event.eventId(),event._id);
- return true;
- }
- }
- return false;
- };
- //满足条件
- Game_Event.prototype.meetsConditions = function(page) {
- var c = page.conditions;
- if (c.switch1Valid) {
- if (!$gameSwitches.value(c.switch1Id)) {
- return false;
- }
- }
- if (c.switch2Valid) {
- if (!$gameSwitches.value(c.switch2Id)) {
- return false;
- }
- }
- if (c.variableValid) {
- if ($gameVariables.value(c.variableId) < c.variableValue) {
- return false;
- }
- }
- //修改独立开关的判断条件
- if (c.selfSwitchValid) {
- // _eventId -> _id
- var key = [this._mapId,this._id, c.selfSwitchCh];
- if ($gameSelfSwitches.value(key) !== true) {
- return false;
- }
- }
- if (c.itemValid) {
- var item = $dataItems[c.itemId];
- if (!$gameParty.hasItem(item)) {
- return false;
- }
- }
- if (c.actorValid) {
- var actor = $gameActors.actor(c.actorId);
- if (!$gameParty.members().contains(actor)) {
- return false;
- }
- }
- return true;
- };
- // Common Event 公共事件
- Game_Interpreter.prototype.command117 = function() {
- var commonEvent = $dataCommonEvents[this._params[0]];
- if (commonEvent) {
- var eventId = this.isOnCurrentMap() ? this._eventId : 0;
- var id = this.isOnCurrentMap() ? this._id : 0;
- this.setupChild(commonEvent.list, eventId,id);
- }
- return true;
- };
- //安装子项
- Game_Interpreter.prototype.setupChild = function(list, eventId,id) {
- this._childInterpreter = new Game_Interpreter(this._depth + 1);
- this._childInterpreter.setup(list, eventId,id);
- };
- //独立开关操作(修改)
- Game_Interpreter.prototype.command123 = function() {
- if (this._eventId > 0) {
- // _eventId -> 事件 _id
- var key = [this._mapId, this._id , this._params[0]];
- $gameSelfSwitches.setValue(key, this._params[1] === 0);
- }
- return true;
- };
- Game_Interpreter.prototype.command111 = function() {
- var result = false;
- switch (this._params[0]) {
- case 0: // Switch 开关
- result = ($gameSwitches.value(this._params[1]) === (this._params[2] === 0));
- break;
- case 1: // Variable 变量
- var value1 = $gameVariables.value(this._params[1]);
- var value2;
- if (this._params[2] === 0) {
- value2 = this._params[3];
- } else {
- value2 = $gameVariables.value(this._params[3]);
- }
- switch (this._params[4]) {
- case 0: // Equal to 等于
- result = (value1 === value2);
- break;
- case 1: // Greater than or Equal to 大于等于
- result = (value1 >= value2);
- break;
- case 2: // Less than or Equal to 小于等于
- result = (value1 <= value2);
- break;
- case 3: // Greater than 大于
- result = (value1 > value2);
- break;
- case 4: // Less than 小于
- result = (value1 < value2);
- break;
- case 5: // Not Equal to 不等于
- result = (value1 !== value2);
- break;
- }
- break;
- case 2: // Self Switch 独立开关
- if (this._eventId > 0) {
- //修改
-
- var key = [this._mapId, this._id, this._params[1]];
- result = ($gameSelfSwitches.value(key) === (this._params[2] === 0));
- }
- break;
- case 3: // Timer 计时器
- if ($gameTimer.isWorking()) {
- if (this._params[2] === 0) {
- result = ($gameTimer.seconds() >= this._params[1]);
- } else {
- result = ($gameTimer.seconds() <= this._params[1]);
- }
- }
- break;
- case 4: // Actor 角色
- var actor = $gameActors.actor(this._params[1]);
- if (actor) {
- var n = this._params[3];
- switch (this._params[2]) {
- case 0: // In the Party 在队伍
- result = $gameParty.members().contains(actor);
- break;
- case 1: // Name 名称
- result = (actor.name() === n);
- break;
- case 2: // Class 职业
- result = actor.isClass($dataClasses[n]);
- break;
- case 3: // Skill 技能
- result = actor.isLearnedSkill(n);
- break;
- case 4: // Weapon 武器
- result = actor.hasWeapon($dataWeapons[n]);
- break;
- case 5: // Armor 防具
- result = actor.hasArmor($dataArmors[n]);
- break;
- case 6: // State 状态
- result = actor.isStateAffected(n);
- break;
- }
- }
- break;
- case 5: // Enemy 敌人
- var enemy = $gameTroop.members()[this._params[1]];
- if (enemy) {
- switch (this._params[2]) {
- case 0: // Appeared 出现
- result = enemy.isAlive();
- break;
- case 1: // State 状态
- result = enemy.isStateAffected(this._params[3]);
- break;
- }
- }
- break;
- case 6: // Character 人物
- var character = this.character(this._params[1]);
- if (character) {
- result = (character.direction() === this._params[2]);
- }
- break;
- case 7: // Gold 金钱
- switch (this._params[2]) {
- case 0: // Greater than or equal to 大于等于
- result = ($gameParty.gold() >= this._params[1]);
- break;
- case 1: // Less than or equal to 小于等于
- result = ($gameParty.gold() <= this._params[1]);
- break;
- case 2: // Less than 小于
- result = ($gameParty.gold() < this._params[1]);
- break;
- }
- break;
- case 8: // Item 物品
- result = $gameParty.hasItem($dataItems[this._params[1]]);
- break;
- case 9: // Weapon 武器
- result = $gameParty.hasItem($dataWeapons[this._params[1]], this._params[2]);
- break;
- case 10: // Armor 防具
- result = $gameParty.hasItem($dataArmors[this._params[1]], this._params[2]);
- break;
- case 11: // Button 按键
- result = Input.isPressed(this._params[1]);
- break;
- case 12: // Script 脚本
- result = !!eval(this._params[1]);
- break;
- case 13: // Vehicle 交通工具
- result = ($gamePlayer.vehicle() === $gameMap.vehicle(this._params[1]));
- break;
- }
- this._branch[this._indent] = result;
- if (this._branch[this._indent] === false) {
- this.skipBranch();
- }
- return true;
- };
- //===================================================================
- //====================添加部分====================
- //添加事件
- addEvent = function (eventId,x,y,d) {
- //如果这个事件id在地图数据中有基础
- if ($dataMap.events[eventId]) {
- //获取添加的id
- var tjid= $gameMap._events.length
- //地图事件添加一个新的基于 地图数据中id事件内容 的事件
- $gameMap._events[tjid]=new Game_Event($gameMap._mapId,eventId,tjid)
- //如果x,y是数字 设置事件位置
- if (isFinite(x) && isFinite(y) ){$gameMap._events[tjid].setPosition(x,y)}
- //如果d是数字 设置事件方向(请输入:2,4,6,8)
- if (isFinite(d)) { $gameMap._events[tjid].setDirection(d)}
- //如果当前场景是 地图
- if (SceneManager._scene.constructor == Scene_Map){
- //地图场景的 精灵组 的 人物精灵 添加 一个新 人物精灵(添加的事件)
- SceneManager._scene._spriteset._characterSprites.push(new Sprite_Character($gameMap._events[tjid]))
- //获取 新添加的精灵的id
- var tjid2 = SceneManager._scene._spriteset._characterSprites.length - 1
- //把 新添加的精灵 添加到 场景 精灵组 地图 的子项
- var tjc=SceneManager._scene._spriteset._characterSprites[tjid2]
- SceneManager._scene._spriteset._tilemap.addChild(tjc);
- }
- $gameMap.requestRefresh()
- }
- }
- //读取事件记录
- Game_Map.prototype.ww_loadEvents = function() {
- //读取变量
- var blid = parseInt(PluginManager.parameters("baocun_event_xyd")["baocunbl"], 10);
- var value = $gameVariables._data[blid]
- //如果存在
- if (!!value){
- //如果这个地图有保存
- if (!!value[this._mapId]){
- //循环所有地图内的事件记录
- for (var i=0; i < value[this._mapId].length ;i++){
- //读取一条事件记录的内容
- var nr = value[this._mapId][i]
- //如果存在内容
- if (!!nr){
- //如果是超出原本地图内事件数量的
- if(i >= $dataMap.events.length ){
- //基于原地图数据复制出一个新的事件
- this._events[i]=new Game_Event(this._mapId,nr[0],i)
- }
- //如果 事件x和y 是数字
- if (isFinite( nr[1] ) && isFinite(nr[2]) ){
- //设置事件的新位置
- this._events[i].setPosition(nr[1],nr[2])
- }
- //如果 事件方向是数字
- if (isFinite( nr[3] )){
- //设置事件方向
- this._events[i].setDirection(nr[3])
- }
- }
- }
- }
- }
- };
- //保存事件记录
- Scene_Map.prototype.ww_saveEventsXyd= function () {
- //读取变量号
- var blid = parseInt(PluginManager.parameters("baocun_event_xyd")["baocunbl"], 10);
- //如果变量内容不存在,新建一个数组
- if (!$gameVariables._data[blid]){$gameVariables._data[blid] = []}
- var value = $gameVariables._data[blid]
- var mapid = $gameMap._mapId
- //变量中本地图的记录内容情况
- value[mapid] = []
- //循环在地图中的事件
- for (var i = 0; i < $gameMap._events.length; i++) {
- event = $gameMap._events[i]
- if (!!event){
- //设置保存内容
- nr =[event._eventId ,event.x,event.y,event._direction]
- value[mapid][i] = nr
- }
- }
- }
- })();
复制代码
|
评分
-
查看全部评分
|