public AIContainer(Character actor, Controller controller, PathFind pathFind, TargetFind targetFind) { this.owner = actor; this.states = new Stack <State>(); this.controller = controller; this.pathFind = pathFind; this.targetFind = targetFind; latestUpdate = DateTime.Now; prevUpdate = latestUpdate; actionQueue = new ActionQueue(owner); }
//Checks whether the skill can be used on the given target public bool IsValidMainTarget(Character user, Character target) { targetFind = new TargetFind(user); if (aoeType == TargetFindAOEType.Box) { targetFind.SetAOEBox(validTarget, aoeTarget, aoeRange, rangeWidth, aoeRotateAngle); } else { targetFind.SetAOEType(validTarget, aoeType, aoeTarget, aoeRange, aoeMinRange, rangeHeight, aoeRotateAngle, aoeConeAngle); } /* * worldMasterTextId * 32512 cannot be performed on a KO'd target. * 32513 can only be performed on a KO'd target. * 32514 cannot be performed on yourself. * 32515 can only be performed on yourself. * 32516 cannot be performed on a friendly target. * 32517 can only be performed on a friendly target. * 32518 cannot be performed on an enemy. * 32519 can only be performed on an enemy, * 32556 unable to execute [weaponskill]. Conditions for use are not met. */ // cant target dead if ((mainTarget & (ValidTarget.Corpse | ValidTarget.CorpseOnly)) == 0 && target.IsDead()) { // cannot be perfomed on if (user is Player) { ((Player)user).SendGameMessage(Server.GetWorldManager().GetActor(), 32512, 0x20, (uint)id); } return(false); } //level too high if (level > user.GetLevel()) { if (user is Player) { ((Player)user).SendGameMessage(Server.GetWorldManager().GetActor(), 32527, 0x20, (uint)id); } //return false; } //Proc requirement if (procRequirement != BattleCommandProcRequirement.None && !user.charaWork.battleTemp.timingCommandFlag[(int)procRequirement - 1]) { if (user is Player) { ((Player)user).SendGameMessage(Server.GetWorldManager().GetActor(), 32556, 0x20, (uint)id); } return(false); } //costs too much tp if (CalculateTpCost(user) > user.GetTP()) { if (user is Player) { ((Player)user).SendGameMessage(Server.GetWorldManager().GetActor(), 32546, 0x20, (uint)id); } return(false); } // todo: calculate cost based on modifiers also (probably in BattleUtils) if (BattleUtils.CalculateSpellCost(user, target, this) > user.GetMP()) { if (user is Player) { ((Player)user).SendGameMessage(Server.GetWorldManager().GetActor(), 32545, 0x20, (uint)id); } return(false); } // todo: check target requirements if (requirements != BattleCommandRequirements.None) { if (false) { // Unable to execute [@SHEET(xtx/command,$E8(1),2)]. Conditions for use are not met. if (user is Player) { ((Player)user).SendGameMessage(Server.GetWorldManager().GetActor(), 32556, 0x20, (uint)id); } return(false); } } // todo: i dont care to message for each scenario, just the most common ones.. if ((mainTarget & ValidTarget.CorpseOnly) != 0) { if (target != null && target.IsAlive()) { if (user is Player) { ((Player)user).SendGameMessage(Server.GetWorldManager().GetActor(), 32513, 0x20, (uint)id); } return(false); } } if ((mainTarget & ValidTarget.Enemy) != 0) { if (target == user || target != null && user.allegiance == target.allegiance) { if (user is Player) { ((Player)user).SendGameMessage(Server.GetWorldManager().GetActor(), 32519, 0x20, (uint)id); } return(false); } } if ((mainTarget & ValidTarget.Ally) != 0) { if (target == null || target.allegiance != user.allegiance) { if (user is Player) { ((Player)user).SendGameMessage(Server.GetWorldManager().GetActor(), 32517, 0x20, (uint)id); } return(false); } } if ((mainTarget & ValidTarget.PartyMember) != 0) { if (target == null || target.currentParty != user.currentParty) { if (user is Player) { ((Player)user).SendGameMessage(Server.GetWorldManager().GetActor(), 32547, 0x20, (uint)id); } return(false); } } if ((mainTarget & ValidTarget.Player) != 0) { if (!(target is Player)) { if (user is Player) { ((Player)user).SendGameMessage(Server.GetWorldManager().GetActor(), 32517, 0x20, (uint)id); } return(false); } } return(true);// targetFind.CanTarget(target, true, true, true); //this will be done later }