This commit is contained in:
aozhiwei 2023-04-06 14:52:53 +08:00
parent 0ffc80f5a9
commit c1d79c7dd2
5 changed files with 18 additions and 3 deletions

View File

@ -45,6 +45,7 @@ class Bullet : public MoveableEntity, public IBullet
void TriggerHitBuff(Entity* e); void TriggerHitBuff(Entity* e);
bool IsFlyHook(); bool IsFlyHook();
virtual const glm::vec3& GetDir() override { return dir; };
virtual float GetStrengthenWall() override { return strengthen_wall; }; virtual float GetStrengthenWall() override { return strengthen_wall; };
virtual long long GetWeaponUniId() override { return weapon_uniid; }; virtual long long GetWeaponUniId() override { return weapon_uniid; };
virtual const mt::Skill* GetSkillMeta() override {return skill_meta; }; virtual const mt::Skill* GetSkillMeta() override {return skill_meta; };

View File

@ -14,15 +14,17 @@
bool Collision::CheckBullet(IBullet* bullet, Creature* c) bool Collision::CheckBullet(IBullet* bullet, Creature* c)
{ {
glm::vec3 bullet_real_pos = bullet->GetPos().ToGlmVec3() - bullet->GetDir() * bullet->GetHitRadius();
return a8::IntersectCylinderCylinder return a8::IntersectCylinderCylinder
( (
bullet->GetPos().ToGlmVec3(), bullet->GetHitRadius() * 1.0, 10, bullet_real_pos, bullet->GetHitRadius() * 1.0, 10,
c->GetPos().ToGlmVec3(), c->GetHitRadius(), 10 c->GetPos().ToGlmVec3(), c->GetHitRadius(), 10
); );
} }
bool Collision::CheckBullet(IBullet* bullet, Entity* e) bool Collision::CheckBullet(IBullet* bullet, Entity* e)
{ {
glm::vec3 bullet_real_pos = bullet->GetPos().ToGlmVec3() - bullet->GetDir() * bullet->GetHitRadius();
if (e->IsEntityType(ET_Obstacle) && ((Obstacle*)e)->IsRoomObstacle()) { if (e->IsEntityType(ET_Obstacle) && ((Obstacle*)e)->IsRoomObstacle()) {
RoomObstacle* ob = (RoomObstacle*)e; RoomObstacle* ob = (RoomObstacle*)e;
float distance = std::fabs(bullet->GetPos().GetX() - e->GetPos().GetX()) + std::fabs(bullet->GetPos().GetZ() - e->GetPos().GetZ()); float distance = std::fabs(bullet->GetPos().GetX() - e->GetPos().GetX()) + std::fabs(bullet->GetPos().GetZ() - e->GetPos().GetZ());
@ -33,13 +35,13 @@ bool Collision::CheckBullet(IBullet* bullet, Entity* e)
auto wobj = ob->init_args->Get<std::shared_ptr<mt::WorldObject>>(0); auto wobj = ob->init_args->Get<std::shared_ptr<mt::WorldObject>>(0);
return a8::IntersectCylinderCylinder return a8::IntersectCylinderCylinder
( (
bullet->GetPos().ToGlmVec3(), bullet->GetHitRadius() * 0.6, 10, bullet_real_pos, bullet->GetHitRadius() * 1.0, 10,
e->GetPos().ToGlmVec3(), std::max(wobj->size.x/2.0f, wobj->size.z/2.0f), 10 e->GetPos().ToGlmVec3(), std::max(wobj->size.x/2.0f, wobj->size.z/2.0f), 10
); );
} else { } else {
return a8::IntersectCylinderCylinder return a8::IntersectCylinderCylinder
( (
bullet->GetPos().ToGlmVec3(), bullet->GetHitRadius() * 0.6, 10, bullet_real_pos, bullet->GetHitRadius() * 1.0, 10,
e->GetPos().ToGlmVec3(), ob->meta->width(), 10 e->GetPos().ToGlmVec3(), ob->meta->width(), 10
); );
} }

View File

@ -152,6 +152,16 @@ namespace mt
int hero_id = a8::XValue(key); int hero_id = a8::XValue(key);
std::vector<std::string> keys2; std::vector<std::string> keys2;
hero_xobj->GetKeys(keys2); hero_xobj->GetKeys(keys2);
#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;
}
}
#endif
for (auto& key2 : keys2) { for (auto& key2 : keys2) {
auto anim_xobj = hero_xobj->At(key2); auto anim_xobj = hero_xobj->At(key2);

View File

@ -79,6 +79,7 @@ class IBullet
{ {
public: public:
virtual const Position& GetPos() = 0; virtual const Position& GetPos() = 0;
virtual const glm::vec3& GetDir() = 0;
virtual float GetStrengthenWall() = 0; virtual float GetStrengthenWall() = 0;
virtual long long GetWeaponUniId() = 0; virtual long long GetWeaponUniId() = 0;
virtual const mt::Skill* GetSkillMeta() = 0; virtual const mt::Skill* GetSkillMeta() = 0;

View File

@ -21,6 +21,7 @@ class VirtualBullet : public IBullet, public ITask
glm::vec3 born_dir = GlmHelper::ZERO; glm::vec3 born_dir = GlmHelper::ZERO;
float strengthen_wall = 0; float strengthen_wall = 0;
virtual const glm::vec3& GetDir() override { return dir; };
virtual float GetStrengthenWall() override; virtual float GetStrengthenWall() override;
virtual long long GetWeaponUniId() override; virtual long long GetWeaponUniId() override;
virtual const mt::Skill* GetSkillMeta() override; virtual const mt::Skill* GetSkillMeta() override;