示例#1
0
    public bool ApplyImmune(eImmuneType immune_type, eAttackType attack_type, short skill_level)
    {
        if (ActionInfo.value < 100000)
        {
            int value = ActionInfo.value - (skill_level - Skill.Level) * GameConfig.Get <int>("stun_level_decrease");
            if (BattleBase.Instance.Rand.NextRange(1, 10000) > value)
            {
                return(false);
            }
        }

        if (Action != null)
        {
            Action.OnHit();
        }

        m_Creature.Character.CharacterAnimation.SetShield();

        if (immune_type == eImmuneType.dot)
        {
            TextManager.Instance.PushMessage(m_Creature, GetImmuneMessage(immune_type, attack_type), eBuffColorType.Immune, eTextPushType.Dot);
        }
        else
        {
            TextManager.Instance.PushMessage(m_Creature, GetImmuneMessage(immune_type, attack_type), eBuffColorType.Immune, eTextPushType.Normal);
        }
        return(true);
    }
示例#2
0
    public bool InvokeImmune(eImmuneType immune_type, eAttackType attack_type, short skill_level)
    {
        if (IsHidden() == true)
        {
            return(true);
        }

        List <Buff> shield_buffs = Buffs.Where(b => b.IsFinish == false && b.ActionInfo.actionType == eActionType.immune && b.ActionInfo.immune_types.Contains(immune_type) == true && b.ActionInfo.attack_types.Contains(attack_type) == true).ToList();

        foreach (Buff buff in shield_buffs)
        {
            if (buff.ApplyImmune(immune_type, attack_type, skill_level) == true)
            {
                return(true);
            }
        }
        return(false);
    }
示例#3
0
    string GetImmuneMessage(eImmuneType immune_type, eAttackType attack_type)
    {
        bool shield = ActionInfo.actionType == eActionType.shield;

        string message = "";

        if (attack_type == eAttackType.heal)
        {
            message = Localization.Get("ImmuneHeal");
        }
        else
        {
            bool immune_damage = shield == true || ActionInfo.immune_types.Contains(eImmuneType.damage);
            bool immune_dot    = shield == false && ActionInfo.immune_types.Contains(eImmuneType.dot);
            bool immune_debuff = shield == false && ActionInfo.immune_types.Contains(eImmuneType.debuff);
            bool immune_cc     = shield == false && ActionInfo.immune_types.Contains(eImmuneType.cc);

            if (immune_damage && immune_dot && immune_debuff && immune_cc)
            {
                message = Localization.Get("ImmuneAll");
            }
            else
            {
                switch (immune_type)
                {
                case eImmuneType.damage:
                case eImmuneType.dot:
                    if (immune_damage && immune_dot)
                    {
                        message = Localization.Get("ImmuneDamageDotDamage");
                    }
                    else if (immune_damage)
                    {
                        message = Localization.Get("ImmuneDamage");
                    }
                    else
                    {
                        message = Localization.Get("ImmuneDotDamage");
                    }
                    break;

                case eImmuneType.debuff:
                case eImmuneType.cc:
                    if (immune_debuff && immune_cc)
                    {
                        message = Localization.Get("ImmuneDebuffCC");
                    }
                    else if (immune_debuff)
                    {
                        message = Localization.Get("ImmuneDebuff");
                    }
                    else
                    {
                        message = Localization.Get("ImmuneCC");
                    }
                    break;
                }
            }

            bool immune_attack_type_physic = ActionInfo.attack_types.Contains(eAttackType.physic);
            bool immune_attack_type_magic  = ActionInfo.attack_types.Contains(eAttackType.magic);

            if (immune_attack_type_physic == true && immune_attack_type_magic == false)
            {
                message = Localization.Format("ImmunePhysicFormat", message);
            }
            else if (immune_attack_type_physic == false && immune_attack_type_magic == true)
            {
                message = Localization.Format("ImmuneMagicFormat", message);
            }
        }

        if (shield)
        {
            return(Localization.Format("ShieldFormat", message));
        }
        else
        {
            return(Localization.Format("ImmuneFormat", message));
        }
    }
示例#4
0
    static public ISkillBuff DoBuff(SkillInfo.Action buff_action, BattleCreature creature, BattleCreature target_creature, BattleSkill skill, int target_index, ISkillBuff parent)
    {
        switch (buff_action.actionType)
        {
        case eActionType.stun:
        case eActionType.hidden:
        case eActionType.sleep:
        {
            if (target_creature.InvokeImmune(eImmuneType.cc, skill.Creature.Info.AttackType, skill.Level) == true)
            {
                return(null);
            }

            int value = skill.GetValueWithTargetIndex(buff_action, target_index, -(target_creature.Level - skill.Level) * GameConfig.Get <int>("stun_level_decrease"));
            if (BattleBase.Instance.Rand.NextRange(1, 10000) > value)
            {
                TextManager.Instance.PushMessage(target_creature, Localization.Get("Miss"), eBuffColorType.Immune, eTextPushType.Normal);
                return(null);
            }

            float duration = skill.GetDuration(buff_action, target_index);
            Buff  buff     = new Buff(target_creature, skill, buff_action, value, duration, parent);
            if (duration == 0f)
            {
                buff.DoAction();
            }
            else if (duration > 0f || duration == -1f)
            {
                target_creature.AddBuff(buff, skill.Info.CanStack);
                TextManager.Instance.PushMessage(target_creature, Localization.Get(buff_action.actionType.ToString()), eBuffColorType.Stun, eTextPushType.Normal);
            }
            else
            {
                Debug.LogErrorFormat("duration is invalid : {0}", buff_action.SkillInfo.Name);
            }
            return(buff);
        }

        case eActionType.ignore_defense_damage:
        case eActionType.ignore_defense_damaged:
        case eActionType.worldboss:
        case eActionType.shield:
        case eActionType.immune:
        case eActionType.provoke:
        case eActionType.buff:
        case eActionType.buff_percent:
        {
            int value = skill.GetValueWithTargetIndex(buff_action, target_index, 0);

            float duration = skill.GetDuration(buff_action, target_index);

            Buff buff = new Buff(target_creature, skill, buff_action, value, duration, parent);
            if (duration == 0f)
            {
                buff.DoAction();
            }
            else if (duration > 0f || duration == -1f)
            {
                target_creature.AddBuff(buff, skill.Info.CanStack);
            }
            else
            {
                Debug.LogErrorFormat("duration is invalid : {0}", buff_action.SkillInfo.Name);
            }
            target_creature.SetWait();

            if (buff_action.statType == eStatType.AttackSpeed && duration > 0f)
            {
                buff.Duration *= (1f + value * 0.0001f);
            }

            return(buff);
        }

        case eActionType.debuff:
        case eActionType.debuff_percent:
        {
            eImmuneType immune_type = eImmuneType.debuff;
            switch (buff_action.actionType)
            {
            default:
                if (target_creature.InvokeImmune(immune_type, skill.Creature.Info.AttackType, skill.Level) == true)
                {
                    return(null);
                }
                break;
            }

            int value = -skill.GetValueWithTargetIndex(buff_action, target_index, 0);

            float duration = skill.GetDuration(buff_action, target_index);

            Buff buff = new Buff(target_creature, skill, buff_action, value, duration, parent);
            if (duration == 0f)
            {
                buff.DoAction();
            }
            else if (duration > 0f || duration == -1f)
            {
                target_creature.AddBuff(buff, skill.Info.CanStack);
            }
            else
            {
                Debug.LogErrorFormat("duration is invalid : {0}", buff_action.SkillInfo.Name);
            }

            target_creature.SetWait();

            if (buff_action.statType == eStatType.AttackSpeed && duration > 0f)
            {
                buff.Duration *= (1f - value * 0.0001f);
            }

            return(buff);
        }

        case eActionType.dot_damage:
        {
            int value = -skill.GetValueWithTargetIndex(buff_action, target_index, creature.GetDamageValue());

            value = Mathf.RoundToInt(value * (1f + (creature.GetValue(eStatType.IncreaseDamagePercent) - creature.GetValue(eStatType.DecreaseDamagePercent)) * 0.0001f));

            float duration = skill.GetDuration(buff_action, target_index);

            Buff buff = new Buff(target_creature, skill, buff_action, value, duration, parent);
            if (duration == 0f)
            {
                buff.DoAction();
            }
            else if (duration > 0f || duration == -1f)
            {
                target_creature.AddBuff(buff, skill.Info.CanStack);
            }
            else
            {
                Debug.LogErrorFormat("duration is invalid : {0}", buff_action.SkillInfo.Name);
            }

            target_creature.SetWait();

            return(buff);
        }

        case eActionType.dot_damage_mana:
        {
            int value = -skill.GetValueWithTargetIndex(buff_action, target_index, 0);

            float decrease = (10000 - (target_creature.Level - skill.Level) * GameConfig.Get <int>("mana_level_decrease")) * 0.0001f;
            value = Mathf.RoundToInt(value * (1f + (creature.GetValue(eStatType.IncreaseDamagePercent) - creature.GetValue(eStatType.DecreaseDamagePercent)) * 0.0001f + decrease));

            float duration = skill.GetDuration(buff_action, target_index);

            Buff buff = new Buff(target_creature, skill, buff_action, value, duration, parent);
            if (duration == 0f)
            {
                buff.DoAction();
            }
            else if (duration > 0f || duration == -1f)
            {
                target_creature.AddBuff(buff, skill.Info.CanStack);
            }
            else
            {
                Debug.LogErrorFormat("duration is invalid : {0}", buff_action.SkillInfo.Name);
            }

            target_creature.SetWait();
            return(buff);
        }

        case eActionType.dot_heal:
        {
            int value = skill.GetValueWithTargetIndex(buff_action, target_index, creature.GetDamageValue());
            value = Mathf.RoundToInt(value * (1f + creature.GetValue(eStatType.IncreaseDamagePercent) * 0.0001f));

            float duration = skill.GetDuration(buff_action, target_index);

            Buff buff = new Buff(target_creature, skill, buff_action, value, duration, parent);
            if (duration == 0f)
            {
                buff.DoAction();
            }
            else if (duration > 0f || duration == -1f)
            {
                target_creature.AddBuff(buff, skill.Info.CanStack);
            }
            else
            {
                Debug.LogErrorFormat("duration is invalid : {0}", buff_action.SkillInfo.Name);
            }
            target_creature.SetWait();

            return(buff);
        }

        case eActionType.dot_heal_mana:
        {
            int   value    = skill.GetValueWithTargetIndex(buff_action, target_index, 0);
            float decrease = (10000 - (target_creature.Level - skill.Level) * GameConfig.Get <int>("mana_level_decrease")) * 0.0001f;
            value = Mathf.RoundToInt(value * (1f + creature.GetValue(eStatType.IncreaseDamagePercent) * 0.0001f) * decrease);

            float duration = skill.GetDuration(buff_action, target_index);

            Buff buff = new Buff(target_creature, skill, buff_action, value, duration, parent);
            if (duration == 0f)
            {
                buff.DoAction();
            }
            else if (duration > 0f || duration == -1f)
            {
                target_creature.AddBuff(buff, skill.Info.CanStack);
            }
            else
            {
                Debug.LogErrorFormat("duration is invalid : {0}", buff_action.SkillInfo.Name);
            }
            target_creature.SetWait();

            return(buff);
        }
        }
        return(null);
    }