1
This commit is contained in:
parent
f47a6d4132
commit
528318d3ce
@ -241,13 +241,17 @@ bool Ability::CanImmune(const std::set<int>& tags)
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
AttrHandle Ability::AddAttr(int attr_id, float val)
|
AttrHandle Ability::AddAttr(int attr_id, float val, int source_type)
|
||||||
{
|
{
|
||||||
float old_max_hp = owner_.Get()->GetMaxHP();
|
float old_max_hp = owner_.Get()->GetMaxHP();
|
||||||
if (IsValidHumanAttr(attr_id) ||
|
if (IsValidHumanAttr(attr_id) ||
|
||||||
IsValidHumanVirtualAttr(attr_id)) {
|
IsValidHumanVirtualAttr(attr_id)) {
|
||||||
|
if (source_type < kAstNone || source_type >= kAstEnd) {
|
||||||
|
A8_ABORT();
|
||||||
|
}
|
||||||
auto p = std::make_shared<AttrAddition>(attr_id, val);
|
auto p = std::make_shared<AttrAddition>(attr_id, val);
|
||||||
p->holder = p;
|
p->holder = p;
|
||||||
|
p->source_type = source_type;
|
||||||
if (p->IsAdd()) {
|
if (p->IsAdd()) {
|
||||||
if (IsValidHumanAttr(attr_id)) {
|
if (IsValidHumanAttr(attr_id)) {
|
||||||
list_add_tail(&p->entry, &std::get<1>(attr_add_[attr_id]));
|
list_add_tail(&p->entry, &std::get<1>(attr_add_[attr_id]));
|
||||||
@ -610,12 +614,8 @@ bool Ability::HasDecAttr(int attr_id)
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void Ability::SetSource(AttrHandle handle, int source_type, std::shared_ptr<std::function<std::string()>> cb)
|
void Ability::SetSource(AttrHandle handle, std::shared_ptr<std::function<std::string()>> cb)
|
||||||
{
|
{
|
||||||
if (source_type < kAstNone || source_type >= kAstEnd) {
|
|
||||||
A8_ABORT();
|
|
||||||
}
|
|
||||||
auto p = handle.lock();
|
auto p = handle.lock();
|
||||||
p->source_type = source_type;
|
|
||||||
p->get_source = cb;
|
p->get_source = cb;
|
||||||
}
|
}
|
||||||
|
@ -24,7 +24,7 @@ class Ability
|
|||||||
void DecSwitch(int type);
|
void DecSwitch(int type);
|
||||||
int GetSwitchTimes(int type);
|
int GetSwitchTimes(int type);
|
||||||
|
|
||||||
AttrHandle AddAttr(int attr_id, float val);
|
AttrHandle AddAttr(int attr_id, float val, int source_type);
|
||||||
void RemoveAttr(AttrHandle handler);
|
void RemoveAttr(AttrHandle handler);
|
||||||
float GetAttr(int attr_id);
|
float GetAttr(int attr_id);
|
||||||
bool HasAttr(int attr_id);
|
bool HasAttr(int attr_id);
|
||||||
@ -37,7 +37,7 @@ class Ability
|
|||||||
void GMDelAttr(int attr_id, int idx);
|
void GMDelAttr(int attr_id, int idx);
|
||||||
void GMClearAttr();
|
void GMClearAttr();
|
||||||
std::vector<std::string> GMShowAttrs();
|
std::vector<std::string> GMShowAttrs();
|
||||||
void SetSource(AttrHandle handle, int source_type, std::shared_ptr<std::function<std::string()>> cb);
|
void SetSource(AttrHandle handle, std::shared_ptr<std::function<std::string()>> cb);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
void Clear();
|
void Clear();
|
||||||
|
@ -1971,9 +1971,9 @@ void CallFuncBuff::BulletDmgCalcProc()
|
|||||||
bool match = target->GetHP() / target->GetMaxHP() < cond;
|
bool match = target->GetHP() / target->GetMaxHP() < cond;
|
||||||
if (match) {
|
if (match) {
|
||||||
if (target_type == 0) {
|
if (target_type == 0) {
|
||||||
context->attr_handle = owner->GetAbility()->AddAttr(attr_id, attr_val);
|
context->attr_handle = owner->GetAbility()->AddAttr(attr_id, attr_val, kAstOther);
|
||||||
} else if (target_type == 1) {
|
} else if (target_type == 1) {
|
||||||
context->attr_handle = target->GetAbility()->AddAttr(attr_id, attr_val);
|
context->attr_handle = target->GetAbility()->AddAttr(attr_id, attr_val, kAstOther);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -16,7 +16,7 @@ void ModifyAttrBuff::Activate()
|
|||||||
int attr_id = meta->_int_buff_param1;
|
int attr_id = meta->_int_buff_param1;
|
||||||
float value = meta->GetBuffParam2(this);
|
float value = meta->GetBuffParam2(this);
|
||||||
if (f8::App::Instance()->GetInstanceId() != 3) {
|
if (f8::App::Instance()->GetInstanceId() != 3) {
|
||||||
attr_handle_ = owner->GetAbility()->AddAttr(attr_id, value);
|
attr_handle_ = owner->GetAbility()->AddAttr(attr_id, value, kAstOther);
|
||||||
#ifdef MYDEBUG
|
#ifdef MYDEBUG
|
||||||
if (!attr_handle_.expired()) {
|
if (!attr_handle_.expired()) {
|
||||||
std::string source_name = a8::Format
|
std::string source_name = a8::Format
|
||||||
@ -33,7 +33,7 @@ void ModifyAttrBuff::Activate()
|
|||||||
{
|
{
|
||||||
return source_name;
|
return source_name;
|
||||||
});
|
});
|
||||||
owner->GetAbility()->SetSource(attr_handle_, kAstOther, cb);
|
owner->GetAbility()->SetSource(attr_handle_, cb);
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
@ -339,7 +339,7 @@ void Player::_CMExecCommand(f8::MsgHdr* hdr, const cs::CMExecCommand& msg)
|
|||||||
float value = a8::XValue(cmds[3]).GetDouble();
|
float value = a8::XValue(cmds[3]).GetDouble();
|
||||||
int source_type = cmds.size() > 4 ? a8::XValue(cmds[4]).GetInt() : kAstOther;
|
int source_type = cmds.size() > 4 ? a8::XValue(cmds[4]).GetInt() : kAstOther;
|
||||||
if (target) {
|
if (target) {
|
||||||
auto handle = target->GetAbility()->AddAttr(attr_id, value);
|
auto handle = target->GetAbility()->AddAttr(attr_id, value, source_type);
|
||||||
if (!handle.expired()) {
|
if (!handle.expired()) {
|
||||||
std::string source_name = "<-gm.self." + a8::XValue(source_type).GetString();
|
std::string source_name = "<-gm.self." + a8::XValue(source_type).GetString();
|
||||||
auto cb = std::make_shared<std::function<std::string()>>
|
auto cb = std::make_shared<std::function<std::string()>>
|
||||||
@ -348,7 +348,7 @@ void Player::_CMExecCommand(f8::MsgHdr* hdr, const cs::CMExecCommand& msg)
|
|||||||
{
|
{
|
||||||
return source_name;
|
return source_name;
|
||||||
});
|
});
|
||||||
target->GetAbility()->SetSource(handle, source_type, cb);
|
target->GetAbility()->SetSource(handle, cb);
|
||||||
}
|
}
|
||||||
std::vector<std::string> strings = target->GetAbility()->GMShowAttrs();
|
std::vector<std::string> strings = target->GetAbility()->GMShowAttrs();
|
||||||
for (auto& str : strings) {
|
for (auto& str : strings) {
|
||||||
|
@ -4250,7 +4250,7 @@ void Creature::GenLevelAttr()
|
|||||||
}
|
}
|
||||||
grow_attr_list_.clear();
|
grow_attr_list_.clear();
|
||||||
for (auto tuple : *attrs) {
|
for (auto tuple : *attrs) {
|
||||||
auto handle = GetAbility()->AddAttr(std::get<0>(tuple), std::get<1>(tuple));
|
auto handle = GetAbility()->AddAttr(std::get<0>(tuple), std::get<1>(tuple), kAstOther);
|
||||||
if (!handle.expired()) {
|
if (!handle.expired()) {
|
||||||
grow_attr_list_.push_back(handle);
|
grow_attr_list_.push_back(handle);
|
||||||
}
|
}
|
||||||
@ -4267,7 +4267,7 @@ void Creature::GenLevelAttr()
|
|||||||
{
|
{
|
||||||
return source_name;
|
return source_name;
|
||||||
});
|
});
|
||||||
GetAbility()->SetSource(handle, kAstOther, cb);
|
GetAbility()->SetSource(handle, cb);
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
@ -292,7 +292,7 @@ private:
|
|||||||
int attr_id = a8::XValue(attr->Get("attr_id", "0"));
|
int attr_id = a8::XValue(attr->Get("attr_id", "0"));
|
||||||
float val = a8::XValue(attr->Get("val", "0")).GetDouble();
|
float val = a8::XValue(attr->Get("val", "0")).GetDouble();
|
||||||
if (IsValidHumanAttr(attr_id)) {
|
if (IsValidHumanAttr(attr_id)) {
|
||||||
auto attr_handle = owner_.Get()->GetAbility()->AddAttr(attr_id, val);
|
auto attr_handle = owner_.Get()->GetAbility()->AddAttr(attr_id, val, kAstOther);
|
||||||
if (!attr_handle.expired()) {
|
if (!attr_handle.expired()) {
|
||||||
#ifdef MYDEBUG
|
#ifdef MYDEBUG
|
||||||
std::string source_name = a8::Format
|
std::string source_name = a8::Format
|
||||||
@ -305,7 +305,7 @@ private:
|
|||||||
{
|
{
|
||||||
return source_name;
|
return source_name;
|
||||||
});
|
});
|
||||||
owner_.Get()->GetAbility()->SetSource(attr_handle, kAstOther, cb);
|
owner_.Get()->GetAbility()->SetSource(attr_handle, cb);
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -324,7 +324,7 @@ private:
|
|||||||
int attr_id = a8::XValue(attr->Get("attr_id", "0"));
|
int attr_id = a8::XValue(attr->Get("attr_id", "0"));
|
||||||
float val = a8::XValue(attr->Get("val", "0")).GetDouble();
|
float val = a8::XValue(attr->Get("val", "0")).GetDouble();
|
||||||
if (IsValidHumanAttr(attr_id)) {
|
if (IsValidHumanAttr(attr_id)) {
|
||||||
auto attr_handle = owner_.Get()->GetAbility()->AddAttr(attr_id, val);
|
auto attr_handle = owner_.Get()->GetAbility()->AddAttr(attr_id, val, kAstChip);
|
||||||
if (!attr_handle.expired()) {
|
if (!attr_handle.expired()) {
|
||||||
#ifdef MYDEBUG
|
#ifdef MYDEBUG
|
||||||
std::string source_name = a8::Format
|
std::string source_name = a8::Format
|
||||||
@ -337,9 +337,7 @@ private:
|
|||||||
{
|
{
|
||||||
return source_name;
|
return source_name;
|
||||||
});
|
});
|
||||||
owner_.Get()->GetAbility()->SetSource(attr_handle, kAstChip, cb);
|
owner_.Get()->GetAbility()->SetSource(attr_handle, cb);
|
||||||
#else
|
|
||||||
owner_.Get()->GetAbility()->SetSource(attr_handle, kAstChip, nullptr);
|
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user