Example #1
0
        // Start is called before the first frame update
        void Start()
        {
            DefinitionStore.Instance.LoadChapter(25);
            //DefinitionStore.Instance.LoadChapter(18);

            //CreatureDefinition def = DefinitionStore.Instance.GetCreatureDefinition(50508);

            FDCreature subject = new FDCreature(4, CreatureFaction.Friend, DefinitionStore.Instance.GetCreatureDefinition(15), FDPosition.At(0, 0));
            FDCreature target  = new FDCreature(11, CreatureFaction.Enemy, DefinitionStore.Instance.GetCreatureDefinition(52502), FDPosition.At(0, 0));

            int hp1 = target.Data.HpMax;
            int hp2 = hp1 / 2;
            int hp3 = hp2 / 2;

            int hp4 = subject.Data.HpMax;
            int hp5 = hp4 / 2;
            int hp6 = hp5 / 2;

            Debug.Log(string.Format(@"hp1: {0}, hp2: {1}, hp3: {2}", hp1, hp2, hp3));

            AttackInformation a1 = new AttackInformation(hp1, hp2, false);
            AttackInformation a2 = new AttackInformation(hp2, hp3, false);
            AttackInformation b1 = new AttackInformation(hp4, hp5, false);
            AttackInformation b2 = new AttackInformation(hp5, hp6, false);

            FightInformation fightInfo = new FightInformation(a1, a2, b1, b2);

            this.Initialize(subject, target, fightInfo);

            fightPhase = FightPhase.Attack1;
            Invoke("DoSubjectAttack", 1.2f);
        }
Example #2
0
    void OnTriggerEnter2D(Collider2D coll)
    {
        if (!isServer)
        {
            return;
        }

        if (coll.name == gameObject.name)
        {
            return;
        }

        if (coll.name.ToLower() == "heart")
        {
            var stats = coll.transform.parent.gameObject.GetComponent <StatsManager>();
            AttackInformation attack = new AttackInformation(owner, damage);
            stats.DealDamage(attack);
            NetworkServer.Destroy(gameObject);
        }

        if (coll.gameObject.tag == "Environment")
        {
            NetworkServer.Destroy(gameObject);
        }
    }
Example #3
0
    protected override void ActivateEffect(GameObject player)
    {
        StatsManager = player.GetComponent <StatsManager>();
        AttackInformation attackInformation = new AttackInformation(player, -1);

        StatsManager.DealDamage(attackInformation);
    }
 public static void CalculateDamage(ref AttackInformation attackInformation, ref AttackCollisionData collisionData, WeaponComponentData weapon, ref int __result)
 {
     if ((attackInformation.IsVictimAgentMine || (attackInformation.IsVictimAgentMount && attackInformation.IsVictimAgentRiderAgentMine)) &&
         BannerlordCheatsSettings.Instance.Invincible)
     {
         __result = 0;
     }
 }
 public static void CalculateDamage(ref AttackInformation attackInformation, ref AttackCollisionData collisionData, WeaponComponentData weapon, ref int __result)
 {
     if ((attackInformation.AttackerFormation?.Team?.IsPlayerTeam ?? false) &&
         !attackInformation.IsFriendlyFire &&
         !BannerlordCheatsSettings.Instance.PartyOneHitKill)
     {
         __result *= BannerlordCheatsSettings.Instance.PartyDamageMultiplier;
     }
 }
 public static void CalculateDamage(ref AttackInformation attackInformation, ref AttackCollisionData collisionData, WeaponComponentData weapon, ref int __result)
 {
     if ((attackInformation.AttackerFormation?.Team?.IsPlayerTeam ?? false) &&
         attackInformation.IsFriendlyFire &&
         BannerlordCheatsSettings.Instance.NoFriendlyFire)
     {
         __result = 0;
     }
 }
Example #7
0
 public static void CalculateDamage(ref AttackInformation attackInformation, ref AttackCollisionData collisionData, WeaponComponentData weapon, ref int __result)
 {
     if ((attackInformation.AttackerAgentCharacter?.IsPlayerCharacter ?? false) &&
         !attackInformation.IsFriendlyFire &&
         attackInformation.IsVictimAgentHuman &&
         BannerlordCheatsSettings.Instance.OneHitKill)
     {
         __result = attackInformation.VictimAgentCharacter.HitPoints;
     }
 }
        public static void CalculateDamage(ref AttackInformation attackInformation, ref AttackCollisionData collisionData, WeaponComponentData weapon, ref int __result)
        {
            if ((attackInformation.VictimFormation?.Team?.IsPlayerTeam ?? false) &&
                !BannerlordCheatsSettings.Instance.PartyInvincible)
            {
                var factor = BannerlordCheatsSettings.Instance.PartyDamageTakenPercentage / 100f;

                var newValue = (int)Math.Round(factor * __result);

                __result = newValue;
            }
        }
Example #9
0
        /// <summary>
        /// Calculate the attack information for the attack on the specified defense Character
        /// </summary>
        /// <param name="defenseCharacter"></param>
        /// <returns></returns>
        public AttackInformation CalculateAttackInformation(Character defenseCharacter)
        {
            Debug.LogFormat("CalculateAttackInformation: {0}", defenseCharacter);
            Weapon attackWeapon = GetUsableItem <Weapon>();

            Debug.LogFormat("Attack weapon: {0}", attackWeapon);

            Weapon defenseWeapon = defenseCharacter.GetUsableItem <Weapon>();

            Debug.LogFormat("Defense weapon: {0}", defenseWeapon);

            bool defenseCanAttack = false;

            if (defenseWeapon != null)
            {
                defenseCanAttack = defenseWeapon.IsInRange(defenseCharacter.transform.position, transform.position);
            }

            int attackHitPercentage      = CalculateHitPercentage(attackWeapon, defenseCharacter, defenseWeapon);
            int attackDamage             = CalculateDamage(attackWeapon, defenseCharacter, defenseWeapon);
            int attackCriticalPercentage = CalculateCriticalPercentage(attackWeapon, defenseCharacter, defenseWeapon);
            int attackNumberOfAttacks    = CalculateNumberOfAttacks(attackWeapon, defenseCharacter, defenseWeapon);

            int defenseHitPercentage      = 0;
            int defenseDamage             = 0;
            int defenseCriticalPercentage = 0;
            int defenseNumberOfAttacks    = 0;

            if (defenseCanAttack)
            {
                defenseHitPercentage      = defenseCharacter.CalculateHitPercentage(defenseWeapon, this, attackWeapon);
                defenseDamage             = defenseCharacter.CalculateDamage(defenseWeapon, this, attackWeapon);
                defenseCriticalPercentage = defenseCharacter.CalculateCriticalPercentage(defenseWeapon, this, attackWeapon);
                defenseNumberOfAttacks    = defenseCharacter.CalculateNumberOfAttacks(defenseWeapon, this, attackWeapon);
            }

            AttackInformation attackInformation = new AttackInformation(
                attackWeapon: attackWeapon,
                attackHitPercentage: attackHitPercentage,
                attackDamage: attackDamage,
                attackCriticalPercentage: attackCriticalPercentage,
                attackNumberOfAttacks: attackNumberOfAttacks,
                defenseWeapon: defenseWeapon,
                defenseHitPercentage: defenseHitPercentage,
                defenseDamage: defenseDamage,
                defenseCriticalPercentage: defenseCriticalPercentage,
                defenseCanAttack: defenseCanAttack,
                defenseNumberOfAttacks: defenseNumberOfAttacks);

            Debug.Log(attackInformation);

            return(attackInformation);
        }
        public static void CalculateDamage(ref AttackInformation attackInformation, ref AttackCollisionData collisionData, WeaponComponentData weapon, ref int __result)
        {
            if ((attackInformation.IsVictimAgentMine || (attackInformation.IsVictimAgentMount && attackInformation.IsVictimAgentRiderAgentMine)) &&
                !BannerlordCheatsSettings.Instance.Invincible)
            {
                var factor = BannerlordCheatsSettings.Instance.DamageTakenPercentage / 100f;

                var newValue = (int)Math.Round(factor * __result);

                __result = newValue;
            }
        }
    public override void CheckNextLevel(AttackInformation atinf)
    {
        if (CurrentExperience >= NextLevelExperience)
        {
            //サウンドを鳴らす
            atinf.AddSound(SoundInformation.SoundType.Levelup);
            atinf.AddVoice(VoiceInformation.VoiceType.Levelup);

            atinf.AddMessage(
                string.Format(CommonConst.Message.LevelUpPlayer, DisplayNameInMessage));
            Level++;
            atinf.AddEffect(EffectFlareCore.CreateObject(this));
            TablePlayerLebel.SetLevel(this, Level);
        }
    }
Example #12
0
 public static void CalculateDamage(ref AttackInformation attackInformation, ref AttackCollisionData collisionData, WeaponComponentData weapon, ref float __result)
 {
     try
     {
         if (attackInformation.AttackerAgentCharacter.IsPlayer() &&
             !attackInformation.IsFriendlyFire &&
             BannerlordCheatsSettings.Instance?.OneHitKill == true)
         {
             __result = 10000;
         }
     }
     catch (Exception e)
     {
         SubModule.LogError(e, typeof(OneHitKill));
     }
 }
Example #13
0
 public static void CalculateDamage(ref AttackInformation attackInformation, ref AttackCollisionData collisionData, WeaponComponentData weapon, ref float __result)
 {
     try
     {
         if (attackInformation.AttackerAgentOrigin.TryGetParty(out var party) &&
             party.IsPlayerParty() &&
             attackInformation.IsFriendlyFire &&
             BannerlordCheatsSettings.Instance?.NoFriendlyFire == true)
         {
             __result = 0;
         }
     }
     catch (Exception e)
     {
         SubModule.LogError(e, typeof(NoFriendlyFire));
     }
 }
 public static void CalculateDamage(ref AttackInformation attackInformation, ref AttackCollisionData collisionData, WeaponComponentData weapon, ref float __result)
 {
     try
     {
         if (attackInformation.AttackerAgentOrigin.TryGetParty(out var party) &&
             party.IsPlayerParty() &&
             !attackInformation.AttackerAgentCharacter.IsPlayer() &&
             !attackInformation.IsFriendlyFire &&
             BannerlordCheatsSettings.Instance?.PartyDamageMultiplier > 1f)
         {
             __result *= BannerlordCheatsSettings.Instance.PartyDamageMultiplier;
         }
     }
     catch (Exception e)
     {
         SubModule.LogError(e, typeof(PartyDamageMultiplier));
     }
 }
Example #15
0
        public static void CalculateDamage(ref AttackInformation attackInformation, ref AttackCollisionData collisionData, WeaponComponentData weapon, ref float __result)
        {
            try
            {
                if (attackInformation.AttackerAgentOrigin.IsOnPlayerEnemySide() &&
                    BannerlordCheatsSettings.Instance?.EnemyDamagePercentage < 100f)
                {
                    var factor = BannerlordCheatsSettings.Instance.EnemyDamagePercentage / 100f;

                    var newValue = (int)Math.Round(factor * __result);

                    __result = newValue;
                }
            }
            catch (Exception e)
            {
                SubModule.LogError(e, typeof(EnemyDamagePercentage));
            }
        }
Example #16
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="defenseCharacter"></param>
        /// <returns></returns>
        private AttackResult Attack(Character defenseCharacter)
        {
            AttackInformation attackInformation = CalculateAttackInformation(defenseCharacter);

            AttackResult attackResult = ApplyAttack(
                attackInformation.AttackWeapon,
                attackInformation.AttackHitPercentage,
                attackInformation.AttackDamage,
                attackInformation.AttackCriticalPercentage,
                defenseCharacter);

            if (defenseCharacter.CurrentHp == 0)
            {
                return(attackResult);
            }

            if (attackInformation.DefenseCanAttack)
            {
                attackResult.Add(defenseCharacter.ApplyAttack(
                                     attackInformation.DefenseWeapon,
                                     attackInformation.DefenseHitPercentage,
                                     attackInformation.DefenseDamage,
                                     attackInformation.DefenseCriticalPercentage,
                                     this));

                if (CurrentHp == 0)
                {
                    return(attackResult);
                }
            }

            if (attackInformation.AttackNumberOfAttacks == 2)
            {
                attackResult.Add(ApplyAttack(
                                     attackInformation.AttackWeapon,
                                     attackInformation.AttackHitPercentage,
                                     attackInformation.AttackDamage,
                                     attackInformation.AttackCriticalPercentage,
                                     defenseCharacter));
            }

            return(attackResult);
        }
        public static void CalculateDamage(ref AttackInformation attackInformation, ref AttackCollisionData collisionData, WeaponComponentData weapon, ref float __result)
        {
            try
            {
                if (attackInformation.VictimAgentCharacter.IsPlayer() &&
                    BannerlordCheatsSettings.Instance?.DamageTakenPercentage < 100f)
                {
                    var factor = BannerlordCheatsSettings.Instance.DamageTakenPercentage / 100f;

                    var newValue = (int)Math.Round(factor * __result);

                    __result = newValue;
                }
            }
            catch (Exception e)
            {
                SubModule.LogError(e, typeof(DamageTakenPercentage));
            }
        }
Example #18
0
    void OnTriggerEnter2D(Collider2D coll)
    {
        if (coll.gameObject.tag == "Enemy")
        {
            if (!alreadyHit.Contains(coll.gameObject.GetInstanceID()))
            {
                alreadyHit.Add(coll.gameObject.GetInstanceID());
                AttackInformation attack = new AttackInformation(owner, 1);
                coll.gameObject.GetComponent <StatsManager>().DealDamage(attack);
                var hitEff = GameObject.Instantiate(hitEffect, transform.position - transform.forward * 0.5f, transform.rotation);
                Destroy(hitEff, 1);
            }
        }

        if (coll.gameObject.tag == "Environment")
        {
            NetworkServer.Destroy(gameObject);
        }
    }
Example #19
0
    public void DealDamage(AttackInformation attack)
    {
        if (!isServer)
        {
            return;
        }

        if (isVulnurable())
        {
            CurrentHP -= attack.damage;
        }

        HitReact();
        HPChange(CurrentHP);

        if (CurrentHP < 0)
        {
            Dies();
        }
    }
Example #20
0
 public static int CalculateDamage(int __result, ref AttackInformation attackInformation, ref AttackCollisionData collisionData, WeaponComponentData weapon)
 {
     if (!attackInformation.IsVictimAgentNull &&
         !attackInformation.IsAttackerAgentNull &&
         attackInformation.IsAttackerAgentHuman &&
         attackInformation.IsVictimAgentHuman &&
         !collisionData.IsFallDamage &&
         attackInformation.AttackerAgentCharacter is CharacterObject atacker &&
         attackInformation.VictimAgentCharacter is CharacterObject &&
         !collisionData.IsAlternativeAttack)
     {
         var   bonuses          = new CharacterAttributeBonuses(atacker);
         var   isMelee          = weapon != null && !weapon.IsRangedWeapon && !weapon.IsAmmo && !weapon.IsConsumable;
         float damageMultiplier = isMelee
             ? bonuses.MeleeDamageMultiplier
             : bonuses.RangeDamageMultiplier;
         var bonusDamage = (int)(__result * damageMultiplier);
         Logger.Log("Bonus " + bonusDamage + " damage from " + (isMelee ? "VIG" : "CON"), atacker);
         __result += bonusDamage;
     }
     return(__result);
 }
 public void OnDamaged(AttackInformation information)
 {
     this.isLastDamaged = true;
     this.LastDamage.CopyFrom(information);
     //this.lastDamage = information.Power;
     //this.lastAttackType = information.Type;
     //this.Life.Value += (int)information.Power;
 }
Example #22
0
 public abstract float CalculateDamage(
     ref AttackInformation attackInformation,
     ref AttackCollisionData collisionData,
     in MissionWeapon weapon,
 public override float CalculateDamage(ref AttackInformation attackInformation, ref AttackCollisionData collisionData, in MissionWeapon weapon, float baseDamage, out float bonusFromSkills)
Example #24
0
 private int CalculatePercentage(AttackInformation info, int percentage)
 {
     return(info.HpBefore - (info.HpBefore - info.HpAfter) * percentage / 100);
 }
 static bool Prefix(ref AttackInformation attackInformation, ref AttackCollisionData attackCollisionData, in MissionWeapon attackerWeapon, DamageTypes damageType, float magnitude, int speedBonus, bool cancelDamage, out int inflictedDamage, out int absorbedByArmor)
Example #26
0
    public override void AttackEffect(BaseCharacter target, BaseCharacter attacker, string damage, AttackState state, AttackInformation atinfo)
    {
        switch (WEType)
        {
        case WeaponEffectType.Stone:
            atinfo.AddEffect(EffectStoneThrow.CreateObject(target, attacker, damage, state));
            break;

        case WeaponEffectType.MachineGun:
            atinfo.AddEffect(
                EffectGunFIre.CreateObject(target, attacker, damage, state));
            break;

        default:
            base.AttackEffect(target, attacker, damage, state, atinfo);
            break;
        }
    }
    public virtual AttackState Attack(ManageDungeon dun, BaseCharacter target, BaseCharacter attacker, int power, AttackInformation atinf)
    {
        int damage = 0;

        atinf.AddTarget(target);

        //声を鳴らす
        atinf.AddVoice(attacker.VoiceAttack());

        //攻撃の命中判定
        if (CommonFunction.IsRandom(WeaponDexterity) == true)
        {
            //行動タイプを設定
            atinf.SetBehType(BehaviorType.Attack);

            //命中したら
            atinf.AddHit(target, true);

            //声を鳴らす
            atinf.AddVoice(target.VoiceDefence());

            //サウンドを鳴らす
            atinf.AddSound(GetAttackHitSound());

            BaseOption[] atoptions = attacker.Options;
            BaseOption[] tgoptions = target.Options;

            //与ダメージを計算
            damage = CalcDamage(dun, attacker, target, power, atoptions, tgoptions, 1);

            //スコア関連値の更新
            if (target.Type == ObjectType.Enemy)
            {
                TotalDamage += damage;
                if (ScoreInformation.Info.MostUseWeaponDamage < TotalDamage)
                {
                    ScoreInformation.Info.MostUseWeaponDamage = TotalDamage;
                    ScoreInformation.Info.MostUseWeaponName   = DisplayNameNormal;
                }

                ScoreInformation.Info.AddScore(damage);
            }

            //atinf.AddDamage(target.Name, damage);

            ////ヒットメッセージ
            //atinf.AddMessage(
            //    target.GetMessageAttackHit(this.DisplayNameInMessage, damage));

            ////ダメージ判定
            //AttackState atState = target.AddDamage(damage);
            //ダメージ追加
            AttackState atState = CommonFunction.AddDamage(atinf, attacker, target, damage);

            //ガラスアイテム判定
            WeaponBase atw = attacker.EquipWeapon;
            foreach (BaseOption op in atw.Options)
            {
                if (op.IsBreak() == true)
                {
                    atinf.AddSound(SoundInformation.SoundType.Break);

                    atinf.AddMessage(
                        string.Format(CommonConst.Message.BreakItem, atw.DisplayNameInMessage));

                    atw.ForceRemoveEquip(attacker);
                    PlayerCharacter.RemoveItem(atw);
                }
            }
            ShieldBase tgs = target.EquipShield;
            foreach (BaseOption op in tgs.Options)
            {
                if (op.IsBreak() == true)
                {
                    atinf.AddSound(SoundInformation.SoundType.Break);

                    atinf.AddMessage(
                        string.Format(CommonConst.Message.BreakItem, tgs.DisplayNameInMessage));

                    tgs.ForceRemoveEquip(target);
                    PlayerCharacter.RemoveItem(tgs);
                }
            }


            //対象が死亡したら
            if (atState == AttackState.Death)
            {
                atinf.AddKillList(target);

                atinf.AddMessage(
                    target.GetMessageDeath(target.HaveExperience));
            }
            else
            {
                //atinf.IsDeath.Add(target.Name, false);

                addabnormal.Clear();
                prevents.Clear();
                foreach (StateAbnormal val in CommonFunction.StateAbnormals)
                {
                    prevents.Add(val, 0);
                    addabnormal.Add(val, AddAbnormalProb[val]);
                }

                int opab = 0;
                //オプションの付加値設定
                foreach (BaseOption o in atoptions)
                {
                    int ab = o.SetAbnormalAttack(addabnormal);
                    opab = opab | ab;
                }

                int tarabn = AddAbnormal | opab;

                if (tarabn != 0)
                {
                    //オプションによる状態異常の取得
                    //foreach (StateAbnormal val in CommonFunction.StateAbnormals)
                    //{
                    //    addabnormal.Add(val, 0);
                    //}

                    //オプションの抵抗値設定
                    foreach (BaseOption o in tgoptions)
                    {
                        o.SetAbnormalPrevent(prevents);
                    }

                    int abn = 0;
                    //状態異常の付与
                    foreach (StateAbnormal val in CommonFunction.StateAbnormals)
                    {
                        int abnormal = (int)val & tarabn;

                        //対象の状態異常を処理
                        if (abnormal != 0)
                        {
                            //float prob = prevents[val] > AddAbnormalProb[val] ? prevents[val] : AddAbnormalProb[val];
                            //状態異常付与が成功したとき
                            if (CommonFunction.IsRandom(addabnormal[val]) == true)
                            {
                                //抵抗に成功したとき
                                if (CommonFunction.IsRandom(prevents[val]) == true)
                                {
                                }
                                else
                                {
                                    int addstate = target.AddStateAbnormal(abnormal);
                                    if (addstate != 0)
                                    {
                                        abn += abnormal;
                                        //atinf.AddAbnormal(target, abnormal);

                                        atinf.AddMessage(
                                            CommonFunction.GetAbnormalMessage(val, target));
                                    }
                                }
                            }
                        }
                    }
                    if (abn != 0)
                    {
                        atinf.AddEffect(EffectBadSmoke.CreateObject(target));
                        atinf.AddAbnormal(target, abn);
                    }
                }
            }

            //エフェクトをかける
            this.AttackEffect(target, attacker, damage.ToString(), AttackState.Hit, atinf);

            return(atState);
        }
        else
        {
            //外れた場合
            atinf.AddHit(target, false);

            EffectDamage d = EffectDamage.CreateObject(target);
            d.SetText("Miss", AttackState.Miss);
            atinf.AddEffect(d);

            atinf.AddSound(GetAttackMissSound());

            atinf.AddMessage(
                target.GetMessageAttackMiss());
            return(AttackState.Miss);
        }
    }
    public virtual void AttackEffect(BaseCharacter target, BaseCharacter attacker, string damage, AttackState state, AttackInformation atinfo)
    {
        EffectDamage d = EffectDamage.CreateObject(target);

        d.SetText(damage, state);
        atinfo.AddEffect(d);
    }
Example #29
0
    public void InjurePlayer(GameObject target, int damage)
    {
        AttackInformation attack = new AttackInformation(gameObject, damage);

        target.GetComponentInParent <StatsManager>().DealDamage(attack);
    }
 public void OnGuarding(AttackInformation information)
 {
     this.guardingAttack = information.Id;
 }