AddGunBuff

This commit is contained in:
aozhiwei 2021-06-29 09:09:22 +00:00
parent 7aea36967d
commit 84adf74342
5 changed files with 27 additions and 48 deletions

View File

@ -382,34 +382,12 @@ void Bullet::ProcFragBomb(int delay_time)
void Bullet::ProcPosionGasBomb(int delay_time) void Bullet::ProcPosionGasBomb(int delay_time)
{ {
if (sender.Get()) { AddGunBuff();
a8::Vec2 old_buff_vec2_param1 = sender.Get()->buff_vec2_param1;
sender.Get()->buff_vec2_param1 = GetPos();
MetaData::Buff * buff_meta = MetaMgr::Instance()->GetBuff(gun_meta->i->buffid());
if (buff_meta) {
sender.Get()->AddBuff(sender.Get(),
buff_meta,
1
);
}
sender.Get()->buff_vec2_param1 = old_buff_vec2_param1;
}
} }
void Bullet::ProcMolotorCocktailBomb(int delay_time) void Bullet::ProcMolotorCocktailBomb(int delay_time)
{ {
if (sender.Get()) { AddGunBuff();
a8::Vec2 old_buff_vec2_param1 = sender.Get()->buff_vec2_param1;
sender.Get()->buff_vec2_param1 = GetPos();
MetaData::Buff * buff_meta = MetaMgr::Instance()->GetBuff(gun_meta->i->buffid());
if (buff_meta) {
sender.Get()->AddBuff(sender.Get(),
buff_meta,
1
);
}
sender.Get()->buff_vec2_param1 = old_buff_vec2_param1;
}
} }
void Bullet::ProcC4Bomb(Car* target, int delay_time) void Bullet::ProcC4Bomb(Car* target, int delay_time)
@ -446,34 +424,12 @@ void Bullet::ProcC4Bomb(Car* target, int delay_time)
void Bullet::ProcSignalGunBomb(int delay_time) void Bullet::ProcSignalGunBomb(int delay_time)
{ {
if (sender.Get()) { AddGunBuff();
a8::Vec2 old_buff_vec2_param1 = sender.Get()->buff_vec2_param1;
sender.Get()->buff_vec2_param1 = GetPos();
MetaData::Buff * buff_meta = MetaMgr::Instance()->GetBuff(gun_meta->i->buffid());
if (buff_meta) {
sender.Get()->AddBuff(sender.Get(),
buff_meta,
1
);
}
sender.Get()->buff_vec2_param1 = old_buff_vec2_param1;
}
} }
void Bullet::ProcShieldWallBomb(int delay_time) void Bullet::ProcShieldWallBomb(int delay_time)
{ {
if (sender.Get()) { AddGunBuff();
a8::Vec2 old_buff_vec2_param1 = sender.Get()->buff_vec2_param1;
sender.Get()->buff_vec2_param1 = GetPos();
MetaData::Buff * buff_meta = MetaMgr::Instance()->GetBuff(gun_meta->i->buffid());
if (buff_meta) {
sender.Get()->AddBuff(sender.Get(),
buff_meta,
1
);
}
sender.Get()->buff_vec2_param1 = old_buff_vec2_param1;
}
} }
void Bullet::ProcOilBucketBomb(int delay_time) void Bullet::ProcOilBucketBomb(int delay_time)
@ -487,3 +443,21 @@ bool Bullet::IsCurrWeapon()
{ {
return sender.Get()->GetCurrWeapon()->meta == gun_meta; return sender.Get()->GetCurrWeapon()->meta == gun_meta;
} }
void Bullet::AddGunBuff()
{
if (sender.Get()) {
std::shared_ptr<Ability> old_context_ability = sender.Get()->context_ability;
a8::Vec2 old_buff_vec2_param1 = sender.Get()->buff_vec2_param1;
sender.Get()->buff_vec2_param1 = GetPos();
MetaData::Buff * buff_meta = MetaMgr::Instance()->GetBuff(gun_meta->i->buffid());
if (buff_meta) {
sender.Get()->AddBuff(sender.Get(),
buff_meta,
1
);
}
sender.Get()->buff_vec2_param1 = old_buff_vec2_param1;
sender.Get()->context_ability = old_context_ability;
}
}

View File

@ -58,6 +58,7 @@ protected:
void ProcOilBucketBomb(int delay_time); void ProcOilBucketBomb(int delay_time);
inline void MapServiceUpdate(); inline void MapServiceUpdate();
void Check(float distance); void Check(float distance);
void AddGunBuff();
private: private:
CircleCollider* self_collider_ = nullptr; CircleCollider* self_collider_ = nullptr;

View File

@ -1585,6 +1585,7 @@ void Creature::SummonObstacle(Buff* buff, int id, const a8::Vec2& pos)
obstacle->SetTeamId(room, team_id); obstacle->SetTeamId(room, team_id);
obstacle->SetMasterId(room, GetUniId()); obstacle->SetMasterId(room, GetUniId());
obstacle->Active(); obstacle->Active();
obstacle->context_ability = context_ability;
slave_things_.push_back(std::make_tuple(buff->meta->i->buff_id(), obstacle)); slave_things_.push_back(std::make_tuple(buff->meta->i->buff_id(), obstacle));
} else { } else {
abort(); abort();

View File

@ -70,6 +70,7 @@ class Creature : public MoveableEntity
Weapon second_weapon; Weapon second_weapon;
a8::Vec2 buff_vec2_param1; a8::Vec2 buff_vec2_param1;
std::shared_ptr<Ability> context_ability;
bool need_sync_active_player = false; bool need_sync_active_player = false;
std::function<void ()> on_loading_bullet; std::function<void ()> on_loading_bullet;

View File

@ -4,6 +4,7 @@
#include "obstacle.h" #include "obstacle.h"
#include "weakptr.h" #include "weakptr.h"
class Ability;
class RoomObstacle : public Obstacle class RoomObstacle : public Obstacle
{ {
public: public:
@ -13,6 +14,7 @@ class RoomObstacle : public Obstacle
bool is_terminator_airdrop_box = false; bool is_terminator_airdrop_box = false;
CreatureWeakPtr master; CreatureWeakPtr master;
int real_object_uniid = 0; int real_object_uniid = 0;
std::shared_ptr<Ability> context_ability;
virtual ~RoomObstacle() override; virtual ~RoomObstacle() override;
virtual void Initialize() override; virtual void Initialize() override;