Ejemplo n.º 1
0
        /// <summary>
        /// Immune to [damage type]
        /// or
        /// [Resist / Vulnerable] N [damage type]
        /// </summary>
        /// <returns></returns>
        public override string ToString()
        {
            if (fValue == 0)
            {
                return("Immune to " + fType.ToString().ToLower());
            }

            string header = (fValue < 0) ? "Resist" : "Vulnerable";
            int    val    = Math.Abs(fValue);

            return(header + " " + val + " " + fType.ToString().ToLower());
        }
Ejemplo n.º 2
0
    private void DebugHurt(HitInfo info)
    {
        if (!ConVar.Vis.damage)
        {
            return;
        }
        if (info.PointStart != info.PointEnd)
        {
            ConsoleNetwork.BroadcastToAllClients("ddraw.arrow", 60, Color.cyan, info.PointStart, info.PointEnd, 0.1f);
            ConsoleNetwork.BroadcastToAllClients("ddraw.sphere", 60, Color.cyan, info.HitPositionWorld, 0.01f);
        }
        string text = "";

        for (int i = 0; i < info.damageTypes.types.Length; i++)
        {
            float num = info.damageTypes.types[i];
            if (num != 0f)
            {
                string[] obj = new string[5] {
                    text, " ", null, null, null
                };
                DamageType damageType = (DamageType)i;
                obj[2] = damageType.ToString().PadRight(10);
                obj[3] = num.ToString("0.00");
                obj[4] = "\n";
                text   = string.Concat(obj);
            }
        }
        string text2 = string.Concat("<color=lightblue>Damage:</color>".PadRight(10), info.damageTypes.Total().ToString("0.00"), "\n<color=lightblue>Health:</color>".PadRight(10), health.ToString("0.00"), " / ", (health - info.damageTypes.Total() <= 0f) ? "<color=red>" : "<color=green>", (health - info.damageTypes.Total()).ToString("0.00"), "</color>", "\n<color=lightblue>HitEnt:</color>".PadRight(10), this, "\n<color=lightblue>HitBone:</color>".PadRight(10), info.boneName, "\n<color=lightblue>Attacker:</color>".PadRight(10), info.Initiator, "\n<color=lightblue>WeaponPrefab:</color>".PadRight(10), info.WeaponPrefab, "\n<color=lightblue>Damages:</color>\n", text);

        ConsoleNetwork.BroadcastToAllClients("ddraw.text", 60, Color.white, info.HitPositionWorld, text2);
    }
Ejemplo n.º 3
0
    public override string ReplaceString(Character caster, string s)
    {
        if (caster.GetType() == typeof(Hero))
        {
            var hero = caster as Hero;

            var color = Colors.HexByDamageType(type);

            if (s.Contains(DmgPercentageString))
            {
                s = s.Replace(DmgPercentageString, $"<color={color}>{(int)(hero.MinPhysicalDamage * damagePercentage)} - {(int)(hero.MaxPhysicalDamage * damagePercentage)} {type} Damage</color>");
            }

            if (s.Contains(ConditionValueString))
            {
                s = s.Replace(ConditionValueString, $"if Life is lower than {conditionValue * 100} %");
            }

            if (s.Contains("_dmgValue_"))
            {
                s = s.Replace("_dmgValue_", $"<color={color}>{(int)(hero.MinPhysicalDamage * damagePercentage)} - {(int)(hero.MaxPhysicalDamage * damagePercentage)}</color>");
            }

            if (s.Contains("_dmgType_"))
            {
                s = s.Replace("_dmgType_", $"<color={color}>{type.ToString()}</color>");
            }
        }
        return(s);
    }
Ejemplo n.º 4
0
    public void TakeDamage(float amount, DamageType damageType)
    {
        EventManager.TriggerEvent("playerattack");
        if (damageType.ToString() == armor.ToString())
        {
            float reducedAmount = 0;
            if (armorValue != 0)
            {
                Debug.Log("Before Armor Reduction" + amount);
                reducedAmount = (amount * armorValue) / 100;
            }
            amount -= reducedAmount;
            Debug.Log("After Armor Reduction" + amount);
        }
        damaged = true;
        damage  = amount;
        EventManager.TriggerEvent("playerdamage");
        currentHealth -= amount;

        healthSlider.value = currentHealth;

        playerAudio.Play();

        if (currentHealth <= 0 && !isDead)
        {
            Death();
        }
    }
Ejemplo n.º 5
0
    // =================================================================================== //
    // take damage and check for death
    public void TakeDamage(int amount, DamageType damageType)
    {
        // remove from hit points
        Stats[Stat.HIT_POINTS] -= amount;

        // if finish hit points - remove from hearts & init the hp
        if (Stats[Stat.HIT_POINTS] <= 0)
        {
            Stats[Stat.HIT_POINTS] = Stats[Stat.MAX_HIT_POINTS];
            Stats[Stat.HEARTS]--;
        }

        Debug.Log(name + " got " + amount.ToString() + " " + damageType.ToString() + "damage");

        // kill if not alive
        if (!IsAlive)
        {
            if (isPartyMember)
            {
                dieAsPartyMember();
            }
            else
            {
                dieAsCreature();
            }
        }
    }
Ejemplo n.º 6
0
        /// <summary>
        /// Immume to [damage type]
        /// or
        /// [Resist / Vulnerable] HH / PP / EE [damage type]
        /// </summary>
        /// <returns></returns>
        public override string ToString()
        {
            int total_mod = fHeroicValue + fParagonValue + fEpicValue;

            if (total_mod == 0)
            {
                return("Immune to " + fType.ToString().ToLower());
            }

            string header  = (fHeroicValue < 0) ? "Resist" : "Vulnerable";
            int    heroic  = Math.Abs(fHeroicValue);
            int    paragon = Math.Abs(fParagonValue);
            int    epic    = Math.Abs(fEpicValue);

            return(header + " " + heroic + " / " + paragon + " / " + epic + " " + fType.ToString().ToLower());
        }
Ejemplo n.º 7
0
    public virtual void DamageSide(Vector3 source, float damage, DamageType damageType)
    {
        Debug.Log(name + " received " + damageType.ToString() + " " + damage + " damage");

        const float cos45 = 0.70710678118f;         //sqrt(2)/2 = 0.70710678118

        Vector3 direction = transform.position - source;

        float cos = Vector3.Dot(transform.forward, direction.normalized);

        if (cos > cos45)
        {
            DamageBack(damage, damageType);
        }
        else
        if (cos < -cos45)
        {
            DamageFront(damage, damageType);
        }
        else
        {
            cos = Vector3.Dot(transform.right, direction.normalized);

            if (cos > cos45)
            {
                DamageLeft(damage, damageType);
            }
            else
            if (cos < -cos45)
            {
                DamageRight(damage, damageType);
            }
        }
    }
Ejemplo n.º 8
0
 public override void TakeDamage(int damage, DamageType damageType)
 {
     Debug.Log("I " + gameObject.name + "take damage by" + damageType.ToString());
     if (damageType == DamageType.DamageByGun)
     {
         m_deltaChangeInHealth += damage;
     }
 }
        public void Initialise()
        {
            // Load in the data from the provided attributes.
            Damage     = Attributes.GetInt("amount");
            DamageType = Attributes.GetEnum <DamageType>("type");

            // Generate the description based on damage and type.
            _desc = $"Deal {Damage} {DamageType.ToString().ToLower()} damage";
        }
Ejemplo n.º 10
0
        private void OnEntityTakeDamage(BaseCombatEntity entity, HitInfo hitInfo)
        {
            if (entity == null || hitInfo == null)
            {
                return;
            }

            if (entity is BuildingBlock)
            {
                BuildingBlock block = entity as BuildingBlock;
                if (block == null)
                {
                    return;
                }
                if (hitInfo.Initiator == null)
                {
                    return;
                }
                BasePlayer attacker = hitInfo.Initiator.ToPlayer();
                if (attacker == null)
                {
                    return;
                }


                if (block.LookupPrefab().name.Contains("foundation") && !IsOwner(attacker, block) && !CupboardPrivlidge(attacker, block.transform.position))
                {
                    if (!UseDamageScaling)
                    {
                        hitInfo.damageTypes  = new DamageTypeList();
                        hitInfo.DoHitEffects = false;
                        hitInfo.HitMaterial  = 0;
                        SendReply(attacker, lang.GetMessage("NoPerm", this, attacker.UserIDString));
                        return;
                    }
                    DamageType type = hitInfo.damageTypes.GetMajorityDamageType();
                    object     modifier;
                    float      mod = 0;
                    if (damageList.TryGetValue(type.ToString(), out modifier))
                    {
                        mod = Convert.ToSingle(modifier);
                        if (mod != 0)
                        {
                            hitInfo.damageTypes.Scale(type, mod);
                        }
                        else
                        {
                            hitInfo.damageTypes  = new DamageTypeList();
                            hitInfo.DoHitEffects = false;
                            hitInfo.HitMaterial  = 0;
                            SendReply(attacker, lang.GetMessage("NoPerm", this, attacker.UserIDString));
                        }
                    }
                }
            }
        }
Ejemplo n.º 11
0
        /// <summary>
        /// Get string representation of a <c>DamageType</c>.
        /// </summary>
        /// <param name="dt"></param>
        /// <returns>
        /// String representation of a <c>DamageType</c>.
        /// </returns>
        public static string GetString(this DamageType dt)
        {
            var name = dt.ToString();

            if (name == "Normal")
            {
                name = "Regular";
            }
            return(name);
        }
Ejemplo n.º 12
0
        public override string ToString()
        {
            string toString = Name + ", " + DamageType.ToString() + ", ";

            toString += AttackType.ToString() + ", ";
            toString += DieType.ToString() + ", ";
            toString += NumberOfDice.ToString() + ", ";
            toString += Modifier.ToString();

            return(toString);
        }
Ejemplo n.º 13
0
        /// <summary>
        /// Sample extension method.
        /// </summary>
        /// <returns>The type as string.</returns>
        /// <param name="type">Type.</param>
        public static string AsString(this DamageType type)
        {
            switch (type)
            {
            case DamageType.CUSTOM_1: return("VENGFUL");

            case DamageType.CUSTOM_2: return("MALOVENT");

            default: return(type.ToString());
            }
        }
    private void DebugHurt(HitInfo info)
    {
        if (!ConVar.Vis.damage)
        {
            return;
        }
        if (info.PointStart != info.PointEnd)
        {
            ConsoleNetwork.BroadcastToAllClients("ddraw.arrow", new object[] { 60, Color.cyan, info.PointStart, info.PointEnd, 0.1f });
            ConsoleNetwork.BroadcastToAllClients("ddraw.sphere", new object[] { 60, Color.cyan, info.HitPositionWorld, 0.01f });
        }
        string str = "";

        for (int i = 0; i < (int)info.damageTypes.types.Length; i++)
        {
            float single = info.damageTypes.types[i];
            if (single != 0f)
            {
                string[]   strArrays  = new string[] { str, " ", null, null, null };
                DamageType damageType = (DamageType)i;
                strArrays[2] = damageType.ToString().PadRight(10);
                strArrays[3] = single.ToString("0.00");
                strArrays[4] = "\n";
                str          = string.Concat(strArrays);
            }
        }
        object[] initiator = new object[18];
        initiator[0] = "<color=lightblue>Damage:</color>".PadRight(10);
        float single1 = info.damageTypes.Total();

        initiator[1]  = single1.ToString("0.00");
        initiator[2]  = "\n<color=lightblue>Health:</color>".PadRight(10);
        single1       = this.health;
        initiator[3]  = single1.ToString("0.00");
        initiator[4]  = " / ";
        initiator[5]  = (this.health - info.damageTypes.Total() <= 0f ? "<color=red>" : "<color=green>");
        single1       = this.health - info.damageTypes.Total();
        initiator[6]  = single1.ToString("0.00");
        initiator[7]  = "</color>";
        initiator[8]  = "\n<color=lightblue>HitEnt:</color>".PadRight(10);
        initiator[9]  = this;
        initiator[10] = "\n<color=lightblue>HitBone:</color>".PadRight(10);
        initiator[11] = info.boneName;
        initiator[12] = "\n<color=lightblue>Attacker:</color>".PadRight(10);
        initiator[13] = info.Initiator;
        initiator[14] = "\n<color=lightblue>WeaponPrefab:</color>".PadRight(10);
        initiator[15] = info.WeaponPrefab;
        initiator[16] = "\n<color=lightblue>Damages:</color>\n";
        initiator[17] = str;
        string str1 = string.Concat(initiator);

        ConsoleNetwork.BroadcastToAllClients("ddraw.text", new object[] { 60, Color.white, info.HitPositionWorld, str1 });
    }
Ejemplo n.º 15
0
    /// <summary>
    /// returns the damage efficency of given attack type on given armor type
    ///
    ///     Red (armor)	Blue (armor)	Yellow (armor)
    ///red    full       half            double
    ///blue   double     full            half
    ///yellow half       double          full
    ///
    ///  0 if type none
    ///
    /// </summary>
    /// <param name="dmgType"></param>
    /// <param name="armorType"></param>
    /// <returns></returns>
    public static float GetDamageTypeFactor(DamageType dmgType, DamageType armorType)
    {
        if (dmgType == DamageType.None || armorType == DamageType.None)
        {
            return(0f);
        }

        float ret = dmgEfficencyTable[(int)dmgType - 1, (int)armorType - 1];

        Debug.Log("dmg: " + dmgType.ToString() + " armor: " + armorType + " " + ret);
        return(ret);
    }
Ejemplo n.º 16
0
        public double GetDamageMultiplier(DamageType type)
        {
            string affectedStatName = type.ToString() + "_DAMAGE";
            var    value            = Stats[affectedStatName];

            if (value == 0)
            {
                return(1);
            }
            return(1 + (value / 100d));

            return(1);
        }
Ejemplo n.º 17
0
    public void Initialize(int damage, DamageType damageType)
    {
        if (isInitialized)
        {
            return;
        }
        isInitialized = true;

        string type = damageType.ToString().Substring(0, 1);

        if (damage < 0)
        {
            // min damage
            damage = 0;
        }
        if (damage >= Mathf.Pow(10, exponents.Count))
        {
            // max damage
            damage = Mathf.RoundToInt(Mathf.Pow(10, exponents.Count)) - 1;
        }

        if (damage == 0)
        {
            exp = 0;
            numbers[0][0].GetComponent <Image>().sprite =
                Resources.Load("DamageNumber/" + type + 0, typeof(Sprite)) as Sprite;
            numbers[0][0].SetActive(true);
            exponents[0].SetActive(true);
        }
        else
        {
            exp = (int)(Mathf.Log10(damage));
            for (int i = 0; i <= exp; i++)
            {
                GameObject g = numbers[exp][i];
                int        n = (damage % (int)Mathf.Pow(10, i + 1)) / (int)Mathf.Pow(10, i);

                g.GetComponent <Image>().sprite =
                    Resources.Load("DamageNumber/" + type + n, typeof(Sprite)) as Sprite;
                g.SetActive(true);
            }
            exponents[exp].SetActive(true);
        }

        if (damageType == DamageType.Critical)
        {
            criticalMarks[exp].SetActive(true);
        }

        StartCoroutine(Disappear());
    }
Ejemplo n.º 18
0
 public override void TakeDamage(int amount, DamageType type, BodyPartKind bodyPart)
 {
     body.TakeDamage(amount, type, bodyPart);
     AI?.RecieveTextMessage($"You take {amount} {type.ToString().ToLowerInvariant()} damage");
     if (!updatingBody && body.NeedsUpdate)
     {
         UpdateBody();
     }
     if (!body.Alive)
     {
         AI?.Die();
         Die();
     }
 }
Ejemplo n.º 19
0
    public override string ReplaceString(Character caster, string s)
    {
        if (caster.GetType() == typeof(Hero))
        {
            var hero = caster as Hero;

            var color = Colors.HexByDamageType(type);

            if (s.Contains("_dmgType_"))
            {
                s = s.Replace("_dmgType_", $"<color={color}>{type.ToString()}</color>");
            }
        }
        return(s);
    }
Ejemplo n.º 20
0
    public void modifyImmediate(int i, DamageType t)
    {
        Debug.Log("causing " + i + " damage of type :" + t.ToString());

        currentHealth += i;

        if (currentHealth > maxHealth)
        {
            currentHealth = maxHealth;
        }

        else if (currentHealth < 0)
        {
            currentHealth = 0;
        }
    }
Ejemplo n.º 21
0
        private decimal GetTypeModifier(DamageType damageType)
        {
            switch (damageType)
            {
            case Damage.Damage.DamageType.Acid:
                return(Race.Acid);

            case Damage.Damage.DamageType.Bludgeon:
                return(Race.Bludgeon);

            case Damage.Damage.DamageType.Cold:
                return(Race.Cold);

            case Damage.Damage.DamageType.Fire:
                return(Race.Fire);

            case Damage.Damage.DamageType.Force:
                return(Race.Force);

            case Damage.Damage.DamageType.Lightning:
                return(Race.Lightning);

            case Damage.Damage.DamageType.Necrotic:
                return(Race.Necrotic);

            case Damage.Damage.DamageType.Pierce:
                return(Race.Pierce);

            case Damage.Damage.DamageType.Poison:
                return(Race.Poison);

            case Damage.Damage.DamageType.Psychic:
                return(Race.Psychic);

            case Damage.Damage.DamageType.Radiant:
                return(Race.Radiant);

            case Damage.Damage.DamageType.Slash:
                return(Race.Slash);

            case Damage.Damage.DamageType.Thunder:
                return(Race.Thunder);

            default:
                throw new System.Exception("Unknown damage type " + damageType.ToString());
            }
        }
Ejemplo n.º 22
0
        public void takeDamage(DamageType damageType, double baseDamage)
        {
            double damageDealt = baseDamage;

            foreach (Chromosome c in chromosomes)
            {
                if (c.Type.ToString() == damageType.ToString())
                {
                    if (c.Increase)
                        damageDealt *= 0.5;
                    else
                        damageDealt *= 2;
                }
            }

            this.health -= (int)damageDealt;
        }
Ejemplo n.º 23
0
        public static I18NString Translate(DamageType damageType)
        {
            switch (damageType)
            {
            case DamageType.Chaos:
                return(I18N.Instance.Get("enum_damage_type_true"));

            case DamageType.Crushing:
                return(I18N.Instance.Get("enum_damage_type_crushing"));

            case DamageType.Slashing:
                return(I18N.Instance.Get("enum_damage_type_slashing"));

            case DamageType.Piercing:
                return(I18N.Instance.Get("enum_damage_type_piercing"));

            case DamageType.Fire:
                return(I18N.Instance.Get("enum_damage_type_fire"));

            case DamageType.Cold:
                return(I18N.Instance.Get("enum_damage_type_cold"));

            case DamageType.Holy:
                return(I18N.Instance.Get("enum_damage_type_holy"));

            case DamageType.Shadow:
                return(I18N.Instance.Get("enum_damage_type_shadow"));

            case DamageType.Arcane:
                return(I18N.Instance.Get("enum_damage_type_arcane"));

            case DamageType.Poison:
                return(I18N.Instance.Get("enum_damage_type_poison"));

            case DamageType.Health:
                return(I18N.Instance.Get("enum_damage_type_health"));

            case DamageType.Lightning:
                return(I18N.Instance.Get("enum_damage_type_lightning"));

            default:
                return(new I18NString(new I18NStringData(damageType.ToString())));
            }
        }
Ejemplo n.º 24
0
    // Behaviour of the object : setting its text, color, floating upper and disappear after a certain time
    private IEnumerator Behave(DamageType _type)
    {
        // Show the damage type as text
        text.text = _type.ToString();
        // Changes the color depending on the damage type
        switch (_type)
        {
        case DamageType.Cool:
            text.color = Color.grey;
            break;

        case DamageType.Great:
            text.color = Color.green;
            break;

        case DamageType.Super:
            text.color = Color.cyan;
            break;

        default:
            break;
        }

        float _lifeTimeTimer = lifeTime;

        // Change the alpha of the text and its position at each frame
        while (_lifeTimeTimer > 0)
        {
            transform.position += Vector3.up * 0.001f;
            text.alpha          = _lifeTimeTimer / lifeTime;

            _lifeTimeTimer -= Time.deltaTime;

            yield return(new WaitForEndOfFrame());
        }

        // After all of this, destroys this game object
        Destroy(gameObject);
        yield return(null);
    }
Ejemplo n.º 25
0
    public void TakeDamage(float amount, Vector3 hitPoint, DamageType damageType)
    {
        EventManager.TriggerEvent(enemyName + "attack");
        EvasionCalculator evC = new EvasionCalculator();

        if (isDead)
        {
            return;
        }
        if (evC.IsEvaded(evasionPercentage))
        {
            Debug.Log("Evasion is true");
            return;
        }
        if (damageType.ToString() == armorType.ToString())
        {
            float reducedAmount = 0;
            if (armorValue != 0)
            {
                Debug.Log("Before Armor Reduction" + amount);
                reducedAmount = (amount * armorValue) / 100;
            }
            amount -= reducedAmount;
            Debug.Log("After Armor Reduction" + amount);
        }

        damage = amount;
        enemyAudio.Play();
        EventManager.TriggerEvent(enemyName + "damage");
        currentHealth -= amount;

        healthSlider.value = currentHealth;
        hitParticles.transform.position = hitPoint;
        hitParticles.Play();

        if (currentHealth <= 0)
        {
            Death();
        }
    }
Ejemplo n.º 26
0
        private void OnEntityTakeDamage(BaseCombatEntity entity, HitInfo hitInfo)
        {
            if (entity == null || hitInfo == null)
            {
                return;
            }

            var buildingBlock = entity as BuildingBlock;

            if (buildingBlock != null)
            {
                BuildingBlock block    = buildingBlock;
                BasePlayer    attacker = hitInfo.Initiator?.ToPlayer();
                if (attacker == null)
                {
                    return;
                }

                object modifier;
                if (block.LookupPrefab().name.ToLower().Contains("foundation") && !CupboardPrivlidge(attacker, block.transform.position))
                {
                    if (IsOwner(attacker, block))
                    {
                        return;
                    }
                    RaycastHit hit;
                    if (ExcludeCave && Physics.SphereCast(block.transform.position, .1f, Vector3.down, out hit, 250, groundLayer) && hit.collider.name.Contains("cave_"))
                    {
                        return;
                    }
                    if (!UseDamageScaling)
                    {
                        hitInfo.damageTypes  = new DamageTypeList();
                        hitInfo.DoHitEffects = false;
                        hitInfo.HitMaterial  = 0;
                        SendReply(attacker, lang.GetMessage("NoPerm", this, attacker.UserIDString));
                        return;
                    }
                    DamageType type = hitInfo.damageTypes.GetMajorityDamageType();
                    if (damageList.TryGetValue(type.ToString(), out modifier))
                    {
                        float mod = Convert.ToSingle(modifier);
                        if (mod > 0.0f)
                        {
                            hitInfo.damageTypes.Scale(type, mod);
                            damageGradeScaling.TryGetValue(block.grade.ToString(), out modifier);
                            mod = Convert.ToSingle(modifier);
                            if (Math.Abs(mod) > 0)
                            {
                                hitInfo.damageTypes.Scale(type, mod);
                                return;
                            }
                            hitInfo.damageTypes  = new DamageTypeList();
                            hitInfo.DoHitEffects = false;
                            hitInfo.HitMaterial  = 0;
                            SendReply(attacker, lang.GetMessage("NoPerm", this, attacker.UserIDString));
                        }
                        else
                        {
                            hitInfo.damageTypes  = new DamageTypeList();
                            hitInfo.DoHitEffects = false;
                            hitInfo.HitMaterial  = 0;
                            SendReply(attacker, lang.GetMessage("NoPerm", this, attacker.UserIDString));
                        }
                    }
                }
                else if (block.LookupPrefab().name.ToLower().Contains("foundation") && CupboardPrivlidge(attacker, block.transform.position))
                {
                    if (IsOwner(attacker, block))
                    {
                        return;
                    }
                    if (!UseDamageScaling)
                    {
                        hitInfo.damageTypes  = new DamageTypeList();
                        hitInfo.DoHitEffects = false;
                        hitInfo.HitMaterial  = 0;
                        SendReply(attacker, lang.GetMessage("NoPerm", this, attacker.UserIDString));
                        return;
                    }
                    DamageType type = hitInfo.damageTypes.GetMajorityDamageType();
                    if (damageList.TryGetValue(type.ToString(), out modifier))
                    {
                        var mod = Convert.ToSingle(modifier);
                        if (Math.Abs(mod) > 0)
                        {
                            hitInfo.damageTypes.Scale(type, mod);
                            damageGradeScaling.TryGetValue(block.grade.ToString(), out modifier);
                            mod = Convert.ToSingle(modifier);
                            if (Math.Abs(mod) > 0)
                            {
                                hitInfo.damageTypes.Scale(type, mod);
                                return;
                            }
                            hitInfo.damageTypes  = new DamageTypeList();
                            hitInfo.DoHitEffects = false;
                            hitInfo.HitMaterial  = 0;
                            SendReply(attacker, lang.GetMessage("NoPerm", this, attacker.UserIDString));
                        }
                        else
                        {
                            hitInfo.damageTypes  = new DamageTypeList();
                            hitInfo.DoHitEffects = false;
                            hitInfo.HitMaterial  = 0;
                            SendReply(attacker, lang.GetMessage("NoPerm", this, attacker.UserIDString));
                        }
                    }
                }
            }
        }
Ejemplo n.º 27
0
        public static Obj_AI_Hero GetTarget(Obj_AI_Base champion,
                                            float range,
                                            DamageType type,
                                            bool ignoreShieldSpells = true,
                                            IEnumerable <Obj_AI_Hero> ignoredChamps = null,
                                            Vector3?rangeCheckFrom = null)
        {
            try
            {
                if (ignoredChamps == null)
                {
                    ignoredChamps = new List <Obj_AI_Hero>();
                }

                var damageType = (Damage.DamageType)Enum.Parse(typeof(Damage.DamageType), type.ToString());

                if (IsValidTarget(
                        SelectedTarget, _configMenu.Item("ForceFocusSelected").GetValue <bool>() ? float.MaxValue : range,
                        type, ignoreShieldSpells, rangeCheckFrom))
                {
                    return(SelectedTarget);
                }

                if (_configMenu != null && _configMenu.Item("TargetingMode") != null &&
                    Mode == TargetingMode.AutoPriority)
                {
                    var menuItem = _configMenu.Item("TargetingMode").GetValue <StringList>();
                    Enum.TryParse(menuItem.SList[menuItem.SelectedIndex], out Mode);
                }

                var targets =
                    ObjectManager.Get <Obj_AI_Hero>()
                    .Where(hero => ignoredChamps.All(ignored => ignored.NetworkId != hero.NetworkId) && IsValidTarget(hero, range, type, ignoreShieldSpells, rangeCheckFrom));

                switch (Mode)
                {
                case TargetingMode.LowHP:
                    return(targets.MinOrDefault(hero => hero.Health));

                case TargetingMode.MostAD:
                    return
                        (targets.MaxOrDefault(hero => hero.BaseAttackDamage + hero.FlatPhysicalDamageMod));

                case TargetingMode.MostAP:
                    return
                        (targets.MaxOrDefault(hero => hero.BaseAbilityDamage + hero.FlatMagicDamageMod));

                case TargetingMode.Closest:
                    return(targets.MinOrDefault(hero => (rangeCheckFrom.HasValue ? rangeCheckFrom.Value : champion.ServerPosition).Distance(hero.ServerPosition, true)));

                case TargetingMode.NearMouse:
                    return(targets.FirstOrDefault(hero => hero.Distance(Game.CursorPos, true) < 22500));    // 150 * 150

                case TargetingMode.AutoPriority:
                    return
                        (targets.MaxOrDefault(hero => champion.CalcDamage(hero, damageType, 100) / (1 + hero.Health) * GetPriority(hero)));

                case TargetingMode.LessAttack:
                    return
                        (targets.MaxOrDefault(hero => champion.CalcDamage(hero, Damage.DamageType.Physical, 100) / (1 + hero.Health) * GetPriority(hero)));

                case TargetingMode.LessCast:
                    return
                        (targets.MaxOrDefault(hero => champion.CalcDamage(hero, Damage.DamageType.Magical, 100) / (1 + hero.Health) * GetPriority(hero)));
                }
            }
            catch (Exception e)
            {
                Console.WriteLine(e);
            }

            return(null);
        }
Ejemplo n.º 28
0
        public static AIHeroClient GetTarget(
            Obj_AI_Base champion,
            float range,
            DamageType type,
            bool ignoreShieldSpells = true,
            IEnumerable <AIHeroClient> ignoredChamps = null,
            Vector3?rangeCheckFrom = null,
            TargetSelectionConditionDelegate conditions = null)
        {
            try
            {
                if (ignoredChamps == null)
                {
                    ignoredChamps = new List <AIHeroClient>();
                }

                var damageType = (Damage.DamageType)Enum.Parse(typeof(Damage.DamageType), type.ToString());

                if (_configMenu != null &&
                    IsValidTarget(
                        SelectedTarget,
                        _configMenu.Item("ForceFocusSelected").GetValue <bool>() ? float.MaxValue : range,
                        type,
                        ignoreShieldSpells,
                        rangeCheckFrom))
                {
                    return(SelectedTarget);
                }

                if (_configMenu != null &&
                    IsValidTarget(
                        SelectedTarget,
                        _configMenu.Item("ForceFocusSelectedKeys").GetValue <bool>() ? float.MaxValue : range,
                        type,
                        ignoreShieldSpells,
                        rangeCheckFrom))
                {
                    if (_configMenu.Item("ForceFocusSelectedK").GetValue <KeyBind>().Active ||
                        _configMenu.Item("ForceFocusSelectedK2").GetValue <KeyBind>().Active)
                    {
                        return(SelectedTarget);
                    }
                }

                if (_configMenu != null && _configMenu.Item("TargetingMode") != null &&
                    Mode == TargetingMode.AutoPriority)
                {
                    var menuItem = _configMenu.Item("TargetingMode").GetValue <StringList>();
                    Enum.TryParse(menuItem.SList[menuItem.SelectedIndex], out Mode);
                }

                var targets =
                    EloBuddy.SDK.EntityManager.Heroes.Enemies.FindAll(
                        hero =>
                        ignoredChamps.All(ignored => ignored.NetworkId != hero.NetworkId) &&
                        IsValidTarget(hero, range, type, ignoreShieldSpells, rangeCheckFrom) &&
                        (conditions == null || conditions(hero)));

                switch (Mode)
                {
                case TargetingMode.LowHP:
                    return(targets.MinOrDefault(hero => hero.Health));

                case TargetingMode.MostAD:
                    return(targets.MaxOrDefault(hero => hero.BaseAttackDamage + hero.FlatPhysicalDamageMod));

                case TargetingMode.MostAP:
                    return(targets.MaxOrDefault(hero => hero.BaseAbilityDamage + hero.FlatMagicDamageMod));

                case TargetingMode.Closest:
                    return
                        (targets.MinOrDefault(
                             hero =>
                             (rangeCheckFrom.HasValue ? rangeCheckFrom.Value : champion.ServerPosition).Distance(
                                 hero.ServerPosition,
                                 true)));

                case TargetingMode.NearMouse:
                    return(targets.MinOrDefault(hero => hero.Distance(Game.CursorPos, true)));

                case TargetingMode.AutoPriority:
                    return
                        (targets.MaxOrDefault(
                             hero =>
                             champion.CalcDamage(hero, damageType, 100) / (1 + hero.Health) * GetPriority(hero)));

                case TargetingMode.LessAttack:
                    return
                        (targets.MaxOrDefault(
                             hero =>
                             champion.CalcDamage(hero, Damage.DamageType.Physical, 100) / (1 + hero.Health)
                             * GetPriority(hero)));

                case TargetingMode.LessCast:
                    return
                        (targets.MaxOrDefault(
                             hero =>
                             champion.CalcDamage(hero, Damage.DamageType.Magical, 100) / (1 + hero.Health)
                             * GetPriority(hero)));

                case TargetingMode.MostStack:
                    return
                        (targets.MaxOrDefault(
                             hero =>
                             champion.CalcDamage(hero, damageType, 100) / (1 + hero.Health) * GetPriority(hero)
                             + (1 + hero.Buffs.Where(b => StackNames.Contains(b.Name.ToLower())).Sum(t => t.Count))));
                }
            }
            catch (Exception e)
            {
                Console.WriteLine(e);
            }

            return(null);
        }
Ejemplo n.º 29
0
        public override string Description()
        {
            string p = percent ? "%" : "";

            return($"Deal {inflict}{p} {dmgType.ToString()} damage.");
        }
Ejemplo n.º 30
0
        // FUNCTIONS //

        public void Apply(Creature victim)
        {
            string victimText = $"{victim.Name}";
            string userText   = $"{user.Name}";

            if (victimHPDamageType != DamageType.None)
            {
                int damageTaken = victim.Defend(victimHPDamageType, victimResourceDamage[0], victim.Position);
                victimText += $" recieved {damageTaken} {victimHPDamageType.ToString()} damage,";
            }
            if (victimResourceDamage[1] > 0)
            {
                victim.ChangeResource(Resource.MP, -victimResourceDamage[1]);
                victimText += $" lost {victimResourceDamage[1]} magicka,";
            }
            if (victimResourceDamage[2] > 0)
            {
                victim.ChangeResource(Resource.SP, -victimResourceDamage[2]);
                victimText += $" lost {victimResourceDamage[2]} stamina,";
            }
            if (victimResourceHealing[0] > 0)
            {
                victim.ChangeResource(Resource.HP, victimResourceHealing[0]);
                victimText += $" had {victimResourceHealing[0]} health restored,";
            }
            if (victimResourceHealing[1] > 0)
            {
                victim.ChangeResource(Resource.MP, victimResourceHealing[1]);
                victimText += $" had {victimResourceHealing[1]} magicka restored,";
            }
            if (victimResourceHealing[2] > 0)
            {
                victim.ChangeResource(Resource.SP, victimResourceHealing[2]);
                victimText += $" had {victimResourceHealing[2]} stamina restored,";
            }
            if (userResourceHealing[0] > 0)
            {
                user.ChangeResource(Resource.SP, userResourceHealing[0]);
                userText += $" recieved {userResourceHealing[0]} health,";
            }
            if (userResourceHealing[1] > 0)
            {
                user.ChangeResource(Resource.SP, userResourceHealing[1]);
                userText += $" recieved {userResourceHealing[1]} magicka,";
            }
            if (userResourceHealing[2] > 0)
            {
                user.ChangeResource(Resource.SP, userResourceHealing[2]);
                userText += $" recieved {userResourceHealing[2]} stamina,";
            }

            if (!victimText.Equals($"{victim.Name}"))
            {
                victimText = victimText.Substring(0, victimText.LastIndexOf(','));
                if (victimText.Contains(","))
                {
                    int commaIndex = victimText.LastIndexOf(',');
                    victimText = victimText.Substring(0, commaIndex) + " and " + victimText.Substring(commaIndex + 2, victimText.Length - (commaIndex + 2));
                }
                victimText += $" from {name}.";
                Program.MsgConsole.WriteLine(victimText);
            }
            if (!userText.Equals($"{user.Name}"))
            {
                userText = userText.Substring(0, userText.LastIndexOf(','));
                if (userText.Contains(","))
                {
                    int commaIndex = userText.LastIndexOf(',');
                    userText = userText.Substring(0, commaIndex) + " and " + userText.Substring(commaIndex + 2, userText.Length - (commaIndex + 2));
                }
                userText += $" from {name}.";
                Program.MsgConsole.WriteLine(userText);
            }

            turns--;
            if (turns == 0)
            {
                victim.Effects.Remove(this);
            }
        }
Ejemplo n.º 31
0
        public static void Postfix(Vehicle __instance, WeaponHitInfo hitInfo, int hitLocation, Weapon weapon, float damageAmount, float directStructureDamage, int hitIndex, DamageType damageType)
        {
            if (__instance == null)
            {
                LogDebug("No vehicle");
                return;
            }
            LogReport($"\n{new string('^', 46)}");
            string wname = (weapon != null) ? (weapon.Name ?? "null") : "null";

            LogReport($"{__instance.DisplayName} :{__instance.GUID } took Damage from {wname} - {damageType.ToString()}");
            DamageHandler.ProcessDamage(__instance, damageAmount, directStructureDamage, 0);
        }
Ejemplo n.º 32
0
        public static Obj_AI_Hero GetTarget(Obj_AI_Base champion,
            float range,
            DamageType type,
            bool ignoreShieldSpells = true,
            IEnumerable<Obj_AI_Hero> ignoredChamps = null,
            Vector3? rangeCheckFrom = null)
        {
            try
            {
                if (ignoredChamps == null)
                {
                    ignoredChamps = new List<Obj_AI_Hero>();
                }

                var damageType = (Damage.DamageType) Enum.Parse(typeof(Damage.DamageType), type.ToString());

                if (_configMenu != null && IsValidTarget(
                    SelectedTarget, _configMenu.Item("ForceFocusSelected").GetValue<bool>() ? float.MaxValue : range,
                    type, ignoreShieldSpells, rangeCheckFrom))
                {
                    return SelectedTarget;
                }

                if (_configMenu != null && _configMenu.Item("TargetingMode") != null &&
                    Mode == TargetingMode.AutoPriority)
                {
                    var menuItem = _configMenu.Item("TargetingMode").GetValue<StringList>();
                    Enum.TryParse(menuItem.SList[menuItem.SelectedIndex], out Mode);
                }

                var targets =
                    HeroManager.Enemies
                        .FindAll(
                            hero =>
                                ignoredChamps.All(ignored => ignored.NetworkId != hero.NetworkId) &&
                                IsValidTarget(hero, range, type, ignoreShieldSpells, rangeCheckFrom));

                switch (Mode)
                {
                    case TargetingMode.LowHP:
                        return targets.MinOrDefault(hero => hero.Health);

                    case TargetingMode.MostAD:
                        return targets.MaxOrDefault(hero => hero.BaseAttackDamage + hero.FlatPhysicalDamageMod);

                    case TargetingMode.MostAP:
                        return targets.MaxOrDefault(hero => hero.BaseAbilityDamage + hero.FlatMagicDamageMod);

                    case TargetingMode.Closest:
                        return
                            targets.MinOrDefault(
                                hero =>
                                    (rangeCheckFrom.HasValue ? rangeCheckFrom.Value : champion.ServerPosition).Distance(
                                        hero.ServerPosition, true));

                    case TargetingMode.NearMouse:
                        return targets.Find(hero => hero.Distance(Game.CursorPos, true) < 22500); // 150 * 150

                    case TargetingMode.AutoPriority:
                        return
                            targets.MaxOrDefault(
                                hero =>
                                    champion.CalcDamage(hero, damageType, 100) / (1 + hero.Health) * GetPriority(hero));

                    case TargetingMode.LessAttack:
                        return
                            targets.MaxOrDefault(
                                hero =>
                                    champion.CalcDamage(hero, Damage.DamageType.Physical, 100) / (1 + hero.Health) *
                                    GetPriority(hero));

                    case TargetingMode.LessCast:
                        return
                            targets.MaxOrDefault(
                                hero =>
                                    champion.CalcDamage(hero, Damage.DamageType.Magical, 100) / (1 + hero.Health) *
                                    GetPriority(hero));
                }
            }
            catch (Exception e)
            {
                Console.WriteLine(e);
            }

            return null;
        }
 //Calcualtes resistance on specific type of damage
 private float getResistanceForDamageType(DamageType dmgType)
 {
     switch (dmgType)
     {
         case DamageType.Physical:
             return PhysicalResistance;
         case DamageType.PhysicalRanged:
             return RangedResistance;
         case DamageType.Fire:
             return FireResistance;
         case DamageType.Ice:
             return IceResistance;
         case DamageType.Magic:
             return MagicResistance;
         default:
             throw new NotImplementedException("You've forgot to implement add DamageType <-> resistance stat mapping for " + dmgType.ToString() +".");
     }
 }
Ejemplo n.º 34
0
        public static AIHeroClient GetTarget(Obj_AI_Base champion,
            float range,
            DamageType type,
            bool ignoreShieldSpells = true,
            IEnumerable<AIHeroClient> ignoredChamps = null,
            Vector3? rangeCheckFrom = null, TargetSelectionConditionDelegate conditions = null)
        {

            try
            {
                if (ignoredChamps == null)
                {
                    ignoredChamps = new List<AIHeroClient>();
                }

                var damageType = (EloBuddy.DamageType)Enum.Parse(typeof(EloBuddy.DamageType), type.ToString());

                if (_configMenu != null && IsValidTarget(
                    SelectedTarget, focusMenu["ForceFocusSelected"].Cast<CheckBox>().CurrentValue ? float.MaxValue : range,
                    type, ignoreShieldSpells, rangeCheckFrom))
                {
                    return SelectedTarget;
                }

                if (_configMenu != null && IsValidTarget(
                    SelectedTarget, focusMenu["ForceFocusSelectedKeys"].Cast<CheckBox>().CurrentValue ? float.MaxValue : range,
                    type, ignoreShieldSpells, rangeCheckFrom))
                {
                    if (focusMenu["ForceFocusSelectedK"].Cast<KeyBind>().CurrentValue ||
                        focusMenu["ForceFocusSelectedK2"].Cast<KeyBind>().CurrentValue)
                    {
                        return SelectedTarget;
                    }
                }

                if (_configMenu != null && _configMenu["TargetingMode"] != null && Mode == TargetingMode.AutoPriority)
                {
                    var menuItem = _configMenu["TargetingMode"].Cast<ComboBox>().CurrentValue;
                    Enum.TryParse(getMode().ToString(), out Mode);
                }

                var targets =
                   EntityManager.Heroes.Enemies
                        .FindAll(
                            hero =>
                                ignoredChamps.All(ignored => ignored.NetworkId != hero.NetworkId) &&
                                IsValidTarget(hero, range, type, ignoreShieldSpells, rangeCheckFrom) && (conditions == null || conditions(hero)));

                switch (Mode)
                {
                    case TargetingMode.LowHP:
                        return targets.MinOrDefault(hero => hero.Health);

                    case TargetingMode.MostAD:
                        return targets.MaxOrDefault(hero => hero.BaseAttackDamage + hero.FlatPhysicalDamageMod);

                    case TargetingMode.MostAP:
                        return targets.MaxOrDefault(hero => hero.BaseAbilityDamage + hero.FlatMagicDamageMod);

                    case TargetingMode.Closest:
                        return
                            targets.MinOrDefault(
                                hero =>
                                    (rangeCheckFrom.HasValue ? rangeCheckFrom.Value : champion.ServerPosition).LSDistance(
                                        hero.ServerPosition, true));

                    case TargetingMode.NearMouse:
                        return targets.MinOrDefault(hero => hero.LSDistance(Game.CursorPos, true));

                    case TargetingMode.AutoPriority:
                        return
                            targets.MaxOrDefault(
                                hero =>
                                    champion.CalcDamage(hero, damageType, 100) / (1 + hero.Health) * GetPriority(hero));

                    case TargetingMode.LessAttack:
                        return
                            targets.MaxOrDefault(
                                hero =>
                                    champion.CalcDamage(hero, EloBuddy.DamageType.Physical, 100) / (1 + hero.Health) *
                                    GetPriority(hero));

                    case TargetingMode.LessCast:
                        return
                            targets.MaxOrDefault(
                                hero =>
                                    champion.CalcDamage(hero, EloBuddy.DamageType.Magical, 100) / (1 + hero.Health) *
                                    GetPriority(hero));

                    case TargetingMode.MostStack:
                        return
                            targets.MaxOrDefault(
                                hero =>
                                    champion.CalcDamage(hero, damageType, 100) / (1 + hero.Health) * GetPriority(hero) +
                                    (1 + hero.Buffs.Where(b => StackNames.Contains(b.Name.ToLower())).Sum(t => t.Count)));
                }
            }
            catch (Exception e)
            {
                Console.WriteLine(e);
            }

            return null;
        }