88 lines
2.6 KiB
C++
88 lines
2.6 KiB
C++
#include "precompile.h"
|
|
|
|
#include "buff/once_chg_attr.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 kHAT_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();
|
|
}
|
|
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 DEBUG
|
|
{
|
|
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;
|
|
}
|
|
}
|