修复 7 浣熊,技能埋的地雷上限为3个,当前无用

This commit is contained in:
aozhiwei 2021-06-07 19:50:25 +08:00
parent f7a217e8f0
commit 6805da5bd2
9 changed files with 85 additions and 37 deletions

View File

@ -869,10 +869,7 @@ void Creature::ProcBuffEffect(Creature* caster, Buff* buff)
case kBET_SummonHero: case kBET_SummonHero:
{ {
if (!dead) { if (!dead) {
SummonHero(buff, SummonHero(buff, GetPos(), GetMoveDir());
GetPos(),
GetMoveDir(),
buff->meta->hero_infos);
} }
} }
break; break;
@ -1509,8 +1506,12 @@ void Creature::CheckSpecObject()
#endif #endif
} }
RoomObstacle* Creature::SummonObstacle(Buff* buff, int id, const a8::Vec2& pos) void Creature::SummonObstacle(Buff* buff, int id, const a8::Vec2& pos)
{ {
buff->meta->int_param2 = 2;
if (buff->meta->int_param2 > 0) {
RemoveSurplusObstacle(buff->meta->i->buff_id(), id, buff->meta->int_param2);
}
RoomObstacle* obstacle = room->CreateObstacle(id, pos.x, pos.y); RoomObstacle* obstacle = room->CreateObstacle(id, pos.x, pos.y);
if (obstacle) { if (obstacle) {
obstacle->master.Attach(this); obstacle->master.Attach(this);
@ -1521,7 +1522,6 @@ RoomObstacle* Creature::SummonObstacle(Buff* buff, int id, const a8::Vec2& pos)
} else { } else {
abort(); abort();
} }
return obstacle;
} }
bool Creature::CollisonDetection() bool Creature::CollisonDetection()
@ -1645,14 +1645,15 @@ void Creature::ResetAllSkillCd()
void Creature::SummonHero(Buff* buff, void Creature::SummonHero(Buff* buff,
const a8::Vec2& pos, const a8::Vec2& pos,
const a8::Vec2& dir, const a8::Vec2& dir
std::vector<std::tuple<int, float, float, int>>& infos) )
{ {
for (auto& info : infos) { for (auto& info : buff->meta->hero_infos) {
int through_wall = std::get<0>(info); int through_wall = std::get<0>(info);
float x = std::get<1>(info); float x = std::get<1>(info);
float y = std::get<2>(info) ; float y = std::get<2>(info) ;
int hero_id = std::get<3>(info); int hero_id = std::get<3>(info);
int num = std::get<4>(info);
MetaData::Player* hero_meta = MetaMgr::Instance()->GetPlayer(hero_id); MetaData::Player* hero_meta = MetaMgr::Instance()->GetPlayer(hero_id);
if (hero_meta && !dead) { if (hero_meta && !dead) {
for (int i = 0; i < 4; ++i) { for (int i = 0; i < 4; ++i) {
@ -1671,6 +1672,7 @@ void Creature::SummonHero(Buff* buff,
hero_pos, hero_pos,
&collider &collider
)) { )) {
RemoveSurplusHero(buff->meta->i->buff_id(), hero_id, num);
Hero* hero = room->CreateHero Hero* hero = room->CreateHero
(this, (this,
hero_meta, hero_meta,

View File

@ -153,11 +153,8 @@ class Creature : public MoveableEntity
void CheckSpecObject(); void CheckSpecObject();
bool CollisonDetection(); bool CollisonDetection();
RoomObstacle* SummonObstacle(Buff* buff, int id, const a8::Vec2& pos); void SummonObstacle(Buff* buff, int id, const a8::Vec2& pos);
void SummonHero(Buff* buff, void SummonHero(Buff* buff, const a8::Vec2& pos, const a8::Vec2& dir);
const a8::Vec2& pos,
const a8::Vec2& dir,
std::vector<std::tuple<int, float, float, int>>& infos);
void FillSkillCasterState(SkillCasterState* caster_state); void FillSkillCasterState(SkillCasterState* caster_state);
void RecoverSkillCasterState(SkillCasterState* caster_state); void RecoverSkillCasterState(SkillCasterState* caster_state);
CreatureWeakPtr AllocWeakPtr(); CreatureWeakPtr AllocWeakPtr();

View File

@ -732,9 +732,10 @@ namespace MetaData
float x = a8::XValue(strings2[1]).GetDouble(); float x = a8::XValue(strings2[1]).GetDouble();
float y = a8::XValue(strings2[2]).GetDouble(); float y = a8::XValue(strings2[2]).GetDouble();
int hero_id = a8::XValue(strings2[3]); int hero_id = a8::XValue(strings2[3]);
int num = strings2.size() > 4 ? a8::XValue(strings2[4]).GetInt() : 10000;
hero_infos.push_back hero_infos.push_back
( (
std::make_tuple(through_wall, x, y, hero_id) std::make_tuple(through_wall, x, y, hero_id, num)
); );
} }
} }

View File

@ -192,7 +192,7 @@ namespace MetaData
std::vector<std::tuple<int, std::vector<std::tuple<int, int>>>> batch_add_list; std::vector<std::tuple<int, std::vector<std::tuple<int, int>>>> batch_add_list;
std::vector<std::tuple<int, std::vector<int>>> post_remove_action; std::vector<std::tuple<int, std::vector<int>>> post_remove_action;
std::set<int> immune_buffeffect; std::set<int> immune_buffeffect;
std::vector<std::tuple<int, float, float, int>> hero_infos; std::vector<std::tuple<int, float, float, int, int>> hero_infos;
}; };
struct SkillPhase struct SkillPhase

View File

@ -54,7 +54,7 @@ class Obstacle : public Entity
void IncDoorOpenTimes(Room* room); void IncDoorOpenTimes(Room* room);
float GetHealth(Room* room); float GetHealth(Room* room);
void SetHealth(Room* room, float value); void SetHealth(Room* room, float value);
void Die(Room* room); virtual void Die(Room* room);
int GetTeamId(Room* room); int GetTeamId(Room* room);
void SetTeamId(Room* room, int team_id); void SetTeamId(Room* room, int team_id);
int GetMasterId(Room* room); int GetMasterId(Room* room);

View File

@ -636,48 +636,65 @@ Hero* Room::CreateHero(Creature* master,
} }
void Room::RemoveObjectLater(RoomEntity* entity) void Room::RemoveObjectLater(RoomEntity* entity)
{
InternalRemoveObjectLater(entity, entity->xtimer_attacher);
}
void Room::RemoveObjectLater(RoomObstacle* entity)
{
InternalRemoveObjectLater(entity, entity->xtimer_attacher);
}
void Room::InternalRemoveObjectLater(Entity* entity, a8::XTimerAttacher& xtimer_attacher)
{ {
auto remove_func = auto remove_func =
[] (const a8::XParams& param) [] (const a8::XParams& param)
{ {
RoomEntity* entity = (RoomEntity*)param.sender.GetUserData(); Entity* entity = (Entity*)param.sender.GetUserData();
Room* room = (Room*)param.param1.GetUserData();
switch (entity->GetEntityType()) { switch (entity->GetEntityType()) {
case ET_Bullet: case ET_Bullet:
{ {
entity->room->RemoveFromMoveableHash((Bullet*)entity); room->RemoveFromMoveableHash((Bullet*)entity);
entity->room->grid_service->DelBullet((Bullet*)entity); room->grid_service->DelBullet((Bullet*)entity);
} }
break; break;
case ET_Loot: case ET_Loot:
{ {
entity->BroadcastDeleteState(entity->room); entity->BroadcastDeleteState(room);
entity->room->grid_service->DelRoomEntity(entity->room, entity); room->grid_service->DelRoomEntity(room, entity);
} }
break; break;
case ET_Player: case ET_Player:
{ {
entity->room->RemoveFromMoveableHash((Human*)entity); room->RemoveFromMoveableHash((Human*)entity);
entity->room->RemoveFromHuamnHash((Human*)entity); room->RemoveFromHuamnHash((Human*)entity);
} }
break; break;
case ET_Car: case ET_Car:
{ {
#if 0 #if 0
entity->RemoveFromAroundPlayers(entity->room); RemoveFromAroundPlayers(entity->room);
entity->BroadcastDeleteState(entity->room); BroadcastDeleteState(entity->room);
entity->room->grid_service->RemoveCreature((Car*)entity); room->grid_service->RemoveCreature((Car*)entity);
#endif #endif
entity->room->RemoveFromMoveableHash((Car*)entity); room->RemoveFromMoveableHash((Car*)entity);
} }
break; break;
case ET_Hero: case ET_Hero:
{ {
#if 0 #if 0
entity->BroadcastDeleteState(entity->room); BroadcastDeleteState(entity->room);
entity->RemoveFromAroundPlayers(entity->room); RemoveFromAroundPlayers(entity->room);
entity->room->grid_service->RemoveCreature((Hero*)entity); room->grid_service->RemoveCreature((Hero*)entity);
#endif #endif
entity->room->RemoveFromMoveableHash((Hero*)entity); room->RemoveFromMoveableHash((Hero*)entity);
}
break;
case ET_Obstacle:
{
entity->BroadcastDeleteState(room);
room->grid_service->DelRoomEntity(room, entity);
} }
break; break;
default: default:
@ -686,7 +703,7 @@ void Room::RemoveObjectLater(RoomEntity* entity)
} }
break; break;
} }
entity->room->RemoveFromEntityHash(entity); room->RemoveFromEntityHash(entity);
#ifdef DEBUG #ifdef DEBUG
#if 0 #if 0
a8::UdpLog::Instance()->Debug a8::UdpLog::Instance()->Debug
@ -701,11 +718,12 @@ void Room::RemoveObjectLater(RoomEntity* entity)
#endif #endif
delete entity; delete entity;
}; };
xtimer.AddDeadLineTimerAndAttach(0, xtimer.AddDeadLineTimerAndAttach(2,
a8::XParams() a8::XParams()
.SetSender(entity), .SetSender(entity)
.SetParam1(this),
remove_func, remove_func,
&entity->xtimer_attacher.timer_list_); &xtimer_attacher.timer_list_);
} }
void Room::OnHumanDie(Human* hum) void Room::OnHumanDie(Human* hum)

View File

@ -91,6 +91,7 @@ public:
Human* FindEnemy(Human* hum); Human* FindEnemy(Human* hum);
void RemoveObjectLater(RoomEntity* entity); void RemoveObjectLater(RoomEntity* entity);
void RemoveObjectLater(RoomObstacle* entity);
void FillSMJoinedNotify(Player* self_hum, cs::SMJoinedNotify& msg); void FillSMJoinedNotify(Player* self_hum, cs::SMJoinedNotify& msg);
@ -261,6 +262,7 @@ private:
size_t GetRoomMaxPlayerNum(); size_t GetRoomMaxPlayerNum();
void InitAndroidAI(); void InitAndroidAI();
void ForwardGasRing(int n); void ForwardGasRing(int n);
void InternalRemoveObjectLater(Entity* entity, a8::XTimerAttacher& entity_xtimer_attacher);
#ifdef DEBUG #ifdef DEBUG
void InitDebugInfo(); void InitDebugInfo();

View File

@ -31,6 +31,12 @@ RoomObstacle::~RoomObstacle()
#endif #endif
room->map_service->RemoveCollider(collider); room->map_service->RemoveCollider(collider);
} }
if (!detached_) {
if (master.Get()) {
master.Get()->SlaveOnRemove(this);
}
detached_ = true;
}
if (!grid_list_) { if (!grid_list_) {
A8_SAFE_DELETE(grid_list_); A8_SAFE_DELETE(grid_list_);
} }
@ -445,5 +451,25 @@ void RoomObstacle::ActivePosionGas()
void RoomObstacle::DetachFromMaster() void RoomObstacle::DetachFromMaster()
{ {
if (!detached_) {
detached_ = true;
if (master.Get()) {
xtimer_attacher.ClearTimerList();
master.Get()->SlaveOnRemove(this);
room->grid_service->DelRoomEntity(room, this);
if (!IsDead(room)) {
Die(room);
BroadcastFullState(room);
}
room->RemoveObjectLater(this);
}
}
}
void RoomObstacle::Die(Room* room)
{
if (!IsDead(room)) {
Obstacle::Die(room);
DetachFromMaster();
}
} }

View File

@ -22,6 +22,7 @@ class RoomObstacle : public Obstacle
void UpdateTimerFunc(); void UpdateTimerFunc();
void Active(); void Active();
void DetachFromMaster(); void DetachFromMaster();
virtual void Die(Room* room) override;
private: private:
void Explosion(); void Explosion();
@ -35,6 +36,7 @@ protected:
bool temp_through_ = false; bool temp_through_ = false;
std::set<GridCell*>* grid_list_ = nullptr; std::set<GridCell*>* grid_list_ = nullptr;
int explosion_times_ = 0; int explosion_times_ = 0;
bool detached_ = false;
RoomObstacle(); RoomObstacle();