示例#1
0
        private void LoadSettings()
        {
            _allowMobHunting                = bool.Parse(PlayerPrefs.GetString($"{_prefsIdentifier}{nameof(_allowMobHunting)}", bool.FalseString));
            _skipUnrestrictedPvPZones       = bool.Parse(PlayerPrefs.GetString($"{_prefsIdentifier}{nameof(_skipUnrestrictedPvPZones)}", bool.TrueString));
            _skipKeeperPacks                = bool.Parse(PlayerPrefs.GetString($"{_prefsIdentifier}{nameof(_skipKeeperPacks)}", bool.TrueString));
            _allowSiegeCampTreasure         = bool.Parse(PlayerPrefs.GetString($"{_prefsIdentifier}{nameof(_allowSiegeCampTreasure)}", bool.TrueString));
            _skipRedAndBlackZones           = bool.Parse(PlayerPrefs.GetString($"{_prefsIdentifier}{nameof(_skipRedAndBlackZones)}", bool.TrueString));
            _keeperSkipRange                = PlayerPrefs.GetFloat($"{_prefsIdentifier}{nameof(_keeperSkipRange)}", 22);
            _minimumHealthForGathering      = PlayerPrefs.GetFloat($"{_prefsIdentifier}{nameof(_minimumHealthForGathering)}", 0.8f);
            _percentageForBanking           = PlayerPrefs.GetFloat($"{_prefsIdentifier}{nameof(_percentageForBanking)}", 99f);
            _percentageForSiegeCampTreasure = PlayerPrefs.GetFloat($"{_prefsIdentifier}{nameof(_percentageForSiegeCampTreasure)}", 33f);
            _selectedGatherCluster          = PlayerPrefs.GetString($"{_prefsIdentifier}{nameof(_selectedGatherCluster)}", null);
            _selectedTownClusterIndex       = PlayerPrefs.GetInt($"{_prefsIdentifier}{nameof(_selectedTownClusterIndex)}", 0);
            _selectedMininumTierIndex       = PlayerPrefs.GetInt($"{_prefsIdentifier}{nameof(_selectedMininumTierIndex)}", 0);
            _gatherInformations             = new Dictionary <GatherInformation, bool>();
            foreach (var resourceType in Enum.GetValues(typeof(Albion_Direct.ResourceType)).Cast <Albion_Direct.ResourceType>())
            {
                foreach (var tier in Enum.GetValues(typeof(Albion_Direct.Tier)).Cast <Albion_Direct.Tier>())
                {
                    foreach (var enchantment in Enum.GetValues(typeof(Albion_Direct.EnchantmentLevel)).Cast <Albion_Direct.EnchantmentLevel>())
                    {
                        if ((tier < Albion_Direct.Tier.IV || resourceType == Albion_Direct.ResourceType.Rock) && enchantment != Albion_Direct.EnchantmentLevel.White)
                        {
                            continue;
                        }

                        var info = new GatherInformation(resourceType, tier, enchantment);
                        var val  = bool.Parse(PlayerPrefs.GetString($"{_prefsIdentifier}{info.ToString()}", (tier >= Albion_Direct.Tier.II).ToString()));
                        _gatherInformations.Add(info, val);
                    }
                }
            }
        }
示例#2
0
        private void LoadSettings()
        {
            _allowMobHunting                = bool.Parse(PlayerPrefs.GetString($"{_prefsIdentifier}{nameof(_allowMobHunting)}", bool.FalseString));
            _skipUnrestrictedPvPZones       = bool.Parse(PlayerPrefs.GetString($"{_prefsIdentifier}{nameof(_skipUnrestrictedPvPZones)}", bool.TrueString));
            _skipKeeperPacks                = bool.Parse(PlayerPrefs.GetString($"{_prefsIdentifier}{nameof(_skipKeeperPacks)}", bool.TrueString));
            _allowSiegeCampTreasure         = bool.Parse(PlayerPrefs.GetString($"{_prefsIdentifier}{nameof(_allowSiegeCampTreasure)}", bool.TrueString));
            _skipRedAndBlackZones           = bool.Parse(PlayerPrefs.GetString($"{_prefsIdentifier}{nameof(_skipRedAndBlackZones)}", bool.TrueString));
            _keeperSkipRange                = PlayerPrefs.GetFloat($"{_prefsIdentifier}{nameof(_keeperSkipRange)}", 22);
            _minimumHealthForGathering      = PlayerPrefs.GetFloat($"{_prefsIdentifier}{nameof(_minimumHealthForGathering)}", 0.8f);
            _percentageForBanking           = PlayerPrefs.GetFloat($"{_prefsIdentifier}{nameof(_percentageForBanking)}", 99f);
            _percentageForSiegeCampTreasure = PlayerPrefs.GetFloat($"{_prefsIdentifier}{nameof(_percentageForSiegeCampTreasure)}", 33f);
            _selectedGatherCluster          = PlayerPrefs.GetString($"{_prefsIdentifier}{nameof(_selectedGatherCluster)}", null);
            _selectedTownClusterIndex       = PlayerPrefs.GetInt($"{_prefsIdentifier}{nameof(_selectedTownClusterIndex)}", 0);
            _selectedMininumTierIndex       = PlayerPrefs.GetInt($"{_prefsIdentifier}{nameof(_selectedMininumTierIndex)}", 0);

            _selectedCraftCluster          = PlayerPrefs.GetString($"{_craftPrefsIdentifier}{nameof(_selectedCraftCluster)}", null);
            _selectedCraftTownClusterIndex = PlayerPrefs.GetInt($"{_craftPrefsIdentifier}{nameof(_selectedCraftTownClusterIndex)}", 0);

            _gatherInformations = new Dictionary <GatherInformation, bool>();
            foreach (var resourceType in Enum.GetValues(typeof(ResourceType)).Cast <ResourceType>())
            {
                foreach (var tier in Enum.GetValues(typeof(Tier)).Cast <Tier>())
                {
                    foreach (var enchantment in Enum.GetValues(typeof(EnchantmentLevel)).Cast <EnchantmentLevel>())
                    {
                        if ((tier < Tier.IV || resourceType == ResourceType.Rock) && enchantment != EnchantmentLevel.White)
                        {
                            continue;
                        }

                        var info = new GatherInformation(resourceType, tier, enchantment);
                        var val  = bool.Parse(PlayerPrefs.GetString($"{_prefsIdentifier}{info.ToString()}", (tier >= Tier.II).ToString()));
                        _gatherInformations.Add(info, val);
                    }
                }
            }
            //  foreach (var processedResourceType in Enum.GetValues(typeof(ProcessedResourceType)).Cast<ProcessedResourceType>)
            _toCraftListCount = PlayerPrefs.GetInt($"{_craftPrefsIdentifier}_toCraftListLength", 0);
            Core.Log($"Loading to craft list Settings {_toCraftListCount}");
            if (_toCraftListCount > 0)
            {
                for (int i = 0; i < _toCraftListCount; i++)
                {
                    string S = PlayerPrefs.GetString($"{_craftPrefsIdentifier}{i}_1", null);
                    int    I = PlayerPrefs.GetInt($"{_craftPrefsIdentifier}{i}_2", -1);
                    Core.Log($"{S}{I}");

                    Tuple <string, int> T = new Tuple <string, int>(S, I);
                    toCraftList.Add(T);
                }
            }
        }
示例#3
0
        public bool IdentifiedTarget(out SimulationObjectView target)
        {
            var resources = _client.GetEntities <HarvestableObjectView>(ValidateHarvestable);
            var hostiles  = _client.GetEntities <MobView>(ValidateMob);

            var views = new List <SimulationObjectView>();

            foreach (var r in resources)
            {
                views.Add(r);
            }
            //foreach (var h in hostiles) views.Add(h);

            var filteredViews = views.Where(view =>
            {
                if (view is HarvestableObjectView harvestable)
                {
                    var resourceType     = (ResourceType)Enum.Parse(typeof(ResourceType), harvestable.GetResourceType(), true);
                    var tier             = (Tier)harvestable.GetTier();
                    var enchantmentLevel = (EnchantmentLevel)harvestable.GetRareState();

                    var info = new GatherInformation(resourceType, tier, enchantmentLevel);

                    return(_gatherInformations[info]);
                }
                else
                {
                    return(false);
                }
            });

            target = filteredViews.OrderBy((view) =>
            {
                var playerPosition   = _localPlayerCharacterView.transform.position;
                var resourcePosition = view.transform.position;

                var score = (resourcePosition - playerPosition).sqrMagnitude;

                if (view is HarvestableObjectView harvestable)
                {
                    var rareState = harvestable.GetRareState();

                    if (harvestable.GetTier() >= 3)
                    {
                        score /= 2;
                    }
                    if (harvestable.GetCurrentCharges() == harvestable.GetMaxCharges())
                    {
                        score /= 2;
                    }
                    if (rareState > 0)
                    {
                        score /= rareState;
                    }
                }
                else if (view is MobView mob)
                {
                }

                var yDelta = Math.Abs(_landscape.GetLandscapeHeight(playerPosition.c()) - _landscape.GetLandscapeHeight(resourcePosition.c()));

                score += (yDelta * 10f);

                return((int)score);
            }).FirstOrDefault();

            if (target != null)
            {
                Core.Log($"Resource spotted: {target.name}");
            }

            return(target != default(SimulationObjectView));
        }
示例#4
0
        public bool IdentifiedTarget(out SimulationObjectView target)
        {
            var views = new List <SimulationObjectView>();

            if (_allowMobHunting)
            {
                var hostiles = _client.GetEntities <MobView>(ValidateMob);
                foreach (var h in hostiles)
                {
                    if (h.GetResourceType().HasValue)
                    {
                        views.Add(h);
                    }
                }
            }

            var resources = _client.GetEntities <HarvestableObjectView>(ValidateHarvestable);

            foreach (var r in resources)
            {
                views.Add(r);
            }

            var filteredViews = views.Where(view =>
            {
                if (_skipUnrestrictedPvPZones && _landscape.IsInAnyUnrestrictedPvpZone(view.transform.position))
                {
                    return(false);
                }

                if (_skipKeeperPacks && ContainKeepers(view.transform.position))
                {
                    return(false);
                }

                if (view is HarvestableObjectView harvestable)
                {
                    var harvestableObject = harvestable.GetHarvestableObject();

                    var resourceType     = harvestableObject.GetResourceType().Value;
                    var tier             = (Tier)harvestableObject.GetTier();
                    var enchantmentLevel = (EnchantmentLevel)harvestableObject.GetRareState();

                    var info = new GatherInformation(resourceType, tier, enchantmentLevel);

                    return(_gatherInformations[info]);
                }
                else if (view is MobView mob)
                {
                    var resourceType     = mob.GetResourceType().Value;
                    var tier             = (Tier)mob.GetTier();
                    var enchantmentLevel = (EnchantmentLevel)mob.GetRareState();

                    var info = new GatherInformation(resourceType, tier, enchantmentLevel);

                    return(_gatherInformations[info]);
                }
                else
                {
                    return(false);
                }
            });

            target = filteredViews.OrderBy((view) =>
            {
                var playerPosition   = _localPlayerCharacterView.transform.position;
                var resourcePosition = view.transform.position;

                var score = (resourcePosition - playerPosition).sqrMagnitude;

                if (view is HarvestableObjectView harvestable)
                {
                    var harvestableObject = harvestable.GetHarvestableObject();
                    var rareState         = harvestableObject.GetRareState();

                    if (harvestableObject.GetTier() >= 3)
                    {
                        score /= (harvestableObject.GetTier() - 1);
                    }
                    if (harvestableObject.GetCharges() == harvestableObject.GetMaxCharges())
                    {
                        score /= 2;
                    }
                    if (rareState > 0)
                    {
                        score /= ((rareState + 1) * (rareState + 1));
                    }
                }
                else if (view is MobView mob)
                {
                    var rareState = mob.GetRareState();

                    if (mob.GetTier() >= 3)
                    {
                        score /= (mob.GetTier() - 1);
                    }
                    //if (mob.GetCurrentCharges() == mob.GetMaxCharges()) score /= 2;
                    if (rareState > 0)
                    {
                        score /= ((rareState + 1) * (rareState + 1));
                    }
                }

                var yDelta = Math.Abs(_landscape.GetTerrainHeight(playerPosition.c(), out RaycastHit A_1) - _landscape.GetTerrainHeight(resourcePosition.c(), out RaycastHit A_2));

                score += (yDelta * 10f);

                return((int)score);
            }).FirstOrDefault();

            if (target != null)
            {
                Core.Log($"Resource spotted: {target.name}");
            }

            return(target != default(SimulationObjectView));
        }
示例#5
0
        private void Search()
        {
            if (HandleAttackers())
            {
                return;
            }

            var isCurrentCluster = ObjectManager.GetInstance().GetCurrentCluster().GetName() == _selectedGatherCluster;
            var isHomeCluster    = ObjectManager.GetInstance().GetCurrentCluster().GetName() == TownClusterNames[_selectedTownClusterIndex];

            if (isCurrentCluster && _allowSiegeCampTreasure && CanUseSiegeCampTreasure && (_localPlayerCharacterView.GetLoadPercent() > _percentageForSiegeCampTreasure))
            {
                Core.Log("Start Seige Camp Treasure Routine");
                _state.Fire(Trigger.StartSiegeCampTreasure);
                return;
            }

            if (_localPlayerCharacterView.GetLoadPercent() > _percentageForBanking)
            {
                Core.Log("Over allowed Weight. Start Banking procedure.");
                _state.Fire(Trigger.Overweight);
                return;
            }

            if (_localPlayerCharacterView.GetLocalPlayerCharacter().HasAnyBrokenItem())
            {
                Core.Log("Damaged - Items fell below 10% durability. Head to Repair in home town");
                _state.Fire(Trigger.Damaged);
                return;
            }

            if (isHomeCluster)
            {
                if (_localPlayerCharacterView.GetLocalPlayerCharacter().HasAnyDamagedItem())
                {
                    Core.Log("We are in home town with damaged items. Fix them before going to harvest.");
                    _state.Fire(Trigger.Damaged);
                    return;
                }
            }

            if (!isCurrentCluster)
            {
                Worldmap worldmapInstance = GameGui.Instance.WorldMap;

                Core.Log("[Travel to target cluster]");
                _targetCluster = worldmapInstance.GetCluster(_selectedGatherCluster).Info;
                _state.Fire(Trigger.StartTravelling);
                return;
            }

            if (Loot())
            {
                return;
            }

            if (_currentTarget != null)
            {
                Core.Log("[Blacklisting target]");

                Blacklist(_currentTarget, TimeSpan.FromMinutes(0.5));

                _currentTarget         = null;
                _harvestPathingRequest = null;

                return;
            }

            if (IdentifiedTarget(out SimulationObjectView target))
            {
                Core.Log("[Checking Target]");

                _currentTarget = target;
            }

            if (_currentTarget != null && ValidateTarget(_currentTarget))
            {
                Core.Log("[Identified]");

                _changeGatheringPathRequest = null;
                _failedFindAttempts         = 0;
                _state.Fire(Trigger.DiscoveredResource);

                return;
            }
            else
            {
                if (HandlePathing(ref _changeGatheringPathRequest))
                {
                    return;
                }

                _failedFindAttempts++;
                if (_failedFindAttempts > MAXIMUM_FAIL_ATTEMPTS)
                {
                    Core.Log($"[Looking for fallback in {_gatheredSpots.Count} objects]");

                    //Remove all fallback points older than 1 hour
                    var entriesToRemove = _gatheredSpots.Where(kvp => !kvp.Value.HarvestDate.HasValue || kvp.Value.HarvestDate.Value.AddHours(1) < DateTime.UtcNow).ToArray();
                    foreach (var entry in entriesToRemove)
                    {
                        Core.Log($"[Removing {entry.Key} from fallback objects. Too old]");
                        _gatheredSpots.Remove(entry.Key);
                    }

                    var validEntries = _gatheredSpots.Where(kvp =>
                    {
                        var info = new GatherInformation(kvp.Value.ResourceType, kvp.Value.Tier, kvp.Value.EnchantmentLevel);
                        return(_gatherInformations[info]);
                    }).ToArray();

                    Core.Log($"[Found {validEntries.Length} valid fallback objects]");
                    if (validEntries.Length == 0)
                    {
                        return;
                    }

                    //Select a random fallback point
                    var spotToUse = validEntries[UnityEngine.Random.Range(0, validEntries.Length)];
                    var spot3d    = new Vector3(spotToUse.Key.GetX(), _landscape.GetTerrainHeight(spotToUse.Key, out RaycastHit hit), spotToUse.Key.GetY());
                    if (_localPlayerCharacterView.TryFindPath(new ClusterPathfinder(), spot3d, IsBlockedGathering, out List <Vector3> pathing))
                    {
                        Core.Log($"Falling back to {spot3d} which should hold {spotToUse.Value.ToString()}. Removing it from fallback objects.");
                        _changeGatheringPathRequest = new PositionPathingRequest(_localPlayerCharacterView, spot3d, pathing);
                    }
                    else
                    {
                        Core.Log($"No path to {spot3d} found. Removing it from fallback objects.");
                    }

                    _gatheredSpots.Remove(spotToUse.Key);
                    _failedFindAttempts = 0;
                }
            }
        }
示例#6
0
        public void HarvestHarvestableObjec(HarvestableObjectView resource)
        {
            Vector3 targetCenter = _currentTarget.transform.position;
            Vector3 playerCenter = _localPlayerCharacterView.transform.position;

            //Skip if target is inside a kepper pack
            if (_skipKeeperPacks && (ContainKeepers(_currentTarget.transform.position)))
            {
                Core.Log("[Blacklisted - Inside Kepper Pack Range]");
                Blacklist(resource, TimeSpan.FromMinutes(5));
                _state.Fire(Trigger.DepletedResource);
                return;
            }

            if (HandlePathing(ref _harvestPathingRequest))
            {
                return;
            }

            var centerDistance = (targetCenter - playerCenter).magnitude;
            var minDistance    = _currentTarget.GetColliderExtents() + _localPlayerCharacterView.GetColliderExtents() + 1.5f;

            if (centerDistance >= minDistance)
            {
                if (_localPlayerCharacterView.TryFindPath(new ClusterPathfinder(), targetCenter, IsBlockedGathering, out List <Vector3> pathing))
                {
                    Core.Log("Path found, begin travel to resource");
                    Core.lineRenderer.positionCount = pathing.Count;
                    Core.lineRenderer.SetPositions(pathing.ToArray());
                    _harvestPathingRequest = new ClusterPathingRequest(_localPlayerCharacterView, _currentTarget, pathing);
                }
                else
                {
                    Core.Log("Path not found");
                    _state.Fire(Trigger.DepletedResource);
                }
                return;
            }

            if (_localPlayerCharacterView.IsHarvesting())
            {
                Core.LogOnce("Currently harvesting. Wait until done.");
                return;
            }

            if (resource.GetHarvestableObject().GetCharges() <= 0)
            {
                Core.Log("resource depleted. Move on");
                _state.Fire(Trigger.DepletedResource);
                return;
            }

            Core.Log("[Harvesting] - Interact with resource");
            _localPlayerCharacterView.Interact(resource);

            var harvestableObject2 = resource.GetHarvestableObject();

            var resourceType     = harvestableObject2.GetResourceType().Value;
            var tier             = (Albion_Direct.Tier)harvestableObject2.GetTier();
            var enchantmentLevel = (Albion_Direct.EnchantmentLevel)harvestableObject2.GetRareState();

            var info = new GatherInformation(resourceType, tier, enchantmentLevel)
            {
                HarvestDate = DateTime.UtcNow
            };

            var position = resource.transform.position.c();

            if (_gatheredSpots.ContainsKey(position))
            {
                _gatheredSpots[position] = info;
            }
            else
            {
                _gatheredSpots.Add(position, info);
            }
        }
示例#7
0
        public void HarvestHarvestableObjec(HarvestableObjectView resource)
        {
            Vector3 targetCenter = _currentTarget.transform.position;
            Vector3 playerCenter = _localPlayerCharacterView.transform.position;

            //Skip if target is inside a kepper pack
            if (_skipKeeperPacks && (ContainKeepers(_currentTarget.transform.position)))
            {
                Core.Log("[Skipped - Inside Kepper Pack Range]");
                Blacklist(resource, TimeSpan.FromHours(24));
                _state.Fire(Trigger.DepletedResource);
                return;
            }

            if (HandlePathing(ref _harvestPathingRequest))
            {
                return;
            }

            var centerDistance = (targetCenter - playerCenter).magnitude;
            var minDistance    = _currentTarget.GetColliderExtents() + _localPlayerCharacterView.GetColliderExtents() + 1.5f;

            if (centerDistance >= minDistance)
            {
                if (_localPlayerCharacterView.TryFindPath(new ClusterPathfinder(), targetCenter, IsBlockedGathering, out List <Vector3> pathing))
                {
                    Core.lineRenderer.positionCount = pathing.Count;
                    Core.lineRenderer.SetPositions(pathing.ToArray());
                    _harvestPathingRequest = new ClusterPathingRequest(_localPlayerCharacterView, _currentTarget, pathing);
                }
                else
                {
                    if (DateTime.Now > notMovingTimer)
                    {
                        isMovingUpdate();
                    }
                    else
                    {
                        Core.Log("Harvest not moving check 1. Going to random location");
                        _localPlayerCharacterView.RequestMove(playerCenter + new Vector3(UnityEngine.Random.Range(-100f, 100f), 0, UnityEngine.Random.Range(-100f, 100f)));
                    }

                    if (!IsMoving)
                    {
                        notMovingTimer = DateTime.Now + TimeSpan.FromSeconds(2);
                    }


                    Core.Log("Path not found");
                    _state.Fire(Trigger.DepletedResource);
                }
                return;
            }

            if (_localPlayerCharacterView.IsHarvesting())
            {
                return;
            }

            if (resource.GetHarvestableObject().GetCharges() <= 0)
            {
                _state.Fire(Trigger.DepletedResource);
                return;
            }
            Core.Log("[Harvesting]");

            _localPlayerCharacterView.Interact(resource);

            if (DateTime.Now > notMovingTimer)
            {
                isMovingUpdate();
            }
            else
            {
                Core.Log("Harvest not moving check 2. Going to random location");
                _localPlayerCharacterView.RequestMove(playerCenter + new Vector3(UnityEngine.Random.Range(-100f, 100f), 0, UnityEngine.Random.Range(-100f, 100f)));
            }

            if (!IsMoving)
            {
                notMovingTimer = DateTime.Now + TimeSpan.FromSeconds(2);
            }


            var harvestableObject2 = resource.GetHarvestableObject();

            var resourceType     = harvestableObject2.GetResourceType().Value;
            var tier             = (Tier)harvestableObject2.GetTier();
            var enchantmentLevel = (EnchantmentLevel)harvestableObject2.GetRareState();

            var info = new GatherInformation(resourceType, tier, enchantmentLevel)
            {
                HarvestDate = DateTime.UtcNow
            };

            var position = resource.transform.position.c();

            if (_gatheredSpots.ContainsKey(position))
            {
                _gatheredSpots[position] = info;
            }
            else
            {
                _gatheredSpots.Add(position, info);
            }
        }