查看: 6840|回复: 9

[交流讨论] 視状態換立繪/行走圖的插件

[复制链接]
梦石
0
星屑
22879
在线时间
8598 小时
注册时间
2011-12-31
回帖
3270
发表于 2021-7-17 15:15:36 | 显示全部楼层 |阅读模式

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

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

×
本帖最后由 tseyik 于 2021-7-18 14:04 编辑

MⅠT
RPGMakerMV-mz_master.zip (10.4 KB, 下载次数: 265)
内含
CharacterPictureManager.js    立繪管理插件
可以設定HP上升下降換衣服
CharacterGraphicManager.js   行走圖管理插件
可以設定降換行走圖
CharacterPictureManager.js
  1. //=============================================================================
  2. // CharacterPictureManager.js
  3. // ----------------------------------------------------------------------------
  4. // (C)2016 Triacontane
  5. // This software is released under the MIT License.
  6. // [url]http://opensource.org/licenses/mit-license.php[/url]
  7. // ----------------------------------------------------------------------------
  8. // Version
  9. // 2.4.1 2021/05/28 2.3.2の修正によりAPNGピクチャプラグインと連携するとAPNGピクチャ以外が立ち絵として表示できなくなっていた問題を修正
  10. // 2.4.0 2021/05/20 立ち絵の座標に制御文字を使ったとき、変数の変更が即座に反映されるよう修正
  11. // 2.3.2 2021/04/26 ヘルプの記述を修正
  12. //                  APNGピクチャプラグインとの連携でGIFファイルを使用できなかった問題を修正
  13. // 2.3.1 2021/04/06 拡大率をシーン単位で設定できる機能を追加
  14. // 2.3.0 2021/04/06 立ち絵に拡大率を設定できる機能を追加
  15. // 2.2.2 2021/02/15 アクター登録していないメンバーを表示させようとするとエラーになる問題を修正
  16. // 2.2.1 2021/02/14 パラメータの防具条件のデータベースタイプが武器になっていた問題を修正
  17. // 2.2.0 2021/02/14 スプライトシート形式の表示に対応
  18. //                  ドラッグ機能をベースごと動かせるように修正
  19. // 2.1.0 2021/02/14 立ち絵をドラッグして座標の確認と調整ができる機能を追加
  20. // 2.0.0 2021/02/12 MZ向けに仕様から再設計
  21. // 1.0.0 2016/05/01 タクポンさん依頼版
  22. // ----------------------------------------------------------------------------
  23. // [Blog]   : [url]https://triacontane.blogspot.jp/[/url]
  24. // [Twitter]: [url]https://twitter.com/triacontane/[/url]
  25. // [GitHub] : [url]https://github.com/triacontane/[/url]
  26. //=============================================================================

  27. /*:
  28. * @plugindesc 立ち絵表示管理プラグイン
  29. * @target MZ
  30. * @url [url]https://github.com/triacontane/RPGMakerMV/tree/mz_master/CharacterPictureManager.js[/url]
  31. * @base PluginCommonBase
  32. * @author トリアコンタン
  33. *
  34. * @param PictureList
  35. * @text 立ち絵リスト
  36. * @desc アクターごとの立ち絵リストです。ひとりのアクターに対して複数の画像を重ねて表示できます。(リストの下が手前に表示)
  37. * @default []
  38. * @type struct<StandPictureActor>[]
  39. *
  40. * @param SceneList
  41. * @text 表示対象シーンリスト
  42. * @desc 立ち絵を表示したいシーンのリストです。シーンごとに基準座標を設定します。
  43. * @default ["{"SceneName":"Scene_Title","MemberPosition":"[\\"{\\\\\\"X\\\\\\":\\\\\\"0\\\\\\",\\\\\\"Y\\\\\\":\\\\\\"0\\\\\\"}\\",\\"{\\\\\\"X\\\\\\":\\\\\\"150\\\\\\",\\\\\\"Y\\\\\\":\\\\\\"0\\\\\\"}\\",\\"{\\\\\\"X\\\\\\":\\\\\\"300\\\\\\",\\\\\\"Y\\\\\\":\\\\\\"0\\\\\\"}\\",\\"{\\\\\\"X\\\\\\":\\\\\\"450\\\\\\",\\\\\\"Y\\\\\\":\\\\\\"0\\\\\\"}\\"]","ScaleX":"100","ScaleY":"100","ShowPictureSwitch":"0","Mirror":"false","Priority":"0"}"]
  44. * @type struct<Scene>[]
  45. *
  46. * @param Origin
  47. * @text 原点
  48. * @desc 立ち絵画像の原点です。全画像で共通の設定です。
  49. * @default 0
  50. * @type select
  51. * @option 左上
  52. * @value 0
  53. * @option 中央
  54. * @value 1
  55. * @option 中央下
  56. * @value 2
  57. *
  58. * @param UsePointAdjust
  59. * @text 座標調整機能を使う
  60. * @desc 有効にすると、テストプレー時に立ち絵をドラッグすることで座標を調整する機能が使えます。
  61. * @default true
  62. * @type boolean
  63. *
  64. * @help CharacterPictureManager.js
  65. *
  66. * 複数の画像から構成される立ち絵を管理、表示できます。
  67. * プラグインパラメータから画像と表示条件、表示したいシーンを登録します。
  68. * 以下の特徴があります。
  69. * ・HP残量やステート、装備、職業、スイッチなど条件に応じた立ち絵の変化
  70. * ・戦闘中は行動時、ダメージ時など戦況に応じた画像の切り替え
  71. * ・複数の画像を使った衣装差分や表情差分の作成
  72. * ・同一の立ち絵を戦闘画面、メニュー画面、マップ画面で使い回しが可能
  73. *
  74. * また、別途公開しているAPNGピクチャプラグインと組み合わせると
  75. * 立ち絵をアニメーションできます。ただし、使いすぎに注意してください。
  76. *
  77. * ●メモ欄条件に指定方法
  78. * 表示条件のメモ欄に『aaa』と指定した場合、対象アクターのデータベース(※)に
  79. * 以下のメモ欄が含まれているときに立ち絵が表示されます。
  80. * <StandPicture:aaa>
  81. * ※アクター、職業、武器、防具、ステートが該当
  82. *
  83. * ●画像の座標指定支援機能
  84. * テストプレー時のみ、立ち絵をドラッグすることで座標の確認、調整ができます。
  85. * 画面上に現在の基準座標と固有座標が表示されます。
  86. * Ctrlキーを押していると奥の画像が、押していないと手前の画像が選択されます。
  87. * Shiftキーを押していると基準座標を、押していないと固有座標を調整します。
  88. * Ctrl+Enterで調整した画像がすべて元の位置に戻ります。
  89. *
  90. * ●立ち絵ファイルの動的設定(上級者向け)
  91. * 立ち絵を大量に使いたい場合にファイル名を命名規則に従って動的に決定できます。
  92. * ファイルが存在しないとエラーになること、未使用ファイルの自動削除機能で
  93. * ファイルが削除される場合があるので上級者向けです。
  94. * 以下の規則に従ってファイル名が変換されます。
  95. *
  96. * {hp:40,60,80}
  97. * HPレートが指定した閾値に従ってインデックスに変換されます。
  98. * 上記の例では以下の数値に変換されます。
  99. *   0%-39% のとき:0
  100. *  40%-59% のとき:1
  101. *  60%-80% のとき:2
  102. *  80%-100%のとき:3
  103. *
  104. * {stateId}
  105. *  もっとも優先度の高いステートIDに変換されます。
  106. *  ただしステートのメモ欄に<NoStandPicture>と記述すると対象外になります。
  107. *
  108. * {switch:3}
  109. *  スイッチ[3]がONのとき[1]に、OFFのとき[0]に変換されます。
  110. *
  111. * {variable:4}
  112. *  変数[4]の値に変換されます。
  113. *
  114. * {action}
  115. *  行動中のとき[1]に、そうでないときに[0]に変換されます。
  116. *
  117. * {damage}
  118. *  被ダメージ時に[1]に、そうでないときに[0]に変換されます。
  119. *
  120. * {note}
  121. *  データベースのメモ欄の<StandPicture>で指定した値に変換されます。
  122. *  <StandPicture:aaa>と記述するとaaaに変換されます。
  123. *  アクター、職業、武器、防具、ステートのメモ欄が対象です。
  124. *
  125. * このプラグインの利用にはベースプラグイン『PluginCommonBase.js』が必要です。
  126. * 『PluginCommonBase.js』は、RPGツクールMZのインストールフォルダ配下の
  127. * 以下のフォルダに格納されています。
  128. * dlc/BasicResources/plugins/official
  129. *
  130. * 利用規約:
  131. *  作者に無断で改変、再配布が可能で、利用形態(商用、18禁利用等)
  132. *  についても制限はありません。
  133. *  このプラグインはもうあなたのものです。
  134. */

  135. /*~struct~StandPictureActor:
  136. *
  137. * @param ActorId
  138. * @text アクター
  139. * @desc 立ち絵を表示する対象のアクターです。
  140. * @default 1
  141. * @type actor
  142. *
  143. * @param Name
  144. * @text 名称
  145. * @desc 区別するための名称です。プラグイン上は特に意味はありません。
  146. * @default
  147. *
  148. * @param Opacity
  149. * @text 不透明度
  150. * @desc 立ち絵の不透明度です。
  151. * @default 255
  152. * @type number
  153. * @max 255
  154. *
  155. * @param X
  156. * @text 固有X座標
  157. * @desc 立ち絵のX座標です。シーンごとの基準座標を加算した値が実際の表示座標です。
  158. * @default 0
  159. * @type number
  160. * @min -9999
  161. * @max 9999
  162. *
  163. * @param Y
  164. * @text 固有Y座標
  165. * @desc 立ち絵のY座標です。シーンごとの基準座標を加算した値が実際の表示座標です。
  166. * @default 0
  167. * @type number
  168. * @min -9999
  169. * @max 9999
  170. *
  171. * @param ScaleX
  172. * @text X拡大率
  173. * @desc 立ち絵の横方向の拡大率です。
  174. * @default 100
  175. * @type number
  176. * @max 1000
  177. *
  178. * @param ScaleY
  179. * @text Y拡大率
  180. * @desc 立ち絵の縦方向の拡大率です。
  181. * @default 100
  182. * @type number
  183. * @max 1000
  184. *
  185. * @param SpriteSheet
  186. * @text スプライトシート
  187. * @desc 立ち絵の画像をスプライトシートから取得したい場合に指定します。
  188. * @type struct<SpriteSheet>

  189. * @param FileList
  190. * @text 立ち絵リスト
  191. * @desc 表示する立ち絵と条件のリストです。条件を満たした立ち絵が1枚だけ(リストの下が優先)表示されます。
  192. * @default []
  193. * @type struct<StandPicture>[]
  194. *
  195. * @param DynamicFileName
  196. * @text 動的ファイル名
  197. * @desc 立ち絵ファイル名を動的に生成します。立ち絵リストに条件を満たしたファイルがあればそちらが優先されます。
  198. * @default
  199. * @type combo
  200. * @option image_{hp:40,60,80}
  201. * @option image_{stateId}
  202. * @option image_{switch:1}
  203. * @option image_{variable:1}
  204. * @option image_{damage}
  205. * @option image_{action}
  206. * @option image_{note}
  207. */

  208. /*~struct~StandPicture:
  209. *
  210. * @param FileName
  211. * @text ファイル名
  212. * @desc 立ち絵のファイル名です。
  213. * @default
  214. * @type file
  215. * @dir img/pictures
  216. *
  217. * @param HpUpperLimit
  218. * @text HP条件(上限)
  219. * @desc HP割合が指定値以下の場合に表示条件を満たします。0を指定すると条件判定を行いません。
  220. * @default 0
  221. * @type number
  222. * @max 100
  223. * @min 0
  224. *
  225. * @param HpLowerLimit
  226. * @text HP条件(下限)
  227. * @desc HP割合が指定値以上の場合に表示条件を満たします。0を指定すると条件判定を行いません。
  228. * @default 0
  229. * @type number
  230. * @max 100
  231. * @min 0
  232. *
  233. * @param Action
  234. * @text 行動中条件
  235. * @desc アクターが行動中の場合に表示条件を満たします。
  236. * @default false
  237. * @type boolean
  238. *
  239. * @param Damage
  240. * @text ダメージ条件
  241. * @desc アクターがダメージを受けている場合に表示条件を満たします。
  242. * @default false
  243. * @type boolean
  244. *
  245. * @param State
  246. * @text ステート条件
  247. * @desc 指定したステートが有効な場合に表示条件を満たします。0を指定すると条件判定を行いません。
  248. * @default 0
  249. * @type state
  250. *
  251. * @param Weapon
  252. * @text 武器条件
  253. * @desc 指定した武器を装備している場合に表示条件を満たします。0を指定すると条件判定を行いません。
  254. * @default 0
  255. * @type weapon
  256. *
  257. * @param Armor
  258. * @text 防具条件
  259. * @desc 指定した防具を装備している場合に表示条件を満たします。0を指定すると条件判定を行いません。
  260. * @default 0
  261. * @type armor
  262. *
  263. * @param Note
  264. * @text メモ欄条件
  265. * @desc データベースのメモ欄<StandPicture:aaa>が指定値と等しい場合に表示条件を満たします。
  266. * @default
  267. *
  268. * @param Switch
  269. * @text スイッチ条件
  270. * @desc 指定したスイッチがONの場合に表示条件を満たします。0を指定すると条件判定を行いません。
  271. * @default 0
  272. * @type switch
  273. *
  274. * @param Script
  275. * @text スクリプト条件
  276. * @desc 指定したスクリプトがtrueを返した場合に表示条件を満たします。aでアクターオブジェクトを参照できます。
  277. * @default
  278. * @type combo
  279. * @option a.mpRate() < 0.5; // MPが50%以下
  280. * @option a.tpRate() < 0.5; // TPが50%以下
  281. *
  282. */

  283. /*~struct~Scene:
  284. *
  285. * @param SceneName
  286. * @text 対象シーン
  287. * @desc 表示対象のシーンです。オリジナルのシーンを対象にする場合はシーンクラス名を直接記入します。
  288. * @type select
  289. * @default Scene_Battle
  290. * @option タイトル
  291. * @value Scene_Title
  292. * @option マップ
  293. * @value Scene_Map
  294. * @option ゲームオーバー
  295. * @value Scene_Gameover
  296. * @option バトル
  297. * @value Scene_Battle
  298. * @option メインメニュー
  299. * @value Scene_Menu
  300. * @option アイテム
  301. * @value Scene_Item
  302. * @option スキル
  303. * @value Scene_Skill
  304. * @option 装備
  305. * @value Scene_Equip
  306. * @option ステータス
  307. * @value Scene_Status
  308. * @option オプション
  309. * @value Scene_Options
  310. * @option セーブ
  311. * @value Scene_Save
  312. * @option ロード
  313. * @value Scene_Load
  314. * @option ゲーム終了
  315. * @value Scene_End
  316. * @option ショップ
  317. * @value Scene_Shop
  318. * @option 名前入力
  319. * @value Scene_Name
  320. * @option デバッグ
  321. * @value Scene_Debug
  322. *
  323. * @param MemberPosition
  324. * @text メンバーごとの基準座標
  325. * @desc メンバーごとの立ち絵の基準座標です。パーティメンバーのぶんだけ登録します。
  326. * @default ["{"X":"0","Y":"0"}","{"X":"150","Y":"0"}","{"X":"300","Y":"0"}","{"X":"450","Y":"0"}"]
  327. * @type struct<Position>[]
  328. *
  329. * @param ScaleX
  330. * @text X拡大率
  331. * @desc 立ち絵の横方向の拡大率です。
  332. * @default 100
  333. * @type number
  334. * @max 1000
  335. *
  336. * @param ScaleY
  337. * @text Y拡大率
  338. * @desc 立ち絵の縦方向の拡大率です。
  339. * @default 100
  340. * @type number
  341. * @max 1000
  342. *
  343. * @param ShowPictureSwitch
  344. * @text 表示スイッチ
  345. * @desc 指定した場合、スイッチがONのときのみピクチャが表示されます。
  346. * @default 0
  347. * @type switch
  348. *
  349. * @param Mirror
  350. * @text 反転表示
  351. * @desc 立ち絵を左右反転させます。
  352. * @default false
  353. * @type boolean
  354. *
  355. * @param Priority
  356. * @text 表示優先度
  357. * @desc 立ち絵の表示優先度です。
  358. * @default 0
  359. * @type select
  360. * @option 最前面
  361. * @value 0
  362. * @option ウィンドウの下
  363. * @value 1
  364. * @option アニメーションの下(戦闘、マップ画面のみ有効)
  365. * @value 2
  366. *
  367. */

  368. /*~struct~Position:
  369. *
  370. * @param X
  371. * @text 基準X座標
  372. * @desc 立ち絵の基準X座標です。
  373. * @default 0
  374. * @type number
  375. * @min -9999
  376. * @max 9999
  377. *
  378. * @param Y
  379. * @text 基準Y座標
  380. * @desc 立ち絵の基準Y座標です。
  381. * @default 0
  382. * @type number
  383. * @min -9999
  384. * @max 9999
  385. *
  386. */

  387. /*~struct~SpriteSheet:
  388. *
  389. * @param MaxColumn
  390. * @text 列数
  391. * @desc スプライトシートの総列数(縦方向)です。
  392. * @default 1
  393. * @type number
  394. * @min 1
  395. *
  396. * @param MaxRow
  397. * @text 行数
  398. * @desc スプライトシートの総行数(横方向)です。
  399. * @default 1
  400. * @type number
  401. * @min 1
  402. *
  403. * @param ColumnNumber
  404. * @text 列番号
  405. * @desc 切り出したい部分の行番号(縦方向)です。
  406. * @default 1
  407. * @type number
  408. * @min 1
  409. *
  410. * @param RowNumber
  411. * @text 行番号
  412. * @desc 切り出したい部分の行番号(横方向)です。
  413. * @default 1
  414. * @type number
  415. * @min 1
  416. *
  417. */

  418. (function() {
  419.     'use strict';
  420.     const script = document.currentScript;
  421.     const param = PluginManagerEx.createParameter(script);
  422.     if (!param.SceneList) {
  423.         PluginManagerEx.throwError('Parameter[SceneList] is not found. ', script);
  424.     }
  425.     if (!param.PictureList) {
  426.         PluginManagerEx.throwError('Parameter[PictureList] is not found. ', script);
  427.     }
  428.     const usePointAdjust = param.UsePointAdjust && Utils.isOptionValid('test');

  429.     /**
  430.      * 立ち絵パラメータを解析します
  431.      */
  432.     class StandPictureParam {
  433.         setup(actor, scene, index) {
  434.             if (!scene.MemberPosition || !scene.MemberPosition[index]) {
  435.                 return false;
  436.             }
  437.             this._actor = actor;
  438.             this._standPictures = param.PictureList.filter(picture => picture.ActorId === actor.actorId());
  439.             if (this._standPictures.length <= 0) {
  440.                 return false;
  441.             }
  442.             this._standPictures.forEach(picture => this.setupPosition(picture, scene, index));
  443.             this.updatePictureFiles();
  444.             return true;
  445.         }

  446.         setupPosition(picture, scene, index) {
  447.             picture.ShowPictureSwitch = scene.ShowPictureSwitch;
  448.             picture.Mirror = scene.Mirror;
  449.             picture.SceneScaleX = scene.ScaleX;
  450.             picture.SceneScaleY = scene.ScaleY;
  451.             this._base = scene.MemberPosition[index];
  452.         }

  453.         getBasePoint() {
  454.             return this._base;
  455.         }

  456.         updatePictureFiles() {
  457.             this._standPictures.forEach(picture => {
  458.                 if (!picture.FileList) {
  459.                     return;
  460.                 }
  461.                 picture.FileList.clone().reverse().some(file => this.setFileNameIfValid(file, picture));
  462.                 if (!picture.FileName && picture.DynamicFileName) {
  463.                     picture.FileName = this.createDynamicFileName(picture.DynamicFileName);
  464.                 }
  465.             });
  466.             return this._standPictures;
  467.         }

  468.         setFileNameIfValid(file, picture) {
  469.             picture.FileName = null;
  470.             const a = this._actor;
  471.             const conditions = [];
  472.             conditions.push(() => !file.HpUpperLimit || file.HpUpperLimit >= a.hpRate() * 100);
  473.             conditions.push(() => !file.HpLowerLimit || file.HpLowerLimit <= a.hpRate() * 100);
  474.             conditions.push(() => !file.Damage || a.isDamage());
  475.             conditions.push(() => !file.Action || a.isAction());
  476.             conditions.push(() => !file.State || a.isStateAffected(file.State));
  477.             conditions.push(() => !file.Weapon || a.hasWeapon($dataWeapons[file.Weapon]));
  478.             conditions.push(() => !file.Armor || a.hasArmor($dataArmors[file.Armor]));
  479.             conditions.push(() => !file.Note || this.findStandPictureMeta() === file.Note);
  480.             conditions.push(() => !file.Switch || $gameSwitches.value(file.Switch));
  481.             conditions.push(() => !file.Script || eval(file.Script));
  482.             if (conditions.every(condition => condition())) {
  483.                 picture.FileName = file.FileName;
  484.                 return true;
  485.             } else {
  486.                 return false;
  487.             }
  488.         }

  489.         createDynamicFileName(dynamicFileName) {
  490.             return dynamicFileName
  491.                 .replace(/{hp:(.*?)}/gi, (_, p1) => this.findHpRateIndex(p1))
  492.                 .replace(/{stateId}/gi, () => this.findActorState())
  493.                 .replace(/{switch:(\d+?)}/gi, (_, p1) => this.findSwitch(p1))
  494.                 .replace(/{variable:(\d+?)}/gi, (_, p1) => this.findVariable(p1))
  495.                 .replace(/{note}/gi, () => this.findStandPictureMeta())
  496.                 .replace(/{action}/gi, () => this._actor.isAction() ? '1' : '0')
  497.                 .replace(/{damage}/gi, () => this._actor.isDamage() ? '1' : '0');
  498.         }

  499.         findHpRateIndex(rateText) {
  500.             const rates = rateText.split(',').map(item => parseInt(item));
  501.             for (let i = 0; i < rates.length + 1; i++) {
  502.                 const min = rates[i - 1] || 0;
  503.                 const max = rates[i] || 100;
  504.                 const rate = this._actor.hpRate() * 100;
  505.                 if (rate >= min && rate <= max) {
  506.                     return String(i);
  507.                 }
  508.             }
  509.             return '0';
  510.         }

  511.         findActorState() {
  512.             const state = this._actor.states().filter(state => !state.meta.NoStandPicture)[0];
  513.             return String(state ? state.id : 0);
  514.         }

  515.         findSwitch(switchText) {
  516.             return $gameSwitches.value(parseInt(switchText)) ? '1' : '0';
  517.         }

  518.         findVariable(variableText) {
  519.             return String($gameVariables.value(parseInt(variableText)));
  520.         }

  521.         findStandPictureMeta() {
  522.             let meta = '';
  523.             this._actor.traitObjects().some(obj => {
  524.                 meta = PluginManagerEx.findMetaValue(obj, 'StandPicture');
  525.                 return !!meta;
  526.             });
  527.             return meta;
  528.         }
  529.     }

  530.     /**
  531.      * Game_Actor
  532.      */
  533.     Game_Actor.prototype.isDamage = function() {
  534.         if (this._damageFrame && this._damageFrame + 30 > Graphics.frameCount) {
  535.             return true;
  536.         }
  537.         this._damageFrame = null;
  538.         return false;
  539.     };

  540.     Game_Actor.prototype.isAction = function() {
  541.         return this._performAction;
  542.     };

  543.     const _Game_Actor_performDamage = Game_Actor.prototype.performDamage;
  544.     Game_Actor.prototype.performDamage = function() {
  545.         _Game_Actor_performDamage.apply(this, arguments);
  546.         this._damageFrame = Graphics.frameCount;
  547.     };

  548.     const _Game_Actor_performAction = Game_Actor.prototype.performAction;
  549.     Game_Actor.prototype.performAction = function(action) {
  550.         _Game_Actor_performAction.apply(this, arguments);
  551.         this._performAction = true;
  552.     };

  553.     const _Game_Actor_performActionEnd = Game_Actor.prototype.performActionEnd;
  554.     Game_Actor.prototype.performActionEnd = function() {
  555.         _Game_Actor_performActionEnd.apply(this, arguments);
  556.         this._performAction = false;
  557.     };

  558.     /**
  559.      * Spriteset_Base
  560.      */
  561.     Spriteset_Base.prototype.appendToEffect = function(displayObject) {
  562.         this._effectsContainer.addChild(displayObject);
  563.     };

  564.     /**
  565.      * Scene_Base
  566.      */
  567.     const _Scene_Base_createWindowLayer = Scene_Base.prototype.createWindowLayer;
  568.     Scene_Base.prototype.createWindowLayer = function() {
  569.         _Scene_Base_createWindowLayer.apply(this, arguments);
  570.         this.createAllStandPicture();
  571.     };

  572.     const _Scene_Base_update = Scene_Base.prototype.update;
  573.     Scene_Base.prototype.update = function() {
  574.         _Scene_Base_update.apply(this, arguments);
  575.         if (this._standSpriteScene) {
  576.             this.updateAllStandPicture();
  577.         }
  578.     };

  579.     Scene_Base.prototype.createAllStandPicture = function() {
  580.         this._standSprites = new Map();
  581.         const sceneName = PluginManagerEx.findClassName(this);
  582.         this._standSpriteScene = param.SceneList.filter(item => item.SceneName === sceneName)[0];
  583.         if (this._standSpriteScene) {
  584.             this.createStandPictureContainer();
  585.             this.updateAllStandPicture();
  586.         }
  587.     };

  588.     Scene_Base.prototype.createStandPictureContainer = function() {
  589.         const container = new Sprite();
  590.         const priority = this._standSpriteScene.Priority;
  591.         if (priority === 1) {
  592.             const index = this.children.indexOf(this._windowLayer);
  593.             this.addChildAt(container, index);
  594.         } else if (priority === 2 && this._spriteset) {
  595.             this._spriteset.appendToEffect(container);
  596.         } else {
  597.             this.addChild(container);
  598.         }
  599.         this._standSpriteContainer = container;
  600.     };

  601.     Scene_Base.prototype.updateAllStandPicture = function() {
  602.         const members = this.findStandPictureMember();
  603.         if (!members) {
  604.             return;
  605.         }
  606.         members.forEach((member, index) => {
  607.             this.updateStandPicture(member, index);
  608.         });
  609.         const membersId = members.map(member => member.actorId());
  610.         this._standSprites.forEach((value, key) => {
  611.             if (!membersId.includes(key)) {
  612.                 this.removeStandPicture($gameActors.actor(key));
  613.             }
  614.         });
  615.     };

  616.     Scene_Base.prototype.findStandPictureMember = function() {
  617.         return $gameParty ? $gameParty.members() : null;
  618.     };

  619.     Scene_Base.prototype.updateStandPicture = function(actor, index) {
  620.         const id = actor.actorId();
  621.         if (this._standSprites.has(id)) {
  622.             return;
  623.         }
  624.         const pictureParam = new StandPictureParam();
  625.         const result = pictureParam.setup(actor, this._standSpriteScene, index);
  626.         if (!result) {
  627.             return;
  628.         }
  629.         const sprite = usePointAdjust ? new Sprite_StandPictureWithDrag(pictureParam) :
  630.             new Sprite_StandPicture(pictureParam);
  631.         this._standSpriteContainer.addChild(sprite);
  632.         this._standSprites.set(id, sprite);
  633.     };

  634.     Scene_Base.prototype.removeStandPicture = function(actor) {
  635.         const id = actor.actorId();
  636.         if (!this._standSprites.has(id)) {
  637.             return;
  638.         }
  639.         this._standSpriteContainer.removeChild(this._standSprites.get(id));
  640.         this._standSprites.delete(id);
  641.     };

  642.     Scene_Skill.prototype.findStandPictureMember = function() {
  643.         return [this.actor()];
  644.     };

  645.     Scene_Equip.prototype.findStandPictureMember = function() {
  646.         return [this.actor()];
  647.     };

  648.     Scene_Status.prototype.findStandPictureMember = function() {
  649.         return [this.actor()];
  650.     };

  651.     Scene_Name.prototype.findStandPictureMember = function() {
  652.         return [this._actor];
  653.     };

  654.     /**
  655.      * Sprite_StandPicture
  656.      */
  657.     class Sprite_StandPicture extends Sprite {
  658.         constructor(pictureParam) {
  659.             super();
  660.             this.setup(pictureParam);
  661.         }

  662.         setup(pictureParam) {
  663.             this._pictures = pictureParam;
  664.             this._pictures.updatePictureFiles().forEach(picture => this.addChild(this.createChild(picture)));
  665.             this.updatePosition();
  666.         }

  667.         updatePosition() {
  668.             const basePoint = this._pictures.getBasePoint();
  669.             this.x = basePoint.X;
  670.             this.y = basePoint.Y;
  671.         }

  672.         createChild(picture) {
  673.             return new Sprite_StandPictureChild(picture);
  674.         }

  675.         update() {
  676.             this._pictures.updatePictureFiles();
  677.             super.update();
  678.             this.updatePosition();
  679.         }
  680.     }

  681.     /**
  682.      * Sprite_StandPictureChild
  683.      */
  684.     class Sprite_StandPictureChild extends Sprite_Clickable {
  685.         constructor(picture) {
  686.             super();
  687.             this.setup(picture);
  688.         }

  689.         setup(picture) {
  690.             this._picture = picture;
  691.             if (param.Origin === 1) {
  692.                 this.anchor.x = 0.5;
  693.                 this.anchor.y = 0.5;
  694.             } else if (param.Origin === 2) {
  695.                 this.anchor.x = 0.5;
  696.                 this.anchor.y = 1.0;
  697.             }
  698.             this.update();
  699.         }

  700.         updatePosition() {
  701.             this.x = this._picture.X;
  702.             this.y = this._picture.Y;
  703.         }

  704.         update() {
  705.             super.update();
  706.             this.updatePosition();
  707.             this.updateBitmap();
  708.             this.updateScale();
  709.             this.updateVisibility();
  710.         }

  711.         updateBitmap() {
  712.             const file = this._picture.FileName;
  713.             if (this._fileName === file) {
  714.                 return;
  715.             }
  716.             if (this.addApngChild) {
  717.                 this.addApngChild(file);
  718.             }
  719.             if (!this._apngSprite) {
  720.                 const bitmap = ImageManager.loadPicture(file);
  721.                 bitmap.addLoadListener(() => this.setBitmap(bitmap));
  722.             }
  723.             this._fileName = file;
  724.         }

  725.         setBitmap(bitmap) {
  726.             this.bitmap = bitmap;
  727.             const sheet = this._picture.SpriteSheet;
  728.             if (sheet) {
  729.                 const width = this.bitmap.width / sheet.MaxColumn;
  730.                 const height = this.bitmap.height / sheet.MaxRow;
  731.                 const x = (sheet.ColumnNumber - 1) * width;
  732.                 const y = (sheet.RowNumber - 1) * height;
  733.                 this.setFrame(x, y, width, height);
  734.             }
  735.         }

  736.         updateVisibility() {
  737.             this.opacity = this._picture.Opacity;
  738.             const showSwitch = this._picture.ShowPictureSwitch;
  739.             this.visible = !showSwitch || $gameSwitches.value(showSwitch);
  740.         }

  741.         updateScale() {
  742.             this.scale.x = (this._picture.ScaleX / 100) || 1;
  743.             this.scale.y = (this._picture.ScaleY / 100) || 1;
  744.             if (this._picture.SceneScaleX) {
  745.                 this.scale.x *= this._picture.SceneScaleX / 100;
  746.             }
  747.             if (this._picture.SceneScaleY) {
  748.                 this.scale.y *= this._picture.SceneScaleY / 100;
  749.             }
  750.             if (this._picture.Mirror) {
  751.                 this.scale.x *= -1;
  752.             }
  753.         }

  754.         loadApngSprite(name) {
  755.             return SceneManager.tryLoadApngPicture(name);
  756.         }
  757.     }

  758.     // for Drag by test play
  759.     if (!usePointAdjust) {
  760.         return;
  761.     }

  762.     let anySpriteDrag = false;

  763.     /**
  764.      * Sprite_StandPictureWithDrag
  765.      */
  766.     class Sprite_StandPictureWithDrag extends Sprite_StandPicture {
  767.         constructor(pictureParam) {
  768.             super(pictureParam);
  769.         }

  770.         createChild(picture) {
  771.             return new Sprite_StandPictureChildWithDrag(picture);
  772.         }

  773.         setupPosition() {
  774.             super.setupPosition();
  775.             this.children.forEach(child => child.setupPosition());
  776.         }

  777.         update() {
  778.             super.update();
  779.             const children = Input.isPressed('control') ? this.children : this.children.clone().reverse()
  780.             children.forEach(sprite => sprite.updateDrag());
  781.         }
  782.     }

  783.     /**
  784.      * Sprite_StandPictureChildWithDrag
  785.      */
  786.     class Sprite_StandPictureChildWithDrag extends Sprite_StandPictureChild {
  787.         constructor(picture) {
  788.             super(picture);
  789.             this._drag = false;
  790.         }

  791.         updateDrag() {
  792.             this.startDragIfNeed();
  793.             if (Input.isPressed('control') && Input.isTriggered('ok')) {
  794.                 this.parent.setupPosition();
  795.                 Graphics.drawPositionInfo('');
  796.             }
  797.             if (!this._drag) {
  798.                 return;
  799.             }
  800.             const dx = TouchInput.x - this._dx;
  801.             const dy = TouchInput.y - this._dy;
  802.             if (this._baseDrag) {
  803.                 this.parent.x = dx;
  804.                 this.parent.y = dy;
  805.             } else {
  806.                 this.x = dx;
  807.                 this.y = dy;
  808.             }
  809.             Graphics.drawPositionInfo(`BaseX:${this.parent.x} BaseY:${this.parent.y} PictureX:${this.x} PictureY:${this.y} `);
  810.             if (!TouchInput.isPressed()) {
  811.                 this.stopDrag();
  812.             }
  813.         }

  814.         startDragIfNeed() {
  815.             if (!this._requestDrag && !this._drag) {
  816.                 return;
  817.             }
  818.             this._requestDrag = false;
  819.             if (this._drag || anySpriteDrag) {
  820.                 return;
  821.             }
  822.             anySpriteDrag = true;
  823.             this._drag = true;
  824.             if (Input.isPressed("shift")) {
  825.                 this._dx = TouchInput.x - this.parent.x;
  826.                 this._dy = TouchInput.y - this.parent.y;
  827.                 this._baseDrag = true;
  828.             } else {
  829.                 this._dx = TouchInput.x - this.x;
  830.                 this._dy = TouchInput.y - this.y;
  831.                 this._baseDrag = false;
  832.             }
  833.             this.setBlendColor([255, 255, 255, 128]);
  834.         }

  835.         stopDrag() {
  836.             anySpriteDrag = false;
  837.             this._drag = false;
  838.             this.setBlendColor([0, 0, 0, 0]);
  839.         }

  840.         onPress() {
  841.             if (this.canDrag()) {
  842.                 this._requestDrag = true;
  843.             }
  844.         }

  845.         canDrag() {
  846.             if (this._apngSprite) {
  847.                 return true;
  848.             }
  849.             const pos = this.findLocalTouchPos();
  850.             return this.bitmap.getAlphaPixel(pos.x, pos.y) !== 0;
  851.         }

  852.         findLocalTouchPos() {
  853.             const touchPos = new Point(TouchInput.x, TouchInput.y);
  854.             const pos = this.worldTransform.applyInverse(touchPos);
  855.             pos.x += this.width * this.anchor.x;
  856.             pos.y += this.height * this.anchor.y;
  857.             return pos;
  858.         }
  859.     }

  860.     const _Graphics__createAllElements = Graphics._createAllElements;
  861.     Graphics._createAllElements        = function() {
  862.         _Graphics__createAllElements.apply(this, arguments);
  863.         this._createPositionInfo();
  864.     };

  865.     Graphics._createPositionInfo = function() {
  866.         const div            = document.createElement('div');
  867.         div.id               = 'position';
  868.         div.style.display    = 'none';
  869.         div.style.position   = 'absolute';
  870.         div.style.left       = '100px';
  871.         div.style.top        = '5px';
  872.         div.style.background = '#222';
  873.         div.style.opacity    = '0.8';
  874.         div.style['z-index'] = '8';
  875.         div.style.color      = '#fff';
  876.         this._positionDiv     = div;
  877.         document.body.appendChild(div);
  878.     };

  879.     Graphics.drawPositionInfo = function(text) {
  880.         if (text) {
  881.             this._positionDiv.style.display = 'block';
  882.             this._positionDiv.textContent   = text;
  883.         } else {
  884.             this._positionDiv.style.display = 'none';
  885.         }
  886.     };
  887. })();
复制代码


梦石
0
星屑
4584
在线时间
369 小时
注册时间
2020-1-29
回帖
211
发表于 2021-7-18 20:10:00 | 显示全部楼层
可以可以
回复

使用道具 举报

梦石
0
星屑
556
在线时间
224 小时
注册时间
2011-8-15
回帖
77
发表于 2021-7-18 21:29:17 | 显示全部楼层
有详细使用教程吗?立绘部分还好理解,行走图部分有点搞不懂。
回复

使用道具 举报

梦石
0
星屑
245
在线时间
49 小时
注册时间
2021-10-26
回帖
10
发表于 2021-10-28 10:08:56 | 显示全部楼层
很实用的插件,试一下,感谢楼主。
回复

使用道具 举报

梦石
0
星屑
46
在线时间
5 小时
注册时间
2021-11-30
回帖
27
发表于 2021-12-1 16:50:35 | 显示全部楼层
感谢大佬的分享 666
回复

使用道具 举报

梦石
0
星屑
112
在线时间
11 小时
注册时间
2021-11-16
回帖
29
发表于 2022-5-18 13:17:57 | 显示全部楼层
感谢分享!
回复

使用道具 举报

梦石
0
星屑
19
在线时间
5 小时
注册时间
2022-6-28
回帖
12
发表于 2022-7-1 21:15:08 | 显示全部楼层
做低血量爆衣的时候用的上
回复

使用道具 举报

梦石
0
星屑
1823
在线时间
270 小时
注册时间
2019-4-9
回帖
79
发表于 2022-7-4 19:59:01 | 显示全部楼层
需要教程+1
還有感謝樓主QWQ
回复

使用道具 举报

梦石
0
星屑
5903
在线时间
1109 小时
注册时间
2021-3-14
回帖
414
发表于 2023-4-23 19:05:48 | 显示全部楼层
这玩意mv能用吗
回复

使用道具 举报

梦石
0
星屑
1669
在线时间
230 小时
注册时间
2018-12-9
回帖
131
发表于 2023-4-23 20:20:44 | 显示全部楼层
感谢楼主,辛苦了
回复

使用道具 举报

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

本版积分规则

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

在本版发帖返回顶部