Attributes

You are here:
← All Topics
Version: 2019.201 Requirements:uMMORPG3d, ToolsScript Define: _IMMOATTRIBUTES
Core Changes:YesTutorial Video:Yes

Description

Adds new, configureable Attributes to uMMORPG:

  • Accuracy: Increases the chance to inflict a buff on the target (a negative buff in this case like “Poison”)
  • Resistance: Increases the chance to resist a buff being applied on self (a negative buff in this case like “Poison”)
  • Critical Factor: Increases the damage of critical hits (should be like 1.5 by default = 150%)
  • Block Factor: Increases the potency of blocking (should be around 0.5 by default = 50%)
  • Drain Health Factor: Drains health based on the damage dealt (0.5 = 50% of damage dealt is healed to own health)
  • Drain Mana Factor: Drains mana based on the damage dealt (0.5 = 50% of damage dealt is healed to own mana)
  • Reflect Damage Factor: Reflects damage based on damage received (0.5 = 50% of damage received is reflected back on attacker)
  • Defense Break Factor: Reduces the targets defense (0.5 = 50% defense reduction)
  • Block Break Factor: Reduces the targets chance to block (0.5 = 50% block rate reduction)
  • Critical Evasion: Reduces the chance to receive a critical hit (0.5 = 50% crit chance reduction)

Core Changes

  1. [Required] Open the following script Entity.cs. See Changes...

    Comment Out/Delete this section:
    	// combat //////////////////////////////////////////////////////////////////
        // deal damage at another entity
        // (can be overwritten for players etc. that need custom functionality)
        [Server]
        public virtual void DealDamageAt(Entity entity, int amount, float stunChance=0, float stunTime=0)
        {
            int damageDealt = 0;
            DamageType damageType = DamageType.Normal;
    
            // don't deal any damage if entity is invincible
            if (!entity.invincible)
            {
                // block? (we use < not <= so that block rate 0 never blocks)
                if (UnityEngine.Random.value < entity.blockChance)
                {
                    damageType = DamageType.Block;
                }
                // deal damage
                else
                {
                    // subtract defense (but leave at least 1 damage, otherwise
                    // it may be frustrating for weaker players)
                    damageDealt = Mathf.Max(amount - entity.defense, 1);
    
                    // critical hit?
                    if (UnityEngine.Random.value < criticalChance)
                    {
                        damageDealt *= 2;
                        damageType = DamageType.Crit;
                    }
    
                    // deal the damage
                    entity.health -= damageDealt;
    
                    // stun?
                    if (UnityEngine.Random.value < stunChance)
                    {
                        // dont allow a short stun to overwrite a long stun
                        // => if a player is hit with a 10s stun, immediately
                        //    followed by a 1s stun, we don't want it to end in 1s!
                        double newStunEndTime = NetworkTime.time + stunTime;
                        entity.stunTimeEnd = Math.Max(newStunEndTime, stunTimeEnd);
                    }
                }
            }
    
            // let's make sure to pull aggro in any case so that archers
            // are still attacked if they are outside of the aggro range
            entity.OnAggro(this);
    
            // show effects on clients
            entity.RpcOnDamageReceived(damageDealt, damageType);
    
            // reset last combat time for both
            lastCombatTime = NetworkTime.time;
            entity.lastCombatTime = NetworkTime.time;
    
            // addon system hooks
            Utils.InvokeMany(typeof(Entity), this, "DealDamageAt_", entity, amount);
        }
  2. [Required] Open the following script Player.cs. See Changes...

    Comment Out/Delete this section:
    	// health
        public override int healthMax
        {
            get
            {
                // calculate equipment bonus
                int equipmentBonus = (from slot in equipment
                                      where slot.amount > 0
                                      select ((EquipmentItem)slot.item.data).healthBonus).Sum();
    
                // calculate strength bonus (1 strength means 1% of hpMax bonus)
                int attributeBonus = Convert.ToInt32(_healthMax.Get(level) * (strength * 0.01f));
    
                // base (health + buff) + equip + attributes
                return base.healthMax + equipmentBonus + attributeBonus;
            }
        }
  3. [Required] Open the following script Player.cs. See Changes...

    Comment Out/Delete this section:
     	// mana
        public override int manaMax
        {
            get
            {
                // calculate equipment bonus
                int equipmentBonus = (from slot in equipment
                                      where slot.amount > 0
                                      select ((EquipmentItem)slot.item.data).manaBonus).Sum();
    
                // calculate intelligence bonus (1 intelligence means 1% of hpMax bonus)
                int attributeBonus = Convert.ToInt32(_manaMax.Get(level) * (intelligence * 0.01f));
    
                // base (mana + buff) + equip + attributes
                return base.manaMax + equipmentBonus + attributeBonus;
            }
        }
  4. [Required] Open the following script Player.cs. See Changes...

    Comment Out/Delete this section:
    	// damage
        public override int damage
        {
            get
            {
                // calculate equipment bonus
                int equipmentBonus = (from slot in equipment
                                      where slot.amount > 0
                                      select ((EquipmentItem)slot.item.data).damageBonus).Sum();
    
                // return base (damage + buff) + equip
                return base.damage + equipmentBonus;
            }
        }
  5. [Required] Open the following script Player.cs. See Changes...

    Comment Out/Delete this section:
    	// defense
        public override int defense
        {
            get
            {
                // calculate equipment bonus
                int equipmentBonus = (from slot in equipment
                                      where slot.amount > 0
                                      select ((EquipmentItem)slot.item.data).defenseBonus).Sum();
    
                // return base (defense + buff) + equip
                return base.defense + equipmentBonus;
            }
        }
  6. [Required] Open the following script Player.cs. See Changes...

    Comment Out/Delete this section:
    	// block
        public override float blockChance
        {
            get
            {
                // calculate equipment bonus
                float equipmentBonus = (from slot in equipment
                                        where slot.amount > 0
                                        select ((EquipmentItem)slot.item.data).blockChanceBonus).Sum();
    
                // return base (blockChance + buff) + equip
                return base.blockChance + equipmentBonus;
            }
        }
  7. [Required] Open the following script Player.cs. See Changes...

    Comment Out/Delete this section:
    	// crit
        public override float criticalChance
        {
            get
            {
                // calculate equipment bonus
                float equipmentBonus = (from slot in equipment
                                        where slot.amount > 0
                                        select ((EquipmentItem)slot.item.data).criticalChanceBonus).Sum();
    
                // return base (criticalChance + buff) + equip
                return base.criticalChance + equipmentBonus;
            }
        }

Installation

  1. [Required]* Move the UCE Attributes folder to your projects resources folder.
    *Note: Don’t keep multiple resource folders or duplicate named items.
  2. [Required] Move the UCE Attributes folder to your projects resources folder.
  3. [Optional] Setup UCE Attribute settings through your project.
  4. [Required] Assign your UCE Attributes to your player prefabs.
  5. [Required] Deactivate your current CharacterInfo found in your scene hierarchy.
  6. [Required] Add all prefabs from the Prefabs folder to your scene hierarchy.
  7. [Required] Assign your new CharacterInfoPanel to your Shortcuts in your scene hierarchy.

Screenshots


Video


Extras

  • Delete your database and create new characters after setup as this fully replaces the built-in attribute system.

  • If your Critical Hits deal no damage anymore, make sure to increase the Critical Factor on the Entity as its 0 by default

Support the IndieMMO Team Today!

Leave a reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.