From cd9c6493ba676692df6da6096620cfb80939b144 Mon Sep 17 00:00:00 2001 From: Xaver-DaRed Date: Sun, 19 Jan 2025 19:19:28 +0100 Subject: [PATCH] Implement successful desynth and critical fail messages --- src/map/packets/synth_message.h | 4 +++- src/map/utils/charutils.cpp | 2 +- src/map/utils/synthutils.cpp | 22 ++++++++++++++-------- src/map/utils/synthutils.h | 2 +- 4 files changed, 19 insertions(+), 11 deletions(-) diff --git a/src/map/packets/synth_message.h b/src/map/packets/synth_message.h index a9aca484089..67975e62339 100644 --- a/src/map/packets/synth_message.h +++ b/src/map/packets/synth_message.h @@ -35,7 +35,9 @@ enum SYNTH_MESSAGE SYNTH_CANCEL, SYNTH_FAILCRYSTAL, SYNTH_NOSKILL, - SYNTH_CANCELRARE + SYNTH_CANCELRARE, + SYNTH_SUCCESS_DESYNTH = 12, + SYNTH_FAIL_CRITICAL = 14, // 0x0E }; class CCharEntity; diff --git a/src/map/utils/charutils.cpp b/src/map/utils/charutils.cpp index 27684b7b643..550418c4b38 100644 --- a/src/map/utils/charutils.cpp +++ b/src/map/utils/charutils.cpp @@ -7191,7 +7191,7 @@ namespace charutils ShowWarning("%s: %s attempting to zone in the middle of a synth, failing their synth!", sourceFunction, PChar->getName()); PChar->setModifier(Mod::SYNTH_MATERIAL_LOSS, -1000); // Force crit fail - synthutils::doSynthFail(PChar); + synthutils::doSynthFail(PChar, true); PChar->CraftContainer->Clean(); // Clean to reset m_ItemCount to 0 } diff --git a/src/map/utils/synthutils.cpp b/src/map/utils/synthutils.cpp index 9c1be3bd4d1..5331fc2bd29 100644 --- a/src/map/utils/synthutils.cpp +++ b/src/map/utils/synthutils.cpp @@ -976,7 +976,7 @@ namespace synthutils * * **************************************************************************/ - void doSynthFail(CCharEntity* PChar) + void doSynthFail(CCharEntity* PChar, bool isCriticalFail) { // Break material calculations. if (PChar->CraftContainer->getCraftType() != CRAFT_SYNTHESIS_NO_LOSS) // If it's a synth where no materials can be lost, skip break calculations. @@ -987,15 +987,17 @@ namespace synthutils // Push "Synthesis failed" messages. uint16 currentZone = PChar->loc.zone->GetID(); + const auto message = isCriticalFail ? SYNTH_FAIL_CRITICAL : SYNTH_FAIL; + if (currentZone && currentZone != ZONE_MONORAIL_PRE_RELEASE && currentZone != ZONE_49 && currentZone < MAX_ZONEID) { - PChar->loc.zone->PushPacket(PChar, CHAR_INRANGE, std::make_unique(PChar, SYNTH_FAIL)); + PChar->loc.zone->PushPacket(PChar, CHAR_INRANGE, std::make_unique(PChar, message)); } - PChar->pushPacket(PChar, SYNTH_FAIL, 29695); + PChar->pushPacket(PChar, message, 29695); } /********************************************************************* @@ -1160,7 +1162,7 @@ namespace synthutils // Block the cheat by forcing the synth to fail PChar->CraftContainer->setQuantity(0, synthutils::SYNTHESIS_FAIL); m_synthResult = SYNTHESIS_FAIL; - doSynthFail(PChar); + doSynthFail(PChar, false); } // And report the incident (will possibly jail the player) anticheat::ReportCheatIncident(PChar, anticheat::CheatID::CHEAT_ID_FASTSYNTH, @@ -1176,7 +1178,7 @@ namespace synthutils if (m_synthResult == SYNTHESIS_FAIL) { - doSynthFail(PChar); + doSynthFail(PChar, false); } else { @@ -1238,14 +1240,18 @@ namespace synthutils } PChar->pushPacket(); + + // Use appropiate message (Regular or desynthesis) + const auto message = PChar->CraftContainer->getCraftType() == CRAFT_DESYNTHESIS ? SYNTH_SUCCESS_DESYNTH : SYNTH_SUCCESS; + if (PChar->loc.zone->GetID() != 255 && PChar->loc.zone->GetID() != 0) { - PChar->loc.zone->PushPacket(PChar, CHAR_INRANGE, std::make_unique(PChar, SYNTH_SUCCESS, itemID, quantity)); - PChar->pushPacket(PChar, SYNTH_SUCCESS, itemID, quantity); + PChar->loc.zone->PushPacket(PChar, CHAR_INRANGE, std::make_unique(PChar, message, itemID, quantity)); + PChar->pushPacket(PChar, message, itemID, quantity); } else { - PChar->pushPacket(PChar, SYNTH_SUCCESS, itemID, quantity); + PChar->pushPacket(PChar, message, itemID, quantity); } // Calculate what craft this recipe "belongs" to based on highest skill required diff --git a/src/map/utils/synthutils.h b/src/map/utils/synthutils.h index fd7b09e54ba..73331f0417a 100644 --- a/src/map/utils/synthutils.h +++ b/src/map/utils/synthutils.h @@ -58,7 +58,7 @@ namespace synthutils void LoadSynthRecipes(); int32 startSynth(CCharEntity* PChar); int32 sendSynthDone(CCharEntity* PChar); - void doSynthFail(CCharEntity* PChar); + void doSynthFail(CCharEntity* PChar, bool isCriticalFail); }; // namespace synthutils #endif