diff --git a/src/custom/script_def.inc b/src/custom/script_def.inc index 8863992732a..4dfca307e27 100644 --- a/src/custom/script_def.inc +++ b/src/custom/script_def.inc @@ -9,3 +9,4 @@ **/ //BUILDIN_DEF(example,""), +BUILDIN_DEF(sellitem,"sii?"), \ No newline at end of file diff --git a/src/map/clif.cpp b/src/map/clif.cpp index 78e0b70acfb..3c04fb91916 100644 --- a/src/map/clif.cpp +++ b/src/map/clif.cpp @@ -3,11 +3,37 @@ #include "clif.hpp" -#include -#include -#include -#include -#include +#include "map.h" +#include "chrif.h" +#include "pc.h" +#include "status.h" +#include "npc.h" +#include "itemdb.h" +#include "chat.h" +#include "trade.h" +#include "storage.h" +#include "script.h" +#include "skill.h" +#include "atcommand.h" +#include "intif.h" +#include "battle.h" +#include "battleground.h" +#include "mob.h" +#include "party.h" +#include "unit.h" +#include "guild.h" +#include "vending.h" +#include "pet.h" +#include "homunculus.h" +#include "instance.h" +#include "mercenary.h" +#include "elemental.h" +#include "log.h" +#include "clif.h" +#include "mail.h" +#include "quest.h" +#include "cashshop.h" +#include "channel.h" #include "../common/cbasetypes.hpp" #include "../common/conf.hpp" @@ -57,6 +83,12 @@ #include "unit.hpp" #include "vending.hpp" +#include +#include +#include +#include +#include + /* for clif_clearunit_delayed */ static struct eri *delay_clearunit_ers; @@ -19875,6 +19907,53 @@ void clif_hat_effect_single( struct map_session_data* sd, uint16 effectId, bool #endif } +void clif_sellitem(struct map_session_data* sd, enum sellitem_filter_type type, int param, bool discount) { + int fd, i, c = 0, val; + + nullpo_retv(sd); + + fd = sd->fd; + WFIFOHEAD(fd, MAX_INVENTORY * 10 + 4); + WFIFOW(fd, 0) = 0xc7; + for (i = 0; i < MAX_INVENTORY; i++) + { + if (sd->inventory.u.items_inventory[i].nameid > 0 && sd->inventory_data[i]) + { + switch (type) { + case SFT_TYPE: + if (!(1 << (itemdb_type(sd->inventory.u.items_inventory[i].nameid))¶m)) + continue; + break; + case SFT_ID: + if (sd->inventory.u.items_inventory[i].nameid != param) + continue; + break; + default: + ShowWarning("clif_sellitem: Unknown filter %d passed to clif_sellitem.\n", type); + break; + } + + if (!itemdb_cansell(&sd->inventory.u.items_inventory[i], pc_get_group_level(sd))) + continue; + + if (sd->inventory.u.items_inventory[i].expire_time) + continue; // Cannot Sell Rental Items + + if (sd->inventory.u.items_inventory[i].bound && !pc_can_give_bounded_items(sd)) + continue; // Don't allow sale of bound items + + val = sd->inventory_data[i]->value_sell; + if (val < 0) + continue; + WFIFOW(fd, 4 + c * 10) = i + 2; + WFIFOL(fd, 6 + c * 10) = val; + WFIFOL(fd, 10 + c * 10) = discount ? pc_modifysellvalue(sd, val) : val; + c++; + } + } + WFIFOW(fd, 2) = c * 10 + 4; + WFIFOSET(fd, WFIFOW(fd, 2)); +} /// Notify the client that a sale has started /// 09b2 .W .L (ZC_NOTIFY_BARGAIN_SALE_SELLING) diff --git a/src/map/clif.hpp b/src/map/clif.hpp index 1531106593f..ae8ae929eac 100644 --- a/src/map/clif.hpp +++ b/src/map/clif.hpp @@ -32,7 +32,9 @@ struct guild; struct battleground_data; struct quest; struct party_booking_ad_info; +enum e_party_member_withdraw; struct sale_item_data; +enum sellitem_filter_type; struct mail_message; struct achievement; @@ -1069,6 +1071,7 @@ void clif_broadcast_obtain_special_item(const char *char_name, unsigned short na void clif_dressing_room(struct map_session_data *sd, int flag); void clif_navigateTo(struct map_session_data *sd, const char* mapname, uint16 x, uint16 y, uint8 flag, bool hideWindow, uint16 mob_id ); void clif_SelectCart(struct map_session_data *sd); +void clif_sellitem(struct map_session_data* sd, enum sellitem_filter_type type, int param, bool discount); /// Achievement System void clif_achievement_list_all(struct map_session_data *sd); diff --git a/src/map/script.cpp b/src/map/script.cpp index 947d2ee66c9..c45d5474a02 100644 --- a/src/map/script.cpp +++ b/src/map/script.cpp @@ -22934,128 +22934,42 @@ BUILDIN_FUNC(openstorage2) { } /** - * Create a new channel - * channel_create "",""{,""{