Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[core] Force crit fail on synth if player zones for any reason #6190

Merged
merged 1 commit into from
Sep 2, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Copy link
Contributor

Choose a reason for hiding this comment

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

Just to be anal, can this be extracted out into something in charutils or synthutils? failSynthOnZone or something

Copy link
Member Author

Choose a reason for hiding this comment

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

updated

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
Loading