From e22ede9fce935c47e507369d8a9005b5aac33391 Mon Sep 17 00:00:00 2001 From: aozhiwei Date: Tue, 27 Jul 2021 12:42:46 +0000 Subject: [PATCH] 1 --- server/gameserver/creature.cc | 46 ++++++++++++++++++++++------------- server/gameserver/creature.h | 1 + 2 files changed, 30 insertions(+), 17 deletions(-) diff --git a/server/gameserver/creature.cc b/server/gameserver/creature.cc index eabce40..4e848b9 100644 --- a/server/gameserver/creature.cc +++ b/server/gameserver/creature.cc @@ -2078,24 +2078,12 @@ void Creature::SummonHero(Buff* buff, born_offset.Rotate(born_dir.CalcAngle(a8::Vec2::UP)); born_offset.Rotate(i * 0.5); a8::Vec2 hero_pos = pos + born_offset; - CircleCollider collider; - collider.pos = hero_pos; - collider.rad = hero_meta->i->radius(); - if (!room->map_service->CollisionDetection - ( - room, - through_wall, - hero_pos, - &collider - )) { + Hero* hero = InternalSummonHero(hero_meta, + dir, + hero_pos, + through_wall); + if (hero) { RemoveSurplusHero(buff->meta->i->buff_id(), hero_id, num); - Hero* hero = room->CreateHero - (this, - hero_meta, - hero_pos, - dir, - team_id - ); slave_heros_.push_back(std::make_tuple(buff->meta->i->buff_id(), hero)); break; } @@ -2528,3 +2516,27 @@ void Creature::TraverseBuff(std::function func) } } } + +Hero* Creature::InternalSummonHero(MetaData::Player* hero_meta, a8::Vec2 dir, a8::Vec2 born_pos, bool through_wall) +{ + CircleCollider collider; + collider.pos = born_pos; + collider.rad = hero_meta->i->radius(); + if (!room->map_service->CollisionDetection + ( + room, + through_wall, + born_pos, + &collider + )) { + Hero* hero = room->CreateHero + (this, + hero_meta, + born_pos, + dir, + team_id + ); + return hero; + } + return nullptr; +} diff --git a/server/gameserver/creature.h b/server/gameserver/creature.h index 38b765b..c732417 100644 --- a/server/gameserver/creature.h +++ b/server/gameserver/creature.h @@ -232,6 +232,7 @@ private: void RemoveSurplusObstacle(int buff_id, int id, int num); void CheckAbilityUsed(); void ProcOnceChgAttrBuff(MetaData::Buff* buff_meta); + Hero* InternalSummonHero(MetaData::Player* hero_meta, a8::Vec2 dir, a8::Vec2 born_pos, bool through_wall ); protected: RaceType_e race_ = kHumanRace;