Inheritance: MonoBehaviour
Exemple #1
0
 /// <summary>
 /// 伤害核心计算公式
 /// </summary>
 /// <param name="monster">怪物</param>
 /// <param name="skillDamage">已经过法强加成的伤害类</param>
 /// <returns>计算抗性后的伤害值</returns>
 public static float CalculateDamage(Monster monster, Damage.SkillDamage skillDamage)
 {
     ///当前版本不存在神圣伤害or物理伤害
     if (!monster.armorComponent)
     {
         return skillDamage.GetTotalDamage();
     }
     float[] elementDefenceList = monster.armorComponent.GetElementDefenceList();
     float sum = 0;
     for (int i = 0; i < Elements.ELEMENT_NUMBER; i++)
     {
         ///当前版本不存在将伤害小于0的效果
         if (skillDamage.elementsDamage[i] < 0)
         {
             skillDamage.elementsDamage[i] = 0;
         }
         ///当前版本不存在将伤害转化成治疗的效果
         float p = 1 - elementDefenceList[i] / 100;
         if (p < 0)
         {
             p = 0;
         }
         sum += skillDamage.elementsDamage[i] * p;
     }
     ///FIXME 物理组件存在物理抗性,物理抗性还需计算
     return sum + skillDamage.physicalDamage;
 }
    void OnTriggerEnter(Collider col)
    {
        if (!destroyed)
        {
            destroyed = true;

            GameObject target;
            if (col.attachedRigidbody != null)
            {
                target = col.attachedRigidbody.gameObject;
            }
            else
            {
                target = col.gameObject;
            }
            Damage dam = new Damage();
            dam.amount = damage;
            dam.source = this;
            dam.targetCollider = col;

            DamageReceiver receiver = target.GetComponent<DamageReceiver>();
            if (receiver != null)
            {
                receiver.TakeDamage(dam);
            }

            Destroy(gameObject);
        }
    }
Exemple #3
0
 public ActionResult AddNewDamage(Damage damage)
 {
     var context = new RiskSystemEntities();
     context.Damages.Add(damage);
     context.SaveChanges();
     return RedirectToAction("Damages");
 }
 public void Pop(Damage damage)
 {
     var message = _messagePrefab.Instantiate();
     message.transform.SetParent(transform, false);
     message.transform.localPosition = Vector3.zero;
     message.Show(damage);
 }
Exemple #5
0
 public virtual bool RecieveDamage(Damage dmg)
 {
     _health -= dmg.damage;
     if ( _health < 0 )
         return true;
     return false;
 }
Exemple #6
0
 public void TakeDamage(Damage damage)
 {
     // we hit a bullet / a bullet hit us, both go away
     AudioSource.PlayClipAtPoint(rockGotHit, Camera.main.transform.position);
     Instantiate(rockHitEffect, transform.position, transform.rotation);
     Destroy(gameObject);
 }
Exemple #7
0
 public void OnDamaged(Damage damage)
 {
     if (damage != null && damage.Sufferers != null )
     {
         beDamaging = true;
     }
 }
    void Update()
    {
        if (isFiring)
        {
            Ray ray = new Ray(startPos.position, startPos.forward);
            RaycastHit hit;
            Vector3 hitPos;
            if (Physics.Raycast(ray, out hit, range))
            {
                hitPos = hit.point;

                GameObject target;
                if (hit.collider.attachedRigidbody != null) target = hit.collider.attachedRigidbody.gameObject;
                else target = hit.collider.gameObject;
                DamageReceiver receiver = target.GetComponent<DamageReceiver>();
                if (receiver != null)
                {
                    Damage dam = new Damage();
                    dam.amount = Time.deltaTime * damage;
                    dam.targetCollider = hit.collider;
                    dam.source = this;
                    receiver.TakeDamage(dam);
                }
            }
            else
            {
                hitPos = startPos.position + startPos.forward * range;
            }

            line.SetPosition(0, startPos.position);
            line.SetPosition(1, hitPos);
        }
    }
Exemple #9
0
 // Copy constructor
 public Damage(Damage copyFrom)
 {
     HitLocation = copyFrom.HitLocation;
     Amount = copyFrom.Amount;
     Attacker = copyFrom.Attacker;
     Attack = copyFrom.Attack;
 }
Exemple #10
0
        public Ability()
        {
            Name = "!!! Unnamed Ability !!!";
            Description = "";

            Animations = new List<GraphicsEffectDefinition>();
            CastingAnimations = new List<GraphicsEffectDefinition>();
            ImpactAnimations = new List<GraphicsEffectDefinition>();

            Damage = new Damage();
            Healing = new Damage();
            DamageType = DamageTypes.SingleTarget;
            TargettingType = TargettingTypes.Hostile;
            Cooldown = new Cooldown(0f);
            Range = new Range(20f);
            Area = 1f;
            ThreatModifier = 1f;
            AurasApplied = new List<Aura>();
            Duration = 1;

            CanMiss = true;
            CanBeDodged = true;
            CanCrit = true;
            CanBeBlocked = true;
        }
 public void OnTakeDamage(Damage d)
 {
     shieldHealth -= d.damage;
     if (shieldHealth <= 0) {
         Destroy (gameObject);
     }
 }
Exemple #12
0
 public void TakeDamage(Damage damage)
 {
     if (!enabled)
         return;
     OnDamage (damage);
     OnDamageAction.Invoke ();
 }
Exemple #13
0
    public void OnTakeDamage(Damage d)
    {
        Vector3 point = d.point;

        float dist = float.MaxValue;
        int index = 0;

        if (majorParts.Length > 0) {
            for (int i = 0; i < majorParts.Length; i++) {
                float ld = Vector3.Distance (point, majorParts[i].part.transform.position);

                if (ld > dist) {
                    ld = dist;
                    index = i;
                }
            }

            majorParts[index].part.AddForceAtPosition (d.force, point);
            if (majorParts[index].canDestroy && d.force.magnitude > dismembermentForce) {
                majorParts[index].part.transform.localScale = Vector3.zero;
            }

            ragdolls.Enqueue (this);
            if (ragdolls.Count > maxRagdollsInScene) {
                RagdollHandler h = ragdolls.Dequeue ();
                h.StartCoroutine (h.Fade ());
            }
        }
    }
    void OnTriggerStay(Collider col)
    {
        GameObject target;
        if (col.attachedRigidbody != null)
        {
            target = col.attachedRigidbody.gameObject;
        }
        else
        {
            target = col.gameObject;
        }

        if (!targets.Contains(target))
        {
            targets.Add(target);
            float dist = (target.transform.position - transform.position).magnitude;

            Damage dam = new Damage();
            dam.amount = damage * radius / (dist + 1);
            dam.source = this;
            dam.targetCollider = col;

            DamageReceiver receiver = target.GetComponent<DamageReceiver>();
            if (receiver != null)
            {
                receiver.TakeDamage(dam);
            }

            if (target.rigidbody != null)
            {
                target.rigidbody.AddExplosionForce(damage * 100, transform.position, radius);
            }
        }
    }
Exemple #15
0
	public virtual void takeDamage(Damage d)
	{
		hp -= d.value;

		if (hp <= 0)
			this.diedFrom (d);
	}
Exemple #16
0
 public virtual bool Attack(Character target)
 {
     Damage damage = new Damage(this, target, attack * (1 - target.defence / 100));
     Damage.AddDamage(damage);
     //target.LoseHp(attack * (1 - target.defence / 100));
     return true;
 }
Exemple #17
0
 void TakeDamage(Damage damage)
 {
     if(rolling)
         StartCoroutine(BumpOutOfRoll());
     else
         StartCoroutine(FlashAndExplode(damage));
 }
Exemple #18
0
 public virtual void BeginAttack(Damage damageToDeal, Fighter attacker)
 {
     weaponUser = attacker;
     attackCast.OnHit += OnWeaponHit;
     damageOut = damageToDeal;
     attackCast.Begin ();
 }
 void TakeDamage(Damage damage)
 {
     var parts = Instantiate (deathParticles, transform.position, Quaternion.LookRotation(damage.direction)) as Transform;
     Destroy(gameObject);
     // Start Reset Coroutine
     //Application.LoadLevel (Application.loadedLevel);
     SceneManager.Instance.dead.SwitchTo();
 }
Exemple #20
0
    protected override void Awake() {
        base.Awake();

        if(anim)
            anim.AnimationEventTriggered += OnAnimEvent;

        mDmg = GetComponent<Damage>();
    }
Exemple #21
0
 void OnTriggerEnter(Collider other)
 {
     if (other.gameObject.tag == "Player" || other.gameObject.tag == "NPC") {
         _inRange = true;
         _targetHealth = other.gameObject.GetComponent<Damage>();
         _targetHealth.ParticleSystem.Play();
     }
 }
Exemple #22
0
 public void TakeHit(Damage damageObject)
 {
     Health -= damageObject.damage;
     if(Health <= 0)
     {
         Die(damageObject.damageType);
     }
 }
Exemple #23
0
 /// <summary>
 /// 受到伤害
 /// </summary>
 /// <param name="p_skillDamage">受到的伤害</param>
 public void GetDamaged(Damage.SkillDamage p_skillDamage)
 {
     if (!hpComponent || p_skillDamage == null)
     {
         return;
     }
     hpComponent.LoseHp(Damage.CalculateDamage(this, p_skillDamage));
 }
        public CharacterHitStopState(Character parent, IGamePad pad, Damage damages)
            : base(parent)
        {
            gamepad = pad;
            this.damage = damages;

            if (damage.damageParameter.damage >= 20F) SoundManager.Play(SoundManager.hitHeavy);
            else SoundManager.Play(SoundManager.hitLight);
        }
Exemple #25
0
 public void ApplyDamage(Damage dmg)
 {
     if ( dmg.owner != gameObject ){
         currentHealth -= dmg.value;
     }
     if ( currentHealth <= 0 ){
         Die ();
     }
 }
 void Start()
 {
     _block          = GetComponent<PlayerBlock>();
     _rigidBody      = GetComponent<Rigidbody>();
     _inputToggle    = GetComponent<ToggleEnableInput>();
     _movement       = GetComponent<PlayerMovement>();
     _damageAmount   = GetComponentInChildren<Damage>();
     _damageBase     = _damageAmount.damage;
 }
Exemple #27
0
    public void takeGeneralDamage(Damage damage, IAbility ability, IBattleCharacter source)
    {
        List<GameObject> children = listChildren(this.gameObject);

        foreach (GameObject child in children)
        {
            child.GetComponent<IBattleCharacter>().takeGeneralDamage(damage,ability,source);
        }
    }
Exemple #28
0
 public void ReceiveDamage(Damage damage)
 {
     if(Time.time - lastHit > hitTimeout){
         lastHit = Time.time;
         SendMessageUpwards("TakeDamage", damage, SendMessageOptions.DontRequireReceiver);
         // Do Screen Effects
         CameraEffects.TakeDamage(damage);
     }
 }
 void onStayHit(Damage damage, int hp)
 {
     if (m_Death) return;
     if (damage.DamageAmount > 0)
     {
         m_NavAgent.velocity = Vector3.zero;
         m_Animator.SetTrigger("Damage");
     }
 }
Exemple #30
0
    protected void BasicInit(Weapon weapon = null , Damage dmg = null, Transform target = null )
    {
        gameObject.tag = Global.BULLET_TAG;
        _damage = dmg;
        _teamColor = weapon.robot.teamColor;

        if ( _rigidbody == null )
            _rigidbody = GetComponent<Rigidbody>();
    }
Exemple #31
0
        /// <summary>
        /// Saves the item definition
        /// </summary>
        /// <param name="writer">Xml writer handle</param>
        /// <returns>True if saved, or false</returns>
        public bool Save(XmlWriter writer)
        {
            if (writer == null)
            {
                throw new ArgumentNullException("writer");
            }

            writer.WriteStartElement("item");
            writer.WriteAttributeString("name", Name);



            writer.WriteStartElement("tile");
            writer.WriteAttributeString("name", TileSetName);
            writer.WriteAttributeString("inventory", TileID.ToString());
            writer.WriteAttributeString("ground", GroundTileID.ToString());
            writer.WriteAttributeString("incoming", IncomingTileID.ToString());
            writer.WriteAttributeString("moveaway", ThrowTileID.ToString());
            writer.WriteEndElement();

            writer.WriteStartElement("type");
            writer.WriteAttributeString("value", Type.ToString());
            writer.WriteEndElement();

            writer.WriteStartElement("damagetype");
            writer.WriteAttributeString("value", DamageType.ToString());
            writer.WriteEndElement();

            writer.WriteStartElement("ac");
            writer.WriteAttributeString("value", ArmorClass.ToString());
            writer.WriteEndElement();

            writer.WriteStartElement("slot");
            writer.WriteAttributeString("value", Slot.ToString());
            writer.WriteEndElement();

            writer.WriteStartElement("classes");
            writer.WriteAttributeString("value", AllowedClasses.ToString());
            writer.WriteEndElement();


            writer.WriteStartElement("weight");
            writer.WriteAttributeString("value", Weight.ToString());
            writer.WriteEndElement();

            Damage.Save("damage", writer);
            DamageVsBig.Save("damagevsbig", writer);
            DamageVsSmall.Save("damagevssmall", writer);

            writer.WriteStartElement("critical");
            writer.WriteAttributeString("min", Critical.X.ToString());
            writer.WriteAttributeString("max", Critical.Y.ToString());
            writer.WriteAttributeString("multiplier", CriticalMultiplier.ToString());
            writer.WriteEndElement();

            Script.Save("script", writer);

            if (IsCursed)
            {
                writer.WriteStartElement("iscursed");
                writer.WriteAttributeString("value", IsCursed.ToString());
                writer.WriteEndElement();
            }

            if (IsIdentified)
            {
                writer.WriteStartElement("isidentified");
                writer.WriteAttributeString("value", IsCursed.ToString());
                writer.WriteEndElement();
            }

            if (CanIdentify)
            {
                writer.WriteStartElement("canidentify");
                writer.WriteAttributeString("value", IsCursed.ToString());
                writer.WriteEndElement();
            }

            if (IsBig)
            {
                writer.WriteStartElement("isbig");
                writer.WriteAttributeString("value", IsBig.ToString());
                writer.WriteEndElement();
            }

            writer.WriteStartElement("allowedhands");
            writer.WriteAttributeString("value", AllowedHands.ToString());
            writer.WriteEndElement();

            writer.WriteElementString("shortname", ShortName);
            writer.WriteElementString("identifiedname", IdentifiedName);


            writer.WriteStartElement("speed");
            writer.WriteAttributeString("value", AttackSpeed.TotalMilliseconds.ToString());
            writer.WriteEndElement();

            writer.WriteEndElement();

            return(true);
        }
    protected override DamageDescriptor FireRaycast(Vector3 pos, Vector3 dir, float range, LayerMask mask, float rayThickness = 0.3f)
    {
        DamageDescriptor d = new DamageDescriptor();

        SpawnTrace();

        float      r = rangeDistance.y;
        RaycastHit h;

        if (Physics.Raycast(pos, dir, out h, r, mask))
        {
            r = h.distance;
        }

        RaycastHit[] hits        = Physics.SphereCastAll(pos, thickness, dir, r, mask);
        int          chosenIndex = -1;
        float        closest     = r;
        int          i           = 0;

        foreach (RaycastHit hit in hits)
        {
            if (hit.distance < closest)
            {
                chosenIndex = i;
            }
            ++i;
        }

        if (chosenIndex != -1)
        {
            RaycastHit hit = hits[chosenIndex];

            if (damagableTags.Contains(hit.collider.tag))
            {
                //find a damagable component
                IDamagable hitComponenet = hit.collider.GetComponent <IDamagable>();
                if (hitComponenet != null)
                {
                    Damage dmg = damage;
                    dmg.pushForce = dir * damage.pushForce.x + Vector3.up * damage.pushForce.y;
                    if (hit.distance > rangeDistance.x)
                    {
                        float x          = (hit.distance - rangeDistance.x) / (rangeDistance.y - rangeDistance.x);
                        float multiplier = 1 - x;
                        dmg.amount = Mathf.Max(damage.amount * multiplier, 0);
                    }

                    //Debug.Log("DAMAGE: " + hit.collider.name + " - " + dmg.amount);

                    hitComponenet.TakeDamage(dmg);
                    if (!d.Initialised())
                    {
                        d = new DamageDescriptor(hit, dir, hitComponenet, damage);
                        if (OnHit != null)
                        {
                            OnHit(d, pos);
                        }

                        return(d);
                    }
                }

                return(d);
            }
        }


        return(new DamageDescriptor());
    }
Exemple #33
0
        public void InflictDamage(Actor self, Actor attacker, Damage damage, bool ignoreModifiers)
        {
            // Overkill! Don't count extra hits as more kills!
            if (IsDead)
            {
                return;
            }

            var oldState = DamageState;

            // Apply any damage modifiers
            if (!ignoreModifiers && damage.Value > 0)
            {
                // PERF: Util.ApplyPercentageModifiers has been manually inlined to
                // avoid unnecessary loop enumerations and allocations
                var appliedDamage = (decimal)damage.Value;
                foreach (var dm in damageModifiers)
                {
                    var modifier = dm.GetDamageModifier(attacker, damage);
                    if (modifier != 100)
                    {
                        appliedDamage *= modifier / 100m;
                    }
                }

                foreach (var dm in damageModifiersPlayer)
                {
                    var modifier = dm.GetDamageModifier(attacker, damage);
                    if (modifier != 100)
                    {
                        appliedDamage *= modifier / 100m;
                    }
                }

                damage = new Damage((int)appliedDamage, damage.DamageTypes);
            }

            hp = (hp - damage.Value).Clamp(0, MaxHP);

            var ai = new AttackInfo
            {
                Attacker            = attacker,
                Damage              = damage,
                DamageState         = DamageState,
                PreviousDamageState = oldState,
            };

            foreach (var nd in notifyDamage)
            {
                nd.Damaged(self, ai);
            }
            foreach (var nd in notifyDamagePlayer)
            {
                nd.Damaged(self, ai);
            }

            if (DamageState != oldState)
            {
                foreach (var nd in notifyDamageStateChanged)
                {
                    nd.DamageStateChanged(self, ai);
                }
            }

            if (Info.NotifyAppliedDamage && attacker != null && attacker.IsInWorld && !attacker.IsDead)
            {
                foreach (var nd in attacker.TraitsImplementing <INotifyAppliedDamage>())
                {
                    nd.AppliedDamage(attacker, self, ai);
                }
                foreach (var nd in attacker.Owner.PlayerActor.TraitsImplementing <INotifyAppliedDamage>())
                {
                    nd.AppliedDamage(attacker, self, ai);
                }
            }

            if (hp == 0)
            {
                foreach (var nd in notifyKilled)
                {
                    nd.Killed(self, ai);
                }
                foreach (var nd in notifyKilledPlayer)
                {
                    nd.Killed(self, ai);
                }

                if (RemoveOnDeath)
                {
                    self.Dispose();
                }
            }
        }
 protected override IEnumerable <MatcherData> CreateCollection() =>
 new StatMatcherCollection <IStatBuilder>(_modifierBuilder)
 {
     // attributes
     { "strength", Attribute.Strength },
     { "strength damage bonus", Attribute.StrengthDamageBonus },
     { "dexterity", Attribute.Dexterity },
     { "dexterity evasion bonus", Attribute.DexterityEvasionBonus },
     { "intelligence", Attribute.Intelligence },
     { "strength and dexterity", ApplyOnce(Attribute.Strength, Attribute.Dexterity) },
     { "strength and intelligence", ApplyOnce(Attribute.Strength, Attribute.Intelligence) },
     { "dexterity and intelligence", ApplyOnce(Attribute.Dexterity, Attribute.Intelligence) },
     { "attributes", ApplyOnce(Attribute.Strength, Attribute.Dexterity, Attribute.Intelligence) },
     // offense
     // - damage: see also DamageStatMatchers
     { "chance to deal double damage", Damage.ChanceToDouble },
     {
         "({DamageTypeMatchers}) damage (gained |added )?as (extra )?({DamageTypeMatchers}) damage",
         References[0].AsDamageType.Damage.AddAs(References[1].AsDamageType.Damage)
     },
     {
         "({DamageTypeMatchers}) damage as extra damage of a random element",
         Reference.AsDamageType.Damage.AddAs(RandomElement.Damage)
     },
     {
         "({DamageTypeMatchers}) damage converted to ({DamageTypeMatchers}) damage",
         References[0].AsDamageType.Damage.ConvertTo(References[1].AsDamageType.Damage)
     },
     { "({DamageTypeMatchers}) damage taken", Reference.AsDamageType.Damage.Taken },
     { "take ({DamageTypeMatchers}) damage", Reference.AsDamageType.Damage.Taken },
     { "damage taken", Damage.Taken },
     // - penetration
     // - crit
     { "(global )?critical strike multiplier", CriticalStrike.Multiplier },
     { "(global )?critical strike chance", CriticalStrike.Chance },
     // - projectiles
     { "projectile speed", Projectile.Speed },
     { "arrow speed", Projectile.Speed, Damage.With(Tags.Bow) },
     // - other
     { "accuracy rating", Stat.Accuracy },
     // defense
     // - life, mana, defences; see also PoolStatMatchers
     { "armour", Armour },
     { "evasion( rating)?", Evasion },
     { "evasion rating and armour", ApplyOnce(Armour, Evasion) },
     { "armour and evasion( rating)?", ApplyOnce(Armour, Evasion) },
     { "armour and energy shield", ApplyOnce(Armour, EnergyShield) },
     { "(global )?defences", ApplyOnce(Armour, Evasion, EnergyShield) },
     // - resistances
     { "({DamageTypeMatchers}) resistance", Reference.AsDamageType.Resistance },
     { "all elemental resistances", Elemental.Resistance },
     { "maximum ({DamageTypeMatchers}) resistance", Reference.AsDamageType.Resistance.Maximum },
     { "all maximum resistances", Elemental.And(Chaos).Resistance.Maximum },
     { "physical damage reduction", Physical.Resistance },
     // - leech
     {
         @"(?<pool>({PoolStatMatchers})) per second to \k<pool> Leech rate",
         Reference.AsPoolStat.Leech.RateLimit
     },
     {
         "({DamageStatMatchers}) leeched as ({PoolStatMatchers})",
         References[1].AsPoolStat.Leech.Of(References[0].AsDamageStat)
     },
     {
         "({DamageStatMatchers}) leeched as ({PoolStatMatchers}) and ({PoolStatMatchers})",
         References[1].AsPoolStat.Leech.Of(References[0].AsDamageStat),
         References[2].AsPoolStat.Leech.Of(References[0].AsDamageStat)
     },
     {
         "damage dealt by your totems is leeched to you as life",
         Life.Leech.To(Entity.ModifierSource).Of(Damage), For(Entity.Totem)
     },
     { "({PoolStatMatchers}) leeched per second", Reference.AsPoolStat.Leech.Rate },
     // - block
     { "chance to block", Block.AttackChance },
     { "block chance", Block.AttackChance },
     { "maximum block chance", Block.AttackChance.Maximum },
     { "chance to block spells", Block.SpellChance },
     { "chance to block spells and attacks", ApplyOnce(Block.SpellChance, Block.AttackChance) },
     // - other
     { "chance to dodge attacks", Stat.Dodge.AttackChance },
     { "chance to dodge spell damage", Stat.Dodge.SpellChance },
     { "chance to evade( attacks)?", Evasion.Chance },
     { "chance to evade projectile attacks", Evasion.ChanceAgainstProjectileAttacks },
     { "chance to evade melee attacks", Evasion.ChanceAgainstMeleeAttacks },
     {
         "damage is taken from ({PoolStatMatchers}) before ({PoolStatMatchers})",
         Damage.TakenFrom(References[0].AsPoolStat).Before(References[1].AsPoolStat)
     },
     {
         "({DamageTypeMatchers}) damage is taken from ({PoolStatMatchers}) before ({PoolStatMatchers})",
         References[0].AsDamageType.Damage.TakenFrom(References[1].AsPoolStat)
         .Before(References[2].AsPoolStat)
     },
     // speed
     { "attack speed", Skills[Keyword.Attack].Speed },
     { "cast speed", Skills.Speed, Not(With(Skills[Keyword.Attack])) },
     { "movement speed", Stat.MovementSpeed },
     {
         // not the most elegant solution but by far the easiest
         @"movement speed \(hidden\)",
         Stat.MovementSpeed, Not(Flag.IgnoreMovementSpeedPenalties.IsSet)
     },
     { "attack and cast speed", Skills.Speed },
     { "attack, cast( speed)? and movement speed", ApplyOnce(Skills.Speed, Stat.MovementSpeed) },
     { "animation speed", Stat.AnimationSpeed },
     // regen and recharge
     { "({PoolStatMatchers}) regeneration rate", Reference.AsPoolStat.Regen },
     { "energy shield recharge rate", EnergyShield.Recharge },
     {
         "recovery rate of life, mana and energy shield",
         Life.RecoveryRate, Mana.RecoveryRate, EnergyShield.RecoveryRate
     },
     // gain
     // charges
     { "(?<!maximum )({ChargeTypeMatchers})", Reference.AsChargeType.Amount },
     { "(?<!while at )maximum ({ChargeTypeMatchers})", Reference.AsChargeType.Amount.Maximum },
     {
         "maximum ({ChargeTypeMatchers}) and maximum ({ChargeTypeMatchers})",
         ApplyOnce(References[0].AsChargeType.Amount.Maximum, References[1].AsChargeType.Amount.Maximum)
     },
     { "chance to (gain|grant) an? ({ChargeTypeMatchers})", Reference.AsChargeType.ChanceToGain },
     {
         "chance to (gain|grant) an? ({ChargeTypeMatchers}) and an? ({ChargeTypeMatchers})",
         References[0].AsChargeType.ChanceToGain, References[1].AsChargeType.ChanceToGain
     },
     { "({ChargeTypeMatchers}) duration", Reference.AsChargeType.Duration },
     {
         "endurance, frenzy and power charge duration",
         Charge.Endurance.Duration, Charge.Frenzy.Duration, Charge.Power.Duration
     },
     // skills
     { "cooldown recovery speed", Skills.CooldownRecoverySpeed },
     { "mana cost( of skills)?", Skills.Cost },
     { "skill effect duration", Skills.Duration },
     { "mana reserved", Skills.Reservation },
     { "({KeywordMatchers}) duration", Skills[Reference.AsKeyword].Duration },
     // traps, mines, totems
     { "traps? placed at a time", Traps.CombinedInstances.Maximum },
     { "remote mines? placed at a time", Mines.CombinedInstances.Maximum },
     { "totems? summoned at a time", Totems.CombinedInstances.Maximum },
     { "trap trigger area of effect", Stat.TrapTriggerAoE },
     { "mine detonation area of effect", Stat.MineDetonationAoE },
     { "trap throwing speed", Traps.Speed },
     { "mine laying speed", Mines.Speed },
     { "totem placement speed", Totems.Speed },
     { "totem life", Life, For(Entity.Totem) },
     // minions
     {
         "maximum number of skeletons",
         Combine(Skill.SummonSkeleton, Skill.VaalSummonSkeletons).CombinedInstances.Maximum
     },
     { "maximum number of spectres", Skill.RaiseSpectre.Instances.Maximum },
     { "maximum number of zombies", Skill.RaiseZombie.Instances.Maximum },
     { "skeleton duration", Skill.SummonSkeleton.Duration, Skill.VaalSummonSkeletons.Duration },
     { "golem at a time", Golems.CombinedInstances.Maximum },
     // buffs
     { "effect of buffs granted by your golems", Buffs(Entity.Minion.With(Keyword.Golem)).Effect },
     {
         "effect of buffs granted by your elemental golems",
         Buffs(Entity.Minion.With(Keyword.Golem, Elemental)).Effect
     },
     { "effect of your curses", Buffs(Self).With(Keyword.Curse).Effect },
     { "effect of curses on you", Buffs(target: Self).With(Keyword.Curse).Effect },
     { "effect of non-curse auras you cast", Buffs(Self).With(Keyword.Aura).Without(Keyword.Curse).Effect },
     { "chance to fortify", Buff.Fortify.ChanceOn(Self) },
     { "effect of fortify on you", Buff.Fortify.Effect },
     { "fortify duration", Buff.Fortify.Duration },
     { "chance for attacks to maim", Buff.Maim.ChanceOn(Enemy), Damage.With(Source.Attack) },
     { "chance to taunt", Buff.Taunt.ChanceOn(Enemy) },
     { "taunt duration", Buff.Taunt.Duration },
     { "chance to blind enemies", Buff.Blind.ChanceOn(Enemy) },
     { "blind duration", Buff.Blind.Duration },
     // flags
     {
         "chance to (gain|grant) ({FlagMatchers})",
         Reference.AsFlagStat     // chance is handled by StatManipulationMatchers
     },
     { "({FlagMatchers}) duration", Reference.AsFlagStat.Duration },
     { "({FlagMatchers}) effect", Reference.AsFlagStat.Effect },
     // ailments
     { "chance to ({AilmentMatchers})( the enemy)?", Reference.AsAilment.Chance },
     {
         "chance to freeze, shock and ignite",
         Ailment.Freeze.Chance, Ailment.Shock.Chance, Ailment.Ignite.Chance
     },
     { "chance to avoid being ({AilmentMatchers})", Reference.AsAilment.Avoidance },
     { "chance to avoid elemental ailments", Ailment.Elemental.Select(a => a.Avoidance) },
     { "({AilmentMatchers}) duration( on enemies)?", Reference.AsAilment.Duration },
     { "duration of elemental ailments on enemies", Ailment.Elemental.Select(a => a.Duration) },
     // stun
     { "chance to avoid being stunned", Effect.Stun.Avoidance },
     { "stun and block recovery", Effect.Stun.Recovery, Block.Recovery },
     { "block recovery", Block.Recovery },
     { "stun threshold", Effect.Stun.Threshold },
     { "enemy stun threshold", Enemy.Stat(Effect.Stun.Threshold) },
     { "stun duration( on enemies)?", Enemy.Stat(Effect.Stun.Duration) },
     { "stun duration (?<inner>with .*) on enemies", Enemy.Stat(Effect.Stun.Duration), "${inner}" },
     {
         "chance to avoid interruption from stuns while casting",
         Effect.Stun.ChanceToAvoidInterruptionWhileCasting
     },
     { "chance to double stun duration", Effect.Stun.Duration.ChanceToDouble },
     // flasks
     { "effect of flasks( on you)?", Flask.Effect },
     { "flask effect duration", Flask.Duration },
     { "life recovery from flasks", Flask.LifeRecovery },
     { "mana recovery from flasks", Flask.ManaRecovery },
     { "flask charges used", Flask.ChargesUsed },
     { "flask charges gained", Flask.ChargesGained },
     { "flask recovery (speed|rate)", Flask.RecoverySpeed },
     // item quantity/quality
     { "quantity of items found", Stat.ItemQuantity },
     { "rarity of items found", Stat.ItemRarity },
     // range and area of effect
     { "area of effect", Skills.AreaOfEffect },
     { "melee weapon and unarmed range", Stat.Range, Not(MainHand.Has(Tags.Ranged)) },
     { "melee weapon range", Stat.Range, And(MainHand.Has(Tags.Weapon), Not(MainHand.Has(Tags.Ranged))) },
     // other
     { "rampage stacks", Stat.RampageStacks },
     { "chance to knock enemies back", Effect.Knockback.ChanceOn(Enemy) },
     { "knockback distance", Effect.Knockback.Distance },
     // Not really anything that can be done with them (yet), but should still be summed up
     { "character size", Stat.Unique("Character Size") },
     { "reflected elemental damage taken", Stat.Unique("Reduced Reflected Elemental Damage taken") },
     { "reflected physical damage taken", Stat.Unique("Reduced Reflected Physical Damage taken") },
     {
         "damage taken gained as mana over 4 seconds when hit",
         Stat.Unique("#% of Damage taken gained as Mana over 4 seconds when Hit")
     },
     { "light radius", Stat.Unique("Light Radius") },
 };
Exemple #35
0
 int IDamageModifier.GetDamageModifier(Actor attacker, Damage damage)
 {
     return(Level == 0 ? 100 : info.DamageRates[Level - 1]);
 }
Exemple #36
0
        static float GetComboDamage(Obj_AI_Base enemy)
        {
            var  APdmg   = 0d;
            var  ADdmg   = 0d;
            var  Truedmg = 0d;
            bool card    = false;

            if (Q.IsReady())
            {
                APdmg += Player.GetSpellDamage(enemy, SpellSlot.Q);
            }

            if (W.IsReady())
            {
                APdmg += Player.GetSpellDamage(enemy, SpellSlot.W, 2);
            }
            else
            {
                card = true;
                foreach (var buff in Player.Buffs)
                {
                    if (buff.Name == "bluecardpreattack")
                    {
                        APdmg += Player.GetSpellDamage(enemy, SpellSlot.W);
                    }
                    else if (buff.Name == "redcardpreattack")
                    {
                        APdmg += Player.GetSpellDamage(enemy, SpellSlot.W, 1);
                    }
                    else if (buff.Name == "goldcardpreattack")
                    {
                        APdmg += Player.GetSpellDamage(enemy, SpellSlot.W, 2);
                    }
                    else
                    {
                        card = false;
                    }
                }
            }

            bool passive = false;

            foreach (var buff in Player.Buffs)
            {
                if (buff.Name == "cardmasterstackparticle")
                {
                    APdmg  += Player.GetSpellDamage(enemy, SpellSlot.E);
                    passive = true;
                }

                if (buff.Name == "lichbane")
                {
                    APdmg  += Damage.CalcDamage(Player, enemy, Damage.DamageType.Magical, (Player.BaseAttackDamage * 0.75) + ((Player.BaseAbilityDamage + Player.FlatMagicDamageMod) * 0.5));
                    passive = true;
                }

                if (buff.Name == "sheen")
                {
                    ADdmg  += Player.GetAutoAttackDamage(enemy, false);
                    passive = true;
                }
            }

            if (!card && passive)
            {
                ADdmg += Player.GetAutoAttackDamage(enemy, false);
            }

            return((float)ADdmg + (float)APdmg + (float)Truedmg);
        }
Exemple #37
0
 public static void TakeDamage(GameUnit.GameUnit unit, Damage damage)
 {
     unit.hp -= damage.damageValue;
 }
Exemple #38
0
    public static Damage GetDamage(GameUnit.GameUnit unit)
    {
        Damage damage = new Damage(unit.atk);

        return(damage);
    }
Exemple #39
0
 public static bool HaveTransition(this Damage damage) => math.abs(damage.Type.x) > 0.1f;
Exemple #40
0
    protected override void OnUpdate()
    {
        InitEntityQueryCache(15);

        Entities.ForEach((Laser laser) =>
        {
            Enemy closestEnemy         = null;
            float closestEnemyDistance = 0f;
            Entities.ForEach((Enemy enemy) =>
            {
                float distanceToEnemy = Vector3.Distance(laser.transform.position, enemy.transform.position);
                if (closestEnemy == null)
                {
                    closestEnemy         = enemy;
                    closestEnemyDistance = distanceToEnemy;
                }
                else if (distanceToEnemy < closestEnemyDistance)
                {
                    closestEnemy         = enemy;
                    closestEnemyDistance = distanceToEnemy;
                }
            });

            // Rotate towards enemy
            if (closestEnemy != null && closestEnemyDistance <= laser.Range)
            {
                var q = Quaternion.LookRotation(closestEnemy.transform.position - laser.transform.position);
                laser.transform.rotation = Quaternion.RotateTowards(laser.transform.rotation, q, laser.AimSpeed * Time.DeltaTime);
            }

            // Laser
            Vector3 currentEndPosition = laser.LineRenderer.GetPosition(1);
            if (closestEnemy != null && closestEnemyDistance <= laser.Range)
            {
                float sightAngle = Vector3.Angle(closestEnemy.transform.position - laser.transform.position, laser.transform.forward);
                if (sightAngle <= 5f)
                {
                    // Laser length
                    laser.LineRenderer.SetPosition(1, new Vector3(currentEndPosition.x, currentEndPosition.y, (2.5f * closestEnemyDistance)));

                    // Tick
                    if (((Time.ElapsedTime - laser.LastTickTime) >= laser.TickFrequency))
                    {
                        Health enemyHealth = null;
                        Entities.ForEach((Enemy enemy, Health health) =>
                        {
                            if (enemy == closestEnemy)
                            {
                                enemyHealth = health;
                            }
                        });
                        if (enemyHealth != null)
                        {
                            Damage tickDamage = new Damage()
                            {
                                Amount = laser.BaseTickDamage.Amount + (laser.AddedDamagePerTick * (float)laser.NumConsecutiveTicks),
                                Type   = laser.BaseTickDamage.Type
                            };
                            enemyHealth.Damage.Enqueue(tickDamage);
                            laser.NumConsecutiveTicks++;
                            laser.LastTickTime = Time.ElapsedTime;
                        }
                    }
                }
                else
                {
                    laser.LineRenderer.SetPosition(1, new Vector3(currentEndPosition.x, currentEndPosition.y, 0f));
                    laser.NumConsecutiveTicks = 0;
                }
            }
            else
            {
                laser.LineRenderer.SetPosition(1, new Vector3(currentEndPosition.x, currentEndPosition.y, 0f));
                laser.NumConsecutiveTicks = 0;
            }
        });
    }
        public override bool FireEvent(Event E)
        {
            if (E.ID == "BeforeApplyDamage")
            {
                Damage parameter = E.GetParameter("Damage") as Damage;
                if (!(parameter.HasAttribute("Electric") || parameter.HasAttribute("Shock") || parameter.HasAttribute("Lightning") || parameter.HasAttribute("Electricity")))
                {
                    return(true);
                }

                double ReductionDouble = (double)parameter.Amount * GetPercentageResist(this.Level);
                int    Reduction       = (int)Math.Floor(ReductionDouble);
                if (ReductionDouble - (double)Reduction >= Stat.Rnd.NextDouble())
                {
                    Reduction += 1;
                }
                if (Reduction > 0 && this.ParentObject.IsPlayer())
                {
                    MessageQueue.AddPlayerMessage("Your scales absorb " + Reduction.ToString() + " damage from the electricity.");
                }
                parameter.Amount = Math.Max(0, parameter.Amount - Reduction);
                return(false);
            }
            if (E.ID == "EndTurn" && this.ChargeCellsActivatedAbility != null && this.ChargeCellsActivatedAbility.ToggleState)
            {
                foreach (GameObject EquippedObject in this.ParentObject.GetPart <Body>().GetEquippedObjects())
                {
                    if (EquippedObject == null)
                    {
                        continue;
                    }

                    EnergyCell Cell = null;
                    if (EquippedObject != null && EquippedObject.HasPart("EnergyCell"))
                    {
                        Cell = EquippedObject.GetPart <EnergyCell>();
                    }
                    else if (EquippedObject.HasPart("EnergyCellSocket"))
                    {
                        EnergyCellSocket Socket = this.ParentObject.GetPart <EnergyCellSocket>();
                        if (Socket.Cell != null && Socket.Cell.HasPart("EnergyCell"))
                        {
                            Cell = Socket.Cell.GetPart <EnergyCell>();
                        }
                    }

                    if (Cell != null && Cell.CanBeRecharged() && Cell.GetRechargeAmount() > 0)
                    {
                        // Cells have varying degrees of charge rates so we need to
                        int RechargedAmount = ConsumeCharge(Math.Min(Cell.GetRechargeAmount(), Cell.ChargeRate));
                        if (RechargedAmount == 0) // hungry....
                        {
                            if (this.ParentObject.IsPlayer())
                            {
                                MessageQueue.AddPlayerMessage("You're too hungry to muster any more energy...");
                            }
                            this.ChargeCellsActivatedAbility.ToggleState = false;
                            break;
                        }
                        else
                        {
                            Cell.AddCharge(RechargedAmount);
                        }
                    }
                }
            }
            return(base.FireEvent(E));
        }
Exemple #42
0
 int IDamageModifier.GetDamageModifier(Actor attacker, Damage damage)
 {
     return(state == PopupState.Closed ? info.ClosedDamageMultiplier : 100);
 }
Exemple #43
0
    public static void AttackEnemy(GameObject player, GameObject enemy, Dictionary <GameObject, List <Element> > whichElementReachEnemy)
    {
        Player      playerStatus  = player.gameObject.GetComponent <Player>();
        Enemy       enemyStatus   = enemy.gameObject.GetComponent <Enemy>();
        Damage      elementDamage = CheckElement(playerStatus.element, enemyStatus.element);
        float       elementWeight = 1.0f;
        ChainWeight chainDamage   = CheckChainCount(player, enemy, whichElementReachEnemy);
        float       chainWeight   = 1.0f;
        Skill       skill;

        if (playerStatus.characterName == Player.CharacterName.Roserian)
        {
            if (elementDamage.damageAdd)
            {
                skill = new EnhanceWeakpoint();
                if (skill.activated)
                {
                    elementWeight = elementDamage.damageWeight + skill.GetWeightedValue();
                }
            }

            else if (elementDamage.damageLoss)
            {
                skill = new BreakWeakpoint();
                if (skill.activated)
                {
                    elementWeight = elementDamage.damageWeight + skill.GetWeightedValue();
                }
            }

            if (chainDamage.chainActive)
            {
                skill = new EnhanceChain();
                if (skill.activated)
                {
                    chainWeight = chainDamage.chainWeight + skill.GetWeightedValue();
                }
            }

            else if (!chainDamage.chainActive)
            {
                skill = new BreakChain();
                if (skill.activated)
                {
                    chainWeight = chainDamage.chainWeight + skill.GetWeightedValue();
                }
            }
        }

        if (playerStatus.characterName == Player.CharacterName.Hesmen)
        {
            if (chainDamage.chainActive)
            {
                skill = new Weaken();
                if (skill.activated)
                {
                    skill.Use(enemyStatus);
                }
            }

            skill = new HpAbsorption();
            if (skill.activated)
            {
                skill.Use(playerStatus);
            }
        }

        enemyStatus.hp -= (int)(playerStatus.atk * elementWeight * chainWeight);
    }
Exemple #44
0
        /// <summary>
        /// Loads an item definition
        /// </summary>
        /// <param name="xml">Xml handle</param>
        /// <returns>True if loaded, or false</returns>
        public bool Load(XmlNode xml)
        {
            if (xml == null || xml.Name != "item")
            {
                return(false);
            }

            //ID = int.Parse(xml.Attributes["id"].Value);
            Name = xml.Attributes["name"].Value;

            foreach (XmlNode node in xml)
            {
                if (node.NodeType == XmlNodeType.Comment)
                {
                    continue;
                }


                switch (node.Name.ToLower())
                {
                case "script":
                {
                    Script.Load(node);
                    //ScriptName = node.Attributes["name"].Value;
                    //InterfaceName = node.Attributes["interface"].Value;
                }
                break;

                case "type":
                {
                    Type = (ItemType)Enum.Parse(typeof(ItemType), node.Attributes["value"].Value, true);
                }
                break;

                case "slot":
                {
                    Slot |= (BodySlot)Enum.Parse(typeof(BodySlot), node.Attributes["value"].Value, true);
                }
                break;

                case "damagetype":
                {
                    DamageType |= (DamageType)Enum.Parse(typeof(DamageType), node.Attributes["value"].Value, true);
                }
                break;

                case "weight":
                {
                    Weight = int.Parse(node.Attributes["value"].Value);
                }
                break;

                case "damage":
                {
                    Damage.Load(node);
                }
                break;

                case "damagevsbig":
                {
                    DamageVsBig.Load(node);
                }
                break;

                case "damagevssmall":
                {
                    DamageVsSmall.Load(node);
                }
                break;

                case "critical":
                {
                    Critical           = new Point(int.Parse(node.Attributes["min"].Value), int.Parse(node.Attributes["max"].Value));
                    CriticalMultiplier = int.Parse(node.Attributes["multiplier"].Value);
                }
                break;

                case "shortname":
                {
                    ShortName = node.InnerText;
                }
                break;

                case "identifiedname":
                {
                    IdentifiedName = node.InnerText;
                }
                break;

                case "isidentified":
                {
                    IsIdentified = bool.Parse(node.Attributes["value"].Value);
                }
                break;

                case "isbig":
                {
                    IsBig = true;
                }
                break;

                case "canidentify":
                {
                    CanIdentify = bool.Parse(node.Attributes["value"].Value);
                }
                break;

                case "speed":
                {
                    AttackSpeed = TimeSpan.FromMilliseconds(int.Parse(node.Attributes["value"].Value));
                }
                break;

                case "ac":
                {
                    ArmorClass = Byte.Parse(node.Attributes["value"].Value);
                }
                break;

                case "tile":
                {
                    TileSetName    = node.Attributes["name"].Value;
                    TileID         = int.Parse(node.Attributes["inventory"].Value);
                    GroundTileID   = int.Parse(node.Attributes["ground"].Value);
                    IncomingTileID = int.Parse(node.Attributes["incoming"].Value);
                    ThrowTileID    = int.Parse(node.Attributes["moveaway"].Value);
                }
                break;

                case "classes":
                {
                    AllowedClasses = (HeroClass)Enum.Parse(typeof(HeroClass), node.Attributes["value"].Value);
                }
                break;

                case "allowedhands":
                {
                    AllowedHands = (HeroHand)Enum.Parse(typeof(HeroHand), node.Attributes["value"].Value);
                }
                break;

                case "cursed":
                {
                    IsCursed = bool.Parse(node.Attributes["value"].Value);
                }
                break;


                case "twohanded":
                {
                    TwoHanded = bool.Parse(node.Attributes["value"].Value);
                }
                break;
                }
            }



            return(true);
        }
Exemple #45
0
 void Start()
 {
     damageType = Damage.None;
 }
Exemple #46
0
 internal static float GetDamageCalc(Obj_AI_Base Sender, Obj_AI_Base Target, Damage.DamageType Type, double Equation = 0d)
 {
     return((float)Damage.CalcDamage(Sender, Target, Type, Equation));
 }
Exemple #47
0
 public bool onHit(Projectile projectile, Damage damage, GameObject attacker, GameObject target)
 {
     return(animator.GetInteger(Unit.ANIMATION) == (int)Unit.Animation.SPRINT && Random.value < DODGE_CHANCE);
 }
Exemple #48
0
 // Use this for initialization
 void Start()
 {
     damageClass = FindObjectOfType <Damage>();
     enemHealth  = FindObjectOfType <EnemyHealth>();
 }
 public long CheckExclusiveDamage(AgentTag AgentTag)
 {
     return(IsExclusiveTarget(AgentTag) ? Damage.Mul(this.ExclusiveDamageModifier) : Damage);
 }
Exemple #50
0
        private static void UseCombo()
        {
            if (Target == null)
            {
                return;
            }

            bool AllSkills = false;

            if (ComboDmg(Target) > Target.Health && Target.Distance(Player) <= 950)
            {
                AllSkills = true;
            }

            if (GetBool("UseItems") && AllSkills && GetDistanceSqr(Player, Target) <= 750 * 750)
            {
                if (Items.CanUseItem(3128))
                {
                    Items.UseItem(3128, Target);
                }
                if (Items.CanUseItem(3188))
                {
                    Items.UseItem(3188, Target);
                }
            }
            if (GetBool("UseQ") && Q.IsReady() && GetDistanceSqr(Player, Target) <= Q.Range * Q.Range)
            {
                Q.CastIfHitchanceEquals(Target, hitChance, GetBool("UsePacket"));
                if (Target.IsValidTarget(550) && Target.HasBuff("luxilluminatingfraulein"))
                {
                    Player.IssueOrder(GameObjectOrder.AttackUnit, Target);
                }
            }
            if (GetBool("UseW") && W.IsReady() && Utility.IsFacing(Player, Target, 450) && Player.Distance(Target) <= 450)
            {
                W.Cast(Target, GetBool("UsePacket"));
            }
            if (GetBool("UseE") && E.IsReady() && GetDistanceSqr(Player, Target) <= E.Range * E.Range)
            {
                if (GetBool("UseQE"))
                {
                    if (Target.HasBuff("LuxLightBindingMis"))
                    {
                        E.Cast(Target, GetBool("UsePacket"));
                        CastE2();
                    }
                }
                else
                {
                    E.CastIfHitchanceEquals(Target, hitChance, GetBool("UsePacket"));
                    CastE2();
                }
                if (Target.IsValidTarget(550) && Target.HasBuff("luxilluminatingfraulein"))
                {
                    Player.IssueOrder(GameObjectOrder.AttackUnit, Target);
                }
            }
            if (GetBool("UseR") && R.IsReady() && (R.IsKillable(Target) || AllSkills))
            {
                if (Target.Health <= Damage.GetAutoAttackDamage(Player, Target, true) && Player.Distance(Target) < 550)
                {
                    Player.IssueOrder(GameObjectOrder.AttackUnit, Target);
                }
                else
                {
                    R.CastIfHitchanceEquals(Target, HitChance.High, GetBool("UsePacket"));
                }
            }
            if (GetBool("UseIgnite") && (IgniteKillable(Target) || AllSkills) && CanIgnite())
            {
                if (Player.Distance(Target) <= 600)
                {
                    if (Target.Health <= Damage.GetAutoAttackDamage(Player, Target, true) && Player.Distance(Target) < 550)
                    {
                        Player.IssueOrder(GameObjectOrder.AttackUnit, Target);
                    }
                    else
                    {
                        Player.Spellbook.CastSpell(IgniteSlot, Target);
                    }
                }
            }
        }
Exemple #51
0
        private static double GetDamage(AIHeroClient target)
        {
            var pDamage     = Damage.CalcDamage(Player, target, Damage.DamageType.Magical, (.08) * target.MaxHealth);
            var qDamage     = Damage.GetSpellDamage(Player, target, SpellSlot.Q);
            var wDamage     = Damage.GetSpellDamage(Player, target, SpellSlot.W);
            var eDamage     = Damage.GetSpellDamage(Player, target, SpellSlot.E);
            var rDamage     = Damage.GetSpellDamage(Player, target, SpellSlot.R);
            var iDamage     = Damage.GetSummonerSpellDamage(Player, target, Damage.SummonerSpell.Ignite);
            var totalDamage = 0.0;

            var myMana    = Player.Mana;
            var qMana     = _Q.Instance.SData.Mana;
            var wMana     = _W.Instance.SData.Mana;
            var eMana     = _E.Instance.SData.Mana;
            var rMana     = _R.Instance.SData.Mana;
            var totalMana = 0.0;

            if (!_Q.IsReady())
            {
                qDamage = 0.0;
            }
            if (!_W.IsReady())
            {
                wDamage = 0.0;
            }
            if (!_E.IsReady())
            {
                eDamage = 0.0;
            }
            if (!_R.IsReady())
            {
                rDamage = 0.0;
            }
            if (_Ignite.Slot == SpellSlot.Unknown)
            {
                iDamage = 0.0;
            }

            if (myMana >= eMana && myMana >= totalMana)
            {
                totalMana   += eMana;
                totalDamage += eDamage;
            }

            if (myMana >= qMana && myMana >= totalMana)
            {
                totalMana   += qMana;
                totalDamage += qDamage;
            }

            if (myMana >= wMana && myMana >= totalMana)
            {
                totalMana   += wMana;
                totalDamage += wDamage;
            }

            if (myMana >= rMana && myMana >= totalMana)
            {
                totalMana   += rMana;
                totalDamage += rDamage;
            }

            totalDamage += pDamage;
            totalDamage += iDamage;
            return(totalDamage);
        }
Exemple #52
0
 public Damage(Damage other) : base(other)
 {
     this.damageValue = other.damageValue;
 }
Exemple #53
0
        public static void Execute()
        {
            if (Q.IsReady() && Settings.Combo.UseQ)
            {
                var target = TargetSelector.GetTarget(GetRealRocketLauncherRange(), DamageType.Physical);

                if (target != null)
                {
                    if (target.Distance(Player.Instance) < GetRealMinigunRange() && HasRocketLauncher &&
                        target.TotalHealthWithShields() > Player.Instance.GetAutoAttackDamage(target, true) * 2.2f)
                    {
                        Q.Cast();
                        return;
                    }

                    if (target.Distance(Player.Instance) > GetRealMinigunRange() &&
                        target.Distance(Player.Instance) < GetRealRocketLauncherRange() && !HasRocketLauncher)
                    {
                        Q.Cast();
                        return;
                    }
                    if (HasMinigun && GetMinigunStacks >= 2 &&
                        target.TotalHealthWithShields() < Player.Instance.GetAutoAttackDamage(target, true) * 2.2f && target.TotalHealthWithShields() > Player.Instance.GetAutoAttackDamage(target, true) * 2f)
                    {
                        Q.Cast();
                        return;
                    }
                }
            }

            if (W.IsReady() && Settings.Combo.UseW && !Player.Instance.Position.IsVectorUnderEnemyTower())
            {
                var target =
                    EntityManager.Heroes.Enemies.Where(
                        x =>
                        x.IsValidTarget(W.Range) && !x.HasUndyingBuffA() && !x.HasSpellShield() &&
                        x.Distance(Player.Instance) > Settings.Combo.WMinDistanceToTarget)
                    .OrderByDescending(x => Player.Instance.GetSpellDamage(x, SpellSlot.W)).FirstOrDefault();

                if (target != null)
                {
                    var wPrediction = W.GetPrediction(target);
                    if (wPrediction.HitChance == HitChance.High)
                    {
                        W.Cast(wPrediction.CastPosition);
                        return;
                    }
                }
            }

            if (E.IsReady() && Settings.Combo.UseE)
            {
                var target = TargetSelector.GetTarget(E.Range, DamageType.Physical);

                if (target != null)
                {
                    var ePrediction = E.GetPrediction(target);
                    if (ePrediction.HitChance == HitChance.High && ePrediction.CastPosition.Distance(target) > 150)
                    {
                        E.Cast(ePrediction.CastPosition);
                        return;
                    }
                }
            }

            if (!R.IsReady() || !Settings.Combo.UseR || Player.Instance.Position.IsVectorUnderEnemyTower())
            {
                return;
            }

            var t = TargetSelector.GetTarget(3000, DamageType.Physical);

            if (t == null || t.HasUndyingBuffA() || !(t.Distance(Player.Instance) > GetRealRocketLauncherRange() + 100))
            {
                return;
            }

            var health = t.TotalHealthWithShields() - IncomingDamage.GetIncomingDamage(t);

            if (health > 0 && health < Damage.GetRDamage(t))
            {
                var rPrediction = R.GetPrediction(t);

                if (rPrediction.HitChance != HitChance.High)
                {
                    return;
                }

                R.Cast(rPrediction.CastPosition);
                Console.WriteLine("KS ULT");
            }
            else
            {
                var rPrediction = R.GetPrediction(t);

                if (t.CountEnemiesInRange(225) < 5 || rPrediction.HitChance != HitChance.High)
                {
                    return;
                }

                R.Cast(rPrediction.CastPosition);
                Console.WriteLine("AOE ULT");
            }
        }
Exemple #54
0
 private static bool IgniteKillable(Obj_AI_Base target)
 {
     return(Damage.GetSummonerSpellDamage(myHero, target, Damage.SummonerSpell.Ignite) > target.Health);
 }
Exemple #55
0
    /// ---------------------------------------- 데미지 처리 ---------------------------------------------------- ///
    // 피해
    public virtual void ApplyDamage(Damage damage)
    {
        if (damage == null)
        {
            return;
        }

        if (isDead)
        {
            return;
        }

        // 공격자 정보가 있는가?
        if (damage.sourceGameObject)
        {
            // 공격자가 유닛인가?
            Unit sourceUnit = null;

            if (damage.sourceGameObject.GetComponent <Unit>() != null)
            {
                sourceUnit = damage.sourceGameObject.GetComponent <Unit>();
            }

            // 공격자가 실명이고 온힛 스킬이면 무효화
            if (sourceUnit.buffDictionary != null)
            {
                if ((sourceUnit.buffDictionary[BuffType.blind].currentSecond > 0) && damage.onHit)
                {
                    return;
                }
            }
        }

        float totalNormalDamage = 0;
        float totalMagicDamage  = 0;
        float totalTrueDamage   = 0;
        float totalIncreaseHp   = 0;
        float totalIncreaseMp   = 0;
        float totalDecreaseMp   = 0;

        totalNormalDamage = damage.normalDamage * (100 / (100 + currentAttackArmor));
        totalMagicDamage  = damage.magicDamage * (100 / (100 + currentSpellArmor));
        totalTrueDamage   = damage.trueDamage;
        totalDecreaseMp   = damage.decreaseMp;
        totalIncreaseHp   = damage.increaseHp;
        totalIncreaseMp   = damage.increaseMp;

        // 내가 약화 상태이면 데미지 1.5배 증가
        if (buffDictionary[BuffType.hurt].currentSecond > 0)
        {
            totalNormalDamage *= 1.5f;
            totalMagicDamage  *= 1.5f;
            totalTrueDamage   *= 1.5f;
        }

        // 내가 치유 금지 상태이면 치유 효과 0으로 만듬
        if (buffDictionary[BuffType.banHealing].currentSecond > 0)
        {
            totalIncreaseHp = 0;
        }

        // 데미지를 적용하고 적용된 데미지 정보에 따라 데미지텍스트 출력하기
        if (totalNormalDamage > 0)
        {
            CurrentHealth -= totalNormalDamage;
            StartCoroutine(PrintDamageText(totalNormalDamage, DamageType.normalDamage));
        }
        if (totalMagicDamage > 0)
        {
            CurrentHealth -= totalMagicDamage;
            StartCoroutine(PrintDamageText(totalMagicDamage, DamageType.magicDamage));
        }
        if (totalTrueDamage > 0)
        {
            CurrentHealth -= totalTrueDamage;
            StartCoroutine(PrintDamageText(totalTrueDamage, DamageType.trueDamage));
        }
        if (totalIncreaseHp > 0)
        {
            totalIncreaseHp *= currentHealthRegen / 100;
            CurrentHealth   += totalIncreaseHp;
            StartCoroutine(PrintDamageText(totalIncreaseHp, DamageType.increaseHp));
        }
        if (totalIncreaseMp > 0)
        {
            totalIncreaseMp *= currentManaRegen / 100;
            CurrentMana     += totalIncreaseMp;
            StartCoroutine(PrintDamageText(totalIncreaseMp, DamageType.increaseMp));
        }
        if (totalDecreaseMp > 0)
        {
            CurrentMana -= totalDecreaseMp;
            StartCoroutine(PrintDamageText(totalDecreaseMp, DamageType.decreaseMp));
        }

        CurrentMana += ((totalNormalDamage + totalMagicDamage + totalTrueDamage) / maxHealth) * (currentManaRegen / 100) * 100; // 총 받은 체력 비례 피해량에 비례해 마나 회복
        InitBuff(damage);                                                                                                       // 데미지 정보에 따라 버프 적용

        if (damage.sourceGameObject)
        {
            Unit   sourceUnit = damage.sourceGameObject.GetComponent <Unit>();
            Damage tempDamage = damage;
            tempDamage.normalDamage = totalNormalDamage;
            tempDamage.magicDamage  = totalMagicDamage;
            tempDamage.trueDamage   = totalTrueDamage;
            tempDamage.increaseHp   = totalIncreaseHp;
            tempDamage.increaseMp   = totalIncreaseMp;
            tempDamage.decreaseMp   = totalDecreaseMp;
            sourceUnit.SucessAttack(damage);
        }
    }
Exemple #56
0
        private void Combo()
        {
            Obj_AI_Hero target = TargetSelector.GetTarget(700, TargetSelector.DamageType.Physical);

            if (target == null)
            {
                return;
            }
            var combodamage = ComboDamage(target);

            if (config.Item("useItems").GetValue <bool>())
            {
                ItemHandler.UseItems(target, config, combodamage);
            }
            bool hasIgnite = player.Spellbook.CanUseSpell(player.GetSpellSlot("SummonerDot")) == SpellState.Ready;
            var  ignitedmg = (float)player.GetSummonerSpellDamage(target, Damage.SummonerSpell.Ignite);

            if (config.Item("useIgnite").GetValue <bool>() && hasIgnite &&
                ((R.IsReady() && ignitedmg + R.GetDamage(target) > target.Health) || ignitedmg > target.Health) &&
                (target.Distance(player) > E.Range || player.HealthPercent < 20))
            {
                player.Spellbook.CastSpell(player.GetSpellSlot("SummonerDot"), target);
            }
            if (config.Item("useq", true).GetValue <bool>() && Q.IsReady() &&
                player.Distance(target) > player.AttackRange && !GarenE && !GarenQ &&
                player.Distance(target) > Orbwalking.GetRealAutoAttackRange(target) &&
                CombatHelper.IsPossibleToReachHim(target, 0.30f, new float[5] {
                1.5f, 2f, 2.5f, 3f, 3.5f
            }[Q.Level - 1]))
            {
                Q.Cast(config.Item("packets").GetValue <bool>());
            }
            if (config.Item("useq", true).GetValue <bool>() && Q.IsReady() && !GarenQ &&
                (!GarenE || (Q.IsReady() && Damage.GetSpellDamage(player, target, SpellSlot.Q) > target.Health)))
            {
                if (GarenE)
                {
                    E.Cast(config.Item("packets").GetValue <bool>());
                }
                Q.Cast(config.Item("packets").GetValue <bool>());
                player.IssueOrder(GameObjectOrder.AutoAttack, target);
            }
            if (config.Item("usee", true).GetValue <bool>() && E.IsReady() && !Q.IsReady() && !GarenQ && !GarenE &&
                player.CountEnemiesInRange(E.Range) > 0)
            {
                E.Cast(config.Item("packets").GetValue <bool>());
            }
            var targHP = target.Health + 20 - CombatHelper.IgniteDamage(target);
            var rLogic = config.Item("user", true).GetValue <bool>() && R.IsReady() && target.IsValidTarget() &&
                         (!config.Item("ult" + target.SkinName, true).GetValue <bool>() ||
                          player.CountEnemiesInRange(1500) == 1) && getRDamage(target) > targHP && targHP > 0;

            if (rLogic && target.Distance(player) < R.Range)
            {
                if (!(GarenE && target.Health < getEDamage(target, true) && target.Distance(player) < E.Range))
                {
                    if (GarenE)
                    {
                        E.Cast(config.Item("packets").GetValue <bool>());
                    }
                    else
                    {
                        R.Cast(target, config.Item("packets").GetValue <bool>());
                    }
                }
            }
            if (config.Item("usew", true).GetValue <bool>() && W.IsReady() && player.CountEnemiesInRange(E.Range) > 0 &&
                target.IsFacing(player))
            {
                W.Cast(config.Item("packets").GetValue <bool>());
            }
            bool hasFlash = player.Spellbook.CanUseSpell(player.GetSpellSlot("SummonerFlash")) == SpellState.Ready;

            if (config.Item("useFlash", true).GetValue <bool>() && hasFlash && rLogic &&
                target.Distance(player) < R.Range + 425 && target.Distance(player) > R.Range + 250 && !Q.IsReady() &&
                !CombatHelper.IsFacing(target, player.Position) && !GarenQ)
            {
                if (target.Distance(player) < R.Range + 300 && player.MoveSpeed > target.MoveSpeed)
                {
                    return;
                }
                if (GarenE)
                {
                    E.Cast(config.Item("packets").GetValue <bool>());
                }
                else if (!player.Position.Extend(target.Position, 425f).IsWall())
                {
                }
                {
                    player.Spellbook.CastSpell(
                        player.GetSpellSlot("SummonerFlash"), player.Position.Extend(target.Position, 425f));
                }
            }
        }
Exemple #57
0
        void HandleUltTarget(EnemyInfo enemyInfo)
        {
            bool ultNow = false;
            bool me     = false;

            foreach (Obj_AI_Hero champ in Allies.Where(x => //gathering the damage from allies should probably be done once only with timers
                                                       x.IsValid <Obj_AI_Hero>() &&
                                                       !x.IsDead &&
                                                       ((x.IsMe && !x.IsStunned) || TeamUlt.Items.Any(item => item.GetValue <bool>() && item.Name == x.ChampionName)) &&
                                                       CanUseUlt(x)))
            {
                if (Menu.Item("checkCollision").GetValue <bool>() && UltSpellData[champ.ChampionName].Collision && IsCollidingWithChamps(champ, EnemySpawnPos, UltSpellData[champ.ChampionName].Width))
                {
                    enemyInfo.RecallInfo.IncomingDamage[champ.NetworkId] = 0;
                    continue;
                }

                //increase timeneeded if it should arrive earlier, decrease if later
                var timeneeded = GetUltTravelTime(champ, UltSpellData[champ.ChampionName].Speed, UltSpellData[champ.ChampionName].Delay, EnemySpawnPos) - 65;

                if (enemyInfo.RecallInfo.GetRecallCountdown() >= timeneeded)
                {
                    enemyInfo.RecallInfo.IncomingDamage[champ.NetworkId] = (float)Damage.GetSpellDamage(champ, enemyInfo.Player, SpellSlot.R, UltSpellData[champ.ChampionName].SpellStage) * UltSpellData[champ.ChampionName].DamageMultiplicator;
                }
                else if (enemyInfo.RecallInfo.GetRecallCountdown() < timeneeded - (champ.IsMe ? 0 : 125)) //some buffer for allies so their damage isnt getting reset
                {
                    enemyInfo.RecallInfo.IncomingDamage[champ.NetworkId] = 0;
                    continue;
                }

                if (champ.IsMe)
                {
                    me = true;

                    enemyInfo.RecallInfo.EstimatedShootT = timeneeded;

                    if (enemyInfo.RecallInfo.GetRecallCountdown() - timeneeded < 60)
                    {
                        ultNow = true;
                    }
                }
            }

            if (me)
            {
                if (!IsTargetKillable(enemyInfo))
                {
                    enemyInfo.RecallInfo.LockedTarget = false;
                    return;
                }

                enemyInfo.RecallInfo.LockedTarget = true;

                if (!ultNow || Menu.Item("panicKey").GetValue <KeyBind>().Active)
                {
                    return;
                }

                Ultimate.Cast(EnemySpawnPos, true);
                LastUltCastT = Environment.TickCount;
            }
            else
            {
                enemyInfo.RecallInfo.LockedTarget    = false;
                enemyInfo.RecallInfo.EstimatedShootT = 0;
            }
        }
Exemple #58
0
        private static float GetComboDamage(Obj_AI_Hero enemy)
        {
            IEnumerable <SpellSlot> spellCombo = new[] { SpellSlot.Q, SpellSlot.W, SpellSlot.E, SpellSlot.R };

            return((float)Damage.GetComboDamage(Player, enemy, spellCombo));
        }
 public float GetDamageAfterResistances(Damage damage)
 {
     return(GetDamageAfterResistances(damage.GetPhysicalDamage(), damage.GetFireDamage(), damage.GetFrostDamage()));
 }
Exemple #60
0
        private void BT_Heal_Click(object sender, EventArgs e)
        {
            // Проверяем, выбрано ли вообще повреждение.
            if (LB_Damages.SelectedItem != null)
            {
                // Создаём объект повреждения для передачи в следующее диалоговое окно и вывода в журнал.
                Damage selectedDamage = new Damage(Damage.GetTypeByName(LB_Damages.SelectedItem.ToString()));
                LogMessage("Лечение повреждения \"" + selectedDamage.name + "\"");

                ActionSelect action    = new ActionSelect(info, selectedDamage);
                DialogResult dlgResult = action.ShowDialog(); // вызываем окно

                switch (dlgResult)
                {
                // Повреждение вылечено
                case DialogResult.OK:
                {
                    // убрать вылеченное из списка
                    LB_Damages.Items.Remove(selectedDamage.ToString());

                    LogMessage("Повреждение устранено.");

                    // если повреждений больше нет - операция успешно завершена
                    if (LB_Damages.Items.Count == 0)
                    {
                        LogMessage("Пациент вылечен!");

                        info.isFinished = true;

                        DialogResult = DialogResult.OK;
                        Close();
                    }
                    break;
                }

                case DialogResult.Cancel:
                {         // процедура лечения ОТМЕНЕНА (т.е. не было произведено ни одного действия)
                    LogMessage("Процедура лечения отменена.");
                    break;
                }

                case DialogResult.Abort:
                {         // процедура лечения ПРЕРВАНА (т.е. действие было совершено, неважно - ошибочное или нет)
                    LogMessage("Процедура лечения прервана.");

                    // Наносим пациенту один уровень урона.
                    // Это не может его убить, т.к. прерывать лечение в критическом состоянии запрещено.
                    info.HurtStats();
                    break;
                }

                case DialogResult.No:
                {         // Попытки закончились, операция провалена. Убиваем пациента.
                    info.isFinished = true;

                    TMR_Pulse.Enabled = false;
                    TMR_Pulse.Dispose();
                    SoundLibrary.PlaySoundLooping(SoundLibrary.SoundType.BEEEEEEP);

                    info.Dead();
                    GUIUpdateStats();
                    TMR_StatsRandomize.Enabled = false;
                    LogMessage("Пациент скончался.");
                    GUIMessageBox.ShowDlg(new string[] { "", "Пациент скончался." });

                    DialogResult = DialogResult.None;

                    Close();

                    SoundLibrary.Stop();
                    break;
                }
                }

                // Контроль индикатора крит. состояния.
                if (info.IsCritical())
                {
                    LogMessage("Пациент в критическом состоянии!");
                    LB_Critical.Visible        = true;
                    TMR_CritFlickering.Enabled = true;
                }
                else
                {
                    TMR_CritFlickering.Enabled = false;
                    LB_Critical.Visible        = false;
                }
            }
            else
            {
                GUIMessageBox.ShowDlg(new string[] { "", "Сначала выберите повреждение." });
            }
        }