From 11c3f8139fe3d6640176f8c6fa8d8e22a6cd6513 Mon Sep 17 00:00:00 2001 From: aozhiwei Date: Wed, 29 Mar 2023 13:30:45 +0800 Subject: [PATCH] 1 --- server/gameserver/mt/Buff.cc | 50 +++++++++++++++++++----------------- server/gameserver/shot.cc | 10 +++++--- 2 files changed, 34 insertions(+), 26 deletions(-) diff --git a/server/gameserver/mt/Buff.cc b/server/gameserver/mt/Buff.cc index 193d51a5..83f4b090 100644 --- a/server/gameserver/mt/Buff.cc +++ b/server/gameserver/mt/Buff.cc @@ -5,6 +5,8 @@ #include "mt/Buff.h" #include "mt/Hero.h" +#include "buff/callfunc.h" + IMPL_TABLE(mt::Buff) namespace mt @@ -12,29 +14,6 @@ namespace mt void Buff::Init1() { - { - std::string data = ""; - std::vector strings; - a8::Split(data, strings, '|'); - for (auto& str : strings) { - std::vector strings2; - a8::Split(str, strings2, ':'); - if (strings2.size() < 2) { - abort(); - } - _bullet_born_offset.push_back - (std::make_tuple( - a8::XValue(strings2[0]).GetDouble(), - a8::XValue(strings2[1]).GetDouble(), - strings2.size() > 2 ? a8::XValue(strings2[2]).GetDouble() : 0, - strings2.size() > 3 ? a8::XValue(strings2[3]).GetInt() : 0, - strings2.size() > 4 ? a8::XValue(strings2[4]).GetInt() : 0, - strings2.size() > 5 ? a8::XValue(strings2[5]).GetInt() : 0 - ) - ); - } - } - _buff_param1 = a8::XValue(buff_param1()).GetDouble(); _buff_param2 = a8::XValue(buff_param2()).GetDouble(); _buff_param3 = a8::XValue(buff_param3()).GetDouble(); @@ -296,6 +275,31 @@ namespace mt A8_ABORT(); } } + { + if (buff_effect() == kBET_CallFunc && + (int)BuffCallFunc_e::kSetBulletBornOffset == _int_buff_param1) { + std::string data = buff_param2(); + std::vector strings; + a8::Split(data, strings, '|'); + for (auto& str : strings) { + std::vector strings2; + a8::Split(str, strings2, ':'); + if (strings2.size() < 2) { + abort(); + } + _bullet_born_offset.push_back + (std::make_tuple( + a8::XValue(strings2[0]).GetDouble(), + a8::XValue(strings2[1]).GetDouble(), + strings2.size() > 2 ? a8::XValue(strings2[2]).GetDouble() : 0, + strings2.size() > 3 ? a8::XValue(strings2[3]).GetInt() : 0, + strings2.size() > 4 ? a8::XValue(strings2[4]).GetInt() : 0, + strings2.size() > 5 ? a8::XValue(strings2[5]).GetInt() : 0 + ) + ); + } + } + } } void Buff::Init2() diff --git a/server/gameserver/shot.cc b/server/gameserver/shot.cc index 040bbe6e..16f09b72 100644 --- a/server/gameserver/shot.cc +++ b/server/gameserver/shot.cc @@ -362,7 +362,11 @@ void InternalShot(Creature* c, ProcMissile(c, weapon_meta, bullet_meta, skill_meta, fly_distance, weapon_uniid, trace_target_uniid); return; } - for (auto& tuple : weapon_meta->_bullet_born_offset) { + auto bullet_born_offset_ptr = &weapon_meta->_bullet_born_offset; + if (c->GetCurrWeapon()->meta == weapon_meta) { + bullet_born_offset_ptr = c->GetCurrWeapon()->bullet_born_offset_ptr; + } + for (auto& tuple : *bullet_born_offset_ptr) { glm::vec3 bullet_born_offset = glm::vec3(std::get<0>(tuple), 0.0f, std::get<1>(tuple)); float bullet_born_angle = GlmHelper::CalcAngle(c->GetAttackDir(), GlmHelper::UP); if (c->GetAttackDir().x > 0.00001f) { @@ -417,8 +421,8 @@ void InternalShot(Creature* c, } } int bulletIdx = 0; - int bulletNum = weapon_meta->_bullet_born_offset.size(); - for (auto& tuple : weapon_meta->_bullet_born_offset) { + int bulletNum = bullet_born_offset_ptr->size(); + for (auto& tuple : *bullet_born_offset_ptr) { ++bulletIdx; glm::vec3 bullet_born_offset = glm::vec3(std::get<0>(tuple), 0.0f, std::get<1>(tuple)); glm::vec3 bullet_born_pos = c->GetPos().ToGlmVec3() + c->shoot_offset + bullet_born_offset;