Beispiel #1
0
    /// <summary>
    /// Resizes the instance list for a given pool (in case we need more instances that we expected)
    /// </summary>
    /// <param name="poolId">The id of the pool we want to resize.</param>
    private void resizePoolInstanceList(PoolIds poolId)
    {
        //Get the pool data and the prefab to instantiate
        PoolData   poolData = poolList[poolId];
        GameObject prefab   = poolData.instanceList[0].gameObject;

        //Calculate the new size and create the new array
        int newSize = Mathf.FloorToInt(poolData.numInstances * 1.20f);

        PoolInstance[] newInstanceList = new PoolInstance[newSize];

        //Move the references
        for (int i = 0; i < poolData.numInstances; i++)
        {
            newInstanceList[i] = poolData.instanceList[i];
        }
        //Create the new instances
        for (int i = poolData.numInstances; i < newSize; i++)
        {
            newInstanceList[i] = instantiatePoolInstance(prefab);
        }

        poolData.numInstances = newSize;
        poolData.instanceList = newInstanceList;
    }
Beispiel #2
0
    /// <summary>
    /// Removes all the instances in a pool
    /// </summary>
    /// <param name="poolId">Pool id.</param>
    private void removePool(PoolIds poolId)
    {
        PoolData poolData = poolList[poolId];

        for (int i = 0; i < poolData.numInstances; i++)
        {
            GameObject.Destroy(poolData.instanceList[i].gameObject);
        }
    }
Beispiel #3
0
    /// <summary>
    /// Creates a new pool
    /// </summary>
    /// <param name="poolId">The Pool id.</param>
    /// <param name="prefab">The prefab to instantiate all the instances.</param>
    /// <param name="numInstances">Number of instances.</param>
    public void createPool(PoolIds poolId, GameObject prefab, int numInstances)
    {
        PoolData poolData = new PoolData();

        poolData.numInstances = numInstances;
        poolData.instanceList = new PoolInstance[numInstances];

        for (int i = 0; i < numInstances; i++)
        {
            poolData.instanceList[i] = instantiatePoolInstance(prefab);
        }

        poolList.Add(poolId, poolData);
    }
Beispiel #4
0
    /// <summary>
    /// Retrieve an instance that it is not being used from an specific pool
    /// </summary>
    /// <returns>The pool instance.</returns>
    /// <param name="poolId">Pool id.</param>
    public PoolInstance retrievePoolInstance(PoolIds poolId)
    {
        PoolData poolData = poolList[poolId];

        //Start from the last instance index and iterate through all the instances
        for (int i = poolData.instanceIndex; i < poolData.instanceIndex + poolData.numInstances; i++)
        {
            int index = (i < poolData.numInstances) ? i : i % poolData.numInstances;
            if (!poolData.instanceList[index].isAlive)
            {
                //Revive the instance and store the index as the last instance used
                poolData.instanceList[index].revive();
                poolData.instanceIndex = index;

                return(poolData.instanceList[index]);
            }
        }

        //If there are no more instances available, resize the pool and log a warning (so we know we need to make the pool bigger)
        resizePoolInstanceList(poolId);
        Debug.LogWarning("There are no instances availables in " + poolId + " (Resizing pool)");

        return(retrievePoolInstance(poolId));
    }
        public MrFishIt(Dictionary <string, string> args)
            : base(args)
        {
            QBCLog.BehaviorLoggingContext = this;

            try
            {
                ParseWaypoints();

                var fishingPoint =
                    GetAttributeAsNullable <Vector3>("", WayPoints.Count == 0, ConstrainAs.Vector3NonEmpty, null) ??
                    Vector3.Zero;
                if (fishingPoint != Vector3.Zero)
                {
                    WayPoints.Add(fishingPoint);
                }

                CollectItemId = GetAttributeAsNullable <int>("CollectItemId", false, ConstrainAs.ItemId, null) ?? 0;
                var collectItemCountExpression = GetAttributeAs("CollectItemCount", false, ConstrainAs.StringNonEmpty,
                                                                null);
                CollectItemCountCompiledExpression =
                    Utility.ProduceParameterlessCompiledExpression <int>(collectItemCountExpression);
                CollectItemCount = Utility.ProduceCachedValueFromCompiledExpression(CollectItemCountCompiledExpression,
                                                                                    1);

                bool circlePathing = GetAttributeAsNullable <bool>("CirclePathing", false, null, null) ?? true;
                PoolIds         = GetAttributeAsArray <uint>("PoolIds", false, null, new[] { "PoolId" }, null);
                _fishingProfile = new FishingBuddyProfile(WayPoints,
                                                          circlePathing ? PathingType.Circle : PathingType.Bounce, PoolIds.ToList());


                _fishingLogic = new FishingLogic(
                    // Wowhead Id of the mainhand weapon to switch to when in combat
                    mainHandItemId: GetAttributeAsNullable <uint>("MainHand", false, null, null) ?? 0,
                    // Wowhead Id of the offhand weapon to switch to when in combat
                    offHandItemId: GetAttributeAsNullable <uint>("OffHand", false, null, null) ?? 0,
                    // Wowhead Id of the hat to switch to when not fishing
                    headItemId: GetAttributeAsNullable <uint>("Hat", false, null, null) ?? 0,
                    // Set this to true if you want to fish from pools, otherwise set to false.
                    poolFishing: _fishingProfile.WayPoints.Count > 1 || (GetAttributeAsNullable <bool>("MoveToPool", false, null, null) ?? false),
                    // GetAttributeAsNullable<bool>("Poolfishing", false, null, null) ?? false;
                    // If set to true bot will attempt to loot any dead lootable NPCs
                    lootNPCs: GetAttributeAsNullable <bool>("LootNPCs", false, null, null) ?? false,
                    // Set to true to enable flying, false to use ground based navigation
                    useFlying: GetAttributeAsNullable <bool>("Fly", false, null, null) ?? true,
                    // If set to true bot will use water walking, either class abilities or pots
                    useWaterWalking: GetAttributeAsNullable <bool>("UseWaterWalking", false, null, null) ?? true,
                    // If set to true, bot will try to avoid landing in lava. Some pools by floating objects such as ice floes will get blacklisted if this is set to true
                    avoidLava: GetAttributeAsNullable <bool>("AvoidLava", false, null, null) ?? false,
                    // If set to true bot will 'ninja' nodes from other players.
                    ninjaNodes: GetAttributeAsNullable <bool>("NinjaNodes", false, null, null) ?? false,
                    // If set to true bot will automatically apply fishing baits6s
                    useBait: GetAttributeAsNullable <bool>("UseBait", false, null, null) ?? true,
                    // Which bait to prefer (item id). If not found, other baits will be used.
                    useBaitPreference: GetAttributeAsNullable <uint>("UseBaitPreference", false, null, new[] { "BaitId" }) ?? 0,
                    // If set to true bot will automatically fillet fish
                    filletFish: GetAttributeAsNullable <bool>("FilletFish", false, null, null) ?? false,
                    // The maximum time in minutes to spend at a pool before it gets blacklisted
                    maxTimeAtPool: GetAttributeAsNullable <int>("MaxTimeAtPool", false, null, null) ?? 5,
                    // The maximum number of failed casts at a pool before moving to a new location at pool
                    maxFailedCasts: GetAttributeAsNullable <int>("MaxFailedCasts", false, null, null) ?? 15,
                    // When bot is within this distance from current hotspot then it cycles to next hotspot. flymode only
                    pathPrecision: GetAttributeAsNullable <float>("PathPrecision", false, null, null) ?? 15f,
                    // Number of tracelines to do in a 360 deg area. the higher the more likely to find a landing spot.recomended to set at a multiple of 20
                    traceStep: GetAttributeAsNullable <int>("TraceStep", false, null, null) ?? 40,
                    // Each time bot fails to find a landing spot it adds this number to the range and tries again until it hits MaxPoolRange. Can use decimals.
                    poolRangeStep: GetAttributeAsNullable <float>("PoolRangeStep", false, null, null) ?? .5f
                    );
            }

            catch (Exception except)
            {
                // Maintenance problems occur for a number of reasons.  The primary two are...
                // * Changes were made to the behavior, and boundary conditions weren't properly tested.
                // * The Honorbuddy core was changed, and the behavior wasn't adjusted for the new changes.
                // In any case, we pinpoint the source of the problem area here, and hopefully it
                // can be quickly resolved.
                QBCLog.Exception(except);
                IsAttributeProblem = true;
            }
        }