添加depend_effect child_buff机制
This commit is contained in:
parent
242db70a3f
commit
d593b8f126
@ -9,6 +9,16 @@
|
|||||||
#include "incubator.h"
|
#include "incubator.h"
|
||||||
#include "car.h"
|
#include "car.h"
|
||||||
|
|
||||||
|
Buff::Buff()
|
||||||
|
{
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
void Buff::Initialize()
|
||||||
|
{
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
int Buff::GetLeftTime()
|
int Buff::GetLeftTime()
|
||||||
{
|
{
|
||||||
int passed_ms = (owner->room->GetFrameNo() - add_frameno) * FRAME_RATE_MS;
|
int passed_ms = (owner->room->GetFrameNo() - add_frameno) * FRAME_RATE_MS;
|
||||||
|
@ -26,7 +26,11 @@ class Buff
|
|||||||
a8::XTimerAttacher xtimer_attacher;
|
a8::XTimerAttacher xtimer_attacher;
|
||||||
long long add_frameno = 0;
|
long long add_frameno = 0;
|
||||||
int skill_lv = 0;
|
int skill_lv = 0;
|
||||||
|
list_head effect_entry;
|
||||||
|
list_head depend_entry;
|
||||||
|
|
||||||
|
Buff();
|
||||||
|
void Initialize();
|
||||||
int GetLeftTime();
|
int GetLeftTime();
|
||||||
int GetLastingTime();
|
int GetLastingTime();
|
||||||
bool NeedSync(Human* hum);
|
bool NeedSync(Human* hum);
|
||||||
|
@ -133,7 +133,16 @@ bool Creature::HasBuffEffect(int buff_effect_id)
|
|||||||
|
|
||||||
Buff* Creature::GetBuffByEffectId(int effect_id)
|
Buff* Creature::GetBuffByEffectId(int effect_id)
|
||||||
{
|
{
|
||||||
return IsValidBuffEffect(effect_id) ? buff_effect_[effect_id] : nullptr;
|
if (!IsValidBuffEffect(effect_id)) {
|
||||||
|
return nullptr;
|
||||||
|
}
|
||||||
|
list_head* list = &buff_effect_[effect_id];
|
||||||
|
if (list_empty(list)) {
|
||||||
|
return nullptr;
|
||||||
|
} else {
|
||||||
|
Buff* buff = list_first_entry(list, Buff, effect_entry);
|
||||||
|
return buff;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
Buff* Creature::GetBuffById(int buff_id)
|
Buff* Creature::GetBuffById(int buff_id)
|
||||||
@ -159,6 +168,9 @@ void Creature::AddBuff(Creature* caster,
|
|||||||
if (IsImmuneBuffEffect(buff_meta->i->buff_effect())) {
|
if (IsImmuneBuffEffect(buff_meta->i->buff_effect())) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
if (buff_meta->i->depend_effect() != 0 && !HasBuffEffect(buff_meta->i->depend_effect())) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
if (!buff_meta->EffectCanStack()) {
|
if (!buff_meta->EffectCanStack()) {
|
||||||
Buff* buff = GetBuffByEffectId(buff_meta->i->buff_effect());
|
Buff* buff = GetBuffByEffectId(buff_meta->i->buff_effect());
|
||||||
if (buff) {
|
if (buff) {
|
||||||
@ -186,7 +198,14 @@ void Creature::AddBuff(Creature* caster,
|
|||||||
buff->skill_meta = buff_skill_meta;
|
buff->skill_meta = buff_skill_meta;
|
||||||
buff->add_frameno = room->GetFrameNo();
|
buff->add_frameno = room->GetFrameNo();
|
||||||
buff->xtimer_attacher.xtimer = &room->xtimer;
|
buff->xtimer_attacher.xtimer = &room->xtimer;
|
||||||
buff_effect_[buff->meta->i->buff_effect()] = buff;
|
list_add_tail(&buff_effect_[buff->meta->i->buff_effect()], &buff->effect_entry);
|
||||||
|
if (buff->meta->i->depend_effect() != 0 &&
|
||||||
|
IsValidBuffEffect(buff->meta->i->depend_effect())) {
|
||||||
|
list_add_tail(&depend_effect_[buff->meta->i->depend_effect()], &buff->depend_entry);
|
||||||
|
} else {
|
||||||
|
INIT_LIST_HEAD(&buff->depend_entry);
|
||||||
|
}
|
||||||
|
buff->Initialize();
|
||||||
{
|
{
|
||||||
room->xtimer.AddDeadLineTimerAndAttach
|
room->xtimer.AddDeadLineTimerAndAttach
|
||||||
(
|
(
|
||||||
@ -207,6 +226,14 @@ void Creature::AddBuff(Creature* caster,
|
|||||||
if (!buff->meta->i->only_server()) {
|
if (!buff->meta->i->only_server()) {
|
||||||
room->frame_event.AddBuff(GetWeakPtrRef(), buff);
|
room->frame_event.AddBuff(GetWeakPtrRef(), buff);
|
||||||
}
|
}
|
||||||
|
if (!buff->meta->child_buff_list.empty()) {
|
||||||
|
for (int child_buff_id : buff->meta->child_buff_list) {
|
||||||
|
MetaData::Buff* child_buff_meta = MetaMgr::Instance()->GetBuff(child_buff_id);
|
||||||
|
if (child_buff_meta) {
|
||||||
|
AddBuff(caster, child_buff_meta, skill_lv, buff_skill_meta);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
#ifdef DEBUG
|
#ifdef DEBUG
|
||||||
SendDebugMsg(a8::Format("添加buff_id:%d buff_effect:%d",
|
SendDebugMsg(a8::Format("添加buff_id:%d buff_effect:%d",
|
||||||
{
|
{
|
||||||
@ -249,8 +276,9 @@ void Creature::RemoveBuffById(int buff_id)
|
|||||||
for (auto itr = buff_list_.begin(); itr != buff_list_.end(); ++itr) {
|
for (auto itr = buff_list_.begin(); itr != buff_list_.end(); ++itr) {
|
||||||
Buff& buff = *itr;
|
Buff& buff = *itr;
|
||||||
if (buff.meta->i->buff_id() == buff_id) {
|
if (buff.meta->i->buff_id() == buff_id) {
|
||||||
if (buff_effect_[buff.meta->i->buff_effect()] == &(*itr)) {
|
list_del_init(&buff.effect_entry);
|
||||||
buff_effect_[buff.meta->i->buff_effect()] = nullptr;
|
if (!list_empty(&buff.depend_entry)) {
|
||||||
|
list_del_init(&buff.depend_entry);
|
||||||
}
|
}
|
||||||
removed_buffs.push_back(buff.meta);
|
removed_buffs.push_back(buff.meta);
|
||||||
OnBuffRemove(buff);
|
OnBuffRemove(buff);
|
||||||
@ -279,6 +307,18 @@ void Creature::RemoveBuffById(int buff_id)
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
for (int child_buff_id : buff_meta->child_buff_list) {
|
||||||
|
RemoveBuffById(child_buff_id);
|
||||||
|
}
|
||||||
|
if (!HasBuffEffect(buff_meta->i->buff_effect()) &&
|
||||||
|
!list_empty(&depend_effect_[buff_meta->i->buff_effect()])) {
|
||||||
|
struct list_head work_list;
|
||||||
|
list_replace_init(&depend_effect_[buff_meta->i->buff_effect()], &work_list);
|
||||||
|
while (!list_empty(&work_list)) {
|
||||||
|
Buff* buff = list_first_entry(&work_list, Buff, depend_entry);
|
||||||
|
RemoveBuffById(buff->meta->i->buff_id());
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
RecalcBuffAttr();
|
RecalcBuffAttr();
|
||||||
#ifdef DEBUG
|
#ifdef DEBUG
|
||||||
@ -337,9 +377,7 @@ void Creature::RemoveBuffByEffectId(int buff_effect_id)
|
|||||||
void Creature::ClearBuffList()
|
void Creature::ClearBuffList()
|
||||||
{
|
{
|
||||||
for (auto itr = buff_list_.begin(); itr != buff_list_.end(); ++itr) {
|
for (auto itr = buff_list_.begin(); itr != buff_list_.end(); ++itr) {
|
||||||
if (buff_effect_[itr->meta->i->buff_effect()] == &(*itr)) {
|
list_del_init(&itr->effect_entry);
|
||||||
buff_effect_[itr->meta->i->buff_effect()] = nullptr;
|
|
||||||
}
|
|
||||||
OnBuffRemove(*itr);
|
OnBuffRemove(*itr);
|
||||||
}
|
}
|
||||||
buff_list_.clear();
|
buff_list_.clear();
|
||||||
@ -945,6 +983,12 @@ void Creature::ProcBuffEffect(Creature* caster, Buff* buff)
|
|||||||
void Creature::Initialize()
|
void Creature::Initialize()
|
||||||
{
|
{
|
||||||
MoveableEntity::Initialize();
|
MoveableEntity::Initialize();
|
||||||
|
for (auto& node : buff_effect_) {
|
||||||
|
INIT_LIST_HEAD(&node);
|
||||||
|
}
|
||||||
|
for (auto& node : depend_effect_) {
|
||||||
|
INIT_LIST_HEAD(&node);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void Creature::SetMoveDir(const a8::Vec2& move_dir)
|
void Creature::SetMoveDir(const a8::Vec2& move_dir)
|
||||||
|
@ -213,7 +213,8 @@ private:
|
|||||||
CreatureWeakPtrChunk weak_ptr_chunk_;
|
CreatureWeakPtrChunk weak_ptr_chunk_;
|
||||||
std::array<float, kHAT_End> buff_attr_abs_ = {};
|
std::array<float, kHAT_End> buff_attr_abs_ = {};
|
||||||
std::array<float, kHAT_End> buff_attr_rate_ = {};
|
std::array<float, kHAT_End> buff_attr_rate_ = {};
|
||||||
std::array<Buff*, kBET_End> buff_effect_ = {};
|
std::array<list_head, kBET_End> buff_effect_ = {};
|
||||||
|
std::array<list_head, kBET_End> depend_effect_ = {};
|
||||||
std::list<Buff> buff_list_;
|
std::list<Buff> buff_list_;
|
||||||
std::list<std::tuple<int, Hero*>> slave_heros_;
|
std::list<std::tuple<int, Hero*>> slave_heros_;
|
||||||
std::list<std::tuple<int, RoomObstacle*>> slave_things_;
|
std::list<std::tuple<int, RoomObstacle*>> slave_things_;
|
||||||
|
@ -719,6 +719,13 @@ namespace MetaData
|
|||||||
int_param2 = a8::XValue(i->buff_param2());
|
int_param2 = a8::XValue(i->buff_param2());
|
||||||
int_param3 = a8::XValue(i->buff_param3());
|
int_param3 = a8::XValue(i->buff_param3());
|
||||||
int_param4 = a8::XValue(i->buff_param4());
|
int_param4 = a8::XValue(i->buff_param4());
|
||||||
|
{
|
||||||
|
std::vector<std::string> strings;
|
||||||
|
a8::Split(i->child_buff(), strings, '|');
|
||||||
|
for (auto& str : strings) {
|
||||||
|
child_buff_list.push_back(a8::XValue(str));
|
||||||
|
}
|
||||||
|
}
|
||||||
{
|
{
|
||||||
std::vector<std::string> strings;
|
std::vector<std::string> strings;
|
||||||
a8::Split(i->immune_buffeffect_list(), strings, '|');
|
a8::Split(i->immune_buffeffect_list(), strings, '|');
|
||||||
|
@ -204,6 +204,8 @@ namespace MetaData
|
|||||||
std::vector<std::tuple<int, std::vector<int>>> post_remove_action;
|
std::vector<std::tuple<int, std::vector<int>>> post_remove_action;
|
||||||
std::set<int> immune_buffeffect;
|
std::set<int> immune_buffeffect;
|
||||||
std::vector<std::tuple<int, float, float, int, int>> hero_infos;
|
std::vector<std::tuple<int, float, float, int, int>> hero_infos;
|
||||||
|
|
||||||
|
std::vector<int> child_buff_list;
|
||||||
};
|
};
|
||||||
|
|
||||||
struct SkillPhase
|
struct SkillPhase
|
||||||
|
@ -236,6 +236,8 @@ message Buff
|
|||||||
optional string post_remove_action = 13;
|
optional string post_remove_action = 13;
|
||||||
optional int32 only_server = 14;
|
optional int32 only_server = 14;
|
||||||
optional int32 only_self = 15;
|
optional int32 only_self = 15;
|
||||||
|
optional int32 depend_effect = 16;
|
||||||
|
optional string child_buff = 17;
|
||||||
}
|
}
|
||||||
|
|
||||||
message Drop
|
message Drop
|
||||||
|
Loading…
x
Reference in New Issue
Block a user