1
This commit is contained in:
parent
a208be87f5
commit
74509caafb
@ -235,3 +235,15 @@ void Bullet::PostAttack()
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void Bullet::ProcMissible(const a8::XParams& param)
|
||||||
|
{
|
||||||
|
Human* sender = (Human*)param.sender.GetUserData();
|
||||||
|
MetaData::Equip* bullet_meta = MetaMgr::Instance()->GetEquip(param.param1);
|
||||||
|
if (sender && bullet_meta) {
|
||||||
|
Human* target = sender->room->GetHumanByUniId(param.param2);
|
||||||
|
if (target && !target->dead) {
|
||||||
|
target->DecHP(10, sender->entity_uniid, sender->name, bullet_meta->i->id());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
@ -28,6 +28,8 @@ class Bullet : public Entity
|
|||||||
virtual void Update(int delta_time) override;
|
virtual void Update(int delta_time) override;
|
||||||
void RecalcSelfCollider();
|
void RecalcSelfCollider();
|
||||||
|
|
||||||
|
static void ProcMissible(const a8::XParams& param);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
|
||||||
void OnHit(std::set<Entity*>& objects);
|
void OnHit(std::set<Entity*>& objects);
|
||||||
|
@ -59,7 +59,7 @@ void FrameEvent::AddShot(Human* hum)
|
|||||||
|
|
||||||
void FrameEvent::AddBullet(Human* hum, int bullet_id, int bullet_lv,
|
void FrameEvent::AddBullet(Human* hum, int bullet_id, int bullet_lv,
|
||||||
a8::Vec2 born_pos, a8::Vec2 dir, float fly_distance,
|
a8::Vec2 born_pos, a8::Vec2 dir, float fly_distance,
|
||||||
int hit_time, int target_id)
|
int hit_time, int target_id, int skill_id)
|
||||||
{
|
{
|
||||||
{
|
{
|
||||||
auto& tuple = a8::FastAppend(bullets_);
|
auto& tuple = a8::FastAppend(bullets_);
|
||||||
@ -73,13 +73,8 @@ void FrameEvent::AddBullet(Human* hum, int bullet_id, int bullet_lv,
|
|||||||
TypeConvert::ToPb(born_pos, p.mutable_pos());
|
TypeConvert::ToPb(born_pos, p.mutable_pos());
|
||||||
TypeConvert::ToPb(dir, p.mutable_dir());
|
TypeConvert::ToPb(dir, p.mutable_dir());
|
||||||
p.set_bulletskin(10001);
|
p.set_bulletskin(10001);
|
||||||
#if 1
|
|
||||||
p.set_gun_id(bullet_id);
|
p.set_gun_id(bullet_id);
|
||||||
p.set_gun_lv(bullet_lv);
|
p.set_gun_lv(bullet_lv);
|
||||||
#else
|
|
||||||
p.set_gun_id(hum->curr_weapon->meta->i->id());
|
|
||||||
p.set_gun_lv(hum->curr_weapon->weapon_lv);
|
|
||||||
#endif
|
|
||||||
p.set_fly_distance(fly_distance);
|
p.set_fly_distance(fly_distance);
|
||||||
if (hit_time != 0) {
|
if (hit_time != 0) {
|
||||||
p.set_hit_time(hit_time);
|
p.set_hit_time(hit_time);
|
||||||
@ -87,6 +82,9 @@ void FrameEvent::AddBullet(Human* hum, int bullet_id, int bullet_lv,
|
|||||||
if (target_id != 0) {
|
if (target_id != 0) {
|
||||||
p.set_target_id(target_id);
|
p.set_target_id(target_id);
|
||||||
}
|
}
|
||||||
|
if (skill_id != 0) {
|
||||||
|
p.set_skill_id(skill_id);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
{
|
{
|
||||||
int bullet_idx = bullets_.size() - 1;
|
int bullet_idx = bullets_.size() - 1;
|
||||||
|
@ -16,7 +16,7 @@ public:
|
|||||||
void AddEmote(Human* hum, int emote_id);
|
void AddEmote(Human* hum, int emote_id);
|
||||||
void AddShot(Human* hum);
|
void AddShot(Human* hum);
|
||||||
void AddBullet(Human* hum, int bullet_id, int bullet_lv, a8::Vec2 born_pos, a8::Vec2 dir,
|
void AddBullet(Human* hum, int bullet_id, int bullet_lv, a8::Vec2 born_pos, a8::Vec2 dir,
|
||||||
float fly_distance, int hit_time, int target_id = 0);
|
float fly_distance, int hit_time, int target_id = 0, int skill_id = 0);
|
||||||
void AddExplosion(int item_id, a8::Vec2 bomb_pos, int effect);
|
void AddExplosion(int item_id, a8::Vec2 bomb_pos, int effect);
|
||||||
void AddSmoke(Bullet* bullet, int item_id, a8::Vec2 pos);
|
void AddSmoke(Bullet* bullet, int item_id, a8::Vec2 pos);
|
||||||
void AddDead(Human* hum);
|
void AddDead(Human* hum);
|
||||||
|
@ -208,7 +208,16 @@ void Human::Shot()
|
|||||||
CancelAction();
|
CancelAction();
|
||||||
}
|
}
|
||||||
|
|
||||||
DirectShot(curr_weapon->meta);
|
DirectShot(curr_weapon->meta, 0);
|
||||||
|
if (curr_weapon->meta->i->equip_subtype() == BulletType_Missile) {
|
||||||
|
room->xtimer.AddDeadLineTimerAndAttach(curr_weapon->meta->i->time() * SERVER_FRAME_RATE,
|
||||||
|
a8::XParams()
|
||||||
|
.SetSender(this)
|
||||||
|
.SetParam1(curr_weapon->meta->i->id())
|
||||||
|
.SetParam2(shot_target_id),
|
||||||
|
Bullet::ProcMissible,
|
||||||
|
&xtimer_attacher.timer_list_);
|
||||||
|
}
|
||||||
--curr_weapon->ammo;
|
--curr_weapon->ammo;
|
||||||
if (curr_weapon->ammo <= 0) {
|
if (curr_weapon->ammo <= 0) {
|
||||||
AutoLoadingBullet();
|
AutoLoadingBullet();
|
||||||
@ -217,7 +226,7 @@ void Human::Shot()
|
|||||||
need_sync_active_player = true;
|
need_sync_active_player = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
void Human::DirectShot(MetaData::Equip* bullet_meta)
|
void Human::DirectShot(MetaData::Equip* bullet_meta, int skill_id)
|
||||||
{
|
{
|
||||||
for (auto& tuple : bullet_meta->bullet_born_offset) {
|
for (auto& tuple : bullet_meta->bullet_born_offset) {
|
||||||
a8::Vec2 bullet_born_offset = a8::Vec2(std::get<0>(tuple), std::get<1>(tuple));
|
a8::Vec2 bullet_born_offset = a8::Vec2(std::get<0>(tuple), std::get<1>(tuple));
|
||||||
@ -246,14 +255,20 @@ void Human::DirectShot(MetaData::Equip* bullet_meta)
|
|||||||
hit_time = bullet_meta->i->time() * 1000;
|
hit_time = bullet_meta->i->time() * 1000;
|
||||||
}
|
}
|
||||||
if (bullet_meta->i->equip_subtype() == BulletType_Missile) {
|
if (bullet_meta->i->equip_subtype() == BulletType_Missile) {
|
||||||
room->frame_event.AddBullet(this, bullet_meta->i->id(),
|
if (skill_id != 0) {
|
||||||
curr_weapon->weapon_lv, bullet_born_pos, bullet_dir,
|
room->frame_event.AddBullet(this, bullet_meta->i->id(),
|
||||||
fly_distance, hit_time, skill_target_id);
|
curr_weapon->weapon_lv, bullet_born_pos, bullet_dir,
|
||||||
|
fly_distance, hit_time, skill_target_id, skill_id);
|
||||||
|
} else {
|
||||||
|
room->frame_event.AddBullet(this, bullet_meta->i->id(),
|
||||||
|
curr_weapon->weapon_lv, bullet_born_pos, bullet_dir,
|
||||||
|
fly_distance, hit_time, shot_target_id);
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
room->frame_event.AddBullet(this, bullet_meta->i->id(),
|
room->frame_event.AddBullet(this, bullet_meta->i->id(),
|
||||||
curr_weapon->weapon_lv,
|
curr_weapon->weapon_lv,
|
||||||
bullet_born_pos, bullet_dir,
|
bullet_born_pos, bullet_dir,
|
||||||
fly_distance, hit_time);
|
fly_distance, hit_time, 0, skill_id);
|
||||||
}
|
}
|
||||||
if (room->BattleStarted()) {
|
if (room->BattleStarted()) {
|
||||||
if (bullet_meta->i->equip_subtype() != BulletType_Missile) {
|
if (bullet_meta->i->equip_subtype() != BulletType_Missile) {
|
||||||
@ -1946,18 +1961,6 @@ void Human::ProcSkillPhase(MetaData::SkillPhase* phase)
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
auto missile_trace_func =
|
|
||||||
[] (const a8::XParams& param)
|
|
||||||
{
|
|
||||||
Human* sender = (Human*)param.sender.GetUserData();
|
|
||||||
MetaData::Equip* bullet_meta = MetaMgr::Instance()->GetEquip(param.param1);
|
|
||||||
if (sender && bullet_meta) {
|
|
||||||
Human* target = sender->room->GetHumanByUniId(param.param2);
|
|
||||||
if (target && !target->dead) {
|
|
||||||
target->DecHP(10, sender->entity_uniid, sender->name, bullet_meta->i->id());
|
|
||||||
}
|
|
||||||
}
|
|
||||||
};
|
|
||||||
auto explosion_check_func =
|
auto explosion_check_func =
|
||||||
[] (const a8::XParams& param)
|
[] (const a8::XParams& param)
|
||||||
{
|
{
|
||||||
@ -2001,14 +2004,14 @@ void Human::ProcSkillPhase(MetaData::SkillPhase* phase)
|
|||||||
{
|
{
|
||||||
MetaData::Equip* bullet_meta = MetaMgr::Instance()->GetEquip(phase->param1.GetInt());
|
MetaData::Equip* bullet_meta = MetaMgr::Instance()->GetEquip(phase->param1.GetInt());
|
||||||
if (bullet_meta) {
|
if (bullet_meta) {
|
||||||
DirectShot(bullet_meta);
|
DirectShot(bullet_meta, skill_meta->i->skill_id());
|
||||||
if (bullet_meta->i->equip_subtype() == BulletType_Missile) {
|
if (bullet_meta->i->equip_subtype() == BulletType_Missile) {
|
||||||
room->xtimer.AddDeadLineTimerAndAttach(bullet_meta->i->time() * SERVER_FRAME_RATE,
|
room->xtimer.AddDeadLineTimerAndAttach(bullet_meta->i->time() * SERVER_FRAME_RATE,
|
||||||
a8::XParams()
|
a8::XParams()
|
||||||
.SetSender(this)
|
.SetSender(this)
|
||||||
.SetParam1(phase->param1.GetInt())
|
.SetParam1(phase->param1.GetInt())
|
||||||
.SetParam2(skill_target_id),
|
.SetParam2(skill_target_id),
|
||||||
missile_trace_func,
|
Bullet::ProcMissible,
|
||||||
&xtimer_attacher.timer_list_);
|
&xtimer_attacher.timer_list_);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -101,6 +101,7 @@ class Human : public Entity
|
|||||||
|
|
||||||
bool shot_start = false;
|
bool shot_start = false;
|
||||||
bool shot_hold = false;
|
bool shot_hold = false;
|
||||||
|
int shot_target_id = 0;
|
||||||
int series_shot_frames = 0;
|
int series_shot_frames = 0;
|
||||||
float fly_distance = 0.0f;
|
float fly_distance = 0.0f;
|
||||||
|
|
||||||
@ -128,7 +129,7 @@ class Human : public Entity
|
|||||||
virtual void GetAabbBox(AabbCollider& aabb_box);
|
virtual void GetAabbBox(AabbCollider& aabb_box);
|
||||||
void FillMFTeamData(cs::MFTeamData* team_data);
|
void FillMFTeamData(cs::MFTeamData* team_data);
|
||||||
void Shot();
|
void Shot();
|
||||||
void DirectShot(MetaData::Equip* bullet_meta);
|
void DirectShot(MetaData::Equip* bullet_meta, int skill_id);
|
||||||
void RecalcSelfCollider();
|
void RecalcSelfCollider();
|
||||||
bool IsCollision();
|
bool IsCollision();
|
||||||
bool IsCollisionInMapService();
|
bool IsCollisionInMapService();
|
||||||
|
@ -131,11 +131,13 @@ void Player::UpdateShot()
|
|||||||
shot_start = false;
|
shot_start = false;
|
||||||
shot_hold = false;
|
shot_hold = false;
|
||||||
series_shot_frames = 0;
|
series_shot_frames = 0;
|
||||||
|
shot_target_id = 0;
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (shot_start) {
|
if (shot_start) {
|
||||||
shot_start = false;
|
shot_start = false;
|
||||||
Shot();
|
Shot();
|
||||||
|
shot_target_id = 0;
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (shot_hold) {
|
if (shot_hold) {
|
||||||
@ -150,6 +152,7 @@ void Player::UpdateShot()
|
|||||||
if (series_shot_frames > 8) {
|
if (series_shot_frames > 8) {
|
||||||
shot_hold = false;
|
shot_hold = false;
|
||||||
series_shot_frames = 0;
|
series_shot_frames = 0;
|
||||||
|
shot_target_id = 0;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -401,6 +404,7 @@ void Player::_CMMove(f8::MsgHdr& hdr, const cs::CMMove& msg)
|
|||||||
}
|
}
|
||||||
shot_start = msg.shot_start();
|
shot_start = msg.shot_start();
|
||||||
shot_hold = msg.shot_hold();
|
shot_hold = msg.shot_hold();
|
||||||
|
shot_target_id = msg.shot_target_id();
|
||||||
fly_distance = std::min(200.0f, msg.fly_distance());
|
fly_distance = std::min(200.0f, msg.fly_distance());
|
||||||
if (!shot_hold) {
|
if (!shot_hold) {
|
||||||
series_shot_frames = 0;
|
series_shot_frames = 0;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user