Esempio n. 1
0
        protected virtual void set_exp(Game_Unit battler_1, Game_Unit battler_2)
        {
            // Check if a battler has been killed
            if (battler_1.is_dead)
            {
                Kill = 1;
            }
            else if (battler_2 != null && battler_2.is_dead)
            {
                Kill = 2;
            }
            // Wexp
            if (battler_can_gain_wexp(battler_1))
            {
                Weapon_1_Broke = battler_1.is_weapon_broke(Weapon_1_Uses);
            }
            else
            {
                //Exp_Gain1 = 0; //Debug
                Wexp1 = 0;
            }
            if (battler_2 != null)
            {
                if (battler_can_gain_wexp(battler_2))
                {
                    Weapon_2_Broke = battler_2.is_weapon_broke(Weapon_2_Uses);
                }
                else
                {
                    //Exp_Gain2 = 0; //Debug
                    Wexp2 = 0;
                }
            }
            // Exp: battler 1
            get_exp_gain(battler_1, battler_2, 1, ref Exp_Gain1);
            // Exp: battler 2
            if (battler_2 != null)
            {
                get_exp_gain(battler_2, battler_1, 2, ref Exp_Gain2);
            }

            // Cap exp gain to amount that can be gained, and then by the amount that can be given
            cap_exp_gain(battler_1, battler_2, ref Exp_Gain1);
            if (battler_2 != null)
            {
                cap_exp_gain(battler_2, battler_1, ref Exp_Gain2);
            }
            // Reset HP and skills
            battler_1.actor.hp = Hp1;
            battler_1.actor.reset_skills(true);
            if (battler_2 != null)
            {
                battler_2.actor.hp = Hp2;
                battler_2.actor.reset_skills(true);
            }
        }
Esempio n. 2
0
        protected void use_weapons(Game_Unit battler_1, Game_Unit battler_2)
        {
            // Weapon Use
            for (int i = 0; i < Weapon_1_Uses; i++)
            {
                battler_1.weapon_use();
            }
            for (int i = 0; i < Weapon_2_Uses; i++)
            {
                battler_2.weapon_use();
            }

            if (battler_1.using_siege_engine)
            {
                // Put siege engine in reload state
                if (Constants.Gameplay.SIEGE_RELOADING)
                {
                    Global.game_map.get_siege(battler_1.loc).fire();
                }
            }
            else if (battler_1.is_weapon_broke())
            {
                battler_1.actor.discard_weapon();
            }

            if (battler_2 != null)
            {
                if (battler_2.using_siege_engine)
                {
                    // Put siege engine in reload state
                    if (Constants.Gameplay.SIEGE_RELOADING)
                    {
                        Global.game_map.get_siege(battler_2.loc).fire();
                    }
                }
                else if (battler_2.is_weapon_broke())
                {
                    battler_2.actor.discard_weapon();
                }
            }

            fix_unusable_items(battler_1, battler_2);
        }
Esempio n. 3
0
        protected override void setup()
        {
            Game_Unit battler_1 = Global.game_map.units[Battler_1_Id];

            set_variables(battler_1, Battler_2_Ids);
            List <int> attack_array = new List <int>();

            for (int i = 0; i < Battler_2_Ids.Count; i++)
            {
                Game_Unit battler_2 = Global.game_map.units[Battler_2_Ids[i]];
                Hp2 = battler_2.actor.hp;
                battler_1.store_state();
                battler_2.store_state();
                process_attacks(battler_1, battler_2, Battler_2_Ids[i]); // why was there a breakpoint here? //Test
                battler_1.restore_state();
                battler_2.restore_state();
                // Set battle end stats
                if (Data.Count == 0)
                {
                    throw new NotImplementedException("A battle with no attacks tried to occur");
                }
                Data[Data.Count - 1].Key.end_battle(Distance, Data[Data.Count - 1].Value);
                // Check if a battler has been killed
                if (battler_1.is_dead)
                {
                    Kills[i] = 1;
                    Kill     = Kills[i];
                }
                else if (battler_2.is_dead)
                {
                    Kills[i] = 2;
                    Kill     = Kills[i];
                }
                // Exp/Wexp: battler 1
                if (battler_can_gain_wexp(battler_1))
                {
                    Weapon_1_Broke = battler_1.is_weapon_broke(Weapon_1_Uses);
                }
                else
                {
                    Exp_Gain1 = 0;
                    Wexp1     = 0;
                }
                if (battler_can_gain_exp(battler_1, battler_2) && Exp_Gain1 > -1)
                {
                    Exp_Gain1 += exp_gain(battler_1, battler_2, this.weapon1, Kill == 2);
                    if (!Full_Exp1)
                    {
                        Exp_Gain1 = (int)MathHelper.Clamp(Exp_Gain1 / 2, 1, 5);
                    }
                }
                else
                {
                    Exp_Gain1 = 0;
                }

                Exp_Gain2 = 0;
                // Reset HP
                battler_1.actor.hp = Hp1;
                battler_2.actor.hp = Hp2;
                Hp2 = 0;
                // Reset skills
                battler_1.actor.reset_skills(true);
                battler_2.actor.reset_skills(true);
            }
            Exp_Gain1 = (Exp_Gain1 > 0 ?
                         Math.Min(Exp_Gain1, battler_1.actor.exp_gain_possible()) :
                         Math.Max(Exp_Gain1, -battler_1.actor.exp_loss_possible()));
        }
Esempio n. 4
0
        protected virtual bool attackable(Game_Unit attacker, Combat_Map_Object target)
        {
            // If target doesn't exist because it's a flare use/etc
            if (target == null)
            {
                return(true);
            }

            // If attacker is dead return
            //@Debug: make sure units who are out of hp but technically aren't
            // dead for whatever reason will stop
            if (attacker.hp <= 0) //@Debug: .is_dead)
            {
                return(false);
            }

            bool is_target_unit = false;

            // If the target is already dead, stop attacking
            if (target.hp <= 0)
            {
                // Don't return if either battler wants the attacks to continue
                if (!attacker.continue_attacking() &&
                    !(target.is_unit() && (target as Game_Unit).continue_attacking()))
                {
                    return(false);
                }
            }
            Game_Unit target_unit = null;

            if (target.is_unit())
            {
                is_target_unit = true;
                target_unit    = (Game_Unit)target;
            }

            var weapon = attacker.id == Battler_1_Id ? this.weapon1 : this.weapon2;

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

            // If target is berserk ally and attacker isn't berserk, don't hurt your friend >:
            if (is_target_unit && attacker.id != Battler_1_Id &&
                !attacker.is_attackable_team(target_unit) && !can_counter_ally(attacker))
            {
                return(false);
            }

            int hit, uses;

            if (attacker.id == Battler_1_Id)
            {
                List <int?> ary = Combat.combat_stats(attacker.id, target.id, Distance);
                hit  = 100;
                uses = Weapon_1_Uses;
                if (ary[0] == null && !weapon.is_staff())
                {
                    return(false); // This is newly added to account for the attacker being put to sleep, did any other cases make hit null?
                }
                if (ary[0] != null)
                {
                    hit = (int)ary[0];
                }
            }
            else
            {
                List <int?> ary = Combat.combat_stats(target.id, attacker.id, Distance);
                if (ary[4] == null)
                {
                    return(false);
                }
                hit  = (int)ary[4];
                uses = Weapon_2_Uses;
            }

            // Breaks if the attacker can't fight/broke their weapon
            if (hit < 0 || attacker.is_weapon_broke(uses))
            {
                return(false);
            }

            return(true);
        }