1
This commit is contained in:
commit
fd2a5b8640
@ -51,9 +51,11 @@ void Bullet::Initialize()
|
||||
|
||||
void Bullet::Update(int delta_time)
|
||||
{
|
||||
if (!trace_target_id) {
|
||||
MapServiceUpdate();
|
||||
++updated_times_;
|
||||
if (shot_animi_time <= (room->GetFrameNo() - create_frameno_) * FRAME_RATE_MS) {
|
||||
if (!trace_target_id) {
|
||||
MapServiceUpdate();
|
||||
++updated_times_;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -79,7 +81,10 @@ void Bullet::OnHit(std::set<Entity*>& objects)
|
||||
if (IsFlyHook()) {
|
||||
if (sender.Get() && !sender.Get()->dead) {
|
||||
for (auto& target : objects) {
|
||||
ProcFlyHook(target);
|
||||
if (target->IsCreature(room) &&
|
||||
!((Creature*)target)->IsCar()) {
|
||||
ProcFlyHook(target);
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
@ -627,7 +632,19 @@ void Bullet::Check(float distance)
|
||||
sender.Get()->IncDisableAttackDirTimes();
|
||||
sender.Get()->room->xtimer.AddDeadLineTimerAndAttach
|
||||
(
|
||||
(0.2 + distance / gun_meta->i->bullet_speed() / 2) * SERVER_FRAME_RATE,
|
||||
(distance / gun_meta->i->bullet_speed() / 2) * SERVER_FRAME_RATE,
|
||||
a8::XParams()
|
||||
.SetSender(sender.Get()),
|
||||
[] (const a8::XParams& param)
|
||||
{
|
||||
Creature* c = (Creature*)param.sender.GetUserData();
|
||||
c->RemoveBuffById(kKeepShotAnimiBuffId);
|
||||
},
|
||||
&sender.Get()->xtimer_attacher.timer_list_
|
||||
);
|
||||
sender.Get()->room->xtimer.AddDeadLineTimerAndAttach
|
||||
(
|
||||
(0.75 + distance / gun_meta->i->bullet_speed() / 2) * SERVER_FRAME_RATE,
|
||||
a8::XParams()
|
||||
.SetSender(sender.Get()),
|
||||
[] (const a8::XParams& param)
|
||||
@ -635,7 +652,6 @@ void Bullet::Check(float distance)
|
||||
Creature* c = (Creature*)param.sender.GetUserData();
|
||||
c->DecDisableMoveTimes();
|
||||
c->DecDisableAttackDirTimes();
|
||||
c->RemoveBuffById(kKeepShotAnimiBuffId);
|
||||
},
|
||||
&sender.Get()->xtimer_attacher.timer_list_
|
||||
);
|
||||
@ -841,15 +857,25 @@ void Bullet::ProcFlyHook(Entity* target)
|
||||
if (target->IsCreature(room)) {
|
||||
Creature* c = (Creature*)target;
|
||||
room->frame_event.AddPropChg(c->GetWeakPtrRef(), kPropBeHook, 0, sender.Get()->GetUniId());
|
||||
c->AutoNavigation(born_pos, gun_meta->i->bullet_speed() * 2);
|
||||
int buff_uniid = c->TryAddBuff(c, gun_meta->i->buffid());
|
||||
c->AutoNavigation(born_pos, gun_meta->i->bullet_speed() * 2,
|
||||
[buff_uniid] (Creature* c)
|
||||
{
|
||||
c->RemoveBuffByUniId(buff_uniid);
|
||||
}
|
||||
);
|
||||
} else {
|
||||
sender.Get()->AutoNavigation(GetPos(), gun_meta->i->bullet_speed() * 2);
|
||||
sender.Get()->AutoNavigation(GetPos(), gun_meta->i->bullet_speed() * 2,
|
||||
[] (Creature* c)
|
||||
{
|
||||
|
||||
});
|
||||
}
|
||||
|
||||
sender.Get()->IncDisableMoveTimes();
|
||||
sender.Get()->room->xtimer.AddDeadLineTimerAndAttach
|
||||
(
|
||||
(distance / gun_meta->i->bullet_speed() / 2) * SERVER_FRAME_RATE,
|
||||
(distance / gun_meta->i->bullet_speed() / 2 + 0.75) * SERVER_FRAME_RATE,
|
||||
a8::XParams()
|
||||
.SetSender(sender.Get()),
|
||||
[] (const a8::XParams& param)
|
||||
|
@ -36,6 +36,7 @@ class Bullet : public MoveableEntity
|
||||
float strengthen_wall = 0;
|
||||
int hand = 0;
|
||||
std::weak_ptr<a8::XTimerPtr> keep_shot_animi_timer_ptr;
|
||||
float shot_animi_time = 0.0f;
|
||||
|
||||
virtual ~Bullet() override;
|
||||
virtual void Initialize() override;
|
||||
|
@ -50,7 +50,9 @@ class Car : public Creature
|
||||
virtual void SendDebugMsg(const std::string& debug_msg) override;
|
||||
virtual void SetAttackDir(const a8::Vec2& attack_dir) override;
|
||||
virtual void DropItems(Obstacle* obstacle) override;
|
||||
virtual const a8::Vec2& GetShotDir() { return curr_shot_dir_; };
|
||||
void OnKillTarget(Creature* target);
|
||||
void SetShotDir(const a8::Vec2& dir) { curr_shot_dir_ = dir; };
|
||||
|
||||
private:
|
||||
int AllocSeat();
|
||||
@ -69,5 +71,6 @@ class Car : public Creature
|
||||
int cur_buff_id_ = 0;
|
||||
int cur_buff_idx_ = -1;
|
||||
float cur_oil_ = 0;
|
||||
a8::Vec2 curr_shot_dir_;
|
||||
CircleCollider* self_collider_ = nullptr;
|
||||
};
|
||||
|
@ -44,6 +44,7 @@ struct BulletInfo
|
||||
float track_change_time = 0;
|
||||
int is_through = 0;
|
||||
int hand = 0;
|
||||
float shot_animi_time = 0;
|
||||
std::weak_ptr<a8::XTimerPtr> keep_shot_animi_timer_ptr;
|
||||
};
|
||||
|
||||
@ -95,7 +96,8 @@ static void InternalCreateBullet(BulletInfo& bullet_info)
|
||||
bullet_info.weapon_uniid,
|
||||
bullet_info.trace_target_uniid,
|
||||
bullet_info.hand,
|
||||
bullet_info.keep_shot_animi_timer_ptr);
|
||||
bullet_info.keep_shot_animi_timer_ptr,
|
||||
bullet_info.shot_animi_time);
|
||||
#ifdef DEBUG1
|
||||
if (bullet_info.c.Get()->IsPlayer()) {
|
||||
bullet_info.c.Get()->SendDebugMsg(a8::Format("CreateBullet id:%d",
|
||||
@ -219,15 +221,25 @@ static void CalcGunMuzzlePosition(Creature* c,
|
||||
}//end if
|
||||
if (weapon_meta->gun_muzzle_position) {
|
||||
gun_muzzle_position +=
|
||||
#if 1
|
||||
glm::vec4(
|
||||
-std::get<0>(*weapon_meta->gun_muzzle_position.get()),
|
||||
std::get<1>(*weapon_meta->gun_muzzle_position.get()),
|
||||
std::get<2>(*weapon_meta->gun_muzzle_position.get()),
|
||||
0
|
||||
);
|
||||
#else
|
||||
glm::vec4(
|
||||
std::get<0>(*weapon_meta->gun_muzzle_position.get()),
|
||||
std::get<1>(*weapon_meta->gun_muzzle_position.get()),
|
||||
std::get<2>(*weapon_meta->gun_muzzle_position.get()),
|
||||
0
|
||||
);
|
||||
#endif
|
||||
}
|
||||
#if 0
|
||||
if (weapon_meta->movex_position) {
|
||||
gun_muzzle_position +=
|
||||
gun_muzzle_position -=
|
||||
glm::vec4(
|
||||
std::get<0>(*weapon_meta->movex_position.get()),
|
||||
std::get<1>(*weapon_meta->movex_position.get()),
|
||||
@ -235,6 +247,7 @@ static void CalcGunMuzzlePosition(Creature* c,
|
||||
0
|
||||
);
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
void InternalShot(Creature* c,
|
||||
@ -316,7 +329,7 @@ void InternalShot(Creature* c,
|
||||
++bulletIdx;
|
||||
a8::Vec2 bullet_born_offset = a8::Vec2(std::get<0>(tuple), std::get<1>(tuple));
|
||||
a8::Vec2 bullet_born_pos = c->GetPos() + c->shoot_offset + bullet_born_offset;
|
||||
a8::Vec2 bullet_dir = c->GetAttackDir();
|
||||
a8::Vec2 bullet_dir = c->GetShotDir();
|
||||
float bullet_angle = std::get<2>(tuple);
|
||||
if (weapon_meta->i->bullet_angle() >= 0.10f) {
|
||||
int angle = (int)weapon_meta->i->bullet_angle() * 1000;
|
||||
@ -326,6 +339,9 @@ void InternalShot(Creature* c,
|
||||
}
|
||||
bullet_dir.Rotate(bullet_angle / 180.0f);
|
||||
int shot_animi_time = (shot_animi ? shot_animi->t : 0);
|
||||
if (shot_animi_time > 0) {
|
||||
shot_animi_time = std::max(100, shot_animi_time);
|
||||
}
|
||||
{
|
||||
bool is_player = c->IsPlayer();
|
||||
bool is_car = c->IsCar();
|
||||
@ -383,6 +399,7 @@ void InternalShot(Creature* c,
|
||||
bullet_info->invincible_buff_uniid = invincible_buff_uniid;
|
||||
bullet_info->trace_target_uniid = trace_target_uniid;
|
||||
bullet_info->keep_shot_animi_timer_ptr = keep_shot_animi_timer_ptr;
|
||||
bullet_info->shot_animi_time = shot_animi_time;
|
||||
if (skill_meta &&
|
||||
(skill_meta->GetMagicId() == MAGIC_AXXF ||
|
||||
skill_meta->GetMagicId() == MAGIC_HJHX)) {
|
||||
@ -3626,7 +3643,8 @@ void Creature::_UpdateSpecMove()
|
||||
}
|
||||
}
|
||||
|
||||
void Creature::AutoNavigation(a8::Vec2 target_pos, float speed)
|
||||
void Creature::AutoNavigation(a8::Vec2 target_pos, float speed,
|
||||
std::function<void (Creature*)> cb)
|
||||
{
|
||||
float distance = GetPos().Distance(target_pos);
|
||||
if (distance < 0.001f) {
|
||||
|
@ -280,7 +280,8 @@ class Creature : public MoveableEntity
|
||||
float GetAttrAbs(int attr_id);
|
||||
float GetAttrRate(int attr_id);
|
||||
void RecalcDtoAttr();
|
||||
void AutoNavigation(a8::Vec2 target_pos, float speed);
|
||||
void AutoNavigation(a8::Vec2 target_pos, float speed,
|
||||
std::function<void (Creature*)> cb);
|
||||
void AddTraceBullet(int bullet_uniid, int target_uniid, int gun_id);
|
||||
void LockAttackDir(int time);
|
||||
void PullTarget(const a8::Vec2& target_pos);
|
||||
|
@ -718,6 +718,17 @@ private:
|
||||
movez
|
||||
);
|
||||
}
|
||||
a8::UdpLog::Instance()->Info
|
||||
("weapon animation equip_id:%d x:%f y:%f z:%f movex:%f lmovey:%f movez:%f",
|
||||
{
|
||||
equip_id,
|
||||
x,
|
||||
y,
|
||||
z,
|
||||
movex,
|
||||
movey,
|
||||
movez
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -28,6 +28,7 @@ class MoveableEntity : public RoomEntity
|
||||
virtual void SetMoveDir(const a8::Vec2& move_dir);
|
||||
virtual const a8::Vec2& GetAttackDir() { return attack_dir_; };
|
||||
virtual void SetAttackDir(const a8::Vec2& attack_dir);
|
||||
virtual const a8::Vec2& GetShotDir() { return attack_dir_; };
|
||||
int GetChgMoveDirTimes() { return chg_move_dir_times_; }
|
||||
int GetChgAttackDirTimes() { return chg_attack_dir_times_; }
|
||||
float GetAttackDirRotate();
|
||||
|
@ -313,14 +313,16 @@ void Player::UpdateShot()
|
||||
GetCar()->shoot_offset = shoot_offset;
|
||||
GetCar()->shot_hole = GetSeat();
|
||||
GetCar()->shot_passenger = this;
|
||||
GetCar()->SetAttackDir(GetAttackDir());
|
||||
GetCar()->SetShotDir(GetAttackDir());
|
||||
GetCar()->Shot(target_dir, shot_ok, fly_distance, 0);
|
||||
if (!moving && GetCar()->IsDriver(this)) {
|
||||
GetCar()->SetMoveDir(GetAttackDir());
|
||||
}
|
||||
#if 0
|
||||
if (!GetCar()->IsDriver(this)) {
|
||||
GetCar()->SetAttackDir(old_car_attack_dir);
|
||||
}
|
||||
#endif
|
||||
GetCar()->shot_hole = old_car_shot_hole;
|
||||
GetCar()->shoot_offset = old_car_shoot_offset;
|
||||
GetCar()->shot_passenger = old_car_shot_passenger;
|
||||
|
@ -599,7 +599,8 @@ int Room::CreateBullet(Creature* sender,
|
||||
long long weapon_uniid,
|
||||
int trace_target_id,
|
||||
int hand,
|
||||
std::weak_ptr<a8::XTimerPtr> keep_shot_animi_timer_ptr)
|
||||
std::weak_ptr<a8::XTimerPtr> keep_shot_animi_timer_ptr,
|
||||
float shot_animi_time)
|
||||
{
|
||||
int bullet_uniid = 0;
|
||||
if (grid_service->CanAdd(pos.x, pos.y)) {
|
||||
@ -621,6 +622,7 @@ int Room::CreateBullet(Creature* sender,
|
||||
bullet->trace_target_id = trace_target_id;
|
||||
bullet->hand = hand;
|
||||
bullet->keep_shot_animi_timer_ptr = keep_shot_animi_timer_ptr;
|
||||
bullet->shot_animi_time = shot_animi_time;
|
||||
bullet->Initialize();
|
||||
AddObjectLater(bullet);
|
||||
bullet_uniid = bullet->GetUniId();
|
||||
|
@ -173,7 +173,8 @@ public:
|
||||
long long weapon_uniid,
|
||||
int trace_target_id,
|
||||
int hand,
|
||||
std::weak_ptr<a8::XTimerPtr> keep_shot_animi_timer_ptr);
|
||||
std::weak_ptr<a8::XTimerPtr> keep_shot_animi_timer_ptr,
|
||||
float shot_animi_time);
|
||||
Car* CreateCar(Human* driver,
|
||||
int car_uniid,
|
||||
MetaData::Equip* meta,
|
||||
|
Loading…
x
Reference in New Issue
Block a user