diff --git a/server/gameserver/battledatacontext.cc b/server/gameserver/battledatacontext.cc index 9b098828..14885b1c 100644 --- a/server/gameserver/battledatacontext.cc +++ b/server/gameserver/battledatacontext.cc @@ -368,22 +368,28 @@ void BattleDataContext::ParseResult(a8::XObject& obj) } if (obj.HasKey("weapon_dto1") && obj.At("weapon_dto1")->IsObject()) { weapon_dto1 = obj.At("weapon_dto1"); - const mt::Equip* meta = mt::Equip::GetById(weapon_dto1->Get("gun_id", 0)); - if (meta) { - weapon1_ability_ = std::make_shared(); - weapon1_ability_->weapon_uniid = weapon_dto1->Get("gun_uniid", 0); - weapon1_ability_->weapon_meta = meta; - weapon1_ability_->weapon_dto = weapon_dto1; + const mt::Item* item_meta = mt::Item::GetById(weapon_dto1->Get("gun_id", 0)); + if (item_meta) { + const mt::Equip* meta = mt::Equip::GetById(item_meta->relationship()); + if (meta) { + weapon1_ability_ = std::make_shared(); + weapon1_ability_->weapon_uniid = weapon_dto1->Get("gun_uniid", 0); + weapon1_ability_->weapon_meta = meta; + weapon1_ability_->weapon_dto = weapon_dto1; + } } } if (obj.HasKey("weapon_dto2") && obj.At("weapon_dto2")->IsObject()) { weapon_dto2 = obj.At("weapon_dto2"); - const mt::Equip* meta = mt::Equip::GetById(weapon_dto2->Get("gun_id", 0)); - if (meta) { - weapon2_ability_ = std::make_shared(); - weapon2_ability_->weapon_uniid = weapon_dto2->Get("gun_uniid", 0); - weapon2_ability_->weapon_meta = meta; - weapon2_ability_->weapon_dto = weapon_dto2; + const mt::Item* item_meta = mt::Item::GetById(weapon_dto2->Get("gun_id", 0)); + if (item_meta) { + const mt::Equip* meta = mt::Equip::GetById(item_meta->relationship()); + if (meta) { + weapon2_ability_ = std::make_shared(); + weapon2_ability_->weapon_uniid = weapon_dto2->Get("gun_uniid", 0); + weapon2_ability_->weapon_meta = meta; + weapon2_ability_->weapon_dto = weapon_dto2; + } } } } @@ -522,7 +528,7 @@ float BattleDataContext::CalcDmg(Creature* target, IBullet* bullet) g_calc_dmg_context.is_crit = IsCrit(bullet) ? 1 : 0; float total_atk = GetTotalAtk(bullet); - float normal_dmg = total_atk * (1 - target->GetBattleContext()->GetDef() / 1000); + float normal_dmg = total_atk * (1 - target->GetBattleContext()->GetDef() / (target->GetBattleContext()->GetDef() + 400)); normal_dmg *= 1 + bullet->GetStrengthenWall(); float crit = g_calc_dmg_context.is_crit ? GetCritRate(bullet) : 0; float dodge = IsDodge(bullet) ? GetDodgeRuduce(bullet) : 0; @@ -535,10 +541,12 @@ float BattleDataContext::CalcDmg(Creature* target, IBullet* bullet) #ifdef DEBUG if (owner_.Get()->IsPlayer()) { std::string data = a8::Format - ("数值: 子弹攻击怪物 total_atk:%f normal_dmg:%f crit:%f dodge:%f finaly_dmg:%f target_def:%f", + ("数值: 子弹攻击怪物 total_atk:%f hero_atk:%f weapon_%f normal_dmg:%f crit:%f dodge:%f finaly_dmg:%f target_def:%f", { total_atk, normal_dmg, + GetHeroTotalAtk(), + GetWeaponAtk(bullet), crit, dodge, finaly_dmg, @@ -551,7 +559,7 @@ float BattleDataContext::CalcDmg(Creature* target, IBullet* bullet) if (g_calc_dmg_context.is_crit) { g_calc_dmg_context.crit_dmg = finaly_dmg; } - return finaly_dmg; + return std::round(finaly_dmg); } float BattleDataContext::CalcDmg(Obstacle* target, IBullet* bullet)