* try to resolve merge conflict
* feat: TU19 (Dec 2014) Features & Content (#32)
* December 2014 files
* Working release build
* Fix compilation issues
* Add sound to Windows64Media
* Add DLC content and force Tutorial DLC
* Revert "Add DLC content and force Tutorial DLC"
This reverts commit 97a4399472.
* Disable broken light packing
* Disable breakpoint during DLC texture map load
Allows DLC loading but the DLC textures are still broken
* Fix post build not working
* ...
* fix vs2022 build
* fix cmake build
---------
Co-authored-by: Loki <lokirautio@gmail.com>
110 lines
3.4 KiB
C++
110 lines
3.4 KiB
C++
#pragma once
|
|
|
|
class ItemInstance;
|
|
class Inventory;
|
|
class DamageSource;
|
|
class Enchantment;
|
|
class EnchantmentInstance;
|
|
|
|
class EnchantmentHelper
|
|
{
|
|
private:
|
|
static Random random;
|
|
|
|
public:
|
|
static int getEnchantmentLevel(int enchantmentId, shared_ptr<ItemInstance> piece);
|
|
static unordered_map<int, int> *getEnchantments(shared_ptr<ItemInstance> item);
|
|
static void setEnchantments(unordered_map<int, int> *enchantments, shared_ptr<ItemInstance> item);
|
|
|
|
static int getEnchantmentLevel(int enchantmentId, ItemInstanceArray inventory);
|
|
|
|
private:
|
|
|
|
|
|
class EnchantmentIterationMethod
|
|
{
|
|
public:
|
|
virtual void doEnchantment(Enchantment *enchantment, int level) = 0;
|
|
};
|
|
|
|
static void runIterationOnItem(EnchantmentIterationMethod &method, shared_ptr<ItemInstance> piece);
|
|
static void runIterationOnInventory(EnchantmentIterationMethod &method, ItemInstanceArray inventory);
|
|
|
|
class GetDamageProtectionIteration : public EnchantmentIterationMethod
|
|
{
|
|
public:
|
|
int sum;
|
|
DamageSource *source;
|
|
|
|
virtual void doEnchantment(Enchantment *enchantment, int level);
|
|
};
|
|
|
|
static GetDamageProtectionIteration getDamageProtectionIteration;
|
|
|
|
/**
|
|
* Fetches the protection value for enchanted items.
|
|
*
|
|
* @param inventory
|
|
* @param source
|
|
* @return
|
|
*/
|
|
public:
|
|
static int getDamageProtection(ItemInstanceArray armor, DamageSource *source);
|
|
|
|
private:
|
|
class GetDamageBonusIteration : public EnchantmentIterationMethod
|
|
{
|
|
public:
|
|
float sum;
|
|
shared_ptr<LivingEntity> target;
|
|
|
|
virtual void doEnchantment(Enchantment *enchantment, int level);
|
|
};
|
|
|
|
static GetDamageBonusIteration getDamageBonusIteration;
|
|
|
|
/**
|
|
*
|
|
* @param inventory
|
|
* @param target
|
|
* @return
|
|
*/
|
|
public:
|
|
static float getDamageBonus(shared_ptr<LivingEntity> source, shared_ptr<LivingEntity> target);
|
|
static int getKnockbackBonus(shared_ptr<LivingEntity> source, shared_ptr<LivingEntity> target);
|
|
static int getFireAspect(shared_ptr<LivingEntity> source);
|
|
static int getOxygenBonus(shared_ptr<LivingEntity> source);
|
|
static int getDiggingBonus(shared_ptr<LivingEntity> source);
|
|
static int getDigDurability(shared_ptr<LivingEntity> source);
|
|
static bool hasSilkTouch(shared_ptr<LivingEntity> source);
|
|
static int getDiggingLootBonus(shared_ptr<LivingEntity> source);
|
|
static int getKillingLootBonus(shared_ptr<LivingEntity> source);
|
|
static bool hasWaterWorkerBonus(shared_ptr<LivingEntity> source);
|
|
static int getArmorThorns(shared_ptr<LivingEntity> source);
|
|
static shared_ptr<ItemInstance> getRandomItemWith(Enchantment *enchantment, shared_ptr<LivingEntity> source);
|
|
|
|
/**
|
|
*
|
|
* @param random
|
|
* @param slot
|
|
* The table slot, 0-2
|
|
* @param bookcases
|
|
* How many book cases that are found around the table.
|
|
* @param itemInstance
|
|
* Which item that is being enchanted.
|
|
* @return The enchantment cost, 0 means unchantable, 50 is max.
|
|
*/
|
|
static int getEnchantmentCost(Random *random, int slot, int bookcases, shared_ptr<ItemInstance> itemInstance);
|
|
|
|
static shared_ptr<ItemInstance> enchantItem(Random *random, shared_ptr<ItemInstance> itemInstance, int enchantmentCost);
|
|
|
|
/**
|
|
*
|
|
* @param random
|
|
* @param itemInstance
|
|
* @param enchantmentCost
|
|
* @return
|
|
*/
|
|
static vector<EnchantmentInstance *> *selectEnchantment(Random *random, shared_ptr<ItemInstance> itemInstance, int enchantmentCost);
|
|
static unordered_map<int, EnchantmentInstance *> *getAvailableEnchantmentResults(int value, shared_ptr<ItemInstance> itemInstance);
|
|
}; |