From 7e7e3e9b2d427a11df14c180b3ad2dda3d372b16 Mon Sep 17 00:00:00 2001 From: aozhiwei Date: Mon, 10 Oct 2022 17:28:57 +0800 Subject: [PATCH] 1 --- server/gameserver/car.h | 3 +++ server/gameserver/creature.cc | 9 +-------- server/gameserver/moveableentity.h | 1 + server/gameserver/player.cc | 4 +++- 4 files changed, 8 insertions(+), 9 deletions(-) diff --git a/server/gameserver/car.h b/server/gameserver/car.h index f0335ac9..e7a5831b 100644 --- a/server/gameserver/car.h +++ b/server/gameserver/car.h @@ -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; }; diff --git a/server/gameserver/creature.cc b/server/gameserver/creature.cc index c1ffd5ab..0ce13f2c 100644 --- a/server/gameserver/creature.cc +++ b/server/gameserver/creature.cc @@ -328,7 +328,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; @@ -354,13 +354,6 @@ void InternalShot(Creature* c, auto transform = glm::rotate(hero_transform, bullet_born_angle * A8_PI, glm::vec3(0.0, 1.0, 0.0)); -#if 1 - if (c->IsCar()) { - transform = glm::rotate(hero_transform, - 0 * A8_PI, - glm::vec3(0.0, 1.0, 0.0)); - } -#endif glm::vec4 gun_muzzle_position(0.0, 0.0, 0.0, 0.0); CalcGunMuzzlePosition(c, weapon_meta, shot_animi, gun_muzzle_position, bulletIdx, bulletNum); glm::vec4 v = transform * gun_muzzle_position; diff --git a/server/gameserver/moveableentity.h b/server/gameserver/moveableentity.h index 9bfbe646..3f39a356 100644 --- a/server/gameserver/moveableentity.h +++ b/server/gameserver/moveableentity.h @@ -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(); diff --git a/server/gameserver/player.cc b/server/gameserver/player.cc index 448ba61c..5a467041 100644 --- a/server/gameserver/player.cc +++ b/server/gameserver/player.cc @@ -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;