| 赞 | 0 |
| VIP | |
| 好人卡 | |
| 积分 | 19 |
| 经验 | |
| 最后登录 | 2025-7-29 |
| 在线时间 | 207 小时 |
- 梦石
- 0
- 星屑
- 1903
- 在线时间
- 207 小时
- 注册时间
- 2016-7-22
- 回帖
- 118
|
楼主 |
发表于 2018-9-3 12:57:27
|
显示全部楼层
[fold=TMsrpg插件]//=============================================================================
// TMPlugin - シミュレーションRPG
// バージョン: 0.1.3a
// 最終更新日: 2017/04/07
// 配布元 : http://hikimoki.sakura.ne.jp/
//-----------------------------------------------------------------------------
// Copyright (c) 2017 tomoaky
// Released under the MIT license.
// http://opensource.org/licenses/mit-license.php
//=============================================================================
//=============================================================================
//修复/汉化:@马哥挡不住/Takakaze
//fixed/translated:@马哥挡不住/Takakaze
//版本更新时间:2018/07/26
//verision update time:2018/07/26
//更新版本号:0.1.3a.7.26.19.19.39
//UPDATE CODE:0.1.3a.7.26.19.19.39
//Released under the MIT license.
// http://opensource.org/licenses/mit-license.php
//THANKS TO THE PLUGIN MAKER @Tomoaky
//=============================================================================
//=============================================================================
//update:back attatck and counter attack updated by @Tomoaki
// fixed some bugs coursed by clashing by Tomoaki's update and my update
//更新:原作者@Tomoaki对脚本进行了更新,增加了背刺和反击等
// 解决了作者更新的部分与本人修改部分直接冲突产生的bug
//=============================================================================
//=============================================================================
//TIPS:本插件需配合SAN_TileToner和FpsSyncOption等插件使用
//本插件为开源插件,允许并欢迎修改,在使用时请注明出处(原作者及其他更新作者)
//另:修改代码并上传需遵守MIT license开源规则
//----@马哥挡不住
//=============================================================================
/*:
* @plugindesc いわゆるシミュレーションRPGぽい機能を追加します。
*
* @author tomoaky (http://hikimoki.sakura.ne.jp/)
*
* @param vnSrpgTurnCount
* @desc 現在のターン数を代入するゲーム変数番号
* 初期値: 1
* @default 1
*
* @param vnActorUnitNums
* @desc 残りアクターユニット数を代入するゲーム変数番号
* 初期値: 2
* @default 2
*
* @param vnEnemyUnitNums
* @desc 残りエネミーユニット数を代入するゲーム変数番号
* 初期値: 3
* @default 3
*
* @param srpgBasicWait
* @desc 敵ターン進行の基本ウェイト時間(フレーム)
* 初期値: 30
* @default 30
*
* @param damagePopupInterval
* @desc 連続ダメージポップアップの間隔(フレーム)
* 初期値: 30
* @default 30
*
* @param checkSkillId
* @desc 調べる/話すスキルの番号
* 初期値: 0
* @default 0
*
* @param regionEffects
* @desc リージョンごとの地形効果の設定
* 初期値: 1,11 2,12
* @default 1,11 2,12
*
* @param useRegionEffectWindow
* @desc 地形効果ウィンドウを利用するかどうか
* 初期値: 1 ( 0 = 無効 / 1 = 有効)
* @default 1
*
* @param useUnitHpGauge
* @desc ユニットHPゲージを利用するかどうか
* 初期値: 1 ( 0 = 無効 / 1 = 有効)
* @default 1
*
* @param useUnitStateIcon
* @desc ユニットステートアイコンを利用するかどうか
* 初期値: 1 ( 0 = 無効 / 1 = 有効)
* @default 1
*
* @param simpleMoveInput
* @desc 移動可能範囲が表示中ならそのまま移動できるようにする
* 初期値: 0 ( 0 = 無効 / 1 = 有効 )
* @default 0
*
* @param moveCommand
* @desc 移動コマンド名
* 初期値: 移動
* @default 移動
*
* @param moveCancelCommand
* @desc 移動キャンセルコマンド名
* 初期値: 移動取り消し
* @default 移動取り消し
*
* @param actionCommand
* @desc 行動コマンド名
* 初期値: 行動
* @default 行動
*
* @param itemCommand
* @desc アイテムコマンド名(未入力でコマンド削除)
* 初期値: アイテム
* @default アイテム
*
* @param equipCommand
* @desc 装備変更コマンド名(未入力でコマンド削除)
* 初期値: 装備変更
* @default 装備変更
*
* @param waitingCommand
* @desc 待機コマンド名(未入力でコマンド削除)
* 初期値: 待機
* @default 待機
*
* @param statusCommand
* @desc ステータスコマンド名(未入力でコマンド削除)
* 初期値: ステータス
* @default ステータス
*
* @param turnEndCommand
* @desc ターン終了コマンド名
* 初期値: ターン終了
* @default ターン終了
*
* @param unitListCommand
* @desc ユニットリストコマンド名(未入力でコマンド削除)
* 初期値: ユニットリスト
* @default ユニットリスト
*
* @param infoCommand
* @desc マップ情報コマンド名(未入力でコマンド削除)
* 初期値: マップ情報
* @default マップ情報
*
* @param optionsCommand
* @desc オプションコマンド名(未入力でコマンド削除)
* 初期値: オプション
* @default オプション
*
* @param saveCommand
* @desc セーブコマンド名(未入力でコマンド削除)
* 初期値: セーブ
* @default セーブ
*
* @param loadCommand
* @desc ロードコマンド名(未入力でコマンド削除)
* 初期値: ロード
* @default ロード
*
* @param gameEndCommand
* @desc ゲーム終了コマンド名(未入力でコマンド削除)
* 初期値: ゲーム終了
* @default ゲーム終了
*
* @param yesCommand
* @desc 肯定コマンド名
* 初期値: はい
* @default はい
*
* @param noCommand
* @desc 否定コマンド名
* 初期値: いいえ
* @default いいえ
*
* @param moveParam
* @desc 移動力パラメータの名前
* 初期値: 移動力
* @default 移動力
*
* @param moveHelp
* @desc 移動場所選択ヘルプ
* 初期値: 移動する場所を決定してください
* @default 移動する場所を決定してください
*
* @param waitingHelp
* @desc 待機方向選択ヘルプ
* 初期値: 待機中の向きを決定してください
* @default 待機中の向きを決定してください
*
* @param turnEndHelp
* @desc ターン終了確認ヘルプ
* 初期値: 味方のターンを終了してよろしいですか?
* @default 味方のターンを終了してよろしいですか?
*
* @param actionRangeHelp
* @desc 行動実行場所選択ヘルプ
* 初期値: 行動を実行する場所を決定してください
* @default 行動を実行する場所を決定してください
*
* @param actionEffectHelp
* @desc 行動最終確認ヘルプ
* 初期値: この行動でよろしいですか?
* @default この行動でよろしいですか?
*
* @param colorAreaMove
* @desc 移動可能範囲のタイルトナー設定
* 初期値: 0 64 255 128
* @default 0 64 255 128
*
* @param colorAreaWaiting
* @desc 待機範囲のタイルトナー設定
* 初期値: 255 32 255 128
* @default 255 32 255 128
*
* @param colorAreaRange
* @desc 射程範囲のタイルトナー設定
* 初期値: 255 32 32 128
* @default 255 32 32 128
*
* @param colorAreaEffect
* @desc 効果範囲のタイルトナー設定
* 初期値: 255 255 32 128
* @default 255 255 32 128
*
* @param backAttackPhysical
* @desc 物理による背後攻撃倍率
* 初期値: 1.5
* @default 1.5
*
* @param backAttackMagical
* @desc 魔法による背後攻撃倍率
* 初期値: 1.5
* @default 1.5
*
* @param reflectAnimationId
* @desc 魔法反射時に再生するアニメーションの番号
* 初期値: 0
* @default 0
* @require 1
* @type animation
*
* @param srpgCommandX
* @desc コマンドウィンドウの表示位置(X座標)
* 初期値: 0
* @default 0
*
* @param srpgCommandY
* @desc コマンドウィンドウの表示位置(Y座標)
* 初期値: 0
* @default 0
*
* @param srpgCommandLineHeight
* @desc コマンドウィンドウの1行の高さ
* 初期値: 36
* @default 36
*
* @param srpgStatusBackground
* @desc ステータスウィンドウの背景タイプ
* 初期値: 1( 0 = ウィンドウ / 1 = 暗くする / 2 = 透明)
* @default 1
*
* @param srpgStatusNameWidth
* @desc ステータスウィンドウのユニット名の幅
* 初期値: 144
* @default 144
*
* @param srpgStatusHpWidth
* @desc ステータスウィンドウのHPゲージの幅(MPでも利用)
* 初期値: 186
* @default 186
*
* @param srpgStatusFaceMirror
* @desc ステータスウィンドウの顔グラフィック左右反転設定
* 初期値: left( left = 左側を反転 / right = 右側を反転)
* @default left
*
* @param srpgUnitListWidth
* @desc ユニットリストウィンドウの幅
* 初期値: 240
* @default 240
*
* @param srpgUnitListRows
* @desc ユニットリストウィンドウの表示行数
* 初期値: 7
* @default 7
*
* @param srpgInfoSize
* @desc マップ情報ウィンドウの大きさ
* 初期値: 480*480
* @default 480*480
*
* @param srpgStatusArrowImage
* @desc ステータスウィンドウの矢印画像のファイル名
* 初期値: SrpgStatusArrow
* @default SrpgStatusArrow
* @require 1
* @dir img/system/
* @type file
*
* @param srpgCursorImage
* @desc SRPGカーソルのファイル名
* 初期値: !$SrpgCursor
* @default !$SrpgCursor
* @require 1
* @dir img/characters/
* @type file
*
* @noteParam faceName
* @noteRequire 1
* @noteDir img/faces/
* @noteType file
* @noteData enemies
*
* @help
* TMPlugin - シミュレーションRPG ver0.1.3a
*
* 使用方法:
*
* 下記URLを参照してください。
* http://hikimoki.sakura.ne.jp/plugin/plugin_srpg.html
* このヘルプにはメモ欄タグやプラグインコマンドの簡単な説明のみを
* 記載しています。
*
* このプラグインは RPGツクールMV Version 1.3.5 で動作確認をしています。
*
* このプラグインはMITライセンスのもとに配布しています、商用利用、
* 改造、再配布など、自由にお使いいただけます。
*
*
* メモ欄タグ(イベント):
*
* <srpgManager>
* このタグのついたイベントをSRPG管理イベントとして利用します。
*
* <srpgActor:0>
* このタグのついたイベントを味方ユニットとして利用します。
* 数値はパーティ内の並び順( 0 が先頭)です。
*
* <srpgEnemy:3>
* このタグのついたイベントを敵ユニットとして利用します。
* 数値は敵キャラのデータベース上の番号です。
*
* <neutral>
* このタグのついたイベントは残りユニット数のカウントから除外します。
*
* <traitor>
* このタグのついたイベントに行動制約『味方を攻撃』が常時付加されます。
*
* <autoState:5 9>
* SRPG開始時、またはsrpgAddUnitコマンド実行時に 5 番と 9 番のステートを
* 自動的に付加します。
*
*
* メモ欄タグ(アクター、職業、武器、防具、敵キャラ、ステート):
*
* <mov:4>
* 移動力を設定します。アクターの場合は現在の職業、装備品、ステートの値も
* 含めた合計値が採用されます。
*
* <shipMove>
* 通常は進入不可能な水の上も移動することができるようになります。
*
* <floatMove>
* 地形を無視して移動することができるようになります。
*
* <search:5>
* 索敵距離を設定します。一番近くにいる敵対ユニットとの距離が
* この値よりも大きい場合、移動も行動もしなくなります。
* タグを省略、または 0 を指定するとこの機能はオフになります。
*
*
* メモ欄タグ(アイテム、スキル):
*
* <range:diamond 2>
* スキルの射程距離を設定します。射程タイプと射程距離を半角スペースで
* 区切って指定してください。射程タイプは下記の中から選んでください。
* diamond = ひし形
* rect = 四角形
* line = 直線(上下左右)
* また、<range:diamond 2 rect 0> のように続けてもうひとつタイプと距離を
* 指定すると、範囲の中心に穴をあけることができます。
*
* <effect:rect 3>
* スキルの効果範囲を設定します。範囲タイプと大きさを半角スペースで
* 区切って指定してください。指定する値は射程距離と同じです。
*
*
* メモ欄タグ(敵キャラ):
*
* <faceName:Monster>
* 敵キャラの顔グラフィックとして利用する画像ファイル名を設定します。
*
* <faceIndex:0>
* 敵キャラの顔グラフィックのインデックスを設定します。
* インデックスとは画像のどの部分を使用するかを決める番号です。
* 0 1 2 3
* 4 5 6 7
*
* <level:10>
* 敵キャラのレベルを設定します、この値はステータス表示のためのダミーです、
* 数値によって能力値が変化するようなことはありません。
*
* <class:3>
* 敵キャラの職業を設定します、この値はステータス表示のためのダミーです、
* 数値によって能力値が変化するようなことはありません。
*
* <nickname:乱暴者>
* 敵キャラの二つ名を設定します。
*
* <profile:人間が大嫌いなオーク族の戦士>
* 敵キャラのプロフィールを設定します。
*
* <equips:2 0 0 3 0>
* 敵キャラの装備品を設定します、この値はステータス表示のためのダミーです、
* 数値によって能力値が変化するようなことはありません。
* 装備スロットの上から順に装備品の番号を半角スペースで区切って
* 指定してください。
*
* <attackAnimation:6>
* 敵キャラの通常攻撃のアニメーション番号を設定します。
*
*
* プラグインコマンド:
*
* reserveSrpg
* SRPG機能を有効化する予約をします、このコマンドを実行したあとにイベント
* コマンド『場所移動』でマップが切り替わるとSRPG機能が有効になります。
*
* srpgCursorMove 10 5
* SRPGカーソルを座標 (10, 5) へ移動させます。
*
* srpgCursorMoveToEvent 2
* SRPGカーソルをイベント 2 番へ移動させます。
*
* setSrpgDestination 4 10 15
* 4 番のイベントの目的地を座標 (10, 15) に設定します。
*
* clearSrpgDestination 4
* 4 番のイベントの目的地設定を解除します。
*
*
* スクリプトコマンド:
*
* this.isSrpgTurnStart()
* ターン開始フラグが立っているかどうかを返します。
*
* this.isSrpgActorTurn()
* 味方ターンかどうかを返します。
*
* this.srpgNextUnit()
* 次に行動するイベント番号を返します。
*
* this.srpgLastUnit()
* 直前に行動したイベント番号を返します。
*
* this.srpgBattler(0)
* ユニットイベントのバトラーオブジェクトを返します。
* 括弧内に取得したいユニットイベントのイベント番号を指定してください。
* 0 を指定した場合はこのコマンドを実行しているイベントが対象となります。
* 何も指定しなかった場合は次に行動するイベント、または直前に行動した
* イベントが対象となります。
*
* this.srpgRemoveUnit(0)
* ユニットイベントを強制的に排除します。
* 戦闘不能になった場合と同じ扱いとなり、セルフスイッチAが自動的に
* オンになり、イベント内容も実行されます。
* 対象の指定方法は this.srpgBattler と同じです。
*
* this.srpgAddUnit(10, 1)
* イベント番号 10 番を敵キャラ 1 番のエネミーユニットとして設定します。
*/
var Imported = Imported || {};
Imported.TMSrpg = true;
(function() {
var parameters = PluginManager.parameters('TMSrpg');
var vnSrpgTurnCount = +(parameters['vnSrpgTurnCount'] || 1);
var vnActorUnitNums = +(parameters['vnActorUnitNums'] || 2);
var vnEnemyUnitNums = +(parameters['vnEnemyUnitNums'] || 3);
var srpgBasicWait = +(parameters['srpgBasicWait'] || 30);
var damagePopupInterval = +(parameters['damagePopupInterval'] || 30);
var checkSkillId = +(parameters['checkSkillId'] || 0);
var regionEffects = {};
parameters['regionEffects'].split(' ').forEach(function(arg) {
arg = arg.split(',').map(Number);
regionEffects[arg[0]] = arg[1];
});
var useRegionEffectWindow = parameters['useRegionEffectWindow'] === '1';
var useUnitHpGauge = parameters['useUnitHpGauge'] === '1';
var useUnitStateIcon = parameters['useUnitStateIcon'] === '1';
var simpleMoveInput = parameters['simpleMoveInput'] === '1';
var moveCommand = parameters['moveCommand'];
var moveCancelCommand = parameters['moveCancelCommand'];
var actionCommand = parameters['actionCommand'];
var itemCommand = parameters['itemCommand'];
var equipCommand = parameters['equipCommand'];
var waitingCommand = parameters['waitingCommand'];
var statusCommand = parameters['statusCommand'];
var turnEndCommand = parameters['turnEndCommand'];
var unitListCommand = parameters['unitListCommand'];
var infoCommand = parameters['infoCommand'];
var optionsCommand = parameters['optionsCommand'];
var saveCommand = parameters['saveCommand'];
var loadCommand = parameters['loadCommand'];
var gameEndCommand = parameters['gameEndCommand'];
var yesCommand = parameters['yesCommand'];
var noCommand = parameters['noCommand'];
var moveParam = parameters['moveParam'];
var moveHelp = parameters['moveHelp'];
var waitingHelp = parameters['waitingHelp'];
var turnEndHelp = parameters['turnEndHelp'];
var actionRangeHelp = parameters['actionRangeHelp'];
var actionEffectHelp = parameters['actionEffectHelp'];
var colorAreaMove = parameters['colorAreaMove'].split(' ').map(Number);
var colorAreaWaiting = parameters['colorAreaWaiting'].split(' ').map(Number);
var colorAreaRange = parameters['colorAreaRange'].split(' ').map(Number);
var colorAreaEffect = parameters['colorAreaEffect'].split(' ').map(Number);
var backAttackPhysical = +(parameters['backAttackPhysical'] || 1.5);
var backAttackMagical = +(parameters['backAttackMagical'] || 1.5);
var reflectAnimationId = +(parameters['reflectAnimationId'] || 0);
var srpgCommandX = +parameters['srpgCommandX'];
var srpgCommandY = +parameters['srpgCommandY'];
var srpgCommandLineHeight = +parameters['srpgCommandLineHeight'];
var srpgStatusBackground = +parameters['srpgStatusBackground'];
var srpgStatusNameWidth = +parameters['srpgStatusNameWidth'];
var srpgStatusHpWidth = +parameters['srpgStatusHpWidth'];
var srpgStatusFaceMirror = parameters['srpgStatusFaceMirror'];
var srpgUnitListWidth = +parameters['srpgUnitListWidth'];
var srpgUnitListRows = +parameters['srpgUnitListRows'];
var srpgInfoSize = parameters['srpgInfoSize'].split('*').map(Number);
var srpgStatusArrowImage = parameters['srpgStatusArrowImage'];
var srpgCursorImage = parameters['srpgCursorImage'];
//-----------------------------------------------------------------------------
// Game_Temp
//
// 初期化処理
var _Game_Temp_initialize = Game_Temp.prototype.initialize;
Game_Temp.prototype.initialize = function() {
_Game_Temp_initialize.call(this);
this.clearSrpgCommand();
this.clearSrpgNextUnitId();
this._srpgLastUnitId = -1;
this._srpgDeadUnitIds = [];
this._srpgCounterUnitIds = [];
};
// ダミーウィンドウを返す
Game_Temp.prototype.srpgDummyWindow = function() {
if (this._srpgDummyWindow == null) this._srpgDummyWindow = new Window_Base(0, 0, 0, 0);
return this._srpgDummyWindow;
};
// SRPGコマンドウィンドウの復元予約
Game_Temp.prototype.reserveSrpgCommand = function(index, event) {
this._srpgCommandIndex = index;
this._srpgCommandEventId = event ? event.eventId() : 0;
};
// SRPGコマンドウィンドウの復元予約をクリア
Game_Temp.prototype.clearSrpgCommand = function() {
this._srpgCommandIndex = -1;
};
// SRPGコマンドウィンドウの復元予約が有効かどうかを返す
Game_Temp.prototype.isSrpgCommandReserved = function() {
return this._srpgCommandIndex >= 0;
};
// 復元予約のウィンドウインデックスを返す
Game_Temp.prototype.srpgCommandIndex = function() {
return this._srpgCommandIndex;
};
// 復元予約の対象イベントを返す
Game_Temp.prototype.srpgCommandEvent = function() {
return $gameMap.event(this._srpgCommandEventId);
};
// SRPGのターン開始フラグをセット
Game_Temp.prototype.setSrpgTurnStart = function(flag) {
this._srpgTurnStart = flag;
};
// SRPGのターン開始フラグが立っているかを返す
Game_Temp.prototype.isSrpgTurnStart = function() {
return this._srpgTurnStart;
};
// これから行動するユニットのイベント番号をクリア
Game_Temp.prototype.clearSrpgNextUnitId = function() {
this.setSrpgNextUnitId(0);
};
// これから行動するユニットのイベント番号をセット
Game_Temp.prototype.setSrpgNextUnitId = function(id) {
this._srpgNextUnitId = id;
};
// これから行動するユニットのイベント番号を返す
Game_Temp.prototype.srpgNextUnitId = function() {
return this._srpgNextUnitId;
};
// 最後に選択したユニットのイベント番号をセット
Game_Temp.prototype.setSrpgLastUnitId = function(id) {
this._srpgLastUnitId = id;
};
// 最後に選択したユニットのイベント番号を返す
Game_Temp.prototype.srpgLastUnitId = function() {
return this._srpgLastUnitId;
};
// ユニットの退場予約
Game_Temp.prototype.setSrpgDeadUnitId = function(id) {
this._srpgDeadUnitIds.push(id);
};
// 退場予約されているユニットのイベント番号をひとつ返す
Game_Temp.prototype.srpgDeadUnitId = function() {
return this._srpgDeadUnitIds.shift();
};
// ユニットの反撃予約
Game_Temp.prototype.setSrpgCounterUnitId = function(id) {
this._srpgCounterUnitIds.push(id);
};
// 反撃予約されているユニットのイベント番号をひとつ返す
Game_Temp.prototype.srpgCounterUnitId = function() {
return this._srpgCounterUnitIds.shift();
};
//-----------------------------------------------------------------------------
// Game_Action
//
// 行動主体のセット
var _Game_Action_setSubject = Game_Action.prototype.setSubject;
Game_Action.prototype.setSubject = function(subject) {
_Game_Action_setSubject.call(this, subject);
// エネミーをトループではなくユニットイベントから取得するための仕込み
if (this._subjectActorId === 0 && this._subjectEnemyIndex < 0) {
this._subjectActorId = -subject.srpgEventId();
}
};
// 行動主体を返す
var _Game_Action_subject = Game_Action.prototype.subject;
Game_Action.prototype.subject = function() {
if (this._subjectActorId < 0) {
// トループを使わずに行動主体としてSRPGバトラーを返す
return $gameMap.event(-this._subjectActorId).srpgBattler();
}
return _Game_Action_subject.call(this);
};
// SRPG用の行動評価計算
Game_Action.prototype.srpgEvaluateWithTarget = function(target) {
if (this.isHpEffect()) {
var value = this.srpgMakeDamageValue(target, true);
if (this.isForOpponent()) {
return value / Math.max(target.hp, 1);
} else {
var recovery = Math.min(-value, target.mhp - target.hp);
return recovery / target.mhp;
}
}
};
// SRPG用の行動結果適用
Game_Action.prototype.srpgApply = function(target) {
var result = target.result();
this.subject().clearResult();
result.clear();
result.used = this.testApply(target);
result.missed = (result.used && Math.random() >= this.itemHit(target));
result.evaded = (!result.missed && Math.random() < this.itemEva(target));
result.physical = this.isPhysical();
result.drain = this.isDrain();
if (result.idear()) {
if (this.item().damage.type > 0) {
result.critical = (Math.random() < this.itemCri(target));
var value = this.srpgMakeDamageValue(target, false, result.critical);
this.executeDamage(target, value);
}
this.item().effects.forEach(function(effect) {
this.applyItemEffect(target, effect);
}, this);
this.applyItemUserEffect(target);
}
};
// 結果予測用のダメージ計算
Game_Action.prototype.srpgMakeDamageValue = function(target, evaluate, critical) {
var baseValue = this.evalDamageFormula(target);
var value = baseValue * this.calcElementRate(target);
if (this.isPhysical()) value *= target.pdr;
if (this.isMagical()) value *= target.mdr;
if (baseValue < 0) value *= target.rec;
if (baseValue > 0) value = this.applyBackAttack(value, target);
if (!evaluate) {
var item = this.item();
if (critical) value = this.applyCritical(value);
value = this.applyVariance(value, item.damage.variance);
}
value = this.applyGuard(value, target);
return Math.round(value);
};
// 背後攻撃のダメージ補正
Game_Action.prototype.applyBackAttack = function(value, target) {
var subject = this.subject();
if (subject.srpgEventId() > 0 && target.srpgEventId() > 0) {
var subjectEvent = subject.srpgEvent();
var targetEvent = target.srpgEvent();
var lastDirection = subjectEvent.direction();
subjectEvent.turnTowardCharacter(targetEvent);
if (subjectEvent.direction() === targetEvent.direction()) {
if (this.isPhysical()) value *= backAttackPhysical;
if (this.isMagical()) value *= backAttackMagical;
}
subjectEvent.setDirection(lastDirection);
}
return value;
};
// ターゲットに対して有効な効果を返す
Game_Action.prototype.itemValidEffect = function(target) {
var effects = this.item().effects;
for (var i = 0; i < effects.length; i++) {
var effect = effects;
if (this.testItemEffect(target, effect)) return effect;
}
return null;
};
// 行動内容が逃げるかどうかを返す
Game_Action.prototype.isEscape = function() {
var effects = this.item().effects;
return effects.some(function(effect) {
return effect.code === Game_Action.EFFECT_SPECIAL;
});
};
//-----------------------------------------------------------------------------
// Game_BattlerBase
//
// 使用可能時の適合判定
var _Game_BattlerBase_isOccasionOk = Game_BattlerBase.prototype.isOccasionOk;
Game_BattlerBase.prototype.isOccasionOk = function(item) {
// SRPGが有効なら『常時』か『バトル画面』に設定されていれば使用可能
if ($gameMap.isSrpg()) return item.occasion === 0 || item.occasion === 1;
return _Game_BattlerBase_isOccasionOk.call(this, item);
};
// SRPGパラメータを返す
Game_BattlerBase.prototype.srpgParam = function(tag) {
var result = this.traitObjects().reduce(function(r, object) {
return r + Number(object.meta[tag] || 0);
}, 0);
return Math.max(result, 0);
};
// SRPGフラグを返す
Game_BattlerBase.prototype.srpgFlag = function(tag) {
return this.traitObjects().some(function(object) {
return object.meta[tag];
});
};
// ユニットのイベント番号をセット
Game_BattlerBase.prototype.setSrpgEventId = function(id) {
this._srpgEventId = id;
};
// ユニットのイベント番号を返す
Game_BattlerBase.prototype.srpgEventId = function() {
return this._srpgEventId || 0;
};
// ユニットイベントを返す
Game_BattlerBase.prototype.srpgEvent = function() {
return $gameMap.event(this.srpgEventId());
};
//-----------------------------------------------------------------------------
// Game_Battler
//
// ユニット退場に対応したgainHp
Game_Battler.prototype.srpgGainHp = function(value) {
Game_Battler.prototype.gainHp.call(this, value);
if (this.isDead()) $gameTemp.setSrpgDeadUnitId(this.srpgEventId());
};
// 行動のアニメーションIDを返す
Game_Battler.prototype.srpgActionAnimationId = function(item) {
var animationId = item.animationId;
return animationId < 0 ? this.attackAnimationId1() : animationId;
};
//-----------------------------------------------------------------------------
// Game_Actor
//
// srpg用の自動行動決定処理
Game_Actor.prototype.srpgMakeActions = function() {
Game_Battler.prototype.makeActions.call(this);
if (this.isAutoBattle()) {
// 使用可能な行動内容からランダムに選択する
var list = this.makeActionList();
for (var i = 0; i < this.numActions(); i++) {
this.setAction(i, list[Math.randomInt(list.length)]);
}
} else {
this.makeConfusionActions();
}
};
//-----------------------------------------------------------------------------
// Game_Enemy
//
Object.defineProperty(Game_Enemy.prototype, 'level', {
get: function() {
return this.enemy().meta.level || 1;
},
configurable: true
});
Game_Enemy.prototype.faceName = function() {
return this.enemy().meta.faceName || '';
};
Game_Enemy.prototype.faceIndex = function() {
return +(this.enemy().meta.faceIndex || 0);
};
Game_Enemy.prototype.nickname = function() {
return this.enemy().meta.nickname || '';
};
Game_Enemy.prototype.profile = function() {
return this.enemy().meta.profile || '';
};
Game_Enemy.prototype.currentClass = function() {
return $dataClasses[this.enemy().meta.class || 1];
};
Game_Enemy.prototype.equips = function() {
var equipIds = this.enemy().meta.equips;
if (equipIds) {
equipIds = equipIds.split(' ').map(Number);
return equipIds.map(function(id, i) {
return i === 0 ? $dataWeapons[id] : $dataArmors[id];
});
}
return [];
};
Game_Enemy.prototype.attackAnimationId1 = function() {
return +(this.enemy().meta.attackAnimation || 1);
};
// srpg用の自動行動決定処理
Game_Enemy.prototype.srpgMakeActions = function() {
return this.makeActions();
};
//-----------------------------------------------------------------------------
// Game_Map
//
// 範囲表示カラーを初期化
Game_Map.prototype.initColorArea = function() {
if (!Imported.SAN_TileToner) return;
this.clearTileTones();
};
// 範囲表示カラーをセット
Game_Map.prototype.setColorArea = function(colorParam) {
if (!Imported.SAN_TileToner) return;
this.clearTileTones();
var keys = Object.keys(this._srpgArea);
for (var i = 0, a; i < keys.length; i++) {
a = keys.split(',').map(Number);
this.setTileTone.apply(this, a.concat(colorParam));
}
};
// SRPG機能が有効になっているかどうかを返す
Game_Map.prototype.isSrpg = function() {
return this._srpgActive;
};
// SRPG機能を有効にします
Game_Map.prototype.srpgActivate = function() {
this._srpgActive = true;
this._srpgActorTurn = false;
this.changeSrpgTurnCount(0);
this.setupTilePassableTable(); // 地形通行判定テーブルのセットアップ
this.setupSrpgManagerEvent(); // SRPG管理イベントのセットアップ
this.setupSrpgUnits(); // SRPGユニットのセットアップ
this.onSrpgTurnStart();
};
// SRPG機能を無効にします
Game_Map.prototype.srpgDeactivate = function() {
this._srpgActive = false;
$gameTemp.clearSrpgCommand();
$gameTemp.clearSrpgNextUnitId();
};
// SRPGの開始を予約します
Game_Map.prototype.reserveSrpgStart = function() {
this._needsSrpgStart = true;
};
// ターン開始
Game_Map.prototype.onSrpgTurnStart = function() {
this._srpgActorTurn = !this._srpgActorTurn;
if (this._srpgActorTurn) {
this.changeSrpgTurnCount(this._srpgTurnCount + 1); // ターン数のカウント
}
this.srpgActiveTurnUnits(true).forEach(function(event) {
event.onSrpgTurnStart();
});
$gameTemp.setSrpgTurnStart(true); // ターン開始フラグを立てる
this.startSrpgManagerEvent(); // SRPG管理イベントを起動する
};
// ターン数の変更
Game_Map.prototype.changeSrpgTurnCount = function(n) {
this._srpgTurnCount = n;
$gameVariables.setValue(vnSrpgTurnCount, n);
};
// 味方ターンかどうかを返す
Game_Map.prototype.isSrpgActorTurn = function() {
return this._srpgActorTurn;
};
// マップのセットアップ
var _Game_Map_setup = Game_Map.prototype.setup;
Game_Map.prototype.setup = function(mapId) {
_Game_Map_setup.call(this, mapId);
this.initColorArea();
if (this._needsSrpgStart) {
this.srpgActivate(); // SRPG機能を有効化
this._needsSrpgStart = false;
} else if (this.isSrpg()) {
this.srpgDeactivate(); // SRPG機能を無効化
}
};
// 地形通行判定テーブルをセットアップ
Game_Map.prototype.setupTilePassableTable = function() {
this._normalTilePassableTable = [];
this._floatTilePassableTable = [];
this._shipTilePassableTable = [];
this._terrainTagTable = [];
for (var x = 0; x < this.width(); x++) {
this._normalTilePassableTable[x] = [];
this._floatTilePassableTable[x] = [];
this._shipTilePassableTable[x] = [];
for (var y = 0; y < this.height(); y++) {
this._normalTilePassableTable[x][y] = [];
this._floatTilePassableTable[x][y] = [];
this._shipTilePassableTable[x][y] = [];
for (var d = 2; d <= 8; d += 2) {
var x2 = this.roundXWithDirection(x, d);
var y2 = this.roundYWithDirection(y, d);
if (this.isValid(x2, y2)) {
var d2 = 10 - d;
var index = d / 2 - 1;
var pass2 = this.isPassable(x2, y2, d2);
if (this.isPassable(x, y, d) && pass2) {
this._normalTilePassableTable[x][y][index] = true;
this._shipTilePassableTable[x][y][index] = true;
} else if (this.isShipPassable(x2, y2) ||
(this.isShipPassable(x, y) && pass2)) {
this._shipTilePassableTable[x][y][index] = true;
}
this._floatTilePassableTable[x][y][index] = true;
}
}
if (this.terrainTag(x, y) === 1) {
this._terrainTagTable.push(new Point(x, y));
}
}
}
};
// SRPG管理イベントのセットアップ
Game_Map.prototype.setupSrpgManagerEvent = function() {
var events = this.events();
for (var i = 0; i < events.length; i++) {
var event = events;
if (event.event().meta.srpgManager) {
this._srpgManagerEventId = event.eventId();
event.setSelfSwitch('A', false);
event.setSelfSwitch('B', false);
event.refresh();
break;
}
}
};
// SRPG管理イベントを返す
Game_Map.prototype.srpgManagerEvent = function() {
return this.event(this._srpgManagerEventId);
};
// SRPG管理イベントを起動する
Game_Map.prototype.startSrpgManagerEvent = function() {
this.srpgManagerEvent().start();
};
// SRPGユニットのセットアップ
Game_Map.prototype.setupSrpgUnits = function() {
this._srpgEnemyIds = {};
this.events().forEach(function(event) {
event.setupSrpgBattler();
});
this.updateSrpgEnemyLetter();
this.updateActorUnitNums();
this.updateEnemyUnitNums();
$gameTemp.setSrpgLastUnitId(-1);
};
Game_Map.prototype.updateSrpgEnemyLetter = function() {
var events = this.srpgEnemyUnits();
for (var i = 0; i < events.length; i++) {
var id = events.srpgBattler().enemyId();
if (this._srpgEnemyIds[id] >= 2) events.setPlural(true);
}
};
Game_Map.prototype.setSrpgEnemyId = function(id) {
if (this._srpgEnemyIds[id] == null) this._srpgEnemyIds[id] = 0;
return this._srpgEnemyIds[id]++;
};
// 残っているアクターユニットの数を更新
Game_Map.prototype.updateActorUnitNums = function() {
var events = this.srpgActorUnits(true).filter(function(event) {
return !event.event().meta.neutral;
});
$gameVariables.setValue(vnActorUnitNums, events.length);
};
// 残っているエネミーユニットの数を更新
Game_Map.prototype.updateEnemyUnitNums = function() {
var events = this.srpgEnemyUnits(true).filter(function(event) {
return !event.event().meta.neutral;
});
$gameVariables.setValue(vnEnemyUnitNums, events.length);
};
// SRPGユニットを返す
Game_Map.prototype.srpgUnits = function(alive) {
return this.events().filter(function(event) {
return event.isSrpgUnit(alive);
});
};
// SRPGアクターユニットを返す
Game_Map.prototype.srpgActorUnits = function(alive) {
return this.events().filter(function(event) {
return event.isSrpgActorUnit(alive);
});
};
// SRPGエネミーユニットを返す
Game_Map.prototype.srpgEnemyUnits = function(alive) {
return this.events().filter(function(event) {
return event.isSrpgEnemyUnit(alive);
});
};
// ターンがアクティブな勢力に属するユニットを返す
Game_Map.prototype.srpgActiveTurnUnits = function(alive) {
return this._srpgActorTurn ? this.srpgActorUnits(alive) :
this.srpgEnemyUnits(alive);
};
// 指定ユニットと違う勢力に属するユニットを返す
Game_Map.prototype.srpgOpponentUnits = function(unit, alive) {
return unit.isSrpgActorUnit() ? this.srpgEnemyUnits(alive) : this.srpgActorUnits(alive);
};
// 指定ユニットと違う勢力に属するユニットを返す(魅了と裏切り者を考慮)
Game_Map.prototype.srpgOpponentUnitsEx = function(unit, alive) {
var confusionLevel = unit.srpgBattler().confusionLevel();
var flag = unit.isSrpgActorUnit() ^ unit.isTraitor() ^
((confusionLevel === 2 && Math.randomInt(2) === 0) || confusionLevel === 3);
var a = flag ? this.srpgEnemyUnits(alive) : this.srpgActorUnits(alive);
var b = flag ? this.srpgActorUnits(alive) : this.srpgEnemyUnits(alive);
var result = a.filter(function(event) {
return (event.srpgBattler().confusionLevel() < 3) === !event.isTraitor();
});
return result.concat(b.filter(function(event) {
return (event.srpgBattler().confusionLevel() < 3) !== !event.isTraitor();
}));
};
// 指定ユニットと同じ勢力に属するユニットを返す
Game_Map.prototype.srpgFriendUnits = function(unit, alive) {
return unit.isSrpgActorUnit() ? this.srpgActorUnits(alive) : this.srpgEnemyUnits(alive);
};
// 指定座標のSRPGユニットを返す
Game_Map.prototype.srpgUnitXy = function(x, y, alive) {
var events = this.srpgUnits(alive);
for (var i = 0; i < events.length; i++) {
var event = events;
if (event.pos(x, y)) return event;
}
return null;
};
// 範囲内のSRPGユニットを返す
Game_Map.prototype.srpgUnitsArea = function(area, alive) {
area = area || this._srpgArea;
var result = [];
var events = this.srpgUnits(alive);
for (var i = 0; i < events.length; i++) {
var event = events;
var key = '' + event.x + ',' + event.y;
if (area[key]) result.push(event);
}
return result;
};
// 指定した行動が有効なユニットを返す
Game_Map.prototype.srpgActionEffectiveUnits = function(unit, action) {
if (!action.item()) return [];
var confusionLevel = unit.srpgBattler().confusionLevel();
var flag = ((confusionLevel === 2 && Math.randomInt(2) === 0) ||
confusionLevel === 3) ^ unit.isTraitor();
// 敵対象スキルかつ勢力反転なし、または味方対象スキルかつ勢力反転あり
if (action.isForOpponent() ^ flag) {
// 魅了されていない敵対ユニットを抽出
var result = this.srpgOpponentUnits(unit, true).filter(function(event) {
return event.srpgBattler().confusionLevel() < 3;
});
// 裏切り者の味方ユニットを追加
result = result.concat(this.srpgFriendUnits(unit, true).filter(function(event) {
return event.isTraitor();
}));
return result;
}
// 敵対象スキルかつ勢力反転あり
if (flag) {
// 自分以外かつ、勢力反転していない味方ユニットを返す
return this.srpgFriendUnits(unit, true).filter(function(event) {
return event.eventId() !== unit.eventId() &&
(!event.isTraitor() ^ event.srpgBattler().confusionLevel() === 3);
});
}
// 味方対象スキルかつ勢力反転なし
// 裏切り者以外の味方ユニットを返す
return this.srpgFriendUnits(unit, true).filter(function(event) {
return !event.isTraitor();
});
};
// 移動中のSRPGユニットがいるかどうかを返す
Game_Map.prototype.isSrpgUnitMoving = function() {
return this.srpgUnits().some(function(event) {
return event.isMoveRouteForcing();
});
};
// アニメーション表示中のSRPGユニットがいるかどうかを返す
Game_Map.prototype.isSrpgUnitAnimationPlaying = function() {
return this.srpgUnits().some(function(event) {
return event.isAnimationPlaying();
});
};
// イベントを指定座標からの距離で並べ替える
Game_Map.prototype.sortEventsDistance = function(events, x, y) {
events.sort(function(a, b) {
var d1 = Math.abs(x - a.x) + Math.abs(y - a.y);
var d2 = Math.abs(x - b.x) + Math.abs(y - b.y);
return d1 - d2;
});
return events;
};
// イベントを敏捷性で並べ替える
Game_Map.prototype.sortEventsAgi = function(events) {
events.sort(function(a, b) {
return b.srpgBattler().agi - a.srpgBattler().agi;
});
return events;
};
// 移動可能範囲を表示する
Game_Map.prototype.showMovableArea = function(unit) {
this._srpgArea = {};
this.setupPassableTable(unit); // 通行判定テーブルをセットアップ
this.checkMovableArea(unit); // 移動可能範囲のルートチェック
this.deleteAreaOverlapEvent(); // すでにイベントがある座標を除外
this.setColorArea(colorAreaMove);
};
// 通行判定テーブルをセットアップ
Game_Map.prototype.setupPassableTable = function(unit) {
if (unit.isFloat()) {
this._passableTable = JSON.parse(JSON.stringify(this._floatTilePassableTable));
} else if (unit.isShip()) {
this._passableTable = JSON.parse(JSON.stringify(this._shipTilePassableTable));
} else {
this._passableTable = JSON.parse(JSON.stringify(this._normalTilePassableTable));
}
var events = this.srpgUnits(true);
for (var i = 0, len = events.length; i < len; i++) {
var event = events;
if (event.isNormalPriority() && !unit.isFriend(event)) {
for (var j = 0; j < 4; j++) {
this._passableTable[event.x][event.y][j] = undefined;
}
}
}
};
// 移動可能範囲のルートチェック
Game_Map.prototype.checkMovableArea = function(unit) {
var mov = unit.mov();
if (mov === 0) return;
mov = mov - 1;
var a = [];
a.push([unit.x, unit.y + 1, unit.x, unit.y, 0, '1', mov]);
a.push([unit.x - 1, unit.y, unit.x, unit.y, 1, '2', mov]);
a.push([unit.x + 1, unit.y, unit.x, unit.y, 2, '3', mov]);
a.push([unit.x, unit.y - 1, unit.x, unit.y, 3, '4', mov]);
while (a.length > 0) {
var data = a.pop();
var x = data[0];
var y = data[1];
var key = '' + x + ',' + y;
if (this._passableTable[data[2]][data[3]][data[4]] &&
(!this._srpgArea[key] || data[5].length <= this._srpgArea[key].length)) {
this._srpgArea[key] = data[5];
if (data[6] > 0) {
data[6] = data[6] - 1;
if (data[4] !== 3) a.push([x, y + 1, x, y, 0, data[5] + '1', data[6]]);
if (data[4] !== 2) a.push([x - 1, y, x, y, 1, data[5] + '2', data[6]]);
if (data[4] !== 1) a.push([x + 1, y, x, y, 2, data[5] + '3', data[6]]);
if (data[4] !== 0) a.push([x, y - 1, x, y, 3, data[5] + '4', data[6]]);
}
}
}
};
// 待機範囲を表示する
Game_Map.prototype.showWaitingArea = function(unit) {
this._srpgArea = this.createArea(unit.x, unit.y, ['diamond', 1, 'rect', 0]);
this.setColorArea(colorAreaWaiting);
};
// 射程範囲を表示する
Game_Map.prototype.showRangeArea = function(x, y, skill) {
this._srpgArea = this.createRangeArea(x, y, skill);
this.setColorArea(colorAreaRange);
};
// 射程範囲を作成する
Game_Map.prototype.createRangeArea = function(x, y, skill) {
var a = (skill.meta.range || 'diamond 1').split(' ');
return this.createArea(x, y, a);
};
// 効果範囲を表示する
Game_Map.prototype.showEffectArea = function(x, y, skill) {
this._srpgArea = this.createEffectArea(x, y, skill);
this.setColorArea(colorAreaEffect);
};
// 効果範囲を作成する
Game_Map.prototype.createEffectArea = function(x, y, skill) {
var a = (skill.meta.effect || 'diamond 0').split(' ');
return this.createArea(x, y, a);
};
// 範囲を作成する
Game_Map.prototype.createArea = function (x, y, param) {
var area = {};
if (param[0] === 'diamond') {
this.setArea(area, this.isAreaValidDiamond, x, y, +param[1], true);
} else if (param[0] === 'rect') {
this.setArea(area, this.isAreaValidRect, x, y, +param[1], true);
} else if (param[0] === 'line') {
this.setArea(area, this.isAreaValidLine, x, y, +param[1], true);
} else if (param[0] === 'straight') {
this.setArea(area, this.isAreaValidPortrait, x, y, +param[1], true);
} else if (param[0] === 'x') {
this.setArea(area, this.isAreaValidX, x, y, +param[1], true);
} else if (param[0] === 'T') {
this.setArea(area, this.isAreaValidT, x, y, +param[1], true);
} else if (param[0] === 'foward') {
this.setArea(area, this.isAreaValidFoward, x, y, +param[1], true);
}
if (param[2] === 'diamond') {
this.deleteArea(area, this.isAreaValidDiamond, x, y, +param[3], false);
} else if (param[2] === 'rect') {
this.deleteArea(area, this.isAreaValidRect, x, y, +param[3], false);
} else if (param[2] === 'line') {
this.deleteArea(area, this.isAreaValidLine, x, y, +param[3], false);
} else if (param[2] === 'straight') {
this.deleteArea(area, this.isAreaValidPortrait, x, y, +param[3], false);
} else if (param[2] === 'x') {
this.deleteArea(area, this.isAreaValidX, x, y, +param[3], false);
} else if (param[2] === 'T') {
this.deleteArea(area, this.isAreaValidT, x, y, +param[3], false);
} else if (param[2] === 'foward') {
this.deleteArea(area, this.isAreaValidFoward, x, y, +param[3], false);
}
return area;
};
Game_Map.prototype.setArea = function(area, checker, x, y, size) {
for (var x2 = x - size; x2 <= x + size; x2++) {
for (var y2 = y - size; y2 <= y + size; y2++) {
if (checker(x, y, x2, y2, size)) area['' + x2 + ',' + y2] = true;
}
}
};
Game_Map.prototype.deleteArea = function(area, checker, x, y, size) {
for (var x2 = x - size; x2 <= x + size; x2++) {
for (var y2 = y - size; y2 <= y + size; y2++) {
if (checker(x, y, x2, y2, size)) delete area['' + x2 + ',' + y2];
}
}
};
Game_Map.prototype.isAreaValidDiamond = function(x, y, x2, y2, size) {
return Math.abs(x - x2) + Math.abs(y - y2) <= size;
};
Game_Map.prototype.isAreaValidRect = function(x, y, x2, y2, size) {
return true;
};
Game_Map.prototype.isAreaValidLine = function(x, y, x2, y2, size) {
return x === x2 || y === y2;
};
Game_Map.prototype.isAreaValidPortrait = function (x, y, x2, y2, size) {
return (x === x2);
};
Game_Map.prototype.isAreaValidX = function (x, y, x2, y2, size) {
return x != x2 && y != y2 && (Math.abs(x + y2) == Math.abs(x2 + y) || Math.abs(x + y) == Math.abs(x2 + y2));
};
Game_Map.prototype.isAreaValidFoward = function (x, y, x2, y2, size) {
var character = $gamePlayer;
// var character = this._srpgStatusWindow.user();
if (character.direction() == 8) {
return (x === x2 && y >= y2);
}
else if (character.direction() == 2) {
return (x === x2 && y <= y2);
}
else if (character.direction() == 4) {
return (x >= x2 && y == y2);
}
else if (character.direction() == 6) {
return (x <= x2 && y == y2);
}
};
Game_Map.prototype.isAreaValidT = function (x, y, x2, y2, size) {
var character = $gamePlayer;
// var character = this._srpgStatusWindow.user();
if (character.direction() == 8) {
return y === y2 || (x === x2 && y <= y2);
}
else if (character.direction() == 2) {
return y === y2 || (x === x2 && y >= y2);
}
else if (character.direction() == 4) {
return x === x2 || (y === y2 && x <= x2);
}
else if (character.direction() == 6) {
return (x === x2) || (y === y2 && x >= x2);
}
};
// 範囲からすでにイベントがある座標を除外
Game_Map.prototype.deleteAreaOverlapEvent = function() {
var events = this.events();
for (var i = 0; i < events.length; i++) {
var event = events;
if (event.isNormalPriority() && !event.isThrough()) {
delete this._srpgArea['' + event.x + ',' + event.y];
}
};
};
// 範囲が空かどうかを返す
Game_Map.prototype.isSrpgAreaEmpty = function() {
return Object.keys(this._srpgArea).length === 0;
};
// 範囲表示を隠す
Game_Map.prototype.hideSrpgArea = function() {
this.initColorArea();
};
// 指定座標の範囲の値を返す
Game_Map.prototype.srpgAreaXy = function(x, y) {
return this._srpgArea['' + x + ',' + y];
};
// 指定座標に一番近い範囲の座標を返す
Game_Map.prototype.posInsideAreaNearXy = function(x, y) {
var result = null;
var minValue = 1000;
var targetEvent = this.srpgUnitXy(x, y, true);
if (targetEvent) {
// 指定座標にユニットがいればその背後の評価を高くする
var bonusD = 10 - targetEvent.direction();
var bonusX = this.xWithDirection(x, bonusD);
var bonusY = this.yWithDirection(y, bonusD);
}
for (var prop in this._srpgArea) {
var pos = prop.split(',').map(Number);
var d = Math.abs(x - pos[0]) + Math.abs(y - pos[1]);
if (pos[0] === bonusX && pos[1] === bonusY) d--;
if (d < minValue) {
minValue = d;
result = new Point(pos[0], pos[1]);
}
}
return result;
};
// 指定座標から一番遠い範囲の座標を返す
Game_Map.prototype.posInsideAreaFarXy = function(x, y) {
var result = null;
var maxValue = -1;
for (var prop in this._srpgArea) {
var pos = prop.split(',').map(Number);
var d = Math.abs(x - pos[0]) + Math.abs(y - pos[1]);
if (d > maxValue) {
maxValue = d;
result = new Point(pos[0], pos[1]);
}
}
return result;
};
// 指定座標が範囲に含まれているかを返す
Game_Map.prototype.isInsideArea = function(x, y) {
return this.srpgAreaXy(x, y) !== undefined;
};
// 指定イベントの一番近くにあり、ユニットイベントのいない地形タグ 1 番の座標を返す
Game_Map.prototype.srpgBlankPosition = function(event) {
var result = null;
var minValue = 1000;
for (var i = 0; i < this._terrainTagTable.length; i++) {
var x = this._terrainTagTable.x;
var y = this._terrainTagTable.y;
if (this.srpgUnitXy(x, y)) continue;
var d = Math.abs(event.x - x) + Math.abs(event.y - y);
if (d < minValue) {
minValue = d;
result = this._terrainTagTable;
}
}
return result;
};
//-----------------------------------------------------------------------------
// Game_CharacterBase
//
// キャラクターがSRPGユニットかどうかを返す
Game_CharacterBase.prototype.isSrpgUnit = function() {
return false;
};
//-----------------------------------------------------------------------------
// Game_Character
//
Game_Character.prototype.turnTowardXy = function(x, y) {
var sx = this.deltaXFrom(x);
var sy = this.deltaYFrom(y);
if (Math.abs(sx) > Math.abs(sy)) {
this.setDirection(sx > 0 ? 4 : 6);
} else if (sy !== 0) {
this.setDirection(sy > 0 ? 8 : 2);
}
};
//-----------------------------------------------------------------------------
// Game_Player
//
var _Game_Player_hasStepAnime = Game_Player.prototype.hasStepAnime;
Game_Player.prototype.hasStepAnime = function() {
return _Game_Player_hasStepAnime.call(this) || $gameMap.isSrpg();
};
var _Game_Player_refresh = Game_Player.prototype.refresh;
Game_Player.prototype.refresh = function() {
_Game_Player_refresh.call(this);
if ($gameMap.isSrpg()) { // SRPG機能が有効なら歩行グラフィックをカーソルにする
var characterName = srpgCursorImage;
var characterIndex = 0;
this.setImage(characterName, characterIndex);
}
};
var _Game_Player_updateMove = Game_Player.prototype.updateMove;
Game_Player.prototype.updateMove = function() {
if ($gameMap.isSrpg()) {
if (this._x < this._realX) {
this._realX = Math.max(this._realX - this._srpgVx, this._x);
} else if (this._x > this._realX) {
this._realX = Math.min(this._realX + this._srpgVx, this._x);
}
if (this._y < this._realY) {
this._realY = Math.max(this._realY - this._srpgVy, this._y);
} else if (this._y > this._realY) {
this._realY = Math.min(this._realY + this._srpgVy, this._y);
}
} else {
_Game_Player_updateMove.call(this);
}
};
var _Game_Player_updateNonmiving = Game_Player.prototype.updateNonmoving;
Game_Player.prototype.updateNonmoving = function(wasMoving) {
if (!$gameMap.isSrpg()) {
_Game_Player_updateNonmiving.call(this, wasMoving);
}
};
var _Game_Player_canMove = Game_Player.prototype.canMove;
Game_Player.prototype.canMove = function() {
return $gameMap.isSrpg() ? false : _Game_Player_canMove.call(this);
};
// SRPG機能(カメラ)としての移動先をセットする(座標で指定)
Game_Player.prototype.setSrpgCameraXy = function(x, y) {
this._x = x;
this._y = y;
this._srpgVx = Math.abs((this._x - this._realX) / 8);
this._srpgVy = Math.abs((this._y - this._realY) / 8);
};
// SRPG機能(カメラ)としての移動先をセットする(イベントで指定)
Game_Player.prototype.setSrpgCameraEvent = function(event) {
this.setSrpgCameraXy(event.x, event.y);
};
//-----------------------------------------------------------------------------
// Game_Followers
//
var _Game_Followers_isVisible = Game_Followers.prototype.isVisible;
Game_Followers.prototype.isVisible = function() {
return _Game_Followers_isVisible.call(this) && !$gameMap.isSrpg();
};
//-----------------------------------------------------------------------------
// Game_Event
//
Game_Event.prototype.setSelfSwitch = function(switchCode, flag) {
var key = [this._mapId, this._eventId, switchCode];
$gameSelfSwitches.setValue(key, flag);
};
Game_Event.prototype.srpgAutoStart = function(switchCode) {
this.setSelfSwitch(switchCode, true);
this.refresh();
this.start();
};
var _Game_Event_erase = Game_Event.prototype.erase;
Game_Event.prototype.erase = function() {
_Game_Event_erase.call(this);
if (this.isSrpgActorUnit()) {
$gameMap.updateActorUnitNums();
} else {
$gameMap.updateEnemyUnitNums();
}
};
// SRPGバトラーをセットアップ
Game_Event.prototype.setupSrpgBattler = function(enemyId) {
this._srpgActorId = null;
this._srpgEnemyId = null;
this._srpgBattler = null;
var srpgActorId = this.event().meta.srpgActor;
if (srpgActorId) {
this.setSelfSwitch('A', false);
var actor = $gameParty.allMembers()[+srpgActorId];
if (actor) {
this.initSrpgUnitSetting();
this._srpgActorId = +srpgActorId;
this.setImage(actor.characterName(), actor.characterIndex());
} else {
this.erase();
}
} else {
var srpgEnemyId = enemyId || this.event().meta.srpgEnemy;
if (srpgEnemyId != null) {
this.setSelfSwitch('A', false);
if (+srpgEnemyId > 0) {
this.initSrpgUnitSetting();
this._srpgEnemyId = +srpgEnemyId;
this._srpgBattler = new Game_Enemy(this._srpgEnemyId, 0, 0);
this._letterIndex = $gameMap.setSrpgEnemyId(this._srpgEnemyId);
}
}
}
if (this.isSrpgUnit()) {
this.srpgBattler().setSrpgEventId(this.eventId());
this.setSrpgAutoState();
this.refreshRegionEffect(this.x, this.y, this.x, this.y);
}
};
Game_Event.prototype.initSrpgUnitSetting = function() {
this.refresh();
this.setPriorityType(1);
};
Game_Event.prototype.setSrpgAutoState = function() {
var stateIds = (this.event().meta.autoState || '').split(' ').map(Number);
var battler = this.srpgBattler();
stateIds.forEach(function(stateId) {
battler.addState(stateId);
});
};
Game_Event.prototype.setPlural = function(plural) {
var battler = this.srpgBattler();
battler.setPlural(plural);
battler.setLetter(plural ? $gameTroop.letterTable()[this._letterIndex] : '');
};
// イベントのSRPGバトラーを返す
Game_Event.prototype.srpgBattler = function() {
if (this.isSrpgActorUnit()) return $gameParty.allMembers()[this._srpgActorId];
return this._srpgBattler;
};
// イベントがSRPGユニットかどうかを返す
Game_Event.prototype.isSrpgUnit = function(alive) {
return this.isSrpgActorUnit(alive) || this.isSrpgEnemyUnit(alive);
};
// イベントがSRPGアクターユニットかどうかを返す
Game_Event.prototype.isSrpgActorUnit = function(alive) {
if (this._srpgActorId == null) return false;
return alive == null || this.srpgBattler().isAlive() === alive;
};
// イベントがSRPGエネミーユニットかどうかを返す
Game_Event.prototype.isSrpgEnemyUnit = function(alive) {
if (this._srpgEnemyId == null) return false;
return alive == null || this.srpgBattler().isAlive() === alive;
};
// イベントが対象ユニットと同じ勢力に属しているかどうかを返す
Game_Event.prototype.isFriend = function(unit) {
return this.srpgBattler().isActor() === unit.srpgBattler().isActor();
};
// イベントが自動行動かどうかを返す
Game_Event.prototype.isSrpgAutoBattle = function() {
var battler = this.srpgBattler();
if (this.isSrpgActorUnit()) {
return battler.isAutoBattle() || battler.isConfused();
}
return battler.enemy().actions.length > 0;
};
// イベントが操作入力可能かどうかを返す
Game_Event.prototype.isSrpgInputtable = function() {
return this.isSrpgActorUnit(true) && !this.isSrpgAutoBattle();
};
// イベントが水上移動可能状態かどうかを返す
Game_Event.prototype.isShip = function() {
return this.srpgBattler().srpgFlag('shipMove');
};
// イベントが浮遊移動状態かどうかを返す
Game_Event.prototype.isFloat = function() {
return this.srpgBattler().srpgFlag('floatMove');
};
// イベントの移動力を返す
Game_Event.prototype.mov = function() {
return Math.max(this.srpgBattler().srpgParam('mov'), 0);
};
// イベントの索敵距離を返す
Game_Event.prototype.search = function() {
return this.srpgBattler().srpgParam('search');
};
// イベントが裏切り者かどうかを返す
Game_Event.prototype.isTraitor = function() {
return this.event().meta.traitor;
};
// イベントが移動可能かどうかを返す
Game_Event.prototype.canSrpgMove = function() {
return !this._moved && this.mov() > 0;
};
// イベントの移動を終了する
Game_Event.prototype.endSrpgMove = function() {
this._moved = true;
};
// イベントが行動可能かどうかを返す
Game_Event.prototype.canSrpgAct = function() {
return !this._acted && this.srpgBattler().canMove();
};
// イベントの行動を終了する
Game_Event.prototype.endSrpgAction = function() {
this._moved = true;
this._acted = true;
this.clearLastPosition(); // 移動前の座標情報をクリア
};
// イベントのターン開始処理
Game_Event.prototype.onSrpgTurnStart = function() {
var battler = this.srpgBattler();
battler.onTurnEnd();
this.reserveDamagePopup(damagePopupInterval);
this.srpgCheckDead();
this._moved = false;
this._acted = false;
};
// イベントの待機処理
Game_Event.prototype.executeSrpgWaiting = function(x, y) {
this.turnTowardXy(x, y);
this._moved = true; // 移動済みフラグを立てる
this.endSrpgAction(); // 行動を終了する
};
// イベントの索敵距離内に敵対ユニットがいるかどうかを返す
Game_Event.prototype.checkSearch = function() {
var search = this.search();
if (search === 0 || this.srpgBattler().isConfused() ||
this.srpgDestination()) return true;
var area = $gameMap.createArea(this.x, this.y, ['diamond', search, 'rect', 0]);
var events = $gameMap.srpgUnitsArea(area, true);
var flag = this.isSrpgActorUnit();
return events.some(function(event) {
return event.isSrpgActorUnit() !== flag || event.isTraitor();
});
};
// 目的地を設定する
Game_Event.prototype.setSrpgDestination = function(x, y) {
this._srpgDestination = new Point(x, y);
};
// 目的地の設定を解除する
Game_Event.prototype.clearSrpgDestination = function() {
this._srpgDestination = null;
};
// 目的地を返す
Game_Event.prototype.srpgDestination = function() {
return this._srpgDestination;
};
// 文字列から移動ルートを生成して移動する
Game_Event.prototype.moveRouteText = function(routeText) {
var gc = Game_Character;
var moveRoute = {list:[], repeat:false, skippable:false, wait:true};
moveRoute.list.push({code:gc.ROUTE_THROUGH_ON, parameters:[]});
moveRoute.list.push({code:gc.ROUTE_CHANGE_SPEED, parameters:[5]});
while (routeText.length > 0) {
moveRoute.list.push({code:+routeText.slice(0, 1), parameters:[]});
routeText = routeText.slice(1);
}
moveRoute.list.push({code:gc.ROUTE_THROUGH_OFF, parameters:[]});
moveRoute.list.push({code:gc.ROUTE_CHANGE_SPEED, parameters:[3]});
moveRoute.list.push({code:gc.ROUTE_END, parameters:[]});
this.forceMoveRoute(moveRoute);
this._lastPosition = {x:this._x, y:this._y, direction:this.direction()};
this._moved = true; // 移動済みフラグを立てる
};
// 移動キャンセル
Game_Event.prototype.backToLastPosition = function() {
this.refreshRegionEffect(this._x, this._y, this._lastPosition.x, this._lastPosition.y);
this.locate(this._lastPosition.x, this._lastPosition.y);
this.setDirection(this._lastPosition.direction);
this.clearLastPosition(); // 移動前の座標情報をクリア
this._moved = false;
};
// 移動前の座標情報をクリア
Game_Event.prototype.clearLastPosition = function() {
this._lastPosition = null;
};
// 移動前の座標情報が有効かどうかを返す
Game_Event.prototype.isLastPositionValid = function() {
return !!this._lastPosition;
};
// 地形効果のリフレッシュ
Game_Event.prototype.refreshRegionEffect = function(lastX, lastY, newX, newY) {
var battler = this.srpgBattler();
var lastStateId = regionEffects[$gameMap.regionId(lastX, lastY)];
var newStateId = regionEffects[$gameMap.regionId(newX, newY)];
battler.clearResult();
if (lastStateId !== newStateId && lastStateId) battler.removeState(lastStateId);
if (newStateId) battler.addState(newStateId);
};
// 指定した行動を評価して最も効果の高い座標を返す
Game_Event.prototype.srpgEvaluateAction = function(action) {
var skill = action.item();
if (!skill) return null;
var result = null, maxValue = 0, cache = {};
var targets = $gameMap.srpgActionEffectiveUnits(this, action);
var rangeArea = $gameMap.createRangeArea(this.x, this.y, skill);
for (var prop in rangeArea) {
var sum = 0;
var pos = prop.split(',').map(Number);
var effectArea = $gameMap.createEffectArea(pos[0], pos[1], skill);
for (var i = 0; i < targets.length; i++) {
var target = targets;
var key = '' + target.x + ',' + target.y;
if (effectArea[key]) {
if (!cache[key]) {
var battler = target.srpgBattler();
cache[key] = action.srpgEvaluateWithTarget(battler);
if (action.hasItemAnyValidEffects(battler)) cache[key] += 0.5;
}
sum += cache[key];
}
}
if (sum > maxValue) {
maxValue = sum;
result = new Point(pos[0], pos[1]);
}
}
return result;
};
// 行動のアニメーションを表示
Game_Event.prototype.showSrpgActionAnimation = function() {
var subject = this.srpgBattler();
var targets = $gameMap.srpgUnitsArea(null, true);
var action = subject.currentAction();
var item = action.item();
var animationId = subject.srpgActionAnimationId(item);
subject.useItem(item); // コストの支払い
for (var i = 0; i < targets.length; i++) {
targets.requestAnimation(animationId);
}
};
// 反撃のアニメーションを表示
Game_Event.prototype.showSrpgCounterAnimation = function() {
var subject = this.srpgBattler();
var target = $gameMap.event(Math.abs($gameTemp.srpgNextUnitId()));
var skill = $dataSkills[subject.attackSkillId()];
var animationId = subject.srpgActionAnimationId(skill);
this.turnTowardCharacter(target); // 最初の行動者がいる方向を向く
target.requestAnimation(animationId); // アニメーションの表示
};
// 行動の実行
Game_Event.prototype.executeSrpgAction = function() {
$gameTemp.setSrpgNextUnitId(-this.eventId());
var subject = this.srpgBattler();
this.srpgCheckDead();
var action = subject.currentAction();
var checkFlag = action.isSkill() && action.item().id === checkSkillId;
var targets = $gameMap.srpgUnitsArea(null, true);
for (var i = 0; i < targets.length; i++) {
if (targets.srpgCheckReflection(action)) targets = this;
action.srpgApply(targets.srpgBattler());
targets.reserveDamagePopup(i * damagePopupInterval);
this.reserveDamagePopup(i * damagePopupInterval);
targets.srpgCheckDead();
this.srpgCheckDead();
targets.srpgCheckCounter(action, this);
if (checkFlag) targets.start();
}
this.endSrpgAction();
subject.onAllActionsEnd();
return targets.length * damagePopupInterval;
};
// 反撃の実行
Game_Event.prototype.executeSrpgCounter = function() {
var target = $gameMap.event(Math.abs($gameTemp.srpgNextUnitId()));
var battler = target.srpgBattler();
if (battler.isDead()) return 0; // 最初の行動者が戦闘不能なら反撃しない
var action = new Game_Action(this.srpgBattler());
action.setAttack();
action.srpgApply(battler);
target.reserveDamagePopup(0);
target.srpgCheckDead();
return damagePopupInterval;
};
// 戦闘不能チェック
Game_Event.prototype.srpgCheckDead = function() {
if (this.srpgBattler().isDead()) {
$gameTemp.setSrpgDeadUnitId(this._eventId);
}
};
// 反撃チェック
Game_Event.prototype.srpgCheckCounter = function(action, attacker) {
var battler = this.srpgBattler();
if(battler.isActor()){
$gameVariables.setValue(8, battler.actorId());
$gameVariables.setValue(32, battler.level);
}
if (Math.random() < action.itemCnt(battler)) {
var skill = $dataSkills[battler.attackSkillId()];
var area = $gameMap.createRangeArea(this.x, this.y, skill);
if (area['' + attacker.x + ',' + attacker.y]) {
$gameTemp.setSrpgCounterUnitId(this._eventId);
}
}
};
// 魔法反射チェック
Game_Event.prototype.srpgCheckReflection = function(action) {
var battler = this.srpgBattler();
if (Math.random() < action.itemMrf(battler)) {
this.requestAnimation(reflectAnimationId); // 魔法反射アニメーションの再生
return true;
}
return false;
};
// ダメージポップアップの予約
Game_Event.prototype.reserveDamagePopup = function(delay) {
this._damagePopupDelay = delay;
this._damagePopupResult = JSON.parse(JSON.stringify(this.srpgBattler().result()));
};
// ダメージポップアップが予約されているかを返す
Game_Event.prototype.isDamagePopupReserved = function() {
return this._damagePopupDelay !== undefined;
};
// フレーム更新
var _Game_Event_update = Game_Event.prototype.update;
Game_Event.prototype.update = function() {
_Game_Event_update.call(this);
this.updateDamagePopup();
};
// ダメージポップアップの更新
Game_Event.prototype.updateDamagePopup = function() {
if (this.isDamagePopupReserved()) {
this._damagePopupDelay--;
if (this._damagePopupDelay <= 0) {
this.pasteDamagePopupResult();
var battler = this.srpgBattler();
battler.startDamagePopup();
var result = battler.result();
if (result.missed) {
SoundManager.playMiss();
} else if (result.evaded) {
SoundManager.playEvasion();
} else if (result.hpAffected) {
if (result.hpDamage > 0) {
if (battler.isActor()) {
SoundManager.playActorDamage();
} else {
SoundManager.playEnemyDamage();
}
} else if (result.hpDamage < 0) {
SoundManager.playRecovery();
}
}
this._damagePopupDelay = undefined;
}
}
};
Game_Event.prototype.pasteDamagePopupResult = function() {
var result = this.srpgBattler().result();
result.missed = this._damagePopupResult.missed;
result.evaded = this._damagePopupResult.evaded;
result.hpAffected = this._damagePopupResult.hpAffected;
result.hpDamage = this._damagePopupResult.hpDamage;
result.mpDamage = this._damagePopupResult.mpDamage;
result.critical = this._damagePopupResult.critical;
this._damagePopupResult = null;
};
//-----------------------------------------------------------------------------
// Game_Interpreter
//
var _Game_Interpreter_pluginCommand = Game_Interpreter.prototype.pluginCommand;
Game_Interpreter.prototype.pluginCommand = function(command, args) {
_Game_Interpreter_pluginCommand.call(this, command, args);
var a = this.convertArgs(args);
if (command === 'reserveSrpg') {
$gameMap.reserveSrpgStart();
} else if (command === 'srpgCursorMove') {
$gamePlayer.setSrpgCameraXy(+a[0], +a[1]);
} else if (command === 'srpgCursorMoveToEvent') {
var event = $gameMap.event(+a[0]);
if (event) $gamePlayer.setSrpgCameraEvent(event);
} else if (command === 'setSrpgDestination') {
var event = $gameMap.event(+a[0]);
if (event) event.setSrpgDestination(+a[1], +a[2]);
} else if (command === 'clearSrpgDestination') {
var event = $gameMap.event(+a[0]);
if (event) event.clearSrpgDestination();
}
};
Game_Interpreter.prototype.convertArgs = function(args) {
var window = $gameTemp.srpgDummyWindow();
return args.map(window.convertEscapeCharacters, window);
};
Game_Interpreter.prototype.isSrpgTurnStart = function() {
return $gameTemp.isSrpgTurnStart();
};
Game_Interpreter.prototype.isSrpgActorTurn = function() {
return $gameMap.isSrpgActorTurn();
};
Game_Interpreter.prototype.srpgNextUnit = function() {
var id = $gameTemp.srpgNextUnitId();
return id > 0 ? id : 0;
};
Game_Interpreter.prototype.srpgLastUnit = function() {
var id = $gameTemp.srpgNextUnitId();
return id < 0 ? 0 - id : 0;
};
Game_Interpreter.prototype.srpgBattler = function(eventId) {
if (eventId == null) eventId = Math.abs($gameTemp.srpgNextUnitId());
var event = this.character(eventId);
return event && event.isSrpgUnit() ? event.srpgBattler() : null;
};
Game_Interpreter.prototype.srpgRemoveUnit = function(eventId) {
var event = $gameMap.event(eventId);
if (event && event.isSrpgUnit(true)) {
var battler = event.srpgBattler();
battler.addState(battler.deathStateId());
$gameTemp.setSrpgDeadUnitId(eventId);
return true;
}
return false;
};
Game_Interpreter.prototype.srpgAddUnit = function(eventId, enemyId) {
var event = $gameMap.event(eventId);
if (event && !event.isSrpgUnit()) {
if ($gameMap.srpgUnitXy(event.x, event.y)) {
var pos = $gameMap.srpgBlankPosition(event);
if (pos == null) return false;
event.locate(pos.x, pos.y);
}
event.setupSrpgBattler(enemyId);
$gameMap.updateSrpgEnemyLetter();
$gameMap.updateActorUnitNums();
$gameMap.updateEnemyUnitNums();
}
return true;
};
Game_Interpreter.prototype.srpgActorEventId = function(actorId) {
var actor = $gameActors.actor(actorId);
var event = actor.srpgEvent();
if (event && event.isSrpgUnit(true) && event.srpgBattler() === actor) {
return actor.srpgEventId();
}
return 0;
};
//-----------------------------------------------------------------------------
// Sprite_Character
//
// メンバ変数の初期化
var _Sprite_Character_initMembers = Sprite_Character.prototype.initMembers;
Sprite_Character.prototype.initMembers = function() {
_Sprite_Character_initMembers.call(this);
this._damages = [];
};
// フレーム更新
var _Sprite_Character_update = Sprite_Character.prototype.update;
Sprite_Character.prototype.update = function() {
_Sprite_Character_update.call(this);
this.updateDamagePopup();
if (useUnitHpGauge) this.updateHpGauge();
if (useUnitStateIcon) this.updateStateIcon();
};
// ダメージポップアップの更新
Sprite_Character.prototype.updateDamagePopup = function() {
if (this._character.isSrpgUnit()) {
this.setupDamagePopup();
}
if (this._damages.length > 0) {
for (var i = 0; i < this._damages.length; i++) {
var damage = this._damages;
damage.update();
damage.x = this.x;
damage.y = this.y;
}
if (!this._damages[0].isPlaying()) {
this.parent.removeChild(this._damages[0]);
this._damages.shift();
}
}
};
// ダメージポップアップのセット
Sprite_Character.prototype.setupDamagePopup = function() {
var battler = this._character.srpgBattler();
if (battler.isDamagePopupRequested()) {
var sprite = new Sprite_Damage();
sprite.x = this.x;
sprite.y = this.y;
sprite.z = this.z + 1;
sprite.setup(battler);
this._damages.push(sprite);
this.parent.addChild(sprite);
battler.clearDamagePopup();
}
};
// HPゲージの更新
Sprite_Character.prototype.updateHpGauge = function() {
if (this._character.isSrpgUnit()) {
if (!this._srpgHpGaugeSprite) {
this._srpgHpGaugeSprite = new Sprite_SrpgHpGauge(this._character);
this._srpgHpGaugeSprite.y = -2;
this.addChild(this._srpgHpGaugeSprite);
}
}
};
// ステートアイコンの更新
Sprite_Character.prototype.updateStateIcon = function() {
if (this._character.isSrpgUnit()) {
if (!this._srpgStateIconSprite) {
this._srpgStateIconSprite = new Sprite_StateIcon();
this._srpgStateIconSprite.setup(this._character.srpgBattler());
this._srpgStateIconSprite.y = -40;
this._srpgStateIconSprite.z = 9;
this._srpgStateIconSprite.scale.x = 0.5;
this._srpgStateIconSprite.scale.y = 0.5;
this.addChild(this._srpgStateIconSprite);
}
}
};
// HPゲージとステートアイコンのbushDepth対応
var _Sprite_Character_createHalfBodySprites = Sprite_Character.prototype.createHalfBodySprites;
Sprite_Character.prototype.createHalfBodySprites = function() {
var flag = !this._upperBody;
_Sprite_Character_createHalfBodySprites.call(this);
if (flag) {
if (this._srpgHpGaugeSprite) this.addChild(this.removeChild(this._srpgHpGaugeSprite));
if (this._srpgStateIconSprite) this.addChild(this.removeChild(this._srpgStateIconSprite));
}
};
//-----------------------------------------------------------------------------
// Sprite_SrpgHpGauge
//
function Sprite_SrpgHpGauge() {
this.initialize.apply(this, arguments);
}
Sprite_SrpgHpGauge.prototype = Object.create(Sprite.prototype);
Sprite_SrpgHpGauge.prototype.constructor = Sprite_SrpgHpGauge;
Sprite_SrpgHpGauge.prototype.initialize = function(character) {
this._battler = character.srpgBattler();
Sprite.prototype.initialize.call(this);
this.bitmap = new Bitmap(32, 4);
this.z = 9;
this.anchor.x = 0.5;
this.anchor.y = 1;
};
Sprite_SrpgHpGauge.prototype.update = function() {
Sprite.prototype.update.call(this);
if (this._hp !== this._battler.hp || this._mhp !== this._battler.mhp) {
this._hp = this._battler.hp;
this._mhp = this._battler.mhp;
this.refresh();
}
};
Sprite_SrpgHpGauge.prototype.refresh = function() {
this.bitmap.clear();
if (this._hp === 0) return;
this.bitmap.fillRect(0, 0, 32, 4, '#000000');
var w = Math.floor(this._hp / this._mhp * 30);
this.bitmap.fillRect(1, 1, w, 2, this._hp === this._mhp ? '#fff060' : '#ffa030');
};
//-----------------------------------------------------------------------------
// Window_Selectable
//
Window_Selectable.prototype.activeOpen = function() {
this.open();
this.activate();
};
//-----------------------------------------------------------------------------
// Window_Status
//
Window_Status.prototype.drawParameters = function(x, y) {
var lineHeight = this.lineHeight();
for (var i = 0; i < 6; i++) {
var paramId = i + 2;
var y2 = y + lineHeight * i;
this.changeTextColor(this.systemColor());
this.drawText(TextManager.param(paramId), 6, y2, 120);
this.resetTextColor();
this.drawText(this._actor.param(paramId), 126, y2, 60, 'right');
}
this.drawText(this._actor.srpgParam('mov'), 350, y, 60, 'right');
this.changeTextColor(this.systemColor());
this.drawText(moveParam, 230, y, 120);
};
var _Window_Status_drawExpInfo = Window_Status.prototype.drawExpInfo;
Window_Status.prototype.drawExpInfo = function(x, y) {
if (this._actor.isActor()) _Window_Status_drawExpInfo.call(this, x, y);
};
//-----------------------------------------------------------------------------
// Window_SrpgCommand
//
function Window_SrpgCommand() {
this.initialize.apply(this, arguments);
}
Window_SrpgCommand.prototype = Object.create(Window_Command.prototype);
Window_SrpgCommand.prototype.constructor = Window_SrpgCommand;
Window_SrpgCommand.prototype.initialize = function() {
this.clearCommandList();
var width = this.windowWidth();
var height = this.windowHeight();
Window_Selectable.prototype.initialize.call(this, 0, 0, width, height);
this.openness = 0;
this.deactivate();
};
Window_SrpgCommand._lastCommandSymbol = null;
Window_SrpgCommand.prototype.lineHeight = function() {
return srpgCommandLineHeight;
};
Window_SrpgCommand.initCommandPosition = function() {
this._lastCommandSymbol = null;
};
Window_SrpgCommand.prototype.windowWidth = function() {
return 240;
};
Window_SrpgCommand.prototype.numVisibleRows = function() {
return this.maxItems();
};
Window_SrpgCommand.prototype.makeCommandList = function() {
this.setHandler('cancel', this._handlers['cancelOrigin']);
if (this._srpgUnit.isSrpgInputtable()) {
var canMove = this._srpgUnit.canSrpgMove();
var canAct = this._srpgUnit.canSrpgAct();
if (canMove || (this._srpgUnit.isLastPositionValid() == false && canAct == true)) {
this.addCommand(moveCommand, 'move', true);
} else {
var enabled = this._srpgUnit.isLastPositionValid();
this.setHandler('cancel', this._handlers['moveCancel']);
this.addCommand(moveCancelCommand, 'moveCancel', enabled);
}
this.addCommand(actionCommand, 'action', canAct);
if (itemCommand) this.addCommand(itemCommand, 'item', canAct);
if (equipCommand) this.addCommand(equipCommand, 'equip', canAct);
if (waitingCommand) {
var enabled = this._srpgUnit.isLastPositionValid() || canMove || canAct;
this.addCommand(waitingCommand, 'waiting', enabled);
if (enabled == false) {
this.setHandler('cancel', this._handlers['cancelOrigin']);
}
}
}
if (statusCommand) this.addCommand(statusCommand, 'status', true);
this.move(srpgCommandX, srpgCommandY, this.windowWidth(), this.windowHeight());
};
Window_SrpgCommand.prototype.makeMenuCommandList = function() {
this.setHandler('cancel', this._handlers['cancelOrigin']);
this.addCommand(turnEndCommand, 'turnEnd', true);
if (unitListCommand) this.addCommand(unitListCommand, 'unitList', true);
if (infoCommand) this.addCommand(infoCommand, 'info', true);
if (optionsCommand) this.addCommand(optionsCommand, 'options', true);
if (saveCommand) this.addCommand(saveCommand, 'save', true);
if (loadCommand) this.addCommand(loadCommand, 'load', true);
if (gameEndCommand) this.addCommand(gameEndCommand, 'gameEnd', true);
this.move(srpgCommandX, srpgCommandY, this.windowWidth(), this.windowHeight());
};
Window_SrpgCommand.prototype.makeYesNoCommandList = function() {
this.setHandler('cancel', this._handlers['noCommand']);
this.addCommand(yesCommand, 'yesCommand', true);
this.addCommand(noCommand, 'noCommand', true);
var width = this.windowWidth();
this.move((Graphics.boxWidth - width) / 2, 0, width, this.windowHeight());
};
Window_SrpgCommand.prototype.processOk = function() {
Window_SrpgCommand._lastCommandSymbol = this.currentSymbol();
Window_Command.prototype.processOk.call(this);
};
Window_SrpgCommand.prototype.selectLast = function() {
this.selectSymbol(Window_SrpgCommand._lastCommandSymbol);
};
Window_SrpgCommand.prototype.setSrpgUnit = function(srpgUnit) {
this._srpgUnit = srpgUnit;
this.refresh();
this.activeOpen();
};
Window_SrpgCommand.prototype.refreshMenu = function() {
this.clearCommandList();
this.makeMenuCommandList();
this.createContents();
Window_Selectable.prototype.refresh.call(this);
this.activeOpen();
};
Window_SrpgCommand.prototype.refreshYesNo = function(y) {
this.clearCommandList();
this.makeYesNoCommandList();
this.createContents();
Window_Selectable.prototype.refresh.call(this);
this.select(0);
this.activeOpen();
this.y = y;
};
//-----------------------------------------------------------------------------
// Window_SrpgStatus
//
function Window_SrpgStatus() {
this.initialize.apply(this, arguments);
}
Window_SrpgStatus.prototype = Object.create(Window_Base.prototype);
Window_SrpgStatus.prototype.constructor = Window_SrpgStatus;
Window_SrpgStatus.prototype.initialize = function() {
var width = Graphics.boxWidth;
var height = this.fittingHeight(4);
var y = Graphics.boxHeight - height;
Window_Base.prototype.initialize.call(this, 0, y, width, height);
this.setBackgroundType(srpgStatusBackground);
this.openness = 0;
this.createFaceSprites();
this.createArrowSprite();
};
Window_SrpgStatus.prototype.createFaceSprites = function() {
var faceWidth = Window_Base._faceWidth;
this._userFaceSprite = new Sprite();
this._userFaceSprite.anchor.x = 0.5;
this._userFaceSprite.x = this.standardPadding() + faceWidth / 2;
this._userFaceSprite.y = this.standardPadding();
if (srpgStatusFaceMirror === 'left') {
this._userFaceSprite.scale.x = -1.0;
}
this.addChildAt(this._userFaceSprite, 2);
this._targetFaceSprite = new Sprite();
this._targetFaceSprite.anchor.x = 0.5;
this._targetFaceSprite.x = this.width - faceWidth / 2 - this.standardPadding();
this._targetFaceSprite.y = this.standardPadding();
if (srpgStatusFaceMirror === 'right') {
this._targetFaceSprite.scale.x = -1.0;
}
this.addChildAt(this._targetFaceSprite, 2);
};
Window_SrpgStatus.prototype.createArrowSprite = function() {
this._arrowSprite = new Sprite();
this._arrowSprite.anchor.x = 0.5;
this._arrowSprite.anchor.y = 0.5;
this._arrowSprite.x = this.width / 2;
this._arrowSprite.y = this.height / 2 + this.lineHeight() / 2;
this._arrowSprite.bitmap = ImageManager.loadSystem(srpgStatusArrowImage);
this.addChild(this._arrowSprite);
};
Window_SrpgStatus.prototype.setSrpgUnit = function(user) {
if (user) {
this.open();
} else {
this.close();
}
if (this._user === user && this._target == null) return;
this._user = user;
this._target = null;
this.refresh();
};
Window_SrpgStatus.prototype.setAction = function(actionObject, target) {
this._actionObject = actionObject;
this._target = target;
var userBattler = this._user.srpgBattler();
userBattler.clearActions();
var action = new Game_Action(userBattler);
action.setItemObject(this._actionObject);
userBattler.setAction(0, action);
this.refresh();
};
Window_SrpgStatus.prototype.user = function() {
return this._user;
};
Window_SrpgStatus.prototype.target = function() {
return this._target;
};
var _Window_SrpgStatus_update = Window_SrpgStatus.prototype.update;
Window_SrpgStatus.prototype.update = function() {
_Window_SrpgStatus_update.call(this);
this._userFaceSprite.opacity = this.contentsOpacity;
this._targetFaceSprite.opacity = this.contentsOpacity;
this.updateArrowSprite();
};
// 矢印スプライトの更新
Window_SrpgStatus.prototype.updateArrowSprite = function() {
if (this._arrowSprite.visible) {
var n = Graphics.frameCount % 30;
var shiftX = Math.sin(Math.PI * 2 * n / 60) * 36 - 18;
this._arrowSprite.x = this.width / 2 + shiftX;
}
};
Window_SrpgStatus.prototype.refresh = function() {
this.contents.clear();
if (!this._user) return;
var userBattler = this._user.srpgBattler();
var lineHeight = this.lineHeight();
var x = this.textPadding();
var w = this.textWidth(TextManager.levelA);
this.setFaceSprite(userBattler, this._userFaceSprite);
this.drawActorIcons(userBattler, 0, lineHeight * 3);
this.changeTextColor(this.systemColor());
this.drawText(TextManager.levelA, x, lineHeight, w);
this.resetTextColor();
this.drawText(userBattler.name(), x, 0, srpgStatusNameWidth);
this.drawText(userBattler.level, x + w, lineHeight, 36, 'right');
this.drawActorGauges(userBattler, Window_Base._faceWidth, lineHeight * 2);
if (this._target) {
this.refreshTarget();
this.refreshAction();
this._targetFaceSprite.visible = true;
this._arrowSprite.visible = true;
} else {
this.refreshStatus(userBattler);
this._targetFaceSprite.visible = false;
this._arrowSprite.visible = false;
}
};
Window_SrpgStatus.prototype.refreshTarget = function() {
var targetBattler = this._target.srpgBattler();
var lineHeight = this.lineHeight();
var faceWidth = Window_Base._faceWidth;
var x = this.contents.width - faceWidth;
var w = this.textWidth(TextManager.levelA);
this.setFaceSprite(targetBattler, this._targetFaceSprite);
this.drawActorIcons(targetBattler, x, lineHeight * 3);
x = this.contents.width - this.textPadding();
this.changeTextColor(this.systemColor());
this.drawText(TextManager.levelA, x - 36 - w, lineHeight, w);
this.resetTextColor();
this.drawText(targetBattler.name(), x - srpgStatusNameWidth, 0,
srpgStatusNameWidth, 'right');
this.drawText(targetBattler.level, x - 36, lineHeight, 36, 'right');
x = this.contents.width - faceWidth - srpgStatusHpWidth;
this.drawActorGauges(targetBattler, x, lineHeight * 2);
};
Window_SrpgStatus.prototype.refreshAction = function() {
var targetBattler = this._target.srpgBattler();
var action = this._user.srpgBattler().currentAction();
var faceWidth = Window_Base._faceWidth;
var w = this.contents.width - faceWidth * 2;
var lineHeight = this.lineHeight();
this.drawText(action.item().name, faceWidth, 0, w, 'center');
var damageText = this.makeDamageText(targetBattler, action);
this.drawText(damageText, faceWidth, lineHeight * 1, w, 'center');
};
// 結果予測テキストを作成
Window_SrpgStatus.prototype.makeDamageText = function(targetBattler, action) {
if (action.isSkill() && action.item().id === checkSkillId) return '????(100%)';
var result = '';
var hit = action.itemHit(targetBattler);
var eva = action.itemEva(targetBattler);
var cnt = action.itemCnt(targetBattler);
var mrf = action.itemMrf(targetBattler);
hit = Math.floor((hit * (1 - eva)) * 100);
if (action.checkDamageType([0])) {
var effect = action.itemValidEffect(targetBattler);
result = this.makeEffectText(targetBattler, effect, hit);
} else {
var damage = -action.srpgMakeDamageValue(targetBattler, true);
if (action.isHpEffect()) {
result = TextManager.hpA;
} else if (action.isMpEffect()) {
result = TextManager.mpA;
}
result += (damage >= 0 ? '+' : '') + damage + '(' + hit + '%)';
}
if (cnt > 0) result += ' / 反击(' + Math.floor(cnt * 100) + '%)';
if (mrf > 0) result += ' / 反射(' + Math.floor(mrf * 100) + '%)';
return result;
};
// 結果予測テキストを作成
Window_SrpgStatus.prototype.makeEffectText = function(targetBattler, effect, hit) {
if (!effect) return '无效果';
switch (effect.code) {
case Game_Action.EFFECT_RECOVER_HP: // HP回復
var n = targetBattler.mhp * effect.value1 + effect.value2;
return TextManager.hpA + (n >= 0 ? '+' : '') + n;
case Game_Action.EFFECT_RECOVER_MP: // MP回復
var n = targetBattler.mmp * effect.value1 + effect.value2;
return TextManager.mpA + (n >= 0 ? '+' : '') + n;
case Game_Action.EFFECT_GAIN_TP: // TP増加
return TextManager.tpA + (effect.value1 >= 0 ? '+' : '') + effect.value1;
case Game_Action.EFFECT_ADD_STATE: // ステート付加
var stateId = effect.dataId;
return $dataStates[stateId].name + '附加' + '(' + hit + '%)';
case Game_Action.EFFECT_REMOVE_STATE: // ステート解除
var stateId = effect.dataId;
return $dataStates[stateId].name + '解除' + '(' + hit + '%)';
case Game_Action.EFFECT_ADD_BUFF: // 強化
var buffId = effect.dataId;
return TextManager.param(buffId) + '強化' + effect.value1 + '回合' + '(' + hit + '%)';
case Game_Action.EFFECT_ADD_DEBUFF: // 弱体
var buffId = effect.dataId;
return TextManager.param(buffId) + '弱化' + effect.value1 + '回合' + '(' + hit + '%)';
case Game_Action.EFFECT_REMOVE_BUFF: // 強化解除
var buffId = effect.dataId;
return TextManager.param(buffId) + '強化解除' + '(' + hit + '%)';
case Game_Action.EFFECT_REMOVE_DEBUFF: // 弱体解除
var buffId = effect.dataId;
return TextManager.param(buffId) + '弱化解除' + '(' + hit + '%)';
case Game_Action.EFFECT_LEARN_SKILL: // スキル習得
var skill = $dataSkills[effect.dataId];
return skill.name + '习得';
default:
return '无效果';
}
};
Window_SrpgStatus.prototype.refreshStatus = function(userBattler) {
var lineHeight = this.lineHeight();
for (var i = 0; i < 6; i++) {
var paramId = i + 2;
var x = i % 2 * 224 + 360;
var y = lineHeight * Math.floor(i / 2);
this.changeTextColor(this.systemColor());
this.drawText(TextManager.param(paramId), x, y, 120);
this.resetTextColor();
this.drawText(userBattler.param(paramId), x + 120, y, 60, 'right');
}
this.drawText(userBattler.srpgParam('mov'), 480, lineHeight * 3, 60, 'right');
this.changeTextColor(this.systemColor());
this.drawText(moveParam, 360, lineHeight * 3, 120);
};
Window_SrpgStatus.prototype.setFaceSprite = function(battler, sprite) {
var faceName = battler.faceName();
var faceIndex = battler.faceIndex();
var faceWidth = Window_Base._faceWidth;
var faceHeight = Window_Base._faceHeight;
sprite.bitmap = ImageManager.loadFace(faceName);
sprite.setFrame(faceIndex % 4 * faceWidth, Math.floor(faceIndex / 4) * faceHeight,
faceWidth, faceHeight);
};
Window_SrpgStatus.prototype.drawActorGauges = function(actor, x, y) {
this.drawActorHp(actor, x, y, srpgStatusHpWidth);
y += this.lineHeight();
if ($dataSystem.optDisplayTp) {
var w = srpgStatusHpWidth / 2 - 4;
this.drawActorMp(actor, x, y, w);
this.drawActorTp(actor, x + w + 8, y, w);
} else {
this.drawActorMp(actor, x, y, srpgStatusHpWidth);
}
};
//-----------------------------------------------------------------------------
// Window_SrpgSkillList
//
function Window_SrpgSkillList() {
this.initialize.apply(this, arguments);
}
Window_SrpgSkillList.prototype = Object.create(Window_Selectable.prototype);
Window_SrpgSkillList.prototype.constructor = Window_SrpgSkillList;
Window_SrpgSkillList.prototype.initialize = function(x, y, width, height) {
Window_Selectable.prototype.initialize.call(this, x, y, width, height);
this.openness = 0;
this._data = [];
};
Window_SrpgSkillList.prototype.setActor = function(actor, category) {
this._actor = actor;
this._category = category || 'skill';
this.refresh();
this.resetScroll();
};
Window_SrpgSkillList.prototype.maxItems = function() {
return this._data ? this._data.length : 1;
};
Window_SrpgSkillList.prototype.item = function() {
return this._data && this.index() >= 0 ? this._data[this.index()] : null;
};
Window_SrpgSkillList.prototype.isCurrentItemEnabled = function() {
return this.isEnabled(this._data[this.index()]);
};
Window_SrpgSkillList.prototype.includes = function(item) {
return item;
};
Window_SrpgSkillList.prototype.isEnabled = function(item) {
return this._actor && this._actor.canUse(item);
};
Window_SrpgSkillList.prototype.makeItemList = function() {
if (this._actor) {
if (this._category === 'skill') {
this._data = this._actor.skills().filter(function(item) {
return this.includes(item);
}, this);
this._data.unshift($dataSkills[this._actor.attackSkillId()]);
if (checkSkillId) this._data.push($dataSkills[checkSkillId]);
this._data.push($dataSkills[this._actor.guardSkillId()]);
} else {
this._data = $gameParty.items().filter(function(item) {
return this._actor.canUse(item);
}, this);
}
} else {
this._data = [];
}
};
Window_SrpgSkillList.prototype.selectLast = function() {
var index = this._category === 'skill' ?
this._data.indexOf(this._actor.lastBattleSkill()) :
this._data.indexOf($gameParty.lastItem());
this.select(index >= 0 ? index : 0);
};
Window_SrpgSkillList.prototype.drawItem = function(index) {
var skill = this._data[index];
if (skill) {
var rect = this.itemRect(index);
rect.width -= this.textPadding();
if (this._category === 'skill') {
var costWidth = this.costWidth();
this.changePaintOpacity(this.isEnabled(skill));
this.drawSkillCost(skill, rect.x, rect.y, rect.width);
} else {
var costWidth = this.numberWidth();
this.changePaintOpacity(1);
this.drawItemNumber(skill, rect.x, rect.y, rect.width);
}
this.drawItemName(skill, rect.x, rect.y, rect.width - costWidth);
this.changePaintOpacity(1);
}
};
Window_SrpgSkillList.prototype.costWidth = function() {
return this.textWidth('000');
};
Window_SrpgSkillList.prototype.numberWidth = function() {
return this.textWidth('000');
};
Window_SrpgSkillList.prototype.drawSkillCost = function(skill, x, y, width) {
if (this._actor.skillTpCost(skill) > 0) {
this.changeTextColor(this.tpCostColor());
this.drawText(this._actor.skillTpCost(skill), x, y, width, 'right');
} else if (this._actor.skillHpCost(skill) > 0) {
this.changeTextColor(this.textColor(18));
this.drawText(this._actor.skillHpCost(skill), x, y, width, 'right');
} else if (this._actor.skillMpCost(skill) > 0) {
this.changeTextColor(this.mpCostColor());
this.drawText(this._actor.skillMpCost(skill), x, y, width, 'right');
}
};
Window_SrpgSkillList.prototype.drawItemNumber = function(item, x, y, width) {
this.drawText(':', x, y, width - this.textWidth('00'), 'right');
this.drawText($gameParty.numItems(item), x, y, width, 'right');
};
Window_SrpgSkillList.prototype.updateHelp = function() {
this.setHelpWindowItem(this.item());
};
Window_SrpgSkillList.prototype.refresh = function() {
this.makeItemList();
this.createContents();
this.drawAllItems();
};
//-----------------------------------------------------------------------------
// Window_SrpgUnitList
//
function Window_SrpgUnitList() {
this.initialize.apply(this, arguments);
}
Window_SrpgUnitList.prototype = Object.create(Window_Selectable.prototype);
Window_SrpgUnitList.prototype.constructor = Window_SrpgUnitList;
Window_SrpgUnitList.prototype.initialize = function(x, y) {
Window_Selectable.prototype.initialize.call(this, x, y, srpgUnitListWidth,
this.fittingHeight(srpgUnitListRows));
this.openness = 0;
this._data = [];
};
Window_SrpgUnitList.prototype.lineHeight = function() {
return srpgCommandLineHeight;
};
Window_SrpgUnitList.prototype.setStatusWindow = function(statusWindow) {
this._statusWindow = statusWindow;
};
Window_SrpgUnitList.prototype.maxItems = function() {
return this._data ? this._data.length : 1;
};
Window_SrpgUnitList.prototype.item = function() {
var index = this.index();
return this._data && index >= 0 ? this._data[index] : null;
};
Window_SrpgUnitList.prototype.makeItemList = function() {
this._data = $gameMap.srpgActorUnits(true).concat($gameMap.srpgEnemyUnits(true));
};
Window_SrpgUnitList.prototype.selectLast = function() {
var lastUnit = $gameMap.event($gameTemp.srpgLastUnitId());
var lastIndex = this._data.indexOf(lastUnit);
this.select(lastIndex >= 0 ? lastIndex : 0);
};
Window_SrpgUnitList.prototype.onTouch = function(triggered) {
var lastIndex = this.index();
Window_Selectable.prototype.onTouch.call(this, triggered);
if (this.index() !== lastIndex) this.changeUnit();
};
Window_SrpgUnitList.prototype.changeUnit = function() {
var unit = this.item();
if (unit) {
$gameTemp.setSrpgLastUnitId(unit.eventId());
$gamePlayer.setSrpgCameraEvent(unit); // カメラ移動
$gameMap.showMovableArea(unit); // 移動可能範囲を表示する
this._statusWindow.setSrpgUnit(unit);
} else {
$gameMap.hideSrpgArea(); // 範囲表示を隠す
this._statusWindow.close();
}
};
Window_SrpgUnitList.prototype.drawItem = function(index) {
var item = this._data[index];
if (!item) return;
var rect = this.itemRect(index);
rect.width -= this.textPadding();
this.drawText(item.srpgBattler().name(), rect.x, rect.y, rect.width);
};
Window_SrpgUnitList.prototype.refresh = function() {
this.makeItemList();
this.createContents();
this.drawAllItems();
};
//-----------------------------------------------------------------------------
// Window_SrpgInfo
//
function Window_SrpgInfo() {
this.initialize.apply(this, arguments);
}
Window_SrpgInfo.prototype = Object.create(Window_Selectable.prototype);
Window_SrpgInfo.prototype.constructor = Window_SrpgInfo;
Window_SrpgInfo.prototype.initialize = function() {
var ww = srpgInfoSize[0];
var wh = srpgInfoSize[1];
var wx = (Graphics.width - ww) / 2;
var wy = (Graphics.height - wh) / 2;
Window_Selectable.prototype.initialize.call(this, wx, wy, ww, wh);
this.refresh();
this.activate();
};
Window_SrpgInfo.prototype.refresh = function() {
this.contents.clear();
var re = /<srpgInfo>([\s\S]+)<\/srpgInfo>/g;
var match = re.exec($dataMap.note);
if (match) this.drawTextEx(match[1], this.textPadding(), 0);
};
//-----------------------------------------------------------------------------
// Window_SrpgRegionEffect
//
function Window_SrpgRegionEffect() {
this.initialize.apply(this, arguments);
}
Window_SrpgRegionEffect.prototype = Object.create(Window_Base.prototype);
Window_SrpgRegionEffect.prototype.constructor = Window_SrpgRegionEffect;
Window_SrpgRegionEffect.prototype.initialize = function(wy) {
var ww = 200;
var wh = this.fittingHeight(1);
var wx = Graphics.width - ww;
Window_Base.prototype.initialize.call(this, wx, wy, ww, wh);
this._stateId = -1;
this.update();
};
Window_SrpgRegionEffect.prototype.update = function() {
Window_Base.prototype.update.call(this);
if (!$gameMap.isSrpg()) {
this.hide();
return;
}
var stateId = regionEffects[$gamePlayer.regionId()] || 0;
if (this._stateId !== stateId) {
this._stateId = stateId;
this.refresh();
this.show();
}
};
Window_SrpgRegionEffect.prototype.refresh = function() {
var state = $dataStates[this._stateId];
this.contents.clear();
this.drawTextEx('\\C[16]\\}地形\\{\\C[0]', 0, 0)
this.drawText(state ? state.name : '无异常', 44, 0, this.contents.Width - 48);
};
//-----------------------------------------------------------------------------
// Scene_MenuBase
//
// SRPGが有効なとき、$gameParty.menuActor() ではなくユニットイベントのバトラーを参照する
var _Scene_MenuBase_updateActor = Scene_MenuBase.prototype.updateActor;
Scene_MenuBase.prototype.updateActor = function() {
if ($gameMap.isSrpg() && $gameTemp.isSrpgCommandReserved()) {
var event = $gameTemp.srpgCommandEvent();
this._actor = event ? event.srpgBattler() : null;
} else {
_Scene_MenuBase_updateActor.call(this);
}
};
//-----------------------------------------------------------------------------
// Scene_Map
//
var _Scene_Map_createAllWindows = Scene_Map.prototype.createAllWindows;
Scene_Map.prototype.createAllWindows = function() {
_Scene_Map_createAllWindows.call(this);
this.createHelpWindow();
this.createSrpgStatusWindow();
this.createSrpgCommandWindow();
this.createSrpgSkillWindow();
this.createSrpgUnitWindow();
if (useRegionEffectWindow) this.createSrpgRegionEffectWindow();
};
Scene_Map.prototype.createHelpWindow = function() {
this._helpWindow = new Window_Help();
this._helpWindow.openness = 0;
this.addWindow(this._helpWindow);
};
Scene_Map.prototype.createSrpgCommandWindow = function() {
this._srpgCommandWindow = new Window_SrpgCommand();
this._srpgCommandWindow.setHandler('move', this.srpgCommandMove.bind(this));
this._srpgCommandWindow.setHandler('moveCancel', this.srpgCommandMoveCancel.bind(this));
this._srpgCommandWindow.setHandler('action', this.srpgCommandAction.bind(this));
this._srpgCommandWindow.setHandler('item', this.srpgCommandItem.bind(this));
this._srpgCommandWindow.setHandler('equip', this.srpgCommandEquip.bind(this));
this._srpgCommandWindow.setHandler('waiting', this.srpgCommandWaiting.bind(this));
this._srpgCommandWindow.setHandler('status', this.srpgCommandStatus.bind(this));
this._srpgCommandWindow.setHandler('turnEnd', this.srpgCommandTurnEnd.bind(this));
this._srpgCommandWindow.setHandler('unitList', this.srpgCommandUnitList.bind(this));
this._srpgCommandWindow.setHandler('info', this.srpgCommandInfo.bind(this));
this._srpgCommandWindow.setHandler('options', this.srpgCommandOptions.bind(this));
this._srpgCommandWindow.setHandler('save', this.srpgCommandSave.bind(this));
this._srpgCommandWindow.setHandler('load', this.srpgCommandLoad.bind(this));
this._srpgCommandWindow.setHandler('gameEnd', this.srpgCommandGameEnd.bind(this));
this._srpgCommandWindow.setHandler('cancelOrigin', this.cancelSrpgCommand.bind(this));
this.addWindow(this._srpgCommandWindow);
if ($gameTemp.isSrpgCommandReserved()) this.autoOpen();
};
// SRPGコマンドウィンドウの復元
Scene_Map.prototype.autoOpen = function() {
this.openSrpgCommand($gameTemp.srpgCommandEvent(), true);
this._srpgCommandWindow.select($gameTemp.srpgCommandIndex());
$gameTemp.clearSrpgCommand();
};
Scene_Map.prototype.createSrpgStatusWindow = function() {
this._srpgStatusWindow = new Window_SrpgStatus();
this.addWindow(this._srpgStatusWindow);
};
Scene_Map.prototype.createSrpgSkillWindow = function() {
var wy = this._helpWindow.height;
var ww = Graphics.boxWidth / 2;
var wh = Graphics.boxHeight - wy - this._srpgStatusWindow.height;
this._srpgSkillWindow = new Window_SrpgSkillList(0, wy, ww, wh);
this._srpgSkillWindow.setHandler('ok', this.okSrpgSkill.bind(this));
this._srpgSkillWindow.setHandler('cancel', this.cancelSrpgSkill.bind(this));
this._srpgSkillWindow.setHelpWindow(this._helpWindow);
this.addWindow(this._srpgSkillWindow);
};
Scene_Map.prototype.createSrpgUnitWindow = function() {
var wx = srpgCommandX;
var wy = srpgCommandY;
this._srpgUnitWindow = new Window_SrpgUnitList(wx, wy);
this._srpgUnitWindow.setHandler('ok', this.okSrpgUnit.bind(this));
this._srpgUnitWindow.setHandler('cancel', this.cancelSrpgUnit.bind(this));
this._srpgUnitWindow.setStatusWindow(this._srpgStatusWindow);
this.addWindow(this._srpgUnitWindow);
};
// 地形効果ウィンドウの作成
Scene_Map.prototype.createSrpgRegionEffectWindow = function() {
var wy = this._helpWindow.fittingHeight(2);
this._srpgRegionEffectWindow = new Window_SrpgRegionEffect(wy);
this.addWindow(this._srpgRegionEffectWindow);
};
Scene_Map.prototype.setSrpgWait = function(waitType, waitCount) {
this._srpgWaitType = waitType;
this._srpgWaitCount = waitCount;
};
Scene_Map.prototype.clearSrpgWait = function() {
this.setSrpgWait(null, 0);
};
var _Scene_Map_updateMain = Scene_Map.prototype.updateMain;
Scene_Map.prototype.updateMain = function() {
_Scene_Map_updateMain.call(this);
if (!$gameMap.isSrpg() || $gameMap.isEventRunning()) return;
if (!this.updateSrpgWait() && !this.updateSrpgDeadUnit() &&
!this.updateSrpgCounterUnit() && !this.checkSrpgGameOver()) {
if ($gameMap.isSrpgActorTurn()) {
if (this._areaSelecterActive) {
this.updateAreaSelecter(); // 範囲選択の更新
} else if (this._srpgTurnState) {
this.updateSrpgActorTurn(); // 味方ターンの更新
} else if (!this._srpgCommandWindow.active && !this._srpgSkillWindow.active &&
!this._srpgUnitWindow.active) {
this.updateSrpgInput(); // SRPG入力の更新
}
} else {
this.updateSrpgEnemyTurn(); // 敵ターンの更新
}
}
};
// SRPGウェイトの更新
Scene_Map.prototype.updateSrpgWait = function() {
if (this._srpgWaitType === 'normal') {
this._srpgWaitCount--;
if (this._srpgWaitCount <= 0) this.clearSrpgWait();
} else if (this._srpgWaitType === 'route') {
if (!$gameMap.isSrpgUnitMoving()) this.clearSrpgWait();
} else if (this._srpgWaitType === 'animation') {
if (!$gameMap.isSrpgUnitAnimationPlaying()) this.clearSrpgWait();
} else {
return false;
}
return true;
};
// 戦闘不能ユニットの処理
Scene_Map.prototype.updateSrpgDeadUnit = function() {
var eventId = $gameTemp.srpgDeadUnitId();
if (eventId > 0) {
var event = $gameMap.event(eventId);
event.srpgAutoStart('A');
if (event.isSrpgActorUnit()) {
var battler = event.srpgBattler();
event.setImage(battler.characterName(), battler.characterIndex());
}
return true;
}
return false;
};
// 反撃ユニットの処理
Scene_Map.prototype.updateSrpgCounterUnit = function() {
if (this._counterUnit) {
this.setSrpgWait('normal', this._counterUnit.executeSrpgCounter());
this._counterUnit = null;
return true;
} else {
var eventId = $gameTemp.srpgCounterUnitId();
if (eventId > 0) {
this._counterUnit = $gameMap.event(eventId);
this._counterUnit.showSrpgCounterAnimation();
this.setSrpgWait('animation');
return true;
}
}
return false;
};
// ゲームオーバー判定
Scene_Map.prototype.checkSrpgGameOver = function() {
if ($gameVariables.value(vnEnemyUnitNums) === 0) {
$gameMap.srpgManagerEvent().srpgAutoStart('A');
return true;
} else if ($gameVariables.value(vnActorUnitNums) === 0) {
$gameMap.srpgManagerEvent().srpgAutoStart('B');
return true;
}
return false;
};
// 範囲選択の更新
Scene_Map.prototype.updateAreaSelecter = function() {
if (TouchInput.isTriggered()){
var x = $gameMap.canvasToMapX(TouchInput.x);
var y = $gameMap.canvasToMapY(TouchInput.y);
if ($gameMap.isInsideArea(x, y)) this.callAreaOkHandler(x, y);
} else if (TouchInput.isCancelled()) {
this.callAreaCancelHandler();
}
};
// 味方ターンの更新
Scene_Map.prototype.updateSrpgActorTurn = function() {
var event = this._srpgStatusWindow.user();
switch (this._srpgTurnState) {
case 3: // 行動結果の反映
$gameTemp.setSrpgTurnStart(false);
this.setSrpgWait('normal', event.executeSrpgAction() + srpgBasicWait);
this._srpgTurnState = 4;
break;
case 4: // 行動後イベントの処理
$gameMap.startSrpgManagerEvent();
this._srpgTurnState = !event.canSrpgMove() ? 5 : 0;
break;
case 5: // 行動後の待機選択
this.srpgAutoWaiting(true);
break;
case 12: // 移動結果の反映
this._srpgStatusWindow.refresh();
this.srpgAutoWaiting(!event.canSrpgAct());
break;
case 32: // ターン開始待ち
$gameMap.onSrpgTurnStart();
var events = $gameMap.srpgUnits(true).filter(function(event) {
return event.isSrpgAutoBattle();
});
this._actionEnemyUnits = $gameMap.sortEventsAgi(events);
this._srpgTurnState = 31;
break;
}
};
Scene_Map.prototype.srpgAutoWaiting = function(flag) {
this.openSrpgCommand(this._srpgStatusWindow.user(), !flag);
if (flag) {
this._srpgCommandWindow.deactivate();
this.srpgCommandWaiting();
}
this._srpgTurnState = 0;
};
// SRPG入力の更新
Scene_Map.prototype.updateSrpgInput = function() {
if (TouchInput.isRepeated()){
var x = $gameMap.canvasToMapX(TouchInput.x);
var y = $gameMap.canvasToMapY(TouchInput.y);
var event = $gameMap.srpgUnitXy(x, y, true);
if (event && TouchInput.isTriggered()) {
this._srpgTurnState = 0;
this.openSrpgCommand(event, true); // ユニットコマンドを開く
SoundManager.playOk(); // 決定効果音を鳴らす
}
$gamePlayer.setSrpgCameraXy(x, y); // カメラ移動
} else if (TouchInput.isCancelled()) {
this.openSrpgCommand(null);
SoundManager.playOk(); // 決定効果音を鳴らす
}
};
var _Scene_Map_isMenuEnabled = Scene_Map.prototype.isMenuEnabled;
Scene_Map.prototype.isMenuEnabled = function() {
// SRPG機能が有効になっている間は通常のメニューを禁止する
return _Scene_Map_isMenuEnabled.call(this) && !$gameMap.isSrpg();
};
// SRPGコマンドウィンドウを開く
Scene_Map.prototype.openSrpgCommand = function(event, showArea) {
this._srpgStatusWindow.setSrpgUnit(event);
if (event) {
this._srpgCommandWindow.setSrpgUnit(event);
if (showArea&&event.canSrpgMove) {
$gameMap.showMovableArea(event);
this.setSimpleMoveInput(event);
}
} else {
this._srpgCommandWindow.refreshMenu();
}
this._srpgCommandWindow.select(0);
};
// シンプル移動入力の準備
Scene_Map.prototype.setSimpleMoveInput = function(event) {
if (simpleMoveInput && event.isSrpgInputtable() && event.canSrpgMove()) {
this.setAreaHandler(this.okAreaMove, this.cancelAreaMove);
}
};
// SRPGヘルプウィンドウを開く
Scene_Map.prototype.openSrpgHelp = function(text, lines) {
this._helpWindow.setText(text);
this._helpWindow.move(0, 0, Graphics.boxWidth, this._helpWindow.fittingHeight(lines));
this._helpWindow.open();
};
// SRPGスキルウィンドウを開く
Scene_Map.prototype.openSrpgSkill = function(category) {
this.areaSelecterDeactivate(true);
var event = this._srpgStatusWindow.user();
this.openSrpgHelp('', 2);
this._srpgCommandWindow.close();
this._srpgSkillWindow.setActor(event.srpgBattler(), category);
this._srpgSkillWindow.selectLast();
this._srpgSkillWindow.activeOpen();
};
// SRPGコマンド【移動】
Scene_Map.prototype.srpgCommandMove = function() {
this.openSrpgHelp(moveHelp, 1);
this._srpgCommandWindow.close();
this.setAreaHandler(this.okAreaMove, this.cancelAreaMove);
};
// SRPGコマンド【移動キャンセル】
Scene_Map.prototype.srpgCommandMoveCancel = function() {
var event = this._srpgStatusWindow.user();
event.backToLastPosition(); // 移動キャンセル実行
$gamePlayer.setSrpgCameraEvent(event); // カメラ移動
SoundManager.playCancel(); // キャンセル効果音を鳴らす
this._srpgStatusWindow.refresh();
this.cancelSrpgCommand();
};
// SRPGコマンド【行動】
Scene_Map.prototype.srpgCommandAction = function() {
this.openSrpgSkill('skill');
};
// SRPGコマンド【アイテム】
Scene_Map.prototype.srpgCommandItem = function() {
this.openSrpgSkill('item');
};
// SRPGコマンド【装備変更】
Scene_Map.prototype.srpgCommandEquip = function() {
this.changeSceneCommand(Scene_Equip);
};
// SRPGコマンド【待機】
Scene_Map.prototype.srpgCommandWaiting = function() {
var event = this._srpgStatusWindow.user();
$gameMap.showWaitingArea(event);
this.openSrpgHelp(waitingHelp, 1);
this._srpgCommandWindow.close();
this.setAreaHandler(this.okAreaWaiting, this.cancelAreaWaiting);
};
// SRPGコマンド【ステータス】
Scene_Map.prototype.srpgCommandStatus = function() {
this.changeSceneCommand(Scene_Status);
};
// SRPGコマンド【ターン終了】
Scene_Map.prototype.srpgCommandTurnEnd = function() {
this.openSrpgHelp(turnEndHelp, 1);
this._srpgCommandWindow.setHandler('yesCommand', this.srpgCommandTurnEndYes.bind(this));
this._srpgCommandWindow.setHandler('noCommand', this.srpgCommandTurnEndNo.bind(this));
this._srpgCommandWindow.refreshYesNo(this._helpWindow.height);
};
// SRPGコマンド【ユニットリスト】
Scene_Map.prototype.srpgCommandUnitList = function() {
this._srpgCommandWindow.close();
this._srpgUnitWindow.refresh();
this._srpgUnitWindow.selectLast();
this._srpgUnitWindow.changeUnit();
this._srpgUnitWindow.activeOpen();
};
// SRPGコマンド【マップ情報】
Scene_Map.prototype.srpgCommandInfo = function() {
this.changeSceneCommand(Scene_SrpgInfo);
};
// SRPGコマンド【オプション】
Scene_Map.prototype.srpgCommandOptions = function() {
this.changeSceneCommand(Scene_Options);
};
// SRPGコマンド【セーブ】
Scene_Map.prototype.srpgCommandSave = function() {
this.changeSceneCommand(Scene_Save);
};
// SRPGコマンド【ロード】
Scene_Map.prototype.srpgCommandLoad = function() {
this.changeSceneCommand(Scene_Load);
};
// SRPGコマンド【ゲーム終了】
Scene_Map.prototype.srpgCommandGameEnd = function() {
this.changeSceneCommand(Scene_GameEnd);
};
// SRPGコマンド【行動:はい】
Scene_Map.prototype.srpgCommandActionYes = function() {
var event = this._srpgStatusWindow.user();
this.showSrpgActionAnimation(event); // 行動アニメーションの表示
this._helpWindow.close();
this._srpgCommandWindow.close();
this._srpgTurnState = 3;
};
// SRPGコマンド【行動:いいえ】
Scene_Map.prototype.srpgCommandActionNo = function() {
var event = this._srpgStatusWindow.user();
var skill = this._srpgSkillWindow.item();
this.openSrpgHelp(actionRangeHelp, 1);
this.setAreaHandler(this.okAreaAction, this.cancelAreaAction);
$gameMap.showRangeArea(event.x, event.y, skill);
event.setDirection(this._lastUnitDirection); // 向きを元に戻す
$gamePlayer.setSrpgCameraEvent(event); // カメラ移動
this._srpgCommandWindow.close();
this._srpgStatusWindow.setSrpgUnit(event);
};
// SRPGコマンド【ターン終了:はい】
Scene_Map.prototype.srpgCommandTurnEndYes = function() {
this._helpWindow.close();
this._srpgCommandWindow.close();
$gameTemp.clearSrpgNextUnitId();
this._srpgTurnState = 32;
};
// SRPGコマンド【ターン終了:いいえ】
Scene_Map.prototype.srpgCommandTurnEndNo = function() {
this._helpWindow.close();
this._srpgCommandWindow.refreshMenu();
this._srpgCommandWindow.selectSymbol('turnEnd');
};
// SRPGコマンド【キャンセル】
Scene_Map.prototype.cancelSrpgCommand = function() {
this._srpgCommandWindow.close();
this._srpgStatusWindow.close();
this.areaSelecterDeactivate(true);
};
// コマンドによるシーン遷移
Scene_Map.prototype.changeSceneCommand = function(nextScene) {
var event = this._srpgStatusWindow.user();
$gameTemp.reserveSrpgCommand(this._srpgCommandWindow.index(), event); // コマンドウィンドウの復元予約
this._srpgCommandWindow.hide();
this._srpgStatusWindow.hide();
if (this._srpgRegionEffectWindow) this._srpgRegionEffectWindow.hide();
SceneManager.push(nextScene);
};
// SRPGスキルウィンドウ【決定】
Scene_Map.prototype.okSrpgSkill = function() {
var event = this._srpgStatusWindow.user();
this.openSrpgHelp(actionRangeHelp, 1);
this._srpgSkillWindow.close();
this.setAreaHandler(this.okAreaAction, this.cancelAreaAction);
$gameMap.showRangeArea(event.x, event.y, this._srpgSkillWindow.item());
};
// SRPGスキルウィンドウ【キャンセル】
Scene_Map.prototype.cancelSrpgSkill = function() {
var event = this._srpgStatusWindow.user();
this._helpWindow.close();
this._srpgSkillWindow.close();
this._srpgCommandWindow.setSrpgUnit(event);
$gameMap.showMovableArea(event);
this.setSimpleMoveInput(event);
};
// SRPGユニットウィンドウ【決定】
Scene_Map.prototype.okSrpgUnit = function() {
var event = this._srpgUnitWindow.item();
this.openSrpgCommand(event, false); // ユニットコマンドを開く
this.setSimpleMoveInput(event);
this._srpgUnitWindow.close();
};
// SRPGユニットウィンドウ【キャンセル】
Scene_Map.prototype.cancelSrpgUnit = function() {
$gameMap.hideSrpgArea(); // 範囲表示を隠す
this._srpgUnitWindow.close();
this._srpgStatusWindow.setSrpgUnit(null);
this._srpgCommandWindow.activeOpen();
};
// 範囲選択の有効化
Scene_Map.prototype.areaSelecterActivate = function() {
this._areaSelecterActive = true;
};
// 範囲選択の無効化
Scene_Map.prototype.areaSelecterDeactivate = function(hide) {
this._areaSelecterActive = false;
this._areaOkHandler = null;
this._areaCancelHandler = null;
if (hide) $gameMap.hideSrpgArea();
};
Scene_Map.prototype.setAreaHandler = function(okMethod, cancelMethod) {
this._areaOkHandler = okMethod;
this._areaCancelHandler = cancelMethod;
this.areaSelecterActivate();
};
Scene_Map.prototype.callAreaOkHandler = function(x, y) {
if (this._areaOkHandler) {
this._areaOkHandler(x, y);
SoundManager.playOk(); // 決定効果音を鳴らす
}
};
Scene_Map.prototype.callAreaCancelHandler = function() {
if (this._areaCancelHandler) {
this._areaCancelHandler();
SoundManager.playCancel(); // キャンセル効果音を鳴らす
}
};
// 範囲選択の決定【移動】
Scene_Map.prototype.okAreaMove = function(x, y) {
var event = this._srpgStatusWindow.user();
this.setSrpgMove(event, x, y);
this._srpgCommandWindow.close();
this._helpWindow.close();
this.areaSelecterDeactivate(true);
this._srpgTurnState = 12;
};
Scene_Map.prototype.setSrpgMove = function(event, x, y) {
var routeText = $gameMap.srpgAreaXy(x, y);
event.moveRouteText(routeText); // 移動を実行
event.refreshRegionEffect(event._x, event._y, x, y); //地形効果をリフレッシュ
$gamePlayer.setSrpgCameraXy(x, y); // カメラ移動
this.setSrpgWait('route'); // 移動完了までウェイト
};
// 範囲選択のキャンセル【移動】
Scene_Map.prototype.cancelAreaMove = function() {
this._srpgCommandWindow.activeOpen();
this._helpWindow.close();
if (!simpleMoveInput) this.areaSelecterDeactivate(false);
};
// 範囲選択の決定【待機】
Scene_Map.prototype.okAreaWaiting = function(x, y) {
this._srpgStatusWindow.user().executeSrpgWaiting(x, y);
$gamePlayer.setSrpgCameraXy(x, y); // カメラ移動
this._helpWindow.close();
this._srpgStatusWindow.close();
this.areaSelecterDeactivate(true);
if (this.isAllActorSrpgWaiting()) {
this.srpgCommandTurnEnd(); // ターン終了へ移行
}
};
// アクター全員が移動と行動を終えているかを返す
Scene_Map.prototype.isAllActorSrpgWaiting = function() {
return !$gameMap.srpgActorUnits(true).some(function(event) {
return !event.isSrpgAutoBattle() &&
(event.canSrpgMove() || event.canSrpgAct());
});
};
// 範囲選択のキャンセル【待機】
Scene_Map.prototype.cancelAreaWaiting = function() {
var event = this._srpgStatusWindow.user();
this._srpgCommandWindow.activeOpen();
this._helpWindow.close();
this.areaSelecterDeactivate(false);
$gameMap.showMovableArea(event);
this.setSimpleMoveInput(event);
};
// 範囲選択の決定【行動】
Scene_Map.prototype.okAreaAction = function(x, y) {
var event = this._srpgStatusWindow.user();
$gameTemp.reserveSrpgCommand(this._srpgCommandWindow.index(), event); // コマンドウィンドウの復元予約
this.openSrpgHelp(actionEffectHelp, 1);
this._srpgCommandWindow.setHandler('yesCommand', this.srpgCommandActionYes.bind(this));
this._srpgCommandWindow.setHandler('noCommand', this.srpgCommandActionNo.bind(this));
this._srpgCommandWindow.refreshYesNo(this._helpWindow.height);
this.areaSelecterDeactivate(false);
this._lastUnitDirection = event.direction();// 現在の向きを記憶
this.setSrpgAction(event, this._srpgSkillWindow.item(), x, y);
};
Scene_Map.prototype.setSrpgAction = function (event, skill, x, y) {
$gameMap.showEffectArea(x, y, skill); // 効果範囲の表示
event.turnTowardXy(x, y); // 実行先の座標を向く
$gamePlayer.setDirection(event.direction());
this.setSrpgAction2(event, skill, x, y);
};
Scene_Map.prototype.setSrpgAction2 = function (event, skill, x, y) {
$gameMap.showEffectArea(x, y, skill); // 効果範囲の表示
event.turnTowardXy(x, y); // 実行先の座標を向く
$gamePlayer.setSrpgCameraXy(x, y); // カメラ移動
var events = $gameMap.sortEventsDistance($gameMap.srpgUnitsArea(null, true), x, y);
this._srpgStatusWindow.setAction(skill, events[0]);
}
// 範囲選択のキャンセル【行動】
Scene_Map.prototype.cancelAreaAction = function() {
this.openSrpgHelp('', 2);
this._srpgSkillWindow.activeOpen();
this.areaSelecterDeactivate(true);
};
// 行動アニメーションの表示
Scene_Map.prototype.showSrpgActionAnimation = function(event) {
$gameMap.hideSrpgArea(); // 範囲表示を隠す
this._srpgStatusWindow.close();
event.showSrpgActionAnimation(); // 行動アニメーションの表示
this.setSrpgWait('animation'); // アニメーション完了までウェイト
};
// 次に行動するSRPGエネミーユニットをセット
Scene_Map.prototype.setSrpgNextEnemyUnit = function() {
if (this._actionEnemyUnits.length > 0) {
var event = this._actionEnemyUnits.shift();
var battler = event.srpgBattler();
this._srpgTurnState = 31;
if (event.isSrpgAutoBattle() && !battler.isDead()) {
$gameTemp.setSrpgNextUnitId(event.eventId());
$gamePlayer.setSrpgCameraEvent(event); // カメラ移動
this._srpgStatusWindow.setSrpgUnit(event);
if (event.checkSearch()) {
battler.srpgMakeActions(); // 行動を作成
if (battler.numActions() > 0) this._srpgTurnState = 1;
}
}
} else {
$gameTemp.clearSrpgNextUnitId();
this._srpgStatusWindow.setSrpgUnit(null);
this._srpgTurnState = 32; // 敵ターン状態遷移
}
};
// 敵ターンの更新
Scene_Map.prototype.updateSrpgEnemyTurn = function() {
var event = this._srpgStatusWindow.user();
switch (this._srpgTurnState) {
case 1: // 移動前行動(準備)
this._srpgTurnState = this.updateSrpgEnemyActionReady(event) ? 2 : 11;
break;
case 2: // 移動前行動(アニメーション表示)
this.showSrpgActionAnimation(event);
this._srpgTurnState = 3;
break;
case 3: // 移動前行動(行動結果の反映)
this.setSrpgWait('normal', event.executeSrpgAction() + srpgBasicWait);
this._srpgTurnState = 4;
break;
case 4: // 移動前行動(行動後イベントの処理)
$gameMap.startSrpgManagerEvent();
this._srpgTurnState = 31;
break;
case 11: // 移動(準備)
this._srpgTurnState = this.updateSrpgEnemyMoveReady(event) ? 12 : 21;
break;
case 12: // 移動(移動結果の反映)
this.updateSrpgEnemyMove(event);
this._srpgTurnState = 21;
break;
case 21: // 移動後行動(準備)
this._srpgTurnState = this.updateSrpgEnemyActionReady(event) ? 22 : 31;
break;
case 22: // 移動後行動(アニメーション表示)
this.showSrpgActionAnimation(event);
this._srpgTurnState = 23;
break;
case 23: // 移動後行動(行動結果の反映)
this.setSrpgWait('normal', event.executeSrpgAction() + srpgBasicWait);
this._srpgTurnState = 24;
break;
case 24: // 移動後行動(行動後イベントの処理)
$gameMap.startSrpgManagerEvent();
this._srpgTurnState = 31;
break;
case 31: // 次のユニットへ
this.setSrpgNextEnemyUnit();
$gameTemp.setSrpgTurnStart(false);
$gameMap.startSrpgManagerEvent();
break;
case 32: // ターン開始待ち
$gameMap.onSrpgTurnStart();
this._srpgTurnState = 0;
break;
}
};
// 敵の行動準備処理
Scene_Map.prototype.updateSrpgEnemyActionReady = function(event) {
if (!event.canSrpgAct()) return false; // 行動不可なら終了
var action = event.srpgBattler().currentAction();
var targetPos = event.srpgEvaluateAction(action);
if (targetPos) { // 有効な実行先が見つかった
this.setSrpgAction(event, action.item(), targetPos.x, targetPos.y);
this.setSrpgWait('normal', srpgBasicWait);
return true;
}
return false;
};
// 敵の移動準備処理
Scene_Map.prototype.updateSrpgEnemyMoveReady = function(event) {
if (event.srpgBattler().isDead()) return false; // 反撃等で戦闘不能なら終了
var destination = event.srpgDestination();
if (destination) {
// すでに目的地に到着していれば終了
if (event.pos(destination.x, destination.y)) return false;
} else {
var action = event.srpgBattler().currentAction();
var targets = action.isEscape() ? $gameMap.srpgOpponentUnitsEx(event, true) :
$gameMap.srpgActionEffectiveUnits(event, action);
this._moveTarget = $gameMap.sortEventsDistance(targets, event.x, event.y)[0];
if (!this._moveTarget) return false; // 対象がいなければ終了
}
$gameMap.showMovableArea(event);
if ($gameMap.isSrpgAreaEmpty()) return false; // 移動できる座標がなければ終了
this._srpgStatusWindow.setSrpgUnit(event);
this.setSrpgWait('normal', srpgBasicWait);
return true;
};
// 敵の移動処理
Scene_Map.prototype.updateSrpgEnemyMove = function(event) {
var escape = event.srpgBattler().currentAction().isEscape() || !event.canSrpgAct();
var target = event.srpgDestination() || this._moveTarget;
var targetPos = escape ? $gameMap.posInsideAreaFarXy(target.x, target.y) :
$gameMap.posInsideAreaNearXy(target.x, target.y);
this.setSrpgMove(event, targetPos.x, targetPos.y);
$gameMap.hideSrpgArea(); // 範囲表示を隠す
};
//-----------------------------------------------------------------------------
// Scene_SrpgInfo
//
function Scene_SrpgInfo() {
this.initialize.apply(this, arguments);
}
Scene_SrpgInfo.prototype = Object.create(Scene_MenuBase.prototype);
Scene_SrpgInfo.prototype.constructor = Scene_SrpgInfo;
Scene_SrpgInfo.prototype.initialize = function() {
Scene_MenuBase.prototype.initialize.call(this);
};
Scene_SrpgInfo.prototype.create = function() {
Scene_MenuBase.prototype.create.call(this);
this._statusWindow = new Window_SrpgInfo();
this._statusWindow.setHandler('cancel', this.popScene.bind(this));
this.addWindow(this._statusWindow);
};
})();
[/fold]
[fold=YEP核心]//=============================================================================
// Yanfly Engine Plugins - Core Engine
// YEP_CoreEngine.js
//=============================================================================
var Imported = Imported || {};
Imported.YEP_CoreEngine = true;
var Yanfly = Yanfly || {};
Yanfly.Core = Yanfly.Core || {};
Yanfly.Core.version = 1.25;
//=============================================================================
/*:
* @plugindesc v1.25 Needed for the majority of Yanfly Engine Scripts. Also
* contains bug fixes found inherently in RPG Maker.
* @author Yanfly Engine Plugins
*
* @param ---Screen---
* @default
*
* @param Screen Width
* @parent ---Screen---
* @type number
* @min 0
* @desc Adjusts the width of the screen.
* Default: 816
* @default 816
*
* @param Screen Height
* @parent ---Screen---
* @type number
* @min 0
* @desc Adjusts the height of the screen.
* Default: 624
* @default 624
*
* @param Scale Battlebacks
* @parent ---Screen---
* @type boolean
* @on YES
* @off NO
* @desc Do you wish to scale battlebacks to resolution?
* NO - false YES - true
* @default true
*
* @param Scale Title
* @parent ---Screen---
* @type boolean
* @on YES
* @off NO
* @desc Do you wish to scale the title screen to resolution?
* NO - false YES - true
* @default true
*
* @param Scale Game Over
* @parent ---Screen---
* @type boolean
* @on YES
* @off NO
* @desc Do you wish to scale the game over screen to resolution?
* NO - false YES - true
* @default true
*
* @param Open Console
* @parent ---Screen---
* @type boolean
* @on Open
* @off Don't Open
* @desc For testing and debug purposes, this opens up the console.
* Don't Open - false Open - true
* @default false
*
* @param Reposition Battlers
* @parent ---Screen---
* @type boolean
* @on YES
* @off NO
* @desc Allow the plugin to reposition battlers to resolution?
* NO - false YES - true
* @default true
*
* @param GameFont Load Timer
* @parent ---Screen---
* @type number
* @min 0
* @desc This allows you to set the timer for loading the GameFont.
* Set to 0 for unlimited time. Default: 20000
* @default 0
*
* @param Update Real Scale
* @parent ---Screen---
* @type boolean
* @on YES
* @off NO
* @desc For now, best left alone, but it will allow real scaling for
* screen stretching. NO - false YES - true
* @default false
*
* @param Collection Clear
* @parent ---Screen---
* @type boolean
* @on YES
* @off NO
* @desc Clears stored objects within major scenes upon switching
* scenes to free up memory. NO - false YES - true
* @default true
*
* @param ---Gold---
* @desc
*
* @param Gold Max
* @parent ---Gold---
* @type number
* @min 1
* @desc The maximum amount of gold the player can have.
* Default: 99999999
* @default 99999999
*
* @param Gold Font Size
* @parent ---Gold---
* @type number
* @min 1
* @desc The font size used to display gold.
* Default: 28
* @default 20
*
* @param Gold Icon
* @parent ---Gold---
* @type number
* @min 0
* @desc This will be the icon used to represent gold in the gold
* window. If left at 0, no icon will be displayed.
* @default 313
*
* @param Gold Overlap
* @parent ---Gold---
* @desc This will be what's displayed when the gold number
* exceeds the allocated area's content size.
* @default A lotta
*
* @param ---Items---
* @desc
*
* @param Default Max
* @parent ---Items---
* @type number
* @min 1
* @desc This is the maximum number of items a player can hold.
* Default: 99
* @default 99
*
* @param Quantity Text Size
* @parent ---Items---
* @type number
* @min 1
* @desc This is the text's font size used for the item quantity.
* Default: 28
* @default 20
*
* @param ---Parameters---
* @default
*
* @param Max Level
* @parent ---Parameters---
* @type number
* @min 1
* @desc Adjusts the maximum level limit for actors.
* Default: 99
* @default 99
*
* @param Actor MaxHP
* @parent ---Parameters---
* @type number
* @min 1
* @desc Adjusts the maximum HP limit for actors.
* Default: 9999
* @default 9999
*
* @param Actor MaxMP
* @parent ---Parameters---
* @type number
* @min 0
* @desc Adjusts the maximum MP limit for actors.
* Default: 9999
* @default 9999
*
* @param Actor Parameter
* @parent ---Parameters---
* @type number
* @min 1
* @desc Adjusts the maximum parameter limit for actors.
* Default: 999
* @default 999
*
* @param Enemy MaxHP
* @parent ---Parameters---
* @type number
* @min 1
* @desc Adjusts the maximum HP limit for enemies.
* Default: 999999
* @default 999999
*
* @param Enemy MaxMP
* @parent ---Parameters---
* @type number
* @min 0
* @desc Adjusts the maximum MP limit for enemies.
* Default: 9999
* @default 9999
*
* @param Enemy Parameter
* @parent ---Parameters---
* @type number
* @min 1
* @desc Adjusts the maximum parameter limit for enemies.
* Default: 999
* @default 999
*
* @param ---Battle---
* @desc
*
* @param Animation Rate
* @parent ---Battle---
* @type number
* @min 1
* @desc Adjusts the rate of battle animations. Lower for faster.
* Default: 4
* @default 4
*
* @param Flash Target
* @parent ---Battle---
* @type boolean
* @on YES
* @off NO
* @desc If an enemy is targeted, it flashes or it can whiten.
* OFF - false ON - true
* @default false
*
* @param Show Events Transition
* @parent ---Battle---
* @type boolean
* @on Show
* @off Hide
* @desc Show events during the battle transition?
* SHOW - true HIDE - false Default: false
* @default true
*
* @param Show Events Snapshot
* @parent ---Battle---
* @type boolean
* @on Show
* @off Hide
* @desc Show events for the battle background snapshot?
* SHOW - true HIDE - false Default: false
* @default true
*
* @param ---Font---
* @desc
*
* @param Chinese Font
* @parent ---Font---
* @desc Default font(s) used for a Chinese RPG.
* Default: SimHei, Heiti TC, sans-serif
* @default SimHei, Heiti TC, sans-serif
*
* @param Korean Font
* @parent ---Font---
* @desc Default font(s) used for a Korean RPG.
* Default: Dotum, AppleGothic, sans-serif
* @default Dotum, AppleGothic, sans-serif
*
* @param Default Font
* @parent ---Font---
* @desc Default font(s) used for everything else.
* Default: GameFont
* @default GameFont, Verdana, Arial, Courier New
*
* @param Font Size
* @parent ---Font---
* @type number
* @min 1
* @desc Default font size used for windows.
* Default: 28
* @default 28
*
* @param Text Align
* @parent ---Font---
* @type combo
* @option left
* @option center
* @option right
* @desc How to align the text for command windows.
* left center right
* @default left
*
* @param ---Windows---
* @default
*
* @param Digit Grouping
* @parent ---Windows---
* @type boolean
* @on YES
* @off NO
* @desc Groups together digits with a comma.
* false - OFF true - ON
* @default true
*
* @param Line Height
* @parent ---Windows---
* @type number
* @min 0
* @desc Adjusts universal line height used in Windows.
* Default: 36
* @default 36
*
* @param Icon Width
* @parent ---Windows---
* @type number
* @min 0
* @desc Adjusts the width of your icons.
* Default: 32
* @default 32
*
* @param Icon Height
* @parent ---Windows---
* @type number
* @min 0
* @desc Adjusts the height of your icons.
* Default: 32
* @default 32
*
* @param Face Width
* @parent ---Windows---
* @type number
* @min 0
* @desc Adjusts the width of actors' faces.
* Default: 144
* @default 144
*
* @param Face Height
* @parent ---Windows---
* @type number
* @min 0
* @desc Adjusts the height of actors' faces.
* Default: 144
* @default 144
*
* @param Window Padding
* @parent ---Windows---
* @type number
* @min 0
* @desc Adjusts the padding for all standard windows.
* Default: 18
* @default 18
*
* @param Text Padding
* @parent ---Windows---
* @type number
* @min 0
* @desc Adjusts the padding for text inside of windows.
* Default: 6
* @default 6
*
* @param Window Opacity
* @parent ---Windows---
* @type number
* @min 0
* @desc Adjusts the background opacity for windows.
* Default: 192
* @default 192
*
* @param Gauge Outline
* @parent ---Windows---
* @type boolean
* @on YES
* @off NO
* @desc Enable outlines for gauges.
* false - OFF true - ON
* @default true
*
* @param Gauge Height
* @parent ---Windows---
* @type number
* @min 0
* @desc Sets the height for gauges.
* Default: 6
* @default 18
*
* @param Menu TP Bar
* @parent ---Windows---
* @type boolean
* @on YES
* @off NO
* @desc Draws a TP bar in the menu status for actors.
* false - OFF true - ON
* @default true
*
* @param ---Window Colors---
* @default
*
* @param Color: Normal
* @parent ---Window Colors---
* @type number
* @min 0
* @max 31
* @desc Changes the text color for Windows.
* Default: 0
* @default 0
*
* @param Color: System
* @parent ---Window Colors---
* @type number
* @min 0
* @max 31
* @desc Changes the text color for Windows.
* Default: 16
* @default 16
*
* @param Color: Crisis
* @parent ---Window Colors---
* @type number
* @min 0
* @max 31
* @desc Changes the text color for Windows.
* Default: 17
* @default 17
*
* @param Color: Death
* @parent ---Window Colors---
* @type number
* @min 0
* @max 31
* @desc Changes the text color for Windows.
* Default: 18
* @default 18
*
* @param Color: Gauge Back
* @parent ---Window Colors---
* @type number
* @min 0
* @max 31
* @desc Changes the text color for Windows.
* Default: 19
* @default 19
*
* @param Color: HP Gauge 1
* @parent ---Window Colors---
* @type number
* @min 0
* @max 31
* @desc Changes the text color for Windows.
* Default: 20
* @default 20
*
* @param Color: HP Gauge 2
* @parent ---Window Colors---
* @type number
* @min 0
* @max 31
* @desc Changes the text color for Windows.
* Default: 21
* @default 21
*
* @param Color: MP Gauge 1
* @parent ---Window Colors---
* @type number
* @min 0
* @max 31
* @desc Changes the text color for Windows.
* Default: 22
* @default 22
*
* @param Color: MP Gauge 2
* @parent ---Window Colors---
* @type number
* @min 0
* @max 31
* @desc Changes the text color for Windows.
* Default: 23
* @default 23
*
* @param Color: MP Cost
* @parent ---Window Colors---
* @type number
* @min 0
* @max 31
* @desc Changes the text color for Windows.
* Default: 23
* @default 23
*
* @param Color: Power Up
* @parent ---Window Colors---
* @type number
* @min 0
* @max 31
* @desc Changes the text color for Windows.
* Default: 24
* @default 24
*
* @param Color: Power Down
* @parent ---Window Colors---
* @type number
* @min 0
* @max 31
* @desc Changes the text color for Windows.
* Default: 25
* @default 25
*
* @param Color: TP Gauge 1
* @parent ---Window Colors---
* @type number
* @min 0
* @max 31
* @desc Changes the text color for Windows.
* Default: 28
* @default 28
*
* @param Color: TP Gauge 2
* @parent ---Window Colors---
* @type number
* @min 0
* @max 31
* @desc Changes the text color for Windows.
* Default: 29
* @default 29
*
* @param Color: TP Cost Color
* @parent ---Window Colors---
* @type number
* @min 0
* @max 31
* @desc Changes the text color for Windows.
* Default: 29
* @default 29
*
* @help
* ============================================================================
* Introduction and Instructions
* ============================================================================
*
* Yanfly Engine Plugins - Core Engine is made for RPG Maker MV. This plugin
* functions primarily to fix bugs and to allow the user more control over RPG
* Maker MV's various features, such as the screen resolution, font, window
* colors, and more.
*
* Just place this on top of all the other Yanfly Engine Plugins.
* Adjust any parameters as you see fit.
*
* ============================================================================
* Bug Fixes
* ============================================================================
*
* This plugin fixes a few bugs found present within RPG Maker MV. Of them are
* the following:
*
* Animation Overlay
* When a skill/item that targets multiple enemies at once using a fullscreen
* animation, it will overlay multiple times causing the image to look
* distorted by a series of overlayed effects. The plugin fixes this issue by
* having only one animation played over the group instead of every one.
*
* Event Movement Speed
* The movement speed of events are slightly slower than what they should be
* due a small error in the source code. The plugin fixes this issue and they
* move at the properly speed.
*
* Event Movement Queue
* If an event were to move through an event command, changing a condition
* that would set the event to change to a different page would cause that
* event's move route to halt in its tracks. The plugin fixes this issue and
* the event's move route will finish.
*
* Event Colliding
* Events cannot move over other events with a Below Player setting. This
* makes it difficult for certain types of puzzles or events to exist. This
* plugin fixes this issue by making the collision check only apply to events
* of "Same as Characters" priority. Any event that's above or below the
* characters will no longer collide with other events.
*
* Screen Tearing
* When moving slowly, the tiles on the screen tear. While it's not
* noticeable on all systems, slower computers will definitely show it. The
* plugin will fix this issue and synch the tiles to keep up to pace with
* the screen's camera movement properly.
*
* Sprite Distortion
* Because of JavaScript's strange mathematical behavior, sometimes values
* with decimal places cause spritesheets to end up looking distorted. The
* plugin will get rid of the decimal places and have sprite sheets take out
* frames properly by using integer values only.
*
* ============================================================================
* Gold
* ============================================================================
*
* You can use the plugin commands to add or remove gold more than the
* editor's 9,999,999 limit. You can also place notetags into items, weapons,
* and armors to over the 999,999 cost limit.
*
* Plugin Command:
* GainGold 1234567890 # Party gains 1234567890 gold.
* LoseGold 9876543210 # Party loses 9876543210 gold.
*
* Item, Weapon, Armor Notetags
* <Price: x>
* Changes the price of the item to x. This notetag allows you to bypass the
* editor's 999,999 gold cost limit.
*
* Enemy Notetag
* <Gold: x>
* Changes the gold drop value of enemies to x. This notetag allows you to
* bypass the editor's 9,999,999 gold drop limit.
*
* ============================================================================
* Items
* ============================================================================
*
* Change the parameters to reflect the maximum number of items a player can
* hold per item. If you wish to make individual items have different max
* values, use the following notetag:
*
* Item, Weapon, Armor Notetag:
* <Max Item: x>
* This changes the maximum amount of the item to x.
*
* ============================================================================
* Stats
* ============================================================================
*
* Even with the parameter limits raised, the editor is still confined to RPG
* Maker MV's default limits. To break past them, use the following notetags
* to allow further control over the individual aspects for the parameters.
*
* Actor Notetag
* <Initial Level: x>
* Changes the actor's initial level to x. This allows you to bypass the
* editor's level 99 limit.
*
* <Max Level: x>
* Changes the actor's max level to x. This allows you to bypass the editor's
* level 99 limit.
*
* Class Skill Learn Notetag
* <Learn at Level: x>
* When placed inside a class's "Skills to Learn" notetag, this will cause
* the class to learn the skill at level x.
*
* Weapon and Armor Notetags
* <stat: +x>
* <stat: -x>
* Allows the piece of weapon or armor to gain or lose x amount of stat.
* Replace "stat" with "hp", "mp", "atk", "def", "mat", "mdf", "agi", or
* "luk" to alter that specific stat. This allows the piece of equipment
* to go past the editor's default limitation so long as the maximum value
* allows for it.
*
* Enemy Notetags
* <stat: x>
* This changes the enemy's stat to x amount. Replace "stat" with "hp",
* "mp", "atk", "def", "mat", "mdf", "agi", or "luk" to alter that
* specific stat. This allows the piece of equipment to go past the
* editor's default limitation.
*
* <exp: x>
* This changes the enemy's exp given out to x amount. This allows the
* enemy give out more exp than the editor's default 9,999,999 limit.
*
* ============================================================================
* Script Call Fail Safe
* ============================================================================
*
* Irregular code in damage formulas, script calls, conditional branches, and
* variable events will no longer crash the game. Instead, they will force open
* the console window to display the error only during test play.
*
* If the player is not in test play, the game will continue as normal without
* the error being shown. If the game is being played in a browser, opening up
* the console window will still display the error.
*
* ============================================================================
* Changelog
* ============================================================================
*
* Version 1.25:
* - Updated for RPG Maker MV version 1.5.0.
* - Updated Scale Title and Scale GameOver to work with 1.5.0.
*
* Version 1.24:
* - Screen jittering prevention is now prevented for RPG Maker MV 1.3.4 and
* above since Pixi4 handles that now.
*
* Version 1.23:
* - For RPG Maker MV version 1.3.2 and above, the 'Scale Battlebacks' plugin
* parameter will now recreate the battleback sprites in a different format.
* This is because battleback scaling with Tiling Sprites is just too volatile.
* Battleback sprites are now just regular sprites instead of tiling sprites.
* This may or may not cause plugin incompatibilities with other plugins that
* alter battlebacks.
* - For RPG Maker MV version 1.3.4, Game_Actor.meetsUsableItemConditions is
* now updated to return a check back to the original Game_BattlerBase version
* to maintain compatibility with other plugins.
*
* Version 1.22:
* - Added 'Show Events Transition' plugin parameter. Enabling this will make
* events on the map no longer hide themselves while entering battle during the
* transition.
* - Added 'Show Events Snapshot' plugin parameter. Enabling this will keep
* events shown as a part of the battle snapshot when entering battle.
* - Irregular code in damage formulas, script calls, conditional branches, and
* variable events will no longer crash the game. Instead, it will force open
* the console window to display the error only during Test Play.
*
* Version 1.21:
* - Fixed a bug with scaling battlebacks not working properly for Front View.
* - Optimization update to keep garbage collection across all scenes.
*
* Version 1.20:
* - Altered increasing resolution function.
* - Added 'Update Real Scale' plugin parameter. This is best left alone for
* now and to be used if a later update meshes with rendered scaling.
* - Added memory clear functionality for versions under 1.3.2 to free up more
* memory upon leaving the map scene.
* - Added 'Collection Clear' plugin parameter. This option, if left on, will
* clear the attached children to Scene_Map and Scene_Battle upon switching to
* a different scene. This will potentially free up memory from various objects
* added to those scenes from other plugins (depending on how they're added)
* and serve as a means of reducing memory bloat.
*
* Version 1.19:
* - Updated for RPG Maker MV version 1.3.2.
* - Fixed 'LearnSkill' function for actors to not be bypassed if a piece of
* equipment has temporarily added a skill.
*
* Version 1.18:
* - Fixed a bug with scaling battlebacks not working properly for Front View.
*
* Version 1.17:
* - Updated for RPG Maker MV version 1.3.0.
*
* Version 1.16:
* - Fixed a bug with RPG Maker MV's inherent 'drawTextEx' function. By default
* it calculates the text height and then resets the font settings before
* drawing the text, which makes the text height inconsistent if it were to
* match the calculated height settings.
*
* Version 1.15:
* - Window's are now set to have only widths and heights of whole numbers. No
* longer is it possible for them to have decimal values. This is to reduce any
* and all clipping issues caused by non-whole numbers.
*
* Version 1.14:
* - Optimization update for RPG Maker MV itself by replacing more memory
* intensive loops in commonly used functions with more efficient loops.
*
* Version 1.13:
* - Updated for RPG Maker MV version 1.1.0.
*
* Version 1.12:
* - Fixed a bug with a notetag: <Learn at Level: x>. Now, the notetag works
* with both <Learn at Level: x> and <Learn Level: x>
*
* Version 1.11:
* - Made fixes to the MV Source Code where FaceWidth was using a hard-coded
* 144 value regardless of what was changed for the Face Width parameter.
* - Fixed a notetag that wasn't working with the enemy EXP values.
* - Updated battler repositioning to no longer clash when entering-exiting the
* scene with Row Formation.
*
* Version 1.10:
* - Removed an MV bugfix that was applied through MV's newes tupdate.
*
* Version 1.09:
* - Changed minimum display width for status drawing to accomodate Party
* Formation defaults.
*
* Version 1.08:
* - Fixed a bug within the MV Source with changing classes and maintaining
* levels, even though the feature to maintain the levels has been removed.
*
* Version 1.07:
* - Fixed an issue with the gauges drawing outlines thicker than normal at odd
* intervals when windows are scaled irregularly.
*
* Version 1.06:
* - Removed event frequency bug fix since it's now included in the source.
*
* Version 1.05:
* - Added 'Scale Game Over' parameter to plugin settings.
*
* Version 1.04:
* - Reworked math for calculating scaled battleback locations.
* - Fixed a bug where if the party failed to escape from battle, states that
* would be removed by battle still get removed. *Fixed by Emjenoeg*
*
* Version 1.03:
* - Fixed a strange bug that made scaled battlebacks shift after one battle.
*
* Version 1.02:
* - Fixed a bug that made screen fading on mobile devices work incorrectly.
* - Added 'Scale Battlebacks' and 'Scale Title' parameters.
*
* Version 1.01:
* - Fixed a bug that where if button sprites had different anchors, they would
* not be properly clickable. *Fixed by Zalerinian*
*
* Version 1.00:
* - Finished plugin!
*/
//=============================================================================
//=============================================================================
// Parameter Variables
//=============================================================================
Yanfly.Parameters = PluginManager.parameters('YEP_CoreEngine');
Yanfly.Param = Yanfly.Param || {};
Yanfly.Icon = Yanfly.Icon || {};
Yanfly.Param.ScreenWidth = Number(Yanfly.Parameters['Screen Width'] || 816);
Yanfly.Param.ScreenHeight = Number(Yanfly.Parameters['Screen Height'] || 624);
Yanfly.Param.ScaleBattleback = String(Yanfly.Parameters['Scale Battlebacks']);
Yanfly.Param.ScaleBattleback = eval(Yanfly.Param.ScaleBattleback);
Yanfly.Param.ScaleTitle = String(Yanfly.Parameters['Scale Title']);
Yanfly.Param.ScaleGameOver = String(Yanfly.Parameters['Scale Game Over']);
Yanfly.Param.OpenConsole = String(Yanfly.Parameters['Open Console']);
Yanfly.Param.OpenConsole = eval(Yanfly.Param.OpenConsole);
Yanfly.Param.ReposBattlers = String(Yanfly.Parameters['Reposition Battlers']);
Yanfly.Param.ReposBattlers = eval(Yanfly.Param.ReposBattlers);
Yanfly.Param.GameFontTimer = Number(Yanfly.Parameters['GameFont Load Timer']);
Yanfly.Param.UpdateRealScale = String(Yanfly.Parameters['Update Real Scale']);
Yanfly.Param.UpdateRealScale = eval(Yanfly.Param.UpdateRealScale);
Yanfly.Param.CollectionClear = String(Yanfly.Parameters['Collection Clear']);
Yanfly.Param.CollectionClear = eval(Yanfly.Param.CollectionClear);
Yanfly.Param.MaxGold = String(Yanfly.Parameters['Gold Max']);
Yanfly.Param.GoldFontSize = Number(Yanfly.Parameters['Gold Font Size']);
Yanfly.Icon.Gold = Number(Yanfly.Parameters['Gold Icon']);
Yanfly.Param.GoldOverlap = String(Yanfly.Parameters['Gold Overlap']);
Yanfly.Param.MaxItem = Number(Yanfly.Parameters['Default Max']);
Yanfly.Param.ItemQuantitySize = Number(Yanfly.Parameters['Quantity Text Size']);
Yanfly.Param.MaxLevel = Number(Yanfly.Parameters['Max Level']);
Yanfly.Param.EnemyMaxHp = Number(Yanfly.Parameters['Enemy MaxHP']);
Yanfly.Param.EnemyMaxMp = Number(Yanfly.Parameters['Enemy MaxMP']);
Yanfly.Param.EnemyParam = Number(Yanfly.Parameters['Enemy Parameter']);
Yanfly.Param.ActorMaxHp = Number(Yanfly.Parameters['Actor MaxHP']);
Yanfly.Param.ActorMaxMp = Number(Yanfly.Parameters['Actor MaxMP']);
Yanfly.Param.ActorParam = Number(Yanfly.Parameters['Actor Parameter']);
Yanfly.Param.AnimationRate = Number(Yanfly.Parameters['Animation Rate']);
Yanfly.Param.FlashTarget = eval(String(Yanfly.Parameters['Flash Target']));
Yanfly.Param.ShowEvTrans = String(Yanfly.Parameters['Show Events Transition']);
Yanfly.Param.ShowEvTrans = eval(Yanfly.Param.ShowEvTrans);
Yanfly.Param.ShowEvSnap = String(Yanfly.Parameters['Show Events Snapshot']);
Yanfly.Param.ShowEvSnap = eval(Yanfly.Param.ShowEvSnap);
Yanfly.Param.ChineseFont = String(Yanfly.Parameters['Chinese Font']);
Yanfly.Param.KoreanFont = String(Yanfly.Parameters['Korean Font']);
Yanfly.Param.DefaultFont = String(Yanfly.Parameters['Default Font']);
Yanfly.Param.FontSize = Number(Yanfly.Parameters['Font Size']);
Yanfly.Param.TextAlign = String(Yanfly.Parameters['Text Align']);
Yanfly.Param.DigitGroup = String(Yanfly.Parameters['Digit Grouping']);
Yanfly.Param.LineHeight = Number(Yanfly.Parameters['Line Height']);
Yanfly.Param.IconWidth = Number(Yanfly.Parameters['Icon Width'] || 32);;
Yanfly.Param.IconHeight = Number(Yanfly.Parameters['Icon Height'] || 32);;
Yanfly.Param.FaceWidth = Number(Yanfly.Parameters['Face Width'] || 144);
Yanfly.Param.FaceHeight = Number(Yanfly.Parameters['Face Height'] || 144);
Yanfly.Param.WindowPadding = Number(Yanfly.Parameters['Window Padding']);
Yanfly.Param.TextPadding = Number(Yanfly.Parameters['Text Padding']);
Yanfly.Param.WindowOpacity = Number(Yanfly.Parameters['Window Opacity']);
Yanfly.Param.GaugeOutline = String(Yanfly.Parameters['Gauge Outline']);
Yanfly.Param.GaugeHeight = Number(Yanfly.Parameters['Gauge Height']);
Yanfly.Param.MenuTpGauge = String(Yanfly.Parameters['Menu TP Bar']);
Yanfly.Param.ColorNormal = Number(Yanfly.Parameters['Color: Normal']);
Yanfly.Param.ColorSystem = Number(Yanfly.Parameters['Color: System']);
Yanfly.Param.ColorCrisis = Number(Yanfly.Parameters['Color: Crisis']);
Yanfly.Param.ColorDeath = Number(Yanfly.Parameters['Color: Death']);
Yanfly.Param.ColorGaugeBack = Number(Yanfly.Parameters['Color: Gauge Back']);
Yanfly.Param.ColorHpGauge1 = Number(Yanfly.Parameters['Color: HP Gauge 1']);
Yanfly.Param.ColorHpGauge2 = Number(Yanfly.Parameters['Color: HP Gauge 2']);
Yanfly.Param.ColorMpGauge1 = Number(Yanfly.Parameters['Color: MP Gauge 1']);
Yanfly.Param.ColorMpGauge2 = Number(Yanfly.Parameters['Color: MP Gauge 2']);
Yanfly.Param.ColorMpCost = Number(Yanfly.Parameters['Color: MP Cost']);
Yanfly.Param.ColorPowerUp = Number(Yanfly.Parameters['Color: Power Up']);
Yanfly.Param.ColorPowerDown = Number(Yanfly.Parameters['Color: Power Down']);
Yanfly.Param.ColorTpGauge1 = Number(Yanfly.Parameters['Color: TP Gauge 1']);
Yanfly.Param.ColorTpGauge2 = Number(Yanfly.Parameters['Color: TP Gauge 2']);
Yanfly.Param.ColorTpCost = Number(Yanfly.Parameters['Color: TP Cost Color']);
//=============================================================================
// Bitmap
//=============================================================================
Yanfly.Core.Bitmap_initialize = Bitmap.prototype.initialize;
Bitmap.prototype.initialize = function(width, height) {
Yanfly.Core.Bitmap_initialize.call(this, width, height);
this.fontFace = Yanfly.Param.DefaultFont;
};
Yanfly.Core.Bitmap_blt = Bitmap.prototype.blt;
Bitmap.prototype.blt = function(source, sx, sy, sw, sh, dx, dy, dw, dh) {
sx = Math.floor(sx);
sy = Math.floor(sy);
sw = Math.floor(sw);
sh = Math.floor(sh);
dx = Math.floor(dx);
dy = Math.floor(dy);
dw = Math.floor(dw);
dh = Math.floor(dh);
Yanfly.Core.Bitmap_blt.call(this, source, sx, sy, sw, sh, dx, dy, dw, dh);
};
Yanfly.Core.Bitmap_fillRect = Bitmap.prototype.fillRect;
Bitmap.prototype.fillRect = function(x, y, w, h, c) {
x = Math.floor(x);
y = Math.floor(y);
w = Math.floor(w);
h = Math.floor(h);
Yanfly.Core.Bitmap_fillRect.call(this, x, y, w, h, c);
};
Yanfly.Core.Bitmap_gradientFillRect = Bitmap.prototype.gradientFillRect;
Bitmap.prototype.gradientFillRect = function(x, y, w, h, c1, c2, ve) {
Yanfly.Core.Bitmap_gradientFillRect.call(this, x, y, w, h, c1, c2, ve);
};
Yanfly.Core.Bitmap_drawCircle = Bitmap.prototype.drawCircle;
Bitmap.prototype.drawCircle = function(x, y, r, c) {
x = Math.floor(x);
y = Math.floor(y);
Yanfly.Core.Bitmap_drawCircle.call(this, x, y, r, c);
};
Yanfly.Core.Bitmap_drawText = Bitmap.prototype.drawText;
Bitmap.prototype.drawText = function(text, x, y, mW, l, align) {
x = Math.floor(x);
y = Math.floor(y);
mW = Math.floor(mW);
l = Math.floor(l);
Yanfly.Core.Bitmap_drawText.call(this, text, x, y, mW, l, align);
};
//=============================================================================
// Graphics
//=============================================================================
if (Yanfly.Param.UpdateRealScale) {
Graphics._updateRealScale = function() {
if (this._stretchEnabled) {
var h = window.innerWidth / this._width;
var v = window.innerHeight / this._height;
this._realScale = Math.min(h, v);
if (this._realScale >= 3) this._realScale = 3;
else if (this._realScale >= 2) this._realScale = 2;
else if (this._realScale >= 1.5) this._realScale = 1.5;
else if (this._realScale >= 1) this._realScale = 1;
else this._realScale = 0.5;
} else {
this._realScale = this._scale;
}
};
}; // Yanfly.Param.UpdateRealScale
//=============================================================================
// Sprite
//=============================================================================
Yanfly.Core.Sprite_updateTransform = Sprite.prototype.updateTransform;
Sprite.prototype.updateTransform = function() {
Yanfly.Core.Sprite_updateTransform.call(this);
this.worldTransform.tx = Math.floor(this.worldTransform.tx);
this.worldTransform.ty = Math.floor(this.worldTransform.ty);
};
//=============================================================================
// ScreenSprite
//=============================================================================
Yanfly.Core.ScreenSprite_initialize = ScreenSprite.prototype.initialize;
ScreenSprite.prototype.initialize = function() {
Yanfly.Core.ScreenSprite_initialize.call(this);
if (Utils.RPGMAKER_VERSION && Utils.RPGMAKER_VERSION >= '1.3.0') return;
this.scale.x = Graphics.boxWidth * 10;
this.scale.y = Graphics.boxHeight * 10;
this.anchor.x = 0.5;
this.anchor.y = 0.5;
this.x = 0;
this.y = 0;
};
//=============================================================================
// Window
//=============================================================================
Yanfly.Core.Window_refreshAllParts = Window.prototype._refreshAllParts;
Window.prototype._refreshAllParts = function() {
this._roundWhUp();
Yanfly.Core.Window_refreshAllParts.call(this);
};
Window.prototype._roundWhUp = function() {
this._width = Math.ceil(this._width);
this._height = Math.ceil(this._height);
};
//=============================================================================
// DataManager
//=============================================================================
Yanfly.Core.DataManager_isDatabaseLoaded = DataManager.isDatabaseLoaded;
DataManager.isDatabaseLoaded = function() {
if (!Yanfly.Core.DataManager_isDatabaseLoaded.call(this)) return false;
if (!Yanfly._loaded_YEP_CoreEngine) {
this.processCORENotetags1($dataItems);
this.processCORENotetags1($dataWeapons);
this.processCORENotetags1($dataArmors);
this.processCORENotetags2($dataEnemies);
this.processCORENotetags3($dataActors);
this.processCORENotetags4($dataClasses);
Yanfly._loaded_YEP_CoreEngine = true;
}
return true;
};
DataManager.processCORENotetags1 = function(group) {
for (var n = 1; n < group.length; n++) {
var obj = group[n];
var notedata = obj.note.split(/[\r\n]+/);
obj.maxItem = Yanfly.Param.MaxItem;
for (var i = 0; i < notedata.length; i++) {
var line = notedata;
if (line.match(/<(?:PRICE):[ ](\d+)>/i)) {
obj.price = parseInt(RegExp.$1);
} else if (line.match(/<(?:MAX ITEM):[ ](\d+)>/i)) {
obj.maxItem = Math.max(1, parseInt(RegExp.$1));
} else if (line.match(/<(.*):[ ]([\+\-]\d+)>/i)) {
var stat = String(RegExp.$1).toUpperCase();
var value = parseInt(RegExp.$2);
switch (stat) {
case 'HP':
case 'MAXHP':
case 'MAX HP':
obj.params[0] = value;
break;
case 'MP':
case 'MAXMP':
case 'MAX MP':
case 'SP':
case 'MAXSP':
case 'MAX SP':
obj.params[1] = value;
break;
case 'ATK':
case 'STR':
obj.params[2] = value;
break;
case 'DEF':
obj.params[3] = value;
break;
case 'MAT':
case 'INT' || 'SPI':
obj.params[4] = value;
break;
case 'MDF':
case 'RES':
obj.params[5] = value;
break;
case 'AGI':
case 'SPD':
obj.params[6] = value;
break;
case 'LUK':
obj.params[7] = value;
break;
case 'EXP':
case 'XP':
obj.exp = value;
break;
}
}
}
}
};
DataManager.processCORENotetags2 = function(group) {
for (var n = 1; n < group.length; n++) {
var obj = group[n];
var notedata = obj.note.split(/[\r\n]+/);
for (var i = 0; i < notedata.length; i++) {
var line = notedata;
if (line.match(/<(?:GOLD):[ ](\d+)>/i)) {
obj.gold = parseInt(RegExp.$1);
} else if (line.match(/<(.*):[ ](\d+)>/i)) {
var stat = String(RegExp.$1).toUpperCase();
var value = parseInt(RegExp.$2);
switch (stat) {
case 'HP':
case 'MAXHP':
case 'MAX HP':
obj.params[0] = value;
break;
case 'MP':
case 'MAXMP':
case 'MAX MP':
case 'SP':
case 'MAXSP':
case 'MAX SP':
obj.params[1] = value;
break;
case 'ATK':
case 'STR':
obj.params[2] = value;
break;
case 'DEF':
obj.params[3] = value;
break;
case 'MAT':
case 'INT':
case 'SPI':
obj.params[4] = value;
break;
case 'MDF':
case 'RES':
obj.params[5] = value;
break;
case 'AGI':
case 'SPD':
obj.params[6] = value;
break;
case 'LUK':
obj.params[7] = value;
break;
case 'EXP':
case 'XP':
obj.exp = value;
break;
}
}
}
}
};
DataManager.processCORENotetags3 = function(group) {
for (var n = 1; n < group.length; n++) {
var obj = group[n];
var notedata = obj.note.split(/[\r\n]+/);
obj.maxLevel = Yanfly.Param.MaxLevel;
for (var i = 0; i < notedata.length; i++) {
var line = notedata;
if (line.match(/<(?:MAX LEVEL):[ ](\d+)>/i)) {
obj.maxLevel = parseInt(RegExp.$1);
if (obj.maxLevel < 1) obj.maxLevel = 1;
} else if (line.match(/<(?:INITIAL LEVEL):[ ](\d+)>/i)) {
obj.initialLevel = parseInt(RegExp.$1);
if (obj.initialLevel < 1) obj.initialLevel = 1;
}
}
}
};
DataManager.processCORENotetags4 = function(group) {
for (var n = 1; n < group.length; n++) {
var obj = group[n];
var notedata = obj.note.split(/[\r\n]+/);
obj.learnings.forEach(function(learning) {
if (learning.note.match(/<(?:LEARN LEVEL|LEARN AT LEVEL):[ ](\d+)>/i)) {
learning.level = parseInt(RegExp.$1);
if (learning.level < 1) obj.maxLevel = 1;
}
}, this);
}
};
//=============================================================================
// SceneManager
//=============================================================================
SceneManager._screenWidth = Yanfly.Param.ScreenWidth;
SceneManager._screenHeight = Yanfly.Param.ScreenHeight;
SceneManager._boxWidth = Yanfly.Param.ScreenWidth;
SceneManager._boxHeight = Yanfly.Param.ScreenHeight
Yanfly.Core.SceneManager_run = SceneManager.run;
SceneManager.run = function(sceneClass) {
Yanfly.Core.SceneManager_run.call(this, sceneClass);
if (!Utils.isNwjs()) return;
Yanfly.updateResolution();
if (Yanfly.Param.OpenConsole) Yanfly.openConsole();
};
Yanfly.updateResolution = function() {
var resizeWidth = Yanfly.Param.ScreenWidth - window.innerWidth;
var resizeHeight = Yanfly.Param.ScreenHeight - window.innerHeight;
if (!Imported.ScreenResolution) {
window.moveBy(-1 * resizeWidth / 2, -1 * resizeHeight / 2);
window.resizeBy(resizeWidth, resizeHeight);
}
};
Yanfly.openConsole = function() {
if (Utils.isNwjs() && Utils.isOptionValid('test')) {
var _debugWindow = require('nw.gui').Window.get().showDevTools();
_debugWindow.moveTo(0, 0);
window.focus();
}
};
//=============================================================================
// BattleManager
//=============================================================================
Yanfly.Core.BattleManager_displayStartMessages =
BattleManager.displayStartMessages;
BattleManager.displayStartMessages = function() {
Yanfly.Core.BattleManager_displayStartMessages.call(this);
$gameTroop.members().forEach(function(enemy) {
enemy.recoverAll();
});
};
BattleManager.processEscape = function() {
$gameParty.performEscape();
SoundManager.playEscape();
var success = this._preemptive ? true : (Math.random() < this._escapeRatio);
if (success) {
$gameParty.removeBattleStates();
this.displayEscapeSuccessMessage();
this._escaped = true;
this.processAbort();
} else {
this.displayEscapeFailureMessage();
this._escapeRatio += 0.1;
$gameParty.clearActions();
this.startTurn();
}
return success;
};
//=============================================================================
// Game_BattlerBase
//=============================================================================
Game_BattlerBase.prototype.paramMax = function(paramId) {
if (paramId === 0) {
return Yanfly.Param.EnemyMaxHp;
} else if (paramId === 1) {
return Yanfly.Param.EnemyMaxMp;
} else {
return Yanfly.Param.EnemyParam;
}
};
//=============================================================================
// Game_Actor
//=============================================================================
Yanfly.Core.Game_Actor_isMaxLevel = Game_Actor.prototype.isMaxLevel;
Game_Actor.prototype.isMaxLevel = function() {
if (this.maxLevel() === 0) return false;
return Yanfly.Core.Game_Actor_isMaxLevel.call(this);
};
Game_Actor.prototype.paramMax = function(paramId) {
if (paramId === 0) {
return Yanfly.Param.ActorMaxHp;
} else if (paramId === 1) {
return Yanfly.Param.ActorMaxMp;
} else {
return Yanfly.Param.ActorParam;
}
};
Yanfly.Core.Game_Actor_paramBase = Game_Actor.prototype.paramBase;
Game_Actor.prototype.paramBase = function(paramId) {
if (this.level > 99) {
var i = this.currentClass().params[paramId][99];
var j = this.currentClass().params[paramId][98];
i += (i - j) * (this.level - 99);
return i;
}
return Yanfly.Core.Game_Actor_paramBase.call(this, paramId);
};
Game_Actor.prototype.changeClass = function(classId, keepExp) {
if (keepExp) {
this._exp[classId] = this._exp[this._classId];
}
this._classId = classId;
this.changeExp(this._exp[this._classId] || 0, false);
this.refresh();
};
Game_Actor.prototype.learnSkill = function(skillId) {
if (!this._skills.contains(skillId)) {
this._skills.push(skillId);
this._skills.sort(function(a, b) {
return a - b;
});
}
};
if (Utils.RPGMAKER_VERSION && Utils.RPGMAKER_VERSION >= '1.3.4') {
Game_Actor.prototype.meetsUsableItemConditions = function(item) {
if($gameParty.inBattle() && !BattleManager.canEscape() &&
this.testEscape(item)){
return false;
}
return Game_BattlerBase.prototype.meetsUsableItemConditions.call(this, item);
};
}; // Utils.RPGMAKER_VERSION && Utils.RPGMAKER_VERSION >= '1.3.4'
//=============================================================================
// Game_Party
//=============================================================================
Game_Party.prototype.maxGold = function() {
return eval(Yanfly.Param.MaxGold);
};
Game_Party.prototype.maxItems = function(item) {
if (!item) return 1;
return item.maxItem;
};
Game_Party.prototype.onPlayerWalk = function() {
var group = this.members();
var length = group.length;
for (var i = 0; i < length; ++i) {
var actor = group;
if (actor) actor.onPlayerWalk();
}
};
//=============================================================================
// Game_Map
//=============================================================================
Yanfly.isPreventScreenJittering = function() {
if (Utils.RPGMAKER_VERSION && Utils.RPGMAKER_VERSION >= '1.3.4') return false;
return true;
};
if (Yanfly.isPreventScreenJittering()) {
Game_Map.prototype.displayX = function() {
return parseFloat(Math.floor(this._displayX *
this.tileWidth())) / this.tileWidth();
};
Game_Map.prototype.displayY = function() {
return parseFloat(Math.floor(this._displayY *
this.tileHeight())) / this.tileHeight();
};
}; // Yanfly.isPreventScreenJittering
Game_Map.prototype.adjustX = function(x) {
if (this.isLoopHorizontal() && x < this.displayX() -
(this.width() - this.screenTileX()) / 2) {
return x - this.displayX() + $dataMap.width;
} else {
return x - this.displayX();
}
};
Game_Map.prototype.adjustY = function(y) {
if (this.isLoopVertical() && y < this.displayY() -
(this.height() - this.screenTileY()) / 2) {
return y - this.displayY() + $dataMap.height;
} else {
return y - this.displayY();
}
};
Game_Map.prototype.updateEvents = function() {
var group = this.events();
var length = group.length;
for (var i = 0; i < length; ++i) {
var ev = group;
if (ev) ev.update();
}
var group = this._commonEvents;
var length = group.length;
for (var i = 0; i < length; ++i) {
var ev = group;
if (ev) ev.update();
}
};
Game_Map.prototype.updateVehicles = function() {
var group = this._vehicles;
var length = group.length;
for (var i = 0; i < length; ++i) {
var vehicle = group;
if (vehicle) vehicle.update();
}
};
//=============================================================================
// Game_Character
//=============================================================================
Game_Character.prototype.queueMoveRoute = function(moveRoute) {
this._originalMoveRoute = moveRoute;
this._originalMoveRouteIndex = 0;
};
Yanfly.Core.Game_Event_setMoveRoute =
Game_Event.prototype.setMoveRoute;
Game_Character.prototype.setMoveRoute = function(moveRoute) {
if (!this._moveRouteForcing) {
Yanfly.Core.Game_Event_setMoveRoute.call(this, moveRoute);
} else {
this.queueMoveRoute(moveRoute);
}
};
Yanfly.Core.Game_Character_processMoveCommand =
Game_Character.prototype.processMoveCommand;
Game_Character.prototype.processMoveCommand = function(command) {
var gc = Game_Character;
var params = command.parameters;
switch (command.code) {
case gc.ROUTE_SCRIPT:
try {
eval(params[0]);
} catch (e) {
Yanfly.Util.displayError(e, params[0], 'MOVE ROUTE SCRIPT ERROR');
}
return;
break;
}
return Yanfly.Core.Game_Character_processMoveCommand.call(this, command);
};
//=============================================================================
// Game_Event
//=============================================================================
Game_Event.prototype.isCollidedWithEvents = function(x, y) {
var events = $gameMap.eventsXyNt(x, y).filter(function(ev) {
return ev.isNormalPriority();
});
if (events.length <= 0) return false;
return this.isNormalPriority();
};
//=============================================================================
// Game_Screen
//=============================================================================
Game_Screen.prototype.updatePictures = function() {
var group = this._pictures;
var length = group.length;
for (var i = 0; i < length; ++i) {
var picture = group;
if (picture) picture.update();
}
};
//=============================================================================
// Game_Action
//=============================================================================
Yanfly.Core.Game_Action_testItemEffect = Game_Action.prototype.testItemEffect;
Game_Action.prototype.testItemEffect = function(target, effect) {
switch (effect.code) {
case Game_Action.EFFECT_LEARN_SKILL:
return target.isActor() && !target._skills.contains(effect.dataId);
default:
return Yanfly.Core.Game_Action_testItemEffect.call(this, target, effect);
}
};
Game_Action.prototype.evalDamageFormula = function(target) {
var item = this.item();
var a = this.subject();
var b = target;
var v = $gameVariables._data;
var sign = ([3, 4].contains(item.damage.type) ? -1 : 1);
try {
var value = Math.max(eval(item.damage.formula), 0) * sign;
if (isNaN(value)) value = 0;
return value;
} catch (e) {
Yanfly.Util.displayError(e, item.damage.formula, 'DAMAGE FORMULA ERROR');
return 0;
}
};
//=============================================================================
// Game_Interpreter
//=============================================================================
// Conditional Branch
Yanfly.Core.Game_Interpreter_command111 =
Game_Interpreter.prototype.command111;
Game_Interpreter.prototype.command111 = function() {
var result = false;
switch (this._params[0]) {
case 12: // Script
var code = this._params[1];
try {
result = !!eval(code);
} catch (e) {
result = false;
Yanfly.Util.displayError(e, code, 'CONDITIONAL BRANCH SCRIPT ERROR');
}
this._branch[this._indent] = result;
if (this._branch[this._indent] === false) this.skipBranch();
return true
break;
}
return Yanfly.Core.Game_Interpreter_command111.call(this);
};
// Control Variables
Yanfly.Core.Game_Interpreter_command122 =
Game_Interpreter.prototype.command122;
Game_Interpreter.prototype.command122 = function() {
switch (this._params[3]) {
case 4: // Script
var value = 0;
var code = this._params[4];
try {
value = eval(code);
} catch (e) {
Yanfly.Util.displayError(e, code, 'CONTROL VARIABLE SCRIPT ERROR');
}
for (var i = this._params[0]; i <= this._params[1]; i++) {
this.operateVariable(i, this._params[2], value);
}
return true;
break;
}
return Yanfly.Core.Game_Interpreter_command122.call(this);
};
// Script
Game_Interpreter.prototype.command355 = function() {
var script = this.currentCommand().parameters[0] + '\n';
while (this.nextEventCode() === 655) {
this._index++;
script += this.currentCommand().parameters[0] + '\n';
}
try {
eval(script);
} catch (e) {
Yanfly.Util.displayError(e, script, 'SCRIPT CALL ERROR');
}
return true;
};
Yanfly.Core.Game_Interpreter_pluginCommand =
Game_Interpreter.prototype.pluginCommand;
Game_Interpreter.prototype.pluginCommand = function(command, args) {
Yanfly.Core.Game_Interpreter_pluginCommand.call(this, command, args);
if (command === 'GainGold') {
$gameParty.gainGold(parseInt(args[0]));
}
if (command === 'LoseGold') {
$gameParty.loseGold(parseInt(args[0]));
}
};
//=============================================================================
// Scene_Base
//=============================================================================
Scene_Base.prototype.clearChildren = function() {
while (this.children.length > 0) {
this.removeChild(this.children[0]);
}
};
if (Yanfly.Param.CollectionClear) {
Yanfly.Core.Scene_Base_terminate = Scene_Base.prototype.terminate;
Scene_Base.prototype.terminate = function() {
Yanfly.Core.Scene_Base_terminate.call(this);
if (this._bypassFirstClear) return;
this.clearChildren();
};
Yanfly.Core.Scene_Title_terminate = Scene_Title.prototype.terminate;
Scene_Title.prototype.terminate = function() {
this._bypassFirstClear = true;
Yanfly.Core.Scene_Title_terminate.call(this);
this.clearChildren();
};
Yanfly.Core.Scene_Map_terminate = Scene_Map.prototype.terminate;
Scene_Map.prototype.terminate = function() {
this._bypassFirstClear = true;
Yanfly.Core.Scene_Map_terminate.call(this);
this.clearChildren();
};
Yanfly.Core.Scene_Battle_terminate = Scene_Battle.prototype.terminate;
Scene_Battle.prototype.terminate = function() {
this._bypassFirstClear = true;
Yanfly.Core.Scene_Battle_terminate.call(this);
this.clearChildren();
};
Yanfly.Core.Scene_Options_terminate = Scene_Options.prototype.terminate;
Scene_Options.prototype.terminate = function() {
this._bypassFirstClear = true;
Yanfly.Core.Scene_Options_terminate.call(this);
this.clearChildren();
};
Yanfly.Core.Scene_Load_terminate = Scene_Load.prototype.terminate;
Scene_Load.prototype.terminate = function() {
this._bypassFirstClear = true;
Yanfly.Core.Scene_Load_terminate.call(this);
this.clearChildren();
};
Yanfly.Core.Scene_Gameover_terminate = Scene_Gameover.prototype.terminate;
Scene_Gameover.prototype.terminate = function() {
this._bypassFirstClear = true;
Yanfly.Core.Scene_Gameover_terminate.call(this);
this.clearChildren();
};
}; // Yanfly.Param.CollectionClear
//=============================================================================
// Scene_Boot
//=============================================================================
Scene_Boot.prototype.isGameFontLoaded = function() {
if (Graphics.isFontLoaded('GameFont')) {
return true;
} else if (Yanfly.Param.GameFontTimer <= 0) {
return false;
} else {
var elapsed = Date.now() - this._startDate;
if (elapsed >= Yanfly.Param.GameFontTimer) {
throw new Error('Failed to load GameFont');
} else {
return false;
}
}
};
//=============================================================================
// Scene_Title
//=============================================================================
Yanfly.Core.Scene_Title_start = Scene_Title.prototype.start;
Scene_Title.prototype.start = function() {
Yanfly.Core.Scene_Title_start.call(this);
if (eval(Yanfly.Param.ScaleTitle)) this.rescaleTitle();
};
Scene_Title.prototype.rescaleTitle = function() {
this.rescaleTitleSprite(this._backSprite1);
this.rescaleTitleSprite(this._backSprite2);
};
Scene_Title.prototype.rescaleTitleSprite = function(sprite) {
if (sprite.bitmap.width <= 0 || sprite.bitmap <= 0) {
return setTimeout(this.rescaleTitleSprite.bind(this, sprite), 5);
}
var width = Graphics.boxWidth;
var height = Graphics.boxHeight;
var ratioX = width / sprite.bitmap.width;
var ratioY = height / sprite.bitmap.height;
if (ratioX > 1.0) sprite.scale.x = ratioX;
if (ratioY > 1.0) sprite.scale.y = ratioY;
this.centerSprite(sprite);
};
//=============================================================================
// Scene_Map
//=============================================================================
if (Yanfly.Param.ShowEvTrans) {
Scene_Map.prototype.startEncounterEffect = function() {
this._encounterEffectDuration = this.encounterEffectSpeed();
};
}; // Yanfly.Param.ShowEvTrans
Yanfly.Core.Scene_Map_snapForBattleBackground =
Scene_Map.prototype.snapForBattleBackground;
Scene_Map.prototype.snapForBattleBackground = function() {
if (!Yanfly.Param.ShowEvSnap) this._spriteset.hideCharacters();
Yanfly.Core.Scene_Map_snapForBattleBackground.call(this);
if (Yanfly.Param.ShowEvTrans) this._spriteset.showCharacters();
};
//=============================================================================
// Scene_Gameover
//=============================================================================
Yanfly.Core.Scene_Gameover_start = Scene_Gameover.prototype.start;
Scene_Gameover.prototype.start = function() {
Yanfly.Core.Scene_Gameover_start.call(this);
if (eval(Yanfly.Param.ScaleGameOver)) this.rescaleBackground();
};
Scene_Gameover.prototype.rescaleBackground = function() {
this.rescaleImageSprite(this._backSprite);
};
Scene_Gameover.prototype.rescaleImageSprite = function(sprite) {
if (sprite.bitmap.width <= 0 || sprite.bitmap <= 0) {
return setTimeout(this.rescaleImageSprite.bind(this, sprite), 5);
}
var width = Graphics.boxWidth;
var height = Graphics.boxHeight;
var ratioX = width / sprite.bitmap.width;
var ratioY = height / sprite.bitmap.height;
if (ratioX > 1.0) sprite.scale.x = ratioX;
if (ratioY > 1.0) sprite.scale.y = ratioY;
this.centerSprite(sprite);
};
Scene_Gameover.prototype.centerSprite = function(sprite) {
sprite.x = Graphics.width / 2;
sprite.y = Graphics.height / 2;
sprite.anchor.x = 0.5;
sprite.anchor.y = 0.5;
};
//=============================================================================
// Sprite_Animation
//=============================================================================
Sprite_Animation.prototype.setupRate = function() {
this._rate = Yanfly.Param.AnimationRate;
};
//=============================================================================
// Sprite_Battler
//=============================================================================
if (!Yanfly.Param.FlashTarget) {
Yanfly.Core.Sprite_Battler_updateSelectionEffect =
Sprite_Battler.prototype.updateSelectionEffect;
Sprite_Battler.prototype.updateSelectionEffect = function() {
if (this._battler.isActor()) {
Yanfly.Core.Sprite_Battler_updateSelectionEffect.call(this);
} else {
if (this._battler.isSelected()) this.startEffect('whiten');
}
};
}; // Yanfly.Param.FlashTarget
//=============================================================================
// Sprite_Actor
//=============================================================================
if (Yanfly.Param.ReposBattlers) {
Yanfly.Core.Sprite_Actor_setActorHome = Sprite_Actor.prototype.setActorHome;
Sprite_Actor.prototype.setActorHome = function(index) {
Yanfly.Core.Sprite_Actor_setActorHome.call(this, index);
this._homeX += Graphics.boxWidth - 816;
this._homeY += Graphics.boxHeight - 624;
};
};
Sprite_Actor.prototype.retreat = function() {
this.startMove(1200, 0, 120);
};
//=============================================================================
// Sprite_Enemy
//=============================================================================
if (Yanfly.Param.ReposBattlers) {
Yanfly.Core.Sprite_Enemy_setBattler = Sprite_Enemy.prototype.setBattler;
Sprite_Enemy.prototype.setBattler = function(battler) {
Yanfly.Core.Sprite_Enemy_setBattler.call(this, battler);
if (!this._enemy._alteredScreenY) {
this._homeY += Graphics.boxHeight - 624;
this._enemy._screenY = this._homeY;
this._enemy._alteredScreenY = true;
}
if ($gameSystem.isSideView()) return;
if (!this._enemy._alteredScreenX) {
this._homeX += (Graphics.boxWidth - 816) / 2;
this._enemy._screenX = this._homeX;
this._enemy._alteredScreenX = true;
}
};
}; // Yanfly.Param.ReposBattlers
//=============================================================================
// Sprite_StateIcon
//=============================================================================
Sprite_StateIcon._iconWidth = Yanfly.Param.IconWidth;
Sprite_StateIcon._iconHeight = Yanfly.Param.IconHeight;
//=============================================================================
// Sprite_Button
//=============================================================================
Sprite_Button.prototype.isButtonTouched = function() {
var x = this.canvasToLocalX(TouchInput.x) + (this.anchor.x * this.width);
var y = this.canvasToLocalY(TouchInput.y) + (this.anchor.y * this.height);
return x >= 0 && y >= 0 && x < this.width && y < this.height;
};
//=============================================================================
// Sprite_Battleback
//=============================================================================
function Sprite_Battleback() {
this.initialize.apply(this, arguments);
}
Sprite_Battleback.prototype = Object.create(Sprite.prototype);
Sprite_Battleback.prototype.constructor = Sprite_Battleback;
Sprite_Battleback.prototype.initialize = function(bitmapName, type) {
Sprite.prototype.initialize.call(this);
this._bitmapName = bitmapName;
this._battlebackType = type;
this.createBitmap();
};
Sprite_Battleback.prototype.createBitmap = function() {
if (this._bitmapName === '') {
this.bitmap = new Bitmap(Graphics.boxWidth, Graphics.boxHeight);
} else {
if (this._battlebackType === 1) {
this.bitmap = ImageManager.loadBattleback1(this._bitmapName);
} else {
this.bitmap = ImageManager.loadBattleback2(this._bitmapName);
}
this.scaleSprite();
}
};
Sprite_Battleback.prototype.scaleSprite = function() {
if (this.bitmap.width <= 0) return setTimeout(this.scaleSprite.bind(this), 5);
var width = Graphics.boxWidth;
var height = Graphics.boxHeight;
if (this.bitmap.width < width) {
this.scale.x = width / this.bitmap.width;
}
if (this.bitmap.height < height) {
this.scale.y = height / this.bitmap.height;
}
this.anchor.x = 0.5;
this.x = Graphics.boxWidth / 2;
if ($gameSystem.isSideView()) {
this.anchor.y = 1;
this.y = Graphics.boxHeight;
} else {
this.anchor.y = 0.5;
this.y = Graphics.boxHeight / 2;
}
};
//=============================================================================
// Spriteset_Map
//=============================================================================
Spriteset_Map.prototype.hideCharacters = function() {
for (var i = 0; i < this._characterSprites.length; i++) {
var sprite = this._characterSprites;
if (!sprite.isTile()) sprite.hide();
}
};
Spriteset_Map.prototype.showCharacters = function() {
for (var i = 0; i < this._characterSprites.length; i++) {
var sprite = this._characterSprites;
if (!sprite.isTile()) sprite.show();
}
};
//=============================================================================
// Spriteset_Battle
//=============================================================================
if (Yanfly.Param.ScaleBattleback) {
if (Utils.RPGMAKER_VERSION && Utils.RPGMAKER_VERSION >= '1.3.2') {
// Rewriting the battlebacks
Spriteset_Battle.prototype.createBattleback = function() {
this._back1Sprite = new Sprite_Battleback(this.battleback1Name(), 1);
this._back2Sprite = new Sprite_Battleback(this.battleback2Name(), 2);
this._battleField.addChild(this._back1Sprite);
this._battleField.addChild(this._back2Sprite);
};
// No more updateBattleback
Spriteset_Battle.prototype.updateBattleback = function() {
};
} else { // Version 1.3.0 and below
Yanfly.Core.Spriteset_Battle_locateBattleback =
Spriteset_Battle.prototype.locateBattleback;
Spriteset_Battle.prototype.locateBattleback = function() {
var sprite1 = this._back1Sprite;
var sprite2 = this._back2Sprite;
if (sprite1.bitmap.width <= 0) return;
if (sprite2.bitmap.width <= 0) return;
if (this._rescaledBattlebackSprite) return;
this._rescaledBattlebackSprite = true;
Yanfly.Core.Spriteset_Battle_locateBattleback.call(this);
var height = this._battleField.height;
sprite1.origin.y = sprite1.x + sprite1.bitmap.height - height;
sprite2.origin.y = sprite1.y + sprite2.bitmap.height - height;
this.rescaleBattlebacks();
};
Spriteset_Battle.prototype.rescaleBattlebacks = function() {
this.rescaleBattlebackSprite(this._back1Sprite, 'fnord');
this.rescaleBattlebackSprite(this._back2Sprite, 'blah');
};
Spriteset_Battle.prototype.rescaleBattlebackSprite = function(sprite) {
if (sprite.bitmap.width <= 0 || sprite.bitmap <= 0) return;
var width = Graphics.boxWidth;
var height = Graphics.boxHeight;
var ratioX = width / sprite.bitmap.width;
var ratioY = height / sprite.bitmap.height;
if (ratioX > 1.0) {
sprite.scale.x = ratioX;
sprite.anchor.x = 0.5;
sprite.x = width / 2;
}
if (ratioY > 1.0) {
sprite.scale.y = ratioY;
sprite.origin.y = 0;
sprite.y = 0;
}
};
} // Version 1.3.0 and below
} // Yanfly.Param.ScaleBattleback
//=============================================================================
// Window_Base
//=============================================================================
Window_Base._iconWidth = Yanfly.Param.IconWidth;
Window_Base._iconHeight = Yanfly.Param.IconHeight;
Window_Base._faceWidth = Yanfly.Param.FaceWidth;
Window_Base._faceHeight = Yanfly.Param.FaceHeight;
Window_Base.prototype.lineHeight = function() {
return Yanfly.Param.LineHeight;
};
Window_Base.prototype.drawTextEx = function(text, x, y) {
if (text) {
this.resetFontSettings();
var textState = { index: 0, x: x, y: y, left: x };
textState.text = this.convertEscapeCharacters(text);
textState.height = this.calcTextHeight(textState, false);
while (textState.index < textState.text.length) {
this.processCharacter(textState);
}
return textState.x - x;
} else {
return 0;
}
};
Window_Base.prototype.textWidthEx = function(text) {
return this.drawTextEx(text, 0, this.contents.height + this.lineHeight());
};
Window_Base.prototype.standardFontFace = function() {
if ($gameSystem.isChinese()) {
return Yanfly.Param.ChineseFont;
} else if ($gameSystem.isKorean()) {
return Yanfly.Param.KoreanFont;
} else {
return Yanfly.Param.DefaultFont;
}
};
Window_Base.prototype.standardFontSize = function() {
return Yanfly.Param.FontSize;
};
Window_Base.prototype.standardPadding = function() {
return Yanfly.Param.WindowPadding;
};
Window_Base.prototype.textPadding = function() {
return Yanfly.Param.TextPadding;
};
Window_Base.prototype.standardBackOpacity = function() {
return Yanfly.Param.WindowOpacity;
};
Window_Base.prototype.normalColor = function() {
return this.textColor(Yanfly.Param.ColorNormal);
};
Window_Base.prototype.systemColor = function() {
return this.textColor(Yanfly.Param.ColorSystem);
};
Window_Base.prototype.crisisColor = function() {
return this.textColor(Yanfly.Param.ColorCrisis);
};
Window_Base.prototype.deathColor = function() {
return this.textColor(Yanfly.Param.ColorDeath);
};
Window_Base.prototype.gaugeBackColor = function() {
return this.textColor(Yanfly.Param.ColorGaugeBack);
};
Window_Base.prototype.hpGaugeColor1 = function() {
return this.textColor(Yanfly.Param.ColorHpGauge1);
};
Window_Base.prototype.hpGaugeColor2 = function() {
return this.textColor(Yanfly.Param.ColorHpGauge2);
};
Window_Base.prototype.mpGaugeColor1 = function() {
return this.textColor(Yanfly.Param.ColorMpGauge1);
};
Window_Base.prototype.mpGaugeColor2 = function() {
return this.textColor(Yanfly.Param.ColorMpGauge2);
};
Window_Base.prototype.mpCostColor = function() {
return this.textColor(Yanfly.Param.ColorMpCost);
};
Window_Base.prototype.powerUpColor = function() {
return this.textColor(Yanfly.Param.ColorPowerUp);
};
Window_Base.prototype.powerDownColor = function() {
return this.textColor(Yanfly.Param.ColorPowerDown);
};
Window_Base.prototype.tpGaugeColor1 = function() {
return this.textColor(Yanfly.Param.ColorTpGauge1);
};
Window_Base.prototype.tpGaugeColor2 = function() {
return this.textColor(Yanfly.Param.ColorTpGauge2);
};
Window_Base.prototype.tpCostColor = function() {
return this.textColor(Yanfly.Param.ColorTpCost);
};
Window_Base.prototype.drawGauge = function(dx, dy, dw, rate, color1, color2) {
var color3 = this.gaugeBackColor();
var fillW = Math.floor(dw * rate).clamp(0, dw);
var gaugeH = this.gaugeHeight();
var gaugeY = dy + this.lineHeight() - gaugeH - 2;
if (eval(Yanfly.Param.GaugeOutline)) {
color3.paintOpacity = this.translucentOpacity();
this.contents.fillRect(dx, gaugeY - 1, dw, gaugeH, color3);
fillW = Math.max(fillW - 2, 0);
gaugeH -= 2;
dx += 1;
} else {
var fillW = Math.floor(dw * rate);
var gaugeY = dy + this.lineHeight() - gaugeH - 2;
this.contents.fillRect(dx, gaugeY, dw, gaugeH, color3);
}
this.contents.gradientFillRect(dx, gaugeY, fillW, gaugeH, color1, color2);
};
Window_Base.prototype.gaugeHeight = function() {
return Yanfly.Param.GaugeHeight;
};
Window_Base.prototype.drawActorLevel = function(actor, x, y) {
this.changeTextColor(this.systemColor());
var dw1 = this.textWidth(TextManager.levelA);
this.drawText(TextManager.levelA, x, y, dw1);
this.resetTextColor();
var level = Yanfly.Util.toGroup(actor.level);
var dw2 = this.textWidth(Yanfly.Util.toGroup(actor.maxLevel()));
this.drawText(level, x + dw1, y, dw2, 'right');
};
Window_Base.prototype.drawCurrentAndMax = function(current, max, x, y,
width, color1, color2) {
var labelWidth = this.textWidth('HP');
var valueWidth = this.textWidth(Yanfly.Util.toGroup(max));
var slashWidth = this.textWidth('/');
var x1 = x + width - valueWidth;
var x2 = x1 - slashWidth;
var x3 = x2 - valueWidth;
if (x3 >= x + labelWidth) {
this.changeTextColor(color1);
this.drawText(Yanfly.Util.toGroup(current), x3, y, valueWidth,
'right');
this.changeTextColor(color2);
this.drawText('/', x2, y, slashWidth, 'right');
this.drawText(Yanfly.Util.toGroup(max), x1, y, valueWidth, 'right');
} else {
this.changeTextColor(color1);
this.drawText(Yanfly.Util.toGroup(current), x1, y, valueWidth,
'right');
}
};
Window_Base.prototype.drawActorTp = function(actor, x, y, width) {
width = width || 96;
var color1 = this.tpGaugeColor1();
var color2 = this.tpGaugeColor2();
this.drawGauge(x, y, width, actor.tpRate(), color1, color2);
this.changeTextColor(this.systemColor());
this.drawText(TextManager.tpA, x, y, 44);
this.changeTextColor(this.tpColor(actor));
this.drawText(Yanfly.Util.toGroup(actor.tp), x + width - 64, y, 64,
'right');
};
Window_Base.prototype.drawActorSimpleStatus = function(actor, x, y, width) {
var lineHeight = this.lineHeight();
var xpad = Window_Base._faceWidth + (2 * Yanfly.Param.TextPadding);
var x2 = x + xpad;
var width2 = Math.max(180, width - xpad - this.textPadding());
this.drawActorName(actor, x, y);
this.drawActorLevel(actor, x, y + lineHeight * 1);
this.drawActorIcons(actor, x, y + lineHeight * 2);
this.drawActorClass(actor, x2, y, width2);
this.drawActorHp(actor, x2, y + lineHeight * 1, width2);
this.drawActorMp(actor, x2, y + lineHeight * 2, width2);
if (eval(Yanfly.Param.MenuTpGauge)) {
this.drawActorTp(actor, x2, y + lineHeight * 3, width2);
}
};
Window_Base.prototype.drawCurrencyValue = function(value, unit, wx, wy, ww) {
this.resetTextColor();
this.contents.fontSize = Yanfly.Param.GoldFontSize;
if (this.usingGoldIcon(unit)) {
var cx = Window_Base._iconWidth;
} else {
var cx = this.textWidth(unit);
}
var text = Yanfly.Util.toGroup(value);
if (this.textWidth(text) > ww - cx) {
text = Yanfly.Param.GoldOverlap;
}
this.drawText(text, wx, wy, ww - cx - 4, 'right');
if (this.usingGoldIcon(unit)) {
this.drawIcon(Yanfly.Icon.Gold, wx + ww - Window_Base._iconWidth, wy + 2);
} else {
this.changeTextColor(this.systemColor());
this.drawText(unit, wx, wy, ww, 'right');
}
this.resetFontSettings();
};
Window_Base.prototype.usingGoldIcon = function(unit) {
if (unit !== TextManager.currencyUnit) return false;
return Yanfly.Icon.Gold > 0;
};
Window_Base.prototype.drawItemName = function(item, x, y, width) {
width = width || 312;
if (item) {
var iconBoxWidth = this.lineHeight();
var padding = (iconBoxWidth - Window_Base._iconWidth) / 2;
this.resetTextColor();
this.drawIcon(item.iconIndex, x + padding, y + padding);
this.drawText(item.name, x + iconBoxWidth, y, width - iconBoxWidth);
}
};
//=============================================================================
// Window_Command
//=============================================================================
Window_Command.prototype.itemTextAlign = function() {
return Yanfly.Param.TextAlign;
};
//=============================================================================
// Window_MenuStatus
//=============================================================================
Window_MenuStatus.prototype.drawItemImage = function(index) {
var actor = $gameParty.members()[index];
var rect = this.itemRect(index);
this.changePaintOpacity(actor.isBattleMember());
var fw = Window_Base._faceWidth;
this.drawActorFace(actor, rect.x + 1, rect.y + 1, fw, rect.height - 2);
this.changePaintOpacity(true);
};
Window_MenuStatus.prototype.drawItemStatus = function(index) {
var actor = $gameParty.members()[index];
var rect = this.itemRect(index);
var xpad = Yanfly.Param.WindowPadding + Window_Base._faceWidth;
var x = rect.x + xpad;
if (!eval(Yanfly.Param.MenuTpGauge)) {
var y = rect.y + rect.height / 2 - this.lineHeight() * 1.5;
} else {
var y = rect.y;
}
var width = rect.width - x - this.textPadding();
this.drawActorSimpleStatus(actor, x, y, width);
};
//=============================================================================
// Window_ItemList
//=============================================================================
Window_ItemList.prototype.numberWidth = function() {
return this.textWidth('\u00d70,000');
};
Window_ItemList.prototype.drawItemNumber = function(item, x, y, width) {
if (!this.needsNumber()) return;
var numItems = Yanfly.Util.toGroup($gameParty.numItems(item));
this.contents.fontSize = Yanfly.Param.ItemQuantitySize;
this.drawText('\u00d7' + numItems, x, y, width, 'right');
this.resetFontSettings();
};
//=============================================================================
// Window_SkillStatus
//=============================================================================
Window_SkillStatus.prototype.refresh = function() {
this.contents.clear();
if (this._actor) {
var w = this.width - this.padding * 2;
var h = this.height - this.padding * 2;
if (!eval(Yanfly.Param.MenuTpGauge)) {
var y = h / 2 - this.lineHeight() * 1.5;
} else {
var y = 0;
}
var xpad = Yanfly.Param.WindowPadding + Window_Base._faceWidth;
var width = w - xpad - this.textPadding();
this.drawActorFace(this._actor, 0, 0, Window_Base._faceWidth, h);
this.drawActorSimpleStatus(this._actor, xpad, y, width);
}
};
Window_SkillList.prototype.drawSkillCost = function(skill, x, y, width) {
if (this._actor.skillTpCost(skill) > 0) {
this.changeTextColor(this.tpCostColor());
var skillcost = Yanfly.Util.toGroup(this._actor.skillTpCost(skill));
this.drawText(skillcost, x, y, width, 'right');
} else if (this._actor.skillMpCost(skill) > 0) {
this.changeTextColor(this.mpCostColor());
var skillcost = Yanfly.Util.toGroup(this._actor.skillMpCost(skill));
this.drawText(skillcost, x, y, width, 'right');
}
};
//=============================================================================
// Window_EquipStatus
//=============================================================================
Window_EquipStatus.prototype.drawCurrentParam = function(x, y, paramId) {
this.resetTextColor();
var actorparam = Yanfly.Util.toGroup(this._actor.param(paramId));
this.drawText(actorparam, x, y, 48, 'right');
};
Window_EquipStatus.prototype.drawNewParam = function(x, y, paramId) {
var newValue = this._tempActor.param(paramId);
var diffvalue = newValue - this._actor.param(paramId);
var actorparam = Yanfly.Util.toGroup(newValue);
this.changeTextColor(this.paramchangeTextColor(diffvalue));
this.drawText(actorparam, x, y, 48, 'right');
};
//=============================================================================
// Window_SkillType
//=============================================================================
Window_SkillType.prototype.makeCommandList = function() {
if (this._actor) {
var skillTypes = this._actor.addedSkillTypes();
skillTypes.sort(function(a, b){return a-b});
skillTypes.forEach(function(stypeId) {
var name = $dataSystem.skillTypes[stypeId];
this.addCommand(name, 'skill', true, stypeId);
}, this);
}
};
//=============================================================================
// Window_ActorCommand
//=============================================================================
Window_ActorCommand.prototype.addSkillCommands = function() {
var skillTypes = this._actor.addedSkillTypes();
skillTypes.sort(function(a, b){return a-b});
skillTypes.forEach(function(stypeId) {
var name = $dataSystem.skillTypes[stypeId];
this.addCommand(name, 'skill', true, stypeId);
}, this);
};
//=============================================================================
// Window_Status
//=============================================================================
Window_Status.prototype.drawParameters = function(x, y) {
var lineHeight = this.lineHeight();
for (var i = 0; i < 6; i++) {
var paramId = i + 2;
var y2 = y + lineHeight * i;
this.changeTextColor(this.systemColor());
this.drawText(TextManager.param(paramId), x, y2, 160);
this.resetTextColor();
var actorParam = Yanfly.Util.toGroup(this._actor.param(paramId));
var dw = this.textWidth(Yanfly.Util.toGroup(this._actor.paramMax(i + 2)));
this.drawText(actorParam, x + 160, y2, dw, 'right');
}
};
Window_Status.prototype.drawExpInfo = function(x, y) {
var lineHeight = this.lineHeight();
var expTotal = TextManager.expTotal.format(TextManager.exp);
var expNext = TextManager.expNext.format(TextManager.level);
var value1 = this._actor.currentExp();
var value2 = this._actor.nextRequiredExp();
if (this._actor.isMaxLevel()) {
value1 = '-------';
value2 = '-------';
} else {
value1 = Yanfly.Util.toGroup(value1);
value2 = Yanfly.Util.toGroup(value2);
}
this.changeTextColor(this.systemColor());
this.drawText(expTotal, x, y + lineHeight * 0, 270);
this.drawText(expNext, x, y + lineHeight * 2, 270);
this.resetTextColor();
this.drawText(value1, x, y + lineHeight * 1, 270, 'right');
this.drawText(value2, x, y + lineHeight * 3, 270, 'right');
};
//=============================================================================
// Window_ShopBuy
//=============================================================================
Window_ShopBuy.prototype.drawItem = function(index) {
var item = this._data[index];
var rect = this.itemRect(index);
rect.width -= this.textPadding();
this.changePaintOpacity(this.isEnabled(item));
this.drawItemName(item, rect.x, rect.y, rect.width);
this.contents.fontSize = Yanfly.Param.GoldFontSize;
var itemPrice = Yanfly.Util.toGroup(this.price(item));
this.drawText(itemPrice, rect.x, rect.y, rect.width, 'right');
this.changePaintOpacity(true);
this.resetFontSettings();
};
//=============================================================================
// Window_ShopNumber
//=============================================================================
Window_ShopNumber.prototype.drawNumber = function() {
var x = this.cursorX();
var y = this.itemY();
var width = this.cursorWidth() - this.textPadding();
this.resetTextColor();
var itemNumber = Yanfly.Util.toGroup(this._number);
this.drawText(itemNumber, x, y, width, 'right');
};
//=============================================================================
// Window_NameEdit
//=============================================================================
Window_NameEdit.prototype.faceWidth = function() {
return Window_Base._faceWidth;
};
//=============================================================================
// Window_BattleStatus
//=============================================================================
Window_BattleStatus.prototype.gaugeAreaWidth = function() {
return this.width / 2 + this.standardPadding();
};
Window_BattleStatus.prototype.drawBasicArea = function(rect, actor) {
var minIconArea = Window_Base._iconWidth * 2;
var nameLength = this.textWidth('0') * 16 + 6;
var iconWidth = Math.max(rect.width - nameLength, minIconArea);
var nameWidth = rect.width - iconWidth;
this.drawActorName(actor, rect.x + 0, rect.y, nameWidth);
this.drawActorIcons(actor, rect.x + nameWidth, rect.y, iconWidth);
};
Window_BattleStatus.prototype.drawGaugeAreaWithTp = function(rect, actor) {
var totalArea = this.gaugeAreaWidth() - 30;
var hpW = parseInt(totalArea * 108 / 300);
var otW = parseInt(totalArea * 96 / 300);
this.drawActorHp(actor, rect.x + 0, rect.y, hpW);
this.drawActorMp(actor, rect.x + hpW + 15, rect.y, otW);
this.drawActorTp(actor, rect.x + hpW + otW + 30, rect.y, otW);
};
Window_BattleStatus.prototype.drawGaugeAreaWithoutTp = function(rect, actor) {
var totalArea = this.gaugeAreaWidth() - 15;
var hpW = parseInt(totalArea * 201 / 315);
var otW = parseInt(totalArea * 114 / 315);
this.drawActorHp(actor, rect.x + 0, rect.y, hpW);
this.drawActorMp(actor, rect.x + hpW + 15, rect.y, otW);
};
//=============================================================================
// Window_BattleLog
//=============================================================================
Window_BattleLog.prototype.showNormalAnimation = function(targets,
animationId, mirror) {
var animation = $dataAnimations[animationId];
if (animation) {
if (animation.position === 3) {
targets.forEach(function(target) {
target.startAnimation(animationId, mirror, 0);
});
} else {
var delay = this.animationBaseDelay();
var nextDelay = this.animationNextDelay();
targets.forEach(function(target) {
target.startAnimation(animationId, mirror, delay);
delay += nextDelay;
});
}
}
};
//=============================================================================
// New Function
//=============================================================================
Yanfly.Util = Yanfly.Util || {};
Yanfly.Util.toGroup = function(inVal) {
if (typeof inVal !== 'string') { inVal = String(inVal); }
if (!eval(Yanfly.Param.DigitGroup)) return inVal;
return inVal.replace(/(^|[^\w.])(\d{4,})/g, function($0, $1, $2) {
return $1 + $2.replace(/\d(?=(?:\d\d\d)+(?!\d))/g, "$&,");
});
};
Yanfly.Util.displayError = function(e, code, message) {
console.log(message);
console.log(code || 'NON-EXISTENT');
console.error(e);
if (Utils.isNwjs() && Utils.isOptionValid('test')) {
if (!require('nw.gui').Window.get().isDevToolsOpen()) {
require('nw.gui').Window.get().showDevTools();
}
}
};
//=============================================================================
// End of File
//=============================================================================
[/fold]
|
|