Esempio n. 1
0
        public void halberdier_linear_spear_stab(Player pl, Floor fl, int x_difference, int y_difference)
        {
            int x_incr = 0;

            if (x_difference > 0)
            {
                x_incr = 1;
            }
            else if (x_difference < 0)
            {
                x_incr = -1;
            }

            if (y_difference == 0)
            {
                int y_value = my_grid_coords[0].y;
                for (int i = 0; i < 2; i++)
                {
                    int            x_value         = my_grid_coords[0].x + (x_incr * (i + 1));
                    gridCoordinate target_location = new gridCoordinate(x_value, y_value);
                    if (pl.get_my_grid_C().x == target_location.x && pl.get_my_grid_C().y == target_location.y)
                    {
                        fl.addmsg("The Skeleton thrusts its spear forward in a heavy stab!");
                        int    dmgVal = rGen.Next(min_damage, (max_damage + 1));
                        Attack dmg    = new Attack(dmg_type, dmgVal);
                        pl.take_damage(dmg, fl, "");
                    }
                    else
                    {
                        int mon_ID;
                        fl.is_monster_here(target_location, out mon_ID);
                        if (mon_ID != -1)
                        {
                            int dmg_value = rGen.Next(min_damage, (max_damage + 1)) * 2;
                            fl.add_new_popup("- " + dmg_value.ToString(), Popup.popup_msg_color.Red, target_location);
                            fl.damage_monster_single_atk(new Attack(dmg_type, dmg_value), null, mon_ID, true, true);
                        }
                    }
                    if (fl.is_tile_passable(target_location))
                    {
                        fl.add_effect(dmg_type, target_location);
                    }
                }
            }

            int y_incr = 0;

            if (y_difference > 0)
            {
                y_incr = 1;
            }
            else if (y_difference < 0)
            {
                y_incr = -1;
            }

            if (x_difference == 0)
            {
                int x_value = my_grid_coords[0].x;
                for (int i = 0; i < 2; i++)
                {
                    int            y_value         = my_grid_coords[0].y + (y_incr * (i + 1));
                    gridCoordinate target_location = new gridCoordinate(x_value, y_value);
                    if (pl.get_my_grid_C().x == target_location.x && pl.get_my_grid_C().y == target_location.y)
                    {
                        fl.addmsg("The Skeleton thrusts its spear forward in a heavy stab!");
                        int    dmgVal = rGen.Next(min_damage, (max_damage + 1));
                        Attack dmg    = new Attack(dmg_type, dmgVal);
                        pl.take_damage(dmg, fl, "");
                    }
                    else
                    {
                        int mon_ID;
                        fl.is_monster_here(target_location, out mon_ID);
                        if (mon_ID != -1)
                        {
                            int dmg_value = rGen.Next(min_damage, (max_damage + 1)) * 2;
                            fl.add_new_popup("- " + dmg_value.ToString(), Popup.popup_msg_color.Red, target_location);
                            fl.damage_monster_single_atk(new Attack(dmg_type, dmg_value), null, mon_ID, true, true);
                        }
                    }
                    if (fl.is_tile_passable(target_location))
                    {
                        fl.add_effect(dmg_type, target_location);
                    }
                }
            }
        }
Esempio n. 2
0
        public override void Update_Monster(Player pl, Floor fl)
        {
            has_moved = false;
            Tile target_tile = find_strongest_scent(fl, 0, smell_threshold, smell_range);

            if (target_tile == null)
            {
                has_scent = false;
            }
            else
            {
                has_scent             = true;
                strongest_smell_coord = target_tile.get_grid_c();
            }

            if (is_player_within(pl, sight_range))
            {
                can_see_player = can_i_see_point(fl, pl.get_my_grid_C());
            }
            else
            {
                can_see_player = false;
            }

            if (!stunned)
            {
                if (can_see_player)
                {
                    have_i_seen_player  = true;
                    last_seen_player_at = new gridCoordinate(pl.get_my_grid_C());
                    //fl.add_new_popup("The Grendel sees you!", Popup.popup_msg_color.Red, my_grid_coord);

                    if (my_weapon_type == Grendel_Weapon_Type.Frostbolt && can_cast(0, frostbolt_manacost, fl))
                    {
                        if (!is_player_within_diamond(pl, 4))
                        {
                            advance_towards_single_point(last_seen_player_at, pl, fl, 0, corporeal);
                        }
                        else
                        {
                            cast_frostbolt(fl, pl.get_my_grid_C());
                        }
                    }
                    else
                    {
                        if (!is_player_within(pl, 1))
                        {
                            advance_towards_single_point(last_seen_player_at, pl, fl, 1, corporeal);
                        }
                        else
                        {
                            fl.addmsg("The Grendel attacks you!");
                            fl.add_effect(dmg_type, pl.get_my_grid_C());
                            Attack dmg = dealDamage();
                            pl.take_damage(dmg, fl, "");
                        }
                    }
                }
                else if (!can_see_player && have_i_seen_player)
                {
                    //fl.add_new_popup("The Grendel goes to your last position!", Popup.popup_msg_color.Red, my_grid_coord);
                    advance_towards_single_point(last_seen_player_at, pl, fl, 0, corporeal);
                    if (occupies_tile(last_seen_player_at))
                    {
                        have_i_seen_player = false;
                    }
                }
                else if (!can_see_player && !have_i_seen_player && has_scent)
                {
                    //fl.add_new_popup("The Grendel smells you!", Popup.popup_msg_color.Red, my_grid_coord);
                    if (is_player_within(pl, 1))
                    {
                        advance_towards_single_point(strongest_smell_coord, pl, fl, 1, corporeal);
                    }
                    else
                    {
                        advance_towards_single_point(strongest_smell_coord, pl, fl, 0, corporeal);
                    }
                }
                else
                {
                    if (heard_something)
                    {
                        follow_path_to_sound(fl, pl);
                    }
                    else
                    {
                        //50% chance to wander.
                        int should_i_wander = rGen.Next(2);
                        if (should_i_wander == 1)
                        {
                            //fl.add_new_popup("The Grendel wanders!", Popup.popup_msg_color.Red, my_grid_coord);
                            wander(pl, fl, corporeal);
                        }
                    }
                }
            }

            base.Update_Monster(pl, fl);
        }
Esempio n. 3
0
        public override void Update_Monster(Player pl, Floor fl)
        {
            has_moved = false;
            heal_near_altar(fl);

            if (is_player_within(pl, sight_range))
            {
                can_see_player = can_i_see_point(fl, pl.get_my_grid_C());
            }
            else
            {
                can_see_player = false;
            }

            if (!stunned)
            {
                if (can_see_player)
                {
                    have_i_seen_player  = true;
                    last_seen_player_at = new gridCoordinate(pl.get_my_grid_C());

                    if (my_weapon_type == Skeleton_Weapon_Type.Bow ||
                        (my_weapon_type == Skeleton_Weapon_Type.Flamebolt && can_cast(0, flamebolt_mana_cost, fl)))
                    {
                        if (!is_player_within_diamond(pl, 4))
                        {
                            advance_towards_single_point(pl.get_my_grid_C(), pl, fl, 1, corporeal);
                        }
                        else
                        {
                            fl.addmsg("The Skeleton attacks you!");
                            if (my_weapon_type == Skeleton_Weapon_Type.Bow)
                            {
                                fire_arrow(fl, pl.get_my_grid_C());
                            }
                            else if (my_weapon_type == Skeleton_Weapon_Type.Flamebolt)
                            {
                                fire_flamebolt(fl, pl.get_my_grid_C());
                            }
                        }
                    }
                    else
                    {
                        if (!is_player_within(pl, 1))
                        {
                            advance_towards_single_point(pl.get_my_grid_C(), pl, fl, 1, corporeal);
                        }
                        else
                        {
                            fl.addmsg("The Skeleton attacks you!");
                            fl.add_effect(dmg_type, pl.get_my_grid_C());
                            Attack dmg = dealDamage();
                            pl.take_damage(dmg, fl, "");
                        }
                    }
                }
                else if (!can_see_player && have_i_seen_player && !has_moved)
                {
                    advance_towards_single_point(last_seen_player_at, pl, fl, 0, corporeal);
                    if (occupies_tile(last_seen_player_at))
                    {
                        have_i_seen_player = false;
                    }
                }
                else if (!can_see_player && !have_i_seen_player && heard_something)
                {
                    follow_path_to_sound(fl, pl);
                }
                else if (!can_see_player && !have_i_seen_player && !heard_something && !has_moved)
                {
                    int should_i_wander = rGen.Next(6);
                    if (should_i_wander == 1)
                    {
                        wander(pl, fl, corporeal);
                    }
                }
            }

            base.Update_Monster(pl, fl);
        }