예제 #1
0
        private void NpcDialog_AnswerListChanged(object s, Dictionary <int, string> options)
        {
            SimpleChar dialogNpc = DynelManager.GetDynel((Identity)s).Cast <SimpleChar>();

            if (dialogNpc.Name == Constants.QuestGiverName)
            {
                foreach (KeyValuePair <int, string> option in options)
                {
                    if (option.Value == "Is there anything I can help you with?" ||
                        (ActiveGlobalSettings.MissionFaction == MissionFaction.Clan && option.Value == "I will defend against the Unredeemed!") ||
                        (ActiveGlobalSettings.MissionFaction == MissionFaction.Omni && option.Value == "I will defend against the Redeemed!") ||
                        (ActiveGlobalSettings.MissionFaction == MissionFaction.Neut && option.Value == "I will defend against the creatures of the brink!") ||
                        (ActiveGlobalSettings.MissionDifficulty == MissionDifficulty.Easy && option.Value == "I will deal with only the weakest aversaries") || //Brink missions have a typo
                        (ActiveGlobalSettings.MissionDifficulty == MissionDifficulty.Easy && option.Value == "I will deal with only the weakest adversaries") ||
                        (ActiveGlobalSettings.MissionDifficulty == MissionDifficulty.Medium && option.Value == "I will challenge these invaders, as long as there aren't too many") ||
                        (ActiveGlobalSettings.MissionDifficulty == MissionDifficulty.Hard && option.Value == "I will purge the temple of any and all assailants"))
                    {
                        NpcDialog.SelectAnswer(dialogNpc.Identity, option.Key);
                    }
                }
            }
            else if (dialogNpc.Name == Constants.QuestStarterName)
            {
                foreach (KeyValuePair <int, string> option in options)
                {
                    if (option.Value == "Yes, I am ready.")
                    {
                        NpcDialog.SelectAnswer(dialogNpc.Identity, option.Key);
                    }
                }
            }
        }
예제 #2
0
        public void Tick()
        {
            foreach (SimpleChar npc in DynelManager.NPCs)
            {
                if (!npc.IsAlive)
                {
                    continue;
                }

                if (npc.Name == Constants.SpiritNPCName)
                {
                    continue;
                }

                if (npc.Name == Constants.QuestStarterName)
                {
                    continue;
                }

                //We're plenty capable of pathing to mobs but we get way more consistent results if we just stand still and attack anything that walks up.
                if (!npc.IsInAttackRange())
                {
                    continue;
                }

                _target = npc;
            }

            HoldPosition();
        }
예제 #3
0
 public CombatActionQueueItem(ICombatAction action, SimpleChar target, bool shouldSetTarget, double timeoutOffset = 1)
 {
     CombatAction    = action;
     Target          = target;
     ShouldSetTarget = shouldSetTarget;
     Timeout         = Time.NormalTime + timeoutOffset;
 }
예제 #4
0
        public static bool FindTarget(out SimpleChar target, out EngageMethod engageMethod)
        {
            TeamMember teamLead = Team.Members.FirstOrDefault(x => x.IsLeader);

            engageMethod = EngageMethod.Pull;
            target       = DynelManager.NPCs.Where(c => c.Name != "Zix")
                           .Where(c => DynelManager.LocalPlayer.GetLogicalRangeToTarget(c) < Constants.MaxPullDistance)
                           .Where(c => c.IsAlive)
                           .Where(c => c.IsInLineOfSight)
                           .OrderByDescending(c => teamLead.Character != null && teamLead.Character.FightingTarget != null && teamLead.Character.FightingTarget.Identity == c.Identity)
                           .OrderBy(c => c.Position.DistanceFrom(DynelManager.LocalPlayer.Position))
                           .FirstOrDefault();

            if (target != null)
            {
                SimpleChar targetCopy = target;
                if (Team.Members.Where(x => x.Character != null).Any(x => x.Character.GetLogicalRangeToTarget(targetCopy) < Constants.FightDistance || (x.Character.FightingTarget != null && x.Character.FightingTarget.Identity == targetCopy.Identity)))
                {
                    engageMethod = EngageMethod.Fight;
                }
                else
                {
                    engageMethod = EngageMethod.Pull;
                }
            }

            return(target != null);
        }
예제 #5
0
        public void Tick()
        {
            if (_target != null && (!_target.IsValid ||
                                    !_target.IsAlive ||
                                    Time.NormalTime > _fightStartTime + FightTimeout))
            {
                _target             = null;
                APFBuddy.PullTarget = null;
            }

            if (_target == null)
            {
                if (APFBuddy.PullTarget != null &&
                    APFBuddy.PullTarget.IsValid &&
                    APFBuddy.PullTarget.IsAlive &&
                    APFBuddy.PullTarget.IsInLineOfSight)
                {
                    _target         = APFBuddy.PullTarget;
                    _fightStartTime = Time.NormalTime;
                }
                else if (APFBuddy.FindTarget(out SimpleChar target, out EngageMethod engageMethod) && engageMethod == EngageMethod.Fight)
                {
                    _target         = target;
                    _fightStartTime = Time.NormalTime;
                    APFBuddy.MovementController.SetFightTarget(_target);
                    Chat.WriteLine($"Fighting {_target.Name}");
                }
                else
                {
                    APFBuddy.FSM.Fire(Trigger.NoMobsInRange);
                }
            }
예제 #6
0
        public void ClearFightTarget()
        {
            _fightTarget = null;

            if (IsNavigating)
            {
                Halt();
            }
        }
예제 #7
0
        private void DynelSpawned(object s, Dynel dynel)
        {
            if (dynel.Identity.Type == IdentityType.SimpleChar)
            {
                SimpleChar c = dynel.Cast <SimpleChar>();

                Chat.WriteLine($"SimpleChar Spawned(TestPlugin): {c.Identity} -- {c.Name} -- {c.Position} -- {c.Health} -- IsInPlay: {c.IsInPlay}");
            }
        }
예제 #8
0
 void OnTriggerEnter(Collider other)
 {
     if (other.gameObject.tag == "Player")
     {
         script = other.GetComponent<SimpleChar>();
         if (script.travelled == false)
         {
             other.gameObject.SetActive(false);
             script.travelled = true;
             StartCoroutine(TunnelTravel(other.gameObject));
         }
     }
 }
예제 #9
0
        private void OnCharInPlay(object s, SimpleChar character)
        {
            if (_phase != ReformPhase.AwaitingTeammembers)
            {
                return;
            }

            if (!_teamCache.Contains(character.Identity))
            {
                return;
            }

            InvitePlayer(character.Identity);
        }
예제 #10
0
        private void OnUpdate(object sender, float e)
        {
            // do nothing if the bot is not enabled
            if (!_enabled)
            {
                return;
            }

            // if returnToDefensePos is true try to run back to the spot we want to defend
            if (_returnToDefensePos && DynelManager.LocalPlayer.Position.DistanceFrom(_posToDefend) > _tetherDistance)
            {
                if (!MovementController.Instance.IsNavigating)
                {
                    Chat.WriteLine($"Returning to {_posToDefend}");
                    MovementController.Instance.SetPath(new Path(_posToDefend)
                    {
                        DestinationReachedDist = _tetherDistance
                    });
                }
            }

            SimpleChar target = GetNextTarget();

            if (target != null)
            {
                Debug.DrawSphere(target.Position, 1, DebuggingColor.LightBlue);
                Debug.DrawLine(DynelManager.LocalPlayer.Position, target.Position, DebuggingColor.LightBlue);

                if (DynelManager.LocalPlayer.FightingTarget == null ||
                    DynelManager.LocalPlayer.FightingTarget.Identity != target.Identity)
                {
                    if (!target.IsInAttackRange())
                    {
                        Inventory.Find(TauntToolHigh, out Item tauntTool);
                        if (!Item.HasPendingUse && !DynelManager.LocalPlayer.Cooldowns.ContainsKey(Stat.Psychology) && tauntTool != null)
                        {
                            target.Target();
                            tauntTool.Use(target);
                        }
                    }
                    else
                    {
                        if (!DynelManager.LocalPlayer.IsAttackPending)
                        {
                            DynelManager.LocalPlayer.Attack(target);
                        }
                    }
                }
            }
        }
예제 #11
0
        public override void Update()
        {
            if (_fightTarget != null && Time.NormalTime > _nextTargetPathUpdate)
            {
                if (!DynelManager.IsValid(_fightTarget) || !_fightTarget.IsAlive)
                {
                    _fightTarget = null;
                }
                else
                {
                    NavigateToCombatPosition();
                }
            }

            base.Update();
        }
예제 #12
0
        private void Pull(SimpleChar target)
        {
            if (Item.HasPendingUse)
            {
                return;
            }

            if (Inventory.Find(TauntToolLow, TauntToolHigh, out Item tauntTool))
            {
                target.Target();
                tauntTool.Use(target);
            }
            else
            {
                Chat.WriteLine("No taunt tool found in inventory");
            }
        }
예제 #13
0
        private void OnDynelSpawned(object s, Dynel dynel)
        {
            if (_phase != ReformPhase.AwaitingTeammembers)
            {
                return;
            }

            if (!_teamCache.Contains(dynel.Identity))
            {
                return;
            }

            SimpleChar oldTeammate = dynel.Cast <SimpleChar>();

            if (!oldTeammate.IsInPlay)
            {
                return;
            }

            InvitePlayer(oldTeammate.Identity);
        }
예제 #14
0
        private SimpleChar GetNextTarget()
        {
            // target things that are fighting us first
            SimpleChar fightingOpponent = DynelManager.Characters
                                          .Where(c => c.FightingTarget != null && c.FightingTarget.Identity == DynelManager.LocalPlayer.Identity)
                                          .OrderBy(c => c.IsPet)
                                          .ThenByDescending(c => c.IsInAttackRange())
                                          .ThenByDescending(c => c.HealthPercent < 75)
                                          .ThenByDescending(c => c.Name == "Alien Larvae")
                                          .ThenByDescending(c => c.Name == "Alien Communications Officer")
                                          .ThenByDescending(c => c.Name.Contains("Ankari"))
                                          .ThenByDescending(c => c.Name.Contains("Ilari"))
                                          .ThenByDescending(c => c.Name.Contains("Vector"))
                                          .ThenByDescending(c => c.GetStat(Stat.Level))
                                          .FirstOrDefault();

            if (fightingOpponent != null)
            {
                return(fightingOpponent);
            }

            // find a new mob to fight
            return(GetValidTargets().FirstOrDefault());
        }
예제 #15
0
        private void OnUpdate(object sender, float e)
        {
            try
            {
                // Draw possible targets
                double currentTime = Time.NormalTime;
                if (currentTime > _nextEffect)
                {
                    _nextEffect = currentTime + _effectDelay;
                    foreach (SimpleChar potentialTarget in GetValidTargets())
                    {
                        IntPtr pEffectHandler = _EffectHandler_t.GetInstance();
                        if (pEffectHandler != IntPtr.Zero)
                        {
                            _EffectHandler_t.CreateEffect2(pEffectHandler, 43005, potentialTarget.Pointer, 0);
                        }
                    }
                }

                SimpleChar target = GetNextTarget();

                if (target != null)
                {
                    Debug.DrawSphere(target.Position, 1, DebuggingColor.LightBlue);
                    Debug.DrawLine(DynelManager.LocalPlayer.Position, target.Position, DebuggingColor.LightBlue);

                    if (target.IsInAttackRange())
                    {
                        if (DynelManager.LocalPlayer.FightingTarget == null ||
                            DynelManager.LocalPlayer.FightingTarget.Identity != target.Identity)
                        {
                            if (!DynelManager.LocalPlayer.IsAttackPending)
                            {
                                DynelManager.LocalPlayer.Attack(target);
                            }
                        }

                        if (!target.Buffs.Contains(268684) && !Item.HasPendingUse && target.HealthPercent >= 21 && target.GetStat(Stat.NPCFamily) == 229 && Inventory.Find(LaserCage, out Item cage))
                        {
                            target.Target();
                            cage.Use(target);
                        }
                    }
                    else
                    {
                        float distanceToTarget = target.Position.DistanceFrom(DynelManager.LocalPlayer.Position);

                        if (distanceToTarget >= LeashDistance)
                        {
                            // Run into leash range if movement is enabled
                            if (_menu.GetBool("EnableMovement") && !MovementController.Instance.IsNavigating)
                            {
                                MovementController.Instance.SetPath(new Path(target.Position)
                                {
                                    DestinationReachedDist = LeashDistance
                                });
                            }
                        }
                        else
                        {
                            // stop running if we are running
                            if (!(target.FightingTarget != null &&
                                  target.FightingTarget.Identity == DynelManager.LocalPlayer.Identity))
                            {
                                if (!DynelManager.LocalPlayer.Cooldowns.ContainsKey(Stat.Psychology))
                                {
                                    Pull(target);
                                }
                            }
                        }
                    }
                }
            }
            catch (Exception ex)
            {
                Chat.WriteLine(ex.ToString());
            }
        }
예제 #16
0
 private void CharInPlay(object s, SimpleChar character)
 {
     Chat.WriteLine($"{character.Name} is now in play.");
 }
예제 #17
0
        protected virtual SimpleChar GetNextTarget()
        {
            SimpleChar target = null;

            // If we are solo target things that are fighting us first
            if (!Team.IsInTeam)
            {
                target = DynelManager.Characters
                         .Where(c => c.FightingTarget != null && c.FightingTarget.Identity == DynelManager.LocalPlayer.Identity)
                         .Where(c => !_namesToIgnore.Contains(c.Name))
                         .OrderBy(c => c.IsPet)
                         .ThenByDescending(c => c.IsInAttackRange())
                         .ThenByDescending(c => c.HealthPercent < 75)
                         .ThenBy(c => c.Health)
                         .FirstOrDefault();
            }
            else
            {
                //find a target depending on our list

                /*target = DynelManager.Characters
                 *  .Where(c => !_namesToIgnore.Contains(c.Name))
                 *  .Where(c => _killOnSight.Contains(c.Name))
                 *  .Where(c => c.FightingTarget != null && Team.Members.Select(t => t.Identity).Contains(c.FightingTarget.Identity))
                 *  .OrderBy(c => c.IsPet)
                 *  .ThenByDescending(c => c.IsInAttackRange())
                 *  .ThenBy(c => c.Health)
                 *  .FirstOrDefault();
                 */
                IEnumerable <SimpleChar> targets = DynelManager.Characters
                                                   .Where(c => !_namesToIgnore.Contains(c.Name))
                                                   .Where(c => c.IsAttacking == true)
                ;
                foreach (string k in _killOnSight)
                {
                    foreach (SimpleChar t in targets)
                    {
                        if (t.Name == k)
                        {
                            //Chat.WriteLine("Found KOS target: "+t.Name);

                            if (t.Name != "Alien Coccoon" || (t.Name == "Alien Coccoon" && t.Health < 300000))
                            {
                                return(t);
                            }
                        }
                    }
                }

                if (target == null)
                {
                    // None of the KOS were found, find a new target
                    // If we are in a team target things that are fighting our team first
                    target = DynelManager.Characters
                             .Where(c => !Team.Members.Select(t => t.Identity).Contains(c.Identity))
                             .Where(c => c.FightingTarget != null && Team.Members.Select(t => t.Identity).Contains(c.FightingTarget.Identity))
                             .Where(c => !_namesToIgnore.Contains(c.Name))
                             .OrderBy(c => c.IsPet)
                             .ThenByDescending(c => c.IsInAttackRange())
                             .ThenByDescending(c => c.HealthPercent < 75)
                             .ThenBy(c => c.Health)
                             .FirstOrDefault();
                }
            }

            if (target == null)
            {
                // find a new mob to fight
                target = DynelManager.NPCs
                         .Where(c => c.Position.DistanceFrom(_posToDefend) < _defenseRadius)
                         .Where(c => !_namesToIgnore.Contains(c.Name))
                         .Where(c => c.IsAlive)
                         .Where(c => c.IsInLineOfSight)
                         .OrderBy(c => c.Position.DistanceFrom(DynelManager.LocalPlayer.Position))
                         .FirstOrDefault();
            }

            return(target);
        }
예제 #18
0
 public void SetFightTarget(SimpleChar target)
 {
     _fightTarget    = target;
     _fightStartTime = Time.NormalTime;
     NavigateToCombatPosition();
 }
예제 #19
0
 public FightState(SimpleChar target) : base(Constants.DefendPos, 3f, 1)
 {
     _target = target;
 }