private bool EvalTrigger(SodaScriptTrigger inTrigger, SkillCommand inCommandToPopulate) { //is this a trigger with a percentage chance? if so start with that since it can save us processing time if (inTrigger.percentageChance < 100) { if (!Utils.PercentageChance(inTrigger.percentageChance)) { return(false); } } potentialTargets.Clear(); culledTargets.Clear(); CharacterData curTarget = null; if (inTrigger.target == SodaScriptTarget.SELF) { potentialTargets.Add(activeCharacter); } else if (inTrigger.target == SodaScriptTarget.ALLY) { for (int i = 0; i < ownTeam.members.Count; i++) { curTarget = ownTeam.members[i]; if (!curTarget.dead && curTarget != activeCharacter) { potentialTargets.Add(curTarget); } } } else if (inTrigger.target == SodaScriptTarget.ENEMY) { for (int i = 0; i < opposingTeam.members.Count; i++) { curTarget = opposingTeam.members[i]; if (!curTarget.dead) { potentialTargets.Add(curTarget); } } } //we might not even have a list of *potential* targets! (this would happen in a case when we try target an ally but we're the only member on the team) if (potentialTargets.Count == 0) { return(false); } //eval the condition on our list if (inTrigger.condition == SodaScriptCondition.ANY) { curTarget = potentialTargets.GetRandomElement(); potentialTargets.Clear(); potentialTargets.Add(curTarget); } else { //default to a normal eval EvalCondition(inTrigger.condition, inTrigger.comparison, inTrigger.compareValue, potentialTargets); } //exit if no potentials found yet if (potentialTargets.Count == 0) { return(false); } //do we have to check a secondary condition? if (inTrigger.hasSecondaryCondition) { EvalCondition(inTrigger.secondaryCondition, inTrigger.secondaryComparison, inTrigger.secondaryCompareValue, potentialTargets); } //did we find a valid target? if not, return false if (potentialTargets.Count == 0) { return(false); } //fix some issues when targetting self and requesting certain skill categories, turn into strongest *self* heal (avoids issues with first aid) if (inTrigger.target == SodaScriptTarget.SELF) { if (inTrigger.skillCategory == SodaScriptSkillCategory.STRONGEST_HEAL) { inTrigger.skillCategory = SodaScriptSkillCategory.STRONGEST_SELF_HEAL; } if (inTrigger.skillCategory == SodaScriptSkillCategory.ANY_BUFF) { inTrigger.skillCategory = SodaScriptSkillCategory.ANY_SELF_BUFF; } } //is the skill also valid? if not, return false if (inTrigger.skillCategory == SodaScriptSkillCategory.DEFAULT) { potentialSkill = activeCharacter.GetDefaultSkill(); } else if (inTrigger.skillCategory == SodaScriptSkillCategory.SPECIFIC) { potentialSkill = Skill.GetSkill(inTrigger.skillId); } else if (inTrigger.skillCategory == SodaScriptSkillCategory.ANY_NON_FRIENDLY_THAT_CONSUMES_MP) { potentialSkill = activeCharacter.GetAnyNonFriendlySkillThatUsesMP(); } else if (inTrigger.skillCategory == SodaScriptSkillCategory.ANY_NON_FRIENDLY_THAT_DOESNT_CONSUME_MP) { potentialSkill = activeCharacter.GetAnyNonFriendlySkillThatDoesntUseMP(); } else if (inTrigger.skillCategory == SodaScriptSkillCategory.ANY) { potentialSkill = activeCharacter.GetRandomUsableSkill(); } else if (inTrigger.skillCategory == SodaScriptSkillCategory.STRONGEST_SELF_HEAL) { potentialSkill = activeCharacter.GetStrongestUsableHealSkill(false, true); } else if (inTrigger.skillCategory == SodaScriptSkillCategory.STRONGEST_HEAL) { potentialSkill = activeCharacter.GetStrongestUsableHealSkill(false, false); } else if (inTrigger.skillCategory == SodaScriptSkillCategory.STRONGEST_GROUP_HEAL) { potentialSkill = activeCharacter.GetStrongestUsableHealSkill(true, false); } else if (inTrigger.skillCategory == SodaScriptSkillCategory.STRONGEST_ATTACK) { potentialSkill = activeCharacter.GetStrongestUsableDamageSkill(false); } else if (inTrigger.skillCategory == SodaScriptSkillCategory.STRONGEST_GROUP_ATTACK) { potentialSkill = activeCharacter.GetStrongestUsableDamageSkill(true); } else if (inTrigger.skillCategory == SodaScriptSkillCategory.STRONGEST_SINGLE_TARGET_ATTACK) { potentialSkill = activeCharacter.GetStrongestUsableDamageSkill(false, true); } else if (inTrigger.skillCategory == SodaScriptSkillCategory.ANY_BUFF) { potentialSkill = activeCharacter.GetAnySkillThatBuffs(); } else if (inTrigger.skillCategory == SodaScriptSkillCategory.ANY_SELF_BUFF) { potentialSkill = activeCharacter.GetAnySkillThatSelfBuffs(); } else if (inTrigger.skillCategory == SodaScriptSkillCategory.ANY_DEBUFF) { potentialSkill = activeCharacter.GetAnySkillThatDebuffs(); } else { throw new Exception("Skill category " + inTrigger.skillCategory + " is not supported"); } if (potentialSkill == null) { return(false); } if (!activeCharacter.CanUseSkill(potentialSkill.id)) { return(false); } //make sure we're not using a friendly skill on an enemy (unless it is DEFEND) if (inTrigger.target == SodaScriptTarget.ENEMY && potentialSkill.isFriendly && potentialSkill.id != SkillId.DEFEND) { return(false); } //make sure we're not using a damage skill on self or ally if ((inTrigger.target == SodaScriptTarget.ALLY || inTrigger.target == SodaScriptTarget.SELF) && !potentialSkill.isFriendly) { return(false); } //make sure if targeting self, chosen skill is allowed to self target if (inTrigger.target == SodaScriptTarget.SELF && !potentialSkill.allowsSelfTarget) { return(false); } //make sure not stealing from someone who has already been stolen from if ((potentialSkill.id == SkillId.PILFER || potentialSkill.id == SkillId.RANSACK) && potentialTargets[0].hasBeenStolenFrom) { return(false); } //don't try to transmute a target after we've already hit the limit of 1 successful transmute per battle (or if not a common enemy) if (potentialSkill.id == SkillId.TRANSMUTE) { bool battleIsBossOrMiniboss = (adventure.battleNumBasedOn10 == 5 || adventure.battleNumBasedOn10 == 10); if (adventure.battleManager.CurBattleTransmuteLimitReached() || battleIsBossOrMiniboss) { return(false); } } else if (potentialSkill.id == SkillId.FORETELL) { //don't try to foretell if the "force warp" flag is active for the current adventure if (adventure.forceWarpAtNextPaths) { return(false); } } //make sure an arena npc isn't using a banned skill if (activeCharacter.isArenaNpc && !potentialSkill.allowedForArenaNpcs) { return(false); } //make sure this team hasn't tried to heal itself too many times in a row if (potentialSkill.isHealing && ownTeam.HasReachedConsecutiveHealLimit()) { return(false); } //if we found a valid target and skill, populate the commmand and return true inCommandToPopulate.Reset(potentialSkill, activeCharacter); inCommandToPopulate.AddTarget(potentialTargets[0]); return(true); }