Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions Maple2.File.Ingest/Mapper/MapEntityMapper.cs
Original file line number Diff line number Diff line change
Expand Up @@ -103,14 +103,14 @@ private IEnumerable<MapEntity> ParseMap(string xblock, IEnumerable<IMapEntity> 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:
Expand Down
1 change: 1 addition & 0 deletions Maple2.Model/Metadata/MapEntity/SpawnPoint.cs
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ public record EventSpawnPointNPC(
bool Visible,
bool SpawnOnFieldCreate,
float SpawnRadius,
int NpcCount,
IList<SpawnPointNPCListEntry> NpcList,
int RegenCheckTime,
int LifeTime,
Expand Down
14 changes: 10 additions & 4 deletions Maple2.Server.Game/Trigger/TriggerContext.Npc.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
}
}

Expand Down Expand Up @@ -283,7 +287,9 @@ private void SpawnNpc(int spawnId, bool useSpawnAnimation = false) {
return;
}

foreach (SpawnPointNPCListEntry entry in spawn.NpcList) {
List<SpawnPointNPCListEntry> 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;
Expand Down
Loading