From 497761a282ec2509dbca141b68fef71def63b9b4 Mon Sep 17 00:00:00 2001 From: Mordred Date: Wed, 20 Mar 2019 22:16:02 +0100 Subject: [PATCH] Preload defense / block values into items --- src/common/CommonGen.cpp | 5 ++ src/common/CommonGen.h | 80 +++++++++++++++++++++++++++++ src/tools/exd_common_gen/main.cpp | 1 + src/world/Actor/PlayerInventory.cpp | 33 ++++++------ src/world/Inventory/Item.cpp | 4 ++ src/world/Inventory/Item.h | 5 ++ 6 files changed, 112 insertions(+), 16 deletions(-) diff --git a/src/common/CommonGen.cpp b/src/common/CommonGen.cpp index 43bce9b2..82f1e886 100644 --- a/src/common/CommonGen.cpp +++ b/src/common/CommonGen.cpp @@ -15,6 +15,11 @@ bool operator==( const uint8_t& g, const ActionCategory& t ) return static_cast< uint8_t >( t ) == g; } +bool operator==( const uint8_t& g, const BaseParam& t ) +{ + return static_cast< uint8_t >( t ) == g; +} + bool operator==( const BeastReputationRank& t, const uint8_t& g ) { return static_cast< uint8_t >( t ) == g; diff --git a/src/common/CommonGen.h b/src/common/CommonGen.h index 8c9b922a..078efa3c 100644 --- a/src/common/CommonGen.h +++ b/src/common/CommonGen.h @@ -31,6 +31,86 @@ enum class ActionCategory : uint8_t AdrenalineRush = 15, }; +/////////////////////////////////////////////////////////// +//BaseParam.exd +enum class BaseParam : uint8_t +{ + None = 0, + Strength = 1, + Dexterity = 2, + Vitality = 3, + Intelligence = 4, + Mind = 5, + Piety = 6, + HP = 7, + MP = 8, + TP = 9, + GP = 10, + CP = 11, + PhysicalDamage = 12, + MagicDamage = 13, + Delay = 14, + AdditionalEffect = 15, + AttackSpeed = 16, + BlockRate = 17, + BlockStrength = 18, + Tenacity = 19, + AttackPower = 20, + Defense = 21, + DirectHitRate = 22, + Evasion = 23, + MagicDefense = 24, + CriticalHitPower = 25, + CriticalHitResilience = 26, + CriticalHit = 27, + CriticalHitEvasion = 28, + SlashingResistance = 29, + PiercingResistance = 30, + BluntResistance = 31, + ProjectileResistance = 32, + AttackMagicPotency = 33, + HealingMagicPotency = 34, + EnhancementMagicPotency = 35, + ElementalBonus = 36, + FireResistance = 37, + IceResistance = 38, + WindResistance = 39, + EarthResistance = 40, + LightningResistance = 41, + WaterResistance = 42, + MagicResistance = 43, + Determination = 44, + SkillSpeed = 45, + SpellSpeed = 46, + Haste = 47, + Morale = 48, + Enmity = 49, + EnmityReduction = 50, + CarefulDesynthesis = 51, + EXPBonus = 52, + Regen = 53, + Refresh = 54, + MainAttribute = 55, + SecondaryAttribute = 56, + SlowResistance = 57, + PetrificationResistance = 58, + ParalysisResistance = 59, + SilenceResistance = 60, + BlindResistance = 61, + PoisonResistance = 62, + StunResistance = 63, + SleepResistance = 64, + BindResistance = 65, + HeavyResistance = 66, + DoomResistance = 67, + ReducedDurabilityLoss = 68, + IncreasedSpiritbondGain = 69, + Craftsmanship = 70, + Control = 71, + Gathering = 72, + Perception = 73, +}; + /////////////////////////////////////////////////////////// //BeastReputationRank.exd enum class BeastReputationRank : uint8_t diff --git a/src/tools/exd_common_gen/main.cpp b/src/tools/exd_common_gen/main.cpp index 4e36da50..a6c7fb60 100644 --- a/src/tools/exd_common_gen/main.cpp +++ b/src/tools/exd_common_gen/main.cpp @@ -110,6 +110,7 @@ int main() result += "namespace Sapphire {\n"; result += "namespace Common {\n"; result += generateEnum( "ActionCategory", 0, "uint8_t" ); + result += generateEnum( "BaseParam", 1, "uint8_t" ); result += generateEnum( "BeastReputationRank", 1, "uint8_t" ); result += generateEnum( "BeastTribe", 11, "uint8_t" ); result += generateEnum( "ClassJob", 0, "uint8_t" ); diff --git a/src/world/Actor/PlayerInventory.cpp b/src/world/Actor/PlayerInventory.cpp index 4cab8baf..bba7b9cf 100644 --- a/src/world/Actor/PlayerInventory.cpp +++ b/src/world/Actor/PlayerInventory.cpp @@ -147,22 +147,6 @@ void Sapphire::Entity::Player::equipSoulCrystal( ItemPtr pItem, bool updateJob ) setClassJob( newClassJob ); } -// equip an item -void Sapphire::Entity::Player::equipItem( Common::GearSetSlot equipSlotId, ItemPtr pItem, bool sendUpdate ) -{ - - //g_framework.getLogger().debug( "Equipping into slot " + std::to_string( equipSlotId ) ); - if( sendUpdate ) - { - updateModels( equipSlotId, pItem, true ); - this->sendModel(); - m_itemLevel = calculateEquippedGearItemLevel(); - sendItemLevel(); - } - else - updateModels( equipSlotId, pItem, false ); -} - void Sapphire::Entity::Player::updateModels( GearSetSlot equipSlotId, const Sapphire::ItemPtr& pItem, bool updateClass ) { uint64_t model = pItem->getModelId1(); @@ -230,6 +214,23 @@ Sapphire::Common::GearModelSlot Sapphire::Entity::Player::equipSlotToModelSlot( } } +// equip an item +void Sapphire::Entity::Player::equipItem( Common::GearSetSlot equipSlotId, ItemPtr pItem, bool sendUpdate ) +{ + + //g_framework.getLogger().debug( "Equipping into slot " + std::to_string( equipSlotId ) ); + if( sendUpdate ) + { + updateModels( equipSlotId, pItem, true ); + sendModel(); + m_itemLevel = calculateEquippedGearItemLevel(); + sendItemLevel(); + } + else + updateModels( equipSlotId, pItem, false ); +} + + void Sapphire::Entity::Player::unequipItem( Common::GearSetSlot equipSlotId, ItemPtr pItem ) { auto modelSlot = equipSlotToModelSlot( equipSlotId ); diff --git a/src/world/Inventory/Item.cpp b/src/world/Inventory/Item.cpp index 941872fe..31682052 100644 --- a/src/world/Inventory/Item.cpp +++ b/src/world/Inventory/Item.cpp @@ -29,6 +29,10 @@ Sapphire::Item::Item( uint64_t uId, uint32_t catalogId, FrameworkPtr pFw, bool i m_itemLevel = itemInfo->levelItem; m_maxStackSize = itemInfo->stackSize; m_additionalData = itemInfo->additionalData; + m_blockRate = itemInfo->blockRate; + m_block = itemInfo->block; + m_defense = itemInfo->defensePhys; + m_defenseMag = itemInfo->defenseMag; } float Sapphire::Item::getAutoAttackDmg() const diff --git a/src/world/Inventory/Item.h b/src/world/Inventory/Item.h index 2c492bed..b0fe3c34 100644 --- a/src/world/Inventory/Item.h +++ b/src/world/Inventory/Item.h @@ -99,6 +99,11 @@ namespace Sapphire uint16_t m_spiritBond; uint32_t m_reservedFlag; + uint32_t m_blockRate; + uint32_t m_block; + uint32_t m_defense; + uint32_t m_defenseMag; + FrameworkPtr m_pFw; uint32_t m_additionalData; };