1
This commit is contained in:
parent
4553fdfb2d
commit
10e302e81d
@ -265,6 +265,8 @@ class WeaponAbility
|
||||
{
|
||||
public:
|
||||
long long weapon_uniid = 0;
|
||||
int weapon_lv = 1;
|
||||
int quality = 1;
|
||||
const mt::Equip* weapon_meta = nullptr;
|
||||
std::shared_ptr<a8::XObject> weapon_dto;
|
||||
|
||||
@ -440,6 +442,8 @@ void BattleDataContext::ParseResult(a8::XObject& obj)
|
||||
if (meta) {
|
||||
weapon1_ability_ = std::make_shared<WeaponAbility>();
|
||||
weapon1_ability_->weapon_uniid = weapon_dto1->Get("gun_uniid", 0);
|
||||
weapon1_ability_->weapon_lv = weapon_dto1->Get("gun_lv", 1);
|
||||
weapon1_ability_->quality = weapon_dto1->Get("quality", 1);
|
||||
weapon1_ability_->weapon_meta = meta;
|
||||
weapon1_ability_->weapon_dto = weapon_dto1;
|
||||
}
|
||||
@ -453,6 +457,8 @@ void BattleDataContext::ParseResult(a8::XObject& obj)
|
||||
if (meta) {
|
||||
weapon2_ability_ = std::make_shared<WeaponAbility>();
|
||||
weapon2_ability_->weapon_uniid = weapon_dto2->Get("gun_uniid", 0);
|
||||
weapon2_ability_->weapon_lv = weapon_dto1->Get("gun_lv", 1);
|
||||
weapon2_ability_->quality = weapon_dto1->Get("quality", 1);
|
||||
weapon2_ability_->weapon_meta = meta;
|
||||
weapon2_ability_->weapon_dto = weapon_dto2;
|
||||
}
|
||||
@ -478,14 +484,14 @@ void BattleDataContext::GetWeaponLvQuality(long long weapon_uniid, int& weapon_l
|
||||
{
|
||||
weapon_lv = 1;
|
||||
quality = 1;
|
||||
if (owner_.Get()->IsPlayer()) {
|
||||
if (weapon1_ability_ && weapon_uniid == weapon_dto1->Get("gun_uniid", 0).GetInt64()) {
|
||||
weapon_lv = weapon_dto1->Get("gun_lv", 0).GetInt();
|
||||
quality = weapon_dto1->Get("quality", 0).GetInt();
|
||||
if (owner_.Get()->IsPlayer() && weapon_uniid) {
|
||||
if (weapon1_ability_ && weapon_uniid == weapon1_ability_->weapon_uniid) {
|
||||
weapon_lv = weapon1_ability_->weapon_lv;
|
||||
quality = weapon1_ability_->quality;
|
||||
}
|
||||
if (weapon2_ability_ && weapon_uniid == weapon_dto2->Get("gun_uniid", 0).GetInt64()) {
|
||||
weapon_lv = weapon_dto2->Get("gun_lv", 0).GetInt();
|
||||
quality = weapon_dto2->Get("quality", 0).GetInt();
|
||||
if (weapon2_ability_ && weapon_uniid == weapon2_ability_->weapon_uniid) {
|
||||
weapon_lv = weapon2_ability_->weapon_lv;
|
||||
quality = weapon2_ability_->quality;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -278,4 +278,50 @@ namespace mt
|
||||
return itr != slot_hash_.end() ? itr->second : nullptr;
|
||||
}
|
||||
|
||||
void Equip::AddMuzzlePos(int lv, std::shared_ptr<std::tuple<float, float, float>> pos)
|
||||
{
|
||||
_gun_muzzle_position_hash_[lv] = pos;
|
||||
}
|
||||
|
||||
void Equip::AdjustMuzzlePos()
|
||||
{
|
||||
Equip::MutTraverse
|
||||
(
|
||||
[]
|
||||
(mt::Equip* meta, bool& stop) mutable
|
||||
{
|
||||
if (meta->_gun_muzzle_position_hash_.size() == 1) {
|
||||
if (meta->_gun_muzzle_position_hash_.find(0) !=
|
||||
meta->_gun_muzzle_position_hash_.end()) {
|
||||
for (int i = 0; i < MAX_WEAPON_LV; ++i) {
|
||||
meta->_gun_muzzle_positions.push_back(meta->_gun_muzzle_position_hash_[0]);
|
||||
}
|
||||
} else if (meta->_gun_muzzle_position_hash_.find(1) !=
|
||||
meta->_gun_muzzle_position_hash_.end()) {
|
||||
for (int i = 0; i < MAX_WEAPON_LV; ++i) {
|
||||
meta->_gun_muzzle_positions.push_back(meta->_gun_muzzle_position_hash_[1]);
|
||||
}
|
||||
} else {
|
||||
abort();
|
||||
}
|
||||
} else if (meta->_gun_muzzle_position_hash_.size() > 1) {
|
||||
if (meta->_gun_muzzle_position_hash_.find(1) !=
|
||||
meta->_gun_muzzle_position_hash_.end()) {
|
||||
abort();
|
||||
}
|
||||
for (int i = 0; i < MAX_WEAPON_LV; ++i) {
|
||||
auto itr = meta->_gun_muzzle_position_hash_.find(i + 1);
|
||||
if (itr != meta->_gun_muzzle_position_hash_.end()){
|
||||
meta->_gun_muzzle_positions.push_back(itr->second);
|
||||
} else {
|
||||
meta->_gun_muzzle_positions.push_back
|
||||
(
|
||||
meta->_gun_muzzle_positions.at(meta->_gun_muzzle_positions.size() - 1)
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -14,7 +14,7 @@ namespace mt
|
||||
//0,0,0,0,后座力,是否取消定身
|
||||
std::vector<std::tuple<float, float, float, int, int, int>> _bullet_born_offset;
|
||||
std::vector<std::tuple<int, glm::vec3>> _shoot_offsets;
|
||||
std::shared_ptr<std::tuple<float, float, float>> _gun_muzzle_position;
|
||||
std::vector<std::shared_ptr<std::tuple<float, float, float>>> _gun_muzzle_positions;
|
||||
std::shared_ptr<std::tuple<float, float, float>> _movex_position;
|
||||
std::array<int, IS_END> _volume = {};
|
||||
int _int_param1 = 0;
|
||||
@ -37,12 +37,15 @@ namespace mt
|
||||
|
||||
void Init1();
|
||||
void Init2();
|
||||
void AddMuzzlePos(int lv, std::shared_ptr<std::tuple<float, float, float>> pos);
|
||||
int GetWeaponIdx() const;
|
||||
bool Match(EventAddBuff_e event, int val, int val2) const;
|
||||
static const Equip* GetByIdBySlotId(int slot_id);
|
||||
static void AdjustMuzzlePos();
|
||||
|
||||
private:
|
||||
static std::map<int, const mt::Equip*> slot_hash_;
|
||||
std::map<int, std::shared_ptr<std::tuple<float, float, float>>> _gun_muzzle_position_hash_;
|
||||
};
|
||||
|
||||
}
|
||||
|
@ -130,6 +130,7 @@ namespace mt
|
||||
void Hero::StaticPostInit()
|
||||
{
|
||||
LoadHeroAndEquipShotData();
|
||||
Equip::AdjustMuzzlePos();
|
||||
}
|
||||
|
||||
const HeroShotAnimation* Hero::GetShotAnimi(int shotfire) const
|
||||
@ -280,31 +281,21 @@ anim.l_y = l_y;
|
||||
float movez = equip_lv_xobj->At("movez") ?
|
||||
equip_lv_xobj->At("movez")->AsXValue().GetDouble() : 0;
|
||||
|
||||
((mt::Equip*)equip_meta)->_gun_muzzle_position = std::make_shared<std::tuple<float, float, float>>
|
||||
auto pos = std::make_shared<std::tuple<float, float, float>>
|
||||
(
|
||||
x,
|
||||
y,
|
||||
z
|
||||
);
|
||||
((mt::Equip*)equip_meta)->AddMuzzlePos(equip_lv, pos);
|
||||
#if 0
|
||||
((mt::Equip*)equip_meta)->_movex_position = std::make_shared<std::tuple<float, float, float>>
|
||||
(
|
||||
movex,
|
||||
movey,
|
||||
movez
|
||||
);
|
||||
#if 0
|
||||
f8::UdpLog::Instance()->Info
|
||||
("weapon animation equip_id:%d x:%f y:%f z:%f movex:%f lmovey:%f movez:%f",
|
||||
{
|
||||
equip_id,
|
||||
x,
|
||||
y,
|
||||
z,
|
||||
movex,
|
||||
movey,
|
||||
movez
|
||||
});
|
||||
#endif
|
||||
#endif
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -12,6 +12,7 @@
|
||||
#include "buff.h"
|
||||
#include "debugcmd.h"
|
||||
#include "ability.h"
|
||||
#include "battledatacontext.h"
|
||||
|
||||
#include "mt/Param.h"
|
||||
#include "mt/Hero.h"
|
||||
@ -54,6 +55,7 @@ struct BulletInfo
|
||||
};
|
||||
|
||||
static void CalcGunMuzzlePosition(Creature* c,
|
||||
int weapon_lv,
|
||||
const mt::Equip* weapon_meta,
|
||||
const mt::HeroShotAnimation* shot_animi,
|
||||
glm::vec4& gun_muzzle_position,
|
||||
@ -122,12 +124,13 @@ static void CalcGunMuzzlePosition(Creature* c,
|
||||
}
|
||||
}
|
||||
}//end if
|
||||
if (weapon_meta->_gun_muzzle_position) {
|
||||
if (weapon_lv > 0 && weapon_lv < weapon_meta->_gun_muzzle_positions.size() + 1) {
|
||||
auto pos = weapon_meta->_gun_muzzle_positions.at(weapon_lv - 1);
|
||||
gun_muzzle_position +=
|
||||
glm::vec4(
|
||||
-std::get<0>(*weapon_meta->_gun_muzzle_position.get()),
|
||||
std::get<1>(*weapon_meta->_gun_muzzle_position.get()),
|
||||
std::get<2>(*weapon_meta->_gun_muzzle_position.get()),
|
||||
-std::get<0>(*pos.get()),
|
||||
std::get<1>(*pos.get()),
|
||||
std::get<2>(*pos.get()),
|
||||
0
|
||||
);
|
||||
}
|
||||
@ -182,6 +185,7 @@ static void InternalCreateBullet(BulletInfo& bullet_info)
|
||||
glm::vec3(0.0, 1.0, 0.0));
|
||||
glm::vec4 gun_muzzle_position(0.0, 0.0, 0.0, 0.0);
|
||||
CalcGunMuzzlePosition(c,
|
||||
bullet_info.weapon_lv,
|
||||
bullet_info.weapon_meta,
|
||||
bullet_info.shot_animi,
|
||||
gun_muzzle_position,
|
||||
@ -362,6 +366,13 @@ void InternalShot(Creature* c,
|
||||
ProcMissile(c, weapon_meta, bullet_meta, skill_meta, fly_distance, weapon_uniid, trace_target_uniid);
|
||||
return;
|
||||
}
|
||||
int weapon_lv = 1;
|
||||
if (weapon_uniid) {
|
||||
int p_weapon_lv = 1;
|
||||
int p_quality = 1;
|
||||
c->GetBattleContext()->GetWeaponLvQuality(weapon_uniid, p_weapon_lv, p_quality);
|
||||
weapon_lv = weapon_lv;
|
||||
}
|
||||
auto bullet_born_offset_ptr = &weapon_meta->_bullet_born_offset;
|
||||
if (c->GetCurrWeapon()->meta == weapon_meta &&
|
||||
c->GetCurrWeapon()->bullet_born_offset_ptr) {
|
||||
@ -462,7 +473,7 @@ void InternalShot(Creature* c,
|
||||
bullet_born_angle * A8_PI,
|
||||
glm::vec3(0.0, 1.0, 0.0));
|
||||
glm::vec4 gun_muzzle_position(0.0, 0.0, 0.0, 0.0);
|
||||
CalcGunMuzzlePosition(c, weapon_meta, shot_animi, gun_muzzle_position, bulletIdx, bulletNum);
|
||||
CalcGunMuzzlePosition(c, weapon_lv, weapon_meta, shot_animi, gun_muzzle_position, bulletIdx, bulletNum);
|
||||
glm::vec4 v = transform * gun_muzzle_position;
|
||||
bullet_born_offset = glm::vec3(v.z *10*1, v.y, v.x*10*-1);
|
||||
bullet_born_pos = c->GetPos().ToGlmVec3() + bullet_born_offset;
|
||||
@ -512,6 +523,7 @@ void InternalShot(Creature* c,
|
||||
bullet_info.shot_animi = shot_animi;
|
||||
bullet_info.bullet_idx = bulletIdx;
|
||||
bullet_info.bullet_num = bulletNum;
|
||||
bullet_info.weapon_lv = weapon_lv;
|
||||
if (skill_meta &&
|
||||
(skill_meta->GetMagicId() == MAGIC_20101_HL ||
|
||||
skill_meta->GetMagicId() == MAGIC_20201_HX)
|
||||
|
Loading…
x
Reference in New Issue
Block a user