2222#include " components/ActorStatus.hpp"
2323#include " components/CharacterStatus.hpp"
2424#include " components/DeletionTimer.hpp"
25+ #include " components/ActorRespawnTimer.hpp"
2526#include " components/Loot.hpp"
2627#include " components/NpcAppearance.hpp"
2728#include " components/PlayerAppearance.hpp"
3738#include " systems/ActorDeletionTimerSystem.hpp"
3839#include " systems/ActorAbnormalEffectSystem.hpp"
3940#include " systems/ActorStatsUpdateSystem.hpp"
41+ #include " systems/ActorRespawnSystem.hpp"
4042
4143#include < l2cpp/CompileTimeConfig.hpp>
4244
@@ -59,6 +61,26 @@ static void addGremlin()
5961 gremlin->setPosX (gremlin->position ().x + (count++ % 2 ? 35 : -35 ));
6062}
6163
64+ static void addGoblin ()
65+ {
66+ static u32 count = 1 ;
67+
68+ if (auto const goblin = World::addMonster (3 ))
69+ goblin->setPosX (goblin->position ().x + (count++ % 2 ? 120 : -120 ));
70+
71+
72+ }
73+
74+ static void addImp ()
75+ {
76+ static u32 count = 1 ;
77+
78+ if (auto const imp = World::addMonster (4 ))
79+ imp->setPosX (imp->position ().x + (count++ % 2 ? 200 : -200 ));
80+
81+
82+ }
83+
6284static void addDummy ()
6385{
6486 static u32 count = 1 ;
@@ -82,6 +104,8 @@ void World::init()
82104 registerSystem<ActorAutoRegenSystem>();
83105 registerSystem<ActorDeletionTimerSystem>();
84106 registerSystem<ActorAbnormalEffectSystem>();
107+ registerSystem<ActorRespawnSystem>();
108+
85109 // Must be last!
86110 registerSystem<ActorStatsUpdateSystem>();
87111
@@ -96,6 +120,10 @@ void World::init()
96120 addGremlin ();
97121 addGremlin ();
98122
123+ addGoblin ();
124+
125+ addImp ();
126+
99127 addDummy ();
100128 addDummy ();
101129}
@@ -285,6 +313,15 @@ void World::unscheduleForDeletion(Actor & a)
285313 a.delComponent <DeletionTimer>();
286314}
287315
316+ void World::scheduleNpcRespawn (Actor& deadActor, u32 npcId, ClockDuration delay)
317+ {
318+ auto & timer = deadActor.getOrAddComponent <ActorRespawnTimer>();
319+ timer.npcId = npcId;
320+ timer.respawnDelay = delay;
321+ timer.elapsedSinceDeath = ClockDuration::zero ();
322+ timer.spawnPosition = deadActor.position ();
323+ }
324+
288325auto World::inGameTime () -> std::chrono::minutes
289326{
290327 if constexpr (Config::isDebugMode)
0 commit comments