Example #1
0
        protected virtual void setup()
        {
            Game_Unit battler_1 = Global.game_map.units[Battler_1_Id];
            Game_Unit battler_2 = Battler_2_Id == null ? null : Global.game_map.units[(int)Battler_2_Id];

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

            battler_1.store_state();
            if (battler_2 != null)
            {
                battler_2.store_state();
            }
            process_attacks(battler_1, battler_2);
            // Set battle end stats
            if (Data.Count == 0)
            {
                throw new NotImplementedException("A battle with no attacks tried to occur");
            }
            end_battle();
            set_exp(battler_1, battler_2);
            battler_1.restore_state();
            if (battler_2 != null)
            {
                battler_2.restore_state();
            }
        }
Example #2
0
        protected override void setup()
        {
            Game_Unit         battler_1 = Global.game_map.units[Battler_1_Id];
            Combat_Map_Object target    = Global.game_map.get_map_object((int)Battler_2_Id) as Combat_Map_Object;

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

            battler_1.store_state();
            process_attacks(battler_1, target);
            battler_1.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)
            {
                Kill = 1;
            }
            else if (target.hp <= Data
                     .Select(x => x.Key)
                     .Where(x => (x.Attacker == 1 ^ x.Result.backfire) && x.Result.hit)
                     .Select(x => x.Result.dmg).Sum()) // target.is_dead) //Debug
            {
                Kill = 2;
            }
            // Exp/Wexp
            Wexp1     = 0;
            Wexp2     = 0;
            Exp_Gain1 = 0;
            Exp_Gain2 = 0;
            // Reset HP
            battler_1.actor.hp = Hp1;
            target.hp          = Hp2;
            // Reset skills
            battler_1.actor.reset_skills(true);
        }
Example #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()));
        }