Skip to content

fix(Scripts/ICC): Fix Risen Archmage respawn after wipe - #25772

Closed
mpfans wants to merge 4 commits into
azerothcore:masterfrom
mpfans:fix/icc-valithria-clean
Closed

fix(Scripts/ICC): Fix Risen Archmage respawn after wipe#25772
mpfans wants to merge 4 commits into
azerothcore:masterfrom
mpfans:fix/icc-valithria-clean

Conversation

@mpfans

@mpfans mpfans commented May 9, 2026

Copy link
Copy Markdown
Contributor

Changes Proposed

  • Core
  • Scripts
  • Database

Script Changes (boss_valithria_dreamwalker.cpp)

Problem: Risen Archmages (NPC 37868) were not respawning after Valithria encounter wipe. Instead of the intended 11-second respawn, they took 7 days (604800 seconds from database).

Root Cause: The old code used RemoveCorpse() followed by SetRespawnTime(11). However, RemoveCorpse() already saved the original spawntime from the database (7 days) before SetRespawnTime(11) could set the new value.

Solution: Changed from RemoveCorpse() + SetRespawnTime(11) to DespawnOrUnsummon(0ms, 11s). This function properly despawns the creature and sets the 11-second respawn timer without database conflicts.

Technical Details:

  • Modified ValithriaDespawner AI script
  • Changed from void SetRespawnTime with RemoveCorpse to DespawnOrUnsummon with relog time parameter
  • Affects spawned Risen Archmages (not summoned)

AI-assisted Pull Requests

  • AI tools (e.g., Claude, ChatGPT, or similar) were used entirely or partially in preparing this pull request. Please specify which tools were used, if any.

Issues Addressed

Source

  • Live research (testing in progress)

Tests Performed

  • Compiles successfully
  • Tested in-game (10-man and 25-man Normal/Heroic)

How to Test

  1. Enter Icecrown Citadel on any difficulty (10/25 Normal/Heroic)
  2. Engage Valithria Dreamwalker encounter
  3. Wipe or reset the encounter (let HP drop below 25% to trigger failure)
  4. Wait 15-20 seconds after wipe
  5. Verify Risen Archmages (NPC 37868) spawn correctly near Valithria platform
  6. Expected: 2 archmages on 10-man, 4 archmages on 25-man
  7. Respawn time should be ~11 seconds, not 7 days

Known Issues

None

@github-actions github-actions Bot added Script Refers to C++ Scripts for the Core file-cpp Used to trigger the matrix build labels May 9, 2026
@mpfans mpfans assigned mpfans and blinkysc and unassigned mpfans and blinkysc May 9, 2026
@mpfans
mpfans requested a review from blinkysc May 9, 2026 05:44
@blinkysc

Copy link
Copy Markdown
Contributor

Do believe this is right, but the comments could probably just be trimmed quite a bit

@github-actions github-actions Bot added CORE Related to the core Bash CMake labels May 11, 2026
- In ValithriaDespawner::Execute(), iterate through GetCreatureRespawnTimes()
  to find Risen Archmages that were killed but corpse already decayed
- Set respawn time to 11 seconds for all Risen Archmages (entry 36968)
- Previously, Cell::VisitObjects could only find creatures still in world,
  missing those that died and decayed during long battles
- Keep DespawnOrUnsummon(0ms, 11s) for visible Archmages as fallback
@mpfans
mpfans force-pushed the fix/icc-valithria-clean branch 6 times, most recently from e777fd5 to e71f6bb Compare May 11, 2026 03:22
- Both Valithria and Risen Archmages respawn in 11s after wipe
- Valithria DB default respawn time is 604800s (7 days)
- When corpse decays, Cell::VisitObjects can't find them
- DespawnOrUnsummon() never called, respawn time not reset
- operator(): use DespawnOrUnsummon(0ms, 11s)
- Execute(): iterate respawn times for decayed corpses
@mpfans
mpfans force-pushed the fix/icc-valithria-clean branch from e71f6bb to 7cab302 Compare May 11, 2026 03:25
@mpfans

mpfans commented May 11, 2026

Copy link
Copy Markdown
Contributor Author

Do believe this is right, but the comments could probably just be trimmed quite a bit

Last night, after testing, if all players die immediately after opening BOSS, Archmage will refresh normally. However, if Archmage's body disappears and then the team is destroyed, it will not refresh. Therefore, I have submitted the repair again today. Please review again

@mpfans
mpfans requested a review from Nyeriah May 11, 2026 03:38
@mpfans mpfans removed Bash CMake file-cpp Used to trigger the matrix build labels May 13, 2026
@Nyeriah

Nyeriah commented Jun 10, 2026

Copy link
Copy Markdown
Member

This doesn't seem right

@sudlud
sudlud force-pushed the fix/icc-valithria-clean branch from 7cab302 to 0e0d8b7 Compare June 27, 2026 07:04
@github-actions github-actions Bot added the file-cpp Used to trigger the matrix build label Jun 27, 2026
@sudlud
sudlud force-pushed the fix/icc-valithria-clean branch from 0e0d8b7 to 7cab302 Compare June 27, 2026 07:07
@coderabbitai

coderabbitai Bot commented Jun 27, 2026

Copy link
Copy Markdown
Contributor

Review Change Stack

Caution

Review failed

The head commit changed during the review from 7cab302 to 3fa2a5c.

📝 Walkthrough

Walkthrough

Valithria Dreamwalker reset handling now updates saved respawn times for the boss and risen archmages, and forces encounter creatures to despawn with explicit 11-second timing after restoring their stored position.

Changes

Valithria reset timing

Layer / File(s) Summary
Respawn and cleanup timing
src/server/scripts/Northrend/IcecrownCitadel/boss_valithria_dreamwalker.cpp
GameTime is added, encounter respawn timestamps are rewritten for NPC_RISEN_ARCHMAGE and NPC_VALITHRIA_DREAMWALKER, and creature cleanup now restores position before DespawnOrUnsummon(0ms, 11s).

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~10 minutes

Suggested labels

Ready to be Reviewed, Tested

Suggested reviewers

  • sudlud
🚥 Pre-merge checks | ✅ 4 | ❌ 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 (4 passed)
Check name Status Explanation
Title check ✅ Passed The title clearly and concisely summarizes the main fix: Risen Archmage respawn handling after a Valithria wipe.
Description check ✅ Passed The description covers the change, issue, source, testing, how to test, and known issues, matching the template well.
Linked Issues check ✅ Passed The change addresses #25768 by fixing Valithria wipe reset and ensuring archmages respawn correctly for a new attempt.
Out of Scope Changes check ✅ Passed The changes stay within the ICC Valithria script fix and do not introduce unrelated scope.
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

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

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

🧹 Nitpick comments (1)
src/server/scripts/Northrend/IcecrownCitadel/boss_valithria_dreamwalker.cpp (1)

238-240: 📐 Maintainability & Code Quality | 🔵 Trivial | ⚡ Quick win

Extract the 11-second reset delay into one constant.

The reset timing now has to stay synchronized between persisted respawn timestamps and DespawnOrUnsummon; using one named duration avoids future drift.

♻️ Proposed refactor
+static constexpr auto ValithriaResetRespawnDelay = 11s;
+
-            time_t newRespawnTime = GameTime::GetGameTime().count() + 11;
+            time_t newRespawnTime = GameTime::GetGameTime().count() + ValithriaResetRespawnDelay.count();
             for (ObjectGuid::LowType spawnId : toRespawn)
                 map->SaveCreatureRespawnTime(spawnId, newRespawnTime);
@@
         // Force the encounter's 11s reset; the DB respawn delay can be up to 7 days.
-        creature->DespawnOrUnsummon(0ms, 11s);
+        creature->DespawnOrUnsummon(0ms, ValithriaResetRespawnDelay);

Also applies to: 283-284

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@src/server/scripts/Northrend/IcecrownCitadel/boss_valithria_dreamwalker.cpp`
around lines 238 - 240, The reset delay is duplicated as a raw 11-second value
and should be centralized to keep respawn persistence and despawn timing in
sync. Introduce a single named constant for the reset duration in the Valithria
Dreamwalker logic, then use it both where `newRespawnTime` is computed and where
`DespawnOrUnsummon` is scheduled, so the timing stays consistent across the
affected code paths.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Nitpick comments:
In `@src/server/scripts/Northrend/IcecrownCitadel/boss_valithria_dreamwalker.cpp`:
- Around line 238-240: The reset delay is duplicated as a raw 11-second value
and should be centralized to keep respawn persistence and despawn timing in
sync. Introduce a single named constant for the reset duration in the Valithria
Dreamwalker logic, then use it both where `newRespawnTime` is computed and where
`DespawnOrUnsummon` is scheduled, so the timing stays consistent across the
affected code paths.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yml

Review profile: CHILL

Plan: Pro Plus

Run ID: d860ed7f-9bec-4ca2-88eb-9304d7023c0f

📥 Commits

Reviewing files that changed from the base of the PR and between f5b21bb and 0e0d8b7.

📒 Files selected for processing (1)
  • src/server/scripts/Northrend/IcecrownCitadel/boss_valithria_dreamwalker.cpp

…::id

PR azerothcore#25197 renamed CreatureData::id1 to id, so the despawner loop no longer
compiled. Update the field access and clean up the loop per review:

- Snapshot matching spawnIds first, then re-time outside the iteration to
  avoid mutating GetCreatureRespawnTimes() while iterating it.
- Drop the redundant per-map mapid guard (the store is already per-map).
- Trim the comments.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
@sudlud

sudlud commented Jun 29, 2026

Copy link
Copy Markdown
Member

Heads up: while working on this branch, Claude (an AI assistant) force-pushed without permission and messed up the PR history. It's been restored, the original commits are intact, and the branch is now updated with a clean merge of master plus one new commit on top, no rewritten history. Apologies for the noise (and the confused CodeRabbit run).

What's on the branch now:

  • Dead-creature path uses DespawnOrUnsummon(0ms, 11s) instead of RemoveCorpse(false) + SetRespawnTime(11). The old code never persisted the 11s: RemoveCorpse saves the DB respawn (7 days) and removes the object, so the following SetRespawnTime(11) writes to an object already being destroyed.
  • Archmage spawns (37868) have spawntimesecs = 604800 like Valithria, so one killed mid-attempt gets a 7-day respawn once its corpse decays and the Cell::VisitObjects sweep can no longer reach it. The added loop re-times those saved respawns to 11s.
  • Fixes vs the earlier push: builds on current master (id1 was renamed to id in refactor(Core/DB): normalize creature table by extracting multi-ID spawns #25197), the loop snapshots spawn ids before writing instead of mutating the container mid-iteration, comments trimmed.

CodeRabbit's only note is a nitpick: factor the 11/11s into one named constant. Can add.

@Nyeriah you said "this doesn't seem right", what specifically looks wrong to you? If it's the boss script touching the map respawn table in Execute(), I can scope it to the known archmage/Valithria spawn ids instead.

@mpfans

mpfans commented Jun 30, 2026

Copy link
Copy Markdown
Contributor Author

I have already applied this PR to my product server and tested it for several weeks with everything going well

@Nyeriah

Nyeriah commented Jul 19, 2026

Copy link
Copy Markdown
Member

Thanks for the PR, but the issue here was that we shouldn’t ever need to manipulate respawns in boss scripts like this. TrinityCore’s approach offers a cleaner and therefore better solution to this problem

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

CORE Related to the core file-cpp Used to trigger the matrix build Script Refers to C++ Scripts for the Core

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[ICC/Valithria Dreamwalker]: Respawn after the first Try wipe doesn't work correctly.

4 participants