This commit is contained in:
aozhiwei 2023-02-13 16:47:06 +08:00
parent 7ae9640d32
commit 1a8990cc59

View File

@ -368,7 +368,9 @@ void BattleDataContext::ParseResult(a8::XObject& obj)
} }
if (obj.HasKey("weapon_dto1") && obj.At("weapon_dto1")->IsObject()) { if (obj.HasKey("weapon_dto1") && obj.At("weapon_dto1")->IsObject()) {
weapon_dto1 = obj.At("weapon_dto1"); weapon_dto1 = obj.At("weapon_dto1");
const mt::Equip* meta = mt::Equip::GetById(weapon_dto1->Get("gun_id", 0)); 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) { if (meta) {
weapon1_ability_ = std::make_shared<WeaponAbility>(); weapon1_ability_ = std::make_shared<WeaponAbility>();
weapon1_ability_->weapon_uniid = weapon_dto1->Get("gun_uniid", 0); weapon1_ability_->weapon_uniid = weapon_dto1->Get("gun_uniid", 0);
@ -376,9 +378,12 @@ void BattleDataContext::ParseResult(a8::XObject& obj)
weapon1_ability_->weapon_dto = weapon_dto1; weapon1_ability_->weapon_dto = weapon_dto1;
} }
} }
}
if (obj.HasKey("weapon_dto2") && obj.At("weapon_dto2")->IsObject()) { if (obj.HasKey("weapon_dto2") && obj.At("weapon_dto2")->IsObject()) {
weapon_dto2 = obj.At("weapon_dto2"); weapon_dto2 = obj.At("weapon_dto2");
const mt::Equip* meta = mt::Equip::GetById(weapon_dto2->Get("gun_id", 0)); 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) { if (meta) {
weapon2_ability_ = std::make_shared<WeaponAbility>(); weapon2_ability_ = std::make_shared<WeaponAbility>();
weapon2_ability_->weapon_uniid = weapon_dto2->Get("gun_uniid", 0); weapon2_ability_->weapon_uniid = weapon_dto2->Get("gun_uniid", 0);
@ -387,6 +392,7 @@ void BattleDataContext::ParseResult(a8::XObject& obj)
} }
} }
} }
}
void BattleDataContext::GetHeroLvQuality(int& hero_lv, int& quality) void BattleDataContext::GetHeroLvQuality(int& hero_lv, int& quality)
{ {
@ -522,7 +528,7 @@ float BattleDataContext::CalcDmg(Creature* target, IBullet* bullet)
g_calc_dmg_context.is_crit = IsCrit(bullet) ? 1 : 0; g_calc_dmg_context.is_crit = IsCrit(bullet) ? 1 : 0;
float total_atk = GetTotalAtk(bullet); 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(); normal_dmg *= 1 + bullet->GetStrengthenWall();
float crit = g_calc_dmg_context.is_crit ? GetCritRate(bullet) : 0; float crit = g_calc_dmg_context.is_crit ? GetCritRate(bullet) : 0;
float dodge = IsDodge(bullet) ? GetDodgeRuduce(bullet) : 0; float dodge = IsDodge(bullet) ? GetDodgeRuduce(bullet) : 0;
@ -535,10 +541,12 @@ float BattleDataContext::CalcDmg(Creature* target, IBullet* bullet)
#ifdef DEBUG #ifdef DEBUG
if (owner_.Get()->IsPlayer()) { if (owner_.Get()->IsPlayer()) {
std::string data = a8::Format 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, total_atk,
normal_dmg, normal_dmg,
GetHeroTotalAtk(),
GetWeaponAtk(bullet),
crit, crit,
dodge, dodge,
finaly_dmg, finaly_dmg,
@ -551,7 +559,7 @@ float BattleDataContext::CalcDmg(Creature* target, IBullet* bullet)
if (g_calc_dmg_context.is_crit) { if (g_calc_dmg_context.is_crit) {
g_calc_dmg_context.crit_dmg = finaly_dmg; g_calc_dmg_context.crit_dmg = finaly_dmg;
} }
return finaly_dmg; return std::round(finaly_dmg);
} }
float BattleDataContext::CalcDmg(Obstacle* target, IBullet* bullet) float BattleDataContext::CalcDmg(Obstacle* target, IBullet* bullet)