今シンボルエンカウント制のゲームを作っているのですが、パーティの平均レベルが一定以上になると敵が
逃げ出すようにしたいです。何か良いプラグインまたはイベントの設定方法はありますでしょうか。
何卒ご教授のほどよろしくお願いします

コード: 全て選択
const variableId = 1;
const levels = $gameParty.members().map(function(member) {
return member.level;
});
const sum = levels.reduce(function(accumulator, currentValue) {
return accumulator + currentValue;
});
const averageLevel = sum / $gameParty.members().length;
$gameVariables.setValue(variableId, averageLevel);
コード: 全て選択
const variableId = 1;