1
This commit is contained in:
parent
9c72db9856
commit
586481482a
@ -1268,25 +1268,6 @@ void Buff::ProcCallFunc()
|
|||||||
switch (meta->int_param1) {
|
switch (meta->int_param1) {
|
||||||
case 1:
|
case 1:
|
||||||
{
|
{
|
||||||
MetaData::Equip* weapon_meta = MetaMgr::Instance()->GetEquip(meta->int_param2);
|
|
||||||
if (weapon_meta) {
|
|
||||||
for (int i = 0; meta->param4_int_list.size(); ++i) {
|
|
||||||
a8::Vec2 bullet_dir = a8::Vec2::UP;
|
|
||||||
bullet_dir.Rotate(meta->param4_int_list[i] / 180.f);
|
|
||||||
a8::Vec2 bullet_born_pos = owner->GetPos() + bullet_dir * meta->param3;
|
|
||||||
int bullet_uniid = owner->room->AllocUniid();
|
|
||||||
owner->room->frame_event.AddBullet
|
|
||||||
(bullet_uniid,
|
|
||||||
owner->GetWeakPtrRef(),
|
|
||||||
weapon_meta,
|
|
||||||
1,
|
|
||||||
bullet_born_pos,
|
|
||||||
bullet_dir,
|
|
||||||
0,
|
|
||||||
0,
|
|
||||||
0);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case 2:
|
case 2:
|
||||||
@ -1320,3 +1301,65 @@ void Buff::ProcRemoveCallFunc()
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void Buff::PreProcess()
|
||||||
|
{
|
||||||
|
switch (meta->i->buff_target()) {
|
||||||
|
case kBET_CallFunc:
|
||||||
|
{
|
||||||
|
switch (meta->int_param1) {
|
||||||
|
case 1:
|
||||||
|
{
|
||||||
|
event_handlers_.push_back
|
||||||
|
(
|
||||||
|
owner->GetTrigger()->AddListener
|
||||||
|
(
|
||||||
|
kTriggerBulletHitBuffEvent,
|
||||||
|
[this] (const std::vector<std::any>& params)
|
||||||
|
{
|
||||||
|
Bullet* bullet = std::any_cast<Bullet*>(params.at(0));
|
||||||
|
ProcSputteringFunc(bullet);
|
||||||
|
}));
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
{
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
{
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void Buff::ProcSputteringFunc(Bullet* bullet)
|
||||||
|
{
|
||||||
|
MetaData::Equip* weapon_meta = MetaMgr::Instance()->GetEquip(meta->int_param2);
|
||||||
|
if (!weapon_meta) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
for (int i = 0; meta->param4_int_list.size(); ++i) {
|
||||||
|
a8::Vec2 bullet_dir = a8::Vec2::UP;
|
||||||
|
bullet_dir.Rotate(meta->param4_int_list[i] / 180.f);
|
||||||
|
a8::Vec2 bullet_born_pos = owner->GetPos() + bullet_dir * meta->param3;
|
||||||
|
int bullet_uniid = owner->room->AllocUniid();
|
||||||
|
owner->room->frame_event.AddBullet
|
||||||
|
(bullet_uniid,
|
||||||
|
owner->GetWeakPtrRef(),
|
||||||
|
weapon_meta,
|
||||||
|
1,
|
||||||
|
bullet_born_pos,
|
||||||
|
bullet_dir,
|
||||||
|
0,
|
||||||
|
0,
|
||||||
|
0);
|
||||||
|
VirtualBullet* bullet = new VirtualBullet();
|
||||||
|
owner->room->AddTask(bullet_uniid, bullet);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
@ -26,6 +26,7 @@ struct RemoveBuffCbConext
|
|||||||
|
|
||||||
class Human;
|
class Human;
|
||||||
class Creature;
|
class Creature;
|
||||||
|
class Bullet;
|
||||||
struct EventHandlerPtr;
|
struct EventHandlerPtr;
|
||||||
struct xtimer_list;
|
struct xtimer_list;
|
||||||
class Buff
|
class Buff
|
||||||
@ -94,10 +95,13 @@ class Buff
|
|||||||
|
|
||||||
void CalcPassengerShotOffset();
|
void CalcPassengerShotOffset();
|
||||||
|
|
||||||
|
void PreProcess();
|
||||||
private:
|
private:
|
||||||
|
void ClearEventHandlers();
|
||||||
void InternalTimerAddBuff();
|
void InternalTimerAddBuff();
|
||||||
void RecoverHoldWeapons();
|
void RecoverHoldWeapons();
|
||||||
void ClearEventHandlers();
|
|
||||||
|
void ProcSputteringFunc(Bullet* bullet);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
int hold_curr_weapon_idx_ = 0;
|
int hold_curr_weapon_idx_ = 0;
|
||||||
|
@ -924,7 +924,6 @@ void Bullet::TriggerHitBuff(Entity* e)
|
|||||||
if (!e->IsDead(room) && e->IsCreature(room)) {
|
if (!e->IsDead(room) && e->IsCreature(room)) {
|
||||||
Creature* c = (Creature*)e;
|
Creature* c = (Creature*)e;
|
||||||
for (int buff_id : gun_meta->hit_buff_list) {
|
for (int buff_id : gun_meta->hit_buff_list) {
|
||||||
|
|
||||||
int buff_uniid = c->TryAddBuff(
|
int buff_uniid = c->TryAddBuff(
|
||||||
sender.Get(),
|
sender.Get(),
|
||||||
buff_id,
|
buff_id,
|
||||||
@ -934,6 +933,7 @@ void Bullet::TriggerHitBuff(Entity* e)
|
|||||||
SkillHelper::ProcBulletHitBuff(this, c, buff_uniid);
|
SkillHelper::ProcBulletHitBuff(this, c, buff_uniid);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
c->GetTrigger()->BulletHitBuff(this);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -186,6 +186,10 @@ int Creature::AddBuff(Creature* caster,
|
|||||||
buff->add_frameno = room->GetFrameNo();
|
buff->add_frameno = room->GetFrameNo();
|
||||||
buff->xtimer_attacher.xtimer = &room->xtimer;
|
buff->xtimer_attacher.xtimer = &room->xtimer;
|
||||||
buff->Init();
|
buff->Init();
|
||||||
|
buff->PreProcess();
|
||||||
|
if (on_add_buff) {
|
||||||
|
on_add_buff(buff);
|
||||||
|
}
|
||||||
if (buff->meta->i->lock_move()) {
|
if (buff->meta->i->lock_move()) {
|
||||||
IncDisableMoveTimes();
|
IncDisableMoveTimes();
|
||||||
}
|
}
|
||||||
|
@ -87,6 +87,7 @@ class Creature : public MoveableEntity
|
|||||||
long long poisoning_time = 0;
|
long long poisoning_time = 0;
|
||||||
bool playing_skill = false;
|
bool playing_skill = false;
|
||||||
int power_idx = -1;
|
int power_idx = -1;
|
||||||
|
std::function<void(Buff*)> on_add_buff;
|
||||||
|
|
||||||
Weapon second_weapon;
|
Weapon second_weapon;
|
||||||
a8::Vec2 context_pos;
|
a8::Vec2 context_pos;
|
||||||
|
@ -470,3 +470,8 @@ void Trigger::FlyHookDestory()
|
|||||||
{
|
{
|
||||||
DispatchEvent(kFlyHookDestoryEvent, {});
|
DispatchEvent(kFlyHookDestoryEvent, {});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void Trigger::BulletHitBuff(Bullet* bullet)
|
||||||
|
{
|
||||||
|
DispatchEvent(kTriggerBulletHitBuffEvent, {bullet});
|
||||||
|
}
|
||||||
|
@ -38,6 +38,7 @@ enum EventId_e
|
|||||||
kFlyHookDestoryEvent,
|
kFlyHookDestoryEvent,
|
||||||
kSkillBulletPreCreateEvent,
|
kSkillBulletPreCreateEvent,
|
||||||
kUseSkillEvent,
|
kUseSkillEvent,
|
||||||
|
kTriggerBulletHitBuffEvent
|
||||||
};
|
};
|
||||||
|
|
||||||
class Weapon;
|
class Weapon;
|
||||||
@ -72,6 +73,7 @@ public:
|
|||||||
void SkillBulletPreCreate(int delay_time, MetaData::Skill* skill_meta);
|
void SkillBulletPreCreate(int delay_time, MetaData::Skill* skill_meta);
|
||||||
void FlyHookCreate(Bullet* bullet);
|
void FlyHookCreate(Bullet* bullet);
|
||||||
void FlyHookDestory();
|
void FlyHookDestory();
|
||||||
|
void BulletHitBuff(Bullet* bullet);
|
||||||
|
|
||||||
std::weak_ptr<EventHandlerPtr> AddListener(int event_id, CommonCbProc cb);
|
std::weak_ptr<EventHandlerPtr> AddListener(int event_id, CommonCbProc cb);
|
||||||
void RemoveEventHandler(std::weak_ptr<EventHandlerPtr> handler_ptr);
|
void RemoveEventHandler(std::weak_ptr<EventHandlerPtr> handler_ptr);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user