Beispiel #1
0
    //Sets the values of this class for reference later on
    public void SetCombatStats(RPGClass Unit)
    {
        //RPGClass Unit = GetComponent<RPGClass>();

        EquipedWeapon = EquipWeapon(Unit.Inventory, Unit.WeaponStats);
        Health        = Unit.Stats[(int)RPGClass.Stat.HitPoints].dynamicValue;
        Stress        = Unit.Stats[(int)RPGClass.Stat.StressPoints].dynamicValue;

        int[] temp = CalculateCombatStats(Unit.Stats, Unit.WeaponStats, EquipedWeapon);
        Attack      = temp[0];
        HitChance   = temp[1];
        CritChance  = temp[2];
        Dodge       = temp[3];
        AttackSpeed = temp[4];
        DamageType  = (Weapons.Damage)temp[5];
        Defense     = temp[6];
        Resistance  = temp[7];

        CriticalDodge = Unit.Stats[(int)RPGClass.Stat.Luck].dynamicValue;
    }
Beispiel #2
0
    //calculate stats that will get passed onto the combat system
    int[] CalculateCombatStats(RPGClass.ClassStats[] UnitStats, RPGClass.ClassWeapons[] WeaponProficencies, Weapons Weapon)
    {
        //Declare some of the final stats that will get passed on.
        int attack = 0, hitChance = 0, critChance = 0, dodgeChance = 0, attackSpeed = 0;

        //Find the Equiped Weapon
        //Weapons EquipedWeapon = EquipWeapon(Inventory, WeaponProficencies);

        //Return Unarmed Here if Applicable

        //Pull Stats from Character
        int Strength = UnitStats[(int)RPGClass.Stat.Strength].dynamicValue;
        int Magic    = UnitStats[(int)RPGClass.Stat.Magic].dynamicValue;
        int Speed    = UnitStats[(int)RPGClass.Stat.Speed].dynamicValue;
        int Skill    = UnitStats[(int)RPGClass.Stat.Skill].dynamicValue;
        int Luck     = UnitStats[(int)RPGClass.Stat.Luck].dynamicValue;
        int Bulk     = UnitStats[(int)RPGClass.Stat.Bulk].dynamicValue;

        Weapons.Rank WeaponSkill = WeaponProficencies[(int)Weapon.WeaponCategory].WeaponRank;


        //Do calculations to determine the final stats
        //Determine attack Speed
        attackSpeed = Speed;
        if (Bulk < Weapon.Weight)
        {
            attackSpeed += (Bulk - Weapon.Weight);
        }

        //Determine Weapon Bonuses
        int[] bonuses = GetWeaponBonuses(Weapon.WeaponCategory, WeaponSkill);

        //Determine Hit, Crit, and Dodge Chances
        hitChance   = (Skill * 2) + (Luck / 2) + Weapon.HitChance;
        critChance  = (Skill * 2) + (Luck / 4) + Weapon.CritChance;
        dodgeChance = (attackSpeed * 2) + Luck;

        //Determine Damage and Damage Type
        Weapons.Damage damageType = Weapon.DamageType;
        if (DamageType == Weapons.Damage.Physical)
        {
            attack = Strength + Weapon.Might;
        }
        else if (DamageType == Weapons.Damage.Magical)
        {
            attack = Magic + Weapon.Might;
        }

        //Apply Bonuses
        attack    += bonuses[0];
        hitChance += bonuses[1];

        //Grab Defenses
        int defense    = UnitStats[(int)RPGClass.Stat.Defense].dynamicValue;
        int resistance = UnitStats[(int)RPGClass.Stat.Resistance].dynamicValue;

        //Return Results
        return(new int[8] {
            attack, hitChance, critChance, dodgeChance, attackSpeed, (int)damageType, defense, resistance
        });
    }
        public CombatStats(RPGClass Unit, Weapons Weapon)
        {
            //Set up stuff from parameters
            UnitReference = Unit;
            EquipedWeapon = Weapon;

            //Rip stats from unit
            Health        = Unit.Stats[(int)Stat.HitPoints].dynamicValue;
            Stress        = Unit.Stats[(int)Stat.StressPoints].dynamicValue;
            Defense       = Unit.Stats[(int)Stat.Defense].dynamicValue;
            Resistance    = Unit.Stats[(int)Stat.Resistance].dynamicValue;
            CriticalDodge = Unit.Stats[(int)Stat.Luck].dynamicValue;

            if (EquipedWeapon == null)
            {
                DamageType  = Weapons.Damage.Physical;
                HitChance   = CritChance = Attack = 0;
                AttackSpeed = Unit.Stats[(int)Stat.Speed].dynamicValue;
                Dodge       = (AttackSpeed * 2) + Unit.Stats[(int)Stat.Luck].dynamicValue;
            }
            else
            {
                DamageType = Weapon.DamageType;

                //Calculate Hit and Crit Chance
                HitChance  = (Unit.Stats[(int)Stat.Skill].dynamicValue * 2) + (Unit.Stats[(int)Stat.Luck].dynamicValue / 2) + Weapon.HitChance;
                CritChance = (Unit.Stats[(int)Stat.Skill].dynamicValue * 2) + (Unit.Stats[(int)Stat.Luck].dynamicValue / 4) + Weapon.CritChance;

                //Calculate Damage, Physical attacks use strength while magical attacks use magic
                if (DamageType == Weapons.Damage.Physical)
                {
                    Attack = Unit.Stats[(int)Stat.Strength].dynamicValue + Weapon.Might;
                }
                else if (DamageType == Weapons.Damage.Magical)
                {
                    Attack = Unit.Stats[(int)Stat.Magic].dynamicValue + Weapon.Might;
                }
                else
                {
                    Attack = 0;
                }

                //If a weapon is too heavy, give a penalty to speed. Otherwise, just use speed
                if (Unit.Stats[(int)Stat.Bulk].dynamicValue < Weapon.Weight)
                {
                    AttackSpeed = Unit.Stats[(int)Stat.Speed].dynamicValue + (Unit.Stats[(int)Stat.Bulk].dynamicValue - Weapon.Weight);
                }
                else
                {
                    AttackSpeed = Unit.Stats[(int)Stat.Speed].dynamicValue;
                }

                //Determine Dodge based off of the (potentially) modified speed stat
                Dodge = (AttackSpeed * 2) + Unit.Stats[(int)Stat.Luck].dynamicValue;

                //Determine Weapon Bonuses, Reward some combination of extra damage or hit damage
                //Check Weapon type first as different bonuses are rewarded to different weapons. Then Check weapon rank, higher rank = better bonus
                Weapons.Rank CharacterWeaponRank = Unit.WeaponStats[(int)Weapon.WeaponCategory].WeaponRank;
                switch (Weapon.WeaponCategory)
                {
                case (Weapons.WeaponType.Sword):
                case (Weapons.WeaponType.Staff):
                    switch (CharacterWeaponRank)
                    {
                    case (Weapons.Rank.C): Attack += 1; break;

                    case (Weapons.Rank.B): Attack += 2; break;

                    case (Weapons.Rank.A):
                    case (Weapons.Rank.S): Attack += 3; break;
                    }
                    break;

                case (Weapons.WeaponType.Lance):
                case (Weapons.WeaponType.Bow):
                case (Weapons.WeaponType.Arcane):
                case (Weapons.WeaponType.Divine):
                case (Weapons.WeaponType.Occult):
                    switch (CharacterWeaponRank)
                    {
                    case (Weapons.Rank.C): Attack += 1; break;

                    case (Weapons.Rank.B): Attack += 1; HitChance += 5; break;

                    case (Weapons.Rank.A):
                    case (Weapons.Rank.S): Attack += 2; HitChance += 5; break;
                    }
                    break;

                case (Weapons.WeaponType.Axe):
                    switch (CharacterWeaponRank)
                    {
                    case (Weapons.Rank.C): HitChance += 5; break;

                    case (Weapons.Rank.B): HitChance += 10; break;

                    case (Weapons.Rank.A):
                    case (Weapons.Rank.S): HitChance += 15; break;
                    }
                    break;
                }
            }
        }