From 40ad332a7ee81db6450a3f8e4ae7c92cc085de3c Mon Sep 17 00:00:00 2001 From: aozhiwei Date: Fri, 26 Apr 2024 17:18:05 +0800 Subject: [PATCH] 1 --- server/gameserver/mt/Hero.cc | 26 +++++++ server/gameserver/mt/Hero.h | 2 + server/gameserver/pbutils.cc | 3 + server/gameserver/shot.cc | 137 ++++++++++++++++++----------------- 4 files changed, 101 insertions(+), 67 deletions(-) diff --git a/server/gameserver/mt/Hero.cc b/server/gameserver/mt/Hero.cc index 1f30bbf1..c1aa04ea 100644 --- a/server/gameserver/mt/Hero.cc +++ b/server/gameserver/mt/Hero.cc @@ -107,6 +107,9 @@ static bool LoadOtherHeroAnimi(const std::string key, float x = act_xobj->At("x")->AsXValue().GetDouble(); float y = act_xobj->At("y")->AsXValue().GetDouble(); float z = act_xobj->At("z")->AsXValue().GetDouble(); + if (!(h == mt::SHOT_HAND_RIGHT || h == mt::SHOT_HAND_LEFT)) { + A8_ABORT(); + } mt::HeroShotAnimationOther o; o.hand = h; o.t = t; @@ -429,4 +432,27 @@ namespace mt } } } + + int HeroShotAnimation::GetShotAnimTime(int bullet_idx) const + { + if (!is_other) { + return t; + } + if (bullet_idx >= 0 && bullet_idx < other_list.size()) { + return other_list.at(bullet_idx).t; + } + return 0; + } + + int HeroShotAnimation::GetShotHand(int bullet_idx) const + { + if (!is_other) { + return SHOT_HAND_RIGHT; + } + if (bullet_idx >= 0 && bullet_idx < other_list.size()) { + return other_list.at(bullet_idx).hand; + } + return SHOT_HAND_RIGHT; + } + } diff --git a/server/gameserver/mt/Hero.h b/server/gameserver/mt/Hero.h index dbd2d6d9..c851de21 100644 --- a/server/gameserver/mt/Hero.h +++ b/server/gameserver/mt/Hero.h @@ -47,6 +47,8 @@ namespace mt float p5_z = 0; std::vector other_list; + int GetShotAnimTime(int bullet_idx) const; + int GetShotHand(int bullet_idx) const; }; DECLARE_ID_TABLE(Hero, mtb::Hero, diff --git a/server/gameserver/pbutils.cc b/server/gameserver/pbutils.cc index 1ed35b0d..b8912f8b 100644 --- a/server/gameserver/pbutils.cc +++ b/server/gameserver/pbutils.cc @@ -2200,7 +2200,10 @@ void Human::PushJoinRoomMsg() notifymsg.set_error_code(0); notifymsg.set_server_info(JsonDataMgr::Instance()->server_info); room->FillSMJoinedNotify(this, notifymsg); +#ifdef MYDEBUG +#else notifymsg.set_pre_client_shot(mt::Param::s().pre_client_shot); +#endif GGListener::Instance()->SendToClient(socket_handle, 0, notifymsg); } { diff --git a/server/gameserver/shot.cc b/server/gameserver/shot.cc index 698c6d7b..0edc2e41 100644 --- a/server/gameserver/shot.cc +++ b/server/gameserver/shot.cc @@ -73,20 +73,60 @@ static void CalcGunMuzzlePosition(Creature* c, int i = 0; } if (shot_animi) { - if (weapon_meta->double_gun()&& - bulletIdx > (int)(bulletNum / 2)) { - gun_muzzle_position += - glm::vec4( - shot_animi->l_x, - shot_animi->l_y, - shot_animi->l_z, - 0 - ); + if (shot_animi->is_other) { } else { - if (c->IsCar() && !weapon_meta->double_gun()) { - switch (c->shot_hole) { - case 1: - { + if (weapon_meta->double_gun()&& + bulletIdx > (int)(bulletNum / 2)) { + gun_muzzle_position += + glm::vec4( + shot_animi->l_x, + shot_animi->l_y, + shot_animi->l_z, + 0 + ); + } else { + if (c->IsCar() && !weapon_meta->double_gun()) { + switch (c->shot_hole) { + case 1: + { + gun_muzzle_position += + glm::vec4( + shot_animi->p3_x, + shot_animi->p3_y, + shot_animi->p3_z, + 0 + ); + } + break; + case 2: + { + gun_muzzle_position += + glm::vec4( + shot_animi->p4_x, + shot_animi->p4_y, + shot_animi->p4_z, + 0 + ); + } + break; + case 3: + { + gun_muzzle_position += + glm::vec4( + shot_animi->p5_x, + shot_animi->p5_y, + shot_animi->p5_z, + 0 + ); + } + break; + default: + { + } + break; + } + } else { + if (c->GetHeroMeta()->id() == 60100) { gun_muzzle_position += glm::vec4( shot_animi->p3_x, @@ -94,61 +134,24 @@ static void CalcGunMuzzlePosition(Creature* c, shot_animi->p3_z, 0 ); - } - break; - case 2: - { - gun_muzzle_position += - glm::vec4( - shot_animi->p4_x, - shot_animi->p4_y, - shot_animi->p4_z, - 0 - ); - } - break; - case 3: - { - gun_muzzle_position += - glm::vec4( - shot_animi->p5_x, - shot_animi->p5_y, - shot_animi->p5_z, - 0 - ); - } - break; - default: - { - } - break; - } - } else { - if (c->GetHeroMeta()->id() == 60100) { - gun_muzzle_position += - glm::vec4( - shot_animi->p3_x, - shot_animi->p3_y, - shot_animi->p3_z, - 0 - ); - } else { - if (weapon_meta->hand() == 1) { - gun_muzzle_position += - glm::vec4( - shot_animi->l_x, - shot_animi->l_y, - shot_animi->l_z, - 0 - ); } else { - gun_muzzle_position += - glm::vec4( - shot_animi->r_x, - shot_animi->r_y, - shot_animi->r_z, - 0 - ); + if (weapon_meta->hand() == 1) { + gun_muzzle_position += + glm::vec4( + shot_animi->l_x, + shot_animi->l_y, + shot_animi->l_z, + 0 + ); + } else { + gun_muzzle_position += + glm::vec4( + shot_animi->r_x, + shot_animi->r_y, + shot_animi->r_z, + 0 + ); + } } } }