This commit is contained in:
aozhiwei 2023-03-17 19:36:14 +08:00
parent 5d8d90658d
commit c17c6e77e9
5 changed files with 21 additions and 11 deletions

View File

@ -68,7 +68,7 @@ void CondAddBuff::ProcBulletHit()
(const a8::Args& args) (const a8::Args& args)
{ {
IBullet* bullet = args.Get<IBullet*>(0); IBullet* bullet = args.Get<IBullet*>(0);
Creature* c = args.Get<Creature*>(0); Creature* c = args.Get<Creature*>(1);
if (context->last_hit_frameno > 0 && if (context->last_hit_frameno > 0 &&
c->room->GetFrameNo() - context->last_hit_frameno > interval_time * SERVER_FRAME_RATE) { c->room->GetFrameNo() - context->last_hit_frameno > interval_time * SERVER_FRAME_RATE) {
context->hited_times = 0; context->hited_times = 0;

View File

@ -2732,6 +2732,7 @@ void Creature::OnLand()
} }
} }
} }
gun_grasp_->Init();
} }
void Creature::CheckBulletHitHoldShield(IBullet* bullet, bool& eat) void Creature::CheckBulletHitHoldShield(IBullet* bullet, bool& eat)
@ -3027,5 +3028,4 @@ float Creature::GetSkillRaycastDistance()
void Creature::NetInitOk() void Creature::NetInitOk()
{ {
gun_grasp_->Init();
} }

View File

@ -26,6 +26,7 @@ GunGrasp::~GunGrasp()
void GunGrasp::Init() void GunGrasp::Init()
{ {
if (owner_->IsHuman()) { if (owner_->IsHuman()) {
TakeOnWeapon(owner_->GetCurrWeapon());
owner_->GetTrigger()->AddListener owner_->GetTrigger()->AddListener
( (
kTakeonWeaponEvent, kTakeonWeaponEvent,
@ -33,15 +34,7 @@ void GunGrasp::Init()
{ {
Weapon* old_weapon = args.Get<Weapon*>(0); Weapon* old_weapon = args.Get<Weapon*>(0);
Weapon* new_weapon = args.Get<Weapon*>(1); Weapon* new_weapon = args.Get<Weapon*>(1);
std::set<int>* buffs = mt::Grasp::GetBuffs(owner_->AsHuman()->meta->id(), TakeOnWeapon(new_weapon);
owner_->GetBattleContext()->GetLevel(),
new_weapon->meta->id());
Clear();
if (buffs) {
for (int buff_id : *buffs) {
owner_->TryAddBuff(owner_, buff_id, nullptr);
}
}
} }
); );
} }
@ -54,3 +47,16 @@ void GunGrasp::Clear()
} }
hold_buffs_.clear(); hold_buffs_.clear();
} }
void GunGrasp::TakeOnWeapon(Weapon* weapon)
{
std::set<int>* buffs = mt::Grasp::GetBuffs(owner_->AsHuman()->meta->id(),
owner_->GetBattleContext()->GetLevel(),
weapon->meta->id());
Clear();
if (buffs) {
for (int buff_id : *buffs) {
owner_->TryAddBuff(owner_, buff_id, nullptr);
}
}
}

View File

@ -16,6 +16,7 @@ class GunGrasp
private: private:
void Clear(); void Clear();
void TakeOnWeapon(Weapon* weapon);
private: private:
Creature* owner_ = nullptr; Creature* owner_ = nullptr;

View File

@ -439,6 +439,9 @@ void Trigger::DispatchEvent(int event_id, const std::vector<std::any>& param)
void Trigger::BulletHit(IBullet* bullet, Creature* target) void Trigger::BulletHit(IBullet* bullet, Creature* target)
{ {
if (bullet->GetSender().Get()) { if (bullet->GetSender().Get()) {
if (bullet->GetSender().Get()->IsPlayer()) {
int i = 0;
}
bullet->GetSender().Get()->GetTrigger()->DispatchEvent(kBulletHitEvent, {bullet, target}); bullet->GetSender().Get()->GetTrigger()->DispatchEvent(kBulletHitEvent, {bullet, target});
} }
} }