1
This commit is contained in:
parent
03e08e46e9
commit
9bd36590d3
@ -2186,52 +2186,38 @@ void Creature::SummonHero(Buff* buff,
|
|||||||
MetaData::Player* hero_meta = MetaMgr::Instance()->GetPlayer(hero_id);
|
MetaData::Player* hero_meta = MetaMgr::Instance()->GetPlayer(hero_id);
|
||||||
if (hero_meta) {
|
if (hero_meta) {
|
||||||
for (int j = 0; j < num; ++j) {
|
for (int j = 0; j < num; ++j) {
|
||||||
|
bool can_create = false;
|
||||||
|
a8::Vec2 born_pos;
|
||||||
Hero* hero = nullptr;
|
Hero* hero = nullptr;
|
||||||
for (int i = 0; i < 4; ++i) {
|
for (int i = 0; i < 4; ++i) {
|
||||||
a8::Vec2 born_dir = dir;
|
a8::Vec2 born_dir = dir;
|
||||||
a8::Vec2 born_offset(x, y);
|
a8::Vec2 born_offset(x, y);
|
||||||
born_offset.Rotate(born_dir.CalcAngle(a8::Vec2::UP));
|
born_offset.Rotate(born_dir.CalcAngle(a8::Vec2::UP));
|
||||||
born_offset.Rotate(i * 0.5);
|
born_offset.Rotate(i * 0.5);
|
||||||
a8::Vec2 hero_pos = pos + born_offset;
|
born_pos = pos + born_offset;
|
||||||
hero = InternalSummonHero(hero_meta,
|
can_create = TrySummonHero(hero_meta,
|
||||||
dir,
|
dir,
|
||||||
hero_pos,
|
born_pos,
|
||||||
through_wall);
|
through_wall);
|
||||||
if (hero) {
|
if (can_create) {
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}//end for i
|
}//end for i
|
||||||
if (!hero) {
|
if (!can_create) {
|
||||||
hero = InternalSummonHero(hero_meta,
|
born_pos = GetPos();
|
||||||
GetAttackDir(),
|
can_create = TrySummonHero(hero_meta,
|
||||||
GetPos(),
|
GetAttackDir(),
|
||||||
through_wall);
|
born_pos,
|
||||||
#ifdef DEBUG
|
through_wall);
|
||||||
SendDebugMsg(a8::Format("second summon hero id:%d pos:%f,%f rad:%d ok:%d",
|
|
||||||
{
|
|
||||||
hero_meta->i->id(),
|
|
||||||
GetPos().x,
|
|
||||||
GetPos().y,
|
|
||||||
hero_meta->i->radius(),
|
|
||||||
hero ? 1 : 0
|
|
||||||
}));
|
|
||||||
#endif
|
|
||||||
}
|
}
|
||||||
if (hero) {
|
if (can_create) {
|
||||||
RemoveSurplusHero(buff->meta->i->buff_id(), hero_id, num);
|
InternalSummonHero(buff,
|
||||||
slave_heros_.push_back(std::make_tuple(buff->meta->i->buff_id(), hero));
|
hero_meta,
|
||||||
hero->room->xtimer.AddDeadLineTimerAndAttach
|
GetAttackDir(),
|
||||||
(
|
born_pos,
|
||||||
life_time / FRAME_RATE_MS,
|
through_wall,
|
||||||
a8::XParams(),
|
num,
|
||||||
[] (const a8::XParams& param)
|
life_time);
|
||||||
{
|
|
||||||
},
|
|
||||||
&hero->xtimer_attacher.timer_list_,
|
|
||||||
[] (const a8::XParams& param)
|
|
||||||
{
|
|
||||||
|
|
||||||
});
|
|
||||||
}
|
}
|
||||||
}//end for j
|
}//end for j
|
||||||
}
|
}
|
||||||
@ -2680,42 +2666,99 @@ void Creature::TraverseBuff(std::function<void (Buff*, bool&)> func)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
Hero* Creature::InternalSummonHero(MetaData::Player* hero_meta, a8::Vec2 dir, a8::Vec2 born_pos, bool through_wall)
|
bool Creature::TrySummonHero(MetaData::Player* hero_meta, a8::Vec2 dir, a8::Vec2 born_pos, bool through_wall)
|
||||||
{
|
{
|
||||||
#if 1
|
|
||||||
AabbCollider collider;
|
AabbCollider collider;
|
||||||
collider._min.x = -hero_meta->i->radius();
|
collider._min.x = -hero_meta->i->radius();
|
||||||
collider._min.y = -hero_meta->i->radius();
|
collider._min.y = -hero_meta->i->radius();
|
||||||
collider._max.x = hero_meta->i->radius();
|
collider._max.x = hero_meta->i->radius();
|
||||||
collider._max.y = hero_meta->i->radius();
|
collider._max.y = hero_meta->i->radius();
|
||||||
collider.MoveCenter(hero_meta->i->move_offset_x(), hero_meta->i->move_offset_y());
|
collider.MoveCenter(hero_meta->i->move_offset_x(), hero_meta->i->move_offset_y());
|
||||||
#else
|
return !room->map_service->CollisionDetection
|
||||||
CircleCollider collider;
|
|
||||||
collider.rad = hero_meta->i->radius();
|
|
||||||
#endif
|
|
||||||
if (!room->map_service->CollisionDetection
|
|
||||||
(
|
(
|
||||||
room,
|
room,
|
||||||
through_wall,
|
through_wall,
|
||||||
born_pos,
|
born_pos,
|
||||||
&collider
|
&collider
|
||||||
)) {
|
);
|
||||||
Hero* hero = room->CreateHero
|
}
|
||||||
(this,
|
|
||||||
hero_meta,
|
Hero* Creature::InternalSummonHero(Buff* buff, MetaData::Player* hero_meta, a8::Vec2 dir, a8::Vec2 born_pos,
|
||||||
born_pos,
|
bool through_wall, int num, int life_time)
|
||||||
dir,
|
{
|
||||||
team_id
|
struct SummonHeroInfo
|
||||||
);
|
{
|
||||||
#ifdef DEBUG
|
MetaData::Player* hero_meta = nullptr;
|
||||||
SendDebugMsg(a8::Format("summon hero id:%d pos:%f,%f",
|
a8::Vec2 dir;
|
||||||
{
|
a8::Vec2 born_pos;
|
||||||
hero_meta->i->id(),
|
bool through_wall = false;
|
||||||
born_pos.x,
|
int num = 0;
|
||||||
born_pos.y
|
int life_time = 0;
|
||||||
}));
|
};
|
||||||
#endif
|
if (TrySummonHero(hero_meta, dir, born_pos, through_wall)) {
|
||||||
return hero;
|
int delay_time = 0;
|
||||||
|
for (auto& tuple : hero_meta->pre_appear_effect) {
|
||||||
|
delay_time += std::get<1>(tuple);
|
||||||
|
}
|
||||||
|
SummonHeroInfo* summon_info = new SummonHeroInfo;
|
||||||
|
summon_info->hero_meta = hero_meta;
|
||||||
|
summon_info->dir = dir;
|
||||||
|
summon_info->born_pos = born_pos;
|
||||||
|
summon_info->through_wall = through_wall;
|
||||||
|
summon_info->num = num;
|
||||||
|
summon_info->life_time = life_time;
|
||||||
|
room->xtimer.AddDeadLineTimerAndAttach
|
||||||
|
(
|
||||||
|
delay_time / FRAME_RATE_MS,
|
||||||
|
a8::XParams()
|
||||||
|
.SetSender(buff)
|
||||||
|
.SetParam1(summon_info),
|
||||||
|
[] (const a8::XParams& param)
|
||||||
|
{
|
||||||
|
Buff* buff = (Buff*)param.sender.GetUserData();
|
||||||
|
Creature* sender = buff->owner;
|
||||||
|
SummonHeroInfo* summon_info = (SummonHeroInfo*)param.param1.GetUserData();
|
||||||
|
Hero* hero = sender->room->CreateHero
|
||||||
|
(sender,
|
||||||
|
summon_info->hero_meta,
|
||||||
|
summon_info->born_pos,
|
||||||
|
summon_info->dir,
|
||||||
|
sender->team_id
|
||||||
|
);
|
||||||
|
if (!hero) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
sender->RemoveSurplusHero(buff->meta->i->buff_id(),
|
||||||
|
summon_info->hero_meta->i->id(),
|
||||||
|
summon_info->num);
|
||||||
|
sender->slave_heros_.push_back(std::make_tuple(buff->meta->i->buff_id(), hero));
|
||||||
|
hero->room->xtimer.AddDeadLineTimerAndAttach
|
||||||
|
(
|
||||||
|
summon_info->life_time / FRAME_RATE_MS,
|
||||||
|
a8::XParams(),
|
||||||
|
[] (const a8::XParams& param)
|
||||||
|
{
|
||||||
|
},
|
||||||
|
&hero->xtimer_attacher.timer_list_,
|
||||||
|
[] (const a8::XParams& param)
|
||||||
|
{
|
||||||
|
|
||||||
|
});
|
||||||
|
#ifdef DEBUG
|
||||||
|
sender->SendDebugMsg(a8::Format("summon hero id:%d pos:%f,%f",
|
||||||
|
{
|
||||||
|
summon_info->hero_meta->i->id(),
|
||||||
|
summon_info->born_pos.x,
|
||||||
|
summon_info->born_pos.y
|
||||||
|
}));
|
||||||
|
#endif
|
||||||
|
},
|
||||||
|
&buff->xtimer_attacher.timer_list_,
|
||||||
|
[] (const a8::XParams& param)
|
||||||
|
{
|
||||||
|
SummonHeroInfo* summon_info = (SummonHeroInfo*)param.param1.GetUserData();
|
||||||
|
delete summon_info;
|
||||||
|
});
|
||||||
}
|
}
|
||||||
return nullptr;
|
return nullptr;
|
||||||
}
|
}
|
||||||
|
@ -272,7 +272,9 @@ private:
|
|||||||
void RemoveSurplusObstacle(int buff_id, int id, int num);
|
void RemoveSurplusObstacle(int buff_id, int id, int num);
|
||||||
void CheckAbilityUsed();
|
void CheckAbilityUsed();
|
||||||
void ProcOnceChgAttrBuff(MetaData::Buff* buff_meta);
|
void ProcOnceChgAttrBuff(MetaData::Buff* buff_meta);
|
||||||
Hero* InternalSummonHero(MetaData::Player* hero_meta, a8::Vec2 dir, a8::Vec2 born_pos, bool through_wall );
|
bool TrySummonHero(MetaData::Player* hero_meta, a8::Vec2 dir, a8::Vec2 born_pos, bool through_wall);
|
||||||
|
Hero* InternalSummonHero(Buff* buff, MetaData::Player* hero_meta, a8::Vec2 dir, a8::Vec2 born_pos,
|
||||||
|
bool through_wall, int num, int life_time);
|
||||||
void AutoSwitchWeapon();
|
void AutoSwitchWeapon();
|
||||||
void CheckLoadingBullet();
|
void CheckLoadingBullet();
|
||||||
|
|
||||||
|
@ -626,6 +626,20 @@ namespace MetaData
|
|||||||
init_buffs.push_back(a8::XValue(str));
|
init_buffs.push_back(a8::XValue(str));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
{
|
||||||
|
std::vector<std::string> strings;
|
||||||
|
a8::Split(i->pre_appear_effect(), strings, '|');
|
||||||
|
for (auto& str : strings) {
|
||||||
|
std::vector<std::string> strings2;
|
||||||
|
a8::Split(str, strings2, ':');
|
||||||
|
assert(strings2.size() == 2);
|
||||||
|
if (strings2.size() >= 2) {
|
||||||
|
int thing_id = a8::XValue(strings2[0]);
|
||||||
|
int time = a8::XValue(strings2[1]);
|
||||||
|
pre_appear_effect.push_back(std::make_tuple(thing_id, time));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
int Player::RandDrop()
|
int Player::RandDrop()
|
||||||
|
@ -134,6 +134,7 @@ namespace MetaData
|
|||||||
std::array<int, IS_END> volume = {};
|
std::array<int, IS_END> volume = {};
|
||||||
std::vector<int> init_buffs;
|
std::vector<int> init_buffs;
|
||||||
std::vector<std::tuple<int, int>> dead_drop;
|
std::vector<std::tuple<int, int>> dead_drop;
|
||||||
|
std::vector<std::tuple<int, int>> pre_appear_effect;
|
||||||
bool HasDrop() { return !dead_drop.empty();};
|
bool HasDrop() { return !dead_drop.empty();};
|
||||||
|
|
||||||
void Init();
|
void Init();
|
||||||
|
@ -235,6 +235,7 @@ message Player
|
|||||||
optional int32 ai = 46;
|
optional int32 ai = 46;
|
||||||
optional int32 delay_remove = 47;
|
optional int32 delay_remove = 47;
|
||||||
optional int32 skinlist = 48;
|
optional int32 skinlist = 48;
|
||||||
|
optional string pre_appear_effect = 50;
|
||||||
}
|
}
|
||||||
|
|
||||||
message Robot
|
message Robot
|
||||||
|
Loading…
x
Reference in New Issue
Block a user