From 150c578a60e863f63b9c96b5862d6d9722dce0e8 Mon Sep 17 00:00:00 2001 From: aozhiwei Date: Fri, 16 Jun 2023 13:41:44 +0800 Subject: [PATCH] 1 --- server/gameserver/bullet.cc | 6 ++++++ server/gameserver/collision.cc | 5 +++-- server/gameserver/mt/Hero.cc | 29 +++++++++++++++++++++++++++-- server/gameserver/mt/Hero.h | 3 +++ 4 files changed, 39 insertions(+), 4 deletions(-) diff --git a/server/gameserver/bullet.cc b/server/gameserver/bullet.cc index 28c4af2a..e5813a1a 100644 --- a/server/gameserver/bullet.cc +++ b/server/gameserver/bullet.cc @@ -104,6 +104,9 @@ void Bullet::Update(int delta_time) void Bullet::OnHit(std::set& objects) { + if (gun_meta->id() == 60201) { + int i = 0; + } std::shared_ptr old_context_ability = sender.Get()->context_ability; glm::vec3 old_context_dir = sender.Get()->context_dir; Position old_context_pos = sender.Get()->context_pos; @@ -500,6 +503,9 @@ float Bullet::GetExplosionRange() void Bullet::Check(float distance) { + if (gun_meta->id() == 60201) { + int i = 0; + } BulletCheckResult result; result.flyed_distance = distance; GetHitThings(result); diff --git a/server/gameserver/collision.cc b/server/gameserver/collision.cc index 2a8c2349..93b8bac4 100644 --- a/server/gameserver/collision.cc +++ b/server/gameserver/collision.cc @@ -12,6 +12,7 @@ #include "mt/Map.h" #include "mt/MapThing.h" +#include "mt/Hero.h" static const float GUN_HEIGHT = 3.0f; @@ -25,14 +26,14 @@ bool Collision::CheckBullet(IBullet* bullet, Creature* c) bool ret = a8::IntersectCylinderCylinder ( bullet_real_pos, bullet_hit_radius * 1.0, GUN_HEIGHT, - c->GetPos().ToGlmVec3(), c->GetHitRadius(), GUN_HEIGHT + c->GetPos().ToGlmVec3(), c->GetHitRadius(), c->GetHeroMeta()->GetHeight() ); if (!ret) { bullet_real_pos = bullet->GetPos().ToGlmVec3() - bullet->GetDir() * (bullet->GetHitRadius() - 2); ret = a8::IntersectCylinderCylinder ( bullet_real_pos, bullet_hit_radius * 1.0, GUN_HEIGHT, - c->GetPos().ToGlmVec3(), c->GetHitRadius(), GUN_HEIGHT + c->GetPos().ToGlmVec3(), c->GetHitRadius(), c->GetHeroMeta()->GetHeight() ); } return ret; diff --git a/server/gameserver/mt/Hero.cc b/server/gameserver/mt/Hero.cc index 12783dfb..aaabbf90 100644 --- a/server/gameserver/mt/Hero.cc +++ b/server/gameserver/mt/Hero.cc @@ -138,6 +138,31 @@ namespace mt { LoadHeroAndEquipShotData(); Equip::AdjustMuzzlePos(); + Traverse( + [] (const Hero* hero, bool& stop) + { + if (hero->GetHeight() < 0.1) { + if (!(hero->id() == 40001 || + hero->id() == 40002 || + hero->id() == 9001 || + hero->id() == 9002 || + hero->id() == 9003 || + hero->id() == 9004 || + hero->id() == 9005 || + hero->id() == 9006 || + hero->id() == 9007 || + hero->id() == 9008 || + hero->id() == 9009 || + hero->id() == 9010 || + hero->id() == 8001 || + hero->id() == 8002 || + hero->id() == 8003 || + hero->id() == 8004 || + hero->id() == 8005)) { + abort(); + } + } + }); } const HeroShotAnimation* Hero::GetShotAnimi(int shotfire) const @@ -159,13 +184,14 @@ namespace mt int hero_id = a8::XValue(key); std::vector keys2; hero_xobj->GetKeys(keys2); + const mt::Hero* hero_meta = mt::Hero::GetById(hero_id); #if 1 { - const mt::Hero* hero_meta = Hero::GetById(hero_id); if (hero_meta) { mt::Hero* mut_hero_meta = (mt::Hero*)hero_meta; auto size_xobj = hero_xobj->At("size"); mut_hero_meta->hit_radius_ = size_xobj->At("radius")->AsXValue().GetDouble() * 10; + mut_hero_meta->height_ = size_xobj->At("height")->AsXValue().GetDouble(); } } #endif @@ -222,7 +248,6 @@ namespace mt } { - const mt::Hero* hero_meta = mt::Hero::GetById(hero_id); if (hero_meta) { mt::HeroShotAnimation anim; anim.id = id; diff --git a/server/gameserver/mt/Hero.h b/server/gameserver/mt/Hero.h index 677879cf..84a41924 100644 --- a/server/gameserver/mt/Hero.h +++ b/server/gameserver/mt/Hero.h @@ -52,8 +52,11 @@ namespace mt int RandDrop() const; const HeroShotAnimation* GetShotAnimi(int shotfire) const; + float GetHeight() const { return height_; } private: + float height_ = 0.0f; + static void LoadHeroAndEquipShotData(); };