Esempio n. 1
0
        public override Vector3Int GetJobLocation()
        {
            var currentPos = usedNPC.Position;

            if (_playerState.CallToArmsEnabled && _weapon != null)
            {
                _target = MonsterTracker.Find(currentPos, _weapon.range, _weapon.shootDamage);

                if (_target != null)
                {
                    return(currentPos);
                }
                else
                {
                    _target = MonsterTracker.Find(currentPos, CALL_RAD, _weapon.shootDamage);

                    if (_target != null)
                    {
                        var ranged = _weapon.range - 5;

                        if (ranged < 0)
                        {
                            ranged = 1;
                        }

                        position = new Vector3Int(_target.Position).Add(ranged, 0, ranged);
                        position = Server.AI.AIManager.ClosestPosition(position, currentPos);

                        if (!Server.AI.AIManager.CanStandAt(position))
                        {
                            _tmpVals.Set(COOLDOWN_KEY, _weapon.cooldownMissingItem);
                            _waitingFor++;
                        }
                        else
                        {
                            return(position);
                        }
                    }
                    else
                    {
                        _tmpVals.Set(COOLDOWN_KEY, _weapon.cooldownMissingItem);
                        _waitingFor++;
                    }
                }
            }

            if (_waitingFor > 10)
            {
                var banner = BannerManager.GetClosestBanner(usedNPC.Colony.Owner, currentPos);

                if (banner != null)
                {
                    return(banner.KeyLocation);
                }
            }

            return(currentPos);
        }