From 993830a5063b8d2af4240ea5bf1c06dfa4f66b7d Mon Sep 17 00:00:00 2001 From: Ben Longbons Date: Mon, 31 Mar 2014 10:13:41 -0700 Subject: Check the equip index array --- src/map/battle.cpp | 33 +++++++++++++++++---------------- 1 file changed, 17 insertions(+), 16 deletions(-) (limited to 'src/map/battle.cpp') diff --git a/src/map/battle.cpp b/src/map/battle.cpp index 49a0538..75ae4f0 100644 --- a/src/map/battle.cpp +++ b/src/map/battle.cpp @@ -1306,8 +1306,9 @@ int battle_is_unarmed(dumb_ptr bl) { dumb_ptr sd = bl->is_player(); - return (sd->equip_index[EQUIP::SHIELD] == -1 - && sd->equip_index[EQUIP::WEAPON] == -1); + int sidx = sd->equip_index_maybe[EQUIP::SHIELD]; + int widx = sd->equip_index_maybe[EQUIP::WEAPON]; + return sidx == -1 && widx == -1; } else return 0; @@ -1426,15 +1427,14 @@ struct Damage battle_calc_pc_weapon_attack(dumb_ptr src, atkmin = atkmin_ = dex; //最低ATKはDEXで初期化? sd->state.arrow_atk = 0; //arrow_atk初期化 - if (sd->equip_index[EQUIP::WEAPON] >= 0 && sd->inventory_data[sd->equip_index[EQUIP::WEAPON]]) - atkmin = - atkmin * (80 + - sd->inventory_data[sd->equip_index[EQUIP::WEAPON]]->wlv * 20) / 100; - if (sd->equip_index[EQUIP::SHIELD] >= 0 && sd->inventory_data[sd->equip_index[EQUIP::SHIELD]]) - atkmin_ = - atkmin_ * (80 + - sd->inventory_data[sd->equip_index[EQUIP::SHIELD]]->wlv * 20) / - 100; + + int widx = sd->equip_index_maybe[EQUIP::WEAPON]; + int sidx = sd->equip_index_maybe[EQUIP::SHIELD]; + + if (widx >= 0 && sd->inventory_data[widx]) + atkmin = atkmin * (80 + sd->inventory_data[widx]->wlv * 20) / 100; + if (sidx >= 0 && sd->inventory_data[sidx]) + atkmin_ = atkmin_ * (80 + sd->inventory_data[sidx]->wlv * 20) / 100; if (sd->status.weapon == ItemLook::BOW) { //武器が弓矢の場合 atkmin = watk * ((atkmin < watk) ? atkmin : watk) / 100; //弓用最低ATK計算 @@ -1989,10 +1989,11 @@ ATK battle_weapon_attack(dumb_ptr src, dumb_ptr target, // 攻撃対象となりうるので攻撃 if (sd && sd->status.weapon == ItemLook::BOW) { - if (sd->equip_index[EQUIP::ARROW] >= 0) + int aidx = sd->equip_index_maybe[EQUIP::ARROW]; + if (aidx >= 0) { if (battle_config.arrow_decrement) - pc_delitem(sd, sd->equip_index[EQUIP::ARROW], 1, 0); + pc_delitem(sd, aidx, 1, 0); } else { @@ -2036,10 +2037,10 @@ ATK battle_weapon_attack(dumb_ptr src, dumb_ptr target, if (src->bl_type == BL::PC) { - int weapon_index = sd->equip_index[EQUIP::WEAPON]; + int weapon_index = sd->equip_index_maybe[EQUIP::WEAPON]; int weapon = 0; - if (sd->inventory_data[weapon_index] - && bool(sd->status.inventory[weapon_index].equip & EPOS::WEAPON)) + if (weapon_index >= 0 && sd->inventory_data[weapon_index] + && bool(sd->status.inventory[weapon_index].equip & EPOS::WEAPON)) weapon = sd->inventory_data[weapon_index]->nameid; MAP_LOG("PC%d %s:%d,%d WPNDMG %s%d %d FOR %d WPN %d", -- cgit v1.2.3-60-g2f50