This commit is contained in:
aozhiwei 2021-08-20 16:14:57 +00:00
parent 1436e0ae7e
commit 2ffe856c05
5 changed files with 24 additions and 34 deletions

View File

@ -3495,21 +3495,11 @@ void Human::GMAddItem(int item_id, int item_num)
weapons[0].Recalc(); weapons[0].Recalc();
} }
} else { } else {
Weapon* weapon = nullptr; Weapon* weapon = weapon = TakeonWeapon(item_meta);
if (weapons[GUN_SLOT1].weapon_id == 0) {
weapon = &weapons[GUN_SLOT1];
weapon->weapon_idx = GUN_SLOT1;
if (GetCurrWeapon() != &weapons[GUN_SLOT2] && !FreezeOperate()) {
SetCurrWeapon(&weapons[GUN_SLOT1]);
}
} else if (weapons[GUN_SLOT2].weapon_id == 0) {
weapon = &weapons[GUN_SLOT2];
weapon->weapon_idx = GUN_SLOT2;
if (GetCurrWeapon() != &weapons[GUN_SLOT1] && !FreezeOperate()) {
SetCurrWeapon(&weapons[GUN_SLOT2]);
}
}
if (weapon) { if (weapon) {
if (GetCurrWeapon() != weapon) {
SetCurWeapon(weapon);
}
weapon->weapon_id = item_id; weapon->weapon_id = item_id;
weapon->weapon_lv = std::max(1, 1); weapon->weapon_lv = std::max(1, 1);
weapon->ammo = 0; weapon->ammo = 0;
@ -3865,7 +3855,7 @@ void Human::ProcUseItem(int item_id)
} }
} }
Weapon* Human::TakeWeapon(MetaData::Equip* equip_meta) Weapon* Human::TakeonWeapon(MetaData::Equip* equip_meta)
{ {
Weapon* weapon = nullptr; Weapon* weapon = nullptr;
if (equip_meta->i->equip_type() == EQUIP_TYPE_WEAPON) { if (equip_meta->i->equip_type() == EQUIP_TYPE_WEAPON) {
@ -3875,8 +3865,8 @@ Weapon* Human::TakeWeapon(MetaData::Equip* equip_meta)
if (weapons[i].weapon_id == 0) { if (weapons[i].weapon_id == 0) {
weapon = &weapons[i]; weapon = &weapons[i];
weapon->weapon_idx = i; weapon->weapon_idx = i;
} else if (weapons[i].meta->i->equip_subtype() == } else if (weapons[i].meta->i->equip_subtype() == equip_meta->i->equip_subtype() &&
equip_meta->i->equip_subtype()){ weapons[i].meta->group_id == equip_meta->group_id){
if (equip_meta->i->quality() > weapons[i].meta->i->quality()) { if (equip_meta->i->quality() > weapons[i].meta->i->quality()) {
weapon = &weapons[i]; weapon = &weapons[i];
weapon->weapon_idx = i; weapon->weapon_idx = i;

View File

@ -242,6 +242,7 @@ protected:
void ProcCamoutflage(Loot* entity, MetaData::Equip* item_meta); void ProcCamoutflage(Loot* entity, MetaData::Equip* item_meta);
void ProcSpoils(Loot* entity, MetaData::Equip* item_meta); void ProcSpoils(Loot* entity, MetaData::Equip* item_meta);
void CancelRevive(); void CancelRevive();
Weapon* TakeonWeapon(MetaData::Equip* equip_meta);
private: private:
void ClearFrameData(); void ClearFrameData();
@ -275,7 +276,6 @@ private:
virtual void OnBuffRemove(Buff& buff) override; virtual void OnBuffRemove(Buff& buff) override;
virtual void DoSkillPreProc(int skill_id, int target_id, const a8::Vec2& target_pos) override; virtual void DoSkillPreProc(int skill_id, int target_id, const a8::Vec2& target_pos) override;
virtual void DoSkillPostProc(bool used, int skill_id, int target_id, const a8::Vec2& target_pos) override; virtual void DoSkillPostProc(bool used, int skill_id, int target_id, const a8::Vec2& target_pos) override;
Weapon* TakeWeapon(MetaData::Equip* equip_meta);
protected: protected:
int level_ = 0; int level_ = 0;

View File

@ -88,6 +88,7 @@ namespace MetaData
int car_active_buff_id = 0; int car_active_buff_id = 0;
int car_deactive_buff_id = 0; int car_deactive_buff_id = 0;
long long special_damage_type = 0; long long special_damage_type = 0;
int group_id = 0;
void Init(); void Init();
void Init2(); void Init2();

View File

@ -103,6 +103,9 @@ public:
std::map<int, MetaData::AI*> ai_hash; std::map<int, MetaData::AI*> ai_hash;
std::map<std::string, std::string> text_hash; std::map<std::string, std::string> text_hash;
int curr_group_id = 1001;
std::map<long long, int> weapon_group_hash;
void Load() void Load()
{ {
if (!f8::IsOnlineEnv()) { if (!f8::IsOnlineEnv()) {
@ -575,6 +578,15 @@ private:
if (meta._inventory_slot() > -1) { if (meta._inventory_slot() > -1) {
equip_slot_hash[meta._inventory_slot()] = &item; equip_slot_hash[meta._inventory_slot()] = &item;
} }
if (meta.equip_type() == EQUIP_TYPE_WEAPON) {
auto itr = weapon_group_hash.find(meta.id());
if (itr != weapon_group_hash.end()) {
item.group_id = itr->second;
} else {
item.group_id = ++curr_group_id;
weapon_group_hash[meta.id()] = item.group_id;
}
}
} }
for (auto& meta : player_meta_list) { for (auto& meta : player_meta_list) {

View File

@ -549,24 +549,11 @@ void Player::LootInteraction(Loot* entity)
if (FreezeOperate()) { if (FreezeOperate()) {
return; return;
} }
Weapon* weapon = nullptr;
bool switch_gun = false; bool switch_gun = false;
#if 0 Weapon* weapon = TakeonWeapon(item_meta);
#else if (weapon && GetCurrWeapon() != weapon) {
if (weapons[GUN_SLOT1].weapon_id == 0) { switch_gun = true;
weapon = &weapons[GUN_SLOT1];
weapon->weapon_idx = GUN_SLOT1;
if (GetCurrWeapon() != &weapons[GUN_SLOT2] && !FreezeOperate()) {
switch_gun = true;
}
} else if (weapons[GUN_SLOT2].weapon_id == 0) {
weapon = &weapons[GUN_SLOT2];
weapon->weapon_idx = GUN_SLOT2;
if (GetCurrWeapon() != &weapons[GUN_SLOT1] && !FreezeOperate()) {
switch_gun = true;
}
} }
#endif
if (!weapon) { if (!weapon) {
/* /*
cs::SMPickup notifymsg; cs::SMPickup notifymsg;