- 累计送礼:
- 0 个
- 累计收礼:
- 0 个
TA的每日心情 | 开心 2025-2-4 02:05 |
---|
签到天数: 110 天 连续签到: 2 天 [LV.6]常住居民II

管理员
  
- VIP
- 6
- 卡币
- 10465
- OK点
- 16
- 推广点
- 0
- 同能卷
- 0
- 积分
- 13215


|
RT,自己写自己用的,用途是用显示用变量做的声望,以及显示用变量做的额外货币,和自己用的一个叫做威望的变量。
如果要实现全部用途,需要具备YEP_ShopMenuCore和YEP_X_MoreCurrencies这两个插件。本插件可以配和这两个插件中实现的用变量当货币功能,提供其显示当作变量用的货币的持有数量。
如果只需要声望系统的话,直接屏蔽掉变量货币部分然后改改代码中的备注有//行高变化,那一行的值就行了。
以下是代码,代码中有具体的说明和注释方便大家修改。
最后,由于各种不会,所以代码写得很乱,而且很多数据,例如图标,声望和货币的名字都需要直接在插件中逐个改,而且最好根据游戏的进程一边设计剧情一边改,不然会出现显示上面的不和谐。因为每个框都在固定的地方,如果预先设好的话,可能会出现二号声望没开结果十号先开了,然后就会出现一大片空白,中间莫名其妙显示着一个声望框- -
JAVASCRIPT 代码 - //=============================================================================
- // Salvareless Ownuse System
- // SOS_声望系统.js
- //=============================================================================
- //帮助区段
- //因为比较靠前的开关和变量大多情况下都有其他插件占用,所以本插件从62号变量开始,61留空写标注。
- //声望开关从62号到79号共18个
- //声望变量从62号到79号共18个
- //威望变量为80号。威望用以影响部分NPC物价,为0时不显示。
- //声望开关62号对应声望变量62号,往下一一对应。对应的开关开启式,才会显示对应的声望计数。
- //声望计数从负无穷到正六万,负可以无限负,正只到六万。
- //声望值达到0,100,800,5000,20000,60000时进入下一个声望阶段。
- //声望阶段依次是:仇恨,冷漠,友善,尊重,尊敬,崇敬,崇拜
- //变量货币需要配合YEP_ShopMenuCore和YEP_X_MoreCurrencies才更有意义,必然就只能做固定的物品兑换事件
- //变量当货币使用到的变量从42号开始到56号,一共15个。
- //已经设置货币当变量用时,大于0才会显示出来。
- //默认声望一共18个,变量货币15个,请随意根据需要删减,= =应该不会用到比这个数量更多了吧…………
- //由于各种不会,所以图标,和声望名字,货币名字什么的,都需要在插件中直接改。
- //由于各种不会,所以代码写得超级乱。
- //帮助区段END
- //=========================================================================
- // 声明区段
- //=========================================================================
- function Window_Shengwang(){
- this.initialize.apply(this, arguments);
- };
- Window_Shengwang.prototype = Object.create(Window_Selectable.prototype);
- Window_Shengwang.prototype.initialize = function(x, y, width, height){
- Window_Selectable.prototype.initialize.call(this, x, y, width, height);
- };
- function Scene_Shengwang(){
- this.initialize.apply(this, arguments);
- };
- Scene_Shengwang.prototype = Object.create(Scene_MenuBase.prototype);
- Scene_Shengwang.prototype.initialize = function(){
- Scene_MenuBase.prototype.initialize.call(this);
- };
- Scene_Shengwang.prototype.create = function(){
- Scene_MenuBase.prototype.create.call(this);
- this._commandWindow = new Window_Shengwang(0, 0, 816, 624);
- this.addWindow(this._commandWindow);
- };
- Scene_Shengwang.prototype.update = function(){
- if(Input.isTriggered('escape') || Input.isTriggered('cancel')){
- this._commandWindow.hide();
- SceneManager.goto(Scene_Menu);
- };
- };
- // ======================================================================
- // * Scene_Menu
- // ======================================================================
- Scene_Menu.prototype.Shengwang_createCommandWindow = Scene_Menu.prototype.createCommandWindow;
- Scene_Menu.prototype.createCommandWindow = function(){
- this.Shengwang_createCommandWindow();
- this._commandWindow.setHandler('shengwang', this.command_Shengwang.bind(this));
- };
- Scene_Menu.prototype.command_Shengwang = function(){
- SceneManager.push(Scene_Shengwang);
- };
- // ======================================================================
- // * Window_MenuCommand
- // ======================================================================
- Window_MenuCommand.prototype.Shengwang_addOriginalCommands = Window_MenuCommand.prototype.addOriginalCommands;
- Window_MenuCommand.prototype.addOriginalCommands = function(){
- this.Shengwang_addOriginalCommands();
- this.addCommand('声望货币', 'shengwang', this.areMainCommandsEnabled());
- };
- //=======================================================================
- // 显示区段
- //=======================================================================
- Window_Shengwang.prototype.initialize = function(x, y, width, height){
- Window_Selectable.prototype.initialize.call(this, x, y, width, height);
- this.drawShengwangText();
- };
- Window_Shengwang.prototype.drawShengwangText = function(){
- var dy = 0;
- var dx = 34; //左侧文字绘制的X坐标,已经留出图标位置。
- var di = 277; //中间图标显示的X坐标,左侧为0
- var dxx = 311; //中间文字绘制的X坐标。已经留出图标位置。
- var dii = 554; //右侧图标绘制的X坐标。
- var dxxx = 588; //右侧文字绘制的X坐标,已经留出图标位置。
- var dw = 230; //界面总宽
- var gx = 0;
- this.contents.fontSize = 20;
- this.drawText("声望和货币", 0, -10, dw, 'left');
- if($gameVariables.value(80) > 0){
- this.drawText("威望:" + $gameVariables.value(80), 0, -10 ,778, 'right');
- };
- this.drawText("—————————————————————————————————————————", 0, dy + 8, 784, 'left');
- this.contents.fontSize = 20;
- //声望区段
- //第一行
- dy += 32; //行高变化
- //左
- if($gameSwitches.value(62) == true){
- this.drawIcon(3, 0, dy + 3);
- this.drawText("人类世界-银西法尔特", dx, dy, dw, 'left');
- this.dataMath($gameVariables.value(62), gx ,dy ,dw); //条显示的函数,第一个值为要使用的变量
- }else{
- this.drawText("声望系统尚未开启", 0, dy, dw, 'left');
- };
- //中
- if($gameSwitches.value(63) == true){
- if($gameVariables.value(63) == 0){
- this.drawText("???", di, dy, dw, 'conter');
- }else{
- this.drawIcon(3, di, dy + 3);
- this.drawText("尘隐镇", dxx, dy, dw, 'left');
- this.dataMath($gameVariables.value(63), gx + 277 ,dy ,dw);
- };};
- //右
- if($gameSwitches.value(64) == true){
- if($gameVariables.value(64) == 0){
- this.drawText("???", dii, dy, dw, 'conter');
- }else{
- this.drawIcon(3, dii, dy + 3);
- this.drawText("天都", dxxx, dy, dw, 'left');
- this.dataMath($gameVariables.value(64), gx + 554 ,dy ,dw);
- };};
- //第二行
- dy += 61; //行高变化
- //左
- if($gameSwitches.value(65) == true){
- if($gameVariables.value(65) == 0){
- this.drawText("???", 0, dy, dw, 'conter');
- }else{
- this.drawIcon(3, 0, dy + 3);
- this.drawText("人类世界-银西法尔特", dx, dy, dw, 'left');
- this.dataMath($gameVariables.value(65), gx ,dy ,dw);
- };};
- //中
- if($gameSwitches.value(66) == true){
- if($gameVariables.value(66) == 0){
- this.drawText("???", di, dy, dw, 'conter');
- }else{
- this.drawIcon(3, di, dy + 3);
- this.drawText("尘隐镇", dxx, dy, dw, 'left');
- this.dataMath($gameVariables.value(66), gx + 277 ,dy ,dw);
- };};
- //右
- if($gameSwitches.value(67) == true){
- if($gameVariables.value(67) == 0){
- this.drawText("???", dii, dy, dw, 'conter');
- }else{
- this.drawIcon(3, dii, dy + 3);
- this.drawText("天都", dxxx, dy, dw, 'left');
- this.dataMath($gameVariables.value(67), gx + 554 ,dy ,dw);
- };};
- //第三行
- dy += 61; //行高变化
- //左
- if($gameSwitches.value(68) == true){
- if($gameVariables.value(68) == 0){
- this.drawText("???", 0, dy, dw, 'conter');
- }else{
- this.drawIcon(3, 0, dy + 3);
- this.drawText("人类世界-银西法尔特", dx, dy, dw, 'left');
- this.dataMath($gameVariables.value(68), gx ,dy ,dw);
- };};
- //中
- if($gameSwitches.value(69) == true){
- if($gameVariables.value(69) == 0){
- this.drawText("???", di, dy, dw, 'conter');
- }else{
- this.drawIcon(3, di, dy + 3);
- this.drawText("尘隐镇", dxx, dy, dw, 'left');
- this.dataMath($gameVariables.value(69), gx + 277 ,dy ,dw);
- };};
- //右
- if($gameSwitches.value(70) == true){
- if($gameVariables.value(70) == 0){
- this.drawText("???", dii, dy, dw, 'conter');
- }else{
- this.drawIcon(3, dii, dy + 3);
- this.drawText("天都", dxxx, dy, dw, 'left');
- this.dataMath($gameVariables.value(70), gx + 554 ,dy ,dw);
- };};
- //第四行
- dy += 61; //行高变化
- //左
- if($gameSwitches.value(71) == true){
- if($gameVariables.value(71) == 0){
- this.drawText("???", 0, dy, dw, 'conter');
- }else{
- this.drawIcon(3, 0, dy + 3);
- this.drawText("人类世界-银西法尔特", dx, dy, dw, 'left');
- this.dataMath($gameVariables.value(71), gx ,dy ,dw);
- };};
- //中
- if($gameSwitches.value(72) == true){
- if($gameVariables.value(72) == 0){
- this.drawText("???", di, dy, dw, 'conter');
- }else{
- this.drawIcon(3, di, dy + 3);
- this.drawText("尘隐镇", dxx, dy, dw, 'left');
- this.dataMath($gameVariables.value(72), gx + 277 ,dy ,dw);
- };};
- //右
- if($gameSwitches.value(73) == true){
- if($gameVariables.value(73) == 0){
- this.drawText("???", dii, dy, dw, 'conter');
- }else{
- this.drawIcon(3, dii, dy + 3);
- this.drawText("天都", dxxx, dy, dw, 'left');
- this.dataMath($gameVariables.value(73), gx + 554 ,dy ,dw);
- };};
- //第五行
- dy += 61; //行高变化
- //左
- if($gameSwitches.value(74) == true){
- if($gameVariables.value(74) == 0){
- this.drawText("???", 0, dy, dw, 'conter');
- }else{
- this.drawIcon(3, 0, dy + 3);
- this.drawText("人类世界-银西法尔特", dx, dy, dw, 'left');
- this.dataMath($gameVariables.value(74), gx ,dy ,dw);
- };};
- //中
- if($gameSwitches.value(75) == true){
- if($gameVariables.value(75) == 0){
- this.drawText("???", di, dy, dw, 'conter');
- }else{
- this.drawIcon(3, di, dy + 3);
- this.drawText("尘隐镇", dxx, dy, dw, 'left');
- this.dataMath($gameVariables.value(75), gx + 277 ,dy ,dw);
- };};
- //右
- if($gameSwitches.value(76) == true){
- if($gameVariables.value(76) == 0){
- this.drawText("???", dii, dy, dw, 'conter');
- }else{
- this.drawIcon(3, dii, dy + 3);
- this.drawText("天都", dxxx, dy, dw, 'left');
- this.dataMath($gameVariables.value(76), gx + 554 ,dy ,dw);
- };};
- //第六行
- dy += 61; //行高变化
- //左
- if($gameSwitches.value(77) == true){
- if($gameVariables.value(77) == 0){
- this.drawText("???", 0, dy, dw, 'conter');
- }else{
- this.drawIcon(3, 0, dy + 3);
- this.drawText("人类世界-银西法尔特", dx, dy, dw, 'left');
- this.dataMath($gameVariables.value(77), gx ,dy ,dw);
- };};
- //中
- if($gameSwitches.value(78) == true){
- if($gameVariables.value(78) == 0){
- this.drawText("???", di, dy, dw, 'conter');
- }else{
- this.drawIcon(3, di, dy + 3);
- this.drawText("尘隐镇", dxx, dy, dw, 'left');
- this.dataMath($gameVariables.value(78), gx + 277 ,dy ,dw);
- };};
- //右
- if($gameSwitches.value(79) == true){
- if($gameVariables.value(79) == 0){
- this.drawText("???", dii, dy, dw, 'conter');
- }else{
- this.drawIcon(3, dii, dy + 3);
- this.drawText("天都", dxxx, dy, dw, 'left');
- this.dataMath($gameVariables.value(79), gx + 554 ,dy ,dw);
- };};
- //声望区段END
- dy = 387;
- this.drawText("————————————————————————————————————", 0, dy, 784, 'left');
- var hi = 0; //一位X坐标,框宽加1像素的边距
- var hii = 157; //二位X坐标
- var hiii = 314 //三位X坐标
- var hiv = 471; //四位X坐标
- var hv = 628; //五位X坐标
- var hw = 156; //每个框宽
- //货币区段
- dy = 407; //第一行
- //左
- if($gameVariables.value(42) > 0){
- this.drawIcon(3, hi, dy + 30);
- this.drawText("神殿晶体:", hi, dy, hw);
- this.drawText("x " + $gameVariables.value(42), hi + 35, dy + 30, hw, 'left');
- }else{
- this.drawText("货币系统尚未开启", hi, dy, 784);
- };
- //左中
- if($gameVariables.value(42) > 0){
- this.drawIcon(3, hii, dy + 30);
- this.drawText("神殿晶体:", hii, dy, hw);
- this.drawText("x " + $gameVariables.value(43), hii + 35, dy + 30, hw, 'left');
- };
- //中
- if($gameVariables.value(42) > 0){
- this.drawIcon(3, hiii, dy + 30);
- this.drawText("神殿晶体:", hiii, dy, hw);
- this.drawText("x " + $gameVariables.value(44), hiii + 35, dy + 30, hw, 'left');
- };
- //右中
- if($gameVariables.value(42) > 0){
- this.drawIcon(3, hiv, dy + 30);
- this.drawText("神殿晶体:", hiv, dy, hw);
- this.drawText("x " + $gameVariables.value(45), hiv + 35, dy + 30, hw, 'left');
- };
- //右
- if($gameVariables.value(42) > 0){
- this.drawIcon(3, hv, dy + 30);
- this.drawText("神殿晶体:", hv, dy, hw);
- this.drawText("x " + $gameVariables.value(46), hv + 35, dy + 30, hw, 'left');
- };
- dy = 466; //第二行
- //左
- if($gameVariables.value(42) > 0){
- this.drawIcon(3, hi, dy + 30);
- this.drawText("神殿晶体:", hi, dy, hw);
- this.drawText("x " + $gameVariables.value(47), hi + 35, dy + 30, hw, 'left');
- };
- //左中
- if($gameVariables.value(42) > 0){
- this.drawIcon(3, hii, dy + 30);
- this.drawText("神殿晶体:", hii, dy, hw);
- this.drawText("x " + $gameVariables.value(48), hii + 35, dy + 30, hw, 'left');
- };
- //中
- if($gameVariables.value(42) > 0){
- this.drawIcon(3, hiii, dy + 30);
- this.drawText("神殿晶体:", hiii, dy, hw);
- this.drawText("x " + $gameVariables.value(49), hiii + 35, dy + 30, hw, 'left');
- };
- //右中
- if($gameVariables.value(42) > 0){
- this.drawIcon(3, hiv, dy + 30);
- this.drawText("神殿晶体:", hiv, dy, hw);
- this.drawText("x " + $gameVariables.value(50), hiv + 35, dy + 30, hw, 'left');
- };
- //右
- if($gameVariables.value(42) > 0){
- this.drawIcon(3, hv, dy + 30);
- this.drawText("神殿晶体:", hv, dy, hw);
- this.drawText("x " + $gameVariables.value(51), hv + 35, dy + 30, hw, 'left');
- };
- dy = 525; //第三行
- //左
- if($gameVariables.value(42) > 0){
- this.drawIcon(3, hi, dy + 30);
- this.drawText("神殿晶体:", hi, dy, hw);
- this.drawText("x " + $gameVariables.value(52), hi + 35, dy + 30, hw, 'left');
- };
- //左中
- if($gameVariables.value(42) > 0){
- this.drawIcon(3, hii, dy + 30);
- this.drawText("神殿晶体:", hii, dy, hw);
- this.drawText("x " + $gameVariables.value(53), hii + 35, dy + 30, hw, 'left');
- };
- //中
- if($gameVariables.value(42) > 0){
- this.drawIcon(3, hiii, dy + 30);
- this.drawText("神殿晶体:", hiii, dy, hw);
- this.drawText("x " + $gameVariables.value(54), hiii + 35, dy + 30, hw, 'left');
- };
- //右中
- if($gameVariables.value(42) > 0){
- this.drawIcon(3, hiv, dy + 30);
- this.drawText("神殿晶体:", hiv, dy, hw);
- this.drawText("x " + $gameVariables.value(55), hiv + 35, dy + 30, hw, 'left');
- };
- //右
- if($gameVariables.value(42) > 0){
- this.drawIcon(3, hv, dy + 30);
- this.drawText("神殿晶体:", hv, dy, hw);
- this.drawText("x " + $gameVariables.value(56), hv + 35, dy + 30, hw, 'left');
- };
- //货币区段END
- };
- //条显示的函数
- Window_Shengwang.prototype.dataMath = function(data, gx, dy, dw){
- var v1 = data;
- var v2 = 1;
- var text = "";
- var color = '#000000';
- if(v1 >= 60000){ //崇拜
- v1 = 60000;
- v2 = 60000; //当前阶段的声望上限
- color = '#00ff00'; //设置声望条的颜色
- text = "崇拜:"+ v1 + "/" + v2; //赋值要显示在声望条上面的文字
- }elseif(v1 >= 20000){ //崇敬
- v2 = 60000;
- color = '#00e400';
- text = "崇敬:"+ v1 + "/" + v2;
- }elseif(v1 >= 5000){ //尊敬
- v2 = 20000;
- color = '#40de5a';
- text = "尊敬:"+ v1 + "/" + v2;
- }elseif(v1 >= 800){ //尊重
- v2 = 5000;
- color = '#eaff56';
- text = "尊重:"+ v1 + "/" + v2;
- }elseif(v1 >= 100){ //友善
- v2 = 800;
- color = '#faff72';
- text = "友善:"+ v1 + "/" + v2;
- }elseif(v1 < 0){ //仇恨
- v2 = v1;
- color = '#ff0000';
- text = "仇恨:"+ v1;
- /* }else if (v1 == 0){ //为0的状态
- v2 = 1;
- color = '#ffffff';
- text = "???";
- */ }else{ //冷漠
- v2 = 100;
- color = '#ffa400';
- var text = "冷漠:"+ v1 + "/" + v2;
- }
- var rate = v1 / v2; //计算声望条的绘制比例
- dy += 30; //行高变化
- this.drawGauge(gx, dy, dw, rate, color); //绘制声望条
- this.drawText(text, gx + 12, dy - 4 , dw, 'center'); //绘制要显示在声望条上面的文字
- };
- //绘制条函数
- Window_Shengwang.prototype.drawGauge = function(x, y, width, rate, color){
- var fillW = Math.floor(width * rate); //比例换算成彩条长度
- this.contents.fillRect(x, y + 8, width, 20, '#000000'); //绘制条的黑底
- this.contents.gradientFillRect(x, y + 8, fillW, 20, color, color); //绘制彩条
- };
复制代码
全部内容显示状态是下图这样的,密集恐惧症慎看= =
更新列表:
1.1--由347780682提供建议,将声望为0,显示为???。这样即使声望还没有获得声望,也可以开启对应的声望系统,这样一来,在设计剧情的时候如果不按常理出牌,先获得了排在靠后的声望时,也可以直接开启靠后的声望同时打开靠前的声望开关,让其显示为???。更新已经并入上面的脚本,各位客官随意取用修改。
1.2--由347780682提供建议,将声望为开启后声望为0的声望地域显示为???,就不再显示图标和条。已经屏蔽上一个版本的修改区段,有特殊需求的客官也可以手动屏蔽声望区的所有if ($gameVariables.value(76) == 0){
this.drawText("???", dii, dy, dw, 'conter' );
} else{ 这个类型的判断,末尾的其中一个};。然后恢复412-416行的屏蔽即可。
本帖来自P1论坛作者salvareless,因Project1站服务器在国外有时候访问缓慢不方便作者交流学习,经联系P1站长fux2同意署名转载一起分享游戏制作经验,共同为国内独立游戏作者共同创造良好交流环境,原文地址: https://rpg.blue/forum.php?mod=viewthread&tid=389652 若有侵权,发帖作者可联系底部站长QQ在线咨询功能删除,谢谢。 |
本帖子中包含更多资源
您需要 登录 才可以下载或查看,没有账号?立即注册
x
|