完成武器升级逻辑
This commit is contained in:
parent
ff825e13db
commit
6b64b8ede3
@ -65,7 +65,11 @@ void Bullet::Update(int delta_time)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}//end for
|
}//end for
|
||||||
if (!objects.empty() || distance > gun_meta->i->range() ||
|
float bullet_range = gun_meta->i->range();
|
||||||
|
if (gun_upgrade_meta && gun_upgrade_meta->attr[EA_ShotRange] > 0) {
|
||||||
|
bullet_range += gun_upgrade_meta->attr[EA_ShotRange];
|
||||||
|
}
|
||||||
|
if (!objects.empty() || distance > bullet_range ||
|
||||||
(IsBomb() && meta->i->_inventory_slot() != 4 && distance >= fly_distance)
|
(IsBomb() && meta->i->_inventory_slot() != 4 && distance >= fly_distance)
|
||||||
) {
|
) {
|
||||||
if (IsBomb()) {
|
if (IsBomb()) {
|
||||||
|
@ -6,6 +6,7 @@ namespace MetaData
|
|||||||
{
|
{
|
||||||
struct Player;
|
struct Player;
|
||||||
struct Equip;
|
struct Equip;
|
||||||
|
struct EquipUpgrade;
|
||||||
}
|
}
|
||||||
|
|
||||||
class Human;
|
class Human;
|
||||||
@ -14,6 +15,7 @@ class Bullet : public Entity
|
|||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
MetaData::Equip* gun_meta = nullptr;
|
MetaData::Equip* gun_meta = nullptr;
|
||||||
|
MetaData::EquipUpgrade* gun_upgrade_meta = nullptr;
|
||||||
MetaData::Equip* meta = nullptr;
|
MetaData::Equip* meta = nullptr;
|
||||||
Human* player = nullptr;
|
Human* player = nullptr;
|
||||||
Vector2D dir;
|
Vector2D dir;
|
||||||
|
@ -122,13 +122,13 @@ enum VirtualPlayer_e
|
|||||||
VP_Mine = 9000003,
|
VP_Mine = 9000003,
|
||||||
};
|
};
|
||||||
|
|
||||||
enum EquipAttr
|
enum EquipAttr_e
|
||||||
{
|
{
|
||||||
EA_HP = 1,
|
EA_View = 1, //客户端用
|
||||||
EA_Dmg = 2,
|
EA_ShotRange = 2,
|
||||||
EA_ShotRange = 3,
|
EA_Volume = 3,
|
||||||
EA_ShotSpeed = 4,
|
EA_AutoAngle = 4, //客户端用
|
||||||
EA_Def = 5,
|
EA_BulletAngle = 5,
|
||||||
EA_End
|
EA_End
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -68,6 +68,7 @@ void FrameEvent::AddBullet(Human* hum, Vector2D born_pos, Vector2D dir, float fl
|
|||||||
dir.ToPB(p.mutable_dir());
|
dir.ToPB(p.mutable_dir());
|
||||||
p.set_bulletskin(10001);
|
p.set_bulletskin(10001);
|
||||||
p.set_gun_id(hum->curr_weapon->meta->i->id());
|
p.set_gun_id(hum->curr_weapon->meta->i->id());
|
||||||
|
p.set_gun_lv(hum->curr_weapon->weapon_lv);
|
||||||
p.set_fly_distance(fly_distance);
|
p.set_fly_distance(fly_distance);
|
||||||
}
|
}
|
||||||
{
|
{
|
||||||
|
@ -25,6 +25,7 @@ Human::Human():Entity()
|
|||||||
default_weapon.weapon_lv = 1;
|
default_weapon.weapon_lv = 1;
|
||||||
default_weapon.ammo = 1;
|
default_weapon.ammo = 1;
|
||||||
default_weapon.meta = MetaMgr::Instance()->GetEquip(default_weapon.weapon_id);
|
default_weapon.meta = MetaMgr::Instance()->GetEquip(default_weapon.weapon_id);
|
||||||
|
default_weapon.Recalc();
|
||||||
weapons.reserve(MAX_WEAPON_NUM);
|
weapons.reserve(MAX_WEAPON_NUM);
|
||||||
for (size_t i = 0; i < MAX_WEAPON_NUM; ++i) {
|
for (size_t i = 0; i < MAX_WEAPON_NUM; ++i) {
|
||||||
auto& weapon = a8::FastAppend(weapons);
|
auto& weapon = a8::FastAppend(weapons);
|
||||||
@ -195,12 +196,18 @@ void Human::Shot(Vector2D& target_dir)
|
|||||||
Vector2D bullet_born_pos = pos + bullet_born_offset;
|
Vector2D bullet_born_pos = pos + bullet_born_offset;
|
||||||
Vector2D bullet_dir = attack_dir;
|
Vector2D bullet_dir = attack_dir;
|
||||||
float bullet_angle = std::get<2>(tuple);
|
float bullet_angle = std::get<2>(tuple);
|
||||||
if (curr_weapon->meta->i->bullet_angle() >= 1.0f) {
|
if (curr_weapon->meta->i->bullet_angle() >= 0.10f) {
|
||||||
bullet_angle += (rand() % (int)curr_weapon->meta->i->bullet_angle()) * (rand() % 2 == 0 ? 1 : -1);
|
int angle = (int)curr_weapon->meta->i->bullet_angle() * 1000;
|
||||||
|
if (curr_weapon->upgrade_meta) {
|
||||||
|
angle -= curr_weapon->upgrade_meta->attr[EA_BulletAngle] * 1000;
|
||||||
|
}
|
||||||
|
if (angle > 0) {
|
||||||
|
bullet_angle += (rand() % angle) / 1000.0f * (rand() % 2 == 0 ? 1 : -1);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
bullet_dir.Rotate(bullet_angle / 180.0f);
|
bullet_dir.Rotate(bullet_angle / 180.0f);
|
||||||
room->frame_event.AddBullet(this, bullet_born_pos, attack_dir, fly_distance);
|
room->frame_event.AddBullet(this, bullet_born_pos, attack_dir, fly_distance);
|
||||||
room->CreateBullet(this, curr_weapon->meta, bullet_born_pos, attack_dir, fly_distance);
|
room->CreateBullet(this, curr_weapon, bullet_born_pos, attack_dir, fly_distance);
|
||||||
}
|
}
|
||||||
--curr_weapon->ammo;
|
--curr_weapon->ammo;
|
||||||
int slot_id = curr_weapon->meta->i->_inventory_slot();
|
int slot_id = curr_weapon->meta->i->_inventory_slot();
|
||||||
@ -397,7 +404,7 @@ void Human::AutoLoadingBullet(bool manual)
|
|||||||
{
|
{
|
||||||
if (curr_weapon->weapon_idx != 0 &&
|
if (curr_weapon->weapon_idx != 0 &&
|
||||||
(curr_weapon->ammo <= 0 ||
|
(curr_weapon->ammo <= 0 ||
|
||||||
(manual && curr_weapon->ammo < curr_weapon->meta->i->clip_volume()))
|
(manual && curr_weapon->ammo < curr_weapon->GetClipVolume()))
|
||||||
) {
|
) {
|
||||||
MetaData::Equip* bullet_meta = MetaMgr::Instance()->GetEquip(curr_weapon->meta->i->use_bullet());
|
MetaData::Equip* bullet_meta = MetaMgr::Instance()->GetEquip(curr_weapon->meta->i->use_bullet());
|
||||||
if (bullet_meta &&
|
if (bullet_meta &&
|
||||||
@ -727,6 +734,7 @@ void Human::Land()
|
|||||||
weapons[GUN_SLOT1].weapon_lv = 1;
|
weapons[GUN_SLOT1].weapon_lv = 1;
|
||||||
weapons[GUN_SLOT1].ammo = 0;
|
weapons[GUN_SLOT1].ammo = 0;
|
||||||
weapons[GUN_SLOT1].meta = weapon_meta;
|
weapons[GUN_SLOT1].meta = weapon_meta;
|
||||||
|
weapons[GUN_SLOT1].Recalc();
|
||||||
curr_weapon = &weapons[GUN_SLOT1];
|
curr_weapon = &weapons[GUN_SLOT1];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -1516,17 +1524,17 @@ void Human::UpdateAction()
|
|||||||
MetaData::Equip* bullet_meta = MetaMgr::Instance()->GetEquip(curr_weapon->meta->i->use_bullet());
|
MetaData::Equip* bullet_meta = MetaMgr::Instance()->GetEquip(curr_weapon->meta->i->use_bullet());
|
||||||
if (bullet_meta) {
|
if (bullet_meta) {
|
||||||
int ammo = curr_weapon->ammo;
|
int ammo = curr_weapon->ammo;
|
||||||
if (ammo < curr_weapon->meta->i->clip_volume()) {
|
if (ammo < curr_weapon->GetClipVolume()) {
|
||||||
if (bullet_meta->i->_inventory_slot() >= 0 &&
|
if (bullet_meta->i->_inventory_slot() >= 0 &&
|
||||||
bullet_meta->i->_inventory_slot() < IS_END) {
|
bullet_meta->i->_inventory_slot() < IS_END) {
|
||||||
if (GetInventory(bullet_meta->i->_inventory_slot()) > 0) {
|
if (GetInventory(bullet_meta->i->_inventory_slot()) > 0) {
|
||||||
int add_num = 0;
|
int add_num = 0;
|
||||||
if (GetInventory(bullet_meta->i->_inventory_slot()) <=
|
if (GetInventory(bullet_meta->i->_inventory_slot()) <=
|
||||||
curr_weapon->meta->i->clip_volume() - ammo) {
|
curr_weapon->GetClipVolume() - ammo) {
|
||||||
add_num = GetInventory(bullet_meta->i->_inventory_slot());
|
add_num = GetInventory(bullet_meta->i->_inventory_slot());
|
||||||
DecInventory(bullet_meta->i->_inventory_slot(), add_num);
|
DecInventory(bullet_meta->i->_inventory_slot(), add_num);
|
||||||
} else {
|
} else {
|
||||||
add_num = curr_weapon->meta->i->clip_volume() - ammo;
|
add_num = curr_weapon->GetClipVolume() - ammo;
|
||||||
DecInventory(bullet_meta->i->_inventory_slot(), add_num);
|
DecInventory(bullet_meta->i->_inventory_slot(), add_num);
|
||||||
}
|
}
|
||||||
curr_weapon->ammo += add_num;
|
curr_weapon->ammo += add_num;
|
||||||
@ -1649,6 +1657,12 @@ void Human::SendWxVoip()
|
|||||||
SendNotifyMsg(notifymsg);
|
SendNotifyMsg(notifymsg);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
int Human::GetWeaponConfigLv(int weapon_id)
|
||||||
|
{
|
||||||
|
auto itr = weapon_configs.find(weapon_id);
|
||||||
|
return itr != weapon_configs.end() ? itr->second : 0;
|
||||||
|
}
|
||||||
|
|
||||||
void Human::ClearFrameData()
|
void Human::ClearFrameData()
|
||||||
{
|
{
|
||||||
if (!new_objects.empty()) {
|
if (!new_objects.empty()) {
|
||||||
|
@ -101,6 +101,7 @@ class Human : public Entity
|
|||||||
long long send_msg_times = 0;
|
long long send_msg_times = 0;
|
||||||
|
|
||||||
float def = 0.0f;
|
float def = 0.0f;
|
||||||
|
std::map<int, int> weapon_configs;
|
||||||
|
|
||||||
Human();
|
Human();
|
||||||
virtual ~Human() override;
|
virtual ~Human() override;
|
||||||
@ -174,6 +175,7 @@ class Human : public Entity
|
|||||||
void UpdateAction();
|
void UpdateAction();
|
||||||
void SendUIUpdate();
|
void SendUIUpdate();
|
||||||
void SendWxVoip();
|
void SendWxVoip();
|
||||||
|
int GetWeaponConfigLv(int weapon_id);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
void ClearFrameData();
|
void ClearFrameData();
|
||||||
|
@ -79,6 +79,32 @@ namespace MetaData
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void EquipUpgrade::Init()
|
||||||
|
{
|
||||||
|
std::vector<int> attr_type;
|
||||||
|
std::vector<float> attr_value;
|
||||||
|
{
|
||||||
|
std::vector<std::string> strings;
|
||||||
|
a8::Split(i->attr_type(), strings, '|');
|
||||||
|
for (auto& str : strings) {
|
||||||
|
attr_type.push_back(a8::XValue(str).GetInt());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
{
|
||||||
|
std::vector<std::string> strings;
|
||||||
|
a8::Split(i->attr_value(), strings, '|');
|
||||||
|
for (auto& str : strings) {
|
||||||
|
attr_value.push_back(a8::XValue(str).GetDouble());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
assert(attr_type.size() == attr_value.size());
|
||||||
|
for (size_t i = 0; i < attr_type.size(); ++i) {
|
||||||
|
if (attr_type[i] < EA_End) {
|
||||||
|
attr[attr_type[i]] = attr_value[i];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
void Player::Init()
|
void Player::Init()
|
||||||
{
|
{
|
||||||
{
|
{
|
||||||
|
@ -52,6 +52,14 @@ namespace MetaData
|
|||||||
void Init();
|
void Init();
|
||||||
};
|
};
|
||||||
|
|
||||||
|
struct EquipUpgrade
|
||||||
|
{
|
||||||
|
const metatable::EquipUpgrade* i = nullptr;
|
||||||
|
|
||||||
|
std::array<float, EA_End> attr = {};
|
||||||
|
void Init();
|
||||||
|
};
|
||||||
|
|
||||||
struct Player
|
struct Player
|
||||||
{
|
{
|
||||||
const metatable::Player* i = nullptr;
|
const metatable::Player* i = nullptr;
|
||||||
|
@ -39,6 +39,8 @@ public:
|
|||||||
std::list<MetaData::Skill> skill_list;
|
std::list<MetaData::Skill> skill_list;
|
||||||
std::list<metatable::RankReward> rankreward_meta_list;
|
std::list<metatable::RankReward> rankreward_meta_list;
|
||||||
std::list<MetaData::RankReward> rankreward_list;
|
std::list<MetaData::RankReward> rankreward_list;
|
||||||
|
std::list<metatable::EquipUpgrade> equipupgrade_meta_list;
|
||||||
|
std::list<MetaData::EquipUpgrade> equipupgrade_list;
|
||||||
|
|
||||||
std::map<std::string, MetaData::Parameter*> parameter_hash;
|
std::map<std::string, MetaData::Parameter*> parameter_hash;
|
||||||
std::map<int, MetaData::Map*> gamemap_hash;
|
std::map<int, MetaData::Map*> gamemap_hash;
|
||||||
@ -55,6 +57,7 @@ public:
|
|||||||
std::map<int, MetaData::Dress*> dress_hash;
|
std::map<int, MetaData::Dress*> dress_hash;
|
||||||
std::map<int, MetaData::Skill*> skill_hash;
|
std::map<int, MetaData::Skill*> skill_hash;
|
||||||
std::map<int, MetaData::RankReward*> rankreward_hash;
|
std::map<int, MetaData::RankReward*> rankreward_hash;
|
||||||
|
std::map<long long, MetaData::EquipUpgrade*> equipupgrade_hash;
|
||||||
|
|
||||||
void Load()
|
void Load()
|
||||||
{
|
{
|
||||||
@ -88,6 +91,7 @@ public:
|
|||||||
f8::ReadCsvMetaFile(res_path + "dress@dress.csv", dress_meta_list);
|
f8::ReadCsvMetaFile(res_path + "dress@dress.csv", dress_meta_list);
|
||||||
f8::ReadCsvMetaFile(res_path + "skill@skill.csv", skill_meta_list);
|
f8::ReadCsvMetaFile(res_path + "skill@skill.csv", skill_meta_list);
|
||||||
f8::ReadCsvMetaFile(res_path + "rankReward@rankReward.csv", rankreward_meta_list);
|
f8::ReadCsvMetaFile(res_path + "rankReward@rankReward.csv", rankreward_meta_list);
|
||||||
|
f8::ReadCsvMetaFile(res_path + "equipUpgrade@equipUpgrade.csv", equipupgrade_meta_list);
|
||||||
BindToMetaData();
|
BindToMetaData();
|
||||||
#if 1
|
#if 1
|
||||||
{
|
{
|
||||||
@ -232,6 +236,12 @@ private:
|
|||||||
rankreward_hash[item.i->rank()] = &item;
|
rankreward_hash[item.i->rank()] = &item;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
for (auto& meta : equipupgrade_meta_list) {
|
||||||
|
MetaData::EquipUpgrade& item = a8::FastAppend(equipupgrade_list);
|
||||||
|
item.i = &meta;
|
||||||
|
equipupgrade_hash[a8::MakeInt64(meta.id(), meta.level())] = &item;
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private:
|
private:
|
||||||
@ -307,6 +317,12 @@ MetaData::Equip* MetaMgr::GetEquipBySlotId(int slot_id)
|
|||||||
return itr != loader_->equip_slot_hash.end() ? itr->second : nullptr;
|
return itr != loader_->equip_slot_hash.end() ? itr->second : nullptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
MetaData::EquipUpgrade* MetaMgr::GetEquipUpgrade(int equip_id, int equip_lv)
|
||||||
|
{
|
||||||
|
auto itr = loader_->equipupgrade_hash.find(a8::MakeInt64(equip_id, equip_lv));
|
||||||
|
return itr != loader_->equipupgrade_hash.end() ? itr->second : nullptr;
|
||||||
|
}
|
||||||
|
|
||||||
MetaData::Building* MetaMgr::GetBuilding(int building_id)
|
MetaData::Building* MetaMgr::GetBuilding(int building_id)
|
||||||
{
|
{
|
||||||
auto itr = loader_->building_hash.find(building_id);
|
auto itr = loader_->building_hash.find(building_id);
|
||||||
|
@ -24,6 +24,7 @@ class MetaMgr : public a8::Singleton<MetaMgr>
|
|||||||
MetaData::Player* GetPlayer(int id);
|
MetaData::Player* GetPlayer(int id);
|
||||||
MetaData::Equip* GetEquip(int id);
|
MetaData::Equip* GetEquip(int id);
|
||||||
MetaData::Equip* GetEquipBySlotId(int slot_id);
|
MetaData::Equip* GetEquipBySlotId(int slot_id);
|
||||||
|
MetaData::EquipUpgrade* GetEquipUpgrade(int equip_id, int equip_lv);
|
||||||
MetaData::Building* GetBuilding(int building_id);
|
MetaData::Building* GetBuilding(int building_id);
|
||||||
MetaData::Drop* GetDrop(int drop_id);
|
MetaData::Drop* GetDrop(int drop_id);
|
||||||
MetaData::SafeArea* GetSafeArea(int area_id);
|
MetaData::SafeArea* GetSafeArea(int area_id);
|
||||||
|
@ -343,13 +343,19 @@ void Player::Shot()
|
|||||||
Vector2D bullet_born_pos = pos + bullet_born_offset;
|
Vector2D bullet_born_pos = pos + bullet_born_offset;
|
||||||
Vector2D bullet_dir = attack_dir;
|
Vector2D bullet_dir = attack_dir;
|
||||||
float bullet_angle = std::get<2>(tuple);
|
float bullet_angle = std::get<2>(tuple);
|
||||||
if (curr_weapon->meta->i->bullet_angle() >= 1.0f) {
|
if (curr_weapon->meta->i->bullet_angle() >= 0.01f) {
|
||||||
bullet_angle += (rand() % (int)curr_weapon->meta->i->bullet_angle()) * (rand() % 2 == 0 ? 1 : -1);
|
int angle = (int)curr_weapon->meta->i->bullet_angle() * 1000;
|
||||||
|
if (curr_weapon->upgrade_meta) {
|
||||||
|
angle -= curr_weapon->upgrade_meta->attr[EA_BulletAngle] * 1000;
|
||||||
|
}
|
||||||
|
if (angle > 0) {
|
||||||
|
bullet_angle += (rand() % angle) / 1000.0f * (rand() % 2 == 0 ? 1 : -1);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
bullet_dir.Rotate(bullet_angle / 180.0f);
|
bullet_dir.Rotate(bullet_angle / 180.0f);
|
||||||
room->frame_event.AddBullet(this, bullet_born_pos, bullet_dir, fly_distance);
|
room->frame_event.AddBullet(this, bullet_born_pos, bullet_dir, fly_distance);
|
||||||
if (room->BattleStarted() || room->gas_data.gas_mode == GasJump && !a8::HasBitFlag(status, HS_Jump)) {
|
if (room->BattleStarted() || room->gas_data.gas_mode == GasJump && !a8::HasBitFlag(status, HS_Jump)) {
|
||||||
room->CreateBullet(this, curr_weapon->meta, bullet_born_pos, bullet_dir, fly_distance);
|
room->CreateBullet(this, curr_weapon, bullet_born_pos, bullet_dir, fly_distance);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
@ -498,8 +504,10 @@ void Player::LootInteraction(Loot* entity)
|
|||||||
} else {
|
} else {
|
||||||
weapons[0].weapon_idx = 0;
|
weapons[0].weapon_idx = 0;
|
||||||
weapons[0].weapon_id = entity->item_id;
|
weapons[0].weapon_id = entity->item_id;
|
||||||
weapons[0].weapon_lv = entity->item_level;
|
weapons[0].weapon_lv = std::max(1, GetWeaponConfigLv(weapons[0].weapon_id));
|
||||||
weapons[0].ammo = 0;
|
weapons[0].ammo = 0;
|
||||||
|
weapons[0].meta = item_meta;
|
||||||
|
weapons[0].Recalc();
|
||||||
}
|
}
|
||||||
need_sync_active_player = true;
|
need_sync_active_player = true;
|
||||||
SyncAroundPlayers();
|
SyncAroundPlayers();
|
||||||
@ -527,9 +535,10 @@ void Player::LootInteraction(Loot* entity)
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
weapon->weapon_id = entity->item_id;
|
weapon->weapon_id = entity->item_id;
|
||||||
weapon->weapon_lv = entity->item_level;
|
weapon->weapon_lv = std::max(1, GetWeaponConfigLv(weapon->weapon_id));
|
||||||
weapon->ammo = 0;
|
weapon->ammo = 0;
|
||||||
weapon->meta = item_meta;
|
weapon->meta = item_meta;
|
||||||
|
weapon->Recalc();
|
||||||
AutoLoadingBullet();
|
AutoLoadingBullet();
|
||||||
need_sync_active_player = true;
|
need_sync_active_player = true;
|
||||||
SyncAroundPlayers();
|
SyncAroundPlayers();
|
||||||
@ -578,6 +587,7 @@ void Player::LootInteraction(Loot* entity)
|
|||||||
weapon->weapon_lv = 1;
|
weapon->weapon_lv = 1;
|
||||||
weapon->ammo += entity->count;
|
weapon->ammo += entity->count;
|
||||||
weapon->meta = item_meta;
|
weapon->meta = item_meta;
|
||||||
|
weapon->Recalc();
|
||||||
DecInventory(item_meta->i->_inventory_slot(), add_num);
|
DecInventory(item_meta->i->_inventory_slot(), add_num);
|
||||||
}
|
}
|
||||||
if (item_meta->i->_inventory_slot() > 12) {
|
if (item_meta->i->_inventory_slot() > 12) {
|
||||||
|
@ -36,6 +36,11 @@ Player* PlayerMgr::CreatePlayerByCMJoin(int socket, const cs::CMJoin& msg)
|
|||||||
// hum->basemelee = msg.basemelee();
|
// hum->basemelee = msg.basemelee();
|
||||||
// hum->elo_score = msg.elo_score();
|
// hum->elo_score = msg.elo_score();
|
||||||
// hum->gmode = msg.gmode();
|
// hum->gmode = msg.gmode();
|
||||||
|
for (auto& weapon : msg.weapons()) {
|
||||||
|
if (weapon.weapon_id() != 0 && weapon.weapon_lv() > 0) {
|
||||||
|
hum->weapon_configs[weapon.weapon_id()] = weapon.weapon_lv();
|
||||||
|
}
|
||||||
|
}
|
||||||
socket_hash_[socket] = hum;
|
socket_hash_[socket] = hum;
|
||||||
return hum;
|
return hum;
|
||||||
}
|
}
|
||||||
|
@ -495,6 +495,22 @@ void Room::CreateLoot(int equip_id, Vector2D pos, int count, int equip_lv)
|
|||||||
entity->meta = equip_meta;
|
entity->meta = equip_meta;
|
||||||
entity->entity_uniid = AllocUniid();
|
entity->entity_uniid = AllocUniid();
|
||||||
entity->pos = pos;
|
entity->pos = pos;
|
||||||
|
#if 1
|
||||||
|
{
|
||||||
|
if (entity->pos.x > MAP_WIDTH) {
|
||||||
|
entity->pos.x = MAP_WIDTH;
|
||||||
|
}
|
||||||
|
if (entity->pos.x <= 0.001f) {
|
||||||
|
entity->pos.x = 0.0f;
|
||||||
|
}
|
||||||
|
if (entity->pos.y > MAP_HEIGHT) {
|
||||||
|
entity->pos.y = MAP_HEIGHT;
|
||||||
|
}
|
||||||
|
if (entity->pos.y < 0.0001f) {
|
||||||
|
entity->pos.y = 0.0f;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
#endif
|
||||||
entity->item_id = equip_id;
|
entity->item_id = equip_id;
|
||||||
entity->count = count;
|
entity->count = count;
|
||||||
entity->item_level = equip_lv;
|
entity->item_level = equip_lv;
|
||||||
@ -505,14 +521,15 @@ void Room::CreateLoot(int equip_id, Vector2D pos, int count, int equip_lv)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void Room::CreateBullet(Human* hum, MetaData::Equip* gun_meta,
|
void Room::CreateBullet(Human* hum, Weapon* weapon,
|
||||||
Vector2D pos, Vector2D dir, float fly_distance)
|
Vector2D pos, Vector2D dir, float fly_distance)
|
||||||
{
|
{
|
||||||
Bullet* bullet = new Bullet();
|
Bullet* bullet = new Bullet();
|
||||||
bullet->player = hum;
|
bullet->player = hum;
|
||||||
bullet->room = this;
|
bullet->room = this;
|
||||||
bullet->gun_meta = gun_meta;
|
bullet->gun_meta = weapon->meta;
|
||||||
bullet->meta = MetaMgr::Instance()->GetEquip(gun_meta->i->use_bullet());
|
bullet->gun_upgrade_meta = weapon->upgrade_meta;
|
||||||
|
bullet->meta = MetaMgr::Instance()->GetEquip(weapon->meta->i->use_bullet());
|
||||||
bullet->pos = pos;
|
bullet->pos = pos;
|
||||||
bullet->dir = dir;
|
bullet->dir = dir;
|
||||||
bullet->born_pos = pos;
|
bullet->born_pos = pos;
|
||||||
|
@ -78,7 +78,7 @@ public:
|
|||||||
|
|
||||||
Hero* CreateHero(Human* hum);
|
Hero* CreateHero(Human* hum);
|
||||||
void CreateLoot(int equip_id, Vector2D pos, int count, int equip_lv);
|
void CreateLoot(int equip_id, Vector2D pos, int count, int equip_lv);
|
||||||
void CreateBullet(Human* hum, MetaData::Equip* gun_meta,
|
void CreateBullet(Human* hum, Weapon* weapon,
|
||||||
Vector2D pos, Vector2D dir, float fly_distance);
|
Vector2D pos, Vector2D dir, float fly_distance);
|
||||||
|
|
||||||
void OnHumanDie(Human* hum);
|
void OnHumanDie(Human* hum);
|
||||||
|
@ -2,9 +2,27 @@
|
|||||||
|
|
||||||
#include "cs_proto.pb.h"
|
#include "cs_proto.pb.h"
|
||||||
|
|
||||||
|
#include "metamgr.h"
|
||||||
|
|
||||||
void Weapon::ToPB(cs::MFWeapon* pb_obj)
|
void Weapon::ToPB(cs::MFWeapon* pb_obj)
|
||||||
{
|
{
|
||||||
pb_obj->set_weapon_id(weapon_id);
|
pb_obj->set_weapon_id(weapon_id);
|
||||||
pb_obj->set_weapon_lv(weapon_lv);
|
pb_obj->set_weapon_lv(weapon_lv);
|
||||||
pb_obj->set_ammo(ammo);
|
pb_obj->set_ammo(ammo);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void Weapon::Recalc()
|
||||||
|
{
|
||||||
|
upgrade_meta = MetaMgr::Instance()->GetEquipUpgrade(weapon_id,
|
||||||
|
weapon_lv);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
int Weapon::GetClipVolume()
|
||||||
|
{
|
||||||
|
if (upgrade_meta) {
|
||||||
|
return meta->i->clip_volume() + upgrade_meta->attr[EA_Volume];
|
||||||
|
} else {
|
||||||
|
return meta->i->clip_volume();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
@ -13,6 +13,7 @@ namespace MetaData
|
|||||||
{
|
{
|
||||||
struct SafeArea;
|
struct SafeArea;
|
||||||
struct Equip;
|
struct Equip;
|
||||||
|
struct EquipUpgrade;
|
||||||
}
|
}
|
||||||
|
|
||||||
struct GasData
|
struct GasData
|
||||||
@ -38,8 +39,11 @@ struct Weapon
|
|||||||
int weapon_lv = 0;
|
int weapon_lv = 0;
|
||||||
int ammo = 0;
|
int ammo = 0;
|
||||||
MetaData::Equip* meta = nullptr;
|
MetaData::Equip* meta = nullptr;
|
||||||
|
MetaData::EquipUpgrade* upgrade_meta = nullptr;
|
||||||
|
|
||||||
void ToPB(cs::MFWeapon* pb_obj);
|
void ToPB(cs::MFWeapon* pb_obj);
|
||||||
|
void Recalc();
|
||||||
|
int GetClipVolume();
|
||||||
};
|
};
|
||||||
|
|
||||||
struct PlayerStats
|
struct PlayerStats
|
||||||
|
@ -462,12 +462,12 @@ message MFBullet
|
|||||||
optional int32 bullet_id = 2; //子弹id
|
optional int32 bullet_id = 2; //子弹id
|
||||||
optional MFVector2D pos = 3; //位置
|
optional MFVector2D pos = 3; //位置
|
||||||
optional MFVector2D dir = 4; //方向
|
optional MFVector2D dir = 4; //方向
|
||||||
optional float variance_t = 5;
|
optional int32 gun_lv = 5; //枪等级
|
||||||
optional int32 bulletskin = 6; //子弹皮肤
|
optional int32 bulletskin = 6; //子弹皮肤
|
||||||
optional bool crit = 7;
|
optional bool crit = 7;
|
||||||
optional int32 reflect_count = 8;
|
optional int32 reflect_count = 8;
|
||||||
optional int32 reflect_objid = 9;
|
optional int32 reflect_objid = 9;
|
||||||
optional int32 gun_id = 10; //抢id
|
optional int32 gun_id = 10; //枪id
|
||||||
optional float fly_distance = 11; //只有手雷和烟雾弹时这个字段才有意义
|
optional float fly_distance = 11; //只有手雷和烟雾弹时这个字段才有意义
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -81,6 +81,15 @@ message Equip
|
|||||||
optional int32 _inventory_slot = 32; //库存槽位
|
optional int32 _inventory_slot = 32; //库存槽位
|
||||||
}
|
}
|
||||||
|
|
||||||
|
message EquipUpgrade
|
||||||
|
{
|
||||||
|
optional int32 id = 1;
|
||||||
|
optional int32 level = 2;
|
||||||
|
optional int32 next_level = 3;
|
||||||
|
optional string attr_type = 4;
|
||||||
|
optional string attr_value = 5;
|
||||||
|
}
|
||||||
|
|
||||||
message Player
|
message Player
|
||||||
{
|
{
|
||||||
optional int32 id = 1; //唯一id
|
optional int32 id = 1; //唯一id
|
||||||
|
Loading…
x
Reference in New Issue
Block a user