var AGI_BASE_VALUE = 2500; var BattleActor = /** @class */ (function () { function BattleActor(id, actorId, level) { this._recoverHp = 0; this._turn = 0; this._id = id; this._actorId = actorId; this._level = level; } BattleActor.prototype.id = function () { return this._id; }; BattleActor.prototype.actor = function () { return $gameActors.actor(this._actorId); }; BattleActor.prototype.characterName = function () { return this.actor().actor().characterName; }; BattleActor.prototype.characterIndex = function () { return this.actor().actor().characterIndex; }; BattleActor.prototype.level = function () { if (this.isZako()) { //return this.actor().level; return $slg .facilityInfo() .findMaxFacility(FacilityType.combatant) .level(); } return this._level; }; BattleActor.prototype.isZako = function () { return this.actorId() >= 187 && this.actorId() <= 191; }; BattleActor.prototype.name = function () { return this.actor().name(); }; BattleActor.prototype.power = function () { return this.atk() + this.mhp(); }; BattleActor.prototype.kaijinParam = function (index) { var param = KAIJIN_PARAMS[this._actorId]; return param[index]; }; BattleActor.prototype.mhp = function () { return this.mhpBase() + this.mhpPlus(); }; BattleActor.prototype.mhpBase = function () { return Math.round(this.kaijinParam(2) * this.levelRate()) + this.mhpBonus(); }; BattleActor.prototype.mhpBonus = function () { switch (this.element()) { case MonsterElement.flame: return ( $gameParty.friendshipBonus(FriendshipBonusType.hpFlame) * $gameParty.friendshipBonusRate(FriendshipBonusType.hpFlame) ); case MonsterElement.water: return ( $gameParty.friendshipBonus(FriendshipBonusType.hpWater) * $gameParty.friendshipBonusRate(FriendshipBonusType.hpWater) ); case MonsterElement.wood: return ( $gameParty.friendshipBonus(FriendshipBonusType.hpWood) * $gameParty.friendshipBonusRate(FriendshipBonusType.hpWood) ); } return 0; }; BattleActor.prototype.mhpPlus = function () { if (!this._passiveSkills) { return 0; } return this._passiveSkills.mhpPlus(this); }; BattleActor.prototype.atk = function () { return this.atkBase() + this.atkPlus() + this.deathAtk(); }; BattleActor.prototype.atkBonus = function () { switch (this.element()) { case MonsterElement.flame: return $gameParty.friendshipBonus(FriendshipBonusType.atkFlame); case MonsterElement.water: return $gameParty.friendshipBonus(FriendshipBonusType.atkWater); case MonsterElement.wood: return $gameParty.friendshipBonus(FriendshipBonusType.atkWood); } return 0; }; BattleActor.prototype.deathAtk = function () { if (!this._passiveSkills) { return 0; } return this._passiveSkills.deathAtk(this, this.atkBase()); }; BattleActor.prototype.atkBase = function () { return Math.round(this.kaijinParam(3) * this.levelRate()) + this.atkBonus(); }; BattleActor.prototype.atkPlus = function () { if (!this._passiveSkills) { return 0; } return this._passiveSkills.atkPlus(this); }; BattleActor.prototype.actorId = function () { return this._actorId; }; BattleActor.prototype.agi = function () { return this.agiBase() - this.agiPlus(); }; BattleActor.prototype.agiBase = function () { return this.kaijinParam(4); }; BattleActor.prototype.agiPlus = function () { if (!this._passiveSkills) { return 0; } return this._passiveSkills.agiPlus(this); }; BattleActor.prototype.agiText = function () { return Math.floor(AGI_BASE_VALUE / this.agi()); }; BattleActor.prototype.agiPlusText = function () { return this.agiText() - Math.floor(AGI_BASE_VALUE / this.agiBase()); }; BattleActor.prototype.levelUpCost = function () { var key = this.rare() + "_" + this.level(); var cost = KAIJIN_LVUP_COSTS[key]; return cost || 0; }; BattleActor.prototype.levelUp = function () { if (this._level == this.maxLevel()) { return; } this._level++; }; BattleActor.prototype.maxLevel = function () { return 5; }; BattleActor.prototype.levelRate = function () { var rate = 5; if (this.isZako()) { rate = 30; } return (100 + (this.level() - 1) * rate) / 100; }; BattleActor.prototype.isCombatant = function () { if (this._actorId >= 187) { if (this._actorId <= 192) { return true; } } return false; }; BattleActor.prototype.updateWait = function () { if (this.isDead()) { return; } if (this._wait > 0) { this._wait--; if (this._wait == 0) { return true; } } else { this._maxWait = this.waitTime(); if (this.isInvokeDoubleAttack()) { this._maxWait = 12; } this.invokeTurnSkill(); this._wait = this._maxWait; } return false; }; BattleActor.prototype.invokeTurnSkill = function () { this.invokeRecoverHp(); this.invokeRecoverHpAll(); }; BattleActor.prototype.invokeRecoverHpAll = function () { var skill = this.getSkill(SkillType.recoverHpAll); if (!skill) { return false; } var value = parseInt(skill.meta[SkillType.recoverHpAll]); for ( var _i = 0, _a = $slg.formation().aliveTargets(); _i < _a.length; _i++ ) { var b = _a[_i]; b.recoverHp(value); } }; BattleActor.prototype.invokeRecoverHp = function () { var skill = this.getSkill(SkillType.recoverHp); if (!skill) { return false; } var value = parseInt(skill.meta[SkillType.recoverHp]); this.recoverHp(value); }; BattleActor.prototype.isInvokeDoubleAttack = function () { var skill = this.getSkill(SkillType.doubleAttack); if (!skill) { return false; } return this.checkInvokeSkill(skill); }; BattleActor.prototype.getSkill = function (skillType) { for (var _i = 0, _a = this.skills(); _i < _a.length; _i++) { var skill = _a[_i]; if (skill.meta[skillType]) { return skill; } } return null; }; BattleActor.prototype.wait = function () { return this._wait; }; BattleActor.prototype.maxWait = function () { return this._maxWait; }; BattleActor.prototype.waitTime = function () { return (this.agi() + Math.randomInt(10)) * this.waitTimeRate(); }; BattleActor.prototype.waitTimeRate = function () { return $slg.clicker().waitTimeRate(); }; BattleActor.prototype.recoverAll = function () { this._hp = this.mhp(); this._recoverHp = 0; this._turn = 1; this._maxWait = this.waitTime(); this._wait = this._maxWait - this.agi() * 2; }; BattleActor.prototype.hp = function () { return this._hp; }; BattleActor.prototype.damage = function (n) { if (this._hp <= 0) { return; } this._hp -= n; if (this._hp < 0) { this._hp = 0; this.invokeDeathSkill(); } }; BattleActor.prototype.invokeDeathSkill = function () { var skill = this.getSkill(SkillType.deathRecover); if (skill) { var value = parseInt(skill.meta[SkillType.deathRecover]); for ( var _i = 0, _a = $slg.formation().aliveTargets(); _i < _a.length; _i++ ) { var t = _a[_i]; t.recoverHp(value); } } }; BattleActor.prototype.recoverHp = function (n) { if (this._hp <= 0) { return; } this._hp += n; this._recoverHp += n; if (this._hp > this.mhp()) { this._hp = this.mhp(); } }; BattleActor.prototype.isDead = function () { return this._hp <= 0; }; BattleActor.prototype.rare = function () { return this.kaijinParam(0); }; BattleActor.prototype.element = function () { return this.kaijinParam(1); }; BattleActor.prototype.isWeak = function (element) { switch (this.element()) { case MonsterElement.flame: return element == MonsterElement.water; case MonsterElement.water: return element == MonsterElement.wood; case MonsterElement.wood: return element == MonsterElement.flame; } return false; }; BattleActor.prototype.learnings = function () { var c = this.actor().currentClass(); return c.learnings; }; BattleActor.prototype.increaseTurn = function () { this._turn++; }; BattleActor.prototype.skills = function () { var result = []; var c = this.actor().currentClass(); for (var _i = 0, _a = c.learnings; _i < _a.length; _i++) { var l = _a[_i]; if (l.level <= this.level()) { result.push($dataSkills[l.skillId]); } } return result; }; BattleActor.prototype.attackSkill = function () { var skill = this.checkTurnSkill(); if (skill) { return skill; } skill = this.checkRandomSkill(); if (skill) { return skill; } return $dataSkills[1]; }; BattleActor.prototype.checkTurnSkill = function () { for (var _i = 0, _a = this.skills(); _i < _a.length; _i++) { var skill = _a[_i]; if (skill.stypeId == 1) { var turn = skill.meta["turn"]; if (turn) { if (parseInt(turn) == this._turn) { return skill; } } var turnInterval = skill.meta["turnInterval"]; if (turnInterval) { if (this._turn % parseInt(turnInterval) == 0) { return skill; } } } } return null; }; BattleActor.prototype.checkRandomSkill = function () { for (var _i = 0, _a = this.skills(); _i < _a.length; _i++) { var skill = _a[_i]; if (skill.stypeId == 1) { if (this.checkInvokeSkill(skill)) { return skill; } } } return null; }; BattleActor.prototype.checkInvokeSkill = function (skill) { if (skill.meta["turn"]) { return false; } if (skill.meta["turnInterval"]) { return false; } return Math.randomInt(100) <= this.skillRate(skill); }; BattleActor.prototype.createPassiveSkillList = function (battleMembers) { var list = this.passiveSkills(); if (list.length == 0) { return []; } var result = []; for (var _i = 0, list_1 = list; _i < list_1.length; _i++) { var skill = list_1[_i]; var passiveSkills = new PassiveMaker().make(this, skill, battleMembers); for ( var _a = 0, passiveSkills_1 = passiveSkills; _a < passiveSkills_1.length; _a++ ) { var passiveSkill = passiveSkills_1[_a]; result.push(passiveSkill); } } return result; }; BattleActor.prototype.passiveSkills = function () { var result = []; for (var _i = 0, _a = this.skills(); _i < _a.length; _i++) { var skill = _a[_i]; if (skill.stypeId == 2) { result.push(skill); } } return result; }; BattleActor.prototype.setPassiveSkills = function (passiveSkills) { this._passiveSkills = passiveSkills; }; BattleActor.prototype.skillRate = function (skill) { return skill.successRate + this.skillRatePlus(); }; BattleActor.prototype.skillRatePlus = function () { if (!this._passiveSkills) { return 0; } return this._passiveSkills.skillRatePlus(this); }; BattleActor.prototype.isMaxLevel = function () { if (this.isZako()) { return true; } return this._level >= this.maxLevel(); }; BattleActor.prototype.getRecoverHp = function () { return this._recoverHp; }; BattleActor.prototype.clearRecoverHp = function () { this._recoverHp = 0; }; BattleActor.prototype.addDebuff = function (skill) { if (skill.meta["damageDebuff"]) { this._damageDebuff = true; } }; BattleActor.prototype.onAfterAttack = function () { this._damageDebuff = false; }; BattleActor.prototype.damageRate = function () { if (this._damageDebuff) { return 0.5; } return 1; }; BattleActor.prototype.onLeaderSkill = function (waitPlus) { this._wait = 1 + waitPlus * 4; }; return BattleActor; })();