public void bow_attack(Floor fl, ref ContentManager Secondary_cManager, gridCoordinate attack_location, int monsterID, int DoodadID) { Weapon Bow = null; if (main_hand != null && (main_hand.get_my_weapon_type() == Weapon.Type.Bow || main_hand.get_my_weapon_type() == Weapon.Type.Crossbow)) Bow = main_hand; else if (off_hand != null && (off_hand.get_my_weapon_type() == Weapon.Type.Bow || off_hand.get_my_weapon_type() == Weapon.Type.Crossbow)) Bow = off_hand; gridCoordinate opposition_coord = new gridCoordinate(-1, -1); if (monsterID != -1) opposition_coord = attack_location; else opposition_coord = fl.Doodad_by_index(DoodadID).get_g_coord(); int cbow_xsplash = 0; int cbow_ysplash = 0; if (opposition_coord.x < my_grid_coord.x) cbow_xsplash = -1; else if (opposition_coord.x > my_grid_coord.x) cbow_xsplash = 1; if (opposition_coord.y < my_grid_coord.y) cbow_ysplash = -1; else if (opposition_coord.y > my_grid_coord.y) cbow_ysplash = 1; gridCoordinate splash_coord = new gridCoordinate(opposition_coord.x + cbow_xsplash, opposition_coord.y + cbow_ysplash); int base_min_dmg_to_monster = Bow.specific_damage_val(false); int base_max_dmg_to_monster = Bow.specific_damage_val(true); int max_dmg_to_monster = (int)base_max_dmg_to_monster; int min_dmg_to_monster = (int)base_min_dmg_to_monster; if (is_cbow_equipped() && my_character == Character.Falsael) { max_dmg_to_monster = (int)Math.Ceiling(base_max_dmg_to_monster * 1.2); min_dmg_to_monster = (int)Math.Ceiling(base_min_dmg_to_monster * 1.2); } if (Bow.get_my_weapon_type() == Weapon.Type.Bow) { Projectile prj = new Projectile(get_my_grid_C(), opposition_coord, Projectile.projectile_type.Arrow, ref Secondary_cManager, false, Scroll.Atk_Area_Type.singleTile); prj.attach_weapon(Bow); fl.create_new_projectile(prj); } else if(Bow.get_my_weapon_type() == Weapon.Type.Crossbow) { Projectile prj = new Projectile(get_my_grid_C(), opposition_coord, Projectile.projectile_type.Crossbow_Bolt, ref Secondary_cManager, false, Scroll.Atk_Area_Type.smallfixedAOE); List<gridCoordinate> crossbow_aoe = new List<gridCoordinate>(); crossbow_aoe.Add(opposition_coord); crossbow_aoe.Add(splash_coord); prj.set_small_AOE_matrix(crossbow_aoe); prj.attach_weapon(Bow); fl.create_new_projectile(prj); } string attack_msg = ""; if (monsterID != -1) attack_msg = "You attack the " + fl.badguy_by_monster_id(monsterID).my_name + " with your " + Bow.get_my_name() + "!"; else attack_msg = "You attack the " + fl.Doodad_by_index(DoodadID).my_name() + " with your " + Bow.get_my_name() + "!"; message_buffer.Add(attack_msg); total_sound += my_sound_value() + (my_sound_value() / 2); total_scent += my_scent_value(); if (my_class == Chara_Class.Warrior) { c_energy += 6; } }
public void charge_attack(Floor fl, Weapon lance, gridCoordinate charge_coordinate, int monsterID, int DoodadID) { bool attacked_Doodad = false; bool rolled_max = false; gridCoordinate my_original_position = new gridCoordinate(my_grid_coord); Weapon c_lance = lance; VisionRay attack_ray = null; if(fl.badguy_by_monster_id(monsterID) == null) { attack_ray = new VisionRay(my_grid_coord, fl.Doodad_by_index(DoodadID).get_g_coord()); } else attack_ray = new VisionRay(my_grid_coord, charge_coordinate); gridCoordinate monster_coord = new gridCoordinate(-1, -1); gridCoordinate Doodad_coord = new gridCoordinate(-1, -1); bool done = false; while (!done) { int old_xPosition = (int)attack_ray.my_current_position.X / 32; int old_yPosition = (int)attack_ray.my_current_position.Y / 32; gridCoordinate previous_ray_position = new gridCoordinate(old_xPosition, old_yPosition); attack_ray.update(); int new_xPosition = (int)attack_ray.my_current_position.X / 32; int new_yPosition = (int)attack_ray.my_current_position.Y / 32; gridCoordinate next_ray_position = new gridCoordinate(new_xPosition, new_yPosition); int mon_ID; int dood_ID; fl.is_monster_here(next_ray_position, out mon_ID); fl.is_destroyable_Doodad_here(next_ray_position, out dood_ID); if (mon_ID == monsterID && monsterID > -1) { monster_coord = new gridCoordinate(charge_coordinate); teleport(previous_ray_position); attack_monster_in_grid(fl, lance, monsterID, charge_coordinate, 1.0, out rolled_max, true); done = true; } if (dood_ID == DoodadID && DoodadID > -1) { attacked_Doodad = true; Doodad_coord = new gridCoordinate(fl.Doodad_by_index(DoodadID).get_g_coord()); teleport(previous_ray_position); attack_Doodad_in_grid(fl, lance, DoodadID, fl.Doodad_by_index(DoodadID).get_g_coord(), 1.0, out rolled_max, true); done = true; } } gridCoordinate opposition_coord = new gridCoordinate(-1, -1); if (attacked_Doodad) opposition_coord = Doodad_coord; else opposition_coord = monster_coord; if (!is_spot_free(fl, my_grid_coord)) { int xdif = my_original_position.x - opposition_coord.x; int ydif = my_original_position.y - opposition_coord.y; int whocares = -1; if (fl.is_monster_here(my_grid_coord, out whocares) || fl.is_destroyable_Doodad_here(my_grid_coord, out whocares)) { if (xdif == 0) if (my_original_position.x < my_grid_coord.x) my_grid_coord.x--; else my_grid_coord.x++; if (ydif == 0) if (my_original_position.y < my_grid_coord.y) my_grid_coord.y--; else my_grid_coord.y++; } else if (!fl.is_monster_here(my_grid_coord, out whocares) && !fl.isWalkable(my_grid_coord)) { int xshift = 0; int yshift = 0; if (xdif < 0) xshift = -1; else xshift = 1; if (ydif < 0) yshift = -1; else yshift = 1; gridCoordinate x_shifted = new gridCoordinate(my_grid_coord.x + xshift, my_grid_coord.y); gridCoordinate y_shifted = new gridCoordinate(my_grid_coord.x, my_grid_coord.y + yshift); bool x_ok = fl.isWalkable(x_shifted); bool y_ok = fl.isWalkable(y_shifted); if (x_ok && !y_ok) my_grid_coord = x_shifted; else if (!x_ok && y_ok) my_grid_coord = y_shifted; else { int go_x = rGen.Next(2); if (go_x == 0) my_grid_coord = x_shifted; else my_grid_coord = y_shifted; } } } reset_my_drawing_position(); loot(fl); total_sound += my_sound_value() + (my_sound_value() / 2); total_scent += my_scent_value(); if (my_class == Chara_Class.Warrior) { c_energy += 5 + rGen.Next(3); if (rolled_max) c_energy += 2; } }
public void attack_monster_in_grid(Floor fl, Weapon w, int c_monsterID, gridCoordinate current_gc, double multiplier, out bool rolled_max, bool charge_attack = false) { rolled_max = false; List<Attack> modified_attacks = new List<Attack>(); if (fl.badguy_by_monster_id(c_monsterID) != null && !fl.monster_aware_of_player(c_monsterID) && my_class == Chara_Class.Rogue) max_energy += 2; if (fl.badguy_by_monster_id(c_monsterID) != null) { if (w != null) { string attack_msg = "You attack the " + fl.badguy_by_monster_id(c_monsterID).my_name + " with your " + w.get_my_name() + "!"; message_buffer.Add(attack_msg); List<Attack> attacks = new List<Attack>(); List<StatusEffect> debuffs = new List<StatusEffect>(); bool aoe_effect = false; if (w.get_my_weapon_type() == Weapon.Type.Axe || w.get_my_weapon_type() == Weapon.Type.Lance) aoe_effect = true; handle_attack_damage(w, null, multiplier, charge_attack, out rolled_max, ref attacks, ref debuffs); fl.damage_monster(attacks, debuffs, c_monsterID, true, aoe_effect); } else //Unarmed attack. { double base_dmg_val = (double)rGen.Next(1, 4) * multiplier; if (base_dmg_val == 3 * multiplier) rolled_max = true; int modified_dmg_val = (int)base_dmg_val; if (my_character == Character.Falsael) modified_dmg_val = (int)Math.Ceiling(base_dmg_val * 1.2); modified_attacks.Add(new Attack(Attack.Damage.Crushing, modified_dmg_val)); string attack_msg = "You attack the " + fl.badguy_by_monster_id(c_monsterID).my_name + " with your fists!"; message_buffer.Add(attack_msg); fl.damage_monster(modified_attacks, null, c_monsterID, true, false); } } }