This commit is contained in:
aozhiwei 2024-01-17 14:04:14 +08:00
parent 3048b8a193
commit 261433b00d
10 changed files with 0 additions and 521 deletions

View File

@ -26,7 +26,6 @@
#include "buff.h"
#include "mapinstance.h"
#include "collision.h"
#include "gungrasp.h"
#include "effect.h"
#include "stats.h"
#include "team.h"
@ -77,7 +76,6 @@ Creature::Creature():MoveableEntity()
inventory_[IS_1XSCOPE].num = 1;
movement_ = std::make_shared<Movement>(this);
gun_grasp_ = std::make_shared<GunGrasp>(this);
compose_ = std::make_shared<Compose>(this);
}
@ -2859,7 +2857,6 @@ void Creature::OnLand()
}
}
}
gun_grasp_->Init();
if (IsPlayer() && GetNetData()->GetHonor()) {
room->xtimer.SetTimeoutWpEx
(

View File

@ -1,64 +0,0 @@
#include "precompile.h"
#include "gungrasp.h"
#include "creature.h"
#include "netdata.h"
#include "trigger.h"
#include "room.h"
#include "effect.h"
#include "weapon.h"
#include "human.h"
#include "mt/GraspBuff.h"
#include "mt/Grasp.h"
#include "mt/Hero.h"
#include "mt/Equip.h"
GunGrasp::GunGrasp(Creature* owner)
{
owner_ = owner;
}
GunGrasp::~GunGrasp()
{
}
void GunGrasp::Init()
{
#if 0
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);
}
);
}
#endif
}
void GunGrasp::Clear()
{
for (int buff_uniid : hold_buffs_) {
owner_->RemoveBuffByUniId(buff_uniid);
}
hold_buffs_.clear();
}
void GunGrasp::TakeOnWeapon(Weapon* weapon)
{
std::set<int>* buffs = mt::Grasp::GetBuffs(owner_->AsHuman()->meta->id(),
owner_->GetNetData()->GetHeroLevel(),
weapon->meta->id());
Clear();
if (buffs) {
for (int buff_id : *buffs) {
hold_buffs_.push_back(owner_->TryAddBuff(owner_, buff_id, nullptr));
}
}
}

View File

@ -1,24 +0,0 @@
#pragma once
#include "trigger.h"
struct GraspBuff;
class Creature;
class Weapon;
class GunGrasp
{
public:
GunGrasp(Creature* owner);
~GunGrasp();
void Init();
private:
void Clear();
void TakeOnWeapon(Weapon* weapon);
private:
Creature* owner_ = nullptr;
std::vector<int> hold_buffs_;
};

View File

@ -1,167 +0,0 @@
#include "precompile.h"
#include "mt/Grasp.h"
#include "mt/Item.h"
IMPL_TABLE(mt::Grasp)
std::map<long long, std::tuple<int, std::set<int>>> mt::Grasp::hero_id_lv_gun_hash_;
namespace mt
{
void Grasp::Init1()
{
{
std::vector<std::string> strings;
a8::Split(add_buff_list(), strings, '|');
for (auto& str : strings) {
_add_buff_list.insert(a8::XValue(str));
}
}
{
std::vector<std::string> strings;
a8::Split(remove_buff_list(), strings, '|');
for (auto& str : strings) {
_remove_buff_list.insert(a8::XValue(str));
}
}
if (hero_id() == 0) {
abort();
}
if (hero_lv() == 0) {
abort();
}
if (weapon_id() == 0) {
abort();
}
const mt::Item* item_meta = mt::Item::GetById(weapon_id());
if (!item_meta){
abort();
}
weapon_id_ = item_meta->relationship();
}
void Grasp::Init2()
{
}
void Grasp::StaticPostInit()
{
int last_hero_id = 0;
int last_hero_lv = 0;
int last_weapon_id = 0;
std::set<int> last_buff_list;
Grasp::MutTraverse
(
[&last_hero_id, &last_hero_lv, &last_weapon_id, &last_buff_list]
(mt::Grasp* meta, bool& stop) mutable
{
#ifdef MYDEBUG
a8::XPrintf("last_hero_id:%d last_hero_lv:%d\n", {last_hero_id, last_hero_lv});
#endif
long long key = a8::MakeInt64(meta->hero_id(), meta->hero_lv());
if (!last_hero_id) {
last_hero_id = meta->hero_id();
last_hero_lv = meta->hero_lv();
last_weapon_id = meta->weapon_id();
if (meta->hero_lv() != 1) {
abort();
}
auto itr = hero_id_lv_gun_hash_.find(key);
if (itr != hero_id_lv_gun_hash_.end()) {
abort();
}
auto tuple = std::make_tuple(meta->weapon_id(), std::set<int>());
for (int buff_id : meta->_add_buff_list) {
std::get<1>(tuple).insert(buff_id);
last_buff_list.insert(buff_id);
}
for (int buff_id : meta->_remove_buff_list) {
std::get<1>(tuple).erase(buff_id);
last_buff_list.erase(buff_id);
}
hero_id_lv_gun_hash_[key] = tuple;
} else {
if (5 * (last_hero_lv / 5 + 1) != meta->hero_lv()) {
abort();
}
if (last_weapon_id != meta->weapon_id()) {
abort();
}
last_hero_id = meta->hero_id();
last_hero_lv = meta->hero_lv();
last_weapon_id = meta->weapon_id();
auto tuple = std::make_tuple(meta->weapon_id(), last_buff_list);
for (int buff_id : meta->_add_buff_list) {
std::get<1>(tuple).insert(buff_id);
last_buff_list.insert(buff_id);
}
for (int buff_id : meta->_remove_buff_list) {
std::get<1>(tuple).erase(buff_id);
last_buff_list.erase(buff_id);
}
hero_id_lv_gun_hash_[key] = tuple;
if (last_hero_lv == 15) {
last_hero_id = 0;
last_hero_lv = 0;
last_weapon_id = 0;
last_buff_list.clear();
}
}
});
}
std::set<int>* Grasp::GetBuffs(int hero_id, int hero_lv, int gun_id)
{
int internal_lv = 1;
switch (hero_lv) {
case 1:
case 2:
case 3:
case 4:
{
internal_lv = 1;
}
break;
case 5:
case 6:
case 7:
case 8:
case 9:
{
internal_lv = 5;
}
break;
case 10:
case 11:
case 12:
case 13:
case 14:
{
internal_lv = 10;
}
break;
default:
{
if (hero_lv < 1) {
internal_lv = 1;
} else {
internal_lv = 15;
}
}
break;
}
long long key = a8::MakeInt64(hero_id, internal_lv);
auto itr = hero_id_lv_gun_hash_.find(key);
if (itr != hero_id_lv_gun_hash_.end()) {
if (std::get<0>(itr->second) == gun_id) {
return &std::get<1>(itr->second);
}
}
return nullptr;
}
}

View File

@ -1,30 +0,0 @@
#pragma once
#include "mt/macro.h"
#include "mtb/Grasp.h"
#include "mt/GraspBuff.h"
namespace mt
{
DECLARE_ID_TABLE(Grasp, mtb::Grasp,
"grasp@grasp.json",
"grasp_id")
public:
void Init1();
void Init2();
static void StaticPostInit();
static std::set<int>* GetBuffs(int hero_id, int hero_lv, int gun_id);
protected:
static std::map<long long, std::tuple<int, std::set<int>>> hero_id_lv_gun_hash_;
std::set<int> _add_buff_list;
std::set<int> _remove_buff_list;
};
}

View File

@ -1,133 +0,0 @@
#include "precompile.h"
#include "mt/GraspBuff.h"
IMPL_TABLE(mt::GraspBuff)
namespace mt
{
void GraspBuff::Init1()
{
{
std::vector<std::string> strings;
a8::Split(graspbuff_trigger(), strings, '|');
if (strings.size() > 2) {
abort();
}
if (strings.empty()) {
abort();
}
std::vector<std::string> strings2;
a8::Split(strings[0], strings2, ',');
int type = a8::XValue(strings2[0]);
switch ((GraspBuffTrigger_e)type) {
case GraspBuffTrigger_e::kHit:
{
_trigger_type = type;
}
break;
case GraspBuffTrigger_e::kKill:
{
_trigger_type = type;
}
break;
case GraspBuffTrigger_e::kTakeOn:
{
_trigger_type = type;
}
break;
case GraspBuffTrigger_e::kCond:
{
_trigger_type = type;
_trigger_subtype = a8::XValue(strings2.at(1));
#if 0
if (_trigger_subtype != (int)GraspBuffTriggerCond_e::kImprint) {
abort();
}
#endif
_trigger_cond.push_back(a8::XValue(strings2.at(2)));
_trigger_cond.push_back(a8::XValue(strings.at(1)));
}
break;
case GraspBuffTrigger_e::kHitAndEnd:
{
_trigger_type = type;
}
break;
default:
{
abort();
}
break;
}
}
{
std::vector<std::string> strings;
a8::Split(graspbuff_time(), strings, '|');
for (auto& str : strings) {
_buff_times.push_back(a8::XValue(str).GetInt());
}
}
{
std::vector<std::string> strings;
a8::Split(attr_num(), strings, '|');
for (auto& str : strings) {
_attr_nums.push_back(a8::XValue(str).GetDouble());
}
}
{
std::vector<std::string> strings;
a8::Split(effect_list(), strings, '|');
for (auto& str : strings) {
_effect_list.push_back(a8::XValue(str).GetDouble());
}
}
}
void GraspBuff::Init2()
{
}
int GraspBuff::GetBuffTime(int hero_lv) const
{
switch (hero_lv) {
case 10:
case 11:
case 12:
case 13:
case 14:
case 15:
{
return _buff_times.size() > 1 ? _buff_times.at(1) :_buff_times.at(0);
}
default:
{
return _buff_times.at(0);
}
break;
}
}
float GraspBuff::GetAttrNum(int hero_lv) const
{
switch (hero_lv) {
case 10:
case 11:
case 12:
case 13:
case 14:
case 15:
{
return _attr_nums.size() > 1 ? _attr_nums.at(1) :_attr_nums.at(0);
}
default:
{
return _attr_nums.at(0);
}
break;
}
}
}

View File

@ -1,30 +0,0 @@
#pragma once
#include "mt/macro.h"
#include "mtb/GraspBuff.h"
namespace mt
{
DECLARE_ID_TABLE(GraspBuff, mtb::GraspBuff,
"graspBuff@graspBuff.json",
"graspbuff_id")
public:
void Init1();
void Init2();
int _trigger_type = 0;
int _trigger_subtype = 0;
std::vector<int> _trigger_cond;
std::vector<int> _effect_list;
int GetBuffTime(int hero_lv) const;
float GetAttrNum(int hero_lv) const;
private:
std::vector<int> _buff_times;
std::vector<float> _attr_nums;
};
}

View File

@ -35,8 +35,6 @@
#include "mt/SkillNumber.h"
#include "mt/MapArea.h"
#include "mt/MapCollider.h"
#include "mt/Grasp.h"
#include "mt/GraspBuff.h"
#include "mt/GuideStep.h"
#include "mt/MergeItem.h"
#include "mt/MapThingGroup.h"
@ -111,8 +109,6 @@ namespace mt
RegMetaTable<Skill>(res_path_);
RegMetaTable<SkillNumber>(res_path_);
RegMetaTable<MapArea>(res_path_);
RegMetaTable<Grasp>(res_path_);
RegMetaTable<GraspBuff>(res_path_);
RegMetaTable<GuideStep>(res_path_);
RegMetaTable<MergeItem>(res_path_);
RegMetaTable<MapThingGroup>(res_path_);

View File

@ -35,8 +35,6 @@
#include "mtb/PveGeminiContent.h"
#include "mtb/PveGeminiMode.h"
#include "mtb/RankRoom.h"
#include "mtb/Grasp.h"
#include "mtb/GraspBuff.h"
#include "mtb/GuideStep.h"
#include "mtb/WorldObject.h"
#include "mtb/MergeItem.h"
@ -805,43 +803,6 @@ namespace mtb
return meta_class;
}
std::shared_ptr<a8::reflect::Class> Grasp::GetClass() const
{
std::shared_ptr<a8::reflect::Class> meta_class = nullptr;
if (!meta_class) {
meta_class = std::make_shared<a8::reflect::Class>("Grasp", 9, 0);
meta_class->SetSimpleField(0, "grasp_id", a8::reflect::ET_INT32, my_offsetof2(Grasp, grasp_id_));
meta_class->SetSimpleField(1, "hero_id", a8::reflect::ET_INT32, my_offsetof2(Grasp, hero_id_));
meta_class->SetSimpleField(2, "hero_lv", a8::reflect::ET_INT32, my_offsetof2(Grasp, hero_lv_));
meta_class->SetSimpleField(3, "graspbuff_id1", a8::reflect::ET_INT32, my_offsetof2(Grasp, graspbuff_id1_));
meta_class->SetSimpleField(4, "graspbuff_id1_floor2", a8::reflect::ET_INT32, my_offsetof2(Grasp, graspbuff_id1_floor2_));
meta_class->SetSimpleField(5, "graspbuff_id2", a8::reflect::ET_INT32, my_offsetof2(Grasp, graspbuff_id2_));
meta_class->SetSimpleField(6, "weapon_id", a8::reflect::ET_INT32, my_offsetof2(Grasp, weapon_id_));
meta_class->SetSimpleField(7, "add_buff_list", a8::reflect::ET_STRING, my_offsetof2(Grasp, add_buff_list_));
meta_class->SetSimpleField(8, "remove_buff_list", a8::reflect::ET_STRING, my_offsetof2(Grasp, remove_buff_list_));
}
return meta_class;
}
std::shared_ptr<a8::reflect::Class> GraspBuff::GetClass() const
{
std::shared_ptr<a8::reflect::Class> meta_class = nullptr;
if (!meta_class) {
meta_class = std::make_shared<a8::reflect::Class>("GraspBuff", 10, 0);
meta_class->SetSimpleField(0, "graspbuff_id", a8::reflect::ET_INT32, my_offsetof2(GraspBuff, graspbuff_id_));
meta_class->SetSimpleField(1, "graspbuff_floor", a8::reflect::ET_INT32, my_offsetof2(GraspBuff, graspbuff_floor_));
meta_class->SetSimpleField(2, "graspbuff_trigger", a8::reflect::ET_STRING, my_offsetof2(GraspBuff, graspbuff_trigger_));
meta_class->SetSimpleField(3, "graspbuff_target", a8::reflect::ET_INT32, my_offsetof2(GraspBuff, graspbuff_target_));
meta_class->SetSimpleField(4, "graspbuff_time", a8::reflect::ET_STRING, my_offsetof2(GraspBuff, graspbuff_time_));
meta_class->SetSimpleField(5, "attr_id", a8::reflect::ET_INT32, my_offsetof2(GraspBuff, attr_id_));
meta_class->SetSimpleField(6, "attr_add_pattern", a8::reflect::ET_INT32, my_offsetof2(GraspBuff, attr_add_pattern_));
meta_class->SetSimpleField(7, "attr_add_pattern2", a8::reflect::ET_INT32, my_offsetof2(GraspBuff, attr_add_pattern2_));
meta_class->SetSimpleField(8, "attr_num", a8::reflect::ET_STRING, my_offsetof2(GraspBuff, attr_num_));
meta_class->SetSimpleField(9, "effect_list", a8::reflect::ET_STRING, my_offsetof2(GraspBuff, effect_list_));
}
return meta_class;
}
std::shared_ptr<a8::reflect::Class> GuideStep::GetClass() const
{
std::shared_ptr<a8::reflect::Class> meta_class = nullptr;

View File

@ -602,33 +602,6 @@ message RankRoom
optional int32 final_player_num = 10;
}
message Grasp
{
optional int32 grasp_id = 1;
optional int32 hero_id = 2;
optional int32 hero_lv = 3;
optional int32 graspbuff_id1 = 4;
optional int32 graspbuff_id1_floor2 = 5;
optional int32 graspbuff_id2 = 6;
optional int32 weapon_id = 7;
optional string add_buff_list = 8;
optional string remove_buff_list = 9;
}
message GraspBuff
{
optional int32 graspbuff_id = 1;
optional int32 graspbuff_floor = 2;
optional string graspbuff_trigger = 4;
optional int32 graspbuff_target = 5;
optional string graspbuff_time = 6;
optional int32 attr_id = 7;
optional int32 attr_add_pattern = 8;
optional int32 attr_add_pattern2 = 9;
optional string attr_num = 10;
optional string effect_list = 11;
}
message GuideStep
{
optional int32 id = 1;