添加批量buff
This commit is contained in:
parent
654630c3d3
commit
7ba76ad4eb
@ -37,7 +37,36 @@ void Buff::ProcIntervalAddBuff(Creature* caster)
|
|||||||
|
|
||||||
void Buff::ProcBatchAddBuff(Creature* caster)
|
void Buff::ProcBatchAddBuff(Creature* caster)
|
||||||
{
|
{
|
||||||
|
for (auto& tuple : meta->batch_add_list) {
|
||||||
|
int rand_space = std::get<0>(tuple);
|
||||||
|
const auto& items = std::get<1>(tuple);
|
||||||
|
if (items.empty()) {
|
||||||
|
abort();
|
||||||
|
}
|
||||||
|
int rnd = rand();
|
||||||
|
if (rand_space == -1) {
|
||||||
|
//概率
|
||||||
|
rnd = rnd % 10000;
|
||||||
|
if (rnd < std::get<1>(items[0])){
|
||||||
|
MetaData::Buff* buff_meta = MetaMgr::Instance()->GetBuff(std::get<0>(items[0]));
|
||||||
|
if (buff_meta) {
|
||||||
|
owner->AddBuff(caster, buff_meta, 1, nullptr);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
//权重
|
||||||
|
rnd = rnd % rand_space;
|
||||||
|
for (const auto& item : items) {
|
||||||
|
if (rnd <= std::get<1>(item)) {
|
||||||
|
MetaData::Buff* buff_meta = MetaMgr::Instance()->GetBuff(std::get<0>(item));
|
||||||
|
if (buff_meta) {
|
||||||
|
owner->AddBuff(caster, buff_meta, 1, nullptr);
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void Buff::InternalTimerAddBuff(Creature* caster)
|
void Buff::InternalTimerAddBuff(Creature* caster)
|
||||||
|
@ -555,6 +555,65 @@ namespace MetaData
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
if (i->buff_effect() == kBET_BatchAddBuff) {
|
||||||
|
std::vector<std::string> strings1;
|
||||||
|
a8::Split(i->buff_param1(), strings1, '|');
|
||||||
|
for (auto& str1 : strings1) {
|
||||||
|
std::vector<std::string> strings2;
|
||||||
|
a8::Split(str1, strings2, '|');
|
||||||
|
for (auto& str2 : strings2) {
|
||||||
|
if (str2.size() < 1) {
|
||||||
|
abort();
|
||||||
|
}
|
||||||
|
auto& p = a8::FastAppend(batch_add_list);
|
||||||
|
if (str2[0] != '!') {
|
||||||
|
//概率
|
||||||
|
std::vector<std::string> strings3;
|
||||||
|
a8::Split(str2, strings3, ':');
|
||||||
|
if (strings3.size() != 2) {
|
||||||
|
abort();
|
||||||
|
}
|
||||||
|
if (a8::XValue(strings3[1]).GetInt() <= 0) {
|
||||||
|
abort();
|
||||||
|
}
|
||||||
|
std::get<0>(p) = -1;
|
||||||
|
std::get<1>(p).push_back
|
||||||
|
(
|
||||||
|
std::make_tuple(a8::XValue(strings3[0]),
|
||||||
|
a8::XValue(strings3[1]))
|
||||||
|
);
|
||||||
|
} else {
|
||||||
|
//权重
|
||||||
|
std::vector<std::string> strings3;
|
||||||
|
a8::Split(str2, strings3, '$');
|
||||||
|
int rand_space = 0;
|
||||||
|
for (const std::string& str3 : strings3) {
|
||||||
|
std::vector<std::string> strings4;
|
||||||
|
a8::Split(str3, strings4, ':');
|
||||||
|
if (strings4.size() != 2) {
|
||||||
|
abort();
|
||||||
|
}
|
||||||
|
std::string tmp_str = strings4[0];
|
||||||
|
a8::ReplaceString(tmp_str, "!", "");
|
||||||
|
int buff_id = a8::XValue(tmp_str);
|
||||||
|
int weight = a8::XValue(strings4[1]);
|
||||||
|
if (weight <= 0) {
|
||||||
|
abort();
|
||||||
|
}
|
||||||
|
|
||||||
|
rand_space += weight;
|
||||||
|
std::get<1>(p).push_back
|
||||||
|
(
|
||||||
|
std::make_tuple(buff_id,
|
||||||
|
rand_space)
|
||||||
|
);
|
||||||
|
}
|
||||||
|
std::get<0>(p) = rand_space;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
int i = 0;
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
bool Buff::EffectCanStack()
|
bool Buff::EffectCanStack()
|
||||||
|
@ -170,6 +170,7 @@ namespace MetaData
|
|||||||
float param3 = 0.0f;
|
float param3 = 0.0f;
|
||||||
float param4 = 0.0f;
|
float param4 = 0.0f;
|
||||||
std::vector<int> param2_int_list;
|
std::vector<int> param2_int_list;
|
||||||
|
std::vector<std::tuple<int, std::vector<std::tuple<int, int>>>> batch_add_list;
|
||||||
std::vector<std::tuple<int, std::vector<int>>> post_remove_action;
|
std::vector<std::tuple<int, std::vector<int>>> post_remove_action;
|
||||||
std::set<int> immune_buffeffect;
|
std::set<int> immune_buffeffect;
|
||||||
};
|
};
|
||||||
|
Loading…
x
Reference in New Issue
Block a user