Adjust spawn count on triggers - #622
Conversation
WalkthroughAdds an int NpcCount to EventSpawnPointNPC, propagates it via the mapper, and updates TriggerContext spawning to accept autoTarget and delay, schedule delayed spawns, and spawn a random subset of NPCs limited by NpcCount. Changes
Sequence Diagram(s)sequenceDiagram
participant Caller as Trigger/Caller
participant Trigger as SpawnMonster
participant Scheduler as Scheduler/Timer
participant Spawner as SpawnNpc
participant NPCSys as NPC System
Caller->>Trigger: SpawnMonster(spawnIds, autoTarget, delay)
alt delay > 0
Trigger->>Scheduler: Schedule SpawnNpc(spawnId, autoTarget) after delay
Scheduler-->>Trigger: Scheduled
else delay <= 0
Trigger->>Spawner: SpawnNpc(spawnId, autoTarget)
end
opt execute spawn (delayed or immediate)
Scheduler->>Spawner: Trigger SpawnNpc(spawnId, autoTarget)
Spawner->>Spawner: Shuffle spawn.NpcList and take up to spawn.NpcCount
Spawner->>NPCSys: Spawn each selected NPC (with autoTarget)
NPCSys-->>Spawner: Spawn results
Spawner-->>Caller: Complete
end
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~20 minutes Possibly related PRs
Suggested reviewers
Poem
🚥 Pre-merge checks | ✅ 2 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (2 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing touches
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
There was a problem hiding this comment.
Actionable comments posted: 1
🤖 Fix all issues with AI agents
In `@Maple2.Server.Game/Trigger/TriggerContext.Npc.cs`:
- Around line 22-29: The parameter name autoTarget in SpawnMonster is misleading
because it actually controls spawn animation passed into SpawnNpc; rename the
parameter to useSpawnAnimation (and update the WarnLog format token
spawnAnimation) and update the forwarded argument to SpawnNpc(spawnId,
useSpawnAnimation); also rename the parameter on SpawnNpc (and all call sites)
to match, or alternatively implement real targeting behavior and keep the
name—ensure all references, log labels, and scheduled lambda captures are
updated consistently to avoid compilation errors.
🧹 Nitpick comments (1)
Maple2.File.Ingest/Mapper/MapEntityMapper.cs (1)
106-107: Drop commented-out diagnostics to keep mapper clean.
Consider removing the commentedConsole.WriteLineinstead of keeping dead code.🧹 Suggested cleanup
- //Console.WriteLine($"No NPCs for {xblock}:{entity.EntityId}");
Summary by CodeRabbit
New Features
Improvements
Bug Fixes
✏️ Tip: You can customize this high-level summary in your review settings.