Exemple #1
0
        public void take_damage(Attack atk, Floor fl, string specific_part)
        {
            //OKAY THIS IS GONNA BE COMPLICATED.
            //First, figure out where the attack is gonna hit. The breakdown is as follows:
            //head, 5%, chest = 25%, arm = 17%, leg = 18%
            int hit_location = rGen.Next(100);
            int overall_damage = atk.get_damage_amt();
            int armor_absorbed = 0;

            switch (specific_part)
            {
                case "Head":
                    hit_location = 0;
                    break;
                case "Chest":
                    hit_location = 76;
                    break;
                case "LArm":
                    hit_location = 23;
                    break;
                case "RArm":
                    hit_location = 6;
                    break;
                case "LLeg":
                    hit_location = 58;
                    break;
                case "RLeg":
                    hit_location = 40;
                    break;
            }

            int dodge_roll = rGen.Next(100);
            bool dodged = false;

            if (dodge_roll < dodge_chance)
            {
                dodged = true;
                fl.add_new_popup("Dodged!", Popup.popup_msg_type.Dodge, my_grid_coord, false, false);
                message_buffer.Add("You dodge the attack!");
            }

            if (!dodged)
            {
                bool head_shot = false;
                Limb target_limb = null;

                if (hit_location < 5 && !Head.is_disabled())
                {
                    head_shot = true;
                    target_limb = Head;
                }
                else if (hit_location >= 5 && hit_location < 22 && !R_Arm.is_disabled())
                    target_limb = R_Arm;
                else if (hit_location >= 22 && hit_location < 39 && !L_Arm.is_disabled())
                    target_limb = L_Arm;
                else if (hit_location >= 39 && hit_location < 57 && !R_Leg.is_disabled())
                    target_limb = R_Leg;
                else if (hit_location >= 57 && hit_location < 75 && !L_Leg.is_disabled())
                    target_limb = L_Leg;
                else
                    target_limb = Torso;

                if (!head_shot)
                {
                    if (over_armor != null)
                        atk = over_armor.absorb_damage(atk, my_grid_coord, ref rGen, ref message_buffer, ref fl);
                    if (under_armor != null)
                        atk = under_armor.absorb_damage(atk, my_grid_coord, ref rGen, ref message_buffer, ref fl);
                }
                else
                {
                    if (helm != null)
                        atk = helm.absorb_damage(atk, my_grid_coord, ref rGen, ref message_buffer, ref fl);
                }

                for (int i = 0; i < BuffDebuffTracker.Count; i++)
                {
                    if (BuffDebuffTracker[i].get_my_type() == Scroll.Status_Type.LesserMageArmor ||
                        BuffDebuffTracker[i].get_my_type() == Scroll.Status_Type.LesserSOF)
                        handle_armor_buffs(BuffDebuffTracker[i].get_my_type(), ref atk);
                }
                armor_absorbed = overall_damage - atk.get_damage_amt();

                int dmg = atk.get_damage_amt();
                target_limb.add_injury(atk.get_dmg_type(), dmg);
                if (dmg > 0)
                    fl.add_new_popup("-" + dmg + " " + target_limb.get_shortname(), Popup.popup_msg_type.Damage, my_grid_coord, armor_absorbed > 0, false, atk.get_dmg_type());
                message_buffer.Add("Your " + target_limb.get_longname() + " takes " + dmg + " wounds!");
            }

            handle_postdamage_calculations();

            if (my_class == Chara_Class.Warrior)
            {
                c_energy += 2 + rGen.Next(3);
                if (atk.is_armor_breaking_attack())
                    c_energy++;
            }

            if (!is_alive())
                message_buffer.Add("Your wounds are too much for you. You collapse and your vision fades.");
        }