示例#1
0
        public virtual void dealDamageTo(Unit target, float damage, DamageType type, DamageSource source)
        {
            /* //F**k LUA
             * if (unitScript.isLoaded())
             * {
             *  try
             *  {
             *      //damage =
             *      unitScript.lua.get<sol::function>("onDealDamage").call<void>(target, damage, type, source);
             *  }
             *  catch (sol::error e)
             *  {
             *      CORE_ERROR("Error callback ondealdamage: %s", e.what());
             *  }
             * }*/


            float defense = 0;
            float regain  = 0;

            switch (type)
            {
            case DamageType.DAMAGE_TYPE_PHYSICAL:
                defense = target.getStats().getArmor();
                defense = ((1 - stats.getArmorPenPct()) * defense) - stats.getArmorPenFlat();

                break;

            case DamageType.DAMAGE_TYPE_MAGICAL:
                defense = target.getStats().getMagicArmor();
                defense = ((1 - stats.getMagicPenPct()) * defense) - stats.getMagicPenFlat();
                break;
            }

            switch (source)
            {
            case DamageSource.DAMAGE_SOURCE_SPELL:
                regain = stats.getSpellVamp();
                break;

            case DamageSource.DAMAGE_SOURCE_ATTACK:
                regain = stats.getLifeSteal();
                break;
            }

            //Damage dealing. (based on leagueoflegends' wikia)
            damage = defense >= 0 ? (100 / (100 + defense)) * damage : (2 - (100 / (100 - defense))) * damage;

            target.getStats().setCurrentHealth(Math.Max(0.0f, target.getStats().getCurrentHealth() - damage));
            if (!target.deathFlag && target.getStats().getCurrentHealth() <= 0)
            {
                target.deathFlag = true;
                target.die(this);
            }
            PacketNotifier.notifyDamageDone(this, target, damage, type);

            //Get health from lifesteal/spellvamp
            if (regain != 0)
            {
                stats.setCurrentHealth(Math.Min(stats.getMaxHealth(), stats.getCurrentHealth() + (regain * damage)));
                PacketNotifier.notifyUpdatedStats(this);
            }
        }
示例#2
0
        public virtual void dealDamageTo(Unit target, float damage, DamageType type, DamageSource source)
        {

            /* //F**k LUA
            if (unitScript.isLoaded())
            {
                try
                {
                    //damage = 
                    unitScript.lua.get<sol::function>("onDealDamage").call<void>(target, damage, type, source);
                }
                catch (sol::error e)
                {
                    CORE_ERROR("Error callback ondealdamage: %s", e.what());
                }
            }*/


            float defense = 0;
            float regain = 0;
            switch (type)
            {
                case DamageType.DAMAGE_TYPE_PHYSICAL:
                    defense = target.getStats().getArmor();
                    defense = ((1 - stats.getArmorPenPct()) * defense) - stats.getArmorPenFlat();

                    break;
                case DamageType.DAMAGE_TYPE_MAGICAL:
                    defense = target.getStats().getMagicArmor();
                    defense = ((1 - stats.getMagicPenPct()) * defense) - stats.getMagicPenFlat();
                    break;
            }

            switch (source)
            {
                case DamageSource.DAMAGE_SOURCE_SPELL:
                    regain = stats.getSpellVamp();
                    break;
                case DamageSource.DAMAGE_SOURCE_ATTACK:
                    regain = stats.getLifeSteal();
                    break;
            }

            //Damage dealing. (based on leagueoflegends' wikia)
            damage = defense >= 0 ? (100 / (100 + defense)) * damage : (2 - (100 / (100 - defense))) * damage;

            target.getStats().setCurrentHealth(Math.Max(0.0f, target.getStats().getCurrentHealth() - damage));
            if (!target.deathFlag && target.getStats().getCurrentHealth() <= 0)
            {
                target.deathFlag = true;
                target.die(this);
            }
            PacketNotifier.notifyDamageDone(this, target, damage, type);

            //Get health from lifesteal/spellvamp
            if (regain != 0)
            {
                stats.setCurrentHealth(Math.Min(stats.getMaxHealth(), stats.getCurrentHealth() + (regain * damage)));
                PacketNotifier.notifyUpdatedStats(this);
            }
        }