protected override bool is_valid_item(List <Item_Data> items, int i)
 {
     if (unit.actor.is_equippable(items, i))
     {
         var         item_data = items[i];
         Data_Weapon weapon    = item_data.to_weapon;
         if (unit.actor.is_equippable(weapon) && weapon.is_staff())
         {
             if (unit.allies_in_staff_range(new HashSet <Vector2> {
                 unit.loc
             }, i)[0].Count > 0)
             {
                 return(true);
             }
             else if (unit.enemies_in_staff_range(new HashSet <Vector2> {
                 unit.loc
             }, i)[0].Count > 0)
             {
                 return(true);
             }
             else if (unit.untargeted_staff_range(i)[1].Count > 0)
             {
                 return(true);
             }
         }
     }
     return(false);
 }
Example #2
0
        internal virtual int crt()
        {
            if (!has_weapon)
            {
                return(0);
            }
            Data_Weapon weapon = this.attacker_weapon;

            if (weapon.is_staff())
            {
                return(0);
            }

            if (!can_crit())
            {
                return(0);
            }

            // Checks if weapon is magic
            bool magic_attack = attacker.check_magic_attack(weapon);
            int  actor_crt, weapon_crt, skill_crt, support_crt, s_bonus;

            actor_crt  = base_crt();
            weapon_crt = weapon.Crt;
            skill_crt  = 0;
            attacker.crt_skill(
                ref skill_crt, ref weapon_crt, ref actor_crt,
                weapon, null, magic_attack, 1);
            support_crt = support_bonus(Combat_Stat_Labels.Crt);
            s_bonus     = attacker.actor.s_rank_bonus(weapon);
            return(Math.Max(0, actor_crt + weapon_crt + skill_crt + support_crt + s_bonus));
        }
        public List <Item_Data> valid_sold_items()
        {
            Weapon_Ranks highest_weapon_rank = (Weapon_Ranks)(Enum_Values.GetEnumCount(typeof(Weapon_Ranks)) - 1);

            return(Sold_Items.Where(item_data =>
            {
                // Only weapons are allowed
                if (!item_data.is_weapon)
                {
                    return false;
                }
                Data_Weapon weapon = item_data.to_weapon;
                // Weapons with infinite uses are not allowed, because they really can't be repaired
                if (weapon.infinite_uses)
                {
                    return false;
                }
                // S rank weapons and Prf weapons are not allowed
                if (weapon.is_prf || weapon.Rank == Weapon_Ranks.None || weapon.Rank == highest_weapon_rank)
                {
                    return false;
                }
                // No Hammerne
                if (weapon.is_staff() && weapon.Staff_Traits[(int)Stave_Traits.Repair])
                {
                    return false;
                }
                return true;
            }).ToList());
        }
Example #4
0
        private void add_attacks(
            Game_Unit battler_1, Combat_Map_Object battler_2,
            int i, Data_Weapon weapon)
        {
#if DEBUG
            System.Diagnostics.Debug.Assert(i == 1 || i == 2);
#endif
            Game_Unit         attacker = i == 2 ? battler_2 as Game_Unit : battler_1;
            Combat_Map_Object target   = i == 2 ? battler_1 : battler_2;

            int num_hits = 1;
            if (!attacker.is_brave_blocked())
            {
                // If only single hits against terrain
                if (!(target != null && !target.is_unit() &&
                      Constants.Combat.BRAVE_BLOCKED_AGAINST_DESTROYABLE))
                {
                    num_hits = weapon.HitsPerAttack;
                }
            }
            for (int j = 0; j < num_hits; j++)
            {
                add_attacks(battler_1, battler_2, i);
            }
        }
Example #5
0
        internal virtual int dmg()
        {
            if (!has_weapon)
            {
                return(0);
            }
            Data_Weapon weapon = this.attacker_weapon;

            // Checks if weapon is magic
            bool magic_attack = attacker.check_magic_attack(weapon, Distance);
            bool imbue = (magic_attack && attacker.actor.power_type() == Power_Types.Strength);
            bool is_staff = weapon.is_staff();
            int  actor_dmg, weapon_dmg, skill_dmg, support_dmg;

            if (is_staff)
            {
                return(0); //Yeti
            }
            else
            {
                actor_dmg = weapon.Ignores_Pow() ?
                            0 : ((int)(attacker.atk_pow(weapon, magic_attack) *
                                       (imbue ? Constants.Combat.MAGIC_WEAPON_STR_RATE : 1)));
                weapon_dmg  = (int)(weapon.Mgt * (imbue ? Constants.Combat.MAGIC_WEAPON_MGT_RATE : 1));
                skill_dmg   = 0;
                support_dmg = support_bonus(Combat_Stat_Labels.Dmg);
                attacker.dmg_skill(
                    ref skill_dmg, ref weapon_dmg, ref actor_dmg, ref support_dmg,
                    weapon, magic_attack, Distance);
            }
            return(Math.Max(0, actor_dmg + weapon_dmg + skill_dmg + support_dmg));
        }
Example #6
0
        private int hit_target(Game_Unit target)
        {
            Data_Weapon weapon = this.attacker_weapon;

            // Checks if weapon is magic
            bool        magic_attack = attacker.check_magic_attack(weapon, Distance);
            bool        is_staff = weapon.is_staff();
            Game_Actor  actor2 = target.actor;
            Data_Weapon weapon2 = actor2.weapon;
            bool        boss_staff = false;
            int         actor_hit, weapon_hit, skill_hit, support_hit, s_bonus;
            int         hit_rate, target_avo;

            if (is_staff)
            {
                actor_hit = attacker.atk_pow(weapon, magic_attack) * 5 +
                            attacker.stat(Stat_Labels.Skl);
                weapon_hit = weapon.Hit;
                skill_hit  = 0;
                attacker.hit_skill(
                    ref skill_hit, ref weapon_hit, ref actor_hit,
                    weapon, target, magic_attack, Distance);
                support_hit = support_bonus(Combat_Stat_Labels.Hit);
                s_bonus     = 0;
                hit_rate    = Math.Max(0, actor_hit + weapon_hit + skill_hit + support_hit + s_bonus);

                target_avo = this.target_stats().staff_avo();
                boss_staff = target.boss;
            }
            else
            {
                actor_hit = base_hit(weapon, magic_attack);

                weapon_hit = weapon.Hit;
                skill_hit  = 0;
                attacker.hit_skill(
                    ref skill_hit, ref weapon_hit, ref actor_hit,
                    weapon, target, magic_attack, Distance);
                support_hit = support_bonus(Combat_Stat_Labels.Hit);
                s_bonus     = attacker.actor.s_rank_bonus(weapon);
                // Weapon triangle
                WeaponTriangle tri = Combat.weapon_triangle(attacker, target, weapon, weapon2, Distance);
                if (tri != WeaponTriangle.Nothing)
                {
                    weapon_hit += Weapon_Triangle.HIT_BONUS * (tri == WeaponTriangle.Advantage ? 1 : -1) *
                                  Combat.weapon_triangle_mult(attacker, target, weapon, weapon2, Distance);
                }

                hit_rate = Math.Max(0, actor_hit + weapon_hit + skill_hit + support_hit + s_bonus);

                target_avo = this.target_stats().avo(Combat.reverse_wta(tri));
            }
            int total_hit = hit_rate - target_avo;
            int result = attacker.hit_target_skill(
                target, weapon, Distance, Math.Max(total_hit, 0) / (boss_staff ? 2 : 1));

            return(result);
        }
Example #7
0
        private void refresh_equippable(Game_Unit unit, Data_Weapon weapon)
        {
            string color = unit.actor.is_equippable(weapon) ? "Blue" : "Grey";

            foreach (var stat in Stats)
            {
                stat.SetColor(Global.Content, color);
            }
        }
Example #8
0
 internal BattlerStats(
     int attackerId,
     Data_Weapon weapon,
     Maybe <int> distance = default(Maybe <int>))
 {
     AttackerId = attackerId;
     WeaponId   = weapon == null ? 0 : weapon.Id;
     Distance   = distance.IsNothing ? 1 : (int)distance;
 }
Example #9
0
 public static bool has_anima_start(this Data_Weapon weapon)
 {
     return((TactileLibrary.Data_Weapon.ANIMA_TYPES.Contains((int)weapon.Main_Type) && new List <int> {
         1, 2, 3
     }.Contains((int)weapon.Rank)) ||
            (TactileLibrary.Data_Weapon.ANIMA_TYPES.Contains((int)weapon.Scnd_Type) && new List <int> {
         1, 2, 3, 4, 5
     }.Contains((int)weapon.Rank)));                                                                                                             //Debug
 }
Example #10
0
 internal CombatStats(
     int attackerId,
     int targetId,
     Data_Weapon weapon,
     Maybe <int> distance = default(Maybe <int>))
     : base(attackerId, weapon,
            get_distance(attackerId, targetId, distance))
 {
     TargetId = targetId;
 }
Example #11
0
        public void set_images(Game_Unit unit, bool full_inventory, bool drops_item)
        {
            Game_Actor actor = unit.actor;

            Icons.Clear();
            if (full_inventory)
            {
                Weapon_Name.text = "";
                int equipped = -1;
                // Show siege engine first if possible and inventory has space
                if (!actor.is_full_items && unit.is_on_siege())
                {
                    var siege = unit.items[Siege_Engine.SiegeInventoryIndex];
                    if (siege.is_weapon)
                    {
                        add_icon(siege, Siege_Engine.SiegeInventoryIndex,
                                 actor.num_items, false);
                    }
                }

                if (equipped_first() && actor.equipped != 0)
                {
                    equipped = actor.equipped - 1;
                    add_icon(actor.items[equipped], equipped, actor.num_items, drops_item);
                }
                for (int i = 0; i < actor.items.Count; i++)
                {
                    if (i == equipped)
                    {
                        continue;
                    }
                    add_icon(actor.items[i], i, actor.num_items, drops_item);
                }
            }
            else
            {
                if (actor.weapon == null)
                {
                    Weapon_Name.text = "Unarmed";
                }
                else
                {
                    Data_Weapon item = actor.weapon;
                    Weapon_Name.text = item.Name;
                    Icons.Add(new Item_Icon_Sprite());
                    if (Global.content_exists(@"Graphics/Icons/" + item.Image_Name))
                    {
                        Icons[Icons.Count - 1].texture = Global.Content.Load <Texture2D>(@"Graphics/Icons/" + item.Image_Name);
                    }
                    Icons[Icons.Count - 1].index   = item.Image_Index;
                    Icons[Icons.Count - 1].loc     = new Vector2(0, 0);
                    Icons[Icons.Count - 1].scissor = scissor();
                }
            }
        }
Example #12
0
        private static int optimize_actor_weapon_value(InventoryOptimizePasses pass,
                                                       Game_Actor actor, Data_Weapon weapon, List <WeaponType> weapon_types)
        {
            int value = 0;

            switch (pass)
            {
            case InventoryOptimizePasses.VanillaWeapon:
                value = weapon.vanilla_value();
                break;

            case InventoryOptimizePasses.RangedWeapon:
                value = weapon.ranged_value();
                break;

            case InventoryOptimizePasses.EffectWeapon:
                value = weapon.effect_value();
                break;

            case InventoryOptimizePasses.BackupWeapon:
                value = weapon.effect_value();
                if (weapon.main_type() == weapon_types[0])
                {
                    value += 10;
                }
                break;

            case InventoryOptimizePasses.HealingStaff:
                value = weapon.healing_value();
                break;

            case InventoryOptimizePasses.StatusStaff:
                value = weapon.status_value();
                break;

            case InventoryOptimizePasses.UtilityStaff:
                value = weapon.utility_value();
                break;
            }

            // Add a small bonus if it's the actor's best weapon type
            if (weapon.main_type() == weapon_types[0])
            {
                value += 3;
            }
            // Penalize AS loss
            value -= actor.wgt_penalty(weapon);
            // Bonus for Prfs
            if (weapon.is_prf)
            {
                value += 5;
            }
            return(value);
        }
Example #13
0
 protected virtual void add_weapon_uses(ref int totalUses, int uses, Data_Weapon weapon)
 {
     if (weapon.Hits_All_in_Range())
     {
         totalUses = Math.Max(totalUses, uses);
     }
     else
     {
         totalUses += uses;
     }
 }
Example #14
0
 public Equipment_Service()
 {
     DebugWeapon = new Data_Weapon()
     {
         Name = "[DEBUG WEAPON]", Main_Type = 0, Uses = -1
     };
     DebugItem = new Data_Item()
     {
         Name = "[DEBUG ITEM]", Uses = -1
     };
 }
Example #15
0
        internal static float effective_multiplier(
            this Data_Weapon weapon,
            Tactile.Game_Unit unit,
            Tactile.Game_Unit target,
            bool halveOnHealingTerrain = true)
        {
            int effectiveness = 1;

            if (target == null)
            {
                return(effectiveness);
            }
            // Skills: Nullify
            if (target.actor.has_skill("NULL"))
            {
                return(effectiveness);
            }

            foreach (TactileLibrary.ClassTypes type in target.actor.actor_class.Class_Types)
            {
                if (weapon.Effectiveness[(int)type] > effectiveness)
                {
                    effectiveness = weapon.Effectiveness[(int)type];
                }
            }
            // Skills: Smite
            if (unit != null && unit.actor.has_skill("SMITE"))
            {
                if (target != null && !unit.nihil(target))
                {
                    if (target.actor.weapon != null && !weapon.is_staff() && (
                            target.actor.weapon.main_type().Name == "Dark" ||
                            target.actor.weapon.scnd_type().Name == "Dark"))
                    {
                        //target.actor.weapon.Main_Type == TactileLibrary.Weapon_Types.Dark || //Debug
                        //target.actor.weapon.Scnd_Type == TactileLibrary.Weapon_Types.Dark))
                        effectiveness = Math.Max(2, effectiveness);
                    }
                }
            }

            float result = effectiveness;

            if (halveOnHealingTerrain)
            {
                if (target.halve_effectiveness() && effectiveness > 1)
                {
                    result = 1 + (effectiveness - 1) / 2f;
                }
            }
            return(result);
        }
Example #16
0
 protected override bool is_valid_item(List <Item_Data> items, int i)
 {
     if (unit.actor.is_equippable(items, i))
     {
         var         item_data = items[i];
         Data_Weapon weapon    = item_data.to_weapon;
         if (!weapon.is_staff())
         {
             return(unit.enemies_in_range(i, Skill)[0].Any());
         }
     }
     return(false);
 }
Example #17
0
        private int crt_target(Game_Unit target)
        {
            Data_Weapon weapon = this.attacker_weapon;

            // Staves can't crit
            if (weapon.is_staff())
            {
                return(0);
            }
            if (weapon.Crt < 0)
            {
                return(0);
            }

            // Checks if weapon is magic
            bool        magic_attack = attacker.check_magic_attack(weapon, Distance);
            bool        is_staff     = weapon.is_staff();
            Game_Actor  actor2       = target.actor;
            Data_Weapon weapon2      = actor2.weapon;
            int         target_dod;
            int         actor_crt, weapon_crt, skill_crt, support_crt, s_bonus;

            actor_crt = base_crt();
            // Bonus to crit for hit > 100
            if (Constants.Combat.HIT_OVERFLOW)
            {
                int hit_bonus = (int)((hit() - 100) *
                                      Constants.Combat.HIT_OVERFLOW_RATE);
                actor_crt += Math.Max(0, hit_bonus);
            }
            weapon_crt = weapon.Crt;
            skill_crt  = 0;
            attacker.crt_skill(
                ref skill_crt, ref weapon_crt, ref actor_crt,
                weapon, target, magic_attack, Distance);
            support_crt = support_bonus(Combat_Stat_Labels.Crt);
            s_bonus     = attacker.actor.s_rank_bonus(weapon);

            target_dod = this.target_stats().dodge();
            int crit_rate = actor_crt + weapon_crt + skill_crt + support_crt + s_bonus;
            int total_crt = Math.Max(0, crit_rate - target_dod);

            if (magic_attack && attacker.actor.power_type() == Power_Types.Strength)
            {
                total_crt = (int)(total_crt * Constants.Combat.MAGIC_WEAPON_CRT_RATE);
            }
            int result = attacker.crt_target_skill(target, weapon, Distance, total_crt);

            return(result);
        }
Example #18
0
 internal static bool can_heal(this Data_Weapon weapon, Tactile.Game_Unit target)
 {
     if (weapon.Heals())
     {
         if (!target.actor.is_full_hp())
         {
             return(true);
         }
     }
     if (healable_statuses(weapon, target).Count > 0)
     {
         return(true);
     }
     return(false);
 }
Example #19
0
        public bool can_crit()
        {
            Data_Weapon weapon = this.attacker_weapon;

            if (weapon == null)
            {
                return(false);
            }

            if (weapon.is_staff())
            {
                return(false);
            }

            return(weapon.Crt >= 0);
        }
        protected override bool is_valid_item(List <Item_Data> items, int i)
        {
            var item_data = items[i];

            if (item_data.non_equipment || !item_data.is_weapon)
            {
                return(false);
            }

            Data_Weapon weapon = item_data.to_weapon;

            if (unit.actor.is_equippable(weapon) && !weapon.is_staff())
            {
                return(true);
            }
            return(false);
        }
 public void wexp_from_weapon_skill(Data_Weapon weapon, ref int wexp)
 {
     // Skills: Discipline
     if (has_skill("DISCIPLINE"))
     {
         wexp *= 2;
     }
     // Skills: Veteran
     if (has_skill("VETERAN"))
     {
         wexp *= 2;
     }
     // Skills: Academic
     else if (has_skill("ACADEMIC"))
     {
         wexp *= 2;
     }
 }
Example #22
0
        internal virtual int hit()
        {
            if (!has_weapon)
            {
                return(0);
            }
            Data_Weapon weapon = this.attacker_weapon;

            // Checks if weapon is magic
            bool magic_attack = attacker.check_magic_attack(weapon, Distance);
            bool is_staff = weapon.is_staff();
            int  actor_hit, weapon_hit, skill_hit, support_hit, s_bonus;

            if (is_staff)
            {
                actor_hit = attacker.atk_pow(weapon, magic_attack) * 5 +
                            attacker.stat(Stat_Labels.Skl);
                weapon_hit = weapon.Hit;
                skill_hit  = 0;
                attacker.hit_skill(
                    ref skill_hit, ref weapon_hit, ref actor_hit,
                    weapon, null, magic_attack, Distance);
                support_hit = support_bonus(Combat_Stat_Labels.Hit);
                s_bonus     = 0;
            }
            else
            {
                actor_hit  = base_hit(weapon, magic_attack);
                weapon_hit = weapon.Hit;
                skill_hit  = 0;
                attacker.hit_skill(
                    ref skill_hit, ref weapon_hit, ref actor_hit,
                    weapon, null, magic_attack, Distance);
                support_hit = support_bonus(Combat_Stat_Labels.Hit);
                s_bonus     = attacker.actor.s_rank_bonus(weapon);
            }
            return(Math.Max(0, actor_hit + weapon_hit + skill_hit + support_hit + s_bonus));
        }
Example #23
0
 public static int anima_type(this Data_Weapon weapon)
 {
     return(Data_Weapon.ANIMA_TYPES.Contains((int)weapon.Main_Type) ? weapon.Main_Type : weapon.Scnd_Type);
 }
Example #24
0
 internal static List <int> healable_statuses(this Data_Weapon weapon, Tactile.Game_Unit target)
 {
     return(weapon.Status_Remove.Intersect(target.actor.negative_states).ToList());
 }
Example #25
0
 public static bool range_blocked_by_walls(this Data_Weapon weapon)
 {
     return(Tactile.Constants.Gameplay.BLOCK_FIRE_THROUGH_WALLS_DEFAULT && !weapon.is_siege());
 }
Example #26
0
 protected virtual int exp_gain(Game_Unit battler_1, Game_Unit battler_2, Data_Weapon weapon, bool kill)
 {
     return(Combat.exp(battler_1, battler_2, kill));
 }
Example #27
0
 public static bool is_siege(this Data_Weapon weapon)
 {
     return(weapon.Long_Range); // weapon.Max_Range >= 10 || weapon.Mag_Range; //Debug
 }
Example #28
0
        private int dmg_target(Game_Unit target)
        {
            Data_Weapon weapon = this.attacker_weapon;

            // Checks if weapon is magic
            bool        magic_attack = attacker.check_magic_attack(weapon, Distance);
            bool        imbue = (magic_attack && attacker.actor.power_type() == Power_Types.Strength);
            bool        is_staff = weapon.is_staff();
            Game_Actor  actor2 = target.actor;
            Data_Weapon weapon2 = actor2.weapon;
            int         total_damage, target_def;
            int         actor_dmg, weapon_dmg, skill_dmg, support_dmg;

            // Staff
            if (is_staff)
            {
                actor_dmg  = attacker.atk_pow(weapon, magic_attack);
                weapon_dmg = weapon.Mgt;
                skill_dmg  = 0;
                attacker.dmg_staff_skill(
                    ref skill_dmg, ref weapon_dmg, ref actor_dmg,
                    target, magic_attack, Distance);
                support_dmg = support_bonus(Combat_Stat_Labels.Dmg);
                target_def  = 0;
            }
            // Weapon
            else
            {
                var target_stats = this.target_stats();
                target_def = magic_attack ?
                             target_stats.res() : target_stats.def();
                target_def = (weapon.Ignores_Def() ? target_def / 2 : target_def);
                if (weapon.Halves_HP())
                {
                    int total_weapon_damage = target_def + (int)Math.Ceiling(target.actor.hp / 2.0f);
                    actor_dmg  = (int)Math.Ceiling(total_weapon_damage / 2.0f);
                    weapon_dmg = (int)Math.Floor(total_weapon_damage / 2.0f);
                }
                else
                {
                    actor_dmg = weapon.Ignores_Pow() ?
                                0 : ((int)(attacker.atk_pow(weapon, magic_attack) *
                                           (imbue ? Constants.Combat.MAGIC_WEAPON_STR_RATE : 1)));
                    weapon_dmg = (int)(weapon.Mgt * (imbue ? Constants.Combat.MAGIC_WEAPON_MGT_RATE : 1));
                    if (weapon.Ignores_Def())
                    {
                        weapon_dmg += target_def;
                    }
                }
                // Weapon triangle
                skill_dmg = 0;
                WeaponTriangle tri = Combat.weapon_triangle(attacker, target, weapon, weapon2, Distance);
                if (tri != WeaponTriangle.Nothing)
                {
                    skill_dmg += Weapon_Triangle.DMG_BONUS * (tri == WeaponTriangle.Advantage ? 1 : -1) *
                                 Combat.weapon_triangle_mult(attacker, target, weapon, weapon2, Distance);
                }

                float effectiveness = weapon.effective_multiplier(attacker, target);
                skill_dmg  += (int)((weapon_dmg + skill_dmg) * (effectiveness - 1));
                support_dmg = support_bonus(Combat_Stat_Labels.Dmg);
                attacker.dmg_skill(
                    ref skill_dmg, ref weapon_dmg, ref actor_dmg, ref support_dmg,
                    ref target_def, weapon, target, weapon2, tri, magic_attack,
                    Distance, effectiveness);
            }
            total_damage = actor_dmg + weapon_dmg + skill_dmg + support_dmg - target_def;
            int result = attacker.dmg_target_skill(target, weapon, Distance, Math.Max(0, total_damage));

            return(result);
        }
        protected void initialize(Item_Data item_data, Game_Actor actor)
        {
            Data_Weapon weapon    = item_data.to_weapon;
            int         stats     = !weapon.is_staff() ? 6 : 3;
            bool        effective = false;

            foreach (int bonus in weapon.Effectiveness)
            {
                if (bonus != 1)
                {
                    effective = true;
                    stats++;
                    break;
                }
            }
            for (int i = 0; i < stats; i++)
            {
                Labels.Add(new TextSprite());
                Labels[Labels.Count - 1].loc = new Vector2((i % 3) * 60, (i / 3) * 16);
                if (i % 3 == 2)
                {
                    Labels[Labels.Count - 1].loc += new Vector2(4, 0);
                }
                Labels[Labels.Count - 1].SetFont(Config.UI_FONT, Global.Content, "Yellow");
            }
            //@Yeti: handle weapon type replacement skills better than hardcoding
            bool knife    = (actor != null && actor.has_skill("KNIFE") && weapon.main_type().Name == "Sword" && !weapon.is_magic());
            bool crossbow = (actor != null && actor.has_skill("CROSSBOW") && weapon.main_type().Name == "Bow" && !weapon.Ballista());

            Labels[0].text = weapon.type;
            if (knife)
            {
                Labels[0].text = "Knife";
            }
            if (crossbow)
            {
                Labels[0].text = "Crossbow";
            }
            Labels[1].text = "Rng";
            Labels[2].text = "Wgt";
            // If not a staff
            if (!weapon.is_staff())
            {
                Labels[3].text = "Mgt";
                Labels[4].text = "Hit";
                Labels[5].text = "Crit";
            }
            if (effective)
            {
                Labels[Labels.Count - 1].text = "Effective";
            }

            // Rank
            Rank     = new TextSprite();
            Rank.loc = new Vector2(32, 0);
            if (crossbow)
            {
                Rank.loc.X += 16;
            }
            Rank.SetFont(
                weapon.Rank == Weapon_Ranks.None ? Config.UI_FONT : Config.UI_FONT + "L",
                Global.Content, "Blue", Config.UI_FONT);
            Rank.text = weapon.rank;
            // Range
            Stats.Add(new TextSprite());
            Stats[Stats.Count - 1].loc = new Vector2(92, 0);
            Stats[Stats.Count - 1].SetFont(Config.UI_FONT, Global.Content, "Blue");
            int min_range = weapon.Min_Range;
            int max_range = weapon.Max_Range;

            if (knife && max_range == 1)
            {
                max_range = 2;
            }
            if (weapon.Mag_Range)
            {
                Stats[0].text   = min_range.ToString() + "-Mg/2";
                Stats[0].offset = new Vector2(15, 0);
            }
            else
            {
                if (min_range == max_range)
                {
                    Stats[0].text = min_range.ToString();
                }
                else
                {
                    Stats[0].text = min_range.ToString() + "-" + max_range.ToString();
                }
                Stats[0].offset = new Vector2(Stats[0].text.Length > 1 ? 12 : 0, 0);
            }
            for (int i = 2; i < stats; i++)
            {
                Stats.Add(new RightAdjustedText());
                Stats[Stats.Count - 1].loc = new Vector2((i % 3) * 60 + 40, (i / 3) * 16);
                if (i % 3 == 2)
                {
                    Stats[Stats.Count - 1].loc += new Vector2(4, 0);
                }
                Stats[Stats.Count - 1].SetFont(Config.UI_FONT, Global.Content, "Blue");
            }
            // Wgt
            Stats[1].text = weapon.Wgt.ToString();
            if (actor != null)
            {
                int actor_wgt = actor.weapon_wgt(weapon);
                if (actor_wgt != weapon.Wgt)
                {
                    int difference = actor_wgt - weapon.Wgt;

                    Stat_Bonuses.Add(new TextSprite());
                    Stat_Bonuses[Stat_Bonuses.Count - 1].loc = Stats[1].loc + new Vector2(0, 0);
                    Stat_Bonuses[Stat_Bonuses.Count - 1].SetFont(
                        Config.UI_FONT + "Bonus", Global.Content,
                        difference <= 0 ? "Green" : "Red", Config.UI_FONT);
                    Stat_Bonuses[Stat_Bonuses.Count - 1].text = difference.ToString();
                }
            }
            // Stats
            if (!weapon.is_staff())
            {
                Stats[2].text = weapon.Mgt.ToString();
                if (knife)
                {
                    Stat_Bonuses.Add(new TextSprite());
                    Stat_Bonuses[Stat_Bonuses.Count - 1].loc = Stats[2].loc + new Vector2(0, 0);
                    Stat_Bonuses[Stat_Bonuses.Count - 1].SetFont(
                        Config.UI_FONT + "Bonus", Global.Content, "Red", Config.UI_FONT);
                    Stat_Bonuses[Stat_Bonuses.Count - 1].text = "-3";
                }
                Stats[3].text = weapon.Hit.ToString();
                if (!knife)
                {
                    Stats[3].offset.X = -((Stats[3].text.Length - 1) / 2) * 8;
                }
                if (knife)
                {
                    Stat_Bonuses.Add(new TextSprite());
                    Stat_Bonuses[Stat_Bonuses.Count - 1].loc = Stats[3].loc - Stats[3].offset + new Vector2(0, 0);
                    Stat_Bonuses[Stat_Bonuses.Count - 1].SetFont(
                        Config.UI_FONT + "Bonus", Global.Content, "Green", Config.UI_FONT);
                    Stat_Bonuses[Stat_Bonuses.Count - 1].text = "+10";
                }
                Stats[4].text = weapon.Crt == -1 ? "--" : weapon.Crt.ToString();
            }
            if (effective)
            {
                for (int i = 0; i < weapon.Effectiveness.Length; i++)
                {
                    if (weapon.Effectiveness[i] != 1)
                    {
                        Effectiveness_Icons.Add(new Icon_Sprite());
                        Effectiveness_Icons[Effectiveness_Icons.Count - 1].texture = Global.Content.Load <Texture2D>(@"Graphics/Icons/Class_Types");
                        Effectiveness_Icons[Effectiveness_Icons.Count - 1].size    = new Vector2(16, 16);
                        Effectiveness_Icons[Effectiveness_Icons.Count - 1].columns = 1;
                        Effectiveness_Icons[Effectiveness_Icons.Count - 1].loc     = new Vector2(
                            48 + ((Effectiveness_Icons.Count - 1) * 16), 32);
                        Effectiveness_Icons[Effectiveness_Icons.Count - 1].index = i;

                        Effectiveness_Multipliers.Add(new Effective_WT_Arrow());
                        Effectiveness_Multipliers[Effectiveness_Icons.Count - 1].loc = new Vector2(
                            48 + ((Effectiveness_Icons.Count - 1) * 16), 32);
                        Effectiveness_Multipliers[Effectiveness_Icons.Count - 1].draw_offset = new Vector2(8, 8);
                        Effectiveness_Multipliers[Effectiveness_Icons.Count - 1].set_effectiveness(weapon.Effectiveness[i]);
                    }
                }
            }
        }
Example #30
0
        protected void initialize_sprites()
        {
            // Black Screen
            Black_Screen           = new Sprite();
            Black_Screen.texture   = Global.Content.Load <Texture2D>(@"Graphics/White_Square");
            Black_Screen.dest_rect = new Rectangle(0, 0, Config.WINDOW_WIDTH, Config.WINDOW_HEIGHT);
            Black_Screen.tint      = new Color(0, 0, 0, 255);
            // Background
            Background              = new Menu_Background();
            Background.texture      = Global.Content.Load <Texture2D>(@"Graphics/Pictures/Status_Background");
            Background.vel          = new Vector2(-0.25f, 0);
            Background.tile         = new Vector2(3, 2);
            Background.stereoscopic = Config.MAPMENU_BG_DEPTH;

            // UI Nodes
            TopPanelNodes = new List <StatusUINode>();
            // Top Panel //
            // Top Panel
            Top_Panel = new Status_Top_Panel_Bg(new List <Texture2D> {
                Global.Content.Load <Texture2D>(@"Graphics/Pictures/Portrait_bg"),
                Global.Content.Load <Texture2D>(@"Graphics/Windowskins/WindowPanel")
            });
            Top_Panel.stereoscopic = Config.STATUS_TOP_PANEL_DEPTH;
            // Face Bg
            Face_Bg              = new Menu_Background();// Sprite(); //Debug
            Face_Bg.texture      = Global.Content.Load <Texture2D>(@"Graphics/Pictures/Portrait_bg");
            Face_Bg.loc          = new Vector2(4, 4);
            Face_Bg.src_rect     = new Rectangle(12, 4, 8, 8);
            Face_Bg.tile         = new Vector2(11, 9);
            Face_Bg.stereoscopic = Config.STATUS_FACE_BG_DEPTH;
            // Map Sprite
            Map_Sprite              = new Character_Sprite();
            Map_Sprite.draw_offset  = MAP_SPRITE_LOC + new Vector2(16, 16);
            Map_Sprite.facing_count = 3;
            Map_Sprite.frame_count  = 3;
            Map_Sprite.stereoscopic = Config.STATUS_TOP_PANEL_DEPTH;
            // Map Sprite Platform
            Platform              = new Sprite();
            Platform.texture      = Global.Content.Load <Texture2D>(@"Graphics/Characters/StatusPlatform");
            Platform.loc          = MAP_SPRITE_LOC;
            Platform.stereoscopic = Config.STATUS_TOP_PANEL_DEPTH;
            // Name
            TopPanelNodes.Add(new StatusTextUINode(
                                  "Name",
                                  (Game_Unit unit) => unit.name, true));
            TopPanelNodes.Last().loc          = new Vector2(112, 4);
            TopPanelNodes.Last().draw_offset  = new Vector2(34, 0);
            TopPanelNodes.Last().Size         = new Vector2(68, 16);
            TopPanelNodes.Last().stereoscopic = Config.STATUS_TOP_PANEL_DEPTH;

            // Class Name
            TopPanelNodes.Add(new StatusTextUINode(
                                  "Class",
                                  (Game_Unit unit) => unit.actor.class_name));
            TopPanelNodes.Last().loc          = new Vector2(104, 24);
            TopPanelNodes.Last().Size         = new Vector2(72, 16);
            TopPanelNodes.Last().stereoscopic = Config.STATUS_TOP_PANEL_DEPTH;

            // Lives
            TopPanelNodes.Add(new StatusLivesUINode("Lives"));
            TopPanelNodes.Last().loc          = new Vector2(180, 60);
            TopPanelNodes.Last().stereoscopic = Config.STATUS_TOP_PANEL_DEPTH;
            // LV/HP/etc

            TopPanelNodes.Add(new StatusStatLargeLabelUINode(
                                  "Lvl", "LV", (Game_Unit unit) => unit.actor.level.ToString(), 32));
            TopPanelNodes.Last().loc          = new Vector2(104, 40);
            TopPanelNodes.Last().stereoscopic = Config.STATUS_TOP_PANEL_DEPTH;
            Func <Game_Unit, DirectionFlags, bool> lvl_cheat = (unit, dir) =>
            {
                int lvl_gain = 0;
                if (dir.HasFlag(DirectionFlags.Right))
                {
                    lvl_gain = 1;
                }
                else if (dir.HasFlag(DirectionFlags.Left))
                {
                    lvl_gain = -1;
                }
                unit.actor.level += lvl_gain;
                unit.queue_move_range_update();
                return(lvl_gain != 0);
            };

#if DEBUG
            TopPanelNodes.Last().set_cheat(lvl_cheat);
#endif

            TopPanelNodes.Add(new StatusStatUINode(
                                  "Exp", "$", (Game_Unit unit) =>
                                  unit.actor.can_level() ? unit.actor.exp.ToString() : "--", 24));
            TopPanelNodes.Last().loc          = new Vector2(136, 40);
            TopPanelNodes.Last().stereoscopic = Config.STATUS_TOP_PANEL_DEPTH;
            Func <Game_Unit, DirectionFlags, bool> exp_cheat = (unit, dir) =>
            {
                int exp_gain = 0;
                if (dir.HasFlag(DirectionFlags.Right))
                {
                    exp_gain = 1;
                }
                else if (dir.HasFlag(DirectionFlags.Left))
                {
                    exp_gain = -1;
                }
                unit.actor.exp = (int)MathHelper.Clamp(
                    unit.actor.exp + exp_gain,
                    0, Global.ActorConfig.ExpToLvl - 1);
                return(exp_gain != 0);
            };
#if DEBUG
            TopPanelNodes.Last().set_cheat(exp_cheat);
#endif

            Func <Game_Unit, Color> label_color = null;
            if (show_stat_colors(Stat_Labels.Hp))
            {
                label_color = (Game_Unit unit) =>
                {
                    if (unit.average_stat_hue_shown)
                    {
                        return(unit.actor.stat_color(Stat_Labels.Hp));
                    }

                    return(Color.White);
                };
            }
            TopPanelNodes.Add(new StatusHpUINode(
                                  "Hp",
                                  "HP",
                                  (Game_Unit unit) =>
            {
                if (unit.actor.hp >=
                    Math.Pow(10, Global.BattleSceneConfig.StatusHpCounterValues))
                {
                    return("--");
                }
                else
                {
                    return(unit.actor.hp.ToString());
                }
            },
                                  (Game_Unit unit) =>
            {
                if (unit.actor.maxhp >=
                    Math.Pow(10, Global.BattleSceneConfig.StatusHpCounterValues))
                {
                    return("--");
                }
                else
                {
                    return(unit.actor.maxhp.ToString());
                }
            },
                                  label_color));
            TopPanelNodes.Last().loc          = new Vector2(104, 56);
            TopPanelNodes.Last().stereoscopic = Config.STATUS_TOP_PANEL_DEPTH;
#if DEBUG
            TopPanelNodes.Last().set_cheat(
                Status_Page_1.stat_cheat(Stat_Labels.Hp));
#endif

            // Battle Stat Labels
            Battle_Stat_Labels = new List <TextSprite>();
            for (int i = 0; i < 1; i++)
            {
                Battle_Stat_Labels.Add(new TextSprite());
                Battle_Stat_Labels[i].loc = new Vector2(204 + (i / 4) * 56, 8 + (i % 4) * 16);
                Battle_Stat_Labels[i].SetFont(Config.UI_FONT, Global.Content, "Yellow");
                Battle_Stat_Labels[i].text         = "doop";
                Battle_Stat_Labels[i].stereoscopic = Config.STATUS_TOP_PANEL_DEPTH;
            }
            Battle_Stat_Labels[0].SetColor(Global.Content, "White");
            Battle_Stat_Labels[0].text = "Battle Stats";
            // Battle Stats
            for (int i = 1; i < 8; i++)
            {
                string help_label;
                string label;
                Func <Game_Unit, string> stat_formula;
                switch (i)
                {
                // Atk
                case 1:
                default:
                    help_label   = "Atk";
                    label        = "Atk";
                    stat_formula = (Game_Unit unit) =>
                    {
                        var stats = new BattlerStats(unit.id);
                        if (!stats.has_non_staff_weapon)
                        {
                            return("--");
                        }
                        return(stats.dmg().ToString());
                    };
                    break;

                // Hit
                case 2:
                    help_label   = "Hit";
                    label        = "Hit";
                    stat_formula = (Game_Unit unit) =>
                    {
                        var stats = new BattlerStats(unit.id);
                        if (!stats.has_non_staff_weapon)
                        {
                            return("--");
                        }
                        return(stats.hit().ToString());
                    };
                    break;

                // Dodge
                case 7:
                    help_label   = "Dodge";
                    label        = "Dodge";
                    stat_formula = (Game_Unit unit) =>
                    {
                        var stats = new BattlerStats(unit.id);
                        return(stats.dodge().ToString());
                    };
                    break;

                // Range
                case 4:
                    help_label   = "Range";
                    label        = "Rng";
                    stat_formula = (Game_Unit unit) =>
                    {
                        if (unit.actor.weapon == null ||
                            unit.actor.weapon.is_staff())
                        {
                            return("--");
                        }

                        Data_Weapon weapon    = unit.actor.weapon;
                        int         min_range = unit.min_range();
                        int         max_range = unit.max_range();
                        if (min_range == max_range)
                        {
                            return(min_range.ToString());
                        }
                        else
                        {
                            return(string.Format("{0}-{1}", min_range, max_range));
                        }
                    };
                    break;

                // Crit
                case 3:
                    help_label   = "Crit";
                    label        = "Crit";
                    stat_formula = (Game_Unit unit) =>
                    {
                        var stats = new BattlerStats(unit.id);
                        if (!stats.has_non_staff_weapon || !stats.can_crit())
                        {
                            return("--");
                        }
                        return(stats.crt().ToString());
                    };
                    break;

                // Avoid
                case 6:
                    help_label   = "Avoid";
                    label        = "Avoid";
                    stat_formula = (Game_Unit unit) =>
                    {
                        var stats = new BattlerStats(unit.id);
                        return(stats.avo().ToString());
                    };
                    break;

                // AS
                case 5:
                    help_label   = "AS";
                    label        = "AS";
                    stat_formula = (Game_Unit unit) => unit.atk_spd().ToString();
                    break;
                }

                Vector2 loc = new Vector2(204 + (i / 4) * 56, 8 + (i % 4) * 16);

                TopPanelNodes.Add(new StatusStatUINode(help_label, label, stat_formula));
                TopPanelNodes.Last().loc          = loc;
                TopPanelNodes.Last().stereoscopic = Config.STATUS_TOP_PANEL_DEPTH;
            }
            // Rescue Icon
            Rescue_Icon              = new Sprite();
            Rescue_Icon.texture      = Global.Content.Load <Texture2D>(@"Graphics/Characters/RescueIcon");
            Rescue_Icon.loc          = new Vector2(103, -5);
            Rescue_Icon.stereoscopic = Config.STATUS_TOP_PANEL_DEPTH;
            // Pages //
            Pages.Add(new Status_Page_1());
            Pages.Add(new Status_Page_2());
            Pages.Add(new Status_Page_3());
            // Page Arrows
            Left_Page_Arrow                = new Page_Arrow();
            Left_Page_Arrow.loc            = new Vector2(4, 84);
            Left_Page_Arrow.stereoscopic   = Config.STATUS_ARROW_DEPTH;
            Left_Page_Arrow.ArrowClicked  += Left_Page_Arrow_ArrowClicked;
            Right_Page_Arrow               = new Page_Arrow();
            Right_Page_Arrow.loc           = new Vector2(Config.WINDOW_WIDTH - 4, 84);
            Right_Page_Arrow.mirrored      = true;
            Right_Page_Arrow.stereoscopic  = Config.STATUS_ARROW_DEPTH;
            Right_Page_Arrow.ArrowClicked += Right_Page_Arrow_ArrowClicked;

            create_cancel_button();

            set_images();
        }