Update fishing mechanics for better parity with TU 31
This commit is contained in:
@@ -4,21 +4,22 @@
|
||||
#include "../Minecraft.World/FishingHelper.h"
|
||||
#include "../Minecraft.World/ItemInstance.h"
|
||||
#include "../Minecraft.World/EnchantmentHelper.h"
|
||||
#include <memory>
|
||||
#include "net.minecraft.world.item.h"
|
||||
|
||||
#include <memory>
|
||||
|
||||
FishingHelper* FishingHelper::getInstance()
|
||||
{
|
||||
static FishingHelper instance;
|
||||
return &instance;
|
||||
}
|
||||
|
||||
FishingHelper::FishingHelper() : catchTypeArray(3), fishingFishArray(4), fishingJunkArray(12), fishingTreasuresArray(5)
|
||||
FishingHelper::FishingHelper() : catchTypeArray(3), fishingFishArray(4), fishingJunkArray(11), fishingTreasuresArray(5)
|
||||
{
|
||||
// Source: https://github.com/WangTingZheng/mcp940/tree/master/src/minecraft/assets/minecraft/loot_tables/gameplay
|
||||
catchTypeArray[0] = new CatchTypeWeighedItem(CatchType::JUNK, -2, 10 );
|
||||
catchTypeArray[1] = new CatchTypeWeighedItem(CatchType::TREASURE, 2, 5 );
|
||||
catchTypeArray[2] = new CatchTypeWeighedItem(CatchType::FISH, -1, 85);
|
||||
catchTypeArray[0] = new CatchTypeWeighedItem(CatchType::FISH, 8); // 850
|
||||
catchTypeArray[1] = new CatchTypeWeighedItem(CatchType::JUNK, 100 );
|
||||
catchTypeArray[2] = new CatchTypeWeighedItem(CatchType::TREASURE, 5 ); // 50
|
||||
|
||||
fishingTreasuresArray[0] = new CatchWeighedItem(Item::bow_Id, 1, 0, 1);
|
||||
fishingTreasuresArray[1] = new CatchWeighedItem(Item::book_Id, 1, 0, 1);
|
||||
@@ -32,34 +33,38 @@ FishingHelper::FishingHelper() : catchTypeArray(3), fishingFishArray(4), fishing
|
||||
fishingFishArray[2] = new CatchWeighedItem(Item::fish_raw_Id, 1, 2, 2); // Clownfish
|
||||
fishingFishArray[3] = new CatchWeighedItem(Item::fish_raw_Id, 1, 3, 13); // Pufferfish
|
||||
|
||||
fishingJunkArray[3] = new CatchWeighedItem(Item::leather_Id, 1, 0, 10);
|
||||
fishingJunkArray[0] = new CatchWeighedItem(Item::leather_Id, 1, 0, 10);
|
||||
fishingJunkArray[1] = new CatchWeighedItem(Item::bone_Id, 1, 0, 10);
|
||||
fishingJunkArray[6] = new CatchWeighedItem(Item::potion_Id, 1, 0, 10); // Water bottle
|
||||
fishingJunkArray[2] = new CatchWeighedItem(Item::bowl_Id, 1, 0, 10);
|
||||
fishingJunkArray[2] = new CatchWeighedItem(Item::potion_Id, 1, 0, 10); // Water bottle
|
||||
fishingJunkArray[3] = new CatchWeighedItem(Item::bowl_Id, 1, 0, 10);
|
||||
fishingJunkArray[4] = new CatchWeighedItem(Item::boots_leather_Id, 1, 0, 10);
|
||||
fishingJunkArray[5] = new CatchWeighedItem(Item::rotten_flesh_Id, 1, 0, 10);
|
||||
fishingJunkArray[7] = new CatchWeighedItem(Tile::tripWireSource_Id, 1, 0, 10);
|
||||
fishingJunkArray[8] = new CatchWeighedItem(Item::stick_Id, 1, 0, 5);
|
||||
fishingJunkArray[9] = new CatchWeighedItem(Item::string_Id, 1, 0, 5);
|
||||
fishingJunkArray[10] = new CatchWeighedItem(Item::fishingRod_Id, 1, 0, 2);
|
||||
fishingJunkArray[11] = new CatchWeighedItem(Item::dye_powder_Id, 10, 0, 1); // 10 ink sacs
|
||||
fishingJunkArray[6] = new CatchWeighedItem(Tile::tripWireSource_Id, 1, 0, 10);
|
||||
fishingJunkArray[7] = new CatchWeighedItem(Item::stick_Id, 1, 0, 5);
|
||||
fishingJunkArray[8] = new CatchWeighedItem(Item::string_Id, 1, 0, 5);
|
||||
fishingJunkArray[9] = new CatchWeighedItem(Item::fishingRod_Id, 1, 0, 2);
|
||||
fishingJunkArray[10] = new CatchWeighedItem(Item::dye_powder_Id, 10, 0, 1); // 10 ink sacs
|
||||
}
|
||||
|
||||
CatchType FishingHelper::getRandCatchType(int luck, Random* random)
|
||||
CatchType FishingHelper::getRandCatchType(int fishMod, int junkMod, int treasureMod, Random* random)
|
||||
{
|
||||
CatchTypeWeighedItem* catchTypeWeighedItem = nullptr;
|
||||
catchTypeArray.calcWeights(luck); // Recalculate the weights based on the luck level of the player
|
||||
((CatchTypeWeighedItem*)catchTypeArray[0])->modWeight(fishMod);
|
||||
((CatchTypeWeighedItem*)catchTypeArray[1])->modWeight(junkMod);
|
||||
((CatchTypeWeighedItem*)catchTypeArray[2])->modWeight(treasureMod);
|
||||
// Recalculate the weights based on the luck level of the player
|
||||
catchTypeWeighedItem = static_cast<CatchTypeWeighedItem *>(WeighedRandom::getRandomItem(random, catchTypeArray));
|
||||
|
||||
return catchTypeWeighedItem->getType();
|
||||
}
|
||||
|
||||
CatchWeighedItem* FishingHelper::getRandCatch(CatchType catchType, Random* random)
|
||||
{
|
||||
CatchWeighedItem* catchWeighedItem = nullptr;
|
||||
switch (catchType) {
|
||||
case CatchType::FISH:
|
||||
return static_cast<CatchWeighedItem *>(WeighedRandom::getRandomItem(random, fishingFishArray));
|
||||
case CatchType::TREASURE:
|
||||
return static_cast<CatchWeighedItem *>(WeighedRandom::getRandomItem(random, fishingTreasuresArray));;
|
||||
return static_cast<CatchWeighedItem *>(WeighedRandom::getRandomItem(random, fishingTreasuresArray));
|
||||
case CatchType::JUNK:
|
||||
return static_cast<CatchWeighedItem *>(WeighedRandom::getRandomItem(random, fishingJunkArray));
|
||||
}
|
||||
@@ -75,11 +80,11 @@ std::shared_ptr<ItemInstance> FishingHelper::handleCatch(CatchWeighedItem* weigh
|
||||
itemInstance->setAuxValue((int) (itemInstance->getMaxDamage() * ((double) random->nextInt(901) + 100.0) / 1000.0)); // 10% to 100% damage
|
||||
}
|
||||
else if (itemInstance->id == Item::fishingRod_Id && catchType == CatchType::TREASURE) {
|
||||
itemInstance->setAuxValue((int)(itemInstance->getMaxDamage() * ((double)random->nextInt(251) / 1000.0)); // 0% to 25% damage
|
||||
itemInstance->setAuxValue((int)(itemInstance->getMaxDamage() * ((double)random->nextInt(251) / 1000.0))); // 0% to 25% damage
|
||||
itemInstance = EnchantmentHelper::enchantItem(random, itemInstance, 30);
|
||||
}
|
||||
else if (itemInstance->id == Item::bow_Id) {
|
||||
itemInstance->setAuxValue((int)(itemInstance->getMaxDamage() * ((double)random->nextInt(251) / 1000.0)); // 0% to 25% damage
|
||||
itemInstance->setAuxValue((int)(itemInstance->getMaxDamage() * ((double)random->nextInt(251) / 1000.0))); // 0% to 25% damage
|
||||
itemInstance = EnchantmentHelper::enchantItem(random, itemInstance, 30);
|
||||
}
|
||||
else if (itemInstance->id == Item::book_Id) {
|
||||
@@ -89,9 +94,9 @@ std::shared_ptr<ItemInstance> FishingHelper::handleCatch(CatchWeighedItem* weigh
|
||||
return itemInstance;
|
||||
}
|
||||
|
||||
std::shared_ptr<ItemInstance> FishingHelper::getCatch(int luck, Random* random)
|
||||
std::shared_ptr<ItemInstance> FishingHelper::getCatch(int fishMod, int junkMod, int treasureMod, Random* random)
|
||||
{
|
||||
CatchType catchType = getRandCatchType(luck, random);
|
||||
CatchType catchType = getRandCatchType(fishMod, junkMod, treasureMod, random);
|
||||
CatchWeighedItem* catchWeighedItem = getRandCatch(catchType, random);
|
||||
return handleCatch(catchWeighedItem, catchType, random);
|
||||
}
|
||||
Reference in New Issue
Block a user