1
This commit is contained in:
parent
9d5555e9dd
commit
058bae7823
@ -157,21 +157,10 @@ int Creature::AddBuff(Creature* caster,
|
||||
if (!buff_meta->_tags.empty() && GetAbility()->CanImmune(buff_meta->_tags)) {
|
||||
return 0;
|
||||
}
|
||||
if (buff_meta->buff_interval() > 0) {
|
||||
if (buff_meta->HasBuffInterval()) {
|
||||
if (buff_interval_hash_.find(buff_meta->buff_id()) != buff_interval_hash_.end()) {
|
||||
return 0;
|
||||
}
|
||||
buff_interval_hash_[buff_meta->buff_id()] = room->GetFrameNo();
|
||||
room->xtimer.SetTimeoutEx
|
||||
(
|
||||
buff_meta->buff_interval() / FRAME_RATE_MS,
|
||||
[this, buff_meta] (int event, const a8::Args* args)
|
||||
{
|
||||
if (a8::TIMER_EXEC_EVENT == event) {
|
||||
buff_interval_hash_.erase(buff_meta->buff_id());
|
||||
}
|
||||
},
|
||||
&xtimer_attacher);
|
||||
}
|
||||
if (buff_meta->coexist_num() > 0){
|
||||
if (GetBuffNum(buff_meta->buff_id()) >= buff_meta->coexist_num()) {
|
||||
@ -301,6 +290,22 @@ int Creature::AddBuff(Creature* caster,
|
||||
},
|
||||
&buff->xtimer_attacher);
|
||||
}
|
||||
{
|
||||
if (buff_meta->HasBuffInterval()) {
|
||||
buff_interval_hash_[buff_meta->buff_id()] = room->GetFrameNo();
|
||||
float buff_internval = buff->meta->GetBuffInterval(buff.get());
|
||||
room->xtimer.SetTimeoutEx
|
||||
(
|
||||
buff_internval / FRAME_RATE_MS,
|
||||
[this, buff_meta] (int event, const a8::Args* args)
|
||||
{
|
||||
if (a8::TIMER_EXEC_EVENT == event) {
|
||||
buff_interval_hash_.erase(buff_meta->buff_id());
|
||||
}
|
||||
},
|
||||
&xtimer_attacher);
|
||||
}
|
||||
}
|
||||
GetTrigger()->ActiveBuff(buff->meta);
|
||||
#ifdef DEBUG
|
||||
if (!f8::IsTestEnv()) {
|
||||
|
@ -153,6 +153,11 @@ namespace mt
|
||||
if (a8::lisp::Expr::MaybeExpr(res_scale())) {
|
||||
_res_scale_expr = LispEnv::Instance()->CompileSkillNumberExpr(res_scale());
|
||||
}
|
||||
if (a8::lisp::Expr::MaybeExpr(buff_interval())) {
|
||||
_buff_interval_expr = LispEnv::Instance()->CompileSkillNumberExpr(buff_interval());
|
||||
} else {
|
||||
_buff_interval = a8::XValue(buff_interval()).GetDouble();
|
||||
}
|
||||
}
|
||||
{
|
||||
std::vector<std::string> strings;
|
||||
@ -461,4 +466,21 @@ namespace mt
|
||||
return mtb::Buff::duration_time();
|
||||
}
|
||||
|
||||
float Buff::GetBuffInterval(::Buff* buff) const
|
||||
{
|
||||
if (_buff_interval_expr) {
|
||||
return LispEnv::Instance()->EvalSkillNumberExpr
|
||||
(
|
||||
_buff_interval_expr,
|
||||
buff
|
||||
);
|
||||
}
|
||||
return _buff_interval;
|
||||
}
|
||||
|
||||
bool Buff::HasBuffInterval() const
|
||||
{
|
||||
return !buff_interval().empty();
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -71,10 +71,13 @@ namespace mt
|
||||
float GetBuffParam4(::Buff* buff) const;
|
||||
float GetBuffParam5(::Buff* buff) const;
|
||||
float GetBuffParam6(::Buff* buff) const;
|
||||
float GetBuffInterval(::Buff* buff) const;
|
||||
float GetResScale(::Buff* buff) const;
|
||||
bool HasBuffInterval() const;
|
||||
|
||||
private:
|
||||
float _duration_time = 0.0f;
|
||||
float _buff_interval = 0.0f;
|
||||
std::shared_ptr<a8::lisp::Value> _duration_time_expr;
|
||||
std::shared_ptr<a8::lisp::Value> _buff_param1_expr;
|
||||
std::shared_ptr<a8::lisp::Value> _buff_param2_expr;
|
||||
@ -83,6 +86,7 @@ namespace mt
|
||||
std::shared_ptr<a8::lisp::Value> _buff_param5_expr;
|
||||
std::shared_ptr<a8::lisp::Value> _buff_param6_expr;
|
||||
std::shared_ptr<a8::lisp::Value> _res_scale_expr;
|
||||
std::shared_ptr<a8::lisp::Value> _buff_interval_expr;
|
||||
|
||||
std::string duration_time() const;
|
||||
|
||||
|
@ -31,7 +31,7 @@ namespace mtb
|
||||
const std::string child_buff() const { return child_buff_; };
|
||||
int coexist_num() const { return coexist_num_; };
|
||||
int dead_valid() const { return dead_valid_; };
|
||||
int buff_interval() const { return buff_interval_; };
|
||||
const std::string buff_interval() const { return buff_interval_; };
|
||||
const std::string tag() const { return tag_; };
|
||||
int post_battle_valid() const { return post_battle_valid_; };
|
||||
const std::string only_spec_race() const { return only_spec_race_; };
|
||||
@ -105,7 +105,7 @@ namespace mtb
|
||||
std::string child_buff_;
|
||||
int coexist_num_ = 0;
|
||||
int dead_valid_ = 0;
|
||||
int buff_interval_ = 0;
|
||||
std::string buff_interval_;
|
||||
std::string tag_;
|
||||
int post_battle_valid_ = 0;
|
||||
std::string only_spec_race_;
|
||||
|
@ -465,7 +465,7 @@ namespace mtb
|
||||
meta_class->SetSimpleField(18, "child_buff", a8::reflect::ET_STRING, my_offsetof2(Buff, child_buff_));
|
||||
meta_class->SetSimpleField(19, "coexist_num", a8::reflect::ET_INT32, my_offsetof2(Buff, coexist_num_));
|
||||
meta_class->SetSimpleField(20, "dead_valid", a8::reflect::ET_INT32, my_offsetof2(Buff, dead_valid_));
|
||||
meta_class->SetSimpleField(21, "buff_interval", a8::reflect::ET_INT32, my_offsetof2(Buff, buff_interval_));
|
||||
meta_class->SetSimpleField(21, "buff_interval", a8::reflect::ET_STRING, my_offsetof2(Buff, buff_interval_));
|
||||
meta_class->SetSimpleField(22, "tag", a8::reflect::ET_STRING, my_offsetof2(Buff, tag_));
|
||||
meta_class->SetSimpleField(23, "post_battle_valid", a8::reflect::ET_INT32, my_offsetof2(Buff, post_battle_valid_));
|
||||
meta_class->SetSimpleField(24, "only_spec_race", a8::reflect::ET_STRING, my_offsetof2(Buff, only_spec_race_));
|
||||
|
@ -367,7 +367,7 @@ message Buff
|
||||
optional string child_buff = 17;
|
||||
optional int32 coexist_num = 18;
|
||||
optional int32 dead_valid = 23;
|
||||
optional int32 buff_interval = 24;
|
||||
optional string buff_interval = 24;
|
||||
optional string tag = 25;
|
||||
optional int32 post_battle_valid = 26;
|
||||
optional string only_spec_race = 27;
|
||||
|
Loading…
x
Reference in New Issue
Block a user