Search Unity

  1. Good news ✨ We have more Unite Now videos available for you to watch on-demand! Come check them out and ask our experts any questions!
    Dismiss Notice

Giving an item modifiers

Discussion in 'Scripting' started by calmcarrots, Jun 15, 2015.

  1. calmcarrots

    calmcarrots

    Joined:
    Mar 7, 2014
    Posts:
    681
    So how exactly do I give an item a modifier? I created an item generator that generates either armor or weaponry. Each item has a level and a rarity value. How exactly do I code it so that they can have a random amount of modifiers?

    For example, armor modifiers can do all of the following:
    Health regen mod, armor boost, vitality / intelligence boost, mana regen
    Weapon mods can have:
    Fire damage, shock dmg, ice dmg, and strength boosts

    I have variables that hold all these values so that I can add it to the player stats class. Also, the rarity values go:
    Legendary (4), Rare (3), Special (2), Uncommon (1), Common (0)

    The more rare it is, the more mods it has and the more effective they are. How do I randomly pick these mods for each item based on rarity?
     
  2. GroZZleR

    GroZZleR

    Joined:
    Feb 1, 2015
    Posts:
    2,205
    Create an Enum of modifiers and give each Item a List<> of them? Then you could add modifiers to the list at item creation.
     
unityunity