diff --git a/server/gameserver/creature.cc b/server/gameserver/creature.cc index 5585b73..21fc2fc 100644 --- a/server/gameserver/creature.cc +++ b/server/gameserver/creature.cc @@ -1937,6 +1937,7 @@ void Creature::SummonObstacle(Buff* buff, int id, const a8::Vec2& pos) } RoomObstacle* obstacle = room->CreateObstacle(id, pos.x, pos.y); if (obstacle) { + obstacle->buff_meta = buff->meta; obstacle->master.Attach(this); obstacle->SetTeamId(room, team_id); obstacle->SetMasterId(room, GetUniId()); @@ -1947,7 +1948,9 @@ void Creature::SummonObstacle(Buff* buff, int id, const a8::Vec2& pos) SendDebugMsg(a8::Format("召唤物件 buff_id:%d thing_id:%d", {buff->meta->i->buff_id(), id})); #endif } else { +#ifdef DEBUG abort(); +#endif } } diff --git a/server/gameserver/roomobstacle.cc b/server/gameserver/roomobstacle.cc index 28e3b4d..1f5f2ad 100644 --- a/server/gameserver/roomobstacle.cc +++ b/server/gameserver/roomobstacle.cc @@ -299,6 +299,20 @@ void RoomObstacle::Active() } break; } + if (meta->i->life_time() > 0) { + room->xtimer.AddDeadLineTimerAndAttach + ( + meta->i->life_time() / FRAME_RATE_MS, + a8::XParams() + .SetSender(this), + [] (const a8::XParams& param) + { + RoomObstacle* obstacle = (RoomObstacle*)param.sender.GetUserData(); + obstacle->DetachFromMaster(); + }, + &xtimer_attacher.timer_list_ + ); + } } void RoomObstacle::ActiveSelfExplosion() diff --git a/server/gameserver/roomobstacle.h b/server/gameserver/roomobstacle.h index 8442ee4..ad658c8 100644 --- a/server/gameserver/roomobstacle.h +++ b/server/gameserver/roomobstacle.h @@ -5,6 +5,11 @@ #include "obstacle.h" #include "weakptr.h" +namespace MetaData +{ + struct Buff; +} + class Ability; class RoomObstacle : public Obstacle { @@ -16,6 +21,7 @@ class RoomObstacle : public Obstacle int real_object_uniid = 0; std::shared_ptr context_ability; bool sweep_lock = false; + MetaData::Buff* buff_meta = nullptr; virtual ~RoomObstacle() override; virtual void Initialize() override; diff --git a/server/tools/protobuild/metatable.proto b/server/tools/protobuild/metatable.proto index 0ec5359..db3557d 100755 --- a/server/tools/protobuild/metatable.proto +++ b/server/tools/protobuild/metatable.proto @@ -73,6 +73,7 @@ message MapThing optional int32 explosion_hit = 30; optional string sweep_tags = 31; optional int32 prebattle_hide = 32; + optional int32 life_time = 33; } message SafeArea