Esempio n. 1
0
 protected void add_attack(Game_Unit battler_1, Game_Unit battler_2, int attacker)
 {
     battler_1.start_attack(Data.Count(x => x.Key.Attacker == attacker), battler_2);
     add_data(battler_1, battler_2);
     Data[Data.Count - 1].Key.Attacker = attacker;
     // Checks if this is the first attack of this unit
     for (int i = 0; i < Data.Count - 1; i++)
     {
         if (Data[i].Key.Attacker == Data[Data.Count - 1].Key.Attacker)
         {
             Data[Data.Count - 1].Key.First_Attack = false;
             break;
         }
     }
     if (attacker == 1)
     {
         Attacked_1 = true;
     }
     else
     {
         Attacked_2 = true;
     }
     Data[Data.Count - 1].Key.set_attack(Distance, Data[Data.Count - 1].Value);
     // Add Attacks
     if (battler_1.actor.added_attacks.Count > 0)
     {
         foreach (int attack in battler_1.actor.added_attacks)
         {
             Add_Attack.Add(attack == 1 ? 1 : 2);
         }
     }
     battler_1.actor.clear_added_attacks();
     if (battler_2.actor.added_attacks.Count > 0)
     {
         foreach (int attack in battler_2.actor.added_attacks)
         {
             Add_Attack.Add(attack == 1 ? 2 : 1);
         }
     }
     battler_2.actor.clear_added_attacks();
     exp_gain_test(battler_1, battler_2, attacker, Data[Data.Count - 1]);
 }
Esempio n. 2
0
        protected void process_attacks(Game_Unit battler_1, Combat_Map_Object battler_2, int targetId)
        {
            battler_1.start_attack(-1, battler_2);
            if (battler_2 is Game_Unit)
            {
                (battler_2 as Game_Unit).start_attack(-1, battler_1);
            }

            bool ambush = battler_2 != null && battler_2.is_unit() &&
                          Global.game_map.units[targetId].counters_first(Global.game_map.units[Battler_1_Id]);

            int num_attacks1, num_attacks2;

            for (int i = 0; i < combat_attacks(
                     battler_1, battler_2, out num_attacks1, out num_attacks2); i++)
            {
                if (ambush)
                {
                    if (battler_2 != null && battler_2.is_unit() &&
                        i < num_attacks2 && this.weapon2 != null)
                    {
                        add_attacks(battler_1, battler_2, 2, this.weapon2);
                    }
                }
                // Add hits for battler_1 in this attack
                if (i < num_attacks1)
                {
                    if (i < num_attacks1)
                    {
                        add_attacks(battler_1, battler_2, 1, this.weapon1);
                    }
                }
                if (!ambush)
                {
                    if (battler_2 != null && battler_2.is_unit() &&
                        i < num_attacks2 && this.weapon2 != null)
                    {
                        add_attacks(battler_1, battler_2, 2, this.weapon2);
                    }
                }
            }
        }
Esempio n. 3
0
        protected void add_solo_attack(Game_Unit battler_1, int attacker)
        {
            battler_1.start_attack(Data.Count(x => x.Key.Attacker == attacker), null);
            add_data(battler_1);
            Data[Data.Count - 1].Key.Attacker = attacker;
            // Checks if this is the first attack of this unit
            for (int i = 0; i < Data.Count - 1; i++)
            {
                if (Data[i].Key.Attacker == Data[Data.Count - 1].Key.Attacker)
                {
                    Data[Data.Count - 1].Key.First_Attack = false;
                    break;
                }
            }
            if (attacker == 1)
            {
                Attacked_1 = true;
            }
            else
            {
                Attacked_2 = true;
            }
            Data[Data.Count - 1].Key.set_attack(Distance, Data[Data.Count - 1].Value);
            // Add Attacks
            if (battler_1.actor.added_attacks.Count > 0)
            {
                foreach (int attack in battler_1.actor.added_attacks)
                {
                    Add_Attack.Add(attack == 1 ? 1 : 2);
                }
            }
            battler_1.actor.clear_added_attacks();

            Exp_Gain1 = Math.Max(0, Exp_Gain1);
            Full_Exp1 = true;
            int uses = battler_1.weapon_use_count(Data[Data.Count - 1].Key.Result.hit);

            add_weapon_uses(ref Weapon_1_Uses, uses, this.weapon1);
            Wexp1 += Data[Data.Count - 1].Key.Result.wexp;
            Data[Data.Count - 1].Key.cause_damage();
        }
Esempio n. 4
0
        private void process_scripted_attacks(Game_Unit battler_1, Combat_Map_Object battler_2, Scripted_Combat_Script script)
        {
            battler_1.start_attack(-1, battler_2);
            if (battler_2 is Game_Unit)
            {
                (battler_2 as Game_Unit).start_attack(-1, battler_1);
            }

            for (int i = 0; i < script.Stats.Count; i++)
            {
                if (script.Stats[i].Result != Attack_Results.End)
                {
                    bool cont = false;
                    while (!cont)
                    {
                        cont = true;
                        int attacker = script.Stats[i].Attacker;
                        if (attacker > 0)
                        {
                            if (battler_2 == null)
                            {
                                add_solo_attack(battler_1, attacker);
                            }
                            else if (battler_2.is_unit())
                            {
                                add_attack(battler_1, battler_2 as Game_Unit, script.Stats[i]);
                            }
                            else
                            {
                                add_attack(battler_1, battler_2 as Combat_Map_Object, attacker);
                            }
                        }
                    }
                }
            }
            Kill = script.kill;
        }