设为首页收藏本站|繁體中文

Project1

 找回密码
 注册会员
搜索
查看: 2028|回复: 4

[有事请教] MV显示事件名称的插件,如何才能在游戏中改变事件名称

[复制链接]

Lv1.梦旅人

梦石
0
星屑
91
在线时间
5 小时
注册时间
2020-1-17
帖子
3
发表于 2020-5-21 10:46:31 | 显示全部楼层 |阅读模式

加入我们,或者,欢迎回来。

您需要 登录 才可以下载或查看,没有帐号?注册会员

x
本帖最后由 wch131424 于 2020-5-21 11:02 编辑

我想在游戏中改变显示的事件名称,最好可以由变量控制


新手发帖,代码是这么粘吗?

/*:
* @plugindesc Namepop Ver 1.03 NPC名称显示
* @author Morpho(dongdongDJH)
*
* @help
* 在地图事件注释栏内填入 NAMEPOP|高度修正值|字体Size|字体颜色;
* 高度修正值单位为1格,不填默认为1,字体大小不填默认为18;
* 例:NAMEPOP|1|18|#00FF00 ; NAMEPOP||20 ;
* 注:一定要用‘|’分隔高度修正值和字体Size;
* 若要调整描边 请直接在下方代码中调整 (ps:0.8是颜色的透明度,0-1)
*/
(function() {
        _Sprite_Character_prototype_initialize = Sprite_Character.prototype.initialize;
        Sprite_Character.prototype.initialize = function(character) {
                _Sprite_Character_prototype_initialize.call(this, character);
                this._tempCharacter = character;
                if (character instanceof Game_Event) {
                        if (character.event().note.match("NAMEPOP") != null) {
                                var notetext = character.event().note.split("|");
                                this._namepopY = Number(notetext[1]) || 1;
                                this._fontSize = Number(notetext[2]) || 18;
                                this._BYcolor  =  notetext[3] || "#FFFFFF";
                                this.createNamepopSet();
                        }
                }
        };

        Sprite_Character.prototype.createNamepopSet = function() {
                var h = this._fontSize;
                this._namepopSprite = new Sprite();
                this._namepopSprite.bitmap = new Bitmap(h * 10, h);
                this._namepopSprite.bitmap.fontSize = h;
                this._namepopSprite.bitmap.outlineColor = "rgba(0, 0, 0, 0.8)"//描边颜色
                this._namepopSprite.bitmap.outlineWidth = 4;//字体描边
                this._namepopSprite.bitmap.textColor = this._BYcolor;//字体颜色
                this._namepopSprite.bitmap.drawText(this._tempCharacter.event().name, 0, 0, h * 10, h, 'center');
                this._namepopSprite.anchor.x = 0.5;
                this._namepopSprite.anchor.y = 1;
                this._namepopSprite.y = this.y - this._namepopY * 48;
                this.addChild(this._namepopSprite);
        };
       
// ---- 新增跟随事件显示 ----
        _Sprite_Character_prototype_setCharacterBitmap = Sprite_Character.prototype.setCharacterBitmap;
        Sprite_Character.prototype.setCharacterBitmap = function() {
                _Sprite_Character_prototype_setCharacterBitmap.call(this);
        if (this._tempCharacter instanceof Game_Event) {
                        this._BYconditions = this._tempCharacter.findProperPageIndex();
                        if(this._BYconditions >= 0 &&  this._namepopSprite){
                                this._namepopSprite.visible = true;
                        }else if(this._namepopSprite){
                                this._namepopSprite.visible = false;
                        }

                }
        };

  // ---- Game_Event ----
  // -------------------------------
        // _Game_Event_prototype_refresh = Game_Event.prototype.refresh;
        // Game_Event.prototype.refresh = function() {
        //         _Game_Event_prototype_refresh.call(this);

        // };
}());

Lv4.逐梦者

梦石
0
星屑
12157
在线时间
4435 小时
注册时间
2014-4-11
帖子
5955

开拓者

发表于 2020-5-21 11:04:14 | 显示全部楼层
本帖最后由 yang1zhi 于 2020-5-21 15:26 编辑

不好办,事件名称是没有保存在存档上的,是公用数据,你修改了,下次还会变回去。
用变量保存事件的名称,然后显示变量的名称可以。

比如
if ($gameVariables.value(10) === 0) {$gameVariables._data[10] = {}}
if ($gameVariables._data[10][地图ID]) {$gameVariables._data[10][地图ID] = {}}
$gameVariables._data[10][地图ID][事件ID] = '笨蛋'
//这样把新的事件的名字写进变量里面

然后
this._namepopSprite.bitmap.drawText(this._tempCharacter.event().name, 0, 0, h * 10, h, 'center');
这条是你那里显示名字的地方。
可以这样
if ($gameVariables._data[10] && $gameVariables._data[10][地图ID]  && $gameVariables._data[10][地图ID][事件ID] ) {
  var name = $gameVariables._data[10][地图ID][事件ID]
} else {
  var name = this._tempCharacter.event().name
}
this._namepopSprite.bitmap.drawText(name , 0, 0, h * 10, h, 'center');

点评

大佬太强了  发表于 2020-5-21 12:56
回复 支持 反对

使用道具 举报

Lv1.梦旅人

梦石
0
星屑
91
在线时间
5 小时
注册时间
2020-1-17
帖子
3
 楼主| 发表于 2020-5-21 11:09:22 | 显示全部楼层
yang1zhi 发表于 2020-5-21 11:04
不好办,事件名称是没有保存在存档上的,是公用数据,你修改了,下次还会变回去。
用变量保存事件的名称, ...

这种代码我应该写在哪儿呢?我还是个新手,请具体指导下,,,

点评

前面的那段是用来改变事件名称的,你写到事件的脚本功能里,就能实现。后面那段是显示名称的,你把你给出的那段脚本修改了就可以  发表于 2020-5-21 11:43
回复 支持 反对

使用道具 举报

您需要登录后才可以回帖 登录 | 注册会员

本版积分规则

拿上你的纸笔,建造一个属于你的梦想世界,加入吧。
 注册会员
找回密码

站长信箱:[email protected]|手机版|小黑屋|无图版|Project1游戏制作

GMT+8, 2024-3-29 21:08

Powered by Discuz! X3.1

© 2001-2013 Comsenz Inc.

快速回复 返回顶部 返回列表