修复伪装问题

This commit is contained in:
aozhiwei 2021-07-09 06:20:51 +00:00
parent fc3e2c1c6c
commit 4f7f2b001a
6 changed files with 47 additions and 6 deletions

View File

@ -25,6 +25,7 @@ struct RemoveBuffCbConext
class Human;
class Creature;
struct xtimer_list;
class Buff
{
public:
@ -38,6 +39,7 @@ class Buff
list_head depend_entry;
list_head cond_entry;
list_head on_remove_contexts;
xtimer_list* remover_timer = nullptr;
Buff();
void Init();

View File

@ -83,6 +83,7 @@ enum BuffEffectType_e
kBET_Trace = 62, //追踪玩家
kBET_MountainTop = 63, //在山顶
kBET_UseSkill = 64, //使用技能
kBET_CamouflageAddition = 65, //对抗伪装
kBET_End
};

View File

@ -239,19 +239,26 @@ void Creature::AddBuff(Creature* caster,
list_add_tail(&buff->depend_entry, &depend_effect_[buff->meta->i->depend_effect()]);
}
{
room->xtimer.AddDeadLineTimerAndAttach
buff->remover_timer = room->xtimer.AddDeadLineTimerAndAttach
(
buff_meta->i->duration_time() * SERVER_FRAME_RATE,
a8::XParams()
.SetSender(this)
.SetParam1(buff_meta->i->buff_id()),
.SetParam1(buff_meta->i->buff_id())
.SetParam2(buff),
[] (const a8::XParams& param)
{
Creature* c = (Creature*)param.sender.GetUserData();
c->RemoveBuffById(param.param1);
},
&buff->xtimer_attacher.timer_list_
);
&buff->xtimer_attacher.timer_list_,
[] (const a8::XParams& param)
{
Buff* buff = (Buff*)param.param2.GetUserData();
if (buff->remover_timer) {
buff->remover_timer = nullptr;
}
});
}
GetTrigger()->ActiveBuff(buff->meta);
ProcBuffEffect(caster, buff);
@ -1090,6 +1097,22 @@ void Creature::ProcBuffEffect(Creature* caster, Buff* buff)
}
}
break;
case kBET_CamouflageAddition:
{
Buff* camouflage_buff = GetBuffByEffectId(kBET_Camouflage);
if (camouflage_buff && camouflage_buff->remover_timer && buff->meta->int_param1 > 0) {
int remain_time = room->xtimer.GetRemainTime(camouflage_buff->remover_timer) * FRAME_RATE_MS;
remain_time += buff->meta->int_param1;
room->xtimer.ModifyTimer(camouflage_buff->remover_timer, remain_time / FRAME_RATE_MS);
}
if (buff->meta->int_param2 != 0) {
++camouflage_move_addition_;
}
if (buff->meta->int_param3 != 0) {
++camouflage_aiming_addition_;
}
}
break;
default:
{
}

View File

@ -240,6 +240,9 @@ protected:
Entity* last_collision_door_ = nullptr;
std::array<Inventory, IS_END> buff_inventory_ = {};
int camouflage_move_addition_ = 0;
int camouflage_aiming_addition_ = 0;
private:
CreatureWeakPtr weak_ptr_;
Trigger* trigger_ = nullptr;

View File

@ -3184,6 +3184,18 @@ void Human::OnBuffRemove(Buff& buff)
need_sync_active_player = true;
}
break;
case kBET_CamouflageAddition:
{
if (buff.meta->int_param2 != 0) {
--camouflage_move_addition_;
}
if (buff.meta->int_param3 != 0) {
-camouflage_aiming_addition_;
}
camouflage_move_addition_ = std::max(camouflage_move_addition_, 0);
camouflage_aiming_addition_ = std::max(camouflage_aiming_addition_, 0);
}
break;
default:
{
}

View File

@ -166,7 +166,7 @@ void Player::UpdateMove()
if (HasBuffEffect(kBET_Passenger)) {
return;
}
if (HasBuffEffect(kBET_Camouflage)) {
if (HasBuffEffect(kBET_Camouflage) && camouflage_move_addition_ <= 0) {
RemoveBuffByEffectId(kBET_Camouflage);
}
++moved_frames;
@ -1668,7 +1668,7 @@ void Player::UpdateAiming()
aiming_frameno = room->GetFrameNo();
power_idx = -1;
}
if (HasBuffEffect(kBET_Camouflage)) {
if (HasBuffEffect(kBET_Camouflage) && camouflage_aiming_addition_ <= 0) {
RemoveBuffByEffectId(kBET_Camouflage);
}
Weapon* p_weapon = GetCurrWeapon();