查看: 1706|回复: 1

[搬运汉化] 敌人行动预测

[复制链接]
梦石
0
星屑
5844
在线时间
973 小时
注册时间
2015-2-6
回帖
123

开拓者

发表于 2024-2-21 23:17:48 | 显示全部楼层 |阅读模式

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

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

×
本帖最后由 戏蹑群星斗 于 2024-2-25 18:25 编辑

发现一个敌人行动预测插件,支持回合制和即时制,给大家分享下
使用请遵守MIT协议 https://kekeelabo.com/?i=42
QQ截图20240225182503.png

敵キャラの次の行動とターゲットを表示するシステム
ターン制&タイムプログレス両対応
  1. //=============================================================================
  2. // Keke_PredictionSystem - 行動予測システム
  3. // バージョン: 1.1.9
  4. //=============================================================================
  5. // Copyright (c) 2023 ケケー
  6. // Released under the MIT license
  7. // [url]http://opensource.org/licenses/mit-license.php[/url]
  8. //=============================================================================

  9. /*:
  10. * @target MZ
  11. * @plugindesc 敵の行動&ターゲット先行表示システム
  12. * @author ケケー
  13. * @url [url]https://kekeelabo.com[/url]
  14. *
  15. * @help
  16. * 【ver.1.1.9】
  17. * 敵キャラの次の行動とターゲットを表示するシステム
  18. * ターン制&タイムプログレス両対応
  19. *
  20. * ● 使い方 ●
  21. *
  22. * ■【最初にやること】ターゲットラインの調整
  23. *  バトルのレイアウトに応じてターゲットラインの位置と方向を調整する
  24. * ◎ターゲットラインとは行動者からターゲットに向けて伸び、
  25. *  誰がターゲットなのか示すラインのこと
  26. * ◎調整はプラグインパラメータで行う
  27. * ◎一例として、左が敵、右が味方のサイドビュー画面向けに調整してみる
  28. *  そのままやってみてほしい
  29. * [1]プラグインパラメータ → 『ライン-進行方向』 を「右」にする
  30. *  ラインは敵から味方に向けて伸びるもの
  31. *  そして敵が左側、味方が右側なので「右」に向かって伸ばす
  32. * [2]プラグインパラメータ → 『ライン-終点』
  33. *  『終点-方向(味方)』を「左」にする
  34. *  ラインが味方グラの左側に向かって伸びるようになる
  35. * [3]以上。バトルを「サイドビュー」にしてテストしてみる
  36. *
  37. *
  38. * ■【設定1】行動予測を手動で発動するようにする
  39. * [1]プラグインパラメータ → 『常に行動予測』 を「false」にする
  40. *  行動予測が自動で発動しないようになる
  41. * [2]データベースのメモ欄orスイッチを使って行動予測をオンにする。詳細は後述
  42. *
  43. *
  44. * ■【設定2】行動ビュー/ターゲットラインを無効化
  45. *  デフォルトでは行動とターゲットの両方が表示されるが、
  46. *  どちらか片方だけにしたい場合に
  47. * ◎行動表示を無効化
  48. *  プラグインパラメータ → 『行動表示』 を「false」
  49. * ◎ターゲット表示を無効化
  50. *  プラグインパラメータ → 『ターゲット表示』 を「false」
  51. *
  52. *
  53. * ■【設定3】行動ビューの見た目をカスタマイズ
  54. *  プラグインパラメータ → 『行動ビュー』
  55. * ◎色々と設定項目が並んでいるが、好きにいじってよい
  56. *
  57. *
  58. * ■【設定4】ターゲットラインの見た目をカスタマイズ
  59. *  プラグインパラメータ → 『ターゲットライン』
  60. * ◎色々と設定項目が並んでいるが、好きにいじってよい
  61. *
  62. *
  63. * ■【機能1】データベースのメモ欄で行動予測の設定変更
  64. *  行動予測の設定を動的に変更できる
  65. *  ・敵毎に行動ビューの位置をずらす
  66. *  ・行動ビューに表示される名前を指定
  67. *  ・行動予測を動的にオンオフ
  68. *  といった機能がある
  69. * ◎アクター、職業、スキル、アイテム、武器、防具、敵キャラ、ステートのメモ欄に
  70. *  <行動予測:  x:  y:  dire:  name:  icon:  redoAct  redoTarget  on  off>
  71. * ★例)
  72. * <行動予測:  x:100>
  73. *  行動ビューの位置を右に 100 ピクセル ずらす。-100 なら左
  74. * <行動予測:  y:100>
  75. *  行動ビューの位置を下に 100 ピクセル ずらす。-100 なら上
  76. * <行動予測:  dire:上>
  77. *  行動ビューの表示方向を 上 にする
  78. *  方向は「中央」「上」「下」「左」「右」を入れられる
  79. * <行動予測:  text:謎の攻撃>
  80. *  行動ビューに表示されるテキストを『謎の攻撃』にする。制御文字も使用可能
  81. *  \n で改行。指定がなければスキル名が表示される
  82. * <行動予測:  icon:11>
  83. *  行動ビューに表示されるアイコンを ID 11 のアイコンにする
  84. *  指定がなければスキルのアイコンが表示される
  85. * <行動予測:  redoAct>
  86. *  敵キャラの行動を再決定する。ターゲットも同時に再決定される
  87. * <行動予測:  redoTarget>
  88. *  敵キャラのターゲットを再決定する。行動はそのまま
  89. * <行動予測:  on>
  90. *  行動予測を オン(有効) にする
  91. * <行動予測:  off>
  92. *  行動予測を オフ(無効) にする
  93. *  オンとオフが両方ある場合はオフが優先される
  94. * <行動予測:  showLine>
  95. *  ターゲットラインを表示する
  96. * <行動予測:  hideLine>
  97. *  ターゲットラインを表示しない
  98. * <行動予測:  x:100  y:100  dire:上  icon:11  name:謎の攻撃  on>
  99. *  とまとめて設定することも可能
  100. *
  101. *
  102. * ■【機能2】スイッチで行動予測を有効/無効
  103. * [1]プラグインパラメータ →
  104. *  『行動予測"有効"スイッチ』/『行動予測"無効"スイッチ』 に、
  105. *  それぞれ好きなスイッチを割り当てる
  106. * [2]有効スイッチをオンにすると行動予測有効、
  107. *  無効スイッチをオンにすると無効になる
  108. *  両方ともオンの場合は無効が優先され無効
  109. *
  110. *
  111. * ● 利用規約 ●
  112. * MITライセンスのもと、自由に使ってくれて大丈夫です
  113. *
  114. *
  115. *
  116. * A system that displays the next action and target of the enemy character
  117. * Supports both turn-based and time-progress
  118. *
  119. * ● How to use ●
  120. *
  121. * ■【First thing to do】 Adjust the target line
  122. * Adjust the position and direction of the target line
  123. * according to the battle layout
  124. * ◎ The target line extends from the actor toward the target,
  125. *   A line that indicates who is the target
  126. * ◎ Adjustments are made with plug-in parameters
  127. * ◎ As an example, try adjusting for the side view screen
  128. *   with enemies on the left and allies on the right.
  129. *   I want you to try it as it is
  130. * [1] Plug-in parameter → Set "ライン-進行方向" to "right"
  131. *   Lines extend from enemies to allies
  132. *   And since the enemy is on the left and the ally is on the right,
  133. *   stretch toward "right"
  134. * [2] Plugin parameter → "ライン-進行方向"
  135. *   Set "終点-方向(味方)" to "left"
  136. *  The line will extend toward the left side of the allied graphic
  137. * [3] and above. Test the battle in "side view"
  138. *
  139. *
  140. * ■ [Setting 1] Manually activate action prediction
  141. * [1] Plugin parameter → Set "常に行動予測r" to "false"
  142. *  Action prediction will not be activated automatically
  143. * [2] Turn on action prediction using the memo field in the database
  144. *    or switch. Details later
  145. *
  146. *
  147. * ■ [Setting 2] Disable action view/target line
  148. *   By default, both actions and targets are displayed,
  149. *   If you want to use only one of them
  150. * ◎ Disable action display
  151. *   Plugin parameter → "行動表示" to "false"
  152. * ◎ Disable target display
  153. *   Plugin parameter → "ターゲット表示" to "false"
  154. *
  155. *
  156. * ■ [Setting 3] Customize the action view appearance
  157. *   Plugin parameter → "行動ビュー"
  158. * ◎ Various setting items are lined up, but you can tweak them as you like.
  159. *
  160. *
  161. * ■ [Setting 4] Customize the appearance of the target line
  162. *   Plug-in parameter → "ターゲットライン"
  163. * ◎ Various setting items are lined up, but you can tweak them as you like.
  164. *
  165. *
  166. * ■ [Function 1] Change action prediction settings
  167. * in the memo field of the database
  168. *   You can dynamically change action prediction settings
  169. * ・Shift the position of the action view for each enemy
  170. * ・Specify the name displayed in the action view
  171. * ・ Dynamically turn on/off action prediction
  172. * There are functions such as
  173. * ◎ Actor, class, skill, item, weapon, armor, enemy character,
  174. *   state memo column
  175. * <prediction: x: y: dire: name: icon: redoAct redoTarget on off>
  176. * ★example)
  177. * <prediction: x:100>
  178. *   Shift the position of the action view by 100 pixels to the right.
  179. *   -100 is left
  180. * <prediction: y:100>
  181. *   Shift the position of the action view downward by 100 pixels. -100 is up
  182. * <prediction: dire:up>
  183. *   Set the display direction of the action view to up
  184. *   Direction can be "Center", "Top", "Bottom", "Left", and "Right"
  185. * <prediction: text: Mysterious attack>
  186. *   Change the text displayed in the action view to "Mysterious Attack".
  187. *   Control characters are allowed
  188. *   Newline with \n. If not specified, the skill name will be displayed
  189. * <prediction: icon:11>
  190. *   Set the icon displayed in the action view to the icon with ID 11
  191. *   If not specified, the skill icon will be displayed
  192. * <prediction: redoAct>
  193. *   Redetermine the actions of the enemy characters.
  194. *   The target is also re-determined at the same time
  195. * <prediction: redoTarget>
  196. *   Redetermine the enemy character's target. action as it is
  197. * <prediction: on>
  198. *   Action prediction he turned on (enabled)
  199. * <prediction: off>
  200. *   He turns off (disables) action prediction
  201. *   If there are both on and off, off takes precedence
  202. * <prediction: showLine>
  203. *   display target line
  204. * <prediction: hideLine>
  205. *   Do not display target line
  206. * <prediction: x:100 y:100 dire:up icon:11 name:mysterious attack on>
  207. *   It is also possible to set together with
  208. *
  209. *
  210. * ■ [Function 2] Activate/deactivate action prediction with a switch
  211. * [1] Plugin parameters →
  212. *   In the "行動予測"有効"スイッチ" / "行動予測"無効"スイッチ",
  213. *   Allocate your favorite switch to each
  214. * [2] Action prediction is enabled when the enable switch is turned on,
  215. *   Disabled when the disabled switch is turned on
  216. *   If both are on, disable takes precedence over disable
  217. *
  218. *
  219. * ● Terms of Use ●
  220. * Feel free to use it under the MIT license.
  221. *
  222. *
  223. *
  224. * @param 常に行動予測
  225. * @desc predictionAlways 常に有効予測を有効にする。有効にしない場合はデータベースのメモ欄で適宜有効にする
  226. * @type boolean
  227. * @default true
  228. *
  229. * @param 行動予測"有効"スイッチ
  230. * @desc prediction"valid"switch 行動予測を有効にするスイッチ
  231. * @type switch
  232. * @default
  233. *
  234. * @param 行動予測"無効"スイッチ
  235. * @desc prediction"unValid"switch 行動予測を無効にするスイッチ
  236. * @type switch
  237. * @default
  238. *
  239. * @param 行動ビュー
  240. *
  241. * @param 行動-表示
  242. * @parent 行動ビュー
  243. * @desc act-show 味方キャラの行動ビューを表示する(場合によっては味方キャラも)
  244. * @type boolean
  245. * @default true
  246. *
  247. * @param 行動-入力中のみ表示
  248. * @parent 行動ビュー
  249. * @desc act-showOnlyInput 行動入力中のみ行動ビューを表示する
  250. * @type boolean
  251. * @default true
  252. *
  253. * @param 行動-詠唱中の味方も表示
  254. * @parent 行動ビュー
  255. * @desc act-showCastActor 詠唱中の味方キャラも行動ビューを表示する
  256. * @type boolean
  257. * @default false
  258. *
  259. * @param 行動-自動中の味方も表示
  260. * @parent 行動ビュー
  261. * @desc act-showAutoActor 自動戦闘中の味方キャラも行動ビューを表示する
  262. * @type boolean
  263. * @default false
  264. *
  265. * @param 行動-フォント
  266. * @parent 行動ビュー
  267. * @desc act-font 行動ビューの使用フォント。Keke_CommonDataでフォント登録しそのフォント名を書く。空欄ならメインフォント
  268. * @default
  269. *
  270. * @param 行動-文字サイズ
  271. * @parent 行動ビュー
  272. * @desc act-fontSize 行動ビューの文字サイズ。基本 20
  273. * @default 20
  274. *
  275. * @param 行動-文字色
  276. * @parent 行動ビュー
  277. * @desc act-fontColor 行動ビューの文字色。赤、緑、青、濃度。色0~255、濃度0~1。基本 255, 255, 0
  278. * @default 255, 255, 0
  279. *
  280. * @param 行動-文字色(詠唱中)
  281. * @parent 行動ビュー
  282. * @desc act-fonColorCast 詠唱中の行動ビューの文字色。赤、緑、青、濃度。色0~255、濃度0~1。基本 255, 192, 255
  283. * @default 255, 192, 255
  284. *
  285. * @param 行動-縁取り幅
  286. * @parent 行動ビュー
  287. * @desc act-outWidth 行動ビューの文字縁取り幅。5 なら 5ピクセル。基本 7
  288. * @default 7
  289. *
  290. * @param 行動-横幅
  291. * @parent 行動ビュー
  292. * @desc act-width 行動ビューの横幅。100 なら 100ピクセル。基本 200
  293. * @default 200
  294. *
  295. * @param 行動-背景色
  296. * @parent 行動ビュー
  297. * @desc act-backColor 行動ビューの背景の色。(赤, 緑, 青, 濃度)。色0~255、濃度0~1。基本 0, 0, 0, 0.25
  298. * @default 0, 0, 0, 0.25
  299. *
  300. * @param 行動-アイコン表示
  301. * @parent 行動ビュー
  302. * @desc act-showicon 行動のアイコンを表示する。基本 true
  303. * @type boolean
  304. * @default true
  305. *
  306. * @param …アイコン間隔
  307. * @parent 行動ビュー
  308. * @desc act-interval 行動名とアイコンの間の間隔。5 なら 5ピクセル。基本 0
  309. * @default 0
  310. *
  311. * @param …アイコンサイズ
  312. * @parent 行動ビュー
  313. * @desc act-iconSize アイコンの大きさ。150 なら 150%、50 なら 50% の大きさになる。基本 100
  314. * @default 100
  315. *
  316. * @param 行動-行間
  317. * @parent 行動ビュー
  318. * @desc act-lineSpace 行動を複数行にわたって表示する時の行間。5 なら 5ピクセル。基本 2
  319. * @default 2
  320. *
  321. * @param 行動-表示位置/味方
  322. * @parent 行動ビュー
  323. * @desc act-showPos/actor 味方の行動ビューの表示位置
  324. * @type struct<viewPos>
  325. * @default {"表示方向":"上","ずらしX":"","ずらしY":""}
  326. *
  327. * @param 行動-表示位置/敵
  328. * @parent 行動ビュー
  329. * @desc act-showPos/enemy 敵の行動ビューの表示位置
  330. * @type struct<viewPos>
  331. * @default {"表示方向":"上","ずらしX":"","ずらしY":""}
  332. *
  333. * @param 行動-非表示範囲
  334. * @parent 行動ビュー
  335. * @desc act-noShowScope 行動ビューを表示しない範囲。下50 なら、画面下端から 50ピクセル の範囲には表示しない
  336. * @type struct<noShowScope>
  337. * @default {"上":"0","下":"0","左":"0","右":"0"}
  338. *
  339. * @param 行動-表示レイヤー
  340. * @parent 行動ビュー
  341. * @desc act-showLayer 行動ビューの表示レイヤー。基本 ウインドウより下
  342. * @type select
  343. * @option ウインドウより上
  344. * @option ウインドウより下
  345. * @default ウインドウより下
  346. *
  347. * @param 行動-不発エフェクト
  348. * @parent 行動ビュー
  349. * @desc act-misfireEffect 行動がMP不足等で不発に終わった時のエフェクト
  350. * @type struct<effect>
  351. * @default {"アニメーション":"64","効果音":"["{\\"ファイル\\":\\"Monster4\\",\\"音量\\":\\"100\\",\\"ピッチ\\":\\"70\\",\\"位相\\":\\"0\\"}"]","画面フラッシュ":"true","…フラッシュ色":"255, 255, 255, 170","…フラッシュ遅延":"","…フラッシュ時間":"30","ヒットストップ":"0, 0","フリーアニメ":""}
  352. *
  353. * @param ターゲットライン
  354. *
  355. * @param ライン-表示
  356. * @parent ターゲットライン
  357. * @desc line-show 敵キャラのターゲットラインを表示する
  358. * @type boolean
  359. * @default true
  360. *
  361. * @param ライン-入力中のみ表示
  362. * @parent ターゲットライン
  363. * @desc line-showOnlyInput 行動入力中のみターゲットラインを表示する
  364. * @type boolean
  365. * @default true
  366. *
  367. * @param ライン-進行方向
  368. * @parent ターゲットライン
  369. * @desc line-vector ターゲットラインの向かう方向
  370. * @type select
  371. * @option 上
  372. * @option 下
  373. * @option 左
  374. * @option 右
  375. * @default 下
  376. *
  377. * @param ライン-始点
  378. * @parent ターゲットライン
  379. * @desc line-startPoint ライン始点の位置設定。始点は敵キャラにのみ発生(ターゲットを表示するのは敵のみであるため)
  380. * @type struct<lineStart>
  381. * @default {"始点-方向":"右","始点-ずらしX":"","始点-ずらしY":""}
  382. *
  383. * @param ライン-終点
  384. * @parent ターゲットライン
  385. * @desc line-endPoint ライン終点の位置設定。終点は味方と敵キャラ両方ある(回復行動など、敵が敵をターゲットすることがあるため)
  386. * @type struct<lineEnd>
  387. * @default {"味方へのライン":"","終点-方向(味方)":"上","終点-ずらしX(味方)":"","終点-ずらしY(味方)":"","敵同士のライン":"","終点-方向(敵)":"中央","終点-ずらしX(敵)":"","終点-ずらしY(敵)":""}
  388. *
  389. * @param ライン-太さ
  390. * @parent ターゲットライン
  391. * @desc line-width ターゲットラインの太さ。5 なら 5ピクセル。基本 4
  392. * @default 4
  393. *
  394. * @param ライン-縁取り幅
  395. * @parent ターゲットライン
  396. * @desc line-outWidth ターゲットラインの縁取りの幅。1 なら 1ピクセル。基本 1.5
  397. * @default 1.5
  398. *
  399. * @param ライン-色リスト
  400. * @parent ターゲットライン
  401. * @desc line-colorList ターゲットラインの色。赤, 緑, 青。各0~255。1行目は一番目の敵、2行目は二番目の敵といった感じで適用
  402. * @type string[]
  403. * @default ["255, 255, 0","255, 0, 255","0, 255, 255","255, 128, 0","128, 255, 0","0, 128, 255","255, 255, 255","255, 0, 0"]
  404. *
  405. * @param ライン-始点大きさ
  406. * @parent ターゲットライン
  407. * @desc line-startPointSize ターゲットラインの始点の円部分の大きさ。5 なら 5ピクセル。基本 3
  408. * @default 3
  409. *
  410. * @param ライン-矢印大きさ
  411. * @parent ターゲットライン
  412. * @desc line-arrowSize ターゲットラインの矢印部分の大きさ。5 なら 5ピクセル。基本 4
  413. * @default 4
  414. *
  415. * @param ライン-重なりずらし
  416. * @parent ターゲットライン
  417. * @desc line-pileOffset ターゲットラインが重なった時にずらす幅。5 なら 5ピクセル。基本 12
  418. * @default 12
  419. *
  420. * @param ライン-最低長さ
  421. * @parent ターゲットライン
  422. * @desc line-minLength ターゲットラインが短すぎる場合の最低長さ。この長さは下回らない。50 なら 50ピクセル。基本 50
  423. * @default 50
  424. *
  425. * @param ライン-全体時はワード
  426. * @parent ターゲットライン
  427. * @desc line-wordOnAll 全体対象の時はラインではなく指定の文字列を表示する
  428. * @type boolean
  429. * @default true
  430. *
  431. * @param …全体ワード設定
  432. * @parent ターゲットライン
  433. * @desc line-allWordCfg 全体対象の時に表示する文字列の設定
  434. * @type struct<allWordCfg>
  435. * @default {"ワード":"ALL","フォント":"","文字サイズ":"22","文字色":"96, 255, 255","縁取り幅":"7","ずらしX":"","ずらしY":""}
  436. */



  437. //==================================================
  438. /*~struct~viewPos:
  439. //==================================================
  440. * @param 表示方向
  441. * @desc showDire 行動ビューの表示方向。基本 上
  442. * @type select
  443. * @option 中央
  444. * @option 上
  445. * @option 下
  446. * @option 左
  447. * @option 右
  448. * @default 上
  449. *
  450. * @param ずらしX
  451. * @desc offsetX 行動ビューのX位置ずらし。5 なら 5ピクセル 右へ。基本 0
  452. * @default
  453. *
  454. * @param ずらしY
  455. * @desc offsetY 行動ビューのY位置ずらし。5 なら 5ピクセル 下へ。基本 0
  456. * @default
  457. */



  458. //==================================================
  459. /*~struct~noShowScope:
  460. //==================================================
  461. * @param 上
  462. * @desc up 上側の非表示範囲。50 なら 画面上端から 50ピクセル の範囲には表示しない。基本 0
  463. *
  464. * @param 下
  465. * @desc down 下側の非表示範囲。50 なら 画面下端から 50ピクセル の範囲には表示しない。基本 0
  466. *
  467. * @param 左
  468. * @desc left 左側の非表示範囲。50 なら 画面左端から 50ピクセル の範囲には表示しない。基本 0
  469. *
  470. * @param 右
  471. * @desc right 右側の非表示範囲。50 なら 画面右端から 50ピクセル の範囲には表示しない。基本 0
  472. */



  473. //==================================================
  474. /*~struct~allWordCfg:
  475. //==================================================
  476. * @param ワード
  477. * @desc word 全体ワードとして表示する文字列
  478. * @default ALL
  479. *
  480. * @param フォント
  481. * @parent 行動ビュー
  482. * @desc font 全体ワードの使用フォント。Keke_CommonDataでフォント登録したフォント名を書く。空欄ならメインフォント
  483. * @default
  484. *
  485. * @param 文字サイズ
  486. * @desc fontSize 全体ワードの文字サイズ。基本 22
  487. * @default 22
  488. *
  489. * @param 文字色
  490. * @desc fontColor 全体ワードの文字色。赤、緑、青、濃度。各0〜255。基本 96, 255, 255
  491. * @default 96, 255, 255
  492. *
  493. * @param 縁取り幅
  494. * @desc outWidth 全体ワードの文字縁取り幅。5 なら 5ピクセル。基本 7
  495. * @default 7
  496. *
  497. * @param ずらしX
  498. * @desc offsetX 全体ワードのX位置ずらし。5 なら 5ピクセル 右へ。基本 0
  499. * @default
  500. *
  501. * @param ずらしY
  502. * @desc offsetY 全体ワードのY位置ずらし。5 なら 5ピクセル 下へ。基本 0
  503. * @default
  504. */



  505. //==================================================
  506. /*~struct~lineStart:
  507. //==================================================
  508. * @param 始点-方向
  509. * @desc startPoint-dire ライン始点の位置方向。基本 右
  510. * @type select
  511. * @option 中央
  512. * @option 上
  513. * @option 下
  514. * @option 左
  515. * @option 右
  516. * @default 右
  517. *
  518. * @param 始点-ずらしX
  519. * @desc startPoint-offsetX ライン始点のXずらし。5 なら 5ピクセル 右へ。基本 0
  520. * @default
  521. *
  522. * @param 始点-ずらしY
  523. * @desc startPoint-offsetY ライン始点のYずらし。5 なら 5ピクセル 下へ。基本 0
  524. * @default
  525. */



  526. //==================================================
  527. /*~struct~lineEnd:
  528. //==================================================
  529. * @param 味方へのライン
  530. *
  531. * @param 終点-方向(味方)
  532. * @parent 味方へのライン
  533. * @desc endPoint-dire(actor) 味方のライン終点の位置方向。基本 上
  534. * @type select
  535. * @option 中央
  536. * @option 上
  537. * @option 下
  538. * @option 左
  539. * @option 右
  540. * @default 上
  541. *
  542. * @param 終点-ずらしX(味方)
  543. * @parent 味方へのライン
  544. * @desc endPoint-offsetX(actor) 味方のライン終点のXずらし。5 なら 5ピクセル 右へ。基本 0
  545. * @default
  546. *
  547. * @param 終点-ずらしY(味方)
  548. * @parent 味方へのライン
  549. * @desc endPoint-offsetY(actor) 味方のライン終点のYずらし。5 なら 5ピクセル 下へ。基本 0
  550. * @default
  551. *
  552. * @param 敵同士のライン
  553. *
  554. * @param 終点-方向(敵)
  555. * @parent 敵同士のライン
  556. * @desc endPoint-dire(enemy) 敵のライン終点の位置方向。基本 中央
  557. * @type select
  558. * @option 中央
  559. * @option 上
  560. * @option 下
  561. * @option 左
  562. * @option 右
  563. * @default 中央
  564. *
  565. * @param 終点-ずらしX(敵)
  566. * @parent 敵同士のライン
  567. * @desc endPoint-offsetX(enemy) 敵のライン終点のXずらし。5 なら 5ピクセル 右へ。基本 0
  568. * @default
  569. *
  570. * @param 終点-ずらしY(敵)
  571. * @parent 敵同士のライン
  572. * @desc endPoint-offsetY(enemy) 敵のライン終点のYずらし。5 なら 5ピクセル 下へ。基本 0
  573. * @default
  574. */



  575. //==================================================
  576. /*~struct~effect:
  577. //==================================================
  578. *
  579. * @param アニメーション
  580. * @desc animation 表示するアニメーション
  581. * @type animation
  582. *
  583. * @param 効果音
  584. * @desc SE 鳴らす効果音
  585. * @type struct<se>[]
  586. * @default []
  587. *
  588. * @param 画面フラッシュ
  589. * @desc screenFlash 画面フラッシュを実行する
  590. * @type boolean
  591. * @default false
  592. *
  593. * @param …フラッシュ色
  594. * @desc flashColor 画面フラッシュの色。赤, 緑, 青, 強さ。各0~255。基本 255, 255, 255, 170
  595. * @default 255, 255, 255, 170
  596. *
  597. * @param …フラッシュ遅延
  598. * @desc flashDelay フラッシュのディレイ。5 なら 5フレーム 待ってからフラッシュ。基本 0
  599. * @default
  600. *
  601. * @param …フラッシュ時間
  602. * @desc flashTime フラッシュの所要時間。5 なら 5フレーム。基本 30
  603. * @default 30
  604. *
  605. * @param ヒットストップ
  606. * @desc hitStope 画面を止める演出。5, 7 なら 5フレーム 待ってから 7フレーム 止める。Keke_HitStopが必要。基本 0, 0
  607. * @default 0, 0
  608. *
  609. * @param フリーアニメ
  610. * @desc freeAnime フリーアニメを再生する。メモ欄同様に記述。Keke_FreeAnimeが必要
  611. * @type multiline_string
  612. */



  613. //==================================================
  614. /*~struct~se:
  615. //==================================================
  616. * @param ファイル
  617. * @desc file 効果音ファイル
  618. * @type file
  619. * @dir audio/se
  620. *
  621. * @param 音量
  622. * @desc volime 効果音の音量
  623. * @default 100
  624. *
  625. * @param ピッチ
  626. * @desc pitch 効果音のピッチ
  627. * @default 100
  628. *
  629. * @param 位相
  630. * @desc pan 効果音の位相
  631. * @default 0
  632. */



  633. (() => {
  634.     //- プラグイン名
  635.     const pluginName = document.currentScript.src.match(/^.*\/(.*).js$/)[1];



  636.     //==================================================
  637.     //--  公開
  638.     //==================================================

  639.     //- 行動予測の開始(公開)
  640.     Game_Temp.prototype.startPredictionKe = function(subject, force) {
  641.         // 行動予測の開始
  642.         startPrediction(subject, force);
  643.     };

  644.    

  645.     //==================================================
  646.     //--  スプライト追加 /ベーシック
  647.     //==================================================
  648.    
  649.     //- 破棄付きスプライト
  650.     function SpriteKePrds() {
  651.         this.initialize(...arguments);
  652.     }

  653.     SpriteKePrds.prototype = Object.create(Sprite.prototype);
  654.     SpriteKePrds.prototype.constructor = SpriteKePrds;

  655.     SpriteKePrds.prototype.destroy = function() {
  656.         if (this.bitmap && !this.bitmap._url) { this.bitmap.destroy(); }
  657.         if (this._texture) { Sprite.prototype.destroy.apply(this); }
  658.     };



  659.     //==================================================
  660.     //--  文字列オート変換 /ベーシック
  661.     //==================================================
  662.    
  663.     //- 文字列のハッシュ化
  664.     function strToHash(str) {
  665.         if (!str || !str.length) { return {}; }
  666.         let hash = {};
  667.         const strs = JSON.parse(str);
  668.         let val = null;
  669.         let val2 = null;
  670.         for (const key in strs) {
  671.             val = strs[key];
  672.             if (!key || !val) { continue; }
  673.             val2 = strToAuto(val, key);
  674.             hash[key] = val2;
  675.         }
  676.         return hash;
  677.     };
  678.    
  679.    
  680.     //- 文字列のリスト化
  681.     function strToList(str) {
  682.         if (!str || !str.length) { return []; }
  683.         let array = JSON.parse(str);
  684.         return array.map((val, i) => {
  685.             return strToAuto(val);
  686.         });
  687.     };
  688.    
  689.    
  690.     //- 文字列の自動処理
  691.     function strToAuto(val, key = "") {
  692.         let val2 = null;
  693.         let match = null;
  694.         let end = false;
  695.         if (!end) {
  696.             if (val[0] == "{") {
  697.                 val2 = strToHash(val);
  698.                 end = true;
  699.             }
  700.         }
  701.         if (!end) {
  702.             if (val[0] == "[") {
  703.                 val2 = strToList(val);
  704.                 end = true;
  705.             }
  706.         }
  707.         if (!end) { val = val + ","; }
  708.         if (!end) {
  709.             match = val.match(/^\s*(-?\d+,\s*-?\d+,\s*-?\d+,?\s*-?\d*\.?\d*)\s*,$/);
  710.             if (match && !val.match(/[^\d\.\-,\s]/)) {
  711.                 if (key.match(/(カラー|色|塗り)/) && !key.includes("トーン") && !key.includes("ブレンド") && !key.includes("配色") && !key.includes("着色") &&  !key.includes("フラッシュ") && !key.includes("チェンジ") &&  !key.includes("選択")) {
  712.                     val2 = "rgba(" +  match[1] + ")";
  713.                 } else {
  714.                     val2 = JSON.parse("[" +  match[1] + "]");
  715.                 }
  716.                 end = true;
  717.             }
  718.         }
  719.         if (!end) {
  720.             match = val.match(/(-?\d+\.?\d*),\s*/g);
  721.             if (match && match.length >= 2 && !val.match(/[^\d\.\-,\s]/)) {
  722.                 val2 = JSON.parse("[" + match.reduce((r, s) => r + s).replace(/,$/, "") + "]");
  723.                 end = true;
  724.             }
  725.         }
  726.         if (!end) {
  727.             match = val.match(/^(true|false)\s*,/);
  728.             if (match) {
  729.                 val2 = match[1] == "true" ? true : false;
  730.                 end = true;
  731.             }
  732.         }
  733.         if (!end) {
  734.             match = val.match(/^(-?\d+\.?\d*)\s*,/);
  735.             if (match && !val.match(/[a-z]/)) {
  736.                 val2 = Number(match[1]); end = true;
  737.                 end = true;
  738.             }
  739.         }
  740.         if (!end) {
  741.             if (val[0] == """) { val = val.slice(1); }
  742.             val2 = val.slice(0, -1);
  743.         }
  744.         return val2;
  745.     };



  746.     //==================================================
  747.     //--  パラメータ受け取り
  748.     //==================================================
  749.    
  750.     //- 真偽化
  751.     function toBoolean(str) {
  752.         if (!str) { return false; }
  753.         const str2 = str.toString().toLowerCase();
  754.         if (str2 == "true" || str2 == "on") { return true; }
  755.         if (str2 == "false" || str2 == "off") { return false; }
  756.         return Number(str);
  757.     };

  758.     let parameters = PluginManager.parameters(pluginName);

  759.     const keke_predictionAlways = toBoolean(parameters["常に行動予測"]);
  760.     const keke_predictionOnSwitch = Number(parameters["行動予測"有効"スイッチ"]);
  761.     const keke_predictionOffSwitch = Number(parameters["行動予測"無効"スイッチ"]);

  762.     //- 行動ビュー
  763.     const keke_actShow = toBoolean(parameters["行動-表示"]);
  764.     const keke_actOnlyInput = toBoolean(parameters["行動-入力中のみ表示"]);
  765.     const keke_actShowCastActor = toBoolean(parameters["行動-詠唱中の味方も表示"]);
  766.     const keke_actShowAutoActor = toBoolean(parameters["行動-自動中の味方も表示"]);
  767.     const keke_actFontFace = parameters["行動-フォント"];
  768.     const keke_actFontSize = Number(parameters["行動-文字サイズ"]);
  769.     const keke_actFontColor = "rgba(" + parameters["行動-文字色"] + ")";
  770.     const keke_actFontColorCast = "rgba(" + parameters["行動-文字色(詠唱中)"] + ")";
  771.     const keke_actOutW = Number(parameters["行動-縁取り幅"]);
  772.     const keke_actW = Number(parameters["行動-横幅"]);
  773.     const keke_actBackColor = parameters["行動-背景色"] ? `rgba(${parameters["行動-背景色"]})` : "";
  774.     const keke_actShowIcon = toBoolean(parameters["行動-アイコン表示"]);
  775.     const keke_actIconSpace = Number(parameters["…アイコン間隔"]);
  776.     const keke_actIconSize = Number(parameters["…アイコンサイズ"]) || 100;
  777.     const keke_actLineSpace = Number(parameters["行動-行間"]);
  778.     const keke_actPosActor = strToHash(parameters["行動-表示位置/味方"]);
  779.     const keke_actPosEnemy = strToHash(parameters["行動-表示位置/敵"]);
  780.     const keke_actNoShowScope = strToHash(parameters["行動-非表示範囲"]);
  781.     const keke_actLayer = parameters["行動-表示レイヤー"];
  782.     const keke_actMisfireEffect = strToHash(parameters["行動-不発エフェクト"]);

  783.     //- ターゲットライン
  784.     const keke_lineShow = toBoolean(parameters["ライン-表示"]);
  785.     const keke_lineOnlyInput = toBoolean(parameters["ライン-入力中のみ表示"]);
  786.     const keke_lineDire = parameters["ライン-進行方向"];
  787.     const keke_lineStart = strToHash(parameters["ライン-始点"]);
  788.     const keke_lineEnd = strToHash(parameters["ライン-終点"]);
  789.     const keke_lineW = Number(parameters["ライン-太さ"]);
  790.     const keke_lineOutW = Number(parameters["ライン-縁取り幅"]);
  791.     const keke_lineColorList = makeColorList(parameters["ライン-色リスト"]);
  792.     const keke_linePileOffset = Number(parameters["ライン-重なりずらし"]);
  793.     const keke_lineStartSize = Number(parameters["ライン-始点大きさ"]);
  794.     const keke_lineArrowSize = Number(parameters["ライン-矢印大きさ"]);
  795.     const keke_lineMinLength = Number(parameters["ライン-最低長さ"]);
  796.     const keke_lineWordIfAll = toBoolean(parameters["ライン-全体時はワード"]);
  797.     const keke_allWordCfg = strToHash(parameters["…全体ワード設定"]);

  798.     parameters = null;

  799.     //- カラーリストの作成
  800.     function makeColorList(str) {
  801.         const list = strToList(str);
  802.         return list.map(s => `rgba(${s})`);
  803.     };
  804.    
  805.    
  806.    
  807.     //==================================================
  808.     //--  プラグインコマンド
  809.     //==================================================
  810.    
  811.     PluginManager.registerCommand(pluginName, "", args => {
  812.         const a = Number(args.a);
  813.     });



  814.     //==================================================
  815.     //--  他プラグイン連携
  816.     //==================================================

  817.      //- フルアニメステータスASIの取得
  818.      function getFullAnimeStatusAsi(battler) {
  819.         // サイドビュー時はバトグラに表示
  820.         if ($gameSystem.isSideView()) { return null; }
  821.         if (!$gameTemp._fullAnimeStatusKe) { return null; }
  822.         const asi = $gameTemp.getFullAnimeStatusAsiKe(battler);
  823.         // 顔アイコンがなければバトグラに表示
  824.         if (!asi || !asi.faceBaseSprite || !asi.faceBaseSprite.visible) { return null; }
  825.         return asi;
  826.     };


  827.     //- 文字サイズ率の取得
  828.     function getFontSizeRate(fontName) {
  829.         if (!fontName || !$gameTemp._fontListKe) { return { width:1, half:1 }; }
  830.         let widthSize = 1;
  831.         let halfSize = 1;
  832.         // フォントリスト展開
  833.         for (const data of $gameTemp._fontListKe) {
  834.             // 名前が適合したら取得
  835.             if (data["フォント名"] == fontName) {
  836.                 widthSize = data["横幅サイズ"] || 1;
  837.                 halfSize = data["半角サイズ"] || 1;
  838.                 break;
  839.             }
  840.         }
  841.         return { width:widthSize, half:halfSize };
  842.     };
  843.    
  844.    
  845.    
  846.     //==================================================
  847.     //--  共通開始
  848.     //==================================================
  849.    
  850.     //- ゲームバトラー/TPB初期化(コア追加)
  851.     const _Game_Battler_initTpbChargeTime = Game_Battler.prototype.initTpbChargeTime;
  852.     Game_Battler.prototype.initTpbChargeTime = function(advantageous) {
  853.         _Game_Battler_initTpbChargeTime.apply(this, arguments);
  854.         // 行動予測の開始(TPB)
  855.         if (BattleManager.isTpb()) {
  856.             setTimeout(startPrediction, 0, this);
  857.         }
  858.     };

  859.    
  860.     //- バトルマネージャー/入力の開始(コア追加)
  861.     const _BattleManager_startInput = BattleManager.startInput;
  862.     BattleManager.startInput = function() {
  863.         _BattleManager_startInput.apply(this);
  864.         // 行動予測の開始-全員(ターン)
  865.         if (!BattleManager.isTpb()) {
  866.             startPredictionAll();
  867.         }
  868.     };

  869.    
  870.    
  871.     //==================================================
  872.     //--  共通更新
  873.     //==================================================
  874.    
  875.     //- スプライトエネミー/更新(コア追加)
  876.     const _Sprite_Enemy_update = Sprite_Enemy.prototype.update;
  877.     Sprite_Enemy.prototype.update = function() {
  878.         _Sprite_Enemy_update.apply(this);
  879.         // ターゲットラインの更新
  880.         updateTargetLine(this);
  881.     };


  882.     //- スプライトセット・バトル/更新(コア追加)
  883.     const _Spriteset_Battle_updateBattleback = Spriteset_Battle.prototype.updateBattleback;
  884.     Spriteset_Battle.prototype.updateBattleback = function() {
  885.         // ターゲットライン周期の更新
  886.         updateTargetLineCycle();
  887.         _Spriteset_Battle_updateBattleback.apply(this);
  888.     };


  889.    
  890.     //==================================================
  891.     //--  共通終了
  892.     //==================================================

  893.     //- バトル終了時の処理(コア追加)
  894.     const _BattleManager_endBattle = BattleManager.endBattle;
  895.     BattleManager.endBattle = function(result) {
  896.         _BattleManager_endBattle.apply(this, arguments);
  897.         // 先行ターゲットの消去-全員
  898.         delTargetFastAll();
  899.         // 受容ラインの初期化
  900.         initReceptLine();
  901.     };


  902.     //- スプライトセット・バトル(コア追加)
  903.     const _Spriteset_Battle_destroy = Spriteset_Battle.prototype.destroy
  904.     Spriteset_Battle.prototype.destroy = function(options) {
  905.         // スプライトの全破棄
  906.         destroySpriteAll(this);
  907.         _Spriteset_Battle_destroy.apply(this, arguments);
  908.     };


  909.     //- スプライトの全破棄
  910.     function destroySpriteAll(spriteset) {
  911.         const layers = spriteset._predictionLayersKe;
  912.         if (!layers) { return; }
  913.         // 全てのレイヤーに対して処理
  914.         Object.keys(layers).forEach(key => {
  915.             // スプライトの破棄
  916.             destroySprite(layers[key]);
  917.         });
  918.         spriteset._predictionLayersKe = null;
  919.     };


  920.     //- スプライトの破棄
  921.     function destroySprite(sprite) {
  922.         if (!sprite) { return; }
  923.         sprite.children.forEach(s => destroySprite(s));
  924.         if (sprite.bitmap && !sprite.bitmap._url) { sprite.bitmap.destroy(); }
  925.         if (sprite._texture) { sprite.destroy(); }
  926.     };


  927.     //- バトルマネージャー/ターンの更新(コア追加)
  928.     const _BattleManager_updateTurn = BattleManager.updateTurn;
  929.     BattleManager.updateTurn = function(timeActive) {
  930.         // 再決定の実行
  931.         executeRedo();
  932.         _BattleManager_updateTurn.apply(this, arguments);
  933.     };



  934.     //==================================================
  935.     //--  共通処理
  936.     //==================================================

  937.     //- 全アクションの終了時の処理(コア追加)
  938.     const _BattleManager_endBattlerActions = BattleManager.endBattlerActions;
  939.     BattleManager.endBattlerActions = function(battler) {
  940.         _BattleManager_endBattlerActions.apply(this, arguments);
  941.         // 行動予測の開始
  942.         startPrediction(battler);
  943.     };


  944.     //- ターン終了時の処理(コア追加)
  945.     const _Game_Battler_onTurnEnd = Game_Battler.prototype.onTurnEnd;
  946.     Game_Battler.prototype.onTurnEnd = function() {
  947.         _Game_Battler_onTurnEnd.apply(this);
  948.         // 行動予測の開始
  949.         startPrediction(this);
  950.     };


  951.     //- 行動直前の処理(コア追加)
  952.     const _Game_Action_prepare = Game_Action.prototype.prepare;
  953.     Game_Action.prototype.prepare = function() {
  954.         _Game_Action_prepare.apply(this);
  955.         // 先行ターゲットの適用
  956.         applyTargetFast(this.subject());
  957.         // 不発だったら不発エフェクト
  958.         if (!this.isValid()) {
  959.             misfireEffect(this.subject());
  960.         }
  961.     };


  962.     //- 詠唱開始時の処理
  963.     const _Game_Battler_startTpbCasting = Game_Battler.prototype.startTpbCasting;
  964.     Game_Battler.prototype.startTpbCasting = function() {
  965.         _Game_Battler_startTpbCasting.apply(this);
  966.         // 行動ビューのリフレッシュフラグをオン
  967.         this._refreshsActViewKe = true;
  968.     };


  969.     //- アクション開始時の処理(コア追加)
  970.     const _BattleManager_startAction = BattleManager.startAction;
  971.     BattleManager.startAction = function() {
  972.         _BattleManager_startAction.apply(this);
  973.         // 再決定の処理
  974.         processRedo(this._subject, this._targets, this._action);
  975.     };


  976.     //- 行動不能時の処理(コア追加)
  977.     const _Game_Battler_onRestrict = Game_Battler.prototype.onRestrict;
  978.     Game_Battler.prototype.onRestrict = function() {
  979.         _Game_Battler_onRestrict.apply(this);
  980.         // 行動予約の消去
  981.         delPrediction(this);
  982.     };



  983.     //==================================================
  984.     //--  レイヤー
  985.     //==================================================

  986.     //- ウインドウレイヤー作成時に行動予測レイヤーも作成
  987.     const _Scene_Battle_createWindowLayer = Scene_Battle.prototype.createWindowLayer;
  988.     Scene_Battle.prototype.createWindowLayer = function() {
  989.         _Scene_Battle_createWindowLayer.apply(this);
  990.         // レイヤーの形成
  991.         createLayer(this);
  992.     };


  993.     //- レイヤーの形成
  994.     function createLayer(scene) {
  995.         const spriteset = scene._spriteset;
  996.         const layers = {};
  997.         // Aレイヤー
  998.         const layerA = new SpriteKePrds();
  999.         spriteset.addChild(layerA);
  1000.         layers["A"] = layerA;
  1001.         // Bレイヤー
  1002.         const layerB = new SpriteKePrds();
  1003.         spriteset.addChild(layerB);
  1004.         layers["B"] = layerB;
  1005.         // Cレイヤー
  1006.         const layerC = new SpriteKePrds();
  1007.         scene.addChild(layerC);
  1008.         layers["C"] = layerC;
  1009.         // Dレイヤー
  1010.         const layerD = new SpriteKePrds();
  1011.         scene.addChild(layerD);
  1012.         layers["D"] = layerD;
  1013.         // 変数セット
  1014.         spriteset._predictionLayersKe = layers;
  1015.     };


  1016.     //- レイヤーチルド
  1017.     function childLayer(sprite, id) {
  1018.         SceneManager._scene._spriteset._predictionLayersKe[id].addChild(sprite);
  1019.     };
  1020.    


  1021.     //==================================================
  1022.     //--  メモ欄からの取得
  1023.     //==================================================

  1024.     //- 行動予測設定の取得
  1025.     function getPredictionCfg(battler, tage, calc = "*", action = null, radioIndex) {
  1026.         const metas = totalAllMetaArray(battler, ["行動予測", "prediction"], action, true, radioIndex);
  1027.         if (!metas || !metas.length) { return null; }
  1028.         const array = [];
  1029.         for (const str of metas.reverse()) {
  1030.             if (!str) { continue; }
  1031.             // ずらしX
  1032.             if (tage == "ずらしX") {
  1033.                 const match = str.match(/(^|[,\s\n])(x|offsetX|posX|ずらしX|位置X):\s*(\-*\d+\.*\d*)/i);
  1034.                 if (match && match[3]) {
  1035.                     return Number(match[3]);
  1036.                 }
  1037.                 continue;
  1038.             }
  1039.             // ずらしY
  1040.             if (tage == "ずらしY") {
  1041.                 const match = str.match(/(^|[,\s\n])(y|offsetY|posY|ずらしY|位置Y):\s*(\-*\d+\.*\d*)/i);
  1042.                 if (match && match[3]) {
  1043.                     return Number(match[3]);
  1044.                 }
  1045.                 continue;
  1046.             }
  1047.             // 表示方向
  1048.             if (tage == "表示方向") {
  1049.                 const match = str.match(/(^|[,\s\n])(dire|direction|showDire|表示方向|方向):\s*(中央|左|右|上|下|center|left|right|up|down|c|l|r|u|d)/i);
  1050.                 if (match && match[3]) {
  1051.                     return convertDirection(match[3]);
  1052.                 }
  1053.                 continue;
  1054.             }
  1055.             // テキスト
  1056.             if (tage == "テキスト") {
  1057.                 const match = str.match(/(^|[,\s\n])(text|name|テキスト|文章|名前):\s*([^\s,]+)/i);
  1058.                 if (match && match[3]) {
  1059.                     return match[3];
  1060.                 }
  1061.                 continue;
  1062.             }
  1063.             // アイコン
  1064.             if (tage == "アイコン") {
  1065.                 const match = str.match(/(^|[,\s\n])(icon|showIcon|アイコン|表示アイコン):\s*(\d*),*\s*(\-*\d*\.*\d*)/i);
  1066.                 if (match && (match[3] || match[4])) {
  1067.                     return { index:Number(match[3]), size:Number(match[4]) };
  1068.                 }
  1069.                 continue;
  1070.             }
  1071.             // 行動再決定
  1072.             if (tage == "行動再決定") {
  1073.                 const match = str.match(/(^|[,\s\n])(actRedo|redoAct|行動再決定|再行動)/i);
  1074.                 if (match && match[2]) {
  1075.                     return true
  1076.                 }
  1077.                 continue;
  1078.             }
  1079.             // ターゲット再決定
  1080.             if (tage == "ターゲット再決定") {
  1081.                 const match = str.match(/(^|[,\s\n])(targetRedo|redoAct|ターゲット再決定|再ターゲット)/i);
  1082.                 if (match && match[2]) {
  1083.                     return true
  1084.                 }
  1085.                 continue;
  1086.             }
  1087.             // ラインあり
  1088.             if (tage == "ラインあり") {
  1089.                 const match = str.match(/(^|[,\s\n])(showLine|showTarget|ラインあり|ターゲットあり|ライン表示|ターゲット表示)/i);
  1090.                 if (match && match[2]) {
  1091.                     return true
  1092.                 }
  1093.                 continue;
  1094.             }
  1095.             // ラインなし
  1096.             if (tage == "ラインなし") {
  1097.                 const match = str.match(/(^|[,\s\n])(hideLine|hideTarget|ラインなし|ターゲットなし|ライン非表示|ターゲット非表示)/i);
  1098.                 if (match && match[2]) {
  1099.                     return true
  1100.                 }
  1101.                 continue;
  1102.             }
  1103.             // 無効
  1104.             if (tage == "無効") {
  1105.                 const match = str.match(/(^|[,\s\n])(no|off|none|無効|オフ)/i);
  1106.                 if (match && match[2]) {
  1107.                     return true
  1108.                 }
  1109.                 continue;
  1110.             }
  1111.             // 有効
  1112.             if (tage == "有効") {
  1113.                 const match = str.match(/(^|[,\s\n])(ok|on|valid|有効|オン)/i);
  1114.                 if (match && match[2]) {
  1115.                     return true
  1116.                 }
  1117.                 continue;
  1118.             }
  1119.         }
  1120.         return null;
  1121.     };


  1122.     //- 方向の変換
  1123.     function convertDirection(d) {
  1124.         if (d.match(/center|c/i)) {
  1125.             return "中央";
  1126.         } else if (d.match(/left|l/i)) {
  1127.             return "左";
  1128.         } else if (d.match(/right|r/i)) {
  1129.             return "右";
  1130.         } else if (d.match(/up|u/i)) {
  1131.             return "上";
  1132.         } else if (d.match(/down|d/i)) {
  1133.             return "下";
  1134.         }
  1135.         return d;
  1136.     };


  1137.     //- メモ欄からのフラグの取得
  1138.     function getValidByMemo(subject) {
  1139.         const members = [subject, ...$gameParty.aliveMembers()];
  1140.         // メモ欄に無効フラグがあったら無効
  1141.         if (members.some(battler => getPredictionCfg(battler, "無効"))) { return false; };
  1142.         // メモ欄に有効フラグがあったら有効
  1143.         if (members.some(battler => getPredictionCfg(battler, "有効"))) { return true; };
  1144.         return  null;
  1145.     }



  1146.     //==================================================
  1147.     //--  行動予測システム
  1148.     //==================================================

  1149.     // 再決定予約
  1150.     let redoReserve = null;

  1151.     // 行動予測の開始
  1152.     function startPrediction(subject, force) {
  1153.         // 対象は敵キャラ & 自動キャラのみ
  1154.         if (subject._actorId && !subject.isAutoBattle()) { return; }
  1155.         // 行動の先行作成
  1156.         makeActionFast(subject, force);
  1157.         // ターゲットの先行作成
  1158.         makeTargetFast(subject);
  1159.     };


  1160.     // 行動の先行作成
  1161.     function makeActionFast(subject, force) {
  1162.         if (!subject) { return; }
  1163.         // 行動作成(TPB時のみ)
  1164.         if (BattleManager.isTpb()) {
  1165.             if (!subject._actions.length || force) {
  1166.                 // アクションのクリア
  1167.                 subject.clearActions();
  1168.                 const preActionState = subject._actionState;
  1169.                 // 行動予約がなければアクション作成
  1170.                 subject.makeActions();  
  1171.                 subject.setActionState(preActionState);
  1172.                 // 先行アクションフラグをオン
  1173.                 subject._actionMakedFastKe = true;
  1174.             }
  1175.         }
  1176.         // 行動ビューのリフレッシュフラグをオン
  1177.         subject._refreshsActViewKe = true;
  1178.     };


  1179.     // 行動ビューを表示するか
  1180.     function isActShow() {
  1181.         return keke_actShow;
  1182.     };


  1183.     // ターゲットラインを表示するか
  1184.     function isTargetLineShow(subject) {
  1185.         if (getPredictionCfg(subject, "ラインあり")) { return true; };
  1186.         if (getPredictionCfg(subject, "ラインなし")) { return false; };
  1187.         return keke_lineShow;
  1188.     };


  1189.     //- 行動予測有効か
  1190.     function isValidPrediction(subject) {
  1191.         // 無効スイッチがオンなら無効
  1192.         if ($gameSwitches.value(keke_predictionOffSwitch)) { return false; };
  1193.         //メモ欄に無効フラグがあったら無効
  1194.         const memoValid = getValidByMemo(subject);
  1195.         if (memoValid == false) { return false; }
  1196.         // 常に行動予測/有効スイッチ/有効フラグのいずれかがオンなら有効
  1197.         return keke_predictionAlways || memoValid == true || $gameSwitches.value(keke_predictionOnSwitch);
  1198.     };


  1199.     // 行動予測の開始-全員
  1200.     function startPredictionAll() {
  1201.         // 全てのキャラに対して処理
  1202.         const members = [...$gameTroop.aliveMembers(), ...$gameParty.aliveMembers()];
  1203.         members.forEach(subject => {
  1204.             // 行動予測の開始
  1205.             startPrediction(subject);
  1206.         });
  1207.     };


  1208.     //- 行動入力時に先行アクションを適用(TPB)(コア追加)
  1209.     const _Game_Battler_startTpbTurn = Game_Battler.prototype.startTpbTurn;
  1210.     Game_Battler.prototype.startTpbTurn = function() {
  1211.         // 先行アクションしていたら
  1212.         if (this._actionMakedFastKe) {
  1213.             // フラグオフ
  1214.             this._actionMakedFastKe = false;
  1215.             // 使用できないアクションは不発にさせる
  1216.             const preActionNum = this._actions.filter(action => action.item()).length;
  1217.             this._actions = this._actions.filter(action => action.isValid());
  1218.             // 不発エフェクト
  1219.             if (preActionNum >= 1 && this._actions.length < preActionNum) {
  1220.                 misfireEffect(this);
  1221.             }
  1222.             // 行動作成済みフラグをオン
  1223.             this._isActionMakedKe = true;
  1224.         }
  1225.         _Game_Battler_startTpbTurn.apply(this);
  1226.         // 行動作成済みフラグをオフ
  1227.         this._isActionMakedKe = false;
  1228.         // 先行ターゲットを消去
  1229.         targetFast = null;
  1230.         // 被キャンセルフラグをオフ
  1231.         this._isCanceledKe = true;
  1232.     };


  1233.     //- 不発エフェクト
  1234.     function misfireEffect(battler) {
  1235.         // エフェクトの実行
  1236.         doEffect(keke_actMisfireEffect, battler);
  1237.         //不発ポップアップ
  1238.         misfirePopup(battler);
  1239.     };


  1240.     //- 不発ポップアップ
  1241.     function misfirePopup(battler) {
  1242.         if (!PluginManager._scripts.some(n => n == "Keke_StatePopup")) { return; }
  1243.         // 不発ポップの表示
  1244.         battler.showMisfirePopKeStpp();
  1245.     };


  1246.     //- 行動作成時、行動作成済みなら作成スキップしてそれを採用(コア追加)
  1247.     const _Game_Battler_makeActions = Game_Battler.prototype.makeActions;
  1248.     Game_Battler.prototype.makeActions = function() {
  1249.         if (this._isActionMakedKe) { return; }
  1250.         _Game_Battler_makeActions.apply(this);
  1251.     };

  1252.     const _Game_Battler_numActions = Game_Battler.prototype.numActions;
  1253.     Game_Battler.prototype.numActions = function() {
  1254.         if (this._isActionMakedKe) { return 0; }
  1255.         return _Game_Battler_numActions.apply(this);
  1256.     };


  1257.     //- 先行アクション済みのキャラをチャージ完了まで行動させない
  1258.     /*const _BattleManager_getNextSubject = BattleManager.getNextSubject;
  1259.     BattleManager.getNextSubject = function() {
  1260.         const battler = this._actionBattlers[0];
  1261.         if (battler && battler._actionMakedFastKe) {
  1262.             this._actionBattlers.shift();
  1263.             return null;
  1264.         }
  1265.         return _BattleManager_getNextSubject.apply(this);
  1266.     };*/


  1267.     //- 行動予約の消去
  1268.     function delPrediction(subject) {
  1269.         // アクションを消去
  1270.         subject._actions = [];
  1271.         // 先行アクションフラグをオフ
  1272.         subject._actionMakedFastKe = false;
  1273.         // 行動作成済みフラグをオフ
  1274.         subject._isActionMakedKe = false;
  1275.         // 先行ターゲットの消去
  1276.         delTargetFast(subject);
  1277.     };


  1278.     //- 行動予測時はTPBターン初期値を 1 に(コア追加)
  1279.     const _Game_Battler_initTpbTurn = Game_Battler.prototype.initTpbTurn;
  1280.     Game_Battler.prototype.initTpbTurn = function() {
  1281.         _Game_Battler_initTpbTurn.apply(this);
  1282.         this._tpbTurnCount = 1;
  1283.     };



  1284.     //==================================================
  1285.     //--  行動の再決定
  1286.     //==================================================


  1287.     //- 再決定の処理
  1288.     function processRedo(subject, targets, action) {
  1289.         // ターゲットの重複を削除、敵キャラのみに限定
  1290.         targets = Array.from(new Set(targets)).filter(target => target._enemyId);
  1291.         // 行動再決定
  1292.         if (getPredictionCfg(subject, "行動再決定", "", action)) {
  1293.             // 行動再決定を予約
  1294.             redoReserve = { targets:getRedoTarget(targets), type:"act" };
  1295.             return;
  1296.         }
  1297.         // ターゲット再決定
  1298.         if (getPredictionCfg(subject, "ターゲット再決定", "", action)) {
  1299.             // ターゲット再決定を予約
  1300.             redoReserve = { targets:getRedoTarget(targets), type:"target" };
  1301.             return;
  1302.         }
  1303.     };


  1304.     //- 再決定ターゲットの取得
  1305.     function getRedoTarget(targets) {
  1306.         // ターゲットの敵キャラが入っていたらそのまま返す
  1307.         if (targets.length && targets.some(battler => battler._enemyId)) {
  1308.             return targets;
  1309.         }
  1310.         // そうでなければ敵キャラ全てを返す
  1311.         return $gameTroop.aliveMembers();
  1312.     };


  1313.     //- 再決定の実行
  1314.     function executeRedo() {
  1315.         if (!redoReserve) { return; }
  1316.         const targets = redoReserve.targets;
  1317.         if (!targets || !targets.length) { return; }
  1318.         // 行動再決定の実行
  1319.         if (redoReserve.type == "act") {
  1320.             targets.forEach(target => {
  1321.                 // 行動の先行作成
  1322.                 makeActionFast(target, true);
  1323.                 // ターゲットの先行作成
  1324.                 makeTargetFast(target, true);
  1325.             });
  1326.         // ターゲット再決定の実行
  1327.         } else {
  1328.             targets.forEach(target => {
  1329.                 // ターゲットの先行作成
  1330.                 makeTargetFast(target, true);
  1331.             });
  1332.         }
  1333.         // 予約を消去
  1334.         redoReserve = null;
  1335.     };



  1336.     //==================================================
  1337.     //--  行動ビューウインドウ
  1338.     //==================================================


  1339.     //- 行動ビューウインドウ
  1340.     function Window_ActViewKe() {
  1341.         this.initialize(...arguments);
  1342.     }
  1343.    
  1344.     Window_ActViewKe.prototype = Object.create(Window_Base.prototype);
  1345.     Window_ActViewKe.prototype.constructor = Window_ActViewKe;


  1346.     //- 初期化(コア追加)
  1347.     Window_ActViewKe.prototype.initialize = function(rect) {
  1348.         Window_Base.prototype.initialize.call(this, rect);
  1349.         this.frameVisible = false;
  1350.         this._backSprite.visible = false;
  1351.     };


  1352.     //- 独自背景スプライトを形成(コア追加)
  1353.     Window_ActViewKe.prototype._createBackSprite = function() {
  1354.         Window_Base.prototype._createBackSprite.call(this);
  1355.         // スプライト形成 & チルド
  1356.         this._backSpriteKe = new SpriteKePrds();
  1357.         this._container.addChild(this._backSpriteKe);
  1358.     };


  1359.     //- 背景の描画
  1360.     Window_ActViewKe.prototype.drawBackKe = function(width, height, color) {
  1361.         // 背景を描画
  1362.         const bitmap = new Bitmap(this._width, this._height);
  1363.         const padding = this._padding;
  1364.         /*const backW = this._width// - padding * 2;
  1365.         const backH = this._height// - padding * 2;*/
  1366.         bitmap.fillRect(padding, padding, width, height, color);
  1367.         // ビットマップを挿入
  1368.         const backSprite = this._backSpriteKe;
  1369.         if (backSprite.bitmap) { backSprite.bitmap.destroy(); }
  1370.         backSprite.bitmap = bitmap;
  1371.     };


  1372.     //- フォント基本設定(コア追加)
  1373.     Window_ActViewKe.prototype.resetFontSettings = function() {
  1374.         const contents = this.contents;
  1375.         contents.fontFace = keke_actFontFace || $gameSystem.mainFontFace();
  1376.         contents.fontSize = keke_actFontSize;
  1377.         this.changeTextColor(isCasting(this._battlerKe) ? keke_actFontColorCast : keke_actFontColor);
  1378.         this.changeOutlineColor(ColorManager.outlineColor());
  1379.         contents.outlineWidth = keke_actOutW;
  1380.     };
  1381.    

  1382.     //- テキストの高さの計算(コア追加)
  1383.     Window_ActViewKe.prototype.calcTextHeight = function(textState) {
  1384.         const lastFontSize = this.contents.fontSize;
  1385.         const lines = textState.text.slice(textState.index).split("\n");
  1386.         const textHeight = this.maxFontSizeInLine(lines[0]) + keke_actLineSpace;
  1387.         this.contents.fontSize = lastFontSize;
  1388.         return textHeight;
  1389.     };


  1390.     //- テキストステート作成処理(コア追加)
  1391.     Window_ActViewKe.prototype.createTextState = function(text, x, y, width) {
  1392.         const textState = Window_Base.prototype.createTextState.call(this, text, x, y, width);
  1393.         // テキストステートを保存
  1394.         this._textState = textState;
  1395.         // 各行のフレームを記録する変数を作成
  1396.         textState.lineFrames = [];
  1397.         // 1行目のフレームを保存
  1398.         textState.lineFrames.push(this.getLineFrame(textState));
  1399.         return textState;
  1400.     };


  1401.     //- 行替えの処理(コア追加)
  1402.     Window_ActViewKe.prototype.processNewLine = function(textState) {
  1403.         Window_Base.prototype.processNewLine.call(this, textState);
  1404.         // 新しい行のフレームを保存
  1405.         textState.lineFrames.push(this.getLineFrame(textState));
  1406.     };


  1407.     //- テキスト書き出しの処理(コア追加)
  1408.     Window_ActViewKe.prototype.flushTextState = function(textState) {
  1409.         const preOutputHeight = textState.outputHeight;
  1410.         // テキスト横幅を取得
  1411.         const text = textState.buffer;
  1412.         const fontSize = this.contents.fontSize;
  1413.         const fontSizeRate = getFontSizeRate(this.contents.fontFace);
  1414.         const textW = Math.max(strWidth(text, fontSize, fontSizeRate));
  1415.         Window_Base.prototype.flushTextState.call(this, textState);
  1416.         // 行フレームの横幅を更新
  1417.         const lineFrames = textState.lineFrames;
  1418.         lineFrames[lineFrames.length - 1].width += textW;
  1419.         // 書き出しがなかったらアウトプットヘイトの更新を無効
  1420.         if (!text) {
  1421.             textState.outputHeight = preOutputHeight;
  1422.         }
  1423.     };


  1424.     //- 行フレームの取得
  1425.     Window_ActViewKe.prototype.getLineFrame = function(textState) {
  1426.         const x = textState.x;
  1427.         const y = textState.y;
  1428.         const width = 0;
  1429.         const height = textState.height;
  1430.         const heightEx = textState.height - keke_actLineSpace;
  1431.         const text = textState.text.slice(textState.index);
  1432.         // 行頭か判定(改行文字による行でないか)
  1433.         let isTop = false;
  1434.         if (text.match(/^topke/)) {
  1435.             isTop = true;
  1436.             textState.index += 5;
  1437.         }
  1438.         return { x:x, y:y, width:width, height:height, heightEx:heightEx, isTop:isTop };
  1439.     };



  1440.     //==================================================
  1441.     //--  行動ビュー
  1442.     //==================================================

  1443.     //- スプライトバトラー/更新(コア追加)
  1444.     const _Sprite_Battler_update = Sprite_Battler.prototype.update;
  1445.     Sprite_Battler.prototype.update = function() {
  1446.         _Sprite_Battler_update.apply(this);
  1447.         // 行動ビューの更新
  1448.         updateActView(this, this._battler);
  1449.     };


  1450.     //- 行動ビューの更新
  1451.     function updateActView(battlerSprite, battler) {
  1452.         if (!battler) { return; }
  1453.         if (BattleManager._phase == "start" && !$gameTroop.isEventRunning()) { return; }
  1454.         // 行動ビューリフレッシュの更新
  1455.         updateActViewRefresh(battler);
  1456.         // 行動ビュースプライトを更新
  1457.         const actWindow = battlerSprite._actWindowKe;
  1458.         if (actWindow) {
  1459.             // 行動ビューの可視更新
  1460.             updateViewVisibleAct(actWindow, battler);
  1461.         }
  1462.     };


  1463.     //- 行動ビューリフレッシュの更新
  1464.     function updateActViewRefresh(subject) {
  1465.         if (!subject._refreshsActViewKe) { return; }
  1466.         const asi = getFullAnimeStatusAsi(subject);
  1467.         const faceSprite = asi ? asi.faceBaseSprite : null;
  1468.         if (faceSprite) {
  1469.             if (asi.startNear) { return; }
  1470.             // 行動ビューのリフレッシュ
  1471.             refreshActView(subject);
  1472.         } else {
  1473.             const subjectSprite = searchSpriteBattler(subject);
  1474.             if (!subjectSprite || !subjectSprite._frame.width) { return;}
  1475.             // 行動ビューのリフレッシュ
  1476.             refreshActView(subject, subjectSprite);
  1477.         }
  1478.     };


  1479.     //- 行動ビューのリフレッシュ
  1480.     function refreshActView(battler, battlerSprite) {
  1481.         battlerSprite = battlerSprite || searchSpriteBattler(battler);
  1482.         if (!battlerSprite) { return; }
  1483.         const actions = battler._actions.filter(action => action && action.item());
  1484.         const skillNames = actions.map(action => getSkillName(action)).filter(a => a);
  1485.         // 行動テキストの作成
  1486.         const text = makeActText(skillNames);
  1487.         // 行動ビューの形成
  1488.         createActView(battlerSprite, battler, actions.length, text);
  1489.         const actWindow = battlerSprite._actWindowKe;
  1490.         // テキストを描画
  1491.         const outW = keke_actOutW;
  1492.         actWindow.drawTextEx(text, outW / 2, outW / 2, Graphics.width);
  1493.         // 描画したテキストステートからフレームを取得
  1494.         const textState = actWindow._textState;
  1495.         const frames = textState.lineFrames;
  1496.         // 行動アイコンの作成
  1497.         const iconW = makeActIcon(actWindow, battler, actions, frames);
  1498.         // 行動ビューの可視更新
  1499.         updateViewVisibleAct(actWindow, battler);
  1500.         // メモ欄からの位置設定を取得
  1501.         actWindow._memoXKe = getPredictionCfg(battler, "ずらしX", "", actions[0]) || 0;
  1502.         actWindow._memoYKe = getPredictionCfg(battler, "ずらしY", "", actions[0]) || 0;
  1503.         actWindow._showDireKe = getPredictionCfg(battler, "表示方向", "", actions[0]);
  1504.         // 最大横幅を保存
  1505.         let widthMax = null;
  1506.         frames.forEach(frame => {
  1507.             // アイコン幅をフレームに保存
  1508.             frame.iconW = iconW;
  1509.             if (widthMax == null || frame.width > widthMax) {
  1510.                 widthMax = frame.width;
  1511.             }
  1512.         });
  1513.         // 背景の描画
  1514.         actWindow.drawBackKe(widthMax + keke_actOutW, textState.outputHeight + keke_actOutW, keke_actBackColor);
  1515.         if (widthMax != null) { actWindow._widthKe = widthMax; }
  1516.         // 行動ビューの位置更新
  1517.         updateViewPosAct(actWindow, battlerSprite, battler);
  1518.         // フレームを保存
  1519.         battlerSprite._actFramesKe = frames;
  1520.         // リフレッシュフラグをオフ
  1521.         battler._refreshsActViewKe = null;
  1522.     };


  1523.     //- スキル名の取得
  1524.     function getSkillName(action) {
  1525.         const item = action.item();
  1526.         // スキル名を取得
  1527.         const skillName = item.name;
  1528.         // メモ欄から表示名を取得
  1529.         const showName = getPredictionCfg(null, "テキスト", "", action);
  1530.         return showName || skillName;
  1531.     };


  1532.     //- 行動テキストの作成
  1533.     function makeActText(skillNames) {
  1534.         let text = "";
  1535.         skillNames.forEach(name => {
  1536.             name = name.replace(/\\n/g, "\n");
  1537.             text += "topke" + name +"\n";
  1538.         });
  1539.         return text;
  1540.     };


  1541.     //- 行動ビューの形成
  1542.     function createActView(battlerSprite, battler, actionNum, text) {
  1543.         const preSprite = battlerSprite._actWindowKe;
  1544.         if (preSprite && preSprite._actionNum == actionNum) { return; }
  1545.         // 前のがあったら破棄
  1546.         if (preSprite) {
  1547.             destroyActView(preSprite);
  1548.         }
  1549.         // 仮ウインドウを作成
  1550.         const tempWindow = new Window_ActViewKe({ x:0, y:0, width:Graphics.width, height:Graphics.height });
  1551.         // テキストのサイズを取得
  1552.         const outW = keke_actOutW;
  1553.         const sizes = tempWindow.textSizeEx(text, 0, 0, Graphics.width);
  1554.         sizes.width += outW;
  1555.         sizes.height += outW;
  1556.         // ウインドウ形成
  1557.         const padding = tempWindow._padding;
  1558.         const windowWidth = keke_actW + padding * 2;
  1559.         const windowHeight = sizes.height + padding * 2;
  1560.         const windo = new Window_ActViewKe({ x:0, y:0, width:windowWidth, height:windowHeight });
  1561.         tempWindow.destroy();
  1562.         // チルド
  1563.         const scene = SceneManager._scene;
  1564.         const layerId = keke_actLayer == "ウインドウより上" ? "D" : "B";
  1565.         childLayer(windo, layerId);
  1566.         // 原点
  1567.         const pos = battler._enemyId ? keke_actPosEnemy : keke_actPosActor;
  1568.         // 変数セット
  1569.         battlerSprite._actWindowKe = windo;
  1570.         // スプライトにサイズを保存
  1571.         windo._widthKe = sizes.width;
  1572.         windo._heightKe = sizes.height + keke_actLineSpace;
  1573.         // ウインドウを中心に配置するために位置補正
  1574.         windo._centerXKe = -windo._width / 2 - windo._padding + (windowWidth - sizes.width) / 2;
  1575.         windo._centerYKe = -windo._height + windo._padding
  1576.         // バトラーを保存
  1577.         windo._battlerKe = battler;
  1578.         // アクション数を保存
  1579.         windo._actionNumKe = actionNum;
  1580.         // 表示方向を保存
  1581.         windo._direKe = pos["表示方向"];
  1582.     };


  1583.     //- 行動アイコンの作成
  1584.     function makeActIcon(actWindow, battler, actions, frames) {
  1585.         if (!keke_actShowIcon) { return; }
  1586.         let iconWMax = 0;
  1587.         // 全てのアクションに対して処理
  1588.         actions.forEach((action, i) => {
  1589.             // アイコンデータの取得
  1590.             const iconData = getIconData(action);
  1591.             // 行フレームの取得
  1592.             const frame = getLineFrame(frames, i);
  1593.             // アイコンスプライトの形成
  1594.             const iconSprite = createIconSprite(iconData.index);
  1595.             // サイズを設定
  1596.             const iconW = frame.height * iconData.size;
  1597.             iconSprite.scale.x = iconW / ImageManager.iconWidth;
  1598.             iconSprite.scale.y = iconW / ImageManager.iconHeight;
  1599.             iconWMax = Math.max(iconW, iconWMax) + keke_actIconSpace;
  1600.             // 位置を設定
  1601.             const padding = actWindow._padding;
  1602.             iconSprite.x = padding - iconW / 2 - keke_actIconSpace;
  1603.             iconSprite.y = padding + frame.y + frame.height / 2;
  1604.             // レイヤーチルド
  1605.             actWindow.addChild(iconSprite);
  1606.             // 変数セット
  1607.             if (!actWindow._iconSpritesKe) { actWindow._iconSpritesKe = []; }
  1608.             actWindow._iconSpritesKe.push(iconSprite);
  1609.             // 烈の中心をアイコン分だけ左にずらす
  1610.             frame.x -= iconWMax / 2;
  1611.         });
  1612.         // 行動ビューをアイコンの分、右にずらす
  1613.         actWindow._iconXKe = iconWMax / 2;
  1614.         return iconWMax;
  1615.     };


  1616.     //- 行フレームの取得
  1617.     function getLineFrame(frames, tage_i) {
  1618.         let i = -1;
  1619.         let true_i = 0;
  1620.         for (const frame of frames) {
  1621.             i++;
  1622.             if (!frame.isTop) { continue; }
  1623.             if (true_i == tage_i) { break; }
  1624.             true_i++;
  1625.         };
  1626.         return frames[i];
  1627.     };


  1628.     //- アイコンデータの取得
  1629.     function getIconData(action) {
  1630.         const item = action.item();
  1631.         // スキルのアイコンを取得
  1632.         const iconIndex = item.iconIndex;
  1633.         // メモ欄から表示アイコンを取得
  1634.         const d = getPredictionCfg(null, "アイコン", "", action) || {};
  1635.         return { index:d.index || iconIndex, size:(d.size || keke_actIconSize) / 100 };
  1636.     };


  1637.     //- 行動ビューの位置更新
  1638.     function updateViewPosAct(sprite, battlerSprite, battler) {
  1639.         const pos = battler._enemyId ? keke_actPosEnemy : keke_actPosActor;
  1640.         const dire = sprite._showDireKe || pos["表示方向"];
  1641.         const asi = getFullAnimeStatusAsi(battler);
  1642.         // フルアニメ
  1643.         if (asi && asi.visible) {
  1644.             const frame = asi.frame;
  1645.             const faceFrame = asi.faceFrame;
  1646.             sprite.x = frame.x;
  1647.             sprite.y = frame.y;
  1648.             if (faceFrame.width) {
  1649.                 const direX = dire == "左" ? -faceFrame.width / 2 : dire == "右" ? faceFrame.width / 2 : 0;
  1650.                 const direY = dire == "上" ? -faceFrame.height / 2 : dire == "下" ? faceFrame.height / 2 : 0;
  1651.                 sprite.x += faceFrame.x + direX;
  1652.                 sprite.y += faceFrame.y + direY;
  1653.             } else {
  1654.                 const direX = dire == "左" ? -frame.width / 2 : dire == "右" ? frame.width / 2 : 0;
  1655.                 const direY = dire == "上" ? -frame.height / 2 : dire == "下" ? frame.height / 2 : 0;
  1656.                 sprite.y += direY;
  1657.                 sprite.x += direX;
  1658.             }
  1659.         // 通常
  1660.         } else {
  1661.             const frame = battlerSprite._frame;
  1662.             const battlerW = frame.width * battlerSprite.scale.x;
  1663.             const battlerH = frame.height * battlerSprite.scale.y;
  1664.             const direX = dire == "左" ? -battlerW / 2 : dire == "右" ? battlerW / 2 : 0;
  1665.             const direY = dire == "下" ? 0 : dire == "中央" ? -battlerH / 2 : -battlerH * 1.1;
  1666.             sprite.x = battlerSprite._homeX + direX;
  1667.             sprite.y = battlerSprite._homeY + direY;
  1668.         }
  1669.         // 共通の位置
  1670.         sprite.x += (pos["ずらしX"] || 0) + (sprite._iconXKe || 0) + sprite._memoXKe + sprite._centerXKe;
  1671.         sprite.y += (pos["ずらしY"] || 0) + sprite._memoYKe + sprite._centerYKe;
  1672.         // 鋼体ビューがあるなら上にずらす
  1673.         /*if (existSteelView(battlerSprite, dire)) {
  1674.             sprite.y -= battlerSprite._steelSpriteKe._heightKe || 0;
  1675.         }*/
  1676.          // 行動ビューとの合計高さを取得
  1677.          const isSteelView = existSteelView(battlerSprite, dire);
  1678.          const steelH = isSteelView ? battlerSprite._steelSpriteKe._heightKe : 0;
  1679.         // 画面外に出さない
  1680.         noOutScreen(sprite, sprite._widthKe, sprite._widthKe, sprite._padding, steelH);
  1681.     };


  1682.     //- 鋼体ビューがあるか
  1683.     function existSteelView(battlerSprite, dire) {
  1684.         const steelSprite = battlerSprite._steelSpriteKe;
  1685.         if (!steelSprite) { return false; }
  1686.         if (steelSprite._direKe != dire) { return false;}
  1687.         return true;
  1688.     };


  1689.     //- 画面外に出さない
  1690.     function noOutScreen(sprite, width, height, padding, upPlus) {
  1691.         // 非表示範囲を取得
  1692.         noShowScope = keke_actNoShowScope || {};
  1693.         // 上下左右の端の位置を取得
  1694.         const leftEdge = sprite.x + padding;
  1695.         const rightEdge = sprite.x + width - padding;
  1696.         const upEdge = sprite.y + padding - upPlus;
  1697.         const downEdge = sprite.y + height - padding;
  1698.         // 上下左右の超過分を取得
  1699.         const leftOver = leftEdge - (noShowScope["左"] || 0);
  1700.         const rightOver = rightEdge - (Graphics.width - (noShowScope["右"] || 0));
  1701.         const upOver = upEdge - (noShowScope["上"] || 0);
  1702.         const downOver = downEdge - (Graphics.height - (noShowScope["下"] || 0));
  1703.         // 超過分だけ位置をずらす
  1704.         if (leftOver < 0) {
  1705.             sprite.x -= leftOver;
  1706.         } else if (rightOver > 0) {
  1707.             sprite.x -= rightOver;
  1708.         }
  1709.         if (upOver < 0) {
  1710.             sprite.y -= upOver;
  1711.         } else if (downOver > 0) {
  1712.             sprite.y -= downOver;
  1713.         }
  1714.     };


  1715.     //- 行動ビューの破棄
  1716.     function destroyActView(actWindow) {
  1717.         actWindow.destroy();
  1718.         const iconSprites = actWindow._iconSpritesKe;
  1719.         if (iconSprites && iconSprites.length) {
  1720.             iconSprites.forEach(sprite => sprite.destroy());
  1721.         }
  1722.         actWindow._iconSpritesKe = [];
  1723.     };


  1724.     //- 行動ビューの可視更新
  1725.     function updateViewVisibleAct(sprite, battler) {
  1726.         if (isVisibleAct(battler)) {
  1727.             sprite.visible = true;
  1728.         } else {
  1729.             sprite.visible = false;
  1730.         }
  1731.     };


  1732.     //- 見えるか-行動
  1733.     function isVisibleAct(battler) {
  1734.         if (BattleManager._phase == "battleEnd") { return false;}
  1735.         if (!isActShow() || !isValidPrediction(battler)) { return false; }
  1736.         if (isActing(battler) || battler.isRestricted()) { return false; }
  1737.         if (keke_actOnlyInput && !BattleManager.isInputting()) { return false; }
  1738.         if (battler._actorId) {
  1739.             let valid = false;
  1740.             if (keke_actShowCastActor && isCasting(battler)) { valid = true; }
  1741.             if (keke_actShowAutoActor && isAutoBattle(battler)) { valid = true; }
  1742.             if (!valid) { return false; }
  1743.         }
  1744.         return true;
  1745.     };


  1746.     //- 行動中か
  1747.     function isActing(battler) {
  1748.         return battler.isActing() || isActingSpeedStar(battler);
  1749.     };

  1750.     //- 行動中か(スピードスター)
  1751.     function isActingSpeedStar(battler) {
  1752.         const isSpeedStar = PluginManager._scripts.some(n => n == "Keke_SpeedStarBattle");
  1753.         const subject = BattleManager._action ? BattleManager._action.subject() : null;
  1754.         return isSpeedStar && BattleManager._battleWaitKe && subject && subject == battler;
  1755.     };


  1756.     //- 詠唱中か
  1757.     function isCasting(battler, isStart) {
  1758.         if (!battler) { return false; }
  1759.         const state = battler._tpbState;
  1760.         const isActive = battler.isAlive() && !battler.isRestricted() && BattleManager._phase != "battleEnd";
  1761.         return state.match(/casting/) && isActive && (isStart ? true : battler._tpbCastTime);
  1762.     };


  1763.     //- 自動戦闘中か
  1764.     function isAutoBattle(battler) {
  1765.         if (!battler) { return false; }
  1766.         return battler.isAutoBattle();
  1767.     };



  1768.     //==================================================
  1769.     //--  ターゲット予測
  1770.     //==================================================

  1771.     // 先行ターゲット
  1772.     let targetFast = null;

  1773.     //- ターゲットの先行作成
  1774.     function makeTargetFast(subject, redo) {
  1775.         // 対象は敵キャラのみ
  1776.         if (subject._actorId) { return; }
  1777.         // アクションを取得
  1778.         const actions = subject._actions;
  1779.         if (!actions.length) { return; }
  1780.         // ターゲットを作成
  1781.         let targets = [];
  1782.         let targetsForLine = [];
  1783.         actions.forEach((action, i) => {
  1784.             // 再決定時は強制ターゲットを消去
  1785.             if (redo) { action._targetIndex = -1; }
  1786.             // アクションのターゲットを取得
  1787.             const t = getActionTargets(action);
  1788.             if (t.list) { targets[i] = t.list; }
  1789.             if (t.listForLine) { targetsForLine[i] = t.listForLine; }
  1790.         });
  1791.         // ターゲットを保存
  1792.         if (targets.length) {
  1793.             subject._targetsFastKe = { lists:targets, listsForLine:targetsForLine };
  1794.             // ターゲットラインのリフレッシュ
  1795.             refreshTargetLine(subject);
  1796.         }
  1797.     };


  1798.     //- アクションのターゲットを取得
  1799.     function getActionTargets(action) {
  1800.         if (!action.item()) { return {}; }
  1801.         // ターゲットの作成
  1802.         const tages = action.makeTargets();
  1803.         if (!tages.length) { return {}; }
  1804.         // 実際のターゲット用
  1805.         let list = tages.map(target => battlerToId(target));
  1806.         // ターゲットライン用
  1807.         let listForLine = [];
  1808.         // 対全体か
  1809.         const isAll = isForAllAction(action);
  1810.         // 全体ワードの時は全体ワードフラグを挿入
  1811.         if (isAll && keke_lineWordIfAll) {
  1812.             listForLine.push({ isAll:true, isAllWord:true });
  1813.         // それ以外はターゲットが重複しないように挿入
  1814.         } else {
  1815.             const line = [];
  1816.             tages.forEach(target => {
  1817.                 if (!line.includes(target)) { line.push(target); }
  1818.             });
  1819.             listForLine = line.map(target => battlerToId(target));
  1820.             listForLine[0].isAll = isAll;
  1821.         }
  1822.         return { list:list, listForLine:listForLine };
  1823.     };


  1824.     //- 対全体アクションか
  1825.     function isForAllAction(action) {
  1826.         if (!action || !action.item()) { return false; }
  1827.         return action.isForAll() || action.isForEveryone();
  1828.     };


  1829.     //- 先行ターゲットの適用
  1830.     function applyTargetFast(subject) {
  1831.         if (!subject._targetsFastKe || !subject._targetsFastKe.lists.length) { return; }
  1832.         // ターゲットラインの消去
  1833.         delTargetLine(subject);
  1834.         // 先行ターゲットリストを取得
  1835.         const targets = subject._targetsFastKe.lists.shift();
  1836.         if (!targets || !targets.length) { return; }
  1837.         // 先行ターゲットをセット
  1838.         targetFast = targets.map(id => idToBattler(id)).filter(target => target.isAlive());
  1839.     };


  1840.     //- 先行ターゲット済みならそれを適用(コア追加)
  1841.     const _Game_Action_makeTargets = Game_Action.prototype.makeTargets;
  1842.     Game_Action.prototype.makeTargets = function() {
  1843.         if (targetFast) { return targetFast; }
  1844.         return _Game_Action_makeTargets.apply(this);
  1845.     };


  1846.     //- アクション消去時に先行ターゲットも消去(コア追加)
  1847.     const _Game_Battler_removeCurrentAction = Game_Battler.prototype.removeCurrentAction;
  1848.     Game_Battler.prototype.removeCurrentAction = function() {
  1849.         _Game_Battler_removeCurrentAction.apply(this);
  1850.         targetFast = null;
  1851.     };


  1852.     //- 先行ターゲットの消去
  1853.     function delTargetFast(subject) {
  1854.         if (subject._actorId) { return; }
  1855.         if (!subject._targetsFastKe || !subject._targetsFastKe.lists.length) { return; }
  1856.         subject._targetsFastKe = null;
  1857.         // ターゲットラインの消去
  1858.         delTargetLine(subject);
  1859.     };


  1860.     //- 先行ターゲットの消去-全員
  1861.     function delTargetFastAll() {
  1862.         $gameTroop.members().forEach(subject => {
  1863.             // 先行ターゲットの消去
  1864.             delTargetFast(subject);
  1865.         });
  1866.     };



  1867.     //==================================================
  1868.     //--  ターゲットの再決定
  1869.     //==================================================

  1870.     //- 被ターゲットが戦闘不能になったらターゲットの修正(コア追加)
  1871.     const _Game_Battler_die = Game_Battler.prototype.die;
  1872.     Game_Battler.prototype.die = function() {
  1873.         _Game_Battler_die.apply(this);
  1874.         // 個別ターゲットの修正
  1875.         setTimeout(restoreEachTarget, 0, this);
  1876.         // 全体ターゲットの修正
  1877.         setTimeout(restoreAllTarget, 0, this);
  1878.     };


  1879.     //- 被ターゲット側が復活したら全体ターゲットの修正(コア追加)
  1880.     const _Game_Battler_revive = Game_Battler.prototype.revive;
  1881.     Game_Battler.prototype.revive = function() {
  1882.         _Game_Battler_revive.apply(this);
  1883.         // 全体ターゲットの修正
  1884.         setTimeout(restoreAllTarget, 0, this);
  1885.     };


  1886.     //- メンバーが加わった時に全体ターゲットの修正(コア追加)
  1887.     const _Game_Party_addActor = Game_Party.prototype.addActor;
  1888.     Game_Party.prototype.addActor = function(actorId) {
  1889.         _Game_Party_addActor.apply(this, arguments);
  1890.         if (inBattle()) {
  1891.             // 加わったアクターを取得
  1892.             const actor = $gameParty.members().find(a => a._actorId == actorId);
  1893.             if (actor) {
  1894.                 // 全体ターゲットの修正
  1895.                 setTimeout(restoreAllTarget, 300, actor);   
  1896.             }
  1897.         }
  1898.     };


  1899.     //- メンバーが外れた時にターゲットの修正(コア追加)
  1900.     const _Game_Party_removeActor = Game_Party.prototype.removeActor;
  1901.     Game_Party.prototype.removeActor = function(actorId) {
  1902.         // 外れたアクターを取得
  1903.         let actor = null;
  1904.         if (inBattle()) {
  1905.             actor = $gameParty.members().find(a => a._actorId == actorId);
  1906.         }
  1907.         _Game_Party_removeActor.apply(this, arguments);
  1908.         if (actor) {
  1909.             // 個別ターゲットの修正
  1910.             setTimeout(restoreEachTarget, 300, actor);
  1911.             // 全体ターゲットの修正
  1912.             setTimeout(restoreAllTarget, 300, actor);
  1913.         }
  1914.     };


  1915.     //- 戦闘中か
  1916.     function inBattle() {
  1917.         // 戦闘中以外はリターン
  1918.         if (!$gameParty.inBattle) { return false; }
  1919.         // 戦闘開始時はリターン
  1920.         if (!BattleManager._phase || BattleManager._phase == "start") { return false; }
  1921.         return true;
  1922.     };


  1923.     //- 個別ターゲットの修正
  1924.     function restoreEachTarget(delTarget) {
  1925.         if (!delTarget) { return; }
  1926.         // 全ての敵キャラに対して処理
  1927.         $gameTroop.aliveMembers().forEach(subject => {
  1928.             const targets = subject._targetsFastKe;
  1929.             if (!targets || !targets.listsForLine.length) { return; }
  1930.             // 全ての行動に対して判定
  1931.             targets.listsForLine.forEach((tages, i) => {
  1932.                 // 対全体はリターン
  1933.                 if (tages[0].isAll) { return; }
  1934.                 // 消去ターゲットがターゲットに含まれてなければリターン
  1935.                 if (!tages.some(target => idToBattler(target) == delTarget)) { return; }
  1936.                 // アクションを取得
  1937.                 const action = subject._actions[i];
  1938.                 if (!action) { return; }
  1939.                 // アクションのターゲットを取得
  1940.                 const t = getActionTargets(action);
  1941.                 // ターゲットを修正
  1942.                 if (t.list) { targets.lists[i] = t.list; };
  1943.                 if (t.listForLine) { targets.listsForLine[i] = t.listForLine; };
  1944.                 // ターゲットラインのリフレッシュ
  1945.                 refreshTargetLine(subject);
  1946.             });
  1947.         });
  1948.     };


  1949.     //- 全体ターゲットの修正
  1950.     function restoreAllTarget(target) {
  1951.         if (!target) { return; }
  1952.         // 全ての敵キャラに対して処理
  1953.         $gameTroop.aliveMembers().forEach(subject => {
  1954.             const targets = subject._targetsFastKe;
  1955.             if (!targets || !targets.listsForLine.length) { return; }
  1956.             // 全ての行動に対して判定
  1957.             targets.listsForLine.forEach((tages, i) => {
  1958.                 // 対全体以外はリターン
  1959.                 if (!tages[0].isAll) { return; }
  1960.                 // アクションを取得
  1961.                 const action = subject._actions[i];
  1962.                 if (!action) { return; }
  1963.                 // アクションのターゲットを取得
  1964.                 const t = getActionTargets(action);
  1965.                 // ターゲットを修正
  1966.                 if (t.list) { targets.lists[i] = t.list; };
  1967.                 if (t.listForLine) { targets.listsForLine[i] = t.listForLine; };
  1968.                 // ターゲットラインのリフレッシュ
  1969.                 refreshTargetLine(subject);
  1970.             });
  1971.         });
  1972.     };


  1973.     //- 先行ターゲットの更新判定
  1974.     /*function judgeTargetFastUpdate(target) {
  1975.         // 全ての敵キャラに対して処理
  1976.         $gameTroop.aliveMembers().forEach(subject => {
  1977.             const targets = subject._targetsFastKe;
  1978.             if (!targets || !targets.lists.length) { return; }
  1979.             // ターゲットに戦闘不能になったキャラが含まれているか判定
  1980.             if (targets.lists.some(list => list.some(id => idToBattler(id) == target))) {
  1981.                 // 含まれていたらターゲットの先行作成
  1982.                 makeTargetFast(subject);
  1983.             }
  1984.         });
  1985.     };*/


  1986.     //- 先行ターゲットの更新判定-全体
  1987.     /*function judgeTargetFastUpdateForAll(target) {
  1988.         // 全ての敵キャラに対して処理
  1989.         $gameTroop.aliveMembers().forEach(subject => {
  1990.             const targets = subject._targetsFastKe;
  1991.             if (!targets || !targets.lists.length) { return; }
  1992.             // 全体攻撃か判定
  1993.             if (!targets.isAll) { return; }
  1994.             // 全体攻撃ならターゲットの先行作成
  1995.             makeTargetFast(subject);
  1996.         });
  1997.     };*/



  1998.     //==================================================
  1999.     //--  ターゲットライン
  2000.     //==================================================

  2001.     //- ターゲットラインのリフレッシュ
  2002.     function refreshTargetLine(subject) {
  2003.         subject._makesTargetLineKe = true;
  2004.     };


  2005.     //- ターゲットラインのリフレッシュ-全員
  2006.     function refreshTargetLineAll() {
  2007.         $gameTroop.members().forEach(subject => {
  2008.             subject._makesTargetLineKe = true;
  2009.         });
  2010.     };


  2011.     //- ステータスウインドウが移動したらターゲットラインをリフレッシュ
  2012.     const _Scene_Battle_updateStatusWindowPosition = Scene_Battle.prototype.updateStatusWindowPosition;
  2013.     Scene_Battle.prototype.updateStatusWindowPosition = function() {
  2014.         const statusWindow = this._statusWindow;
  2015.         const targetX = this.statusWindowX();
  2016.         const preSame = statusWindow.x == targetX;
  2017.         _Scene_Battle_updateStatusWindowPosition.apply(this);
  2018.         if (statusWindow.visible) {
  2019.             const same = statusWindow.x == targetX;;
  2020.             if (!preSame && same) {
  2021.                 // ターゲットラインのリフレッシュ-全員
  2022.                 refreshTargetLineAll();
  2023.             }
  2024.         }
  2025.     };


  2026.     //- アクター移動終了時にターゲットラインをリフレッシュ
  2027.     const _Sprite_Actor_onMoveEnd = Sprite_Actor.prototype.onMoveEnd;
  2028.     Sprite_Actor.prototype.onMoveEnd = function() {
  2029.         _Sprite_Actor_onMoveEnd.apply(this);
  2030.         // ターゲットラインのリフレッシュ-全員
  2031.         refreshTargetLineAll();
  2032.     };


  2033.     //- ターゲットラインの更新
  2034.     function updateTargetLine(sprite) {
  2035.         if (BattleManager._phase == "start" && !$gameTroop.isEventRunning()) { return; }
  2036.         const subject = sprite._battler;
  2037.         // ターゲットライン作成の更新
  2038.         updateTargetLineMake(subject);
  2039.         // ターゲットライン明滅の更新
  2040.         updataTargetLineFlicker(subject, sprite);
  2041.         // ターゲットラインの可視更新
  2042.         updateTargetLineVisible(subject, sprite);
  2043.     };


  2044.     //- ターゲットライン作成の更新
  2045.     function updateTargetLineMake(subject) {
  2046.         if (!subject._makesTargetLineKe) { return; }
  2047.         const asi = getFullAnimeStatusAsi(subject);
  2048.         const faceSprite = asi ? asi.faceBaseSprite : null;
  2049.         if (faceSprite) {
  2050.             if (asi.startNear) { return; }
  2051.             // ターゲットラインの作成
  2052.             makeTargetLine(subject);
  2053.         } else {
  2054.             const subjectSprite = searchSpriteBattler(subject);
  2055.             if (!subjectSprite || !subjectSprite._frame.width) { return;}
  2056.             // ターゲットラインの作成
  2057.             makeTargetLine(subject);
  2058.         }
  2059.     };


  2060.     //- ターゲットラインの作成
  2061.     function makeTargetLine(subject) {
  2062.         // ターゲットラインの消去
  2063.         delTargetLine(subject);
  2064.         // アクションがない場合はリターン
  2065.         if (!subject._actions.filter(action => action.item()).length) {
  2066.             subject._makesTargetLineKe = null;
  2067.             return;
  2068.         }
  2069.         const targets = subject._targetsFastKe;
  2070.         if (!targets || !targets.listsForLine.length) { return; }
  2071.         // 全てのターゲットに対して処理
  2072.         targets.listsForLine.forEach((tages, i) => {
  2073.             tages.forEach(targetId => {
  2074.                 if (!targetId) { return; }
  2075.                 // 全体ワードの作成
  2076.                 if (targetId.isAllWord) {
  2077.                     makeAllWord(subject, i);
  2078.                 // ワイヤーの形成
  2079.                 } else {
  2080.                     const target = idToBattler(targetId);
  2081.                     createWire(subject, target, i);
  2082.                 }
  2083.             })
  2084.         });
  2085.         // 作成開始フラグをオフ
  2086.         subject._makesTargetLineKe = null;
  2087.         // ターゲットラインのリチルド
  2088.         rechildTargetLine();
  2089.     };


  2090.     //- 全体ワードの作成
  2091.     function makeAllWord(subject, i) {
  2092.         subjectSprite = searchSpriteBattler(subject);
  2093.         const allCfg = keke_allWordCfg;
  2094.         //if (!subjectSprite) { return }
  2095.         // 全体ワードの形成
  2096.         const allSprite = createAllWord(subjectSprite, subject, i);
  2097.         // ワードの描画
  2098.         const cfg = {};
  2099.         cfg.word = allCfg["ワード"];
  2100.         cfg.fontFace = allCfg["フォント"];
  2101.         cfg.fontSize = allCfg["文字サイズ"] || keke_actFontSize;
  2102.         cfg.fontSizeRate = getFontSizeRate(cfg.fontFace);
  2103.         cfg.fontColor = allCfg["文字色"] || keke_lineColorList[subject.index() % 8] || "rgba(255, 255, 255)";
  2104.         cfg.outW = allCfg["縁取り幅"] || keke_actOutW;
  2105.         const frame = drawWard(allSprite, subject, cfg);
  2106.         // ライン始点の取得
  2107.         const point = getLineStart(subject, subjectSprite, i, frame);
  2108.         // 位置をセット
  2109.         allSprite.x = point.x + (allCfg["ずらしX"] || 0);
  2110.         allSprite.y = point.y + (allCfg["ずらしY"] || 0);
  2111.     };


  2112.     //- 全体ワードの形成
  2113.     function createAllWord(subjectSprite, subject, i) {
  2114.         const allCfg = keke_allWordCfg;
  2115.         // サイズを取得
  2116.         const outW = allCfg["縁取り幅"] || keke_actOutW;
  2117.         const width = keke_actW + outW;
  2118.         const height = keke_actFontSize + outW;
  2119.         // スプライト & ビットマップ形成
  2120.         const bitmap = new Bitmap(width, height);
  2121.         const sprite = new SpriteKePrds(bitmap);
  2122.         // チルド
  2123.         const layerId = keke_actLayer == "ウインドウより上" ? "D" : "B";
  2124.         childLayer(sprite, layerId);
  2125.         // 原点
  2126.         sprite.anchor.x = 0.5;
  2127.         sprite.anchor.y = 0.5;
  2128.         // 変数セット
  2129.         if (!subjectSprite._targetLinesKe) { subjectSprite._targetLinesKe = { list:[] }; }
  2130.         subjectSprite._targetLinesKe.list.push(sprite);
  2131.         // スプライトにサイズを保存
  2132.         sprite._widthKe = width;
  2133.         sprite._heightKe = height;
  2134.         // 表示方向を保存
  2135.         const pos = subject._enemyId ? keke_actPosEnemy : keke_actPosActor;
  2136.         sprite._direKe = pos["表示方向"];
  2137.         // 全体ワードフラグをセット
  2138.         sprite._isAllWordKe = true;
  2139.         return sprite;
  2140.     };


  2141.     //- ワードの描画
  2142.     function drawWard(sprite, subject, cfg) {
  2143.         const fontSize = cfg.fontSize;
  2144.         const word = cfg.word;
  2145.         const outW = cfg.outW;
  2146.         // フォント設定
  2147.         const bitmap = sprite.bitmap;
  2148.         bitmap.fontFace = cfg.fontFace || $gameSystem.mainFontFace();;
  2149.         bitmap.fontSize = fontSize;
  2150.         bitmap.textColor = cfg.fontColor;
  2151.         bitmap.outlineWidth = cfg.outW;
  2152.         // サイズを取得
  2153.         const width = strWidth(word, fontSize, cfg.fontSizeRate);
  2154.         const height = fontSize + outW;
  2155.         // 描画
  2156.         bitmap.drawText(word, 0, 0, bitmap.width, height, "center");
  2157.         // フレームを保存
  2158.         const frame = { x:0, y:0, width:width, height:height, outW:outW }
  2159.         return frame;
  2160.     };


  2161.     //- ワイヤーの形成
  2162.     function createWire(subject, target, i) {
  2163.         // バトラースプライト取得
  2164.         const subjectSprite = searchSpriteBattler(subject);
  2165.         if (!subjectSprite) { return; }
  2166.         const targetSprite = searchSpriteBattler(target);
  2167.         if (!isFrontViewActor(target) && !targetSprite ) { return; }
  2168.         // ライン始点の取得
  2169.         const subjectPoint = getLineStart(subject, subjectSprite, i);
  2170.         // ワイヤー始点Yの補正
  2171.         subjectPoint.y += keke_lineW / 2 + keke_lineOutW;
  2172.         // ライン終点の取得
  2173.         const targetPoint = getLineEnd(target, targetSprite);
  2174.         // 受容ラインの選択
  2175.         const receptIndex = saveReceptLine(target, subject);
  2176.         // ワイヤーの描画
  2177.         const wireBitmap = new Bitmap(Graphics.width, Graphics.height);
  2178.         const wireSprite = new SpriteKePrds(wireBitmap);
  2179.         drawWire(subject, target, wireBitmap, subjectPoint.x, subjectPoint.y, targetPoint.x, targetPoint.y, receptIndex);
  2180.         wireSprite._isWireKe = true;
  2181.         // 矢印の描画
  2182.         const arrowBitmap = new Bitmap(Graphics.width, Graphics.height);
  2183.         const arrowSprite = new SpriteKePrds(arrowBitmap);
  2184.         drawWire(subject, target, arrowBitmap, subjectPoint.x, subjectPoint.y, targetPoint.x, targetPoint.y, receptIndex, true);
  2185.         arrowSprite._isArrowKe = true;
  2186.         // スプライト内にターゲットIDを保存
  2187.         wireSprite._targetIdKe = battlerToId(target);
  2188.         arrowSprite._targetIdKe = wireSprite._targetIdKe;
  2189.         // チルド
  2190.         const layerId = keke_actLayer == "ウインドウより上" ? "C" : "A";
  2191.         childLayer(wireSprite, layerId);
  2192.         childLayer(arrowSprite, layerId);
  2193.         // 変数セット
  2194.         if (!subjectSprite._targetLinesKe) { subjectSprite._targetLinesKe = { list:[] }; }
  2195.         subjectSprite._targetLinesKe.list.push(wireSprite);
  2196.         subjectSprite._targetLinesKe.list.push(arrowSprite);
  2197.         // ワイヤーの長さを保存
  2198.         const length = pointDistance(subjectPoint.x, subjectPoint.y, targetPoint.x, targetPoint.y);
  2199.         const preLength = subjectSprite._targetLinesKe.length || 0;
  2200.         subjectSprite._targetLinesKe.length = Math.max(length, preLength);
  2201.     };


  2202.     //- フロントビューアクターか
  2203.     function isFrontViewActor(battler) {
  2204.         return !$gameSystem.isSideView() && battler._actorId;
  2205.     };


  2206.     //- ライン始点の取得
  2207.     function getLineStart(battler, battlerSprite, i, allData) {
  2208.         // 行動ビューからのポイント取得
  2209.         const point = getPointFromActView(battler, battlerSprite, i, allData);
  2210.         if (point) { return point; }
  2211.         // 取得できなければバトグラから始点を取得
  2212.         const asi = getFullAnimeStatusAsi(battler);
  2213.         const faceSprite = asi ? asi.faceBaseSprite : null;
  2214.         const startCfg = keke_lineStart;
  2215.         const dire = startCfg["始点-方向"];
  2216.         const offsetX = startCfg["始点-ずらしX"] || 0;
  2217.         const offsetY = startCfg["始点-ずらしY"] || 0;
  2218.         // ラインポイントの取得
  2219.         return getLinePoint(battler, battlerSprite, asi, faceSprite, dire, offsetX, offsetY);
  2220.     };


  2221.     //- 行動ビューからのポイント取得
  2222.     function getPointFromActView(battler, battlerSprite, i, allData) {
  2223.         // 行動ビュースプライトを取得
  2224.         const actWindow = battlerSprite._actWindowKe;
  2225.         if (!actWindow) { return; }
  2226.         // 行動ビューのフレームを取得
  2227.         const actFrames = battlerSprite._actFramesKe;
  2228.         if (!actFrames || !actFrames.length) { return; }
  2229.         const frame = getLineFrame(actFrames, i);
  2230.         if (!frame) { return; }
  2231.         // 始点の設定を取得
  2232.         const startCfg = keke_lineStart;
  2233.         const dire = startCfg["始点-方向"];
  2234.         const offsetX = startCfg["始点-ずらしX"] || 0;
  2235.         const offsetY = startCfg["始点-ずらしY"] || 0;
  2236.         // ポイント位置を取得
  2237.         const point = {};
  2238.         const padding = actWindow._padding;
  2239.         point.x = actWindow.x + padding + offsetX;
  2240.         point.y = actWindow.y + padding + offsetY + frame.y + frame.height / 2;
  2241.         const actOutW = keke_actOutW;
  2242.         // 全体ワードの方向補正
  2243.         if (allData) {
  2244.             const outWs = actOutW + allData.outW;
  2245.             point.x += dire == "左" ? -frame.iconW - allData.width / 2 - outWs : frame.width + allData.width / 2 + outWs;
  2246.             // 画面外に出さない-全体ワード
  2247.             noOutScreenAllWord(point, frame.width, allData.width, frame.iconW);
  2248.         // 始点ポイントの方向補正
  2249.         } else {
  2250.             const startSize = keke_lineStartSize + actOutW;
  2251.             point.x += dire == "左" ? -frame.iconW - startSize : dire == "右" ? frame.width + startSize : frame.width / 2;
  2252.             point.y += dire == "上" ? -frame.height / 2 - startSize : dire == "下" ? frame.height / 2 + startSize : 0;
  2253.         }
  2254.         return point;
  2255.     };


  2256.     //- 画面外に出さない全体ワード
  2257.     function noOutScreenAllWord(point, frameW, allW, iconW) {
  2258.         // 非表示範囲を取得
  2259.         noShowScope = keke_actNoShowScope || {};
  2260.         // 左右の端の位置を取得
  2261.         const leftEdge = point.x - allW / 2;
  2262.         const rightEdge = point.x + allW / 2;
  2263.         // 左右の超過分を取得
  2264.         const leftOver = leftEdge - (noShowScope["左"] || 0);
  2265.         const rightOver = rightEdge - (Graphics.width - (noShowScope["右"] || 0));
  2266.         // 超過分だけ位置をずらす
  2267.         if (leftOver < 0) {
  2268.             sprite.x -= leftOver;
  2269.         } else if (rightOver > 0) {
  2270.             sprite.x -= rightOver;
  2271.         }
  2272.         // 左に超過したら右に移動
  2273.         /*if (leftOver < 0) {
  2274.             point.x += frameW + allW + iconW / 2;
  2275.         }
  2276.         // 右に超過したら右に移動
  2277.         if (rightOver > 0) {
  2278.             point.x -= frameW + allW + iconW / 2;
  2279.         }*/
  2280.     };


  2281.     //- ライン終点の取得
  2282.     function getLineEnd(battler, battlerSprite) {
  2283.         const asi = getFullAnimeStatusAsi(battler);
  2284.         const faceSprite = asi ? asi.faceBaseSprite : null;
  2285.         const endCfg = keke_lineEnd;
  2286.         const word = battler._actorId ? "(味方)" : "(敵)";
  2287.         const dire = endCfg["終点-方向" + word];
  2288.         const offsetX = endCfg["終点-ずらしX" + word] || 0;
  2289.         const offsetY = endCfg["終点-ずらしY" + word] || 0;
  2290.         // ラインポイントの取得
  2291.         return getLinePoint(battler, battlerSprite, asi, faceSprite, dire, offsetX, offsetY);
  2292.     };


  2293.     //- ラインポイントの取得
  2294.     function getLinePoint(battler, battlerSprite, asi, faceSprite, dire, offsetX, offsetY) {
  2295.         const point = {}
  2296.         let frame = null;
  2297.         let x = 0;
  2298.         let y = 0;
  2299.         let inX = 0;
  2300.         let inY = 0;
  2301.         // 顔アイコンの位置情報
  2302.         if (faceSprite) {
  2303.             frame = asi.faceFrame;
  2304.             x = asi.faceHomeX;
  2305.             y = asi.faceHomeY;
  2306.         // バトグラの位置情報
  2307.         } else {
  2308.             // フロントビュー時のアクターはステータス位置を取得
  2309.             if (isFrontViewActor(battler)) {
  2310.                 const statusWindow = SceneManager._scene._statusWindow;
  2311.                 const i = $gameParty.allMembers().indexOf(battler);
  2312.                 frame = copyHash(statusWindow.faceRect(i));
  2313.                 frame.height = 0;
  2314.                 x = statusWindow.x + frame.x + frame.width / 2;
  2315.                 y = statusWindow.y + frame.y;
  2316.             // その他はバトグラ位置
  2317.             } else {
  2318.                 frame = copyHash(battlerSprite._frame);
  2319.                 frame.width *= battlerSprite.scale.x;
  2320.                 frame.height *= battlerSprite.scale.y;
  2321.                 x = battlerSprite.x;
  2322.                 y = battlerSprite.y - frame.height / 4;
  2323.                 // 原点による補正
  2324.                 inX += (0.5 - battlerSprite.anchor.x) * frame.width;
  2325.                 inY += (0.5 - battlerSprite.anchor.y) * frame.height;
  2326.             }
  2327.         }
  2328.         // ポイントの位置
  2329.         inX += dire == "左" ? -frame.width / 2 : dire == "右" ? frame.width / 2 : 0;
  2330.         inY += dire == "上" ? -frame.height / 2 : dire == "下" ? frame.height / 2 : 0;
  2331.         // 座標
  2332.         point.x = x + inX + offsetX;
  2333.         point.y = y + inY + offsetY;
  2334.         // 画面外に出さない-ポイント
  2335.         noOutScreenPoint(point);
  2336.         return point;
  2337.     };


  2338.     //- 画面外に出さない-ポイント
  2339.     function noOutScreenPoint(point) {
  2340.         // 非表示範囲を取得
  2341.         noShowScope = keke_actNoShowScope || {};
  2342.         // 上下左右の限界位置を取得
  2343.         const leftMax = noShowScope["左"] || 0;
  2344.         const rightMax = Graphics.width - (noShowScope["右"] || 0);
  2345.         const upMax = noShowScope["上"] || 0;
  2346.         const downMax = Graphics.height - (noShowScope["下"] || 0);
  2347.         // 限界位置を超えた分だけずらす
  2348.         if (point.x < leftMax) { point.x += leftMax - point.x; } else
  2349.         if (point.x > rightMax) { point.x += rightMax - point.x; }
  2350.         if (point.y < upMax) { point.y += upMax - point.y; } else
  2351.         if (point.y > downMax) { point.y += downMax - point.y; }
  2352.     };


  2353.     //- ポイント間の距離
  2354.     function pointDistance(ax, ay, bx, by) {
  2355.         return Math.sqrt(Math.pow(ax - bx, 2) + Math.pow(ay - by, 2));
  2356.     };
  2357.    

  2358.     //- ワイヤーの描画
  2359.     function drawWire(subject, target, bitmap, ax, ay, bx, by, receptIndex, isArrow) {
  2360.         const context = bitmap.context;
  2361.         // 矢印の方向を取得
  2362.         let dire = keke_lineDire;
  2363.         // 敵キャラ同志をつなぐ場合は反転
  2364.         if (target._enemyId) {
  2365.             dire = dire == "左" ? "右" : dire == "右" ? "左" : dire == "上" ? "下" : "上";
  2366.         }
  2367.         const lineW = keke_lineW;
  2368.         const ow = keke_lineOutW;
  2369.         // ラインが複数ある時のずらしを取得
  2370.         const pileOffset = keke_linePileOffset;
  2371.         let offsetX = 0;
  2372.         let offsetY = 0;
  2373.         // 横ラインの時
  2374.         if (dire.match(/左|右/)) {
  2375.             offsetY = pileOffset * receptIndex;
  2376.         // 縦ラインの時
  2377.         } else {
  2378.             offsetX = -pileOffset * receptIndex;
  2379.         }
  2380.         // アウトラインを描画
  2381.         context.strokeStyle = "rgba(0, 0, 0)";
  2382.         context.lineWidth = ow;
  2383.         const radius = keke_lineStartSize || lineW;
  2384.         context.beginPath();
  2385.         context.arc(ax, ay, radius, 0, Math.PI * 2, false);
  2386.         context.stroke();

  2387.         context.lineWidth = lineW + ow * 2;
  2388.         if (isArrow) { strokeArrow(context, ax, ay, bx, by, dire, offsetX, offsetY, lineW, ow, true); } else
  2389.         { strokeWire(context, ax, ay, bx, by, dire, offsetX, offsetY, lineW, ow, true); }
  2390.         // 本線を描画
  2391.         context.strokeStyle = keke_lineColorList[subject.index() % 8] || "rgba(255, 255, 255)";
  2392.         context.fillStyle = context.strokeStyle;

  2393.         context.beginPath();
  2394.         context.arc(ax, ay, radius, 0, Math.PI * 2, false);
  2395.         context.fill();

  2396.         context.lineWidth = lineW;
  2397.         if (isArrow) { strokeArrow(context, ax, ay, bx, by, dire, offsetX, offsetY, lineW, ow); } else
  2398.         { strokeWire(context, ax, ay, bx, by, dire, offsetX, offsetY, lineW, ow); }
  2399.         // 終了
  2400.         context.restore();
  2401.         bitmap._baseTexture.update();
  2402.     };


  2403.     //- ワイヤーの線描画
  2404.     function strokeWire(context, ax, ay, bx, by, dire, offsetX, offsetY, lineW, ow, isOutLine) {
  2405.         const arrowW = keke_lineArrowSize + ow;
  2406.         const minLength = keke_lineMinLength;
  2407.         const xLength = Math.abs(bx - ax);
  2408.         const yLength = Math.abs(by - ay);
  2409.         const w = dire.match(/左|右/i) ? bx - ax : by - ay;
  2410.         context.beginPath();
  2411.         // 上
  2412.         if (dire == "上") {
  2413.             by += arrowW;
  2414.             bx += offsetX;
  2415.             if (ax == bx) { ax -= keke_linePileOffset; }
  2416.             const middleY= by > ay || yLength < minLength ? by + minLength : ay + w * 0.5;
  2417.             context.moveTo(ax, ay);
  2418.             context.lineTo(bx, middleY);
  2419.         // 下
  2420.         } else if (dire == "下") {
  2421.             by += -arrowW;
  2422.             bx += offsetX;
  2423.             if (ax == bx) { ax -= keke_linePileOffset; }
  2424.             const middleY= by < ay || yLength < minLength ? by - minLength : ay + w * 0.5;
  2425.             context.moveTo(ax, ay);
  2426.             context.lineTo(bx, middleY);
  2427.         // 左
  2428.         } else if (dire == "左") {
  2429.             bx += arrowW;
  2430.             by += offsetY;
  2431.             if (ay == by) { ay += keke_linePileOffset; }
  2432.             const middleX= bx > ax || xLength < minLength ? bx + minLength : ax + w * 0.5;
  2433.             context.moveTo(ax, ay);
  2434.             context.lineTo(middleX, by);

  2435.         // 右
  2436.         } else if (dire == "右") {
  2437.             bx += -arrowW;
  2438.             by += offsetY;
  2439.             if (ay == by) { ay += keke_linePileOffset; }
  2440.             const middleX= bx < ax || xLength < minLength ? bx - minLength : ax + w * 0.5;
  2441.             context.moveTo(ax, ay);
  2442.             context.lineTo(middleX, by);
  2443.         }
  2444.         context.lineTo(bx, by);
  2445.         context.stroke();
  2446.     };


  2447.     //- 矢印の線描画
  2448.     function strokeArrow(context, ax, ay, bx, by, dire, offsetX, offsetY, lineW, ow, isOutLine) {
  2449.         const arrowW = keke_lineArrowSize;
  2450.         const middleW = Math.max((arrowW * 2 - lineW - ow * 2) / 2, 1);
  2451.         const sharp = arrowW / 20;
  2452.         context.beginPath();
  2453.         // 上
  2454.         if (dire == "上") {
  2455.             bx += offsetX;
  2456.             if (ax == bx) { ax -= keke_linePileOffset; }
  2457.             context.beginPath();
  2458.             context.moveTo(bx, by);
  2459.             context.lineTo(bx - arrowW, by + arrowW);
  2460.             context.lineTo(bx, by);
  2461.             context.lineTo(bx + arrowW, by + arrowW);
  2462.             if (isOutLine) {
  2463.                 context.lineTo(bx + arrowW - middleW, by + arrowW - sharp);
  2464.                 context.moveTo(bx - arrowW + middleW, by + arrowW - sharp);
  2465.             }
  2466.             context.lineTo(bx - arrowW, by + arrowW);
  2467.         // 下
  2468.         } else if (dire == "下") {
  2469.             bx += offsetX;
  2470.             if (ax == bx) { ax -= keke_linePileOffset; }
  2471.             context.beginPath();
  2472.             context.moveTo(bx, by);
  2473.             context.lineTo(bx - arrowW, by - arrowW);
  2474.             context.lineTo(bx, by);
  2475.             context.lineTo(bx + arrowW, by - arrowW);
  2476.             if (isOutLine) {
  2477.                 context.lineTo(bx + arrowW - middleW, by - arrowW + sharp);
  2478.                 context.moveTo(bx - arrowW + middleW, by - arrowW + sharp);
  2479.             }
  2480.             context.lineTo(bx - arrowW, by - arrowW);
  2481.         // 左
  2482.         } else if (dire == "左") {
  2483.             by += offsetY;
  2484.             if (ay == by) { ay += keke_linePileOffset; }
  2485.             context.beginPath();
  2486.             context.moveTo(bx, by);
  2487.             context.lineTo(bx + arrowW, by - arrowW);
  2488.             context.lineTo(bx, by);
  2489.             context.lineTo(bx + arrowW, by + arrowW);
  2490.             if (isOutLine) {
  2491.                 context.lineTo(bx + arrowW - sharp, by + arrowW - middleW);
  2492.                 context.moveTo(bx + arrowW - sharp, by - arrowW + middleW);
  2493.             }
  2494.             context.lineTo(bx + arrowW, by - arrowW);
  2495.         // 右
  2496.         } else if (dire == "右") {
  2497.             by += offsetY;
  2498.             if (ay == by) { ay += keke_linePileOffset; }
  2499.             context.beginPath();
  2500.             context.moveTo(bx, by);
  2501.             context.lineTo(bx - arrowW, by - arrowW);
  2502.             context.lineTo(bx, by);
  2503.             context.lineTo(bx - arrowW, by + arrowW);
  2504.             if (isOutLine) {
  2505.                 context.lineTo(bx - arrowW + sharp, by + arrowW - middleW);
  2506.                 context.moveTo(bx - arrowW + sharp, by - arrowW + middleW);
  2507.             }
  2508.             context.lineTo(bx - arrowW, by - arrowW)
  2509.         }
  2510.         context.lineTo(bx, by);
  2511.         context.stroke();
  2512.         context.fill();
  2513.     };


  2514.     //- ターゲットラインの消去
  2515.     function delTargetLine(subject) {
  2516.         // ターゲットライン作成フラグを消去
  2517.         subject._makesTargetLineKe = null;
  2518.         if (!subject) { return; }
  2519.         // ラインを取得
  2520.         const sprite = searchSpriteBattler(subject);
  2521.         if (!sprite) { return; }
  2522.         const lines = sprite._targetLinesKe;
  2523.         if (!lines || !lines.list.length) { return; }
  2524.         // 全てのラインに対して処理
  2525.         lines.list.forEach(sprite => {
  2526.             // スプライト破棄
  2527.             sprite.parent.removeChild(sprite);
  2528.             sprite.destroy();
  2529.             // 受容ラインの消去
  2530.             delReceptLine(idToBattler(sprite._targetIdKe), subject)
  2531.         });
  2532.         sprite._targetLinesKe = null;
  2533.     };


  2534.     //- 受容ラインの選択
  2535.     function saveReceptLine(target, subject) {
  2536.         if (!target._receptLinesKe) { target._receptLinesKe = []; }
  2537.         const recepts = target._receptLinesKe;
  2538.         let receptIndex = 0;
  2539.         // 攻撃者ID
  2540.         const subjectId = battlerToId(subject);
  2541.         // 空きがあったらそこを選択
  2542.         let saved = false;
  2543.         recepts.forEach((slot, i) => {
  2544.             if (!slot && !saved) {
  2545.                 recepts[i] = subjectId;
  2546.                 receptIndex = i;
  2547.                 saved = true;
  2548.             }
  2549.         });
  2550.         // 空きがなかったら末尾を選択
  2551.         if (!saved) {
  2552.             recepts.push(subjectId);
  2553.             receptIndex = recepts.length - 1;
  2554.         }
  2555.         return receptIndex;
  2556.     };


  2557.     //- 受容ラインの消去
  2558.     function delReceptLine(target, subject) {
  2559.         if (!target || !target._receptLinesKe) { return; }
  2560.         const recepts = target._receptLinesKe;
  2561.         // 行動者のスロットがあったら消去
  2562.         recepts.forEach((slot, i) => {
  2563.             if (idToBattler(slot) == subject) {
  2564.                 recepts[i] = null;
  2565.             }
  2566.         });
  2567.     };


  2568.     //- 受容ラインの初期化
  2569.     function initReceptLine() {
  2570.         $gameParty.allMembers().forEach(target => {
  2571.             target._receptLinesKe = null;
  2572.         });
  2573.     };


  2574.     //- ターゲットラインのリチルド
  2575.     function rechildTargetLine() {
  2576.         const layerId = keke_actLayer == "ウインドウより上" ? "C" : "A";
  2577.         // ラインを全て取得
  2578.         const allLines = [];
  2579.         $gameTroop.aliveMembers().forEach(enemy => {
  2580.             const sprite = searchSpriteBattler(enemy);
  2581.             if (!sprite) { return false; }
  2582.             const lines = sprite._targetLinesKe;
  2583.             if (!lines || !lines.list.length) { return false; }
  2584.             allLines.push(lines);
  2585.         });
  2586.         if (!allLines.length) { return; }
  2587.         // ラインを長さが長い順にソート
  2588.         allLines.sort((a, b) => b.length - a.length);
  2589.         // ワイヤーを再チルド
  2590.         allLines.forEach(lines => {
  2591.             lines.list.forEach(sprite => {
  2592.                 // ワイヤーでなければ除外
  2593.                 if (!sprite._isWireKe) { return; }
  2594.                 childLayer(sprite, layerId);
  2595.             });
  2596.         });
  2597.         // 矢印を再チルド
  2598.         allLines.forEach(lines => {
  2599.             lines.list.forEach(sprite => {
  2600.                 // 矢印でなければ除外
  2601.                 if (!sprite._isArrowKe) { return; }
  2602.                 childLayer(sprite, layerId);
  2603.             });
  2604.         });
  2605.     };


  2606.     //- ターゲットラインの可視更新
  2607.     function updateTargetLineVisible(subject, subjectSprite) {
  2608.         if (!subjectSprite._targetLinesKe || !subjectSprite._targetLinesKe.list.length) { return; }
  2609.         let valid = true;
  2610.         while (true) {
  2611.             if (BattleManager._phase == "battleEnd") { valid = false;  break; }
  2612.             if (isActing(subject) || subject.isRestricted()) { valid = false;  break; }
  2613.             if (keke_lineOnlyInput && !BattleManager.isInputting()) { valid = false;  break; }
  2614.             if (!isTargetLineShow(subject) || !isValidPrediction(subject)) { valid = false;  break; }
  2615.             break;
  2616.         }
  2617.         subjectSprite._targetLinesKe.list.forEach(line => {
  2618.             line.visible = valid;
  2619.         })
  2620.     };



  2621.     //==================================================
  2622.     //--  ターゲットライン-アニメ
  2623.     //==================================================

  2624.     //- ターゲットライン周期の更新
  2625.     function updateTargetLineCycle() {
  2626.         const gt = $gameTemp;
  2627.         if (gt._tlFlickerDurationKe == null) { gt._tlFlickerDurationKe = 45; }
  2628.         gt._tlFlickerDurationKe--;
  2629.         if (gt._tlFlickerDurationKe <= 0) {
  2630.             gt._tlFlickerDurationKe = 45;
  2631.         }
  2632.     };


  2633.     //- ターゲットライン明滅の更新
  2634.     function updataTargetLineFlicker(subject, sprite) {
  2635.         const lines = sprite._targetLinesKe;
  2636.         if (!lines || !lines.list.length) { return; }
  2637.         // 全てのラインに対して処理
  2638.         lines.list.forEach(sprite => {
  2639.             // 明滅の更新
  2640.             updataFlicker(sprite);
  2641.         });
  2642.     };


  2643.     //- 明滅の更新
  2644.     function updataFlicker(sprite) {
  2645.         // 明滅の開始
  2646.         startFlicker(sprite);
  2647.         // 明滅の処理
  2648.         processFlicker(sprite);
  2649.     };


  2650.     //- 明滅の開始
  2651.     function startFlicker(sprite) {
  2652.         if (sprite._flickerKe) { return; }
  2653.         const d = {};
  2654.         d.start = 64;
  2655.         d.target = 255;
  2656.         d.timeMax = 45;
  2657.         d.easing = "eo";
  2658.         d.duration = $gameTemp._tlFlickerDurationKe || d.timeMax;
  2659.         d.current = d.start;
  2660.         sprite._flickerKe = d;
  2661.     };


  2662.     //- 明滅の処理
  2663.     function processFlicker(sprite) {
  2664.         if (!sprite._flickerKe) { return; }
  2665.         const d = sprite._flickerKe;
  2666.         // カウントを減らす
  2667.         d.duration--;
  2668.         // ターンの処理
  2669.         //d.current = processTurn(d.current, d.start, d.target, d.duration + 1, d.timeMax);
  2670.         d.current = processEasing(d.current, d.target, d.duration + 1, d.timeMax, d.easing);
  2671.         sprite.opacity = d.current;
  2672.         // ループ
  2673.         if (d.duration <= 0) {
  2674.             d.duration = d.timeMax;
  2675.             d.current = d.start;
  2676.         }
  2677.     };
  2678.    


  2679.     //==================================================
  2680.     //--  フォント基本 /ベーシック
  2681.     //==================================================

  2682.     //- 文字列幅
  2683.     function strWidth(str, fontSize, sizeRate  = {}) {
  2684.         return strBytes(str, 0.5, sizeRate.half || 1) * fontSize * (sizeRate.width || 1);
  2685.     };


  2686.     //- 文字列バイト数
  2687.     function strBytes(str, rate = 1, halfSize = 1) {
  2688.         let byte = 0;
  2689.         for (let i = 0; i < str.length; i++) {
  2690.             var c = str.charCodeAt(i);
  2691.             if ((c >= 0x0 && c < 0x81) || (c === 0xf8f0) || (c >= 0xff61 && c < 0xffa0) || (c >= 0xf8f1 && c < 0xf8f4)) {
  2692.                 byte += 1 * (rate * halfSize);
  2693.             } else {
  2694.                 byte += 2 * rate;
  2695.             }
  2696.         }
  2697.         return byte;
  2698.     };



  2699.     //==================================================
  2700.     //--  配列基本 /ベーシック
  2701.     //==================================================
  2702.    
  2703.     //- ハッシュのディープコピー
  2704.     function copyHash(hash) {
  2705.         const copy = {};
  2706.         Object.keys(hash).forEach(k => {
  2707.             if (!hash[k]) { copy[k] = hash[k];  return; }
  2708.             if (hash[k].constructor.name == "Object") {
  2709.                 copy[k] = copyHash(hash[k]);
  2710.             } else if (hash[k].constructor.name == "Array") {
  2711.                 copy[k] = copyArray(hash[k]);
  2712.             } else {
  2713.                 copy[k] = hash[k];
  2714.             }
  2715.         });
  2716.         return copy;
  2717.     };
  2718.    
  2719.    
  2720.     //- 配列のディープコピー
  2721.     function copyArray(array) {
  2722.         const copy = [];
  2723.         array.forEach((v, i) => {
  2724.             if (v.constructor.name == "Object") {
  2725.                 copy[i] = copyHash(v);
  2726.             } else if (v.constructor.name == "Array") {
  2727.                 copy[i] = copyArray(v);
  2728.             } else {
  2729.                 copy[i] = v;
  2730.             }
  2731.         });
  2732.         return copy;
  2733.     };



  2734.     //==================================================
  2735.     //--  バトラー基本 /ベーシック
  2736.     //==================================================

  2737.     //- バトラーをIDに
  2738.     function battlerToId(battler) {
  2739.         if (battler._actorId) {
  2740.             return { type:"actor", id:battler._actorId};
  2741.         } else {
  2742.             return { type:"enemy", id:battler.index()};
  2743.         }
  2744.     };


  2745.     //- IDをバトラーに
  2746.     function idToBattler(id) {
  2747.         if (!id) { return; }
  2748.         if (id.type == "actor") {
  2749.             return $gameParty.members().find(actor => actor._actorId == id.id);
  2750.         } else {
  2751.             return $gameTroop.members()[id.id];
  2752.         }
  2753.     };



  2754.     //==================================================
  2755.     //--  メタ取得 /ベーシック
  2756.     //==================================================
  2757.    
  2758.     //- 全てのメタ配列を合算
  2759.     function totalAllMetaArray(battler, words, action, noDelSpace, ratioIndex) {
  2760.         let data = null
  2761.         let array = [];
  2762.         // バトラー値
  2763.         if (battler) {
  2764.             data = battler._actorId ? battler.actor() : battler.enemy();
  2765.             if (data) { metaAll(data.note, words, ratioIndex).forEach(e => array.push(e)); }
  2766.             if (battler._actorId) {
  2767.                 // 職業値
  2768.                 data = battler.currentClass();
  2769.                 if (data) { metaAll(data.note, words, ratioIndex).forEach(e => array.push(e)); }
  2770.                 // 装備値
  2771.                 battler._equips.forEach(equip => {
  2772.                     data = equip.object();
  2773.                     if (data) { metaAll(data.note, words, ratioIndex).forEach(e => array.push(e)); }
  2774.                 });
  2775.             }
  2776.             // ステート値
  2777.             battler._states.forEach(stateId => {
  2778.                 data = $dataStates[stateId];
  2779.                 if (data) { metaAll(data.note, words, ratioIndex).forEach(e => array.push(e)); }
  2780.             });
  2781.         }
  2782.         // アクション値
  2783.         if (action) {
  2784.             data = action.item();
  2785.             if (data) { metaAll(data.note, words, ratioIndex).forEach(e => array.push(e)); }
  2786.         }
  2787.         // スペース削除
  2788.         if (!noDelSpace) { array = array.map(e => e.replace(/\s/g, "")); }
  2789.         // 空の要素は削除
  2790.         array = array.filter(e => e);
  2791.         return array;
  2792.     };
  2793.    
  2794.    
  2795.     //- 全取得メタ
  2796.     function metaAll(note, words, ratioIndex) {
  2797.         var result = [];
  2798.         words.forEach(word => {
  2799.             var regText = '\<' + word + ':([^\>]*)\>';
  2800.             var regExp_g = new RegExp(regText, 'g');
  2801.             var regExp = new RegExp(regText);
  2802.             var matches = note.match(regExp_g);
  2803.             if (matches) {
  2804.                 matches.forEach(function(line) {
  2805.                     const match = line.match(regExp);
  2806.                     const vals = match[1].replace(/\s/g, "").split(",");
  2807.                     ratioIndexEx = ratioIndex - 1;
  2808.                     if (ratioIndex && vals[ratioIndexEx] && Math.randomInt(100) >= Number(vals[ratioIndexEx])) {
  2809.                         return;
  2810.                     }
  2811.                     result.push(match[1]);
  2812.                 });
  2813.             }
  2814.         });
  2815.         return result;
  2816.     };



  2817.     //==================================================
  2818.     //--  スプライト基本 /ベーシック
  2819.     //==================================================
  2820.    
  2821.     //- スプライトの検索-バトラー
  2822.     function searchSpriteBattler(battler) {
  2823.         const spriteset = SceneManager._scene._spriteset;
  2824.         let result = null;
  2825.         const sprites = battler._enemyId ? spriteset._enemySprites : spriteset._actorSprites;
  2826.         for (const sprite of sprites) {
  2827.             if(!sprite._battler) { continue; }
  2828.             if ((battler._actorId && sprite._battler._actorId == battler._actorId) || (battler._enemyId && sprite._battler.index() == battler.index())) {
  2829.                 result = sprite;
  2830.                 break;
  2831.             }
  2832.         }
  2833.         return result;
  2834.     };


  2835.     //==================================================
  2836.     //--  イージング /ベーシック
  2837.     //==================================================

  2838.     //- ターンの処理
  2839.     function processTurn(current, start, target, duration, timeMax, easingRate = 1) {
  2840.         let result = 0;
  2841.         const d1 = Math.round(timeMax / 2);
  2842.         const d2 = timeMax - d1;
  2843.         if (duration > d2) {
  2844.             result = processEasing(current, target, duration - d2, d1, "e", easingRate);
  2845.         } else {
  2846.             result = processEasing(current, start, duration, d2, "e", easingRate);
  2847.         }
  2848.         return result;
  2849.     };


  2850.     //- イージングの処理
  2851.     function processEasing(current, target, duration, timeMax, easing, easingRate = 1) {
  2852.         const lt = calcEasing((timeMax - duration) / timeMax, easing, easingRate);
  2853.         const t = calcEasing((timeMax - duration + 1) / timeMax, easing, easingRate);
  2854.         const start = (current - target * lt) / (1 - lt);
  2855.         return start + (target - start) * t;
  2856.     };
  2857.    

  2858.     //- イージングの計算
  2859.     function calcEasing(t, easing, easingRate = 1) {
  2860.         const exponent = 2 * easingRate;
  2861.         switch (easing.toUpperCase()) {
  2862.             case "EI":
  2863.                 return easeIn(t, exponent);
  2864.             case "EO":
  2865.                 return easeOut(t, exponent);
  2866.             case "E":
  2867.                 return easeInOut(t, exponent);
  2868.             default:
  2869.                 return t;
  2870.         }
  2871.     };
  2872.    

  2873.     //- 各イージング処理
  2874.     function easeIn(t, exponent) {
  2875.         return Math.pow(t, exponent) || 0.001;
  2876.     };
  2877.    
  2878.     function easeOut(t, exponent) {;
  2879.         return 1 - (Math.pow(1 - t, exponent) || 0.001);
  2880.     };
  2881.    
  2882.     function easeInOut(t, exponent) {
  2883.         if (t < 0.5) {
  2884.             return easeIn(t * 2, exponent) / 2;
  2885.         } else {
  2886.             return easeOut(t * 2 - 1, exponent) / 2 + 0.5;
  2887.         }
  2888.     };



  2889.     //==================================================
  2890.     //--  アイコンスプライト /ベーシック
  2891.     //==================================================
  2892.    
  2893.     //- アイコンスプライトの形成
  2894.     function createIconSprite(iconIndex, anchorX = 0.5, anchorY = 0.5) {
  2895.         const sprite = new SpriteKePrds();
  2896.         sprite.anchor.x = anchorX;
  2897.         sprite.anchor.y = anchorY;
  2898.         const bitmap = ImageManager.loadSystem("IconSet");
  2899.         sprite.bitmap = bitmap;
  2900.         const pw = ImageManager.iconWidth;
  2901.         const ph = ImageManager.iconHeight;
  2902.         const sx = (iconIndex % 16) * pw;
  2903.         const sy = Math.floor(iconIndex / 16) * ph;
  2904.         sprite.setFrame(sx, sy, pw, ph);
  2905.         return sprite;
  2906.     };



  2907.     //==================================================
  2908.     //--  エフェクト /ベーシック
  2909.     //==================================================

  2910.     //- エフェクトの実行
  2911.     function doEffect(effect, subject, target) {
  2912.         target = target || subject;
  2913.         // アニメの表示
  2914.         showAnime(subject, target, effect["アニメーション"]);
  2915.         // 効果音の再生
  2916.         playSe(effect["効果音"]);
  2917.         // 画面フラッシュの表示
  2918.         showScreenFlash(effect);
  2919.         // 画面ストップの開始
  2920.         startScreenStop(effect["ヒットストップ"]);
  2921.         // フリーアニメ・スキルの実行
  2922.         doFreeAnimeSkill(subject, target, effect["フリーアニメ"]);
  2923.     };


  2924.     //- アニメの表示
  2925.     function showAnime(subject, target, animeId) {
  2926.         if (!animeId) { return; }
  2927.         Window_BattleLog.prototype.showAnimation(subject, [target], animeId);
  2928.     };


  2929.     //- 効果音の再生
  2930.     function playSe(ses) {
  2931.         if (!ses || !ses.length) { return; }
  2932.         ses.forEach(se => {
  2933.             if (!se) { return; }
  2934.             AudioManager.playSe({ name:se["ファイル"], volume:se["音量"], pitch:se["ピッチ"], pan:se["位相"] });
  2935.         });
  2936.         
  2937.     };


  2938.     //- 画面フラッシュの表示
  2939.     function showScreenFlash(d) {
  2940.         if (!d["画面フラッシュ"] || !d["…フラッシュ色" || !d["…フラッシュ時間"]]) { return; }
  2941.         const delay = d["…フラッシュ遅延"] || 0;
  2942.         if (delay) {
  2943.             setTimeout(screenFlash, delay * 1000 / 60, d);
  2944.         } else {
  2945.             screenFlash(d);
  2946.         }
  2947.     };


  2948.     //- 画面フラッシュ
  2949.     function screenFlash(d) {
  2950.         $gameScreen.startFlash(d["…フラッシュ色"], d["…フラッシュ時間"]);
  2951.     };


  2952.     //- 画面ストップの開始
  2953.     function startScreenStop(str) {
  2954.         if (!PluginManager._scripts.some(n => n == "Keke_HitStop")) { return; }
  2955.         // 画面ストップ
  2956.         $gameTemp.screenStopKe(str);
  2957.     };


  2958.     //- フリーアニメ・スキルの実行
  2959.     function doFreeAnimeSkill(subject, target, note) {
  2960.         if (!isFreeAnime() || !note) { return; }
  2961.         // アニメファイルとコモンを取得
  2962.         const metaList = metaAll(note, ["フリーアニメ", "freeAnime"]);
  2963.         if (!metaList || !metaList.length) { return; }
  2964.         metaList.forEach(meta => {
  2965.             //-フリーアニメ・スキルの実行-個別
  2966.             BattleManager.doFreeAnimeSkillKe(meta, subject, [target]);
  2967.         });
  2968.     };


  2969.     //- フリーアニメフラグ
  2970.     function isFreeAnime() {
  2971.         return PluginManager._scripts.some(n => n == "Keke_FreeAnime");
  2972.     };
  2973.    
  2974. })();
复制代码


QQ截图20240221230827.png
此书生之言,可言而不可用也 ↑-_-||

仓管610早晚班,没多余精力做别的了 →_→
梦石
0
星屑
25555
在线时间
1137 小时
注册时间
2019-3-5
回帖
1303
发表于 2024-2-24 18:08:13 | 显示全部楼层
草。
回复

使用道具 举报

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

本版积分规则

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

在本版发帖返回顶部