diff --git a/server/gameserver/car.cc b/server/gameserver/car.cc index 569e86d..9b2b398 100644 --- a/server/gameserver/car.cc +++ b/server/gameserver/car.cc @@ -178,3 +178,9 @@ void Car::SyncPos() room->grid_service->MoveCreature(this); } } + +float Car::GetRadius() +{ + abort(); + return 0; +} diff --git a/server/gameserver/car.h b/server/gameserver/car.h index 1feacd8..870d646 100644 --- a/server/gameserver/car.h +++ b/server/gameserver/car.h @@ -28,6 +28,7 @@ class Car : public Creature void GetDown(Human* passenger); void GetOn(Human* passenger); void SyncPos(); + virtual float GetRadius() override; private: int AllocSeat(); diff --git a/server/gameserver/creature.cc b/server/gameserver/creature.cc index d380785..fc744a0 100644 --- a/server/gameserver/creature.cc +++ b/server/gameserver/creature.cc @@ -1344,3 +1344,53 @@ RoomObstacle* Creature::SummonObstacle(int id, const a8::Vec2& pos) } return obstacle; } + +bool Creature::CollisonDetection() +{ + #if 0 + if (room->OverBorder(GetPos(), GetRadius())){ + return true; + } + if (HasBuffEffect(kBET_ThroughWall) || + HasBuffEffect(kBET_Fly)) { + return false; + } + + std::set colliders; + room->map_service->GetColliders(room, GetX(), GetY(), colliders); + + AabbCollider aabb_box; + GetAabbBox(aabb_box); + for (ColliderComponent* collider : colliders) { + switch (collider->owner->GetEntityType()) { + case ET_Obstacle: + { + Obstacle* obstacle = (Obstacle*)collider->owner; + if (!obstacle->IsDead(room) && + ( + (collider->type == CT_Aabb && aabb_box.Intersect((ColliderComponent*)collider)) || + (collider->type == CT_Circle && self_collider_->Intersect((ColliderComponent*)collider)) + )) { + return true; + } + } + break; + case ET_Building: + { + if ( + ( + (collider->type == CT_Aabb && aabb_box.Intersect((ColliderComponent*)collider)) || + (collider->type == CT_Circle && self_collider_->Intersect((ColliderComponent*)collider)) + ) + ) { + return true; + } + } + break; + default: + break; + } + } + #endif + return false; +} diff --git a/server/gameserver/creature.h b/server/gameserver/creature.h index 4194389..737ba02 100644 --- a/server/gameserver/creature.h +++ b/server/gameserver/creature.h @@ -120,6 +120,7 @@ class Creature : public MoveableEntity void CheckSpecObject(); RoomObstacle* SummonObstacle(int id, const a8::Vec2& pos); + bool CollisonDetection(); private: diff --git a/server/gameserver/entity.h b/server/gameserver/entity.h index fbe4b2a..fe20379 100644 --- a/server/gameserver/entity.h +++ b/server/gameserver/entity.h @@ -22,6 +22,7 @@ class Entity virtual void FillMFObjectFull(Room* room, Human* hum, cs::MFObjectFull* full_data) {}; virtual float GetSpeed() { return 1.0f;}; virtual void GetAabbBox(AabbCollider& aabb_box); + virtual float GetRadius() { return 0;}; virtual void GetCircleBox(CircleCollider& circle_box); virtual bool IsDead(Room* room) { return false;}; virtual long long GetDeadFrameNo(Room* room) { return 0;}; diff --git a/server/gameserver/hero.cc b/server/gameserver/hero.cc index 073eefd..e246307 100644 --- a/server/gameserver/hero.cc +++ b/server/gameserver/hero.cc @@ -187,3 +187,9 @@ void Hero::RecalcSelfCollider() self_collider_->pos = a8::Vec2(); self_collider_->rad = meta->i->radius(); } + + +float Hero::GetRadius() +{ + return meta->i->radius(); +} diff --git a/server/gameserver/hero.h b/server/gameserver/hero.h index 5cf661a..b6c4a48 100644 --- a/server/gameserver/hero.h +++ b/server/gameserver/hero.h @@ -30,6 +30,7 @@ public: virtual void GetAabbBox(AabbCollider& aabb_box) override; virtual float GetSpeed() override; + virtual float GetRadius() override; protected: virtual void _UpdateMove(int speed) override; diff --git a/server/gameserver/human.cc b/server/gameserver/human.cc index c9414a4..6adffcc 100644 --- a/server/gameserver/human.cc +++ b/server/gameserver/human.cc @@ -629,11 +629,6 @@ void Human::FindPathInMapService() SetPos(old_pos); } -float Human::GetRadius() -{ - return meta->i->radius(); -} - float Human::GetHP() { return ability.hp; @@ -3368,3 +3363,8 @@ void Human::DoSkillPostProc(bool used, int skill_id, int target_id, const a8::Ve OnAttack(); } } + +float Human::GetRadius() +{ + return meta->i->radius(); +} diff --git a/server/gameserver/human.h b/server/gameserver/human.h index 4eca4bf..7b0e8ba 100644 --- a/server/gameserver/human.h +++ b/server/gameserver/human.h @@ -153,7 +153,6 @@ class Human : public Creature virtual void RecalcSelfCollider() override; bool IsCollisionInMapService(); void FindPathInMapService(); - float GetRadius(); float GetHP(); float GetMaxHP(); void BeKill(int killer_id, const std::string& killer_name, int weapon_id); @@ -239,6 +238,7 @@ class Human : public Creature void SetSeat(int seat) { seat_ = seat; } void DeadDrop(); virtual std::string GetName() override { return name;}; + virtual float GetRadius() override; protected: void _InternalUpdateMove(float speed); diff --git a/server/tools/protobuild/metatable.proto b/server/tools/protobuild/metatable.proto index 3b7c6ff..6e30e28 100755 --- a/server/tools/protobuild/metatable.proto +++ b/server/tools/protobuild/metatable.proto @@ -146,6 +146,7 @@ message Player optional int32 revive_time = 22; optional string name = 23; optional int32 normal_skill = 24; + optional float hit_radius = 25; } message Robot