From faba088cf7096d9e576edd8a5e1ed584f0c1fccb Mon Sep 17 00:00:00 2001 From: Jesse Sestito Date: Mon, 18 May 2026 13:08:06 -0500 Subject: [PATCH] [cpp] Enable cutscene immunity on zone-in events This enables the cutscene immunity using setLocked. It also adds in invisibility until the cutscene is done. --- src/map/entities/charentity.cpp | 10 ++++++---- src/map/entities/charentity.h | 3 ++- src/map/event_info.h | 1 + src/map/lua/luautils.cpp | 10 ++++++++++ src/map/packets/char_update.cpp | 2 +- 5 files changed, 20 insertions(+), 6 deletions(-) diff --git a/src/map/entities/charentity.cpp b/src/map/entities/charentity.cpp index 15c8bdd60a3..f7ca5e936f6 100644 --- a/src/map/entities/charentity.cpp +++ b/src/map/entities/charentity.cpp @@ -118,9 +118,10 @@ CCharEntity::CCharEntity() eventPreparation = new EventPrep(); currentEvent = new EventInfo(); - inSequence = false; - gotMessage = false; - m_Locked = false; + inSequence = false; + gotMessage = false; + m_Locked = false; + m_zoneInCutscene = false; accid = 0; m_GMlevel = 0; @@ -2921,7 +2922,8 @@ void CCharEntity::endCurrentEvent() currentEvent->reset(); eventPreparation->reset(); setLocked(false); - m_Substate = CHAR_SUBSTATE::SUBSTATE_NONE; + m_zoneInCutscene = false; + m_Substate = CHAR_SUBSTATE::SUBSTATE_NONE; tryStartNextEvent(); } diff --git a/src/map/entities/charentity.h b/src/map/entities/charentity.h index f2c7e69dc4b..3423d9ad0e6 100644 --- a/src/map/entities/charentity.h +++ b/src/map/entities/charentity.h @@ -749,7 +749,8 @@ class CCharEntity : public CBattleEntity void clearCharVarsWithPrefix(const std::string& prefix); - bool m_Locked{}; // Is the player locked in a cutscene + bool m_Locked{}; // Is the player locked in a cutscene + bool m_zoneInCutscene{}; // Is the player currently in a zone-in cutscene // Starts a synth with skillType X bool startSynth(SKILLTYPE synthSkill); diff --git a/src/map/event_info.h b/src/map/event_info.h index e355b96d54e..4e61b8f19d6 100644 --- a/src/map/event_info.h +++ b/src/map/event_info.h @@ -79,6 +79,7 @@ struct EventInfo : EventPrep strings.clear(); textTable = -1; eventFlags = 0; + type = NORMAL; } }; diff --git a/src/map/lua/luautils.cpp b/src/map/lua/luautils.cpp index 59ab90c5b87..24fdf13649f 100644 --- a/src/map/lua/luautils.cpp +++ b/src/map/lua/luautils.cpp @@ -1989,6 +1989,8 @@ void OnZoneIn(CCharEntity* PChar) return; } + PChar->m_zoneInCutscene = false; + CZone* prevZone = zoneutils::GetZone(PChar->loc.prevzone); std::string prevZoneStr = "Unknown"; if (prevZone) @@ -2025,6 +2027,14 @@ void OnZoneIn(CCharEntity* PChar) { PChar->currentEvent->eventId = result.get(); } + + // On zone-in events + if (PChar->currentEvent->eventId >= 0) + { + PChar->currentEvent->type = CUTSCENE; + PChar->m_zoneInCutscene = true; + PChar->setLocked(true); + } } void AfterZoneIn(CBaseEntity* PChar) diff --git a/src/map/packets/char_update.cpp b/src/map/packets/char_update.cpp index 761ab5844b3..b475830071b 100644 --- a/src/map/packets/char_update.cpp +++ b/src/map/packets/char_update.cpp @@ -285,7 +285,7 @@ void CCharUpdatePacket::updateWith(CCharEntity* PChar, ENTITYUPDATE type, uint8 packet->ModelHitboxSize = static_cast(PChar->modelHitboxSize * 10); // TODO: verify this value and if it changes (Monstrosity?) packet->Flags1.MonsterFlag = false; // TODO: Is this ever set for Monstrosity PVP? - packet->Flags1.HideFlag = false; + packet->Flags1.HideFlag = PChar->m_zoneInCutscene; packet->Flags1.SleepFlag = 0; // Something to do with events. // TODO: figure out when/if this is set. Probably when you're in a cutscene? packet->Flags1.unknown_0_3 = PChar->loc.zone ? PChar->loc.zone->CanUseMisc(MISC_TREASURE) : 0; // Set global treasure pool packet->Flags1.unknown_0_4 = 0;