Esempio n. 1
0
        private void CheckAdjacentObstructions(MHit hit)
        {
            var tgt = hit.Data.Target.Current as CChar;

            if (tgt.Tile.Model.GetCol() <= hit.Data.Source.Tile.Model.GetCol())
            {
                if (tgt.Tile.Model.GetRow() >= hit.Data.Source.Tile.Model.GetRow())
                {
                    this.HandleQuadrantOne(hit, tgt);
                }
                else
                {
                    this.HandleQuadrantFour(hit, tgt);
                }
            }
            else
            {
                if (tgt.Tile.Model.GetRow() >= hit.Data.Source.Tile.Model.GetRow())
                {
                    this.HandleQuadrantTwo(hit, tgt);
                }
                else
                {
                    this.HandleQuadrantThree(hit, tgt);
                }
            }
        }
Esempio n. 2
0
        private void ProcessNewInjury(CChar tgt, MHit hit)
        {
            var injuries = new List <EInjury>();

            injuries.AddRange(hit.Data.Ability.Data.Injuries);
            if (hit.Data.Ability.Data.ParentWeapon != null)
            {
                injuries.AddRange(hit.Data.Ability.Data.ParentWeapon.Data.Injuries);
            }
            var random = ListUtil <EInjury> .GetRandomElement(injuries);

            if (random != EInjury.None)
            {
                try
                {
                    var injuryParams = InjuryTable.Instance.Table[random];
                    var injury       = injuryParams.GetInjury();
                    var data         = new EvInjuryData();
                    data.Hit    = hit;
                    data.Injury = injury;
                    data.Target = tgt;
                    var e = new EvInjury(data);
                    e.TryProcess();
                }
                catch (KeyNotFoundException e)
                {
                    Debug.LogError("Injury not found: " + random.ToString());
                    Debug.LogError(e.Message);
                }
            }
        }
Esempio n. 3
0
 public override void TryProcessHit(MHit hit, bool prediction)
 {
     base.TryProcessHit(hit, prediction);
     if (base.CheckConditions(hit))
     {
     }
 }
Esempio n. 4
0
        private void HandleHitCounterHelper(MHit hit, CChar tgt)
        {
            var data = new ActionData();

            data.Ability = EAbility.Attack_Of_Opportunity;
            bool proceed = false;

            if (tgt.Proxy.GetLWeapon() != null && !tgt.Proxy.GetLWeapon().IsTypeOfShield())
            {
                data.LWeapon      = true;
                data.ParentWeapon = tgt.Proxy.GetLWeapon();
                proceed           = true;
            }
            else if (tgt.Proxy.GetRWeapon() != null && !tgt.Proxy.GetRWeapon().IsTypeOfShield())
            {
                data.LWeapon      = false;
                data.ParentWeapon = tgt.Proxy.GetRWeapon();
                proceed           = true;
            }
            if (proceed)
            {
                data.Source     = tgt;
                data.Target     = hit.Data.Source.Tile;
                data.WpnAbility = true;
                var action = new MAction(data);
                action.TryProcess();
            }
        }
Esempio n. 5
0
 public virtual bool CheckConditions(MHit hit)
 {
     if (this.Data.AbilityCondition != EAbility.None)
     {
         if (hit.Data.Ability.Type != this.Data.AbilityCondition)
         {
             return(false);
         }
     }
     if (this.Data.CastCondition != ECastType.None)
     {
         if (hit.Data.Ability.Data.CastType != this.Data.CastCondition)
         {
             return(false);
         }
     }
     if (this.Data.WeaponCondition != "None")
     {
         if (hit.Data.Ability.Data.ParentWeapon == null)
         {
             return(false);
         }
         else
         {
             var name = hit.Data.Ability.Data.ParentWeapon.Data.Name;
             if (!name.Contains(this.Data.WeaponCondition))
             {
                 return(false);
             }
         }
     }
     return(true);
 }
Esempio n. 6
0
 public void PredictRay(MHit hit)
 {
     this._calcContainer.DodgeCalc.Predict(hit);
     this._calcContainer.CritCalc.Predict(hit);
     this._calcContainer.DmgCalc.Predict(hit);
     this._calcContainer.ResistCalc.Predict(hit);
 }
Esempio n. 7
0
        public double GetSurroundedDeltaMod(MHit hit)
        {
            double mod = 1;

            if (hit.Data.Ability.Data.CastType == Enum.ECastType.Melee)
            {
                int  count        = 0;
                bool attackerTeam = hit.Data.Source.Proxy.LParty;
                var  tgt          = hit.Data.Target.Current as CChar;
                bool defenderTeam = tgt.Proxy.LParty;
                if (attackerTeam != defenderTeam)
                {
                    foreach (var tile in hit.Data.Target.GetAdjacent())
                    {
                        if (tile.Current != null && tile.Current.GetType().Equals(typeof(CChar)))
                        {
                            var tileChar = tile.Current as CChar;
                            if (tileChar.Proxy.LParty == attackerTeam)
                            {
                                count++;
                            }
                        }
                    }
                }
                if (count > 1)
                {
                    mod -= (count * DELTA_BONUS);
                }
            }
            return(mod);
        }
Esempio n. 8
0
        public void CalculateAbilityDmg(MHit hit)
        {
            var hitData     = hit.Data;
            var abilityData = hitData.Ability.Data;
            var source      = hit.Data.Source.Proxy;
            var dmg         = hit.Data.ModData.BaseDamage;

            dmg += abilityData.FlatDamage;
            dmg += (abilityData.DmgPerPower * source.GetStat(ESecondaryStat.Power));
            dmg *= abilityData.DamageMod;
            if (hit.Data.Ability.Data.IsHeal)
            {
                // TODO:
                hit.Data.Dmg = (int)dmg;
            }
            else if (hit.Data.Ability.Data.ProcessDamage)
            {
                if (source.GetLWeapon() != null && hit.Data.IsWeapon && hit.Data.IsLWeapon)
                {
                    dmg += source.GetLWeapon().GetStat(EWeaponStat.Damage);
                    dmg *= source.GetLWeapon().GetDurabilityPercentage();
                }
                else if (source.GetRWeapon() != null && hit.Data.IsWeapon)
                {
                    dmg += source.GetRWeapon().GetStat(EWeaponStat.Damage);
                    dmg *= source.GetRWeapon().GetDurabilityPercentage();
                }
                hit.Data.Dmg = (int)dmg;
            }
            else
            {
                hit.Data.Dmg = 0;
            }
        }
Esempio n. 9
0
        public override void Predict(MHit hit)
        {
            var target = hit.Data.Target.Current as CChar;

            if (target != null)
            {
                var acc         = target.Proxy.GetStat(ESecondaryStat.Melee);
                var dodge       = target.Proxy.GetStat(ESecondaryStat.Dodge);
                var dodgeChance = LogicParams.BASE_DODGE_CHANCE / hit.Data.Ability.Data.AccMod;
                dodgeChance *= this.GetHeightDeltaMod(hit);
                dodgeChance *= this.GetSurroundedDeltaMod(hit);

                if (target.Proxy.GetArmor() != null)
                {
                    dodgeChance *= target.Proxy.GetArmor().GetStat(EArmorStat.Dodge_Mod);
                }
                if (target.Proxy.GetHelm() != null)
                {
                    dodgeChance *= target.Proxy.GetHelm().GetStat(EArmorStat.Dodge_Mod);
                }

                acc *= hit.Data.Ability.Data.AccMod;

                hit.Data.Chances.Dodge  = this.GetAttackVSDefenseSkillChance(acc, dodge, dodgeChance);
                hit.Data.Chances.Dodge *= hit.Data.Ability.Data.DodgeMod;
                hit.Data.Chances.Dodge *= hit.Data.ModData.TgtDodgeMod;
            }
        }
Esempio n. 10
0
        public void DoSingleFX(MHit hit)
        {
            var ability = hit.Data.Ability.Data.ParentAction.ActiveAbility;
            var sprites = this.GetSingleFXSprites(ability);

            if (sprites.Count > 0)
            {
                var roll = RNG.Instance.Next(ability.Data.MinSprites, ability.Data.MaxSprites);
                for (int i = 0; i < roll; i++)
                {
                    var fx       = new GameObject();
                    var renderer = fx.AddComponent <SpriteRenderer>();
                    var index    = ListUtil <int> .GetRandomElement(ability.Data.Sprites);

                    renderer.sprite           = sprites[index];
                    renderer.sortingLayerName = SortingLayers.PARTICLES;
                    fx.transform.position     = hit.Data.Target.Model.Center;
                    if (ability.Data.SingleFXRandomTranslate)
                    {
                        RotateTranslateUtil.Instance.RandomTranslate(fx, CombatGUIParams.SINGLE_FX_OFFSET);
                    }
                    fx.transform.SetParent(hit.Data.Target.Handle.transform);
                    var delete = fx.AddComponent <SDestroyByLifetime>();
                    delete.Init(fx, CombatGUIParams.SINGLE_FX_DUR);
                }
            }
            hit.CallbackHandler(null);
        }
Esempio n. 11
0
 public override void TryProcessAction(MHit hit)
 {
     //if (hit.Ability.CastType == ECastType.Melee)
     //{
     //    var source = hit.Source;
     //    var dur = (int)(this.Dur * AbilityLogic.Instance.GetSpellDurViaMod(hit.Source.Model));
     //    var hp = (int)(source.Model.GetCurrentStatValue(ESecondaryStat.Power) * this.ValPerPower);
     //    var hexes = source.CurrentTile.Model.GetAoETiles((int)this.AoE);
     //    foreach (var hex in hexes)
     //    {
     //        if (hex.Current != null && hex.Current.GetType().Equals(typeof(CharController)))
     //        {
     //            var character = hex.Current as CharController;
     //            if (character.LParty == hit.Source.LParty)
     //            {
     //                if (hp > 0 && dur > 0)
     //                {
     //                    var shield = new Shield(character, dur, hp);
     //                    var shieldEvent = new EvShield(CombatEventManager.Instance, shield, character);
     //                }
     //            }
     //        }
     //    }
     // }
 }
Esempio n. 12
0
        public override void Process(MHit hit)
        {
            if (hit.Data.Ability.Data.IsHeal)
            {
                // TODO:
            }
            else if (hit.Data.Ability.Data.ProcessDamage)
            {
                var src = hit.Data.Source.Proxy;
                var targetController = hit.Data.Target.Current as CChar;
                var tgt = targetController.Proxy;

                double dmgToApply    = this.GetCritDamage(hit, (double)hit.Data.Dmg);
                double dmgReduction  = tgt.GetStat(ESecondaryStat.Damage_Reduction);
                double flatDmgNegate = src.GetStat(ESecondaryStat.Damage_Ignore);

                if (FHit.HasFlag(hit.Data.Flags.CurFlags, FHit.Flags.Head))
                {
                    flatDmgNegate += this.GetArmorNegation(hit, src, tgt, flatDmgNegate, true);
                    dmgReduction   = this.GetDmgReduction(hit, src, tgt, dmgReduction, true);
                }
                else
                {
                    flatDmgNegate += this.GetArmorNegation(hit, src, tgt, flatDmgNegate, false);
                    dmgReduction   = this.GetDmgReduction(hit, src, tgt, dmgReduction, false);
                }
                dmgToApply  -= flatDmgNegate;
                dmgToApply  *= dmgReduction;
                hit.Data.Dmg = (int)dmgToApply;
            }
        }
Esempio n. 13
0
        public List <MHit> GetHits(AbilityArgs arg)
        {
            var tiles = this.GetTargetedTiles(arg);
            var hits  = new List <MHit>();

            if (this._data.HitsTiles)
            {
                foreach (var tile in tiles)
                {
                    var data = new HitData();
                    var hit  = new MHit(data);
                    this.PopulateHitData(hit, tile, arg);
                    hits.Add(hit);
                }
            }
            else
            {
                foreach (var tile in tiles)
                {
                    if (tile.Current != null && tile.Current.GetType().Equals(typeof(CChar)))
                    {
                        var target = tile.Current as CChar;
                        var data   = new HitData();
                        var hit    = new MHit(data);
                        this.PopulateHitData(hit, target.Tile, arg);
                        hits.Add(hit);
                    }
                }
            }
            return(hits);
        }
Esempio n. 14
0
        private double GetDmgReduction(MHit hit, PChar src, PChar tgt, double baseReduce, bool helm)
        {
            double reduction = baseReduce;

            if (helm && tgt.GetHelm() != null)
            {
                reduction *= tgt.GetHelm().GetStat(EArmorStat.Damage_Mod) / tgt.GetHelm().GetDurabilityPercentage();
            }
            else if (!helm && tgt.GetArmor() != null)
            {
                reduction *= tgt.GetArmor().GetStat(EArmorStat.Damage_Mod) / tgt.GetArmor().GetDurabilityPercentage();
            }
            if (hit.Data.IsWeapon)
            {
                double modifier = 1;
                if (hit.Data.IsLWeapon)
                {
                    modifier *= (src.GetLWeapon().GetStat(EWeaponStat.Armor_Ignore) / src.GetLWeapon().GetDurabilityPercentage());
                }
                else
                {
                    modifier *= (src.GetRWeapon().GetStat(EWeaponStat.Armor_Ignore) / src.GetRWeapon().GetDurabilityPercentage());
                }
                reduction /= modifier;
            }
            reduction *= hit.Data.Ability.Data.ArmorIgnoreMod;
            reduction *= hit.Data.ModData.SrcArmorIgnoreMod;
            return(reduction);
        }
Esempio n. 15
0
        private double GetArmorNegation(MHit hit, PChar src, PChar tgt, double baseNegation, bool helm)
        {
            double negation = baseNegation;

            if (helm && tgt.GetHelm() != null)
            {
                negation += tgt.GetHelm().GetStat(EArmorStat.Flat_Damage_Ignore);
                negation *= tgt.GetHelm().GetDurabilityPercentage();
            }
            else if (!helm && tgt.GetArmor() != null)
            {
                negation += tgt.GetArmor().GetStat(EArmorStat.Flat_Damage_Ignore);
                negation *= tgt.GetArmor().GetDurabilityPercentage();
            }
            if (hit.Data.IsWeapon)
            {
                double modifier = 1;
                if (hit.Data.IsLWeapon)
                {
                    modifier *= (src.GetLWeapon().GetStat(EWeaponStat.Armor_Pierce) / src.GetLWeapon().GetDurabilityPercentage());
                }
                else
                {
                    modifier *= (src.GetRWeapon().GetStat(EWeaponStat.Armor_Pierce) / src.GetRWeapon().GetDurabilityPercentage());
                }
                negation *= modifier;
            }
            negation /= hit.Data.Ability.Data.ArmorPierceMod;
            negation *= hit.Data.ModData.SrcArmorPierceMod;
            return(negation);
        }
Esempio n. 16
0
 private void ProcessPerks(MHit hit)
 {
     foreach (var perk in hit.Data.Source.Proxy.GetPerks().GetAbilityModPerks())
     {
         perk.TryModAbility(hit);
     }
 }
Esempio n. 17
0
        private void SetBulletStrayChance(MHit hit)
        {
            if (hit.Data.Source.Proxy.GetStat(ESecondaryStat.Ranged) < BASE_STRAY_FLOOR)
            {
                double delta = BASE_STRAY_FLOOR - hit.Data.Source.Proxy.GetStat(ESecondaryStat.Ranged);
                this._currentStrayChance = delta / BASE_STRAY_SCALAR / 100;

                foreach (var neighbor in hit.Data.Target.Model.GetAoETiles(1))
                {
                    var data = new StrayTargetData();
                    data.Tile   = neighbor.Controller;
                    data.Chance = this._currentStrayChance * BASE_ADJACENT_DIST_ONE_STRAY_CHANCE / BASE_ADJACENT_MULTIPLE;
                    this._strayTargets.Add(new Pair <double, double>(neighbor.GetCol(), neighbor.GetRow()), data);
                }
                foreach (var neighbor in hit.Data.Target.Model.GetAoETiles(2))
                {
                    var pair = new Pair <double, double>(neighbor.GetCol(), neighbor.GetRow());
                    if (!this._strayTargets.ContainsKey(pair))
                    {
                        var data = new StrayTargetData();
                        data.Tile   = neighbor.Controller;
                        data.Chance = this._currentStrayChance * BASE_ADJACENT_DIST_TWO_STRAY_CHANCE / BASE_ADJACENT_MULTIPLE;
                        this._strayTargets.Add(new Pair <double, double>(neighbor.GetCol(), neighbor.GetRow()), data);
                    }
                }
            }
        }
Esempio n. 18
0
 public void PredictBullet(MHit hit)
 {
     this._calcContainer.DodgeCalc.Predict(hit);
     this._calcContainer.BlockCalc.Predict(hit);
     this._calcContainer.DmgCalc.Predict(hit);
     this._calcContainer.ResistCalc.Predict(hit);
 }
Esempio n. 19
0
 private void ProcessBulletFlags(MHit hit)
 {
     this._calcContainer.DodgeCalc.Process(hit);
     this._calcContainer.BlockCalc.Process(hit);
     this._calcContainer.CritCalc.Process(hit);
     this._calcContainer.HeadShotCalc.Process(hit);
     this._calcContainer.ResistCalc.Process(hit);
 }
Esempio n. 20
0
 public override void TryModHit(MHit hit)
 {
     //base.TryModHit(hit);
     //if (hit.Target.Model.Shields.Count > 0)
     //{
     //    hit.ModData.BlockMod = this.Val;
     //}
 }
Esempio n. 21
0
        private int GetHP(MHit hit)
        {
            int hp = 0;

            hp += (int)hit.Data.Ability.Data.FlatDamage;
            hp += (int)(hit.Data.Ability.Data.DmgPerPower * hit.Data.Source.Proxy.GetStat(ESecondaryStat.Power));
            return(hp);
        }
Esempio n. 22
0
 public override void TryProcessHit(MHit hit, bool prediction)
 {
     base.TryProcessHit(hit, prediction);
     if (base.CheckConditions(hit))
     {
         hit.AddCallback(this.ProcessSummon);
     }
 }
Esempio n. 23
0
 public override void TryModHit(MHit hit)
 {
     //if (!hit.IsHeal)
     //{
     //    var mod = new SecondaryStatMod(ESecondaryStat.Parry, (int)this.Dur, this.Val);
     //    // TODO: Buff Event
     //}
 }
Esempio n. 24
0
        private void PredictPerks(MHit hit)
        {
            var tgt = hit.Data.Target.Current as CChar;

            foreach (var perk in tgt.Proxy.GetPerks().GetWhenHitPerks())
            {
                perk.TryModHit(hit);
            }
        }
Esempio n. 25
0
        public override void Process(MHit hit)
        {
            var roll = RNG.Instance.NextDouble();

            if (roll > LogicParams.BASE_HEAD_CHANCE)
            {
                FHit.SetHeadTrue(hit.Data.Flags);
            }
        }
Esempio n. 26
0
 public void PredictMelee(MHit hit)
 {
     this._calcContainer.DodgeCalc.Predict(hit);
     this._calcContainer.BlockCalc.Predict(hit);
     this._calcContainer.CritCalc.Predict(hit);
     this._calcContainer.ParryCalc.Predict(hit);
     this._calcContainer.DmgCalc.Predict(hit);
     this._calcContainer.ResistCalc.Predict(hit);
 }
Esempio n. 27
0
        public void ProcessBulletStrayPossible(MHit hit)
        {
            var logic = new BulletLogic();

            logic.AttemptToStrayBullet(hit);
            this.ProcessBulletFlags(hit);
            this._calcContainer.DmgCalc.CalculateAbilityDmg(hit);
            this._calcContainer.DmgCalc.ModifyDmgViaDefender(hit);
        }
Esempio n. 28
0
 public void ProcessDefenderHit(MHit hit)
 {
     if (hit.Data.Target.Current != null &&
         hit.Data.Target.Current.GetType().Equals(typeof(CChar)))
     {
         var target = hit.Data.Target.Current as CChar;
         this.ProcessDefenderHitsHelper(target, hit);
     }
 }
Esempio n. 29
0
 public override void TryModHit(MHit hit)
 {
     //if (FHit.HasFlag(hit.Flags.CurFlags, FHit.Flags.Critical) && !hit.IsHeal)
     //{
     //    var shieldQty = hit.Target.Model.GetCurrentStatValue(ESecondaryStat.HP) * this.Val;
     //    var shield = new Shield(hit.Source, (int)this.Dur, (int)shieldQty);
     //    var shieldEv = new EvShield(CombatEventManager.Instance, shield, hit.Source);
     //}
 }
Esempio n. 30
0
        public override void Process(MHit hit)
        {
            this.Predict(hit);
            var roll = RNG.Instance.NextDouble();

            if (hit.Data.Chances.Parry > roll)
            {
                FHit.SetParryTrue(hit.Data.Flags);
            }
        }