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

Project1

 找回密码
 注册会员
搜索
查看: 3466|回复: 2
打印 上一主题 下一主题

[有事请教] MV如何使用半身像?

[复制链接]

Lv2.观梦者

梦石
0
星屑
384
在线时间
29 小时
注册时间
2018-6-1
帖子
42
跳转到指定楼层
1
发表于 2018-6-8 18:09:54 | 只看该作者 回帖奖励 |倒序浏览 |阅读模式

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

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

x
MV版本如何在对话中使用半身像?
我本是仅有两片叶子的花,可黑暗的不公使我拥有荆棘

Lv4.逐梦者

梦石
0
星屑
7787
在线时间
1175 小时
注册时间
2006-7-18
帖子
606
2
发表于 2018-6-8 19:05:47 | 只看该作者
本帖最后由 雷影 于 2018-6-8 20:12 编辑

有一个GALV_MessageBusts插件是可以对话显示半身像的!
找一下就能找到,还附带实例工程!

JAVASCRIPT 代码复制
  1. //-----------------------------------------------------------------------------
  2. //  Galv's Message Busts
  3. //-----------------------------------------------------------------------------
  4. //  For: RPGMAKER MV
  5. //  GALV_MessageBusts.js
  6. //-----------------------------------------------------------------------------
  7. //  2017-11-04 - Version 2.8 - Added fade out speed setting
  8. //  2017-08-21 - Version 2.7 - Fixed a minor bug with appear in front & above
  9. //  2016-10-04 - Version 2.6 - Fixed issue where bust disable/position did not
  10. //                             save in saved games.
  11. //  2016-08-11 - Version 2.5 - Made bust sprite object public
  12. //  2016-08-10 - Version 2.4 - Fixed a crash in MV 1.3 update
  13. //  2016-04-27 - Version 2.3 - Fixed deployment bug with face name case
  14. //  2016-04-22 - Version 2.2 - Fixed a bug with still checking for bust when
  15. //                             Using just faces
  16. //  2016-04-22 - Version 2.1 - Fixed issue with turning busts on/off
  17. //  2016-04-02 - Version 2.0 - Added compatibility for Message Style popups
  18. //  2016-01-12 - Version 1.9 - Fixed issue with middle-aligned textbox
  19. //  2015-12-26 - Version 1.8 - added an option to append text to bust filenames
  20. //                           - to use different images for this and bust menu
  21. //  2015-11-11 - Version 1.7 - fixed text code to change bust mid message.
  22. //                           - (the actor number went to wrong face)
  23. //                           - fixed mid message changing of bust flicker
  24. //  2015-11-11 - Version 1.6 - added Galv plugin command efficiency code
  25. //  2015-11-09 - Version 1.5 - Added ability to display faces/busts based on
  26. //                           - Member position or leader.
  27. //  2015-11-02 - Version 1.4 - Added escape code to change bust during message
  28. //  2015-11-01 - Version 1.3 - fixed bug with bust not disappearing
  29. //  2015-11-01 - Version 1.2 - fixed bug with changing bust
  30. //  2015-11-01 - Version 1.1 - fixed bug with settings
  31. //  2015-11-01 - Version 1.0 - release
  32. //-----------------------------------------------------------------------------
  33. // Terms can be found at:
  34. // galvs-scripts.com
  35. //-----------------------------------------------------------------------------
  36.  
  37. var Imported = Imported || {};
  38. Imported.Galv_MessageBusts = true;
  39.  
  40. var Galv = Galv || {};        // Galv's main object
  41. Galv.pCmd = Galv.pCmd || {};  // Plugin Command manager
  42. Galv.MB = Galv.MB || {};      // Galv's stuff
  43.  
  44. Galv.Mstyle = Galv.Mstyle || {};  // compatibility
  45.  
  46. //-----------------------------------------------------------------------------
  47. /*:
  48.  * @plugindesc (v.2.8) 半身像对话框插件
  49.  *
  50.  * @author Galv - galvs-scripts.com
  51.  *
  52.  * @param Bust Priority
  53.  * @desc 可以用 0 or 1控制.
  54.  * 0 = 半身像显示在对话框后面。 1 = 半身像显示在对话框前面。
  55.  * @default 0
  56.  *
  57.  * @param Bust Position
  58.  * @desc 可以用 0 or 1控制.
  59.  * 0 = 半身像显示在对话框上方. 1 = 半身显示在屏幕底部
  60.  * @default 0
  61.  *
  62.  * @param Text X Offset
  63.  * @desc 当左侧显示半身像时,文本被推到右边的像素数量。
  64.  * @default 390
  65.  *
  66.  * @param Fade Out Speed
  67.  * @desc 半身像消失的速度. 1-255
  68.  * @default 32
  69.  *
  70.  * @param Filename Append
  71.  * @desc 追加插件寻找的正常文件路径的文本。
  72.  * @default
  73.  
  74.  *
  75.  * @help
  76.  *   半身像对话框插件
  77.  * ----------------------------------------------------------------------------
  78.  * This plugin displays a bust image from /img/pictures/ folder based on the
  79.  * face chosen in the 'Show Text' event command.  For example:
  80.  * If your 'Show Text' uses the 2nd face from the "Actor1" faces file, then
  81.  * the plugin will use /img/pictures/Actor1_2.png for the bust image.
  82.  *
  83.  * Remember, all filenames are case sensitive, so make sure to use the correct
  84.  * capitalization/case for your faces and busts.
  85.  *
  86.  * ADDED: A plugin setting called "Filename Append".
  87.  * Whatever you put in this setting will be added to the end of the filename.
  88.  * Using the above example, if the Filename Append setting is "_bust", then the
  89.  * plugin will use /img/pictures/Actor1_2_bust.png instead.
  90.  *
  91.  * Make sure to add 'wait' between messages with different character's busts
  92.  * for better looking transitions.
  93.  * Use the 'Plugin' event command to change bust settings. These settings will
  94.  * be in effect until changed, so they can be used for multiple messages.
  95.  *
  96.  * NOTE: You will need to find your own bust images to use. I can not help
  97.  * you with that. The images in the demo are for demo purposes only.
  98.  *
  99.  * This plugin also comes with the ability to display bust/facesets according
  100.  * to who is in the party or a certain position from the leader's faceset.
  101.  * This works for both the faces and busts.
  102.  *
  103.  * 1. Member's face.
  104.  * Create a face file (or get from demo) called "partymember.png".
  105.  * Number each face in this faceset from 1 to 8.
  106.  * When this face set is used in a "Show Text" event command, it will replace
  107.  * the face with the party member according to the face number used.
  108.  *
  109.  * 1. Leader's face.
  110.  * Create a face file (or get from demo) called "partyleader.png".
  111.  * Label your faces accordingly (for example, happy, sad, laugh. Or numbers)
  112.  * When this face set is used in a "Show Text" event command, it will replace
  113.  * the face with the party leader's faceset and the face number of the chosen
  114.  * face position of the 'partyleader' faceset.
  115.  *
  116.  *
  117.  * 半身像放在/img/pictures文件夹里,对应/img/faces里头像文件名。
  118.  * 半身像文件名和头像名一样,加上后缀_1~_8,对应8个位置头像
  119.  * 例如:半身像/img/pictures/Actor1_1.png对应/img/faces/Actor1.png头像图的第一个头像
  120.  * ----------------------------------------------------------------------------
  121.  *   PLUGIN COMMANDS (To change bust position/visibility)
  122.  * ----------------------------------------------------------------------------
  123.  *
  124.  *   BUST POSITION MIRROR                    // BUST = the plugin command 插件命令
  125.  *                                                                  // POSITION = LEFT or RIGHT 显示位置左/右
  126.  *                                                                  // MIRROR = TRUE or FALSE 是否开启镜像
  127.  *   BUST STATUS                                        // STATUS = TRUE or FALSE 使用/不使用半身像
  128.  *
  129.  *
  130.  * ----------------------------------------------------------------------------
  131.  * 实例:
  132.  * BUST LEFT FALSE    // 左侧显示半身像,非镜像
  133.  * BUST RIGHT TRUE    // 右侧显示半身像,镜像。
  134.  * BUST FALSE         // 不使用半身像,正常显示头像框
  135.  * ----------------------------------------------------------------------------
  136.  *
  137.  * ----------------------------------------------------------------------------
  138.  *   TEXT ESCAPE CODES (During 'Show Tesxt')
  139.  * ----------------------------------------------------------------------------
  140.  *
  141.  * \BST[x]            // 在消息的中途改变半身像。X是不改变脸部名称的脸部号码
  142.  *
  143.  * \BST[x,face]       // 将半身像图像更改为不同的文件名
  144.  *
  145.  * ----------------------------------------------------------------------------
  146.  * 实例:
  147.  * 在“显示文本”事件命令使用“ACTRO1”的3号头像
  148.  * \BST[7]  将继续使用“ACTRO1”头像文件,但将3更改为7
  149.  * \BST[7,Actor2]    将脸部文件更改为“ACTRES2”并使用7号头像
  150.  * ----------------------------------------------------------------------------
  151.  */
  152.  
  153.  
  154. //-----------------------------------------------------------------------------
  155. //  CODE STUFFS
  156. //-----------------------------------------------------------------------------
  157.  
  158. (function() {       
  159.  
  160.         Galv.MB.prio = Number(PluginManager.parameters('Galv_MessageBusts')["Bust Priority"]);
  161.         Galv.MB.pos = Number(PluginManager.parameters('Galv_MessageBusts')["Bust Position"]);
  162.         Galv.MB.w = Number(PluginManager.parameters('Galv_MessageBusts')["Text X Offset"]);
  163.         Galv.MB.f = PluginManager.parameters('Galv_MessageBusts')["Filename Append"];
  164.  
  165.         Galv.MB.fadeOutSpeed = Number(PluginManager.parameters('Galv_MessageBusts')["Fade Out Speed"]);
  166.  
  167.         Galv.MB.msgWindow = null;
  168.  
  169. if (Galv.MB.prio == 1 && Galv.MB.pos == 0) {
  170.         // Fix
  171.         Galv.MB.prio = 0;
  172. };
  173.  
  174. // GALV'S PLUGIN MANAGEMENT. INCLUDED IN ALL GALV PLUGINS THAT HAVE PLUGIN COMMAND CALLS, BUT ONLY RUN ONCE.
  175. if (!Galv.aliased) {
  176.         var Galv_Game_Interpreter_pluginCommand = Game_Interpreter.prototype.pluginCommand;
  177.         Game_Interpreter.prototype.pluginCommand = function(command, args) {
  178.                 if (Galv.pCmd[command]) {
  179.                         Galv.pCmd[command](args);
  180.                         return;
  181.                 };
  182.                 Galv_Game_Interpreter_pluginCommand.call(this, command, args);
  183.         };
  184.         Galv.aliased = true; // Don't keep aliasing for other Galv scripts.
  185. };
  186.  
  187. // Direct to Plugin Object
  188. Galv.pCmd.BUST = function(arguments) {
  189.         Galv.MB.bustPos(arguments);
  190. };
  191. // END GALV'S PLUGIN MANAGEMENT
  192.  
  193. Galv.MB.bustPos = function(pos) {
  194.         if (pos[0] === "TRUE") {
  195.                 return $gameSystem.bustDisable = false;
  196.         } else if (pos[0] === "FALSE") {
  197.                 return $gameSystem.bustDisable = true;
  198.         };
  199.  
  200.         $gameSystem.bustPos = 0
  201.         if (pos[0] === "LEFT") {
  202.                 $gameSystem.bustPos = 0;
  203.         } else if (pos[0] === "RIGHT") {
  204.                 $gameSystem.bustPos = 1;
  205.         };
  206.         if (pos[1] === "TRUE") {
  207.                 $gameSystem.bustMirror = true;
  208.         } else if (pos[1] === "FALSE") {
  209.                 $gameSystem.bustMirror = false;
  210.         };
  211. };
  212.  
  213.  
  214.  
  215. // ---------------- WINDOW MESSAGE
  216.  
  217. Galv.MB.Game_Message_setFaceImage = Game_Message.prototype.setFaceImage;
  218. Game_Message.prototype.setFaceImage = function(faceName, faceIndex) {
  219.         switch (faceName) {
  220.                 case 'PartyLeader':
  221.                         var faceName = $gameParty.leader().faceName();
  222.                         break;
  223.                 case 'PartyMember':
  224.                         if ($gameParty.members()[faceIndex]) {
  225.                                 var faceName = $gameParty.members()[faceIndex].faceName();
  226.                                 var faceIndex = $gameParty.members()[faceIndex].faceIndex();
  227.                         } else {
  228.                                 var faceName = "";
  229.                         };
  230.                         break;
  231.         };
  232.     Galv.MB.Game_Message_setFaceImage.call(this,faceName,faceIndex);
  233. };
  234.  
  235.  
  236. // WINDOW MESSAGE START MESSAGE - MOD
  237. Galv.MB.Window_Message_startMessage = Window_Message.prototype.startMessage;
  238. Window_Message.prototype.startMessage = function() {
  239.         Galv.MB.msgWindow = this;
  240.         $gameSystem.bustPos = $gameSystem.bustPos || 0;
  241.         $gameMessage.bustOffset = $gameMessage.bustOffset || Galv.MB.w;
  242.         Galv.MB.Window_Message_startMessage.call(this);
  243.         Galv.MB.msgWindow.tempPosType = this._positionType;
  244. };
  245.  
  246.  
  247. Galv.MB.Window_Message_processEscapeCharacter = Window_Message.prototype.processEscapeCharacter;
  248. Window_Message.prototype.processEscapeCharacter = function(code, textState) {
  249.     switch (code) {
  250.     case 'BST':
  251.         this.obtainSpecialParam(textState);
  252.         break;
  253.     }
  254.         Galv.MB.Window_Message_processEscapeCharacter.call(this, code, textState);
  255. };
  256.  
  257.  
  258. Window_Message.prototype.obtainSpecialParam = function(textState) {
  259.     var arr = /^\[(.*)]/.exec(textState.text.slice(textState.index));
  260.     if (arr) {
  261.         textState.index += arr[0].length;
  262.         var txt = arr[0].slice(1).slice(0, - 1);
  263.                 var array = txt.split(",");
  264.                 $gameMessage.setFaceImage(array[1] || $gameMessage._faceName,Number(array[0] - 1));
  265.     } else {
  266.         return '';
  267.     }
  268. };
  269.  
  270.  
  271. Galv.MB.Window_Message_drawMessageFace = Window_Message.prototype.drawMessageFace;
  272. Window_Message.prototype.drawMessageFace = function() {
  273.         if (!$gameSystem.bustDisable) return;
  274.         Galv.MB.Window_Message_drawMessageFace.call(this);
  275. };
  276.  
  277. // ---------------- SPRITESET MAP
  278.  
  279. if (Galv.MB.prio == 0) {
  280. // UNDER MESSAGE
  281.         Galv.MB.Spriteset_Map_createUpperLayer = Spriteset_Base.prototype.createUpperLayer;
  282.         Spriteset_Base.prototype.createUpperLayer = function() {
  283.                 Galv.MB.Spriteset_Map_createUpperLayer.call(this);
  284.                 this.createBusts();
  285.         };
  286.  
  287.         // SPRITESET MAP CREATE MSG BG
  288.         Spriteset_Base.prototype.createBusts = function() {
  289.                 // Create bust image
  290.                 if (this._msgBustSprite) return;
  291.                 this._msgBustSprite = new Sprite_GalvBust();
  292.                 this.addChild(this._msgBustSprite);
  293.         };
  294.  
  295.         Galv.MB.Window_Message_newLineX = Window_Message.prototype.newLineX;
  296.         Window_Message.prototype.newLineX = function() {
  297.                 if ($gameSystem.bustDisable) {
  298.                         return Galv.MB.Window_Message_newLineX.call(this);
  299.                 } else {
  300.                         return 0;
  301.                 };
  302.         };
  303.  
  304. } else {
  305. // OVER MESSAGE
  306.  
  307.         // Add to window_message as child instead, so it displays above
  308.         Galv.MB.Window_Message_createSubWindows = Window_Message.prototype.createSubWindows;
  309.         Window_Message.prototype.createSubWindows = function() {
  310.                 Galv.MB.Window_Message_createSubWindows.call(this);
  311.                 if (this._msgBustSprite) return;
  312.                 this._msgBustSprite = new Sprite_GalvBust();
  313.                 this.addChild(this._msgBustSprite);
  314.         };
  315.  
  316.  
  317.         Galv.MB.Window_Message_newLineX = Window_Message.prototype.newLineX;
  318.         Window_Message.prototype.newLineX = function() {
  319.                 if ($gameSystem.bustDisable) {
  320.                         return Galv.MB.Window_Message_newLineX.call(this);
  321.                 } else if ($gameMessage.faceName() && Galv.MB.prio == 1 && $gameMessage._positionType == 2 && $gameSystem.bustPos == 0) {
  322.                         return $gameMessage.bustOffset;
  323.                 } else {
  324.                         return 0;
  325.                 };
  326.         };
  327.  
  328. };
  329.  
  330. })();
  331.  
  332.  
  333. // ---------------- SPRITE GALVMSGBG - NEW
  334.  
  335. function Sprite_GalvBust() {
  336.     this.initialize.apply(this, arguments);
  337. }
  338.  
  339. Sprite_GalvBust.prototype = Object.create(Sprite.prototype);
  340. Sprite_GalvBust.prototype.constructor = Sprite_GalvBust;
  341.  
  342. Sprite_GalvBust.prototype.initialize = function() {
  343.     Sprite.prototype.initialize.call(this);
  344.         this.name = "";
  345.         this.opacity = 0;
  346.     this.update();
  347. };
  348.  
  349. Sprite_GalvBust.prototype.update = function() {
  350.     Sprite.prototype.update.call(this);
  351.     if (Galv.MB.msgWindow) this.controlBitmap();
  352. };
  353.  
  354. Sprite_GalvBust.prototype.loadBitmap = function() {
  355.         var name = $gameMessage.faceName() + "_" + ($gameMessage.faceIndex() + 1);
  356.         if ($gameSystem.bustDisable) {
  357.                 var img = ImageManager.loadPicture('');
  358.         } else {
  359.                 var img = ImageManager.loadPicture(name + Galv.MB.f);
  360.         };
  361.         if (img.isReady()) {
  362.                 if (this.bitmap) {
  363.                         //this._destroyCachedSprite();
  364.                         this.bitmap = null;
  365.                 };
  366.                 this.bitmap = img;
  367.                 this.name = name;
  368.                 this.hasBust = true;
  369.         };
  370. };
  371.  
  372. Sprite_GalvBust.prototype.controlBitmap = function() {
  373.         if ($gameMessage.faceName() && this.name !== $gameMessage.faceName() + "_" + ($gameMessage.faceIndex() + 1)) {
  374.             this.loadBitmap();  // If image changed, reload bitmap
  375.         };
  376.  
  377.         if (Galv.MB.msgWindow.openness <= 0 || !this.hasBust || $gameSystem.bustDisable) {
  378.                 this.opacity = 0;
  379.                 this.name = "";
  380.                 this.hasBust = false;
  381.                 return;
  382.         };
  383.  
  384.         if ($gameSystem.bustMirror) {
  385.                 this.scale.x = -1;
  386.                 var offset = this.bitmap.width;
  387.         } else {
  388.                 this.scale.x = 1;
  389.                 var offset = 0;
  390.         };
  391.  
  392.         this.opacity = $gameMessage.faceName() ? Galv.MB.msgWindow._openness : this.opacity - Galv.MB.fadeOutSpeed;
  393.  
  394.         // Control image position
  395.         switch (Galv.MB.msgWindow.tempPosType) {
  396.         case 0:
  397.                 this.y = this.baseY();
  398.                 break;
  399.         case 1:
  400.         //top and middle
  401.                 this.y =  this.baseY() - Galv.MB.msgWindow.y;
  402.                 break;
  403.         case 2:
  404.         //bottom
  405.                 if (Galv.MB.prio == 1) {
  406.                         this.y = Galv.MB.msgWindow.height - this.bitmap.height;
  407.                 } else if (Galv.MB.pos === 1) {
  408.                         this.y = this.baseY();
  409.                 } else {
  410.                         this.y = this.baseY() - Galv.MB.msgWindow.height;
  411.                 };
  412.                 break;
  413.         };
  414.  
  415.         if ($gameSystem.bustPos == 1) {
  416.                 // if on the right
  417.                 if (Galv.MB.prio == 1) {
  418.                         this.x = Galv.MB.msgWindow.width - this.bitmap.width + offset;
  419.                 } else {
  420.                         this.x = Galv.MB.msgWindow.x + Galv.MB.msgWindow.width - this.bitmap.width + offset;
  421.                 };
  422.         } else {
  423.                 // else on the left
  424.                 if (Galv.MB.prio == 1) {
  425.                         this.x = 0 + offset;
  426.                 } else {
  427.                         this.x = Galv.MB.msgWindow.x + offset;
  428.                 };
  429.         };
  430. };
  431.  
  432. Sprite_GalvBust.prototype.baseY = function() {
  433.         if (Galv.Mstyle.target) {
  434.                 return Galv.MB.msgWindow.y + Galv.MB.msgWindow.height - this.bitmap.height;
  435.         } else {
  436.                 return Graphics.boxHeight - this.bitmap.height;
  437.         };
  438. };
  439.  
  440.  
  441. //-----------------------------------------------------------------------------
  442. //  Galv's Message Busts
  443. //-----------------------------------------------------------------------------
  444. //  For: RPGMAKER MV
  445. //  GALV_MessageBusts.js
  446. //-----------------------------------------------------------------------------
  447. //  2017-11-04 - Version 2.8 - Added fade out speed setting
  448. //  2017-08-21 - Version 2.7 - Fixed a minor bug with appear in front & above
  449. //  2016-10-04 - Version 2.6 - Fixed issue where bust disable/position did not
  450. //                             save in saved games.
  451. //  2016-08-11 - Version 2.5 - Made bust sprite object public
  452. //  2016-08-10 - Version 2.4 - Fixed a crash in MV 1.3 update
  453. //  2016-04-27 - Version 2.3 - Fixed deployment bug with face name case
  454. //  2016-04-22 - Version 2.2 - Fixed a bug with still checking for bust when
  455. //                             Using just faces
  456. //  2016-04-22 - Version 2.1 - Fixed issue with turning busts on/off
  457. //  2016-04-02 - Version 2.0 - Added compatibility for Message Style popups
  458. //  2016-01-12 - Version 1.9 - Fixed issue with middle-aligned textbox
  459. //  2015-12-26 - Version 1.8 - added an option to append text to bust filenames
  460. //                           - to use different images for this and bust menu
  461. //  2015-11-11 - Version 1.7 - fixed text code to change bust mid message.
  462. //                           - (the actor number went to wrong face)
  463. //                           - fixed mid message changing of bust flicker
  464. //  2015-11-11 - Version 1.6 - added Galv plugin command efficiency code
  465. //  2015-11-09 - Version 1.5 - Added ability to display faces/busts based on
  466. //                           - Member position or leader.
  467. //  2015-11-02 - Version 1.4 - Added escape code to change bust during message
  468. //  2015-11-01 - Version 1.3 - fixed bug with bust not disappearing
  469. //  2015-11-01 - Version 1.2 - fixed bug with changing bust
  470. //  2015-11-01 - Version 1.1 - fixed bug with settings
  471. //  2015-11-01 - Version 1.0 - release
  472. //-----------------------------------------------------------------------------
  473. // Terms can be found at:
  474. // galvs-scripts.com
  475. //-----------------------------------------------------------------------------
  476.  
  477. var Imported = Imported || {};
  478. Imported.Galv_MessageBusts = true;
  479.  
  480. var Galv = Galv || {};        // Galv's main object
  481. Galv.pCmd = Galv.pCmd || {};  // Plugin Command manager
  482. Galv.MB = Galv.MB || {};      // Galv's stuff
  483.  
  484. Galv.Mstyle = Galv.Mstyle || {};  // compatibility
  485.  
  486. //-----------------------------------------------------------------------------
  487. /*:
  488.  * @plugindesc (v.2.8) 半身像对话框插件
  489.  *
  490.  * @author Galv - galvs-scripts.com
  491.  *
  492.  * @param Bust Priority
  493.  * @desc 可以用 0 or 1控制.
  494.  * 0 = 半身像显示在对话框后面。 1 = 半身像显示在对话框前面。
  495.  * @default 0
  496.  *
  497.  * @param Bust Position
  498.  * @desc 可以用 0 or 1控制.
  499.  * 0 = 半身像显示在对话框上方. 1 = 半身显示在屏幕底部
  500.  * @default 0
  501.  *
  502.  * @param Text X Offset
  503.  * @desc 当左侧显示半身像时,文本被推到右边的像素数量。
  504.  * @default 390
  505.  *
  506.  * @param Fade Out Speed
  507.  * @desc 半身像消失的速度. 1-255
  508.  * @default 32
  509.  *
  510.  * @param Filename Append
  511.  * @desc 追加插件寻找的正常文件路径的文本。
  512.  * @default
  513.  
  514.  *
  515.  * @help
  516.  *   半身像对话框插件
  517.  * ----------------------------------------------------------------------------
  518.  * This plugin displays a bust image from /img/pictures/ folder based on the
  519.  * face chosen in the 'Show Text' event command.  For example:
  520.  * If your 'Show Text' uses the 2nd face from the "Actor1" faces file, then
  521.  * the plugin will use /img/pictures/Actor1_2.png for the bust image.
  522.  *
  523.  * Remember, all filenames are case sensitive, so make sure to use the correct
  524.  * capitalization/case for your faces and busts.
  525.  *
  526.  * ADDED: A plugin setting called "Filename Append".
  527.  * Whatever you put in this setting will be added to the end of the filename.
  528.  * Using the above example, if the Filename Append setting is "_bust", then the
  529.  * plugin will use /img/pictures/Actor1_2_bust.png instead.
  530.  *
  531.  * Make sure to add 'wait' between messages with different character's busts
  532.  * for better looking transitions.
  533.  * Use the 'Plugin' event command to change bust settings. These settings will
  534.  * be in effect until changed, so they can be used for multiple messages.
  535.  *
  536.  * NOTE: You will need to find your own bust images to use. I can not help
  537.  * you with that. The images in the demo are for demo purposes only.
  538.  *
  539.  * This plugin also comes with the ability to display bust/facesets according
  540.  * to who is in the party or a certain position from the leader's faceset.
  541.  * This works for both the faces and busts.
  542.  *
  543.  * 1. Member's face.
  544.  * Create a face file (or get from demo) called "partymember.png".
  545.  * Number each face in this faceset from 1 to 8.
  546.  * When this face set is used in a "Show Text" event command, it will replace
  547.  * the face with the party member according to the face number used.
  548.  *
  549.  * 1. Leader's face.
  550.  * Create a face file (or get from demo) called "partyleader.png".
  551.  * Label your faces accordingly (for example, happy, sad, laugh. Or numbers)
  552.  * When this face set is used in a "Show Text" event command, it will replace
  553.  * the face with the party leader's faceset and the face number of the chosen
  554.  * face position of the 'partyleader' faceset.
  555.  *
  556.  *
  557.  * 半身像放在/img/pictures文件夹里,对应/img/faces里头像文件名。
  558.  * 半身像文件名和头像名一样,加上后缀_1~_8,对应8个位置头像
  559.  * 例如:半身像/img/pictures/Actor1_1.png对应/img/faces/Actor1.png头像图的第一个头像
  560.  * ----------------------------------------------------------------------------
  561.  *   PLUGIN COMMANDS (To change bust position/visibility)
  562.  * ----------------------------------------------------------------------------
  563.  *
  564.  *   BUST POSITION MIRROR                    // BUST = the plugin command 插件命令
  565.  *                                           // POSITION = LEFT or RIGHT 显示位置左/右
  566.  *                                           // MIRROR = TRUE or FALSE 是否开启镜像
  567.  *   BUST STATUS                             // STATUS = TRUE or FALSE 使用/不使用半身像
  568.  *
  569.  *
  570.  * ----------------------------------------------------------------------------
  571.  * 实例:
  572.  * BUST LEFT FALSE    // 左侧显示半身像,非镜像
  573.  * BUST RIGHT TRUE    // 右侧显示半身像,镜像。
  574.  * BUST FALSE         // 不使用半身像,正常显示头像框
  575.  * ----------------------------------------------------------------------------
  576.  *
  577.  * ----------------------------------------------------------------------------
  578.  *   TEXT ESCAPE CODES (During 'Show Tesxt')
  579.  * ----------------------------------------------------------------------------
  580.  *
  581.  * \BST[x]            // 在消息的中途改变半身像。X是不改变脸部名称的脸部号码
  582.  *
  583.  * \BST[x,face]       // 将半身像图像更改为不同的文件名
  584.  *
  585.  * ----------------------------------------------------------------------------
  586.  * 实例:
  587.  * 在“显示文本”事件命令使用“ACTRO1”的3号头像
  588.  * \BST[7]  将继续使用“ACTRO1”头像文件,但将3更改为7
  589.  * \BST[7,Actor2]    将脸部文件更改为“ACTRES2”并使用7号头像
  590.  * ----------------------------------------------------------------------------
  591.  */
  592.  
  593.  
  594. //-----------------------------------------------------------------------------
  595. //  CODE STUFFS
  596. //-----------------------------------------------------------------------------
  597.  
  598. (function() {       
  599.  
  600.         Galv.MB.prio = Number(PluginManager.parameters('Galv_MessageBusts')["Bust Priority"]);
  601.         Galv.MB.pos = Number(PluginManager.parameters('Galv_MessageBusts')["Bust Position"]);
  602.         Galv.MB.w = Number(PluginManager.parameters('Galv_MessageBusts')["Text X Offset"]);
  603.         Galv.MB.f = PluginManager.parameters('Galv_MessageBusts')["Filename Append"];
  604.  
  605.         Galv.MB.fadeOutSpeed = Number(PluginManager.parameters('Galv_MessageBusts')["Fade Out Speed"]);
  606.  
  607.         Galv.MB.msgWindow = null;
  608.  
  609. if (Galv.MB.prio == 1 && Galv.MB.pos == 0) {
  610.         // Fix
  611.         Galv.MB.prio = 0;
  612. };
  613.  
  614. // GALV'S PLUGIN MANAGEMENT. INCLUDED IN ALL GALV PLUGINS THAT HAVE PLUGIN COMMAND CALLS, BUT ONLY RUN ONCE.
  615. if (!Galv.aliased) {
  616.         var Galv_Game_Interpreter_pluginCommand = Game_Interpreter.prototype.pluginCommand;
  617.         Game_Interpreter.prototype.pluginCommand = function(command, args) {
  618.                 if (Galv.pCmd[command]) {
  619.                         Galv.pCmd[command](args);
  620.                         return;
  621.                 };
  622.                 Galv_Game_Interpreter_pluginCommand.call(this, command, args);
  623.         };
  624.         Galv.aliased = true; // Don't keep aliasing for other Galv scripts.
  625. };
  626.  
  627. // Direct to Plugin Object
  628. Galv.pCmd.BUST = function(arguments) {
  629.         Galv.MB.bustPos(arguments);
  630. };
  631. // END GALV'S PLUGIN MANAGEMENT
  632.  
  633. Galv.MB.bustPos = function(pos) {
  634.         if (pos[0] === "TRUE") {
  635.                 return $gameSystem.bustDisable = false;
  636.         } else if (pos[0] === "FALSE") {
  637.                 return $gameSystem.bustDisable = true;
  638.         };
  639.  
  640.         $gameSystem.bustPos = 0
  641.         if (pos[0] === "LEFT") {
  642.                 $gameSystem.bustPos = 0;
  643.         } else if (pos[0] === "RIGHT") {
  644.                 $gameSystem.bustPos = 1;
  645.         };
  646.         if (pos[1] === "TRUE") {
  647.                 $gameSystem.bustMirror = true;
  648.         } else if (pos[1] === "FALSE") {
  649.                 $gameSystem.bustMirror = false;
  650.         };
  651. };
  652.  
  653.  
  654.  
  655. // ---------------- WINDOW MESSAGE
  656.  
  657. Galv.MB.Game_Message_setFaceImage = Game_Message.prototype.setFaceImage;
  658. Game_Message.prototype.setFaceImage = function(faceName, faceIndex) {
  659.         switch (faceName) {
  660.                 case 'PartyLeader':
  661.                         var faceName = $gameParty.leader().faceName();
  662.                         break;
  663.                 case 'PartyMember':
  664.                         if ($gameParty.members()[faceIndex]) {
  665.                                 var faceName = $gameParty.members()[faceIndex].faceName();
  666.                                 var faceIndex = $gameParty.members()[faceIndex].faceIndex();
  667.                         } else {
  668.                                 var faceName = "";
  669.                         };
  670.                         break;
  671.         };
  672.     Galv.MB.Game_Message_setFaceImage.call(this,faceName,faceIndex);
  673. };
  674.  
  675.  
  676. // WINDOW MESSAGE START MESSAGE - MOD
  677. Galv.MB.Window_Message_startMessage = Window_Message.prototype.startMessage;
  678. Window_Message.prototype.startMessage = function() {
  679.         Galv.MB.msgWindow = this;
  680.         $gameSystem.bustPos = $gameSystem.bustPos || 0;
  681.         $gameMessage.bustOffset = $gameMessage.bustOffset || Galv.MB.w;
  682.         Galv.MB.Window_Message_startMessage.call(this);
  683.         Galv.MB.msgWindow.tempPosType = this._positionType;
  684. };
  685.  
  686.  
  687. Galv.MB.Window_Message_processEscapeCharacter = Window_Message.prototype.processEscapeCharacter;
  688. Window_Message.prototype.processEscapeCharacter = function(code, textState) {
  689.     switch (code) {
  690.     case 'BST':
  691.         this.obtainSpecialParam(textState);
  692.         break;
  693.     }
  694.         Galv.MB.Window_Message_processEscapeCharacter.call(this, code, textState);
  695. };
  696.  
  697.  
  698. Window_Message.prototype.obtainSpecialParam = function(textState) {
  699.     var arr = /^\[(.*)]/.exec(textState.text.slice(textState.index));
  700.     if (arr) {
  701.         textState.index += arr[0].length;
  702.         var txt = arr[0].slice(1).slice(0, - 1);
  703.                 var array = txt.split(",");
  704.                 $gameMessage.setFaceImage(array[1] || $gameMessage._faceName,Number(array[0] - 1));
  705.     } else {
  706.         return '';
  707.     }
  708. };
  709.  
  710.  
  711. Galv.MB.Window_Message_drawMessageFace = Window_Message.prototype.drawMessageFace;
  712. Window_Message.prototype.drawMessageFace = function() {
  713.         if (!$gameSystem.bustDisable) return;
  714.         Galv.MB.Window_Message_drawMessageFace.call(this);
  715. };
  716.  
  717. // ---------------- SPRITESET MAP
  718.  
  719. if (Galv.MB.prio == 0) {
  720. // UNDER MESSAGE
  721.         Galv.MB.Spriteset_Map_createUpperLayer = Spriteset_Base.prototype.createUpperLayer;
  722.         Spriteset_Base.prototype.createUpperLayer = function() {
  723.                 Galv.MB.Spriteset_Map_createUpperLayer.call(this);
  724.                 this.createBusts();
  725.         };
  726.  
  727.         // SPRITESET MAP CREATE MSG BG
  728.         Spriteset_Base.prototype.createBusts = function() {
  729.                 // Create bust image
  730.                 if (this._msgBustSprite) return;
  731.                 this._msgBustSprite = new Sprite_GalvBust();
  732.                 this.addChild(this._msgBustSprite);
  733.         };
  734.  
  735.         Galv.MB.Window_Message_newLineX = Window_Message.prototype.newLineX;
  736.         Window_Message.prototype.newLineX = function() {
  737.                 if ($gameSystem.bustDisable) {
  738.                         return Galv.MB.Window_Message_newLineX.call(this);
  739.                 } else {
  740.                         return 0;
  741.                 };
  742.         };
  743.  
  744. } else {
  745. // OVER MESSAGE
  746.  
  747.         // Add to window_message as child instead, so it displays above
  748.         Galv.MB.Window_Message_createSubWindows = Window_Message.prototype.createSubWindows;
  749.         Window_Message.prototype.createSubWindows = function() {
  750.                 Galv.MB.Window_Message_createSubWindows.call(this);
  751.                 if (this._msgBustSprite) return;
  752.                 this._msgBustSprite = new Sprite_GalvBust();
  753.                 this.addChild(this._msgBustSprite);
  754.         };
  755.  
  756.  
  757.         Galv.MB.Window_Message_newLineX = Window_Message.prototype.newLineX;
  758.         Window_Message.prototype.newLineX = function() {
  759.                 if ($gameSystem.bustDisable) {
  760.                         return Galv.MB.Window_Message_newLineX.call(this);
  761.                 } else if ($gameMessage.faceName() && Galv.MB.prio == 1 && $gameMessage._positionType == 2 && $gameSystem.bustPos == 0) {
  762.                         return $gameMessage.bustOffset;
  763.                 } else {
  764.                         return 0;
  765.                 };
  766.         };
  767.  
  768. };
  769.  
  770. })();
  771.  
  772.  
  773. // ---------------- SPRITE GALVMSGBG - NEW
  774.  
  775. function Sprite_GalvBust() {
  776.     this.initialize.apply(this, arguments);
  777. }
  778.  
  779. Sprite_GalvBust.prototype = Object.create(Sprite.prototype);
  780. Sprite_GalvBust.prototype.constructor = Sprite_GalvBust;
  781.  
  782. Sprite_GalvBust.prototype.initialize = function() {
  783.     Sprite.prototype.initialize.call(this);
  784.         this.name = "";
  785.         this.opacity = 0;
  786.     this.update();
  787. };
  788.  
  789. Sprite_GalvBust.prototype.update = function() {
  790.     Sprite.prototype.update.call(this);
  791.     if (Galv.MB.msgWindow) this.controlBitmap();
  792. };
  793.  
  794. Sprite_GalvBust.prototype.loadBitmap = function() {
  795.         var name = $gameMessage.faceName() + "_" + ($gameMessage.faceIndex() + 1);
  796.         if ($gameSystem.bustDisable) {
  797.                 var img = ImageManager.loadPicture('');
  798.         } else {
  799.                 var img = ImageManager.loadPicture(name + Galv.MB.f);
  800.         };
  801.         if (img.isReady()) {
  802.                 if (this.bitmap) {
  803.                         //this._destroyCachedSprite();
  804.                         this.bitmap = null;
  805.                 };
  806.                 this.bitmap = img;
  807.                 this.name = name;
  808.                 this.hasBust = true;
  809.         };
  810. };
  811.  
  812. Sprite_GalvBust.prototype.controlBitmap = function() {
  813.         if ($gameMessage.faceName() && this.name !== $gameMessage.faceName() + "_" + ($gameMessage.faceIndex() + 1)) {
  814.             this.loadBitmap();  // If image changed, reload bitmap
  815.         };
  816.  
  817.         if (Galv.MB.msgWindow.openness <= 0 || !this.hasBust || $gameSystem.bustDisable) {
  818.                 this.opacity = 0;
  819.                 this.name = "";
  820.                 this.hasBust = false;
  821.                 return;
  822.         };
  823.  
  824.         if ($gameSystem.bustMirror) {
  825.                 this.scale.x = -1;
  826.                 var offset = this.bitmap.width;
  827.         } else {
  828.                 this.scale.x = 1;
  829.                 var offset = 0;
  830.         };
  831.  
  832.         this.opacity = $gameMessage.faceName() ? Galv.MB.msgWindow._openness : this.opacity - Galv.MB.fadeOutSpeed;
  833.  
  834.         // Control image position
  835.         switch (Galv.MB.msgWindow.tempPosType) {
  836.         case 0:
  837.                 this.y = this.baseY();
  838.                 break;
  839.         case 1:
  840.         //top and middle
  841.                 this.y =  this.baseY() - Galv.MB.msgWindow.y;
  842.                 break;
  843.         case 2:
  844.         //bottom
  845.                 if (Galv.MB.prio == 1) {
  846.                         this.y = Galv.MB.msgWindow.height - this.bitmap.height;
  847.                 } else if (Galv.MB.pos === 1) {
  848.                         this.y = this.baseY();
  849.                 } else {
  850.                         this.y = this.baseY() - Galv.MB.msgWindow.height;
  851.                 };
  852.                 break;
  853.         };
  854.  
  855.         if ($gameSystem.bustPos == 1) {
  856.                 // if on the right
  857.                 if (Galv.MB.prio == 1) {
  858.                         this.x = Galv.MB.msgWindow.width - this.bitmap.width + offset;
  859.                 } else {
  860.                         this.x = Galv.MB.msgWindow.x + Galv.MB.msgWindow.width - this.bitmap.width + offset;
  861.                 };
  862.         } else {
  863.                 // else on the left
  864.                 if (Galv.MB.prio == 1) {
  865.                         this.x = 0 + offset;
  866.                 } else {
  867.                         this.x = Galv.MB.msgWindow.x + offset;
  868.                 };
  869.         };
  870. };
  871.  
  872. Sprite_GalvBust.prototype.baseY = function() {
  873.         if (Galv.Mstyle.target) {
  874.                 return Galv.MB.msgWindow.y + Galv.MB.msgWindow.height - this.bitmap.height;
  875.         } else {
  876.                 return Graphics.boxHeight - this.bitmap.height;
  877.         };
  878. };

评分

参与人数 1+1 收起 理由
双叶荆棘 + 1 塞糖

查看全部评分

回复 支持 1 反对 0

使用道具 举报

Lv2.观梦者

梦石
0
星屑
384
在线时间
29 小时
注册时间
2018-6-1
帖子
42
3
 楼主| 发表于 2018-6-9 10:15:25 | 只看该作者
谢谢了。
回复 支持 反对

使用道具 举报

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

本版积分规则

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

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

GMT+8, 2025-1-10 04:40

Powered by Discuz! X3.1

© 2001-2013 Comsenz Inc.

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