Example #1
0
 internal bool test_attack_flag_match(AttackAnims anim,
                                      AttackAnims definition_flag, AttackAnims test_flag)
 {
     // If this animation doesn't care about this definition, return true
     if (!AnimDefinition.HasEnumFlag(definition_flag))
     {
         return(true);
     }
     // Check if the animation data and the requested anim have the same flag
     return(AnimDefinition.HasEnumFlag(test_flag) == anim.HasEnumFlag(test_flag));
 }
        internal List <int> attack_animation(AttackAnims anim)
        {
            List <Battle_Animation_Variable_Set> anim_set;

            if (anim.HasEnumFlag(AttackAnims.Attack))
            {
                anim_set = Attack;
            }
            else if (anim.HasEnumFlag(AttackAnims.Hold))
            {
                anim_set = Hold;
            }
            else //if (anim.Overlaps(AttackAnims.Return))
            {
                anim_set = Return;
            }

            for (int i = anim_set.Count - 1; i >= 0; i--)
            {
                var animation = anim_set[i];
                // Check for hit, crit, damage caused
                if (!animation.test_attack_flag_match(anim,
                                                      AttackAnims.HitDefined, AttackAnims.Hit))
                {
                    continue;
                }
                if (!animation.test_attack_flag_match(anim,
                                                      AttackAnims.CritDefined, AttackAnims.Crit))
                {
                    continue;
                }
                if (!animation.test_attack_flag_match(anim,
                                                      AttackAnims.DamageDefined, AttackAnims.CausedDamage))
                {
                    continue;
                }
                if (!animation.test_attack_flag_match(anim,
                                                      AttackAnims.SkillDefined, AttackAnims.SkillActive))
                {
                    continue;
                }

                // All checks passed
                return(animation.Animation);
            }

            // Should never hit this, but just in case
            return(null);
        }
        public List <int> attack_animation(AnimTypeKeys type, int distance, AttackAnims anim)
        {
            var attack_set = AttackAnimations
                             .FirstOrDefault(x => x.Type.attack_type_match(type, distance));

            // If no match, for thrown weapons at 1 range, default down to normal attack if possible
            if (attack_set == null && type.HasEnumFlag(AnimTypeKeys.ThrownWeapon) && distance == 1)
            {
                attack_set = AttackAnimations
                             .FirstOrDefault(x => x.Type.attack_type_match(
                                                 (type & ~AnimTypeKeys.ThrownWeapon) | AnimTypeKeys.NormalAttack, distance));
            }
            if (attack_set != null)
            {
                return(attack_set.attack_animation(anim));
            }

            return(null);
        }
Example #4
0
        public bool test_attack_flag_match(AttackAnims anim)
        {
            foreach (var pair in ATTACK_DEFINITION_FLAGS)
            {
                AttackAnims definition_flag = pair.Key;
                AttackAnims test_flag       = pair.Value;

                // If this animation doesn't care about this definition, continue
                if (!AnimDefinition.HasEnumFlag(definition_flag))
                {
                    continue;
                }
                // Check if the animation data and the requested anim have the same flag
                if (AnimDefinition.HasEnumFlag(test_flag) != anim.HasEnumFlag(test_flag))
                {
                    return(false);
                }
            }
            return(true);
        }
        // Returns the animation numbers of the given class as it starts to attack
        public static List <int> attack_animation_value(Animation_Setup_Data battler, int offset, bool crit, bool hit)
        {
            offset += ATTACK_ANIM_OFFSET;
            switch (battler.Class_Id)
            {
                #region 51: Swordmaster
            case 51:
                // Astra
                if (battler.Astra_Activated)
                {
                    if (battler.Astra_Missed)
                    {
                        return(offset.list_add(new List <int>()
                        {
                            17, 41
                        }));
                    }
                    else
                    {
                        switch (battler.Astra_Count)
                        {
                        case 4:
                            return(offset.list_add(new List <int>()
                            {
                                17, 18, crit ? 32 : 19
                            }));

                        case 3:
                            return(offset.list_add(new List <int>()
                            {
                                crit ? 34 : 22
                            }));

                        case 2:
                            return(offset.list_add(new List <int>()
                            {
                                crit ? 36 : 25
                            }));

                        case 1:
                            return(offset.list_add(new List <int>()
                            {
                                crit ? 38 : 28
                            }));

                        default:
                            return(offset.list_add(new List <int>()
                            {
                                crit ? 40 : 31
                            }));
                        }
                    }
                }
                break;
                #endregion
            }

            var anim_set = animation_set(battler);
            if (anim_set != null)
            {
                AttackAnims anim = AttackAnims.Attack;
                // Hit
                anim |= AttackAnims.HitDefined;
                if (hit)
                {
                    anim |= AttackAnims.Hit;
                }
                // Crit
                anim |= AttackAnims.CritDefined;
                if (crit)
                {
                    anim |= AttackAnims.Crit;
                }
                // Skill
                anim |= AttackAnims.SkillDefined;
                if (battler.Skill)
                {
                    anim |= AttackAnims.SkillActive;
                }
                var attack = anim_set.attack_animation(battler.anim_type, battler.Distance, anim);
                return(offset.list_add(attack));
            }

            return(new List <int>());
        }
        // Returns the animation numbers of the given class as it returns after attack
        public static List <int> return_animation_value(Animation_Setup_Data battler, int offset, bool crit, bool hit, bool no_damage)
        {
            offset += ATTACK_ANIM_OFFSET;
            switch (battler.Class_Id)
            {
                #region 51: Swordmaster
            case 51:
                // Astra
                if (battler.Astra_Activated && battler.Astra_Count > 0)
                {
                    switch (battler.Astra_Count)
                    {
                    case 4:
                        return(offset.list_add(new List <int>()
                        {
                            21
                        }));

                    case 3:
                        return(offset.list_add(new List <int>()
                        {
                            24
                        }));

                    case 2:
                        return(offset.list_add(new List <int>()
                        {
                            27
                        }));

                    default:
                        return(offset.list_add(new List <int>()
                        {
                            30
                        }));
                    }
                }
                break;
                #endregion
            }

            var anim_set = animation_set(battler);
            if (anim_set != null)
            {
                AttackAnims anim = AttackAnims.Return;
                // Hit
                anim |= AttackAnims.HitDefined;
                if (hit)
                {
                    anim |= AttackAnims.Hit;
                }
                // Crit
                anim |= AttackAnims.CritDefined;
                if (crit)
                {
                    anim |= AttackAnims.Crit;
                }
                // No Damage
                anim |= AttackAnims.DamageDefined;
                if (!no_damage)
                {
                    anim |= AttackAnims.CausedDamage;
                }
                // Skill
                anim |= AttackAnims.SkillDefined;
                if (battler.Skill)
                {
                    anim |= AttackAnims.SkillActive;
                }
                return(offset.list_add(anim_set.attack_animation(battler.anim_type, battler.Distance, anim)));
            }

            return(new List <int>());
        }
Example #7
0
 public Battle_Animation_Variable_Set(Battle_Animation_Variable_Set other)
 {
     AnimDefinition = other.AnimDefinition;
     Animation      = new List <int>(other.Animation);
 }