Skip to content

Commit

Permalink
Merge pull request #6190 from WinterSolstice8/zoning_synth_stuff
Browse files Browse the repository at this point in the history
[core] Force crit fail on synth if player zones for any reason
  • Loading branch information
claywar authored Sep 2, 2024
2 parents 5ceaed6 + 8e41ae8 commit 250a64a
Show file tree
Hide file tree
Showing 4 changed files with 31 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
23 changes: 23 additions & 0 deletions src/map/utils/charutils.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,7 @@
#include "roe.h"
#include "spell.h"
#include "status_effect_container.h"
#include "trade_container.h"
#include "trait.h"
#include "treasure_pool.h"
#include "unitychat.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,12 @@ namespace charutils
PChar->resetPetZoningInfo();
}

// If player somehow gets zoned, force crit fail their synth
if (PChar->CraftContainer && PChar->CraftContainer->getItemsCount() > 0)
{
charutils::forceSynthCritFail("SendToZone", PChar);
}

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

Expand Down Expand Up @@ -7122,4 +7130,19 @@ namespace charutils
return 0;
}

void forceSynthCritFail(std::string sourceFunction, CCharEntity* PChar)
{
// NOTE:
// Supposed non-losable items are reportedly 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("%s: %s attempting to zone in the middle of a synth, failing their synth!", sourceFunction, 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
}

}; // namespace charutils
2 changes: 2 additions & 0 deletions src/map/utils/charutils.h
Original file line number Diff line number Diff line change
Expand Up @@ -279,6 +279,8 @@ namespace charutils
bool hasEntitySpawned(CCharEntity* PChar, CBaseEntity* entity);

uint32 getCharIdFromName(std::string const& name);

void forceSynthCritFail(std::string sourceFunction, CCharEntity* PChar);
}; // namespace charutils

#endif // _CHARUTILS_H
6 changes: 6 additions & 0 deletions src/map/zone_entities.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -485,6 +485,12 @@ 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)
{
charutils::forceSynthCritFail("DecreaseZoneCounter", PChar);
}

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

0 comments on commit 250a64a

Please sign in to comment.