buff post action添加addbuff处理
This commit is contained in:
parent
458c8c0d70
commit
e8d711dcd3
@ -450,3 +450,17 @@ void Buff::ProcTurnOver(Creature* caster)
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
CreatureWeakPtr& Buff::GetCaster()
|
||||||
|
{
|
||||||
|
return caster_;
|
||||||
|
}
|
||||||
|
|
||||||
|
void Buff::SetCaster(Creature* caster)
|
||||||
|
{
|
||||||
|
if (caster) {
|
||||||
|
caster_.Attach(caster);
|
||||||
|
} else {
|
||||||
|
caster_.Reset();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
@ -1,5 +1,7 @@
|
|||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
|
#include "weakptr.h"
|
||||||
|
|
||||||
namespace MetaData
|
namespace MetaData
|
||||||
{
|
{
|
||||||
struct Player;
|
struct Player;
|
||||||
@ -36,6 +38,8 @@ class Buff
|
|||||||
bool NeedSync(Human* hum);
|
bool NeedSync(Human* hum);
|
||||||
void FillMFBuff(cs::MFBuff* buff_pb);
|
void FillMFBuff(cs::MFBuff* buff_pb);
|
||||||
bool FreezeOperate();
|
bool FreezeOperate();
|
||||||
|
CreatureWeakPtr& GetCaster();
|
||||||
|
void SetCaster(Creature* caster);
|
||||||
|
|
||||||
void ProcDelayAddBuff(Creature* caster);
|
void ProcDelayAddBuff(Creature* caster);
|
||||||
void ProcIntervalAddBuff(Creature* caster);
|
void ProcIntervalAddBuff(Creature* caster);
|
||||||
@ -59,4 +63,5 @@ private:
|
|||||||
private:
|
private:
|
||||||
int hold_curr_weapon_idx_ = 0;
|
int hold_curr_weapon_idx_ = 0;
|
||||||
std::list<Weapon> hold_weapons_;
|
std::list<Weapon> hold_weapons_;
|
||||||
|
CreatureWeakPtr caster_;
|
||||||
};
|
};
|
||||||
|
@ -323,7 +323,8 @@ enum GameChannel_e
|
|||||||
enum PostBuffAction_e
|
enum PostBuffAction_e
|
||||||
{
|
{
|
||||||
kRemoveBuffByIdAction = 1,
|
kRemoveBuffByIdAction = 1,
|
||||||
kRemoveBuffByEffectAction = 2
|
kRemoveBuffByEffectAction = 2,
|
||||||
|
kAddBuffAction = 3
|
||||||
};
|
};
|
||||||
|
|
||||||
enum ObstacleType_e
|
enum ObstacleType_e
|
||||||
|
@ -67,6 +67,7 @@ enum BuffEffectType_e
|
|||||||
kBET_InGrass = 56, //在草丛
|
kBET_InGrass = 56, //在草丛
|
||||||
kBET_InWater = 57, //在水里
|
kBET_InWater = 57, //在水里
|
||||||
kBET_InIce = 58, //在冰里
|
kBET_InIce = 58, //在冰里
|
||||||
|
kBET_PullToWalkable = 59, //从碰撞里以自己方向拖出来直到没有碰撞
|
||||||
kBET_BatchAddBuff = 60, //批量添加buff
|
kBET_BatchAddBuff = 60, //批量添加buff
|
||||||
kBET_BeRecycle = 61, //待回收
|
kBET_BeRecycle = 61, //待回收
|
||||||
kBET_Trace = 62, //追踪玩家
|
kBET_Trace = 62, //追踪玩家
|
||||||
|
@ -192,6 +192,7 @@ void Creature::AddBuff(Creature* caster,
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
Buff* buff = &a8::FastAppend(buff_list_);
|
Buff* buff = &a8::FastAppend(buff_list_);
|
||||||
|
buff->SetCaster(caster);
|
||||||
buff->skill_lv = skill_lv;
|
buff->skill_lv = skill_lv;
|
||||||
buff->owner = this;
|
buff->owner = this;
|
||||||
buff->meta = buff_meta;
|
buff->meta = buff_meta;
|
||||||
@ -272,7 +273,7 @@ void Creature::TryAddBuff(Creature* caster, int buff_id)
|
|||||||
|
|
||||||
void Creature::RemoveBuffById(int buff_id)
|
void Creature::RemoveBuffById(int buff_id)
|
||||||
{
|
{
|
||||||
std::vector<MetaData::Buff*> removed_buffs;
|
std::vector<std::tuple<MetaData::Buff*, Creature*>> removed_buffs;
|
||||||
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) {
|
||||||
@ -280,13 +281,15 @@ void Creature::RemoveBuffById(int buff_id)
|
|||||||
if (!list_empty(&buff.depend_entry)) {
|
if (!list_empty(&buff.depend_entry)) {
|
||||||
list_del_init(&buff.depend_entry);
|
list_del_init(&buff.depend_entry);
|
||||||
}
|
}
|
||||||
removed_buffs.push_back(buff.meta);
|
removed_buffs.push_back(std::make_tuple(buff.meta, buff.GetCaster().Get()));
|
||||||
OnBuffRemove(buff);
|
OnBuffRemove(buff);
|
||||||
buff_list_.erase(itr);
|
buff_list_.erase(itr);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
for (MetaData::Buff* buff_meta : removed_buffs) {
|
for (auto& tuple1 : removed_buffs) {
|
||||||
|
MetaData::Buff* buff_meta = std::get<0>(tuple1);
|
||||||
|
Creature* caster = std::get<1>(tuple1);
|
||||||
for (const auto& tuple : buff_meta->post_remove_action) {
|
for (const auto& tuple : buff_meta->post_remove_action) {
|
||||||
switch (std::get<0>(tuple)) {
|
switch (std::get<0>(tuple)) {
|
||||||
case kRemoveBuffByIdAction:
|
case kRemoveBuffByIdAction:
|
||||||
@ -303,6 +306,13 @@ void Creature::RemoveBuffById(int buff_id)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
case kAddBuffAction:
|
||||||
|
{
|
||||||
|
for (int buff_id :std::get<1>(tuple)) {
|
||||||
|
TryAddBuff(caster, buff_id);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
break;
|
||||||
default:
|
default:
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
@ -3,6 +3,7 @@
|
|||||||
#include "weakptr.h"
|
#include "weakptr.h"
|
||||||
#include "moveableentity.h"
|
#include "moveableentity.h"
|
||||||
#include "buff.h"
|
#include "buff.h"
|
||||||
|
#include "weakptr.h"
|
||||||
|
|
||||||
#include "cs_proto.pb.h"
|
#include "cs_proto.pb.h"
|
||||||
|
|
||||||
|
@ -765,12 +765,15 @@ namespace MetaData
|
|||||||
std::vector<std::string> strings3;
|
std::vector<std::string> strings3;
|
||||||
a8::Split(strings2[1], strings3, ';');
|
a8::Split(strings2[1], strings3, ';');
|
||||||
if (strings2[0] == "remove_buff_by_id" ||
|
if (strings2[0] == "remove_buff_by_id" ||
|
||||||
strings2[0] == "remove_buff_by_effect") {
|
strings2[0] == "remove_buff_by_effect" ||
|
||||||
|
strings2[0] == "add_buff") {
|
||||||
auto& action = a8::FastAppend(post_remove_action);
|
auto& action = a8::FastAppend(post_remove_action);
|
||||||
if (strings2[0] == "remove_buff_by_id") {
|
if (strings2[0] == "remove_buff_by_id") {
|
||||||
std::get<0>(action) = kRemoveBuffByIdAction;
|
std::get<0>(action) = kRemoveBuffByIdAction;
|
||||||
} else if (strings2[0] == "remove_buff_by_effect") {
|
} else if (strings2[0] == "remove_buff_by_effect") {
|
||||||
std::get<0>(action) = kRemoveBuffByEffectAction;
|
std::get<0>(action) = kRemoveBuffByEffectAction;
|
||||||
|
} else if (strings2[0] == "add_buff") {
|
||||||
|
std::get<0>(action) = kAddBuffAction;
|
||||||
}
|
}
|
||||||
for (auto& str3 : strings3) {
|
for (auto& str3 : strings3) {
|
||||||
if (!str3.empty()) {
|
if (!str3.empty()) {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user