OpenFusion/src/ItemManager.hpp

75 lines
3.0 KiB
C++
Raw Normal View History

#pragma once
#include "CNShardServer.hpp"
#include "Player.hpp"
2020-09-13 22:54:47 +00:00
struct VendorListing {
int sort, type, iID;
2020-09-13 22:54:47 +00:00
};
2020-09-16 00:30:01 +00:00
struct CrocPotEntry {
int multStats, multLooks;
float base, rd0, rd1, rd2, rd3;
};
struct Crate {
int rarityRatioId;
std::vector<int> itemSets;
};
2020-09-13 22:54:47 +00:00
namespace ItemManager {
enum class SlotType {
EQUIP = 0,
INVENTORY = 1,
BANK = 3
};
2020-12-04 18:57:08 +00:00
struct Item {
bool tradeable, sellable;
2020-12-31 05:54:57 +00:00
int buyPrice, sellPrice, stackSize, level, rarity, pointDamage, groupDamage, fireRate, defense, gender; // TODO: implement more as needed
2020-12-04 18:57:08 +00:00
};
2020-09-13 22:54:47 +00:00
// hopefully this is fine since it's never modified after load
extern std::map<std::pair<int32_t, int32_t>, Item> ItemData; // <id, type> -> data
2020-09-13 22:54:47 +00:00
extern std::map<int32_t, std::vector<VendorListing>> VendorTables;
2020-09-16 00:30:01 +00:00
extern std::map<int32_t, CrocPotEntry> CrocPotTable; // level gap -> entry
extern std::map<int32_t, std::vector<int>> RarityRatios;
extern std::map<int32_t, Crate> Crates;
// pair <Itemset, Rarity> -> vector of pointers (map iterators) to records in ItemData (it looks a lot scarier than it is)
extern std::map<std::pair<int32_t, int32_t>,
std::vector<std::map<std::pair<int32_t, int32_t>, Item>::iterator>> CrateItems;
extern std::map<std::string, std::vector<std::pair<int32_t, int32_t>>> CodeItems; // code -> vector of <id, type>
2020-09-13 22:54:47 +00:00
void init();
void itemMoveHandler(CNSocket* sock, CNPacketData* data);
void itemDeleteHandler(CNSocket* sock, CNPacketData* data);
void itemGMGiveHandler(CNSocket* sock, CNPacketData* data);
void itemUseHandler(CNSocket* sock, CNPacketData* data);
// Bank
void itemBankOpenHandler(CNSocket* sock, CNPacketData* data);
void tradeOffer(CNSocket* sock, CNPacketData* data);
void tradeOfferAccept(CNSocket* sock, CNPacketData* data);
void tradeOfferRefusal(CNSocket* sock, CNPacketData* data);
void tradeConfirm(CNSocket* sock, CNPacketData* data);
bool doTrade(Player* plr, Player* plr2);
void tradeConfirmCancel(CNSocket* sock, CNPacketData* data);
void tradeRegisterItem(CNSocket* sock, CNPacketData* data);
void tradeUnregisterItem(CNSocket* sock, CNPacketData* data);
void tradeRegisterCash(CNSocket* sock, CNPacketData* data);
void tradeChat(CNSocket* sock, CNPacketData* data);
void chestOpenHandler(CNSocket* sock, CNPacketData* data);
// crate opening logic with all helper functions
int getItemSetId(Crate& crate, int crateId);
int getRarity(Crate& crate, int itemSetId);
int getCrateItem(sItemBase& reward, int itemSetId, int rarity, int playerGender);
int findFreeSlot(Player *plr);
Item* getItemData(int32_t id, int32_t type);
void checkItemExpire(CNSocket* sock, Player* player);
void setItemStats(Player* plr);
void updateEquips(CNSocket* sock, Player* plr);
2020-12-16 15:27:18 +00:00
#ifdef ACADEMY
extern std::map<int32_t, int32_t> NanoCapsules; // crate id -> nano id
void nanoCapsuleHandler(CNSocket* sock, sP_CL2FE_REQ_ITEM_CHEST_OPEN* chest);
#endif
}