diff --git a/Maple2.File.Ingest/Mapper/MapEntityMapper.cs b/Maple2.File.Ingest/Mapper/MapEntityMapper.cs index a18d7cf81..a9c523995 100644 --- a/Maple2.File.Ingest/Mapper/MapEntityMapper.cs +++ b/Maple2.File.Ingest/Mapper/MapEntityMapper.cs @@ -103,14 +103,14 @@ private IEnumerable ParseMap(string xblock, IEnumerable e return new SpawnPointNPCListEntry(npcId, npcCount); }).WhereNotNull().ToList(); if (npcSpawn.NpcCount == 0 || npcList.Count == 0) { - Console.WriteLine($"No NPCs for {xblock}:{entity.EntityId}"); + //Console.WriteLine($"No NPCs for {xblock}:{entity.EntityId}"); continue; } switch (npcSpawn) { case IEventSpawnPointNPC eventNpcSpawn: yield return new MapEntity(xblock, new Guid(entity.EntityId), entity.EntityName) { - Block = new EventSpawnPointNPC(npcSpawn.EntityId, npcSpawn.SpawnPointID, npcSpawn.Position, npcSpawn.Rotation, npcSpawn.IsVisible, npcSpawn.IsSpawnOnFieldCreate, npcSpawn.SpawnRadius, npcList, (int) npcSpawn.RegenCheckTime, (int) eventNpcSpawn.LifeTime, eventNpcSpawn.SpawnAnimation), + Block = new EventSpawnPointNPC(npcSpawn.EntityId, npcSpawn.SpawnPointID, npcSpawn.Position, npcSpawn.Rotation, npcSpawn.IsVisible, npcSpawn.IsSpawnOnFieldCreate, npcSpawn.SpawnRadius, (int) npcSpawn.NpcCount, npcList, (int) npcSpawn.RegenCheckTime, (int) eventNpcSpawn.LifeTime, eventNpcSpawn.SpawnAnimation), }; continue; default: diff --git a/Maple2.Model/Metadata/MapEntity/SpawnPoint.cs b/Maple2.Model/Metadata/MapEntity/SpawnPoint.cs index cab466e92..228bcc52b 100644 --- a/Maple2.Model/Metadata/MapEntity/SpawnPoint.cs +++ b/Maple2.Model/Metadata/MapEntity/SpawnPoint.cs @@ -35,6 +35,7 @@ public record EventSpawnPointNPC( bool Visible, bool SpawnOnFieldCreate, float SpawnRadius, + int NpcCount, IList NpcList, int RegenCheckTime, int LifeTime, diff --git a/Maple2.Server.Game/Trigger/TriggerContext.Npc.cs b/Maple2.Server.Game/Trigger/TriggerContext.Npc.cs index a2bcbcd16..3786f7e65 100644 --- a/Maple2.Server.Game/Trigger/TriggerContext.Npc.cs +++ b/Maple2.Server.Game/Trigger/TriggerContext.Npc.cs @@ -19,10 +19,14 @@ public void ChangeMonster(int removeSpawnId, int addSpawnId) { SpawnMonster(addSpawnId); } - public void SpawnMonster(int[] spawnIds, bool spawnAnimation, int arg3) { - WarnLog("[CreateMonster] spawnIds:{SpawnIds}, spawnAnimation:{SpawnAnimation}, arg3:{Arg3}", string.Join(", ", spawnIds), spawnAnimation, arg3); + public void SpawnMonster(int[] spawnIds, bool autoTarget, int delay) { + WarnLog("[CreateMonster] spawnIds:{SpawnIds}, autoTarget:{AutoTarget}, delay:{Delay}", string.Join(", ", spawnIds), autoTarget, delay); foreach (int spawnId in spawnIds) { - SpawnNpc(spawnId, spawnAnimation); + if (delay > 0) { + Events.Schedule(() => SpawnNpc(spawnId, autoTarget), TimeSpan.FromMilliseconds(delay)); + } else { + SpawnNpc(spawnId, autoTarget); + } } } @@ -283,7 +287,9 @@ private void SpawnNpc(int spawnId, bool useSpawnAnimation = false) { return; } - foreach (SpawnPointNPCListEntry entry in spawn.NpcList) { + List npcList = spawn.NpcList.OrderBy(_ => Random.Shared.Next()).Take(spawn.NpcCount).ToList(); + + foreach (SpawnPointNPCListEntry entry in npcList) { if (!Field.NpcMetadata.TryGet(entry.NpcId, out NpcMetadata? npc)) { logger.Error("[SpawnNpc] Invalid npcId:{NpcId}", entry.NpcId); continue;