1
This commit is contained in:
parent
4ca54b42be
commit
4ca93f2f97
@ -68,6 +68,7 @@
|
||||
#include "mt/PveGemini.h"
|
||||
#include "mt/PveGeminiMode.h"
|
||||
#include "mt/PveGeminiContent.h"
|
||||
#include "mt/BattlePotion.h"
|
||||
|
||||
static void Creature_FillBuffList(Creature* self, Human* hum, ::google::protobuf::RepeatedPtrField<::cs::MFBuff>* pb_buff_list)
|
||||
{
|
||||
@ -2948,9 +2949,36 @@ void CustomBattle::NotifyState()
|
||||
void Bag::UseItem(int equip_id)
|
||||
{
|
||||
auto p = GetItemById(equip_id);
|
||||
if (p && p->equip_num > 0 && p->GetCdTime(owner_) <= 0 && p->equip_meta) {
|
||||
if (p && p->equip_num > 0 && p->GetCdTime(owner_) <= 0 && p->equip_meta && p->potion_meta) {
|
||||
--p->equip_num;
|
||||
p->last_use_tick = owner_->room->GetFrameNo();
|
||||
if (!p->potion_meta->attrs.empty()) {
|
||||
std::list<AttrHandle> attr_handlers;
|
||||
for (auto& tuple : p->potion_meta->attrs) {
|
||||
auto handler = owner_->GetAbility()->AddAttr(std::get<0>(tuple),
|
||||
std::get<1>(tuple), kAstOther);
|
||||
if (!handler.expired()) {
|
||||
attr_handlers.push_back(handler);
|
||||
}
|
||||
}
|
||||
owner_->room->xtimer.SetTimeoutEx
|
||||
(p->potion_meta->duration() * SERVER_FRAME_RATE,
|
||||
[owner = owner_, attr_handlers] (int event, const a8::Args* args)
|
||||
{
|
||||
if (a8::TIMER_EXEC_EVENT == event) {
|
||||
for (auto handler : attr_handlers) {
|
||||
owner->GetAbility()->RemoveAttr(handler);
|
||||
}
|
||||
}
|
||||
},
|
||||
&owner_->xtimer_attacher);
|
||||
}
|
||||
if (p->potion_meta->buff()) {
|
||||
owner_->TryAddBuffAndSetTime(owner_,
|
||||
p->potion_meta->buff(),
|
||||
p->potion_meta->duration() * 1000);
|
||||
}
|
||||
|
||||
cs::SMUpdateBag notify_msg;
|
||||
auto pb_item = notify_msg.add_items();
|
||||
pb_item->set_equip_id(p->equip_id);
|
||||
|
Loading…
x
Reference in New Issue
Block a user