This commit is contained in:
aozhiwei 2020-05-13 15:18:53 +08:00
parent 016cea1b76
commit 6ba0c3cd3d
5 changed files with 72 additions and 17 deletions

View File

@ -51,7 +51,8 @@ void Bullet::OnHit(std::set<Entity*>& objects)
return; return;
} }
Human* hum = (Human*)target; Human* hum = (Human*)target;
if (hum->HasBuffEffect(kBET_Invincible)) { if (hum->HasBuffEffect(kBET_Invincible) ||
hum->HasBuffEffect(kBET_LordMode)) {
continue; continue;
} }
#if 1 #if 1
@ -61,12 +62,14 @@ void Bullet::OnHit(std::set<Entity*>& objects)
(hum->team_id == 0 || player->team_id != hum->team_id)) { (hum->team_id == 0 || player->team_id != hum->team_id)) {
#endif #endif
#if 1 #if 1
float dmg = gun_meta->i->atk() * (1 + player->atk_add); float dmg = gun_meta->i->atk() * (1 + hum->GetBuffAttrRate(kHAT_Atk)) +
hum->GetBuffAttrAbs(kHAT_Atk);
#else #else
float dmg = gun_meta->i->atk() * (1 + player->buff.damage_add + player->atk_add); float dmg = gun_meta->i->atk() * (1 + player->buff.damage_add + player->atk_add);
#endif #endif
#if 1 #if 1
float def = hum->ability.def; float def = hum->ability.def * (1 + hum->GetBuffAttrRate(kHAT_Def)) +
hum->GetBuffAttrAbs(kHAT_Def);
#else #else
float def = hum->def + hum->buff.def_add; float def = hum->def + hum->buff.def_add;
#endif #endif

View File

@ -2915,6 +2915,22 @@ void Human::DecItem(int item_id, int item_num)
} }
} }
float Human::GetBuffAttrAbs(int attr_type)
{
if (IsValidHumanAttr(attr_type)) {
return buff_attr_abs_[attr_type];
}
return 0;
}
float Human::GetBuffAttrRate(int attr_type)
{
if (IsValidHumanAttr(attr_type)) {
return buff_attr_rate_[attr_type];
}
return 0;
}
void Human::RecalcBuffAttr() void Human::RecalcBuffAttr()
{ {
buff_attr_abs_ = {}; buff_attr_abs_ = {};

View File

@ -134,6 +134,7 @@ class Human : public Entity
a8::Vec2 skill_target_pos; a8::Vec2 skill_target_pos;
float skill_param1 = 0; float skill_param1 = 0;
bool playing_skill = false; bool playing_skill = false;
xtimer_list* ad_timer_ = nullptr;
Human(); Human();
virtual ~Human() override; virtual ~Human() override;
@ -243,6 +244,8 @@ class Human : public Entity
int GetItemNum(int item_id); int GetItemNum(int item_id);
void AddItem(int item_id, int item_num); void AddItem(int item_id, int item_num);
void DecItem(int item_id, int item_num); void DecItem(int item_id, int item_num);
float GetBuffAttrAbs(int attr_id);
float GetBuffAttrRate(int attr_id);
protected: protected:
void _UpdateMove(int speed); void _UpdateMove(int speed);
@ -307,7 +310,6 @@ protected:
HumanCar car_; HumanCar car_;
MetaData::Skill* skill_meta_ = nullptr; MetaData::Skill* skill_meta_ = nullptr;
xtimer_list* ad_timer_ = nullptr;
private: private:
CircleCollider* self_collider_ = nullptr; CircleCollider* self_collider_ = nullptr;

View File

@ -1228,6 +1228,10 @@ void Player::_CMAdStart(f8::MsgHdr& hdr, const cs::CMAdStart& msg)
if (GetBuffByEffectId(kBET_AdPlaying)) { if (GetBuffByEffectId(kBET_AdPlaying)) {
return; return;
} }
if (ad_timer_) {
room->xtimer.DeleteTimer(ad_timer_);
ad_timer_ = nullptr;
}
MetaData::Buff* buff_meta = MetaMgr::Instance()->GetBuff(ADPLAY_BUFFID); MetaData::Buff* buff_meta = MetaMgr::Instance()->GetBuff(ADPLAY_BUFFID);
if (buff_meta) { if (buff_meta) {
AddBuff(buff_meta, 1); AddBuff(buff_meta, 1);
@ -1238,12 +1242,14 @@ void Player::_CMAdStart(f8::MsgHdr& hdr, const cs::CMAdStart& msg)
.SetSender(this), .SetSender(this),
[] (const a8::XParams& param) [] (const a8::XParams& param)
{ {
Player* hum = (Player*)param.sender.GetUserData();
hum->InternalAdCancel();
}, },
&xtimer_attacher.timer_list, &xtimer_attacher.timer_list_,
[] (const a8::XParams& param) [] (const a8::XParams& param)
{ {
Human* hum = (Human*)param.sender.GetUserData();
hum->ad_timer_ = nullptr;
} }
); );
} }
@ -1251,19 +1257,45 @@ void Player::_CMAdStart(f8::MsgHdr& hdr, const cs::CMAdStart& msg)
void Player::_CMAdCancel(f8::MsgHdr& hdr, const cs::CMAdCancel& msg) void Player::_CMAdCancel(f8::MsgHdr& hdr, const cs::CMAdCancel& msg)
{ {
if (GetBuffByEffectId(kBET_LordMode)) { InternalAdCancel();
return;
}
if (GetBuffByEffectId(kBET_AdPlaying)) {
RemoveBuffByEffectId(kBET_AdPlaying);
if (ad_timer_) {
room->xtimer.DeleteTimer(ad_timer_);
ad_timer_ = nullptr;
}
}
} }
void Player::_CMAdEnd(f8::MsgHdr& hdr, const cs::CMAdEnd& msg) void Player::_CMAdEnd(f8::MsgHdr& hdr, const cs::CMAdEnd& msg)
{
if (GetBuffByEffectId(kBET_LordMode)) {
return;
}
if (GetBuffByEffectId(kBET_AdPlaying)) {
MetaData::Buff* buff_meta = MetaMgr::Instance()->GetBuff(ADPLAY_BUFFID);
if (buff_meta) {
MetaData::Buff* lord_buff_meta = nullptr;
if (msg.param() == 1) {
lord_buff_meta = MetaMgr::Instance()->GetBuff(buff_meta->param1);
} else if (msg.param() == 2) {
lord_buff_meta = MetaMgr::Instance()->GetBuff(buff_meta->param2);
}
if (lord_buff_meta) {
AddBuff(lord_buff_meta, 1);
std::vector<std::string> strings;
a8::Split(lord_buff_meta->i->buff_param1(), strings, ':');
for (auto& str : strings) {
int buff_id = a8::XValue(str);
MetaData::Buff* ext_buff_meta = MetaMgr::Instance()->GetBuff(buff_id);
if (ext_buff_meta) {
AddBuff(ext_buff_meta, 1);
}
}
}
}
RemoveBuffByEffectId(kBET_AdPlaying);
if (ad_timer_) {
room->xtimer.DeleteTimer(ad_timer_);
ad_timer_ = nullptr;
}
}
}
void Player::InternalAdCancel()
{ {
if (GetBuffByEffectId(kBET_LordMode)) { if (GetBuffByEffectId(kBET_LordMode)) {
return; return;

View File

@ -99,4 +99,6 @@ class Player : public Human
void _CMAdCancel(f8::MsgHdr& hdr, const cs::CMAdCancel& msg); void _CMAdCancel(f8::MsgHdr& hdr, const cs::CMAdCancel& msg);
void _CMAdEnd(f8::MsgHdr& hdr, const cs::CMAdEnd& msg); void _CMAdEnd(f8::MsgHdr& hdr, const cs::CMAdEnd& msg);
private:
void InternalAdCancel();
}; };