From 4cfe93e405bb8026c39523b18d6c8aac11ec3368 Mon Sep 17 00:00:00 2001 From: aozhiwei Date: Sun, 28 Apr 2024 11:34:08 +0800 Subject: [PATCH] 1 --- server/gameserver/mt/Hero.cc | 6 +++--- server/gameserver/shot.cc | 34 ++++++++++++++++++++++++++-------- 2 files changed, 29 insertions(+), 11 deletions(-) diff --git a/server/gameserver/mt/Hero.cc b/server/gameserver/mt/Hero.cc index c1aa04ea..e397f429 100644 --- a/server/gameserver/mt/Hero.cc +++ b/server/gameserver/mt/Hero.cc @@ -93,8 +93,8 @@ static bool LoadOtherHeroAnimi(const std::string key, std::shared_ptr anim_xobj, mt::HeroShotAnimation& anim) { - std::string id_str; - a8::ReplaceString(id_str, key, "other"); + std::string id_str = key; + a8::ReplaceString(id_str, "other", ""); int id = a8::XValue(id_str); std::vector keys; @@ -102,7 +102,7 @@ static bool LoadOtherHeroAnimi(const std::string key, for (auto& tmp_key : keys) { auto act_xobj = anim_xobj->At(tmp_key); int act_id = a8::XValue(tmp_key).GetInt(); - int h = act_xobj->At("h")->AsXValue().GetInt(); + int h = act_xobj->At("h")->AsXValue().GetString() == "l" ? mt::SHOT_HAND_LEFT : mt::SHOT_HAND_RIGHT; int t = act_xobj->At("t")->AsXValue().GetInt() * 1000; float x = act_xobj->At("x")->AsXValue().GetDouble(); float y = act_xobj->At("y")->AsXValue().GetDouble(); diff --git a/server/gameserver/shot.cc b/server/gameserver/shot.cc index 0edc2e41..27d4e203 100644 --- a/server/gameserver/shot.cc +++ b/server/gameserver/shot.cc @@ -74,6 +74,19 @@ static void CalcGunMuzzlePosition(Creature* c, } if (shot_animi) { if (shot_animi->is_other) { + if (bulletIdx > 0 && bulletIdx <= shot_animi->other_list.size()) { + gun_muzzle_position += + glm::vec4( + shot_animi->other_list.at(bulletIdx - 1).x, + shot_animi->other_list.at(bulletIdx - 1).y, + shot_animi->other_list.at(bulletIdx - 1).z, + 0 + ); + } else { +#ifdef MYDEBUG + A8_ABORT(); +#endif + } } else { if (weapon_meta->double_gun()&& bulletIdx > (int)(bulletNum / 2)) { @@ -436,7 +449,7 @@ void InternalShot(Creature* c, bullet_angle *= 1.0f + c->GetAbility()->GetAttr(kHVAT_BulletAngle); } GlmHelper::RotateY(bullet_dir, glm::radians(bullet_angle)); - int shot_animi_time = (shot_animi ? shot_animi->t : 0); + int shot_animi_time = (shot_animi ? shot_animi->GetShotAnimTime(bulletIdx - 1) : 0); if (shot_animi_time > 0) { shot_animi_time = std::max(100, shot_animi_time); } @@ -470,7 +483,7 @@ void InternalShot(Creature* c, } if (c->IsPlayer() || c->IsCar()) { #ifdef MYDEBUG - a8::XPrintf("idx:%d offset:%f,%f,%f angle:%f old_angle:%f angle_xyz:%f,%f,%f %f %f gun_muzzle_position:%f,%f,%f pos:%f,%f,%f gun_id:%d t:%d fly_distance:%f delay_time:%d\n", + a8::XPrintf("idx:%d offset:%f,%f,%f angle:%f old_angle:%f angle_xyz:%f,%f,%f %f %f gun_muzzle_position:%f,%f,%f pos:%f,%f,%f gun_id:%d t:%d fly_distance:%f delay_time:%d hand:%d\n", { bulletIdx, bullet_born_offset.x, @@ -492,7 +505,8 @@ void InternalShot(Creature* c, weapon_meta->id(), shot_animi_time, fly_distance, - std::get<3>(tuple) + std::get<3>(tuple), + shot_animi && shot_animi->is_other ? shot_animi->GetShotHand(bulletIdx - 1) : -1 }); #endif } @@ -524,11 +538,15 @@ void InternalShot(Creature* c, bullet_info.reporter_list = c->CalcReporterList(trace_target_uniid, weapon_meta, bullet_meta); bullet_info.ignore_original_dmg = c->GetAbility()->GetSwitchTimes(kIgnoreOriginalDmg) > 0; bullet_info.on_bullet_exit = on_bullet_exit; - if (weapon_meta->double_gun() && - bulletIdx > (int)(bulletNum / 2)) { - bullet_info.hand = 1; - } else if (weapon_meta->hand() == 1) { - bullet_info.hand = 1; + if (shot_animi && shot_animi->is_other) { + bullet_info.hand = shot_animi->GetShotHand(bulletIdx - 1); + } else { + if (weapon_meta->double_gun() && + bulletIdx > (int)(bulletNum / 2)) { + bullet_info.hand = 1; + } else if (weapon_meta->hand() == 1) { + bullet_info.hand = 1; + } } #ifdef MYDEBUG1 if (bullet_info.trace_target_uniid) {