This commit is contained in:
aozhiwei 2022-10-13 12:47:10 +08:00
parent b8b357410c
commit c5bb28dc12
9 changed files with 103 additions and 67 deletions

View File

@ -216,26 +216,6 @@ int Ability::GetDefAdditionTimes()
return def_addition_times_;
}
void Ability::IncImmuneVertigo()
{
++immune_vertigo_times_;
}
void Ability::DecImmuneVertigo()
{
--immune_vertigo_times_;
#ifdef DEBUG
if (immune_vertigo_times_ < 0) {
abort();
}
#endif
}
int Ability::GetImmuneVertigoTimes()
{
return immune_vertigo_times_;
}
void Ability::AddAtkAddition(float rate)
{
atk_addition_rate_ += rate;
@ -263,3 +243,41 @@ int Ability::GetAtkAdditionTimes()
{
return atk_addition_times_;
}
void Ability::IncImmuneTimes(int tag)
{
auto itr = immune_tags_.find(tag);
if (itr != immune_tags_.end()) {
--itr->second;
if (itr->second <= 0) {
immune_tags_.erase(itr);
}
}
}
void Ability::DecImmuneTimes(int tag)
{
auto itr = immune_tags_.find(tag);
if (itr != immune_tags_.end()) {
++itr->second;
} else {
immune_tags_[tag] = 1;
}
}
bool Ability::CanImmune(int tag)
{
return immune_tags_.find(tag) != immune_tags_.end();
}
bool Ability::CanImmune(const std::set<int>& tags)
{
if (!immune_tags_.empty()) {
for (int tag : tags) {
if (CanImmune(tag)) {
return true;
}
}
}
return false;
}

View File

@ -41,9 +41,10 @@ class Ability
float GetAtkAddition();
int GetAtkAdditionTimes();
void IncImmuneVertigo();
void DecImmuneVertigo();
int GetImmuneVertigoTimes();
void IncImmuneTimes(int tag);
void DecImmuneTimes(int tag);
bool CanImmune(int tag);
bool CanImmune(const std::set<int>& tags);
private:
std::array<float, kHAT_End> buff_attr_abs_ = {};
@ -65,6 +66,6 @@ class Ability
int atk_addition_times_ = 0;
float atk_addition_rate_ = 0;
int immune_vertigo_times_ = 0;
std::map<int, int> immune_tags_;
};

View File

@ -1241,3 +1241,17 @@ void Buff::ProcRemoveRescuer()
owner->GetTrigger()->EndRescue(target);
}
}
void Buff::ProcImmune()
{
for (int tag : meta->param1_int_list) {
owner->GetAbility()->IncImmuneTimes(tag);
}
}
void Buff::ProcRemoveImmune()
{
for (int tag : meta->param1_int_list) {
owner->GetAbility()->DecImmuneTimes(tag);
}
}

View File

@ -87,6 +87,8 @@ class Buff
void ProcRemoveHide();
void ProcRescuer();
void ProcRemoveRescuer();
void ProcImmune();
void ProcRemoveImmune();
void CalcPassengerShotOffset();

View File

@ -919,28 +919,10 @@ void Bullet::TriggerHitBuff(Entity* e)
if (!e->IsDead(room) && e->IsCreature(room)) {
Creature* c = (Creature*)e;
for (int buff_id : gun_meta->hit_buff_list) {
MetaData::Buff* buff_meta = MetaMgr::Instance()->GetBuff(buff_id);
if (buff_meta) {
if (c->GetAbility()->GetImmuneVertigoTimes() > 0 &&
buff_meta->i->buff_effect() == kBET_Vertigo) {
#ifdef DEBUG
{
std::string dbg_msg = a8::Format
(
"免疫眩晕 target_uniid:%d ImmuneVertigoTimes:%d",
{
c->GetUniId(),
c->GetAbility()->GetImmuneVertigoTimes()
});
sender.Get()->SendDebugMsg(dbg_msg);
a8::XPrintf("%s\n", {dbg_msg});
}
#endif
continue;
}
int buff_uniid = c->AddBuff(
int buff_uniid = c->TryAddBuff(
sender.Get(),
buff_meta,
buff_id,
skill_meta
);
if (skill_meta && buff_uniid) {
@ -949,7 +931,6 @@ void Bullet::TriggerHitBuff(Entity* e)
}
}
}
}
bool Bullet::IsFlyHook()
{

View File

@ -20,6 +20,7 @@ const int kPeaceModeBuffId = 7019;
const int kInRescueBuffId = 7020;
const int kKeepShotAnimiBuffId = 7021;
const int kVertigoEffectBuffId = 7022;
const int kDispelEffectBuffId = 7023;
const int kPullToWalkableBuffId = 8003;
const int kDiveBuffId = 8054;
const int kInvincibleBuffId = 1005;
@ -32,7 +33,7 @@ enum BuffEffectType_e
kBET_Car = 3, //骑乘
kBET_Invincible = 4, //无敌
kBET_Camouflage = 5, //伪装
kBET_AdPlaying = 6, //看广告中
kBET_Immune = 6, //免疫
kBET_LordMode = 7, //上帝模式
kBET_NewProtect = 8, //新手保护血量低于50%
kBET_BePull = 9, //拉人(被拉方)

View File

@ -119,6 +119,9 @@ int Creature::AddBuff(Creature* caster,
return 0;
}
}
if (!buff_meta->tags.empty() && GetAbility()->CanImmune(buff_meta->tags)) {
return 0;
}
if (buff_meta->i->buff_interval() > 0) {
if (buff_interval_hash_.find(buff_meta->i->buff_id()) != buff_interval_hash_.end()) {
return 0;
@ -527,6 +530,11 @@ void Creature::OnBuffRemove(Buff& buff)
buff.ProcRemoveRescuer();
}
break;
case kBET_Immune:
{
buff.ProcRemoveImmune();
}
break;
default:
{
}
@ -1245,6 +1253,11 @@ void Creature::ProcBuffEffect(Creature* caster, Buff* buff)
buff->ProcRescuer();
}
break;
case kBET_Immune:
{
buff->ProcImmune();
}
break;
case kBET_SummonObstacle:
{
if (!dead || buff->meta->i->dead_valid() != 0) {
@ -2354,7 +2367,6 @@ bool Creature::IsInvincible()
{
return
HasBuffEffect(kBET_Invincible) ||
HasBuffEffect(kBET_AdPlaying) ||
HasBuffEffect(kBET_Driver) ||
HasBuffEffect(kBET_Passenger)
;

View File

@ -743,6 +743,7 @@ void Player::_CMReconnect(f8::MsgHdr& hdr, const cs::CMReconnect& msg)
void Player::_CMMove(f8::MsgHdr& hdr, const cs::CMMove& msg)
{
long long pre_frameno = last_cmmove_frameno_;
last_cmmove_frameno_ = room->GetFrameNo();
moving = false;
if (msg.has_move_dir()) {
@ -808,9 +809,13 @@ void Player::_CMMove(f8::MsgHdr& hdr, const cs::CMMove& msg)
}
}
}
#if 1
moved_frames = 0;
#else
if (moving) {
moved_frames = 0;
}
#endif
//前一个状态是纯点射
if (shot_start && !shot_hold) {
@ -902,6 +907,16 @@ void Player::_CMMove(f8::MsgHdr& hdr, const cs::CMMove& msg)
}
last_cmmove_frameno = room->GetFrameNo();
trace_target_uniid = msg.trace_target_uniid();
#ifdef DEBUG1
a8::XPrintf("move_dir:%f %f frameno:%d %d moving:%d\n",
{
msg.move_dir().x(),
msg.move_dir().y(),
pre_frameno,
room->GetFrameNo(),
moving ? 1 : 0
});
#endif
#ifdef DEBUG1
if (msg.has_drop_weapon()) {
SendDebugMsg(a8::Format("zzzzzzzz frameno:%d drop_weapon:%d", {room->GetFrameNo(), msg.drop_weapon()}));

View File

@ -310,7 +310,8 @@ void Skill::ProcSJXY()
bool is_immune = false;
if (shot_times % meta->number_meta->int_ratio == 0) {
if ((rnd % 100) < meta->number_meta->float_probability * 100) {
if (target->GetAbility()->GetImmuneVertigoTimes() > 0) {
MetaData::Buff* buff_meta = MetaMgr::Instance()->GetBuff(kVertigoEffectBuffId);
if (buff_meta && target->GetAbility()->CanImmune(buff_meta->tags)) {
is_immune = true;
} else {
auto itr = hited_objs.find(target->GetUniId());
@ -500,15 +501,10 @@ void Skill::ProcSWZB()
}
int buff_id = SkillHelper::GetSwzbBuffId(skill_meta);
float buff_time = SkillHelper::GetSwzbBuffTime(skill_meta);
MetaData::Buff* buff_meta = MetaMgr::Instance()->GetBuff(buff_id);
if (c->GetAbility()->GetImmuneVertigoTimes() > 0 &&
buff_meta->i->buff_effect() == kBET_Vertigo) {
} else {
c->TryAddBuffAndSetTime(sender.Get(), buff_id, buff_time);
}
}
}
}
);
e->EnemyAndObstacleAttack
(
@ -577,14 +573,12 @@ void Skill::ProcCMXD()
dir * SkillHelper::GetCmxdDistance(skill_meta);
c->PullTarget(target_pos);
}
if (c->GetAbility()->GetImmuneVertigoTimes() <= 0) {
c->TryAddBuffAndSetTime(sender.Get(),
kVertigoEffectBuffId,
SkillHelper::GetCmxdVertigoTime(skill_meta) * 1000);
}
}
}
}
);
e->EnemyAndObstacleAttack
(
@ -629,7 +623,6 @@ void Skill::ProcMYXY()
return;
}
owner->GetAbility()->AddSpeedAddition(speed_rate);
owner->GetAbility()->IncImmuneVertigo();
}
);
owner->GetTrigger()->AddListener
@ -642,7 +635,6 @@ void Skill::ProcMYXY()
return;
}
owner->GetAbility()->DelSpeedAddition(speed_rate);
owner->GetAbility()->DecImmuneVertigo();
}
);
#ifdef DEBUG