This commit is contained in:
aozhiwei 2024-04-22 19:48:42 +08:00
parent d2db33e7db
commit 145b0e76b9

View File

@ -287,6 +287,24 @@ private:
if (attr && attr->IsObject()) { if (attr && attr->IsObject()) {
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)) {
auto attr_handle = owner_.Get()->GetAbility()->AddAttr(attr_id, val);
if (!attr_handle.expired()) {
#ifdef MYDEBUG
std::string source_name = a8::Format
("<-hero_rand_attr",
{
});
auto cb = std::make_shared<std::function<std::string()>>
(
[source_name] () -> std::string
{
return source_name;
});
owner_.Get()->GetAbility()->SetSource(attr_handle, cb);
}
#endif
}
} }
} }
} }
@ -301,6 +319,24 @@ private:
if (attr && attr->IsObject()) { if (attr && attr->IsObject()) {
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)) {
auto attr_handle = owner_.Get()->GetAbility()->AddAttr(attr_id, val);
if (!attr_handle.expired()) {
#ifdef MYDEBUG
std::string source_name = a8::Format
("<-chip_page",
{
});
auto cb = std::make_shared<std::function<std::string()>>
(
[source_name] () -> std::string
{
return source_name;
});
owner_.Get()->GetAbility()->SetSource(attr_handle, cb);
}
#endif
}
} }
} }
} }