Forum begins after the advertisement:


[Part 15/16] New weapon system

Viewing 6 posts - 1 through 6 (of 6 total)
  • Author
    Posts
  • #13327
    Kai
    Level 12
    Participant
    Helpful?
    Up
    0
    ::

    So I’ve been playing around with the new weapon system and I came across some bugs. I don’t know it’s just me or everyone but:
    -New Player Inventory system:
    Player can have up to 6 weapons and if the number of available weapons (weapon data) are 7 or more, new weapon will show up when player already have 6 weapons in the inventory and it’s unclickable (because i already have 6 wps)

    -Random growth is stacking up stats. For example I have knife(max lv8) 1-5 is linear and 5a, 5b, 5c is random growth. Stats from them will stack if upgrades pop up as 5c (stats in 5c will become 5a+5b+5c instead)

    #13328
    Terence
    Level 30
    Keymaster
    Helpful?
    Up
    0
    ::

    Hi Kai, thanks for the heads up. Let me look into this and get back to you.

    #13340
    Kai
    Level 12
    Participant
    Helpful?
    Up
    0
    ::

    My bad on the first one, I set the weapon slots and passive slots to 6 (i don’t remember how), but still, new weapons show up when the weapon slots are full

    #13341
    Terence
    Level 30
    Keymaster
    Helpful?
    Up
    0
    ::

    Hi Kai, below is a quick temporary fix. I will be addressing this issue in Part 18 of the series.

        // Finds an empty slot and adds a weapon of a certain type, returns
        // the slot number that the item was put in.
        public int Add(WeaponData data)
        {
            int slotNum = -1;
    
            // Try to find an empty slot.
            for(int i = 0; i < weaponSlots.Capacity; i++)
            {
                if (weaponSlots[i].IsEmpty())
                {
                    slotNum = i;
                    break;
                }
            }
    
            // If there is no empty slot, exit.
            if (slotNum < 0) return slotNum;
            else if(slotNum > 5) return -1;
    
            // Otherwise create the weapon in the slot.
            // Get the type of the weapon we want to spawn.
            Type weaponType = Type.GetType(data.behaviour);
    
            if (weaponType != null)
            {
                // Spawn the weapon GameObject.
                GameObject go = new GameObject(data.baseStats.name + " Controller");
                Weapon spawnedWeapon = (Weapon)go.AddComponent(weaponType);
                spawnedWeapon.Initialise(data);
                spawnedWeapon.transform.SetParent(transform); //Set the weapon to be a child of the player
                spawnedWeapon.transform.localPosition = Vector2.zero;
                spawnedWeapon.OnEquip();
    
                // Assign the weapon to the slot.
                weaponSlots[slotNum].Assign(spawnedWeapon);
    
                // Close the level up UI if it is on.
                if (GameManager.instance != null && GameManager.instance.choosingUpgrade)
                    GameManager.instance.EndLevelUp();
    
                return slotNum;
            }
            else
            {
                Debug.LogWarning(string.Format(
                    "Invalid weapon type specified for {0}.",
                    data.name
                ));
            }
    
            return -1;
        }
    #16149
    Kai
    Level 12
    Participant
    Helpful?
    Up
    0
    ::

    Hi, I was wrong about random growth stacking stats, what actually happened was the description didn’t match the stats in random growth array. I am using random growth for every weapon levelup (level 1 to 8)

    My weapon set up:

    View post on imgur.com

    #16154
    Terence
    Level 30
    Keymaster
    Helpful?
    Up
    0
    ::

    Thank you for sharing this Kai.

Viewing 6 posts - 1 through 6 (of 6 total)
  • You must be logged in to reply to this topic.

Go to Login Page →


Advertisement below: