game2006/server/gameserver/buff/once_chg_attr.cc
aozhiwei d4abdc7002 1
2024-01-04 17:45:20 +08:00

94 lines
2.8 KiB
C++

#include "precompile.h"
#include "buff/once_chg_attr.h"
#include "attrdefine.h"
#include "creature.h"
#include "room.h"
#include "mt/Buff.h"
void OnceChgAttrBuff::Activate()
{
InternalProcOnceChgAttr();
}
void OnceChgAttrBuff::Deactivate()
{
}
void OnceChgAttrBuff::InternalProcOnceChgAttr()
{
if (owner->dead) {
return;
}
switch (meta->_int_buff_param1) {
case kXHAT_Hp:
{
int real_killer_id = 0;
std::string real_killer_name;
if (caster_.Get()) {
real_killer_id = caster_.Get()->GetUniId();
real_killer_name = caster_.Get()->GetName();
}
#ifdef MYDEBUG
if (caster_.Get()->IsPlayer()) {
a8::XPrintf("once chgattr %d %d\n", {real_killer_id, real_killer_name});
}
#endif
if (meta->_int_buff_param2 == 1) {
//绝对值
if (meta->_buff_param3 > 0) {
owner->AddHp(meta->_buff_param3);
} else if (meta->_buff_param3 < 0) {
float dmg_out = 0.0f;
owner->over_delay_time = 100;
owner->DecHP(std::abs(meta->_buff_param3),
VP_Buff,
"",
meta->buff_id(),
real_killer_id,
real_killer_name,
dmg_out);
owner->over_delay_time = 0;
}
} else if (meta->_int_buff_param2 == 2) {
//百分比
float chg_hp = owner->GetHP() * meta->_buff_param3;
if (chg_hp > 0.0001f) {
owner->AddHp(chg_hp);
} else if (chg_hp < 0.0001f) {
float dmg_out = 0.0f;
owner->over_delay_time = 100;
owner->DecHP(std::abs(chg_hp),
VP_Buff,
"",
meta->buff_id(),
real_killer_id,
real_killer_name,
dmg_out);
owner->over_delay_time = 0;
}
}
#ifdef MYDEBUG
{
std::string dbg_msg = a8::Format
("buff扣血 type:%s val:%f",
{
meta->_int_buff_param2,
meta->_int_buff_param3,
});
owner->room->BroadcastDebugMsg(dbg_msg);
}
#endif
owner->room->frame_event.AddHpChg(owner->GetWeakPtrRef());
}
break;
default:
{
}
break;
}
}