查看: 4358|回复: 2

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

[复制链接]
梦石
0
星屑
384
在线时间
29 小时
注册时间
2018-6-1
回帖
34
发表于 2018-6-8 18:09:54 | 显示全部楼层 |阅读模式

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

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

×
MV版本如何在对话中使用半身像?
我本是仅有两片叶子的花,可黑暗的不公使我拥有荆棘
梦石
0
星屑
8201
在线时间
1331 小时
注册时间
2006-7-18
回帖
460
发表于 2018-6-8 19:05:47 | 显示全部楼层
本帖最后由 雷影 于 2018-6-8 20:12 编辑

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

  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. var Imported = Imported || {};
  37. Imported.Galv_MessageBusts = true;

  38. var Galv = Galv || {};        // Galv's main object
  39. Galv.pCmd = Galv.pCmd || {};  // Plugin Command manager
  40. Galv.MB = Galv.MB || {};      // Galv's stuff

  41. Galv.Mstyle = Galv.Mstyle || {};  // compatibility

  42. //-----------------------------------------------------------------------------
  43. /*:
  44. * @plugindesc (v.2.8) 半身像对话框插件
  45. *
  46. * @author Galv - galvs-scripts.com
  47. *
  48. * @param Bust Priority
  49. * @desc 可以用 0 or 1控制.
  50. * 0 = 半身像显示在对话框后面。 1 = 半身像显示在对话框前面。
  51. * @default 0
  52. *
  53. * @param Bust Position
  54. * @desc 可以用 0 or 1控制.
  55. * 0 = 半身像显示在对话框上方. 1 = 半身显示在屏幕底部
  56. * @default 0
  57. *
  58. * @param Text X Offset
  59. * @desc 当左侧显示半身像时,文本被推到右边的像素数量。
  60. * @default 390
  61. *
  62. * @param Fade Out Speed
  63. * @desc 半身像消失的速度. 1-255
  64. * @default 32
  65. *
  66. * @param Filename Append
  67. * @desc 追加插件寻找的正常文件路径的文本。
  68. * @default

  69. *
  70. * @help
  71. *   半身像对话框插件
  72. * ----------------------------------------------------------------------------
  73. * This plugin displays a bust image from /img/pictures/ folder based on the
  74. * face chosen in the 'Show Text' event command.  For example:
  75. * If your 'Show Text' uses the 2nd face from the "Actor1" faces file, then
  76. * the plugin will use /img/pictures/Actor1_2.png for the bust image.
  77. *
  78. * Remember, all filenames are case sensitive, so make sure to use the correct
  79. * capitalization/case for your faces and busts.
  80. *
  81. * ADDED: A plugin setting called "Filename Append".
  82. * Whatever you put in this setting will be added to the end of the filename.
  83. * Using the above example, if the Filename Append setting is "_bust", then the
  84. * plugin will use /img/pictures/Actor1_2_bust.png instead.
  85. *
  86. * Make sure to add 'wait' between messages with different character's busts
  87. * for better looking transitions.
  88. * Use the 'Plugin' event command to change bust settings. These settings will
  89. * be in effect until changed, so they can be used for multiple messages.
  90. *
  91. * NOTE: You will need to find your own bust images to use. I can not help
  92. * you with that. The images in the demo are for demo purposes only.
  93. *
  94. * This plugin also comes with the ability to display bust/facesets according
  95. * to who is in the party or a certain position from the leader's faceset.
  96. * This works for both the faces and busts.
  97. *
  98. * 1. Member's face.
  99. * Create a face file (or get from demo) called "partymember.png".
  100. * Number each face in this faceset from 1 to 8.
  101. * When this face set is used in a "Show Text" event command, it will replace
  102. * the face with the party member according to the face number used.
  103. *
  104. * 1. Leader's face.
  105. * Create a face file (or get from demo) called "partyleader.png".
  106. * Label your faces accordingly (for example, happy, sad, laugh. Or numbers)
  107. * When this face set is used in a "Show Text" event command, it will replace
  108. * the face with the party leader's faceset and the face number of the chosen
  109. * face position of the 'partyleader' faceset.
  110. *
  111. *
  112. * 半身像放在/img/pictures文件夹里,对应/img/faces里头像文件名。
  113. * 半身像文件名和头像名一样,加上后缀_1~_8,对应8个位置头像
  114. * 例如:半身像/img/pictures/Actor1_1.png对应/img/faces/Actor1.png头像图的第一个头像
  115. * ----------------------------------------------------------------------------
  116. *   PLUGIN COMMANDS (To change bust position/visibility)
  117. * ----------------------------------------------------------------------------
  118. *
  119. *   BUST POSITION MIRROR                    // BUST = the plugin command 插件命令
  120. *                                                                  // POSITION = LEFT or RIGHT 显示位置左/右
  121. *                                                                  // MIRROR = TRUE or FALSE 是否开启镜像
  122. *   BUST STATUS                                        // STATUS = TRUE or FALSE 使用/不使用半身像
  123. *
  124. *
  125. * ----------------------------------------------------------------------------
  126. * 实例:
  127. * BUST LEFT FALSE    // 左侧显示半身像,非镜像
  128. * BUST RIGHT TRUE    // 右侧显示半身像,镜像。
  129. * BUST FALSE         // 不使用半身像,正常显示头像框
  130. * ----------------------------------------------------------------------------
  131. *
  132. * ----------------------------------------------------------------------------
  133. *   TEXT ESCAPE CODES (During 'Show Tesxt')
  134. * ----------------------------------------------------------------------------
  135. *
  136. * \BST[x]            // 在消息的中途改变半身像。X是不改变脸部名称的脸部号码
  137. *
  138. * \BST[x,face]       // 将半身像图像更改为不同的文件名
  139. *
  140. * ----------------------------------------------------------------------------
  141. * 实例:
  142. * 在“显示文本”事件命令使用“ACTRO1”的3号头像
  143. * \BST[7]  将继续使用“ACTRO1”头像文件,但将3更改为7
  144. * \BST[7,Actor2]    将脸部文件更改为“ACTRES2”并使用7号头像
  145. * ----------------------------------------------------------------------------
  146. */


  147. //-----------------------------------------------------------------------------
  148. //  CODE STUFFS
  149. //-----------------------------------------------------------------------------

  150. (function() {       

  151.         Galv.MB.prio = Number(PluginManager.parameters('Galv_MessageBusts')["Bust Priority"]);
  152.         Galv.MB.pos = Number(PluginManager.parameters('Galv_MessageBusts')["Bust Position"]);
  153.         Galv.MB.w = Number(PluginManager.parameters('Galv_MessageBusts')["Text X Offset"]);
  154.         Galv.MB.f = PluginManager.parameters('Galv_MessageBusts')["Filename Append"];

  155.         Galv.MB.fadeOutSpeed = Number(PluginManager.parameters('Galv_MessageBusts')["Fade Out Speed"]);
  156.        
  157.         Galv.MB.msgWindow = null;
  158.        
  159. if (Galv.MB.prio == 1 && Galv.MB.pos == 0) {
  160.         // Fix
  161.         Galv.MB.prio = 0;
  162. };
  163.        
  164. // GALV'S PLUGIN MANAGEMENT. INCLUDED IN ALL GALV PLUGINS THAT HAVE PLUGIN COMMAND CALLS, BUT ONLY RUN ONCE.
  165. if (!Galv.aliased) {
  166.         var Galv_Game_Interpreter_pluginCommand = Game_Interpreter.prototype.pluginCommand;
  167.         Game_Interpreter.prototype.pluginCommand = function(command, args) {
  168.                 if (Galv.pCmd[command]) {
  169.                         Galv.pCmd[command](args);
  170.                         return;
  171.                 };
  172.                 Galv_Game_Interpreter_pluginCommand.call(this, command, args);
  173.         };
  174.         Galv.aliased = true; // Don't keep aliasing for other Galv scripts.
  175. };

  176. // Direct to Plugin Object
  177. Galv.pCmd.BUST = function(arguments) {
  178.         Galv.MB.bustPos(arguments);
  179. };
  180. // END GALV'S PLUGIN MANAGEMENT

  181. Galv.MB.bustPos = function(pos) {
  182.         if (pos[0] === "TRUE") {
  183.                 return $gameSystem.bustDisable = false;
  184.         } else if (pos[0] === "FALSE") {
  185.                 return $gameSystem.bustDisable = true;
  186.         };
  187.        
  188.         $gameSystem.bustPos = 0
  189.         if (pos[0] === "LEFT") {
  190.                 $gameSystem.bustPos = 0;
  191.         } else if (pos[0] === "RIGHT") {
  192.                 $gameSystem.bustPos = 1;
  193.         };
  194.         if (pos[1] === "TRUE") {
  195.                 $gameSystem.bustMirror = true;
  196.         } else if (pos[1] === "FALSE") {
  197.                 $gameSystem.bustMirror = false;
  198.         };
  199. };


  200.        
  201. // ---------------- WINDOW MESSAGE

  202. Galv.MB.Game_Message_setFaceImage = Game_Message.prototype.setFaceImage;
  203. Game_Message.prototype.setFaceImage = function(faceName, faceIndex) {
  204.         switch (faceName) {
  205.                 case 'PartyLeader':
  206.                         var faceName = $gameParty.leader().faceName();
  207.                         break;
  208.                 case 'PartyMember':
  209.                         if ($gameParty.members()[faceIndex]) {
  210.                                 var faceName = $gameParty.members()[faceIndex].faceName();
  211.                                 var faceIndex = $gameParty.members()[faceIndex].faceIndex();
  212.                         } else {
  213.                                 var faceName = "";
  214.                         };
  215.                         break;
  216.         };
  217.     Galv.MB.Game_Message_setFaceImage.call(this,faceName,faceIndex);
  218. };


  219. // WINDOW MESSAGE START MESSAGE - MOD
  220. Galv.MB.Window_Message_startMessage = Window_Message.prototype.startMessage;
  221. Window_Message.prototype.startMessage = function() {
  222.         Galv.MB.msgWindow = this;
  223.         $gameSystem.bustPos = $gameSystem.bustPos || 0;
  224.         $gameMessage.bustOffset = $gameMessage.bustOffset || Galv.MB.w;
  225.         Galv.MB.Window_Message_startMessage.call(this);
  226.         Galv.MB.msgWindow.tempPosType = this._positionType;
  227. };


  228. Galv.MB.Window_Message_processEscapeCharacter = Window_Message.prototype.processEscapeCharacter;
  229. Window_Message.prototype.processEscapeCharacter = function(code, textState) {
  230.     switch (code) {
  231.     case 'BST':
  232.         this.obtainSpecialParam(textState);
  233.         break;
  234.     }
  235.         Galv.MB.Window_Message_processEscapeCharacter.call(this, code, textState);
  236. };


  237. Window_Message.prototype.obtainSpecialParam = function(textState) {
  238.     var arr = /^\[(.*)]/.exec(textState.text.slice(textState.index));
  239.     if (arr) {
  240.         textState.index += arr[0].length;
  241.         var txt = arr[0].slice(1).slice(0, - 1);
  242.                 var array = txt.split(",");
  243.                 $gameMessage.setFaceImage(array[1] || $gameMessage._faceName,Number(array[0] - 1));
  244.     } else {
  245.         return '';
  246.     }
  247. };


  248. Galv.MB.Window_Message_drawMessageFace = Window_Message.prototype.drawMessageFace;
  249. Window_Message.prototype.drawMessageFace = function() {
  250.         if (!$gameSystem.bustDisable) return;
  251.         Galv.MB.Window_Message_drawMessageFace.call(this);
  252. };

  253. // ---------------- SPRITESET MAP

  254. if (Galv.MB.prio == 0) {
  255. // UNDER MESSAGE
  256.         Galv.MB.Spriteset_Map_createUpperLayer = Spriteset_Base.prototype.createUpperLayer;
  257.         Spriteset_Base.prototype.createUpperLayer = function() {
  258.                 Galv.MB.Spriteset_Map_createUpperLayer.call(this);
  259.                 this.createBusts();
  260.         };
  261.        
  262.         // SPRITESET MAP CREATE MSG BG
  263.         Spriteset_Base.prototype.createBusts = function() {
  264.                 // Create bust image
  265.                 if (this._msgBustSprite) return;
  266.                 this._msgBustSprite = new Sprite_GalvBust();
  267.                 this.addChild(this._msgBustSprite);
  268.         };
  269.        
  270.         Galv.MB.Window_Message_newLineX = Window_Message.prototype.newLineX;
  271.         Window_Message.prototype.newLineX = function() {
  272.                 if ($gameSystem.bustDisable) {
  273.                         return Galv.MB.Window_Message_newLineX.call(this);
  274.                 } else {
  275.                         return 0;
  276.                 };
  277.         };
  278.        
  279. } else {
  280. // OVER MESSAGE
  281.        
  282.         // Add to window_message as child instead, so it displays above
  283.         Galv.MB.Window_Message_createSubWindows = Window_Message.prototype.createSubWindows;
  284.         Window_Message.prototype.createSubWindows = function() {
  285.                 Galv.MB.Window_Message_createSubWindows.call(this);
  286.                 if (this._msgBustSprite) return;
  287.                 this._msgBustSprite = new Sprite_GalvBust();
  288.                 this.addChild(this._msgBustSprite);
  289.         };
  290.        
  291.        
  292.         Galv.MB.Window_Message_newLineX = Window_Message.prototype.newLineX;
  293.         Window_Message.prototype.newLineX = function() {
  294.                 if ($gameSystem.bustDisable) {
  295.                         return Galv.MB.Window_Message_newLineX.call(this);
  296.                 } else if ($gameMessage.faceName() && Galv.MB.prio == 1 && $gameMessage._positionType == 2 && $gameSystem.bustPos == 0) {
  297.                         return $gameMessage.bustOffset;
  298.                 } else {
  299.                         return 0;
  300.                 };
  301.         };

  302. };

  303. })();


  304. // ---------------- SPRITE GALVMSGBG - NEW

  305. function Sprite_GalvBust() {
  306.     this.initialize.apply(this, arguments);
  307. }

  308. Sprite_GalvBust.prototype = Object.create(Sprite.prototype);
  309. Sprite_GalvBust.prototype.constructor = Sprite_GalvBust;

  310. Sprite_GalvBust.prototype.initialize = function() {
  311.     Sprite.prototype.initialize.call(this);
  312.         this.name = "";
  313.         this.opacity = 0;
  314.     this.update();
  315. };

  316. Sprite_GalvBust.prototype.update = function() {
  317.     Sprite.prototype.update.call(this);
  318.     if (Galv.MB.msgWindow) this.controlBitmap();
  319. };

  320. Sprite_GalvBust.prototype.loadBitmap = function() {
  321.         var name = $gameMessage.faceName() + "_" + ($gameMessage.faceIndex() + 1);
  322.         if ($gameSystem.bustDisable) {
  323.                 var img = ImageManager.loadPicture('');
  324.         } else {
  325.                 var img = ImageManager.loadPicture(name + Galv.MB.f);
  326.         };
  327.         if (img.isReady()) {
  328.                 if (this.bitmap) {
  329.                         //this._destroyCachedSprite();
  330.                         this.bitmap = null;
  331.                 };
  332.                 this.bitmap = img;
  333.                 this.name = name;
  334.                 this.hasBust = true;
  335.         };
  336. };

  337. Sprite_GalvBust.prototype.controlBitmap = function() {
  338.         if ($gameMessage.faceName() && this.name !== $gameMessage.faceName() + "_" + ($gameMessage.faceIndex() + 1)) {
  339.             this.loadBitmap();  // If image changed, reload bitmap
  340.         };
  341.        
  342.         if (Galv.MB.msgWindow.openness <= 0 || !this.hasBust || $gameSystem.bustDisable) {
  343.                 this.opacity = 0;
  344.                 this.name = "";
  345.                 this.hasBust = false;
  346.                 return;
  347.         };

  348.         if ($gameSystem.bustMirror) {
  349.                 this.scale.x = -1;
  350.                 var offset = this.bitmap.width;
  351.         } else {
  352.                 this.scale.x = 1;
  353.                 var offset = 0;
  354.         };

  355.         this.opacity = $gameMessage.faceName() ? Galv.MB.msgWindow._openness : this.opacity - Galv.MB.fadeOutSpeed;
  356.        
  357.         // Control image position
  358.         switch (Galv.MB.msgWindow.tempPosType) {
  359.         case 0:
  360.                 this.y = this.baseY();
  361.                 break;
  362.         case 1:
  363.         //top and middle
  364.                 this.y =  this.baseY() - Galv.MB.msgWindow.y;
  365.                 break;
  366.         case 2:
  367.         //bottom
  368.                 if (Galv.MB.prio == 1) {
  369.                         this.y = Galv.MB.msgWindow.height - this.bitmap.height;
  370.                 } else if (Galv.MB.pos === 1) {
  371.                         this.y = this.baseY();
  372.                 } else {
  373.                         this.y = this.baseY() - Galv.MB.msgWindow.height;
  374.                 };
  375.                 break;
  376.         };
  377.        
  378.         if ($gameSystem.bustPos == 1) {
  379.                 // if on the right
  380.                 if (Galv.MB.prio == 1) {
  381.                         this.x = Galv.MB.msgWindow.width - this.bitmap.width + offset;
  382.                 } else {
  383.                         this.x = Galv.MB.msgWindow.x + Galv.MB.msgWindow.width - this.bitmap.width + offset;
  384.                 };
  385.         } else {
  386.                 // else on the left
  387.                 if (Galv.MB.prio == 1) {
  388.                         this.x = 0 + offset;
  389.                 } else {
  390.                         this.x = Galv.MB.msgWindow.x + offset;
  391.                 };
  392.         };
  393. };

  394. Sprite_GalvBust.prototype.baseY = function() {
  395.         if (Galv.Mstyle.target) {
  396.                 return Galv.MB.msgWindow.y + Galv.MB.msgWindow.height - this.bitmap.height;
  397.         } else {
  398.                 return Graphics.boxHeight - this.bitmap.height;
  399.         };
  400. };


  401. //-----------------------------------------------------------------------------
  402. //  Galv's Message Busts
  403. //-----------------------------------------------------------------------------
  404. //  For: RPGMAKER MV
  405. //  GALV_MessageBusts.js
  406. //-----------------------------------------------------------------------------
  407. //  2017-11-04 - Version 2.8 - Added fade out speed setting
  408. //  2017-08-21 - Version 2.7 - Fixed a minor bug with appear in front & above
  409. //  2016-10-04 - Version 2.6 - Fixed issue where bust disable/position did not
  410. //                             save in saved games.
  411. //  2016-08-11 - Version 2.5 - Made bust sprite object public
  412. //  2016-08-10 - Version 2.4 - Fixed a crash in MV 1.3 update
  413. //  2016-04-27 - Version 2.3 - Fixed deployment bug with face name case
  414. //  2016-04-22 - Version 2.2 - Fixed a bug with still checking for bust when
  415. //                             Using just faces
  416. //  2016-04-22 - Version 2.1 - Fixed issue with turning busts on/off
  417. //  2016-04-02 - Version 2.0 - Added compatibility for Message Style popups
  418. //  2016-01-12 - Version 1.9 - Fixed issue with middle-aligned textbox
  419. //  2015-12-26 - Version 1.8 - added an option to append text to bust filenames
  420. //                           - to use different images for this and bust menu
  421. //  2015-11-11 - Version 1.7 - fixed text code to change bust mid message.
  422. //                           - (the actor number went to wrong face)
  423. //                           - fixed mid message changing of bust flicker
  424. //  2015-11-11 - Version 1.6 - added Galv plugin command efficiency code
  425. //  2015-11-09 - Version 1.5 - Added ability to display faces/busts based on
  426. //                           - Member position or leader.
  427. //  2015-11-02 - Version 1.4 - Added escape code to change bust during message
  428. //  2015-11-01 - Version 1.3 - fixed bug with bust not disappearing
  429. //  2015-11-01 - Version 1.2 - fixed bug with changing bust
  430. //  2015-11-01 - Version 1.1 - fixed bug with settings
  431. //  2015-11-01 - Version 1.0 - release
  432. //-----------------------------------------------------------------------------
  433. // Terms can be found at:
  434. // galvs-scripts.com
  435. //-----------------------------------------------------------------------------

  436. var Imported = Imported || {};
  437. Imported.Galv_MessageBusts = true;

  438. var Galv = Galv || {};        // Galv's main object
  439. Galv.pCmd = Galv.pCmd || {};  // Plugin Command manager
  440. Galv.MB = Galv.MB || {};      // Galv's stuff

  441. Galv.Mstyle = Galv.Mstyle || {};  // compatibility

  442. //-----------------------------------------------------------------------------
  443. /*:
  444. * @plugindesc (v.2.8) 半身像对话框插件
  445. *
  446. * @author Galv - galvs-scripts.com
  447. *
  448. * @param Bust Priority
  449. * @desc 可以用 0 or 1控制.
  450. * 0 = 半身像显示在对话框后面。 1 = 半身像显示在对话框前面。
  451. * @default 0
  452. *
  453. * @param Bust Position
  454. * @desc 可以用 0 or 1控制.
  455. * 0 = 半身像显示在对话框上方. 1 = 半身显示在屏幕底部
  456. * @default 0
  457. *
  458. * @param Text X Offset
  459. * @desc 当左侧显示半身像时,文本被推到右边的像素数量。
  460. * @default 390
  461. *
  462. * @param Fade Out Speed
  463. * @desc 半身像消失的速度. 1-255
  464. * @default 32
  465. *
  466. * @param Filename Append
  467. * @desc 追加插件寻找的正常文件路径的文本。
  468. * @default

  469. *
  470. * @help
  471. *   半身像对话框插件
  472. * ----------------------------------------------------------------------------
  473. * This plugin displays a bust image from /img/pictures/ folder based on the
  474. * face chosen in the 'Show Text' event command.  For example:
  475. * If your 'Show Text' uses the 2nd face from the "Actor1" faces file, then
  476. * the plugin will use /img/pictures/Actor1_2.png for the bust image.
  477. *
  478. * Remember, all filenames are case sensitive, so make sure to use the correct
  479. * capitalization/case for your faces and busts.
  480. *
  481. * ADDED: A plugin setting called "Filename Append".
  482. * Whatever you put in this setting will be added to the end of the filename.
  483. * Using the above example, if the Filename Append setting is "_bust", then the
  484. * plugin will use /img/pictures/Actor1_2_bust.png instead.
  485. *
  486. * Make sure to add 'wait' between messages with different character's busts
  487. * for better looking transitions.
  488. * Use the 'Plugin' event command to change bust settings. These settings will
  489. * be in effect until changed, so they can be used for multiple messages.
  490. *
  491. * NOTE: You will need to find your own bust images to use. I can not help
  492. * you with that. The images in the demo are for demo purposes only.
  493. *
  494. * This plugin also comes with the ability to display bust/facesets according
  495. * to who is in the party or a certain position from the leader's faceset.
  496. * This works for both the faces and busts.
  497. *
  498. * 1. Member's face.
  499. * Create a face file (or get from demo) called "partymember.png".
  500. * Number each face in this faceset from 1 to 8.
  501. * When this face set is used in a "Show Text" event command, it will replace
  502. * the face with the party member according to the face number used.
  503. *
  504. * 1. Leader's face.
  505. * Create a face file (or get from demo) called "partyleader.png".
  506. * Label your faces accordingly (for example, happy, sad, laugh. Or numbers)
  507. * When this face set is used in a "Show Text" event command, it will replace
  508. * the face with the party leader's faceset and the face number of the chosen
  509. * face position of the 'partyleader' faceset.
  510. *
  511. *
  512. * 半身像放在/img/pictures文件夹里,对应/img/faces里头像文件名。
  513. * 半身像文件名和头像名一样,加上后缀_1~_8,对应8个位置头像
  514. * 例如:半身像/img/pictures/Actor1_1.png对应/img/faces/Actor1.png头像图的第一个头像
  515. * ----------------------------------------------------------------------------
  516. *   PLUGIN COMMANDS (To change bust position/visibility)
  517. * ----------------------------------------------------------------------------
  518. *
  519. *   BUST POSITION MIRROR                    // BUST = the plugin command 插件命令
  520. *                                           // POSITION = LEFT or RIGHT 显示位置左/右
  521. *                                           // MIRROR = TRUE or FALSE 是否开启镜像
  522. *   BUST STATUS                             // STATUS = TRUE or FALSE 使用/不使用半身像
  523. *
  524. *
  525. * ----------------------------------------------------------------------------
  526. * 实例:
  527. * BUST LEFT FALSE    // 左侧显示半身像,非镜像
  528. * BUST RIGHT TRUE    // 右侧显示半身像,镜像。
  529. * BUST FALSE         // 不使用半身像,正常显示头像框
  530. * ----------------------------------------------------------------------------
  531. *
  532. * ----------------------------------------------------------------------------
  533. *   TEXT ESCAPE CODES (During 'Show Tesxt')
  534. * ----------------------------------------------------------------------------
  535. *
  536. * \BST[x]            // 在消息的中途改变半身像。X是不改变脸部名称的脸部号码
  537. *
  538. * \BST[x,face]       // 将半身像图像更改为不同的文件名
  539. *
  540. * ----------------------------------------------------------------------------
  541. * 实例:
  542. * 在“显示文本”事件命令使用“ACTRO1”的3号头像
  543. * \BST[7]  将继续使用“ACTRO1”头像文件,但将3更改为7
  544. * \BST[7,Actor2]    将脸部文件更改为“ACTRES2”并使用7号头像
  545. * ----------------------------------------------------------------------------
  546. */


  547. //-----------------------------------------------------------------------------
  548. //  CODE STUFFS
  549. //-----------------------------------------------------------------------------

  550. (function() {       

  551.         Galv.MB.prio = Number(PluginManager.parameters('Galv_MessageBusts')["Bust Priority"]);
  552.         Galv.MB.pos = Number(PluginManager.parameters('Galv_MessageBusts')["Bust Position"]);
  553.         Galv.MB.w = Number(PluginManager.parameters('Galv_MessageBusts')["Text X Offset"]);
  554.         Galv.MB.f = PluginManager.parameters('Galv_MessageBusts')["Filename Append"];

  555.         Galv.MB.fadeOutSpeed = Number(PluginManager.parameters('Galv_MessageBusts')["Fade Out Speed"]);
  556.        
  557.         Galv.MB.msgWindow = null;
  558.        
  559. if (Galv.MB.prio == 1 && Galv.MB.pos == 0) {
  560.         // Fix
  561.         Galv.MB.prio = 0;
  562. };
  563.        
  564. // GALV'S PLUGIN MANAGEMENT. INCLUDED IN ALL GALV PLUGINS THAT HAVE PLUGIN COMMAND CALLS, BUT ONLY RUN ONCE.
  565. if (!Galv.aliased) {
  566.         var Galv_Game_Interpreter_pluginCommand = Game_Interpreter.prototype.pluginCommand;
  567.         Game_Interpreter.prototype.pluginCommand = function(command, args) {
  568.                 if (Galv.pCmd[command]) {
  569.                         Galv.pCmd[command](args);
  570.                         return;
  571.                 };
  572.                 Galv_Game_Interpreter_pluginCommand.call(this, command, args);
  573.         };
  574.         Galv.aliased = true; // Don't keep aliasing for other Galv scripts.
  575. };

  576. // Direct to Plugin Object
  577. Galv.pCmd.BUST = function(arguments) {
  578.         Galv.MB.bustPos(arguments);
  579. };
  580. // END GALV'S PLUGIN MANAGEMENT

  581. Galv.MB.bustPos = function(pos) {
  582.         if (pos[0] === "TRUE") {
  583.                 return $gameSystem.bustDisable = false;
  584.         } else if (pos[0] === "FALSE") {
  585.                 return $gameSystem.bustDisable = true;
  586.         };
  587.        
  588.         $gameSystem.bustPos = 0
  589.         if (pos[0] === "LEFT") {
  590.                 $gameSystem.bustPos = 0;
  591.         } else if (pos[0] === "RIGHT") {
  592.                 $gameSystem.bustPos = 1;
  593.         };
  594.         if (pos[1] === "TRUE") {
  595.                 $gameSystem.bustMirror = true;
  596.         } else if (pos[1] === "FALSE") {
  597.                 $gameSystem.bustMirror = false;
  598.         };
  599. };


  600.        
  601. // ---------------- WINDOW MESSAGE

  602. Galv.MB.Game_Message_setFaceImage = Game_Message.prototype.setFaceImage;
  603. Game_Message.prototype.setFaceImage = function(faceName, faceIndex) {
  604.         switch (faceName) {
  605.                 case 'PartyLeader':
  606.                         var faceName = $gameParty.leader().faceName();
  607.                         break;
  608.                 case 'PartyMember':
  609.                         if ($gameParty.members()[faceIndex]) {
  610.                                 var faceName = $gameParty.members()[faceIndex].faceName();
  611.                                 var faceIndex = $gameParty.members()[faceIndex].faceIndex();
  612.                         } else {
  613.                                 var faceName = "";
  614.                         };
  615.                         break;
  616.         };
  617.     Galv.MB.Game_Message_setFaceImage.call(this,faceName,faceIndex);
  618. };


  619. // WINDOW MESSAGE START MESSAGE - MOD
  620. Galv.MB.Window_Message_startMessage = Window_Message.prototype.startMessage;
  621. Window_Message.prototype.startMessage = function() {
  622.         Galv.MB.msgWindow = this;
  623.         $gameSystem.bustPos = $gameSystem.bustPos || 0;
  624.         $gameMessage.bustOffset = $gameMessage.bustOffset || Galv.MB.w;
  625.         Galv.MB.Window_Message_startMessage.call(this);
  626.         Galv.MB.msgWindow.tempPosType = this._positionType;
  627. };


  628. Galv.MB.Window_Message_processEscapeCharacter = Window_Message.prototype.processEscapeCharacter;
  629. Window_Message.prototype.processEscapeCharacter = function(code, textState) {
  630.     switch (code) {
  631.     case 'BST':
  632.         this.obtainSpecialParam(textState);
  633.         break;
  634.     }
  635.         Galv.MB.Window_Message_processEscapeCharacter.call(this, code, textState);
  636. };


  637. Window_Message.prototype.obtainSpecialParam = function(textState) {
  638.     var arr = /^\[(.*)]/.exec(textState.text.slice(textState.index));
  639.     if (arr) {
  640.         textState.index += arr[0].length;
  641.         var txt = arr[0].slice(1).slice(0, - 1);
  642.                 var array = txt.split(",");
  643.                 $gameMessage.setFaceImage(array[1] || $gameMessage._faceName,Number(array[0] - 1));
  644.     } else {
  645.         return '';
  646.     }
  647. };


  648. Galv.MB.Window_Message_drawMessageFace = Window_Message.prototype.drawMessageFace;
  649. Window_Message.prototype.drawMessageFace = function() {
  650.         if (!$gameSystem.bustDisable) return;
  651.         Galv.MB.Window_Message_drawMessageFace.call(this);
  652. };

  653. // ---------------- SPRITESET MAP

  654. if (Galv.MB.prio == 0) {
  655. // UNDER MESSAGE
  656.         Galv.MB.Spriteset_Map_createUpperLayer = Spriteset_Base.prototype.createUpperLayer;
  657.         Spriteset_Base.prototype.createUpperLayer = function() {
  658.                 Galv.MB.Spriteset_Map_createUpperLayer.call(this);
  659.                 this.createBusts();
  660.         };
  661.        
  662.         // SPRITESET MAP CREATE MSG BG
  663.         Spriteset_Base.prototype.createBusts = function() {
  664.                 // Create bust image
  665.                 if (this._msgBustSprite) return;
  666.                 this._msgBustSprite = new Sprite_GalvBust();
  667.                 this.addChild(this._msgBustSprite);
  668.         };
  669.        
  670.         Galv.MB.Window_Message_newLineX = Window_Message.prototype.newLineX;
  671.         Window_Message.prototype.newLineX = function() {
  672.                 if ($gameSystem.bustDisable) {
  673.                         return Galv.MB.Window_Message_newLineX.call(this);
  674.                 } else {
  675.                         return 0;
  676.                 };
  677.         };
  678.        
  679. } else {
  680. // OVER MESSAGE
  681.        
  682.         // Add to window_message as child instead, so it displays above
  683.         Galv.MB.Window_Message_createSubWindows = Window_Message.prototype.createSubWindows;
  684.         Window_Message.prototype.createSubWindows = function() {
  685.                 Galv.MB.Window_Message_createSubWindows.call(this);
  686.                 if (this._msgBustSprite) return;
  687.                 this._msgBustSprite = new Sprite_GalvBust();
  688.                 this.addChild(this._msgBustSprite);
  689.         };
  690.        
  691.        
  692.         Galv.MB.Window_Message_newLineX = Window_Message.prototype.newLineX;
  693.         Window_Message.prototype.newLineX = function() {
  694.                 if ($gameSystem.bustDisable) {
  695.                         return Galv.MB.Window_Message_newLineX.call(this);
  696.                 } else if ($gameMessage.faceName() && Galv.MB.prio == 1 && $gameMessage._positionType == 2 && $gameSystem.bustPos == 0) {
  697.                         return $gameMessage.bustOffset;
  698.                 } else {
  699.                         return 0;
  700.                 };
  701.         };

  702. };

  703. })();


  704. // ---------------- SPRITE GALVMSGBG - NEW

  705. function Sprite_GalvBust() {
  706.     this.initialize.apply(this, arguments);
  707. }

  708. Sprite_GalvBust.prototype = Object.create(Sprite.prototype);
  709. Sprite_GalvBust.prototype.constructor = Sprite_GalvBust;

  710. Sprite_GalvBust.prototype.initialize = function() {
  711.     Sprite.prototype.initialize.call(this);
  712.         this.name = "";
  713.         this.opacity = 0;
  714.     this.update();
  715. };

  716. Sprite_GalvBust.prototype.update = function() {
  717.     Sprite.prototype.update.call(this);
  718.     if (Galv.MB.msgWindow) this.controlBitmap();
  719. };

  720. Sprite_GalvBust.prototype.loadBitmap = function() {
  721.         var name = $gameMessage.faceName() + "_" + ($gameMessage.faceIndex() + 1);
  722.         if ($gameSystem.bustDisable) {
  723.                 var img = ImageManager.loadPicture('');
  724.         } else {
  725.                 var img = ImageManager.loadPicture(name + Galv.MB.f);
  726.         };
  727.         if (img.isReady()) {
  728.                 if (this.bitmap) {
  729.                         //this._destroyCachedSprite();
  730.                         this.bitmap = null;
  731.                 };
  732.                 this.bitmap = img;
  733.                 this.name = name;
  734.                 this.hasBust = true;
  735.         };
  736. };

  737. Sprite_GalvBust.prototype.controlBitmap = function() {
  738.         if ($gameMessage.faceName() && this.name !== $gameMessage.faceName() + "_" + ($gameMessage.faceIndex() + 1)) {
  739.             this.loadBitmap();  // If image changed, reload bitmap
  740.         };
  741.        
  742.         if (Galv.MB.msgWindow.openness <= 0 || !this.hasBust || $gameSystem.bustDisable) {
  743.                 this.opacity = 0;
  744.                 this.name = "";
  745.                 this.hasBust = false;
  746.                 return;
  747.         };

  748.         if ($gameSystem.bustMirror) {
  749.                 this.scale.x = -1;
  750.                 var offset = this.bitmap.width;
  751.         } else {
  752.                 this.scale.x = 1;
  753.                 var offset = 0;
  754.         };

  755.         this.opacity = $gameMessage.faceName() ? Galv.MB.msgWindow._openness : this.opacity - Galv.MB.fadeOutSpeed;
  756.        
  757.         // Control image position
  758.         switch (Galv.MB.msgWindow.tempPosType) {
  759.         case 0:
  760.                 this.y = this.baseY();
  761.                 break;
  762.         case 1:
  763.         //top and middle
  764.                 this.y =  this.baseY() - Galv.MB.msgWindow.y;
  765.                 break;
  766.         case 2:
  767.         //bottom
  768.                 if (Galv.MB.prio == 1) {
  769.                         this.y = Galv.MB.msgWindow.height - this.bitmap.height;
  770.                 } else if (Galv.MB.pos === 1) {
  771.                         this.y = this.baseY();
  772.                 } else {
  773.                         this.y = this.baseY() - Galv.MB.msgWindow.height;
  774.                 };
  775.                 break;
  776.         };
  777.        
  778.         if ($gameSystem.bustPos == 1) {
  779.                 // if on the right
  780.                 if (Galv.MB.prio == 1) {
  781.                         this.x = Galv.MB.msgWindow.width - this.bitmap.width + offset;
  782.                 } else {
  783.                         this.x = Galv.MB.msgWindow.x + Galv.MB.msgWindow.width - this.bitmap.width + offset;
  784.                 };
  785.         } else {
  786.                 // else on the left
  787.                 if (Galv.MB.prio == 1) {
  788.                         this.x = 0 + offset;
  789.                 } else {
  790.                         this.x = Galv.MB.msgWindow.x + offset;
  791.                 };
  792.         };
  793. };

  794. Sprite_GalvBust.prototype.baseY = function() {
  795.         if (Galv.Mstyle.target) {
  796.                 return Galv.MB.msgWindow.y + Galv.MB.msgWindow.height - this.bitmap.height;
  797.         } else {
  798.                 return Graphics.boxHeight - this.bitmap.height;
  799.         };
  800. };


复制代码

评分

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

查看全部评分

回复 1 0

使用道具 举报

梦石
0
星屑
384
在线时间
29 小时
注册时间
2018-6-1
回帖
34
 楼主| 发表于 2018-6-9 10:15:25 | 显示全部楼层
谢谢了。
回复

使用道具 举报

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

本版积分规则

Powered by Discuz! X5.0 © 2001-2026 Discuz! Team.

在本版发帖返回顶部