コード例 #1
0
ファイル: Player.cs プロジェクト: Chupaflor/Cronkpit_Samples
        //Functions for handling attack lists and talismans
        public void handle_attack_damage(Weapon w, Scroll s, double initialMultiplier, bool charge_attack, out bool rolledMax,
                                         ref List<Attack> attacksOut, ref List<StatusEffect> effectsOut)
        {
            rolledMax = false;

            int mindmg = 0;
            int maxdmg = 0;
            Attack.Damage dmgTyp = 0;
            List<Talisman> equipped_talismans = new List<Talisman>();
            List<Attack> temp_attacks = new List<Attack>();
            if (w != null)
            {
                mindmg = w.specific_damage_val(false);
                maxdmg = w.specific_damage_val(true);
                dmgTyp = w.get_my_damage_type();
                equipped_talismans = w.get_my_equipped_talismans();
            }
            else if (s != null)
            {
                mindmg = s.get_specific_damage(false);
                maxdmg = s.get_specific_damage(true);
                dmgTyp = s.get_damage_type();
                equipped_talismans = s.get_my_equipped_talismans();
            }

            int baseDamage = rGen.Next(mindmg, maxdmg + 1);
            if(w != null)
                rolledMax = baseDamage == w.specific_damage_val(true);

            //next we check for a talisman of expediency.
            for (int i = 0; i < equipped_talismans.Count; i++)
            {
                if (equipped_talismans[i].get_my_type() == Talisman.Talisman_Type.Expediency)
                {
                    int base_val = (int)equipped_talismans[i].get_my_prefix() + 2;
                    int min_damage_modifier = base_val;
                    int max_damage_modifier = (base_val * 2);
                    if (baseDamage > 0)
                        baseDamage += rGen.Next(min_damage_modifier, max_damage_modifier + 1);
                }
            }

            //Next we check for Thrashing damage
            int thrashing_slot = check_for_status_effect(Scroll.Status_Type.Thrashing);
            if (thrashing_slot != -1)
            {
                int thrashing_stacks = BuffDebuffTracker[thrashing_slot].get_current_stacks();
                int thrashing_bonus = rGen.Next( thrashing_stacks * 2, (thrashing_stacks * 3) + 1);
                baseDamage += thrashing_bonus;
            }

            //Next we see if the spell is a rage dump and add bonus damage as appropriate
            if (s != null && s.spell_is_rage_dump())
            {
                baseDamage += s.get_rage_bonus(c_energy, rGen);
                c_energy = 0;
            }

            //Now we add any talisman based attacks.
            for (int i = 0; i < equipped_talismans.Count; i++)
            {
                if (equipped_talismans[i].extra_damage_specific_type_talisman())
                {
                    int base_val = (int)equipped_talismans[i].get_my_prefix() + 1;
                    Attack.Damage dmg_typ = 0;
                    switch (equipped_talismans[i].get_my_type())
                    {
                        case Talisman.Talisman_Type.Pressure:
                            dmg_typ = Attack.Damage.Crushing;
                            break;
                        case Talisman.Talisman_Type.Heat:
                            dmg_typ = Attack.Damage.Fire;
                            break;
                        case Talisman.Talisman_Type.Snow:
                            dmg_typ = Attack.Damage.Frost;
                            break;
                        case Talisman.Talisman_Type.Razors:
                            dmg_typ = Attack.Damage.Slashing;
                            break;
                        case Talisman.Talisman_Type.Heartsblood:
                            dmg_typ = Attack.Damage.Piercing;
                            break;
                        case Talisman.Talisman_Type.Toxicity:
                            dmg_typ = Attack.Damage.Acid;
                            break;
                        case Talisman.Talisman_Type.Sparks:
                            dmg_typ = Attack.Damage.Electric;
                            break;
                    }
                    temp_attacks.Add(new Attack(dmg_typ, rGen.Next(base_val, (base_val * 2) + 1), Weapon.Type.Talisman));
                }
            }
            //next, for characters. Falsael gets a bonus to all nonbow weapons
            //and melee spells. Petaer gets a bonus to all spells.
            if ((my_character == Character.Petaer && s != null) ||
               (my_character == Character.Falsael && ((w != null && w.get_my_weapon_type() != Weapon.Type.Bow) ||
                                                      (s != null && s.is_melee_range_spell()))))
                baseDamage = (int)(Math.Ceiling((double)baseDamage * 1.2));

            //Okay we're not quite done yet. First we need to check for weapon damage enhancing buffs.
            if (w != null) //This only works for weapons, not for spells.
            {
                for (int i = 0; i < BuffDebuffTracker.Count; i++)
                {
                    Scroll.Status_Type effect_typ = BuffDebuffTracker[i].get_my_type();

                    if (w != null && effect_typ == Scroll.Status_Type.LynxFer)
                        initialMultiplier += .2;
                    else if (w != null && effect_typ == Scroll.Status_Type.PantherFer)
                        initialMultiplier += .4;
                    else if (w != null && effect_typ == Scroll.Status_Type.TigerFer)
                        initialMultiplier += .6;
                }
                //Then we multiply all the attacks by that.
                baseDamage = (int)((double)baseDamage * initialMultiplier);
                for (int i = 0; i < temp_attacks.Count; i++)
                {
                    double attack_basedmg = (double)temp_attacks[i].get_damage_amt();
                    attack_basedmg *= initialMultiplier;
                    temp_attacks[i].reset_dmg((int)attack_basedmg);
                }
            }

            if (baseDamage > 0)
            {
                Weapon.Type w_typ = Weapon.Type.Monster;
                if (w != null)
                    w_typ = w.get_my_weapon_type();

                Attack baseAttack = new Attack(dmgTyp, baseDamage, w_typ);
                attacksOut.Add(baseAttack);
            }
            attacksOut.AddRange(temp_attacks);

            //Now we apply damage penalties where appropriate
            if (!charge_attack && w != null && w.get_my_weapon_type() == Weapon.Type.Lance)
                for (int i = 0; i < attacksOut.Count; i++)
                {
                    int atkdmg = attacksOut[i].get_damage_amt();
                    attacksOut[i].reset_dmg(atkdmg / 4);
                }
            //Horray, we're done with attacks! But we still need to do debuffs.
            if (s != null && s.get_spell_type() == Scroll.Atk_Area_Type.enemyDebuff)
                effectsOut.Add(new StatusEffect(s.get_status_effect(), s.get_duration(), s.does_spell_buff_count_down(), s.get_cost_per_turn(), s.get_cost_per_turn_per_turn(), false));

            for (int i = 0; i < equipped_talismans.Count; i++)
            {
                bool add_fx = false;
                int talisman_qualVal = 1 + (int)equipped_talismans[i].get_my_prefix();
                int fx_chance = 0;
                int fx_duration = 0;
                Scroll.Status_Type fx_type = Scroll.Status_Type.None;
                switch (equipped_talismans[i].get_my_type())
                {
                    case Talisman.Talisman_Type.Distruption:
                        add_fx = true;
                        fx_chance = talisman_qualVal * 4;
                        fx_duration = talisman_qualVal + 2;
                        fx_type = Scroll.Status_Type.Disrupt;
                        break;
                    case Talisman.Talisman_Type.Thunder:
                        add_fx = true;
                        fx_chance = talisman_qualVal * 2;
                        fx_duration = Math.Max(talisman_qualVal - 1, 1);
                        fx_type = Scroll.Status_Type.Stun;
                        break;
                    case Talisman.Talisman_Type.Grasping:
                        add_fx = true;
                        fx_chance = talisman_qualVal * 4;
                        fx_duration = talisman_qualVal;
                        fx_type = Scroll.Status_Type.Root;
                        break;
                }

                if (add_fx)
                {
                    if (rGen.Next(100) < fx_chance)
                        effectsOut.Add(new StatusEffect(fx_type, fx_duration, true, 0, 0, false));
                }
            }

            //Last but not least, attacking breaks lesser invisibility.
            for (int i = 0; i < BuffDebuffTracker.Count; i++)
                if (BuffDebuffTracker[i].get_my_type() == Scroll.Status_Type.Invisibility_Lesser)
                    BuffDebuffTracker.RemoveAt(i);
        }