protected virtual bool ChooseTargets(List <FormationUnit> availableTargets, MonsterBrainDecision decision) { if (availableTargets.Count > 0) { decision.TargetInfo.Targets.Clear(); if (decision.SelectedSkill.TargetRanks.IsMultitarget) { decision.TargetInfo.Targets.AddRange(availableTargets); return(true); } else { int index = Random.Range(0, availableTargets.Count); decision.TargetInfo.Targets.Add(availableTargets[index]); availableTargets.RemoveAt(index); if (decision.SelectedSkill.ExtraTargetsChance > 0 && availableTargets.Count > 0 && RandomSolver.CheckSuccess(decision.SelectedSkill.ExtraTargetsChance)) { int sideTargetIndex = Random.Range(0, availableTargets.Count); decision.TargetInfo.Targets.Add(availableTargets[sideTargetIndex]); return(true); } return(true); } } return(false); }
public override bool SelectTarget(FormationUnit performer, MonsterBrainDecision decision) { if (decision.TargetInfo.Targets.All(target => !target.Character.GetStatusEffect(StatusType.Marked).IsApplied)) { return(false); } return(base.SelectTarget(performer, decision)); }
public override bool SelectTarget(FormationUnit performer, MonsterBrainDecision decision) { if (decision.SelectedSkill.Effects.All(effect => !effect.SubEffects.Any(subeffect => subeffect is CaptureEffect))) { return(false); } return(base.SelectTarget(performer, decision)); }
protected override bool ChooseTargets(List <FormationUnit> availableTargets, MonsterBrainDecision decision) { if (availableTargets.Count > 0) { decision.TargetInfo.Targets.Clear(); if (decision.SelectedSkill.TargetRanks.IsMultitarget) { decision.TargetInfo.Targets.AddRange(availableTargets); return(true); } else { float lowestRes = float.MaxValue; FormationUnit lowestResTarget = null; foreach (var target in availableTargets) { if (target.Character[ResistanceType].ModifiedValue < lowestRes) { lowestRes = target.Character[ResistanceType].ModifiedValue; lowestResTarget = target; } } decision.TargetInfo.Targets.Add(lowestResTarget); availableTargets.Remove(lowestResTarget); if (decision.SelectedSkill.ExtraTargetsChance > 0 && availableTargets.Count > 0 && RandomSolver.CheckSuccess(decision.SelectedSkill.ExtraTargetsChance)) { lowestRes = 500f; lowestResTarget = null; foreach (var target in availableTargets) { if (target.Character[ResistanceType].ModifiedValue < lowestRes) { lowestRes = target.Character[ResistanceType].ModifiedValue; lowestResTarget = target; } } if (lowestResTarget != null) { decision.TargetInfo.Targets.Add(lowestResTarget); } return(true); } return(true); } } return(false); }
public virtual bool SelectTarget(FormationUnit performer, MonsterBrainDecision decision) { if (!(SpecificCombatSkillId == "" || SpecificCombatSkillId == decision.SelectedSkill.Id)) { return(false); } if (decision.SelectedSkill.TargetRanks.IsSelfFormation && !IsFriendlyTargetDesire) { return(false); } if (!(decision.SelectedSkill.TargetRanks.IsSelfFormation || decision.SelectedSkill.TargetRanks.IsSelfTarget) && !IsEnemyTargetDesire) { return(false); } return(ChooseTargets(FilterTargets(performer, decision.TargetInfo.Targets), decision)); }
public bool SelectSkill(FormationUnit performer, MonsterBrainDecision decision) { if (IsRestricted(performer)) { return(false); } var monster = (Monster)performer.Character; var availableSkills = monster.Data.CombatSkills.FindAll(skill => IsValidSkill(performer, skill)); if (availableSkills.Count > 0) { decision.Decision = BrainDecisionType.Perform; decision.SelectedSkill = availableSkills[RandomSolver.Next(availableSkills.Count)]; decision.TargetInfo.Targets = BattleSolver.GetSkillAvailableTargets(performer, decision.SelectedSkill); decision.TargetInfo.Targets.RemoveAll(target => !IsValidTarget(target)); decision.TargetInfo.Type = decision.SelectedSkill.TargetRanks.SkillTargetType; if (decision.TargetInfo.Targets.Count == 0) { return(false); } var availableTargetDesires = monster.Brain.TargetDesireSet.FindAll(IsValidTargetDesire); while (availableTargetDesires.Count > 0) { TargetSelectionDesire desire = RandomSolver.ChooseByRandom(availableTargetDesires); if (desire.SelectTarget(performer, decision)) { return(true); } availableTargetDesires.Remove(desire); } return(false); } return(false); }
public static MonsterBrainDecision UseMonsterBrain(FormationUnit performer, string combatSkillOverride = null) { if (performer.Character.IsMonster) { var monster = performer.Character as Monster; if (string.IsNullOrEmpty(combatSkillOverride)) { var skillDesires = new List <SkillSelectionDesire>(monster.Brain.SkillDesireSet); var monsterBrainDecision = new MonsterBrainDecision(BrainDecisionType.Pass); while (skillDesires.Count != 0) { SkillSelectionDesire desire = RandomSolver.ChooseByRandom(skillDesires); if (desire != null && desire.SelectSkill(performer, monsterBrainDecision)) { var cooldown = monster.Brain.SkillCooldowns.Find(cd => cd.SkillId == monsterBrainDecision.SelectedSkill.Id); if (cooldown != null) { performer.CombatInfo.SkillCooldowns.Add(cooldown.Copy()); } RaidSceneManager.BattleGround.LastSkillUsed = monsterBrainDecision.SelectedSkill.Id; return(monsterBrainDecision); } else { skillDesires.Remove(desire); } } return(new MonsterBrainDecision(BrainDecisionType.Pass)); } else { var availableSkill = monster.Data.CombatSkills.Find(skill => skill.Id == combatSkillOverride); if (availableSkill != null && IsSkillUsable(performer, availableSkill)) { var monsterBrainDecision = new MonsterBrainDecision(BrainDecisionType.Pass); monsterBrainDecision.Decision = BrainDecisionType.Perform; monsterBrainDecision.SelectedSkill = availableSkill; monsterBrainDecision.TargetInfo.Targets = GetSkillAvailableTargets(performer, monsterBrainDecision.SelectedSkill); monsterBrainDecision.TargetInfo.Type = monsterBrainDecision.SelectedSkill.TargetRanks.IsSelfTarget ? SkillTargetType.Self : monsterBrainDecision.SelectedSkill.TargetRanks.IsSelfFormation ? SkillTargetType.Party : SkillTargetType.Enemy; var availableTargetDesires = new List <TargetSelectionDesire>(monster.Brain.TargetDesireSet); while (availableTargetDesires.Count > 0) { TargetSelectionDesire desire = RandomSolver.ChooseByRandom(availableTargetDesires); if (desire.SelectTarget(performer, monsterBrainDecision)) { return(monsterBrainDecision); } else { availableTargetDesires.Remove(desire); } } return(new MonsterBrainDecision(BrainDecisionType.Pass)); } return(new MonsterBrainDecision(BrainDecisionType.Pass)); } } else { var hero = performer.Character as Hero; var availableSkills = hero.Mode == null ? new List <CombatSkill>(hero.CurrentCombatSkills).FindAll(skill => skill != null && IsSkillUsable(performer, skill)) : new List <CombatSkill>(hero.CurrentCombatSkills).FindAll(skill => skill.ValidModes.Contains(hero.CurrentMode.Id) && IsSkillUsable(performer, skill)); if (availableSkills.Count != 0) { var monsterBrainDecision = new MonsterBrainDecision(BrainDecisionType.Pass); monsterBrainDecision.Decision = BrainDecisionType.Perform; monsterBrainDecision.SelectedSkill = availableSkills[RandomSolver.Next(availableSkills.Count)]; monsterBrainDecision.TargetInfo.Targets = GetSkillAvailableTargets(performer, monsterBrainDecision.SelectedSkill); monsterBrainDecision.TargetInfo.Type = monsterBrainDecision.SelectedSkill.TargetRanks.IsSelfTarget ? SkillTargetType.Self : monsterBrainDecision.SelectedSkill.TargetRanks.IsSelfFormation ? SkillTargetType.Party : SkillTargetType.Enemy; var availableTargets = new List <FormationUnit>(monsterBrainDecision.TargetInfo.Targets); if (availableTargets.Count > 0) { monsterBrainDecision.TargetInfo.Targets.Clear(); if (monsterBrainDecision.SelectedSkill.TargetRanks.IsMultitarget) { monsterBrainDecision.TargetInfo.Targets.AddRange(availableTargets); return(monsterBrainDecision); } else { int index = RandomSolver.Next(availableTargets.Count); monsterBrainDecision.TargetInfo.Targets.Add(availableTargets[index]); availableTargets.RemoveAt(index); return(monsterBrainDecision); } } return(new MonsterBrainDecision(BrainDecisionType.Pass)); } return(new MonsterBrainDecision(BrainDecisionType.Pass)); } }
public override bool SelectTarget(FormationUnit performer, MonsterBrainDecision decision) { if (!(SpecificCombatSkillId == "" || SpecificCombatSkillId == decision.SelectedSkill.Id)) { return(false); } if (decision.SelectedSkill.TargetRanks.IsSelfFormation && !IsFriendlyTargetDesire) { return(false); } if (!(decision.SelectedSkill.TargetRanks.IsSelfFormation || decision.SelectedSkill.TargetRanks.IsSelfTarget) && !IsEnemyTargetDesire) { return(false); } var availableTargets = new List <FormationUnit>(decision.TargetInfo.Targets). FindAll(target => target.Character.Class == AllyBaseClass); if (Parameters[TargetSelectParameter.CanTargetDeathsDoor].HasValue) { if (!Parameters[TargetSelectParameter.CanTargetDeathsDoor].Value) { availableTargets.RemoveAll(unit => unit.Character.AtDeathsDoor); } } if (Parameters[TargetSelectParameter.CanTargetLastHero].HasValue) { if (!Parameters[TargetSelectParameter.CanTargetLastHero].Value) { availableTargets.RemoveAll(unit => performer.CombatInfo.LastCombatSkillTarget == unit.CombatInfo.CombatId); } } if (Parameters[TargetSelectParameter.CanTargetNotOverstressed].HasValue) { if (!Parameters[TargetSelectParameter.CanTargetNotOverstressed].Value) { availableTargets.RemoveAll(unit => !unit.Character.IsOverstressed); } } if (Parameters[TargetSelectParameter.CanTargetAfflicted].HasValue) { if (!Parameters[TargetSelectParameter.CanTargetAfflicted].Value) { availableTargets.RemoveAll(unit => unit.Character.IsAfflicted); } } if (Parameters[TargetSelectParameter.CanTargetVirtued].HasValue) { if (!Parameters[TargetSelectParameter.CanTargetVirtued].Value) { availableTargets.RemoveAll(unit => unit.Character.IsVirtued); } } if (availableTargets.Count > 0) { decision.TargetInfo.Targets.Clear(); if (decision.SelectedSkill.TargetRanks.IsMultitarget) { decision.TargetInfo.Targets.AddRange(availableTargets); return(true); } else { int index = Random.Range(0, availableTargets.Count); decision.TargetInfo.Targets.Add(availableTargets[index]); availableTargets.RemoveAt(index); if (decision.SelectedSkill.ExtraTargetsChance > 0 && availableTargets.Count > 0 && RandomSolver.CheckSuccess(decision.SelectedSkill.ExtraTargetsChance)) { int sideTargetIndex = Random.Range(0, availableTargets.Count); decision.TargetInfo.Targets.Add(availableTargets[sideTargetIndex]); return(true); } return(true); } } return(false); }
public abstract bool SelectTarget(FormationUnit performer, MonsterBrainDecision decision);
public override bool SelectTarget(FormationUnit performer, MonsterBrainDecision decision) { if (decision.SelectedSkill.Effects.Find(effect => effect.SubEffects.Find(subeffect => subeffect is CaptureEffect) != null) == null) { return(false); } if (!(SpecificCombatSkillId == "" || SpecificCombatSkillId == decision.SelectedSkill.Id)) { return(false); } if (decision.SelectedSkill.TargetRanks.IsSelfFormation && !IsFriendlyTargetDesire) { return(false); } if (!(decision.SelectedSkill.TargetRanks.IsSelfFormation || decision.SelectedSkill.TargetRanks.IsSelfTarget) && !IsEnemyTargetDesire) { return(false); } var availableTargets = new List <FormationUnit>(decision.TargetInfo.Targets); if (Parameters[TargetSelectParameter.CanTargetDeathsDoor].HasValue) { if (!Parameters[TargetSelectParameter.CanTargetDeathsDoor].Value) { availableTargets.RemoveAll(unit => unit.Character.AtDeathsDoor); } } if (Parameters[TargetSelectParameter.CanTargetLastHero].HasValue) { if (!Parameters[TargetSelectParameter.CanTargetLastHero].Value) { availableTargets.RemoveAll(unit => performer.CombatInfo.LastCombatSkillTarget == unit.CombatInfo.CombatId); } } if (Parameters[TargetSelectParameter.CanTargetNotOverstressed].HasValue) { if (!Parameters[TargetSelectParameter.CanTargetNotOverstressed].Value) { availableTargets.RemoveAll(unit => !unit.Character.IsOverstressed); } } if (Parameters[TargetSelectParameter.CanTargetAfflicted].HasValue) { if (!Parameters[TargetSelectParameter.CanTargetAfflicted].Value) { availableTargets.RemoveAll(unit => unit.Character.IsAfflicted); } } if (Parameters[TargetSelectParameter.CanTargetVirtued].HasValue) { if (!Parameters[TargetSelectParameter.CanTargetVirtued].Value) { availableTargets.RemoveAll(unit => unit.Character.IsVirtued); } } if (availableTargets.Count > 0) { decision.TargetInfo.Targets.Clear(); if (decision.SelectedSkill.TargetRanks.IsMultitarget) { decision.TargetInfo.Targets.AddRange(availableTargets); return(true); } else { int index = Random.Range(0, availableTargets.Count); decision.TargetInfo.Targets.Add(availableTargets[index]); return(true); } } return(false); }
public override bool SelectTarget(FormationUnit performer, MonsterBrainDecision decision) { if (!(SpecificCombatSkillId == "" || SpecificCombatSkillId == decision.SelectedSkill.Id)) { return(false); } if (decision.SelectedSkill.TargetRanks.IsSelfFormation && !IsFriendlyTargetDesire) { return(false); } if (!(decision.SelectedSkill.TargetRanks.IsSelfFormation || decision.SelectedSkill.TargetRanks.IsSelfTarget) && !IsEnemyTargetDesire) { return(false); } var availableTargets = new List <FormationUnit>(decision.TargetInfo.Targets); if (Parameters[TargetSelectParameter.CanTargetDeathsDoor].HasValue) { if (!Parameters[TargetSelectParameter.CanTargetDeathsDoor].Value) { availableTargets.RemoveAll(unit => unit.Character.AtDeathsDoor); } } if (Parameters[TargetSelectParameter.CanTargetLastHero].HasValue) { if (!Parameters[TargetSelectParameter.CanTargetLastHero].Value) { availableTargets.RemoveAll(unit => performer.CombatInfo.LastCombatSkillTarget == unit.CombatInfo.CombatId); } } if (Parameters[TargetSelectParameter.CanTargetNotOverstressed].HasValue) { if (!Parameters[TargetSelectParameter.CanTargetNotOverstressed].Value) { availableTargets.RemoveAll(unit => !unit.Character.IsOverstressed); } } if (Parameters[TargetSelectParameter.CanTargetAfflicted].HasValue) { if (!Parameters[TargetSelectParameter.CanTargetAfflicted].Value) { availableTargets.RemoveAll(unit => unit.Character.IsAfflicted); } } if (Parameters[TargetSelectParameter.CanTargetVirtued].HasValue) { if (!Parameters[TargetSelectParameter.CanTargetVirtued].Value) { availableTargets.RemoveAll(unit => unit.Character.IsVirtued); } } if (availableTargets.Count > 0) { decision.TargetInfo.Targets.Clear(); if (decision.SelectedSkill.TargetRanks.IsMultitarget) { decision.TargetInfo.Targets.AddRange(availableTargets); return(true); } else { float lowestRes = float.MaxValue; FormationUnit lowestResTarget = null; foreach (var target in availableTargets) { if (target.Character[ResistanceType].ModifiedValue < lowestRes) { lowestRes = target.Character[ResistanceType].ModifiedValue; lowestResTarget = target; } } decision.TargetInfo.Targets.Add(lowestResTarget); availableTargets.Remove(lowestResTarget); if (decision.SelectedSkill.ExtraTargetsChance > 0 && availableTargets.Count > 0 && RandomSolver.CheckSuccess(decision.SelectedSkill.ExtraTargetsChance)) { lowestRes = 500f; lowestResTarget = null; foreach (var target in availableTargets) { if (target.Character[ResistanceType].ModifiedValue < lowestRes) { lowestRes = target.Character[ResistanceType].ModifiedValue; lowestResTarget = target; } } if (lowestResTarget != null) { decision.TargetInfo.Targets.Add(lowestResTarget); } return(true); } return(true); } } return(false); }