Skip to content

Conversation

@Zintixx
Copy link
Collaborator

@Zintixx Zintixx commented Jan 17, 2026

Summary by CodeRabbit

  • New Features

    • NPC spawning supports configurable delays for time-based scheduling
    • NPC pools now spawn a randomized subset limited by a configurable count
  • Improvements

    • Spawn method parameters renamed for clearer intent and logging
  • Bug Fixes

    • Removed noisy runtime diagnostic that previously reported empty NPC entries

✏️ Tip: You can customize this high-level summary in your review settings.

@coderabbitai
Copy link
Contributor

coderabbitai bot commented Jan 17, 2026

Walkthrough

Adds 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

Cohort / File(s) Summary
Model: EventSpawnPointNPC
Maple2.Model/Metadata/MapEntity/SpawnPoint.cs
Added int NpcCount field/constructor parameter to EventSpawnPointNPC, increasing constructor arity.
Mapper updates
Maple2.File.Ingest/Mapper/MapEntityMapper.cs
Passes the new NpcCount parameter into EventSpawnPointNPC construction; removed a Console.WriteLine diagnostic about missing NPCs.
Trigger / Spawning logic
Maple2.Server.Game/Trigger/TriggerContext.Npc.cs
Changed SpawnMonster signature to (int[] spawnIds, bool autoTarget, int delay); added delay-based scheduling; SpawnNpc now shuffles spawn.NpcList and takes up to spawn.NpcCount entries before spawning.

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
Loading

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~20 minutes

Possibly related PRs

Suggested reviewers

  • AngeloTadeucci

Poem

🐰 I count the bunnies, shuffled in a row,

A little delay, then out they go.
The noisy log quieted, calm and neat,
A hopping dance of spawns, a playful beat.
🥕✨

🚥 Pre-merge checks | ✅ 2 | ❌ 1
❌ Failed checks (1 warning)
Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (2 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The pull request title 'Adjust spawn count on triggers' directly reflects the main change: adding NpcCount parameter to spawn handling in EventSpawnPointNPC and modifying SpawnMonster to use spawn.NpcCount for limiting NPC spawns.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing touches
  • 📝 Generate docstrings

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.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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 commented Console.WriteLine instead of keeping dead code.

🧹 Suggested cleanup
-                                //Console.WriteLine($"No NPCs for {xblock}:{entity.EntityId}");

@AngeloTadeucci AngeloTadeucci merged commit 6740a9d into master Jan 20, 2026
4 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants