Skip to content
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
13 changes: 7 additions & 6 deletions HeavenClient/Gameplay/MapleMap/FieldLimit.h
Original file line number Diff line number Diff line change
Expand Up @@ -152,17 +152,18 @@ namespace ms
}

// v83 FUN_00a0977b: bit 0x4 keeps summoning sacks shut unless the
// map's info/allowedItem lists them.
inline bool may_summon(int32_t fieldlimit, const std::vector<int32_t> &allowed, int32_t item_id)
// map's info/allowedItem lists them. A GM (FUN_00473cde() & 1) may
// open one anywhere.
inline bool may_summon(int32_t fieldlimit, const std::vector<int32_t> &allowed, int32_t item_id, bool gm)
{
return !(fieldlimit & SUMMON_SACKS) || std::find(allowed.begin(), allowed.end(), item_id) != allowed.end();
return gm || !(fieldlimit & SUMMON_SACKS) || std::find(allowed.begin(), allowed.end(), item_id) != allowed.end();
}

// v83 FUN_00a0977b: a summoning sack asks before it opens, unless
// it is an event's (2109xxx) or 2100067.
inline bool sack_asks(int32_t item_id)
// it is an event's (2109xxx) or 2100067, or the player is a GM.
inline bool sack_asks(int32_t item_id, bool gm)
{
return item_id / 1000 != 2109 && item_id != 2100067;
return !gm && item_id / 1000 != 2109 && item_id != 2100067;
}

// v83 FUN_00a0a63f, type 0x25: bit 0x40000 keeps Miu Miu's merchant
Expand Down
4 changes: 2 additions & 2 deletions HeavenClient/Gameplay/MapleMap/MapInfo.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -162,9 +162,9 @@ namespace ms
return field_limit::may_use(fieldlimit, allowed_items, item_id);
}

bool MapInfo::can_summon(int32_t item_id) const
bool MapInfo::can_summon(int32_t item_id, bool gm) const
{
return field_limit::may_summon(fieldlimit, allowed_items, item_id);
return field_limit::may_summon(fieldlimit, allowed_items, item_id, gm);
}

bool MapInfo::can_drop() const
Expand Down
4 changes: 2 additions & 2 deletions HeavenClient/Gameplay/MapleMap/MapInfo.h
Original file line number Diff line number Diff line change
Expand Up @@ -136,8 +136,8 @@ namespace ms
bool can_use_item(int32_t item_id) const;

// Whether the map lets the player open a summoning sack
// (field_limit::may_summon).
bool can_summon(int32_t item_id) const;
// (field_limit::may_summon); a GM may anywhere.
bool can_summon(int32_t item_id, bool gm) const;

// Whether the map lets the player drop items and mesos.
bool can_drop() const;
Expand Down
8 changes: 5 additions & 3 deletions HeavenClient/IO/UITypes/UIItemInventory.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -994,13 +994,15 @@ namespace ms

// v83 FUN_00a0977b: a summoning sack (210xxxx) stays shut while
// riding or where the map forbids it, and asks first unless it is an
// event's.
// event's. A GM skips both the map's rule and the question.
void use_summon_sack(int16_t slot, int32_t item_id)
{
if (Stage::get().get_player().ride_refuses())
return;

if (!Stage::get().get_mapinfo().can_summon(item_id))
bool gm = Configuration::get().get_grade().gm();

if (!Stage::get().get_mapinfo().can_summon(item_id, gm))
{
UI::get().emplace<UIOk>(NOT_HERE, [](bool)
{});
Expand All @@ -1012,7 +1014,7 @@ namespace ms
Stage::get().get_player().request(SummonSackPacket(slot, item_id), ExclRequest::USE_WAIT);
};

if (!field_limit::sack_asks(item_id))
if (!field_limit::sack_asks(item_id, gm))
open();
else
UI::get().emplace<UIYesNo>(SUMMON_SACK, [open](bool yes)
Expand Down
14 changes: 8 additions & 6 deletions HeavenClient/tests/field_limit.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -24,12 +24,14 @@ int main()
require(may_use(0x400, {}, 2040000), "a scroll doesn't go the potion way");
require(!may_use(0x400, {}, 2210000), "a transformation potion is refused");

require(may_summon(0, {}, 2100000), "a summoning sack opens on an open map");
require(!may_summon(0x4, {}, 2100000), "bit 0x4 keeps it shut");
require(may_summon(0x526fc, allowed, 2109004), "unless the map lists it");
require(!may_summon(0x526fc, allowed, 2100000), "an unlisted one stays shut");
require(sack_asks(2100000) && sack_asks(2101000), "a sack asks first");
require(!sack_asks(2109004) && !sack_asks(2100067), "an event's sack and 2100067 don't");
require(may_summon(0, {}, 2100000, false), "a summoning sack opens on an open map");
require(!may_summon(0x4, {}, 2100000, false), "bit 0x4 keeps it shut");
require(may_summon(0x526fc, allowed, 2109004, false), "unless the map lists it");
require(!may_summon(0x526fc, allowed, 2100000, false), "an unlisted one stays shut");
require(may_summon(0x4, {}, 2100000, true), "a GM opens one anywhere");
require(sack_asks(2100000, false) && sack_asks(2101000, false), "a sack asks first");
require(!sack_asks(2109004, false) && !sack_asks(2100067, false), "an event's sack and 2100067 don't");
require(!sack_asks(2100000, true), "nor does any sack for a GM");

require(may_drop(0x400), "consumable limits leave drops alone");
require(!may_drop(0x400000), "bit 0x400000 keeps items on the player");
Expand Down
7 changes: 6 additions & 1 deletion agent_docs/inventory.md
Original file line number Diff line number Diff line change
Expand Up @@ -645,7 +645,12 @@ A summoning sack (210xxxx) is opened from the USE tab with USE_SUMMON_BAG
of its mobs at its percent chance, below the player. Where the map's
fieldLimit has 0x4 and its `allowedItem` doesn't list the sack, the client
shows "You can't use it here in this map." itself, unless the player is
a GM (v83 FUN_00a0977b). The server also keeps a sack with `info/reqMap`
a GM (v83 FUN_00a0977b). Then, again unless the player is a GM, and
unless the sack is an event's (2109xxx) or the Ariant Coliseum's Bomb
2100067, it asks "Too much interest can hinder your process of leveling
up. will you really summon the monster?" and sends nothing on No
(`field_limit::sack_asks`). The client's GM bit comes only with gm_level 3
and up. The server also keeps a sack with `info/reqMap`
to the maps it names (their ids are the children's names): the Ariant
Coliseum's Bomb 2100067 opens only in 980010101, 980010201 and 980010301.
A sack the server refuses for the map gets
Expand Down
Loading