protected override void SpecialPath(ManagerHelper mH) { var temp = (CaptureTheFlag)mH.GetGametype(); if (temp.GetEnemyBase(affiliation).GetMyFlag().status != Flag.FlagStatus.taken) { mH.GetPathHelper() .FindClearPath(GetOriginPosition(), temp.GetEnemyBase(affiliation).GetMyFlag().GetOriginPosition(), mH, path); } else { NPC captor = temp.GetEnemyBase(affiliation).GetMyFlag().GetCaptor(); if (captor == this) { mH.GetPathHelper() .FindClearPath(GetOriginPosition(), temp.GetAllyBase(affiliation).GetOriginPosition(), mH, path); } else { mH.GetPathHelper().FindClearPath(GetOriginPosition(), captor.GetOriginPosition(), mH, path); } } }
protected override void NewPath(ManagerHelper mH) { NPC tempEnemy = null; float shortestDistance = float.PositiveInfinity; foreach (var agent in mH.GetNPCManager().GetNPCs()) { if (agent.GetAffiliation() != affiliation) { float distanceToAgent = PathHelper.DistanceSquared(GetOriginPosition(), agent.GetOriginPosition()); if (distanceToAgent < shortestDistance) { shortestDistance = distanceToAgent; tempEnemy = agent; } } } Vector2 closetRockPosition = FindClosestRock(mH); if (closetRockPosition != new Vector2(-1, -1)) { mH.GetPathHelper().FindClearPath(GetOriginPosition(), closetRockPosition, mH, path); } else if (tempEnemy != null) { mH.GetPathHelper().FindClearPath(GetOriginPosition(), tempEnemy.GetOriginPosition(), mH, path); } else { RandomPath(mH); } }
protected override void NewPath(ManagerHelper mH) { List <Vector2> sniperSpots = mH.GetLevel().GetSniperSpots(); Vector2 endPoint = GetOriginPosition(); foreach (Vector2 v in sniperSpots) { bool validPoint = true; foreach (NPC agent in mH.GetNPCManager().GetNPCs()) { if (agent.GetAffiliation() != affiliation && NPCManager.IsNPCInRadius(agent, GetOriginPosition(), 200)) { validPoint = false; break; } } if (validPoint) { endPoint = v; break; } } mH.GetPathHelper().FindClearPath(GetOriginPosition(), endPoint, mH, path); }
//Specialized Paths protected void DefensePath(ManagerHelper mH, Vector2 m) { float x = mH.GetRandom().Next(-100, 100); float y = mH.GetRandom().Next(-100, 100); mH.GetPathHelper().FindClearPath(GetOriginPosition(), m + new Vector2(x, y), mH, path); }
public List <Vector2> GetFrameBlockersSpecial(ManagerHelper mH) { var tempList = new List <Vector2>(); foreach (Vector2 n in GetFrameBlockers()) { int x = (int)((position.X / 32) + n.X); int y = (int)((position.Y / 32) + n.Y); if (x >= 0 && x < mH.GetPathHelper().GetLength() && y >= 0 && y < mH.GetPathHelper().GetLength()) { tempList.Add(new Vector2(x, y)); } } return(tempList); }
protected override void SpecialPath(ManagerHelper mH) { if (target != null) { mH.GetPathHelper().FindClearPath(GetOriginPosition(), TargetDecider(mH).GetOriginPosition(), mH, path); } else { RandomPath(mH); } }
protected void HoverPath(ManagerHelper mH, Vector2 p, int r) { bool validPoint; Vector2 randPoint; Vector2 originNode = GetOriginPosition() / mH.GetPathHelper().GetNodeSize(); do { validPoint = true; randPoint = originNode + new Vector2(mH.GetRandom().Next(-1 * r / 32, r / 32), mH.GetRandom().Next(-1 * r / 32, r / 32)); if ((randPoint.X > 0 && randPoint.X < mH.GetLevelSize().X / 32) && (randPoint.Y > 0 && randPoint.Y < mH.GetLevelSize().Y / 32)) { foreach (Environment e in mH.GetEnvironmentManager().GetStaticBlockers()) { foreach (Vector2 n in e.GetFrameBlockers()) { if ((n.X + (int)e.GetOriginPosition().X) == randPoint.X && (n.Y + (int)e.GetOriginPosition().Y) == randPoint.Y) { validPoint = false; break; } } if (!validPoint) { break; } } } else { validPoint = false; } } while (!validPoint); mH.GetPathHelper().FindClearPath(GetOriginPosition(), randPoint * 32, mH, path); }
public static bool IsNPCInDirection(NPC agent, Vector2 pos, float dir, float cone, ManagerHelper mH) { if (!mH.GetPathHelper().IsVectorObstructed(pos, agent.GetOriginPosition())) { float dirToAgent = PathHelper.Direction(pos, agent.GetOriginPosition()); return(MathHelper.Distance(dirToAgent, dir) < cone); } else { return(false); } }
protected virtual void CTFPath(ManagerHelper mH) { var ctf = (CaptureTheFlag)mH.GetGametype(); Flag f = ctf.GetAllyBase(affiliation).GetMyFlag(); if (f.status == Flag.FlagStatus.away) { mH.GetPathHelper().FindClearPath(GetOriginPosition(), f.GetOriginPosition(), mH, path); } else { EngagePath(mH); } }
protected virtual void AssaultPath(ManagerHelper mH) { var ass = (Assault)mH.GetGametype(); Flag f = ass.GetAllyBase(affiliation).GetMyFlag(); if (f != null && f.status == Flag.FlagStatus.away) { mH.GetPathHelper().FindClearPath(GetOriginPosition(), f.GetOriginPosition(), mH, path); } else { EngagePath(mH); } }
protected override void SpecialPath(ManagerHelper mH) { var temp = (Conquest)mH.GetGametype(); ConquestBase forwardBase = temp.GetForwardBase(affiliation, mH); if (forwardBase != null) { mH.GetPathHelper().FindClearPath(GetOriginPosition(), forwardBase.GetOriginPosition(), mH, path); } else { EngagePath(mH); } }
protected override void DeathmatchPath(ManagerHelper mH) { var temp = (Deathmatch)mH.GetGametype(); Claimable c = temp.GetClosestClaimable(GetOriginPosition(), mH); if (c != null && temp.GetPopCap() > mH.GetNPCManager().GetAllies(affiliation).Count) { mH.GetPathHelper().FindClearPath(GetOriginPosition(), c.GetOriginPosition(), mH, path); } else { EngagePath(mH); } }
protected override void SurvivalPath(ManagerHelper mH) { pathTimerEnd = .5; var temp = (Survival)mH.GetGametype(); Claimable c = temp.GetClosestClaimable(GetOriginPosition()); NPC enemy = mH.GetNPCManager() .GetClosestInList(mH.GetNPCManager().GetAllies(AffliationTypes.black), GetOriginPosition()); if (enemy != null && PathHelper.DistanceSquared(GetOriginPosition(), enemy.GetOriginPosition()) < 200 * 200) { mH.GetPathHelper().FindEscapePath(GetOriginPosition(), enemy.GetOriginPosition(), 400, mH, 200, path); } else if (c != null && temp.GetPopCap() > mH.GetNPCManager().GetAllies(affiliation).Count) { mH.GetPathHelper().FindClearPath(GetOriginPosition(), c.GetOriginPosition(), mH, path); } else { RandomPath(mH); } }
protected override void SpecialPath(ManagerHelper mH) { var temp = (CaptureTheFlag)mH.GetGametype(); if (temp.GetAllyBase(affiliation).GetMyFlag().status == Flag.FlagStatus.home) { DefensePath(mH, temp.GetAllyBase(affiliation).GetOriginPosition()); } else { NPC captor = temp.GetAllyBase(affiliation).GetMyFlag().GetCaptor(); if (captor != null) { mH.GetPathHelper().FindClearPath(GetOriginPosition(), captor.GetOriginPosition(), mH, path); } else { mH.GetPathHelper() .FindClearPath(GetOriginPosition(), temp.GetAllyBase(affiliation).GetMyFlag().GetOriginPosition(), mH, path); } } }
protected override void SpecialPath(ManagerHelper mH) { //do i have friends NPC friend = mH.GetNPCManager().GetClosestInList(mH.GetNPCManager().GetAllies(affiliation), this); if (friend != null) { float closestDistancetoTarget = float.PositiveInfinity; target = null; foreach (var team in mH.GetGametype().GetTeams()) { if (team != affiliation) { NPC closestTargetForTeam = mH.GetNPCManager() .GetClosestInList(mH.GetNPCManager().GetAllies(team), friend.GetOriginPosition()); if (closestTargetForTeam != null) { float closestDiestanceToTargetForTeam = PathHelper.DistanceSquared( closestTargetForTeam.GetOriginPosition(), friend.GetOriginPosition()); if (closestDiestanceToTargetForTeam < closestDistancetoTarget) { target = closestTargetForTeam; closestDistancetoTarget = closestDiestanceToTargetForTeam; } } } } } Vector2 destination; //if so if (friend != null && target != null) { //we can now get a midpoint destination = PathHelper.MidPoint(friend.GetOriginPosition(), target.GetOriginPosition()); //and wedge ourselves in mH.GetPathHelper().FindClearPath(GetOriginPosition(), destination, mH, path); } //else, we shall wander the planes between heaven and hell else { RandomPath(mH); } }
protected void EngagePath(ManagerHelper mH) { NPC tempEnemy; if (mH.GetGametype() is Survival) { tempEnemy = target ?? mH.GetNPCManager() .GetClosestInList(mH.GetNPCManager().GetAllies(AffliationTypes.black), this); } else { NPC tempClosestEnemy = null; float tempClosestDistance = float.PositiveInfinity; foreach (var agent in mH.GetNPCManager().GetNPCs()) { if (agent.GetAffiliation() != affiliation) { float distaceToEnemy = PathHelper.DistanceSquared(GetOriginPosition(), agent.GetOriginPosition()); if (distaceToEnemy < tempClosestDistance) { tempClosestDistance = distaceToEnemy; tempClosestEnemy = agent; } } } tempEnemy = target != null ? target : tempClosestEnemy; } if (tempEnemy != null) { if (PathHelper.DistanceSquared(GetOriginPosition(), tempEnemy.GetOriginPosition()) > 128 * 128) { mH.GetPathHelper().FindClearPath(GetOriginPosition(), tempEnemy.GetOriginPosition(), mH, path); } else { HoverPath(mH, GetOriginPosition(), 64); } } else { RandomPath(mH); } }
protected virtual void SurvivalPath(ManagerHelper mH) { var c = (Commander)mH.GetNPCManager().GetCommander(affiliation); if (c != null) { if (PathHelper.DistanceSquared(c.GetOriginPosition(), GetOriginPosition()) < 96 * 96) { HoverPath(mH, c.GetOriginPosition(), 96); } else { mH.GetPathHelper().FindClearPath(GetOriginPosition(), c.GetOriginPosition(), mH, path); } } else { RandomPath(mH); } }
protected override void SpecialPath(ManagerHelper mH) { var temp = (Conquest)mH.GetGametype(); ConquestBase targetBase = null; float distanceToClosest = float.PositiveInfinity; foreach (ConquestBase conquestBase in temp.GetBases()) { if (conquestBase.affiliation != affiliation) { float distanceToBase = PathHelper.DistanceSquared(GetOriginPosition(), conquestBase.GetOriginPosition()); if (distanceToBase < distanceToClosest) { distanceToClosest = distanceToBase; targetBase = conquestBase; } } } if (targetBase != null) { if (PathHelper.DistanceSquared(GetOriginPosition(), targetBase.GetOriginPosition()) > 32 * 32) { mH.GetPathHelper().FindClearPath(GetOriginPosition(), targetBase.GetOriginPosition(), mH, path); } else { HoverPath(mH, targetBase.GetOriginPosition(), 32); } } else { EngagePath(mH); } }
protected void RandomPath(ManagerHelper mH) { bool validPoint; Vector2 randPoint; pathTimerEnd = 10; do { validPoint = true; randPoint = new Vector2(mH.GetRandom().Next((int)mH.GetLevelSize().X), mH.GetRandom().Next((int)mH.GetLevelSize().Y)) / mH.GetPathHelper().GetNodeSize(); foreach (Environment e in mH.GetEnvironmentManager().GetStaticBlockers()) { foreach (Vector2 n in e.GetFrameBlockers()) { if (n.Equals(randPoint)) { validPoint = false; break; } else { validPoint = true; } } if (!validPoint) { break; } } } while (!validPoint); mH.GetPathHelper().FindClearPath(GetOriginPosition(), randPoint * 32, mH, path); }
protected override void AssaultPath(ManagerHelper mH) { var temp = (Assault)mH.GetGametype(); if (temp.GetAttacker() == affiliation) { if (temp.GetEnemyBase(affiliation).GetMyFlag().status != Flag.FlagStatus.taken) { mH.GetPathHelper() .FindClearPath(GetOriginPosition(), temp.GetEnemyBase(affiliation).GetOriginPosition(), mH, path); } else { NPC captor = temp.GetEnemyBase(affiliation).GetMyFlag().GetCaptor(); NPC closestEnemy = null; float closestDistanceToEnemy = float.PositiveInfinity; foreach (var team in mH.GetGametype().GetTeams()) { if (team != affiliation) { NPC closestEnemyForTeam = mH.GetNPCManager().GetClosestInList(mH.GetNPCManager().GetAllies(team), captor); if (closestEnemyForTeam != null) { float closestDistanceToEnemyForTeam = PathHelper.DistanceSquared(closestEnemyForTeam.GetOriginPosition(), captor.GetOriginPosition()); if (closestDistanceToEnemyForTeam < closestDistanceToEnemy) { closestDistanceToEnemy = closestDistanceToEnemyForTeam; closestEnemy = closestEnemyForTeam; } } } } if (captor == this) { mH.GetPathHelper() .FindClearPath(GetOriginPosition(), temp.GetAllyBase(affiliation).GetOriginPosition(), mH, path); } else if (closestEnemy != null) { mH.GetPathHelper() .FindClearPath(GetOriginPosition(), closestEnemy.GetOriginPosition(), mH, path); } else { mH.GetPathHelper().FindClearPath(GetOriginPosition(), captor.GetOriginPosition(), mH, path); } } } else { if (temp.GetAllyBase(affiliation).GetMyFlag().status == Flag.FlagStatus.home) { HoverPath(mH, temp.GetAllyBase(affiliation).GetOriginPosition(), 48); } else { NPC captor = temp.GetAllyBase(affiliation).GetMyFlag().GetCaptor(); if (captor != null) { mH.GetPathHelper().FindClearPath(GetOriginPosition(), captor.GetOriginPosition(), mH, path); } else { mH.GetPathHelper() .FindClearPath(GetOriginPosition(), temp.GetAllyBase(affiliation).GetMyFlag().GetOriginPosition(), mH, path); } } } }