This commit is contained in:
aozhiwei 2024-01-17 14:41:46 +08:00
parent 5a33ca8030
commit e9f425eb89
14 changed files with 18 additions and 262 deletions

View File

@ -1,89 +0,0 @@
#include "precompile.h"
#include "compose.h"
#include "creature.h"
#include "netdata.h"
#include "trigger.h"
#include "room.h"
#include "effect.h"
#include "weapon.h"
#include "human.h"
#include "mt/MergeItem.h"
#include "mt/Hero.h"
#include "mt/Equip.h"
Compose::Compose(Creature* owner)
{
owner_ = owner;
}
Compose::~Compose()
{
}
void Compose::Init()
{
if (owner_->IsPlayer()) {
TakeOnWeapon(owner_->GetCurrWeapon());
owner_->GetTrigger()->AddListener
(
kTakeonWeaponEvent,
[this] (const a8::Args& args) mutable
{
Weapon* old_weapon = args.Get<Weapon*>(0);
Weapon* new_weapon = args.Get<Weapon*>(1);
TakeOnWeapon(new_weapon);
}
);
}
}
void Compose::Clear()
{
for (int buff_uniid : hold_buffs_) {
owner_->RemoveBuffByUniId(buff_uniid);
}
hold_buffs_.clear();
}
bool Compose::CanAdd()
{
return GetNum() < 8;
}
void Compose::IncNum()
{
++num_;
if ((num_ + 1) % 3 == 0 && num_ < 9) {
TakeOnWeapon(owner_->GetCurrWeapon());
}
if (num_ >= 8) {
owner_->room->NotifyNewsTicker
(1,
{
owner_->GetName(),
a8::XValue(owner_->GetCurrWeapon()->meta->id()).GetString()
});
}
}
void Compose::TakeOnWeapon(Weapon* weapon)
{
Clear();
auto merge_item_meta = mt::MergeItem::GetById(weapon->meta->id());
if (merge_item_meta) {
std::set<int>* buffs = merge_item_meta->GetBuffs((num_ + 1) / 3);
if (buffs) {
for (int buff_id : *buffs) {
hold_buffs_.push_back(owner_->TryAddBuff(owner_, buff_id, nullptr));
}
}
}
}
void Compose::Reset()
{
Clear();
num_ = 0;
}

View File

@ -1,28 +0,0 @@
#pragma once
#include "trigger.h"
class Creature;
class Weapon;
class Compose
{
public:
Compose(Creature* owner);
~Compose();
void Init();
void IncNum();
bool CanAdd();
int GetNum() { return num_; }
void Reset();
private:
void Clear();
void TakeOnWeapon(Weapon* weapon);
private:
Creature* owner_ = nullptr;
int num_ = 0;
std::vector<int> hold_buffs_;
};

View File

@ -30,7 +30,6 @@
#include "stats.h"
#include "team.h"
#include "bornpoint.h"
#include "compose.h"
#include "player.h"
#include "app.h"
#include "tracemgr.h"
@ -41,7 +40,6 @@
#include "mt/Buff.h"
#include "mt/Skill.h"
#include "mt/SkillNumber.h"
#include "mt/GunTalentGrow.h"
#include "mt/SafeArea.h"
#include "mt/MapThing.h"
#include "mt/Text.h"
@ -76,7 +74,6 @@ Creature::Creature():MoveableEntity()
inventory_[IS_1XSCOPE].num = 1;
movement_ = std::make_shared<Movement>(this);
compose_ = std::make_shared<Compose>(this);
}
Creature::~Creature()

View File

@ -66,7 +66,6 @@ class Trigger;
class DelayAddBuffHandle;
class Movement;
class Player;
class Compose;
class Android;
class Creature : public MoveableEntity
{
@ -384,7 +383,6 @@ class Creature : public MoveableEntity
bool CanShot(bool try_reload);
void AdjustPos();
void OnLand();
std::shared_ptr<Compose> GetCompose() { return compose_; }
void ClearGemStoneBuffs();
virtual Car* GetCar() { return nullptr; }
void AddIgnoreTarget(int target_uniid, int time);
@ -501,8 +499,6 @@ private:
std::map<int, long long> buff_interval_hash_;
std::array<Inventory, IS_END> inventory_ = {};
std::shared_ptr<Compose> compose_;
std::map<int, a8::XTimerWp> ignore_target_hash_;
std::map<int, std::map<int, float>> skill_local_vars_;

View File

@ -42,7 +42,6 @@
#include "ability.h"
#include "stats.h"
#include "hero.h"
#include "compose.h"
#include "bornpoint.h"
#include "buff/sprint.h"
@ -53,7 +52,6 @@
#include "mt/Buff.h"
#include "mt/Skill.h"
#include "mt/SkillNumber.h"
#include "mt/GunTalentGrow.h"
#include "mt/SafeArea.h"
#include "mt/MapThing.h"
#include "mt/Text.h"
@ -1416,7 +1414,6 @@ void Human::DeadDrop()
DecInventory(IS_WEAPON_STONE, GetInventory(IS_WEAPON_STONE));
SyncVolume(IS_WEAPON_STONE);
}
GetCompose()->Reset();
}
{
room->frame_event.AddPropChg
@ -2859,10 +2856,6 @@ void Human::ProcLootWeaponNew(AddItemDTO& dto)
GetCurrWeapon()->weapon_idx == GUN_SLOT1 ||
GetCurrWeapon()->weapon_idx == GUN_SLOT2) {
if (GetCurrWeapon()->weapon_id == dto.item_meta->id()) {
if (!GetCompose()->CanAdd()) {
return;
}
GetCompose()->IncNum();
MarkSyncActivePlayer(__FILE__, __LINE__, __func__);
SyncAroundPlayers(__FILE__, __LINE__, __func__);
dto.handled = true;
@ -2874,7 +2867,6 @@ void Human::ProcLootWeaponNew(AddItemDTO& dto)
} else {
DropWeapon(GetCurrWeapon()->weapon_idx, 1);
}
GetCompose()->Reset();
Weapon* weapon = &weapons[old_weapon_idx];
weapon->weapon_id = dto.item_id;
weapon->meta = dto.item_meta;
@ -3071,7 +3063,12 @@ void Human::DropWeapon(int weapon_idx, int num)
return;
}
bool is_curr_weapon = weapon_idx == GetCurrWeapon()->weapon_idx;
#if 1
//888
int stack_num = 0;
#else
int stack_num = is_curr_weapon ? GetCompose()->GetNum() + 1: 0;
#endif
bool drop_ok = false;
Weapon* weapon = &weapons[weapon_idx];
int weapon_id = weapon->weapon_id;
@ -3739,10 +3736,6 @@ void Human::ProcPurpleStoneItem(AddItemDTO& dto)
void Human::ProcWeaponStoneItem(AddItemDTO& dto)
{
if (!GetCompose()->CanAdd()) {
return;
}
GetCompose()->IncNum();
MarkSyncActivePlayer(__FILE__, __LINE__, __func__);
SyncAroundPlayers(__FILE__, __LINE__, __func__);

View File

@ -1,37 +0,0 @@
#include "precompile.h"
#include "mt/GunTalentGrow.h"
IMPL_TABLE(mt::GunTalentGrow)
std::map<long long, const mt::GunTalentGrow*> mt::GunTalentGrow::id_lv_hash_;
namespace mt
{
void GunTalentGrow::Init1()
{
std::vector<std::string> tmp_strs1;
a8::Split(addattr(), tmp_strs1, '|');
for (std::string& str : tmp_strs1) {
std::vector<std::string> tmp_strs2;
a8::Split(str, tmp_strs2, ':');
if (tmp_strs2.size() >= 2) {
_addattr.push_back(
std::make_tuple(a8::XValue(tmp_strs2[0]), a8::XValue(tmp_strs2[1]))
);
}
}
{
long long key = a8::MakeInt64(talent_id(), talent_lv());
id_lv_hash_[key] = this;
}
}
const GunTalentGrow* GunTalentGrow::GetByIdQyality(int id, int quality)
{
long long key = a8::MakeInt64(id, quality);
auto itr = id_lv_hash_.find(key);
return itr != id_lv_hash_.end() ? itr->second : nullptr;
};
}

View File

@ -1,23 +0,0 @@
#pragma once
#include "mt/macro.h"
#include "mtb/GunTalentGrow.h"
namespace mt
{
DECLARE_ID_TABLE(GunTalentGrow, mtb::GunTalentGrow,
"gunTalentGrow@gunTalentGrow.json",
"id")
public:
std::vector<std::tuple<int, int>> _addattr;
void Init1();
static const GunTalentGrow* GetByIdQyality(int id, int quality);
private:
static std::map<long long, const mt::GunTalentGrow*> id_lv_hash_;
};
}

View File

@ -7,7 +7,6 @@
#include "mt/Attr.h"
#include "mt/FormulaPvp.h"
#include "mt/GunQuality.h"
#include "mt/GunTalentGrow.h"
#include "mt/HeroQuality.h"
#include "mt/PveGemini.h"
#include "mt/PveGeminiContent.h"
@ -81,7 +80,6 @@ namespace mt
RegMetaTable<Attr>(res_path_);
RegMetaTable<FormulaPvp>(res_path_);
RegMetaTable<GunQuality>(res_path_);
RegMetaTable<GunTalentGrow>(res_path_);
RegMetaTable<HeroQuality>(res_path_);
RegMetaTable<PveGemini>(res_path_);
RegMetaTable<PveGeminiContent>(res_path_);

View File

@ -1,37 +0,0 @@
#pragma once
#include <bitset>
namespace mtb
{
class GunTalentGrow
{
public:
std::shared_ptr<a8::reflect::Class> GetClass() const;
int id() const { return id_; };
int talent_id() const { return talent_id_; };
int talent_lv() const { return talent_lv_; };
int addtype() const { return addtype_; };
const std::string addattr() const { return addattr_; };
bool has_id() const { return __flags__.test(0);};
bool has_talent_id() const { return __flags__.test(1);};
bool has_talent_lv() const { return __flags__.test(2);};
bool has_addtype() const { return __flags__.test(3);};
bool has_addattr() const { return __flags__.test(4);};
protected:
int id_ = 0;
int talent_id_ = 0;
int talent_lv_ = 0;
int addtype_ = 0;
std::string addattr_;
public:
std::bitset<5> __flags__;
};
};

View File

@ -27,7 +27,6 @@
#include "mtb/KillPoint.h"
#include "mtb/AI.h"
#include "mtb/Text.h"
#include "mtb/GunTalentGrow.h"
#include "mtb/HeroQuality.h"
#include "mtb/GunQuality.h"
#include "mtb/FormulaPvp.h"
@ -683,20 +682,6 @@ namespace mtb
return meta_class;
}
std::shared_ptr<a8::reflect::Class> GunTalentGrow::GetClass() const
{
std::shared_ptr<a8::reflect::Class> meta_class = nullptr;
if (!meta_class) {
meta_class = std::make_shared<a8::reflect::Class>("GunTalentGrow", 5, 0);
meta_class->SetSimpleField(0, "id", a8::reflect::ET_INT32, my_offsetof2(GunTalentGrow, id_));
meta_class->SetSimpleField(1, "talent_id", a8::reflect::ET_INT32, my_offsetof2(GunTalentGrow, talent_id_));
meta_class->SetSimpleField(2, "talent_lv", a8::reflect::ET_INT32, my_offsetof2(GunTalentGrow, talent_lv_));
meta_class->SetSimpleField(3, "addtype", a8::reflect::ET_INT32, my_offsetof2(GunTalentGrow, addtype_));
meta_class->SetSimpleField(4, "addattr", a8::reflect::ET_STRING, my_offsetof2(GunTalentGrow, addattr_));
}
return meta_class;
}
std::shared_ptr<a8::reflect::Class> HeroQuality::GetClass() const
{
std::shared_ptr<a8::reflect::Class> meta_class = nullptr;

View File

@ -33,7 +33,6 @@
#include "buff.h"
#include "stats.h"
#include "mapinstance.h"
#include "compose.h"
#include "debugcmd.h"
#include "mt/Param.h"
@ -736,7 +735,11 @@ void Player::ProcInteraction()
int curr_num = 0;
if (loot->meta->equip_type() == EQUIP_TYPE_WEAPON) {
if (GetCurrWeapon()->weapon_id == loot->meta->id()) {
#if 1
//888
#else
curr_num = GetCompose()->GetNum() + 1;
#endif
}
} else if (loot->meta->equip_type() == EQUIP_TYPE_GEMSTONE) {
switch (loot->meta->equip_subtype()) {
@ -774,7 +777,11 @@ void Player::ProcInteraction()
int curr_num = 0;
if (loot->meta->equip_type() == EQUIP_TYPE_WEAPON) {
if (GetCurrWeapon()->weapon_id == loot->meta->id()) {
#if 1
//888
#else
curr_num = GetCompose()->GetNum() + 1;
#endif
}
} else if (loot->meta->equip_type() == EQUIP_TYPE_GEMSTONE) {
switch (loot->meta->equip_subtype()) {

View File

@ -54,7 +54,6 @@
#include "mt/Buff.h"
#include "mt/Skill.h"
#include "mt/SkillNumber.h"
#include "mt/GunTalentGrow.h"
#include "mt/SafeArea.h"
#include "mt/MapThing.h"
#include "mt/Text.h"

View File

@ -5,7 +5,6 @@
#include "netdata.h"
#include "pbutils.h"
#include "human.h"
#include "compose.h"
#include "mt/Equip.h"
@ -60,7 +59,12 @@ int Weapon::GetWeaponBattleLv(Creature* c)
{
if (c) {
if (c->GetCurrWeapon() == this) {
#if 1
//888
return 1;
#else
return c->GetCompose()->GetNum() + 1;
#endif
}
}
return 1;

View File

@ -523,15 +523,6 @@ message Text
optional string text = 2;
}
message GunTalentGrow
{
optional int32 id = 1;
optional int32 talent_id = 2;
optional int32 talent_lv = 3;
optional int32 addtype = 4;
optional string addattr = 5;
}
message HeroQuality
{
optional int32 id = 1;