Exemplo n.º 1
0
/*!
 * @brief モンスターのボール型&ブレス型魔法処理 /
 * @param power 呪いの段階
 * @param o_ptr 呪いをかけられる装備オブジェクトの構造体参照ポインタ
 * @return 与える呪いのID
 */
u32b get_curse(int power, object_type *o_ptr)
{
	u32b new_curse;

	while(1)
	{
		new_curse = (1 << (randint0(MAX_CURSE)+4));
		if (power == 2)
		{
			if (!(new_curse & TRC_HEAVY_MASK)) continue;
		}
		else if (power == 1)
		{
			if (new_curse & TRC_SPECIAL_MASK) continue;
		}
		else if (power == 0)
		{
			if (new_curse & TRC_HEAVY_MASK) continue;
		}
		if (new_curse == TRC_LOW_MELEE && !object_is_weapon(o_ptr)) continue;
		if (new_curse == TRC_LOW_AC && !object_is_armour(o_ptr)) continue;
		break;
	}
	return new_curse;
}
Exemplo n.º 2
0
bool object_is_weapon_armour_ammo(object_type *o_ptr)
{
	if (enchantment_hack && o_ptr->name1 == ART_HEPHAESTUS) return FALSE;

	if (object_is_weapon_ammo(o_ptr) || object_is_armour(o_ptr)) return TRUE;

	return FALSE;
}
static void _water_process_world(void)
{
    int inven_ct = 0;
    int equip_ct = 0;
    int chance = 15;
    int i;
    for (i = 0; i < INVEN_TOTAL; i++)
    {
        object_type *o_ptr = &inventory[i];
        u32b         flgs[TR_FLAG_SIZE];
        char         o_name[MAX_NLEN];

        if (!o_ptr->k_idx) continue;
        if (!object_is_armour(o_ptr)) continue;
        if (randint0(1000) >= chance) continue;
        if (o_ptr->ac + o_ptr->to_a <= 0) continue;

        object_flags(o_ptr, flgs);
        if (have_flag(flgs, TR_IGNORE_ACID)) continue;

        object_desc(o_name, o_ptr, (OD_OMIT_PREFIX | OD_NAME_ONLY));
        msg_format("Your watery touch corrodes your %s!", o_name);
                
        o_ptr->to_a--;

        if (i >= EQUIP_BEGIN) ++equip_ct;
        else ++inven_ct;
    }

    if (equip_ct)
    {
        p_ptr->update |= PU_BONUS;
        p_ptr->window |= PW_EQUIP | PW_PLAYER;
    }

    if (equip_ct + inven_ct)
        disturb(1, 0);
}
Exemplo n.º 4
0
/*
 * Check if an object is weapon, armour or ammo
 */
bool object_is_weapon_armour_ammo(object_type *o_ptr)
{
    if (object_is_weapon_ammo(o_ptr) || object_is_armour(o_ptr)) return TRUE;

    return FALSE;
}
Exemplo n.º 5
0
void
combat_attack(Character *who, Character *whom)
{

    int dir;
    int tohit, damage, damage1, damage2, damage_reduced;
    int hits, hits2, luck1, luck2;
    int i;
    int item, weapon_skill;
    char *attack_type;
    int bonus;

    who->ap -= COMBAT_ATTACK_COST;

    if (abs(who->x - whom->x) > abs(who->y - whom->y)) {
        if (who->x > whom->x)
            dir = CHARACTER_LEFT;
        else
            dir = CHARACTER_RIGHT;
    } else {
        if (who->y > whom->y)
            dir = CHARACTER_UP;
        else
            dir = CHARACTER_DOWN;
    }


    character_attack(who, dir);



    tohit = 0;

    if (game_in_party(who))
        damage = 4;             /* bare hand */
    else
        damage = 6;             /* something better */

    attack_type = "swings";

    /* when unarmed, brawl is in effect */
    weapon_skill = 0x40;

    bonus = 0;

    for (i = 0; i < who->items_num; ++i)
        if (who->item_used[i]) {
            item = who->items[i];
            if (object_is_weapon(item)) {
                weapon_skill = object_weapon_skill(item);
                damage = object_weapon_damage(item);
                tohit += object_weapon_to_hit(item);
                if (object_weapon_class(item) == 8)     /* bow */
                    attack_type = "fires";

                /* Sting, Glamdring, Anduril, Durin's Axe, Magic Bow */
                if (item == 0x60 || item == 0x63 || item == 0x62
                    || item == 0x67 || item == 0x65)
                    bonus = 1;

                /* Spider Sword */
                if (item == 0x64 && strcmp(whom->name, "Spider"))
                    bonus = 1;

                /* Troll Slayer */
                if (item == 0x66 &&
                    (strcmp(whom->name, "Troll") ||
                     strcmp(whom->name, "Olog-hai")))
                    bonus = 1;

            }

            /* armours have impairing effect */
            if (object_is_armour(item))
                tohit -= object_weapon_to_hit(item);
        }

    /* better chance to hit if we are skilled with our weapon */
    for (i = 0; i < who->skills_num; ++i)
        if (weapon_skill == who->skills[i]) {
            tohit += 2;
            break;
        }

    damage_reduced = 0;

    for (i = 0; i < whom->items_num; ++i)
        if (whom->item_used[i]) {
            item = who->items[i];

            /* armours have impairing effect */
            if (object_is_armour(item)) {
                damage_reduced = object_armour_reduced(item);
                tohit += object_weapon_to_hit(item);
            }

            if (object_is_shield(item))
                tohit -= object_shield_to_hit(item);
        }


    /* better chance to defend if we have dodge */
    for (i = 0; i < whom->skills_num; ++i)
        if (whom->skills[i] == 0x46) {
            tohit -= 2;
            break;
        }


    hits = combat_if_hits(who->dex, whom->dex, tohit);
    hits2 = combat_if_hits(who->dex, whom->dex, tohit);

    luck1 = lotr_rnd(30 + who->luck);
    luck2 = lotr_rnd(30 + who->luck);

    if (luck1 > 2 * luck2)
        hits = max(hits, hits2);

    if (2 * luck1 < luck2)
        hits = min(hits, hits2);


    /* Balrog must be a deadly foe */
    if (!strcmp(who->name, "Balrog")) {
        hits = 1;
        bonus = 1;
    }

    if (hits) {
        damage1 = lotr_rnd(who->str) / 10 + lotr_rnd(damage)
            + bonus * lotr_rnd(damage) - damage_reduced;
        damage2 = lotr_rnd(who->str) / 10 + lotr_rnd(damage)
            + bonus * lotr_rnd(damage) - damage_reduced;


        luck1 = lotr_rnd(30 + who->luck);
        luck2 = lotr_rnd(30 + who->luck);

        damage = damage1;

        if (luck1 > 2 * luck2)
            damage = max(damage1, damage2);

        if (2 * luck1 < luck2)
            damage = min(damage1, damage2);

        if (damage < 0)
            damage = 0;

        whom->life -= damage;
        if (whom->life < 0)
            whom->life = 0;

    }


    combat_who_attacked = whom;

    if (hits) {
        if (damage > 0) {
            if (whom->life == 0) {
                snprintf(combat_result_text, sizeof(combat_result_text), "%s kills %s.", who->name,
                         whom->name);
                combat_character_remove(whom);

            } else {
                if (whom->life >= 6 || !game_in_party(whom)) {
                    snprintf(combat_result_text, sizeof(combat_result_text),
                             "%s hits %s for %d points of damage.", who->name,
                             whom->name, damage);
                } else {
                    snprintf(combat_result_text, sizeof(combat_result_text),
                             "%s hits %s for %d points of damage, knocking %s out of cold.",
                             who->name, whom->name, damage, whom->name);
                }
            }
        } else {
            snprintf(combat_result_text, sizeof(combat_result_text), "%s hits %s but does no damage.",
                     who->name, whom->name);
        }
    } else {
        snprintf(combat_result_text, sizeof(combat_result_text), "%s %s at and misses %s.", who->name,
                 attack_type, whom->name);
    }

    if (hits)
        sound_play(10);
    else
        sound_play(11);

    combat_attack_animation = 1;

}
Exemplo n.º 6
0
void
combat_start(void)
{

    int i, j;
    int leader_x, leader_y;

    combat_mode = 1;
    music_combat_started();
    quit_menu();
    combat_attack_animation = 0;

    map_get_center(&combat_x, &combat_y);

    combat_x /= 8;
    combat_y /= 8;

    combat_x -= COMBAT_C_X;
    combat_y -= COMBAT_C_Y;


    combat_party_size = game_get_party_characters(combat_party);

    combat_leader_x = game_get_leader()->x;
    leader_x = combat_leader_x / 4 - combat_x;
    combat_leader_y = game_get_leader()->y;
    leader_y = combat_leader_y / 4 - combat_y;

    if (leader_x < 0)
        leader_x = 0;
    if (leader_y < 0)
        leader_y = 0;
    if (leader_x >= COMBAT_WIDTH)
        leader_x = COMBAT_WIDTH - 1;
    if (leader_y >= COMBAT_HEIGHT)
        leader_x = COMBAT_HEIGHT - 1;


    combat_area_init();

    combat_area[leader_x][leader_y] = 1;
    combat_stack[0][0] = leader_x;
    combat_stack[0][1] = leader_y;
    combat_stack_size = 1;
    combat_stack_start = 0;
    combat_stack_proceed();


    for (i = 0; i < combat_party_size; ++i)
        combat_move_to_area(combat_party[i]);

    ring_not_working = 0;

    for (i = 0; i < combat_enemies_num; ++i) {
        /* somewhat stupid */
        if (!strcmp(combat_enemies[i]->name, "Nazgul") ||
            !strcmp(combat_enemies[i]->name, "Witch-King") ||
            !strcmp(combat_enemies[i]->name, "Ghostking") ||
            !strcmp(combat_enemies[i]->name, "Ghost") ||
            !strcmp(combat_enemies[i]->name, "Balrog") ||
            !strcmp(combat_enemies[i]->name, "Barrow Wight") ||
            !strcmp(combat_enemies[i]->name, "Werewolf"))
            ring_not_working = 1;

        if (strcmp(combat_enemies[i]->name, "Tentacles"))
            combat_move_to_area(combat_enemies[i]);

        for (j = 0; j < combat_enemies[i]->items_num; ++j)
            combat_enemies[i]->item_used[j] = 0;

        for (j = 0; j < combat_enemies[i]->items_num; ++j)
            if (object_is_weapon(combat_enemies[i]->items[j])) {
                combat_enemies[i]->item_used[j] = 1;
                break;
            }

        for (j = 0; j < combat_enemies[i]->items_num; ++j)
            if (object_is_armour(combat_enemies[i]->items[j])) {
                combat_enemies[i]->item_used[j] = 1;
                break;
            }

        for (j = 0; j < combat_enemies[i]->items_num; ++j)
            if (object_is_shield(combat_enemies[i]->items[j])) {
                combat_enemies[i]->item_used[j] = 1;
                break;
            }

    }

    active_character = NULL;
    combat_next_turn();

}