Skip to content

Commit

Permalink
[core] Force crit fail on synth if player zones for any reason
Browse files Browse the repository at this point in the history
  • Loading branch information
WinterSolstice8 committed Aug 30, 2024
1 parent b736713 commit 8cd103c
Show file tree
Hide file tree
Showing 3 changed files with 33 additions and 12 deletions.
12 changes: 0 additions & 12 deletions src/map/packet_system.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -553,18 +553,6 @@ void SmallPacket0x00D(map_session_data_t* const PSession, CCharEntity* const PCh
PSession->shuttingDown = 2;
_sql->Query("UPDATE char_stats SET zoning = 1 WHERE charid = %u", PChar->id);
charutils::CheckEquipLogic(PChar, SCRIPT_CHANGEZONE, PChar->getZone());

if (PChar->CraftContainer->getItemsCount() > 0 && PChar->animation == ANIMATION_SYNTH)
{
// NOTE:
// Supposed non-losable items are reportely lost if this condition is met:
// https://ffxiclopedia.fandom.com/wiki/Lu_Shang%27s_Fishing_Rod
// The broken rod can never be lost in a normal failed synth. It will only be lost if the synth is
// interrupted in some way, such as by being attacked or moving to another area (e.g. ship docking).

ShowWarning("SmallPacket0x00D: %s attempting to zone in the middle of a synth, failing their synth!", PChar->getName());
synthutils::doSynthFail(PChar);
}
}

if (PChar->loc.zone != nullptr)
Expand Down
17 changes: 17 additions & 0 deletions src/map/utils/charutils.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,7 @@
#include "spell.h"
#include "status_effect_container.h"
#include "trait.h"
#include "trade_container.h"
#include "treasure_pool.h"
#include "unitychat.h"
#include "universal_container.h"
Expand All @@ -103,6 +104,7 @@
#include "itemutils.h"
#include "petutils.h"
#include "puppetutils.h"
#include "synthutils.h"
#include "zoneutils.h"

/************************************************************************
Expand Down Expand Up @@ -6521,6 +6523,21 @@ namespace charutils
PChar->resetPetZoningInfo();
}

if (PChar->CraftContainer && PChar->CraftContainer->getItemsCount() > 0)
{
// NOTE:
// Supposed non-losable items are reportely lost if this condition is met:
// https://ffxiclopedia.fandom.com/wiki/Lu_Shang%27s_Fishing_Rod
// The broken rod can never be lost in a normal failed synth. It will only be lost if the synth is
// interrupted in some way, such as by being attacked or moving to another area (e.g. ship docking).

ShowWarning("SendToZone: %s attempting to zone in the middle of a synth, failing their synth!", PChar->getName());
PChar->setModifier(Mod::SYNTH_FAIL_RATE, 10000); // Force crit fail
synthutils::doSynthFail(PChar);

PChar->CraftContainer->Clean(); // Clean to reset m_ItemCount to 0
}

PChar->pushPacket(new CServerIPPacket(PChar, type, ipp));
}

Expand Down
16 changes: 16 additions & 0 deletions src/map/zone_entities.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -485,6 +485,22 @@ void CZoneEntities::DecreaseZoneCounter(CCharEntity* PChar)
}
}

// Duplicated from charUtils, it is theoretically possible through d/c magic to hit this block and not sendToZone
if (PChar->CraftContainer && PChar->CraftContainer->getItemsCount() > 0)
{
// NOTE:
// Supposed non-losable items are reportely lost if this condition is met:
// https://ffxiclopedia.fandom.com/wiki/Lu_Shang%27s_Fishing_Rod
// The broken rod can never be lost in a normal failed synth. It will only be lost if the synth is
// interrupted in some way, such as by being attacked or moving to another area (e.g. ship docking).

ShowWarning("DecreaseZoneCounter: %s attempting to zone in the middle of a synth, failing their synth!", PChar->getName());
PChar->setModifier(Mod::SYNTH_FAIL_RATE, 10000); // Force crit fail
synthutils::doSynthFail(PChar);

PChar->CraftContainer->Clean(); // Clean to reset m_ItemCount to 0
}

if (PChar->animation == ANIMATION_SYNTH)
{
PChar->CraftContainer->setQuantity(0, synthutils::SYNTHESIS_FAIL);
Expand Down

0 comments on commit 8cd103c

Please sign in to comment.