functional crates (no more plungers) (#133)

* FM, Taros and Boosts awards from killing mobs should be pretty
accurate now. A temporary formula for adjusting player/mob level gap is
implemented, but it will probably need to be adjusted in the future

* Mobs now drop correct crates

* Crates can be opened and give you correct items This includes
regular mob crates, world boss crates, mission crates, IZ race crates,
E.G.G.E.R.s, golden Eggs, and Event Crates.  Keep in mind that neither
IZ races or golden Eggs are implemented, but if you spawn such a crate
it can be opened.

* All data is read from a json file, for which I'm going to release a
tool soon so it's easily adjustable

* There is a new setting for enabling events, which enables dropping
extra event crates These are Knishmas, Halloween and Easter
This commit is contained in:
kamilprzyb
2020-10-10 19:18:47 +02:00
committed by dongresource
parent ab5857e7e2
commit dd54668697
9 changed files with 435 additions and 33 deletions

View File

@@ -5,7 +5,7 @@
struct Item {
bool tradeable, sellable;
int buyPrice, sellPrice, stackSize, level, rarity, pointDamage, groupDamage, defense; // TODO: implement more as needed
int buyPrice, sellPrice, stackSize, level, rarity, pointDamage, groupDamage, defense, gender; // TODO: implement more as needed
};
struct VendorListing {
int sort, type, iID;
@@ -14,6 +14,10 @@ struct CrocPotEntry {
int multStats, multLooks;
float base, rd0, rd1, rd2, rd3;
};
struct Crate {
int rarityRatioId;
std::vector<int> itemSets;
};
namespace ItemManager {
enum class SlotType {
@@ -25,6 +29,11 @@ namespace ItemManager {
extern std::map<std::pair<int32_t, int32_t>, Item> ItemData; // <id, type> -> data
extern std::map<int32_t, std::vector<VendorListing>> VendorTables;
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;
void init();
@@ -46,6 +55,14 @@ namespace ItemManager {
void itemTradeChatHandler(CNSocket* sock, CNPacketData* data);
void chestOpenHandler(CNSocket* sock, CNPacketData* data);
// crate opening logic with all helper functions
sItemBase openCrate(int crateId, int playerGender);
Crate getCrate(int crateId);
int getItemSetId(Crate crate, int crateId);
int getRarity(Crate crate, int itemSetId);
sItemBase getCrateItem(int itemSetId, int rarity, int playerGender);
void throwError(int ignore);
int findFreeSlot(Player *plr);
Item* getItemData(int32_t id, int32_t type);
void checkItemExpire(CNSocket* sock, Player* player);