mirror of
https://github.com/SapphireServer/Sapphire.git
synced 2025-04-24 05:37:45 +00:00
Merge pull request #402 from Squall5668/develop
Add class change on weapon swaps. Also adds a forgotten inventory on character creation.
This commit is contained in:
commit
c35f70fdfc
3 changed files with 18 additions and 17 deletions
|
@ -319,6 +319,7 @@ void PlayerMinimal::saveAsNew()
|
|||
createInvDbContainer( InventoryType::ArmoryWrist );
|
||||
createInvDbContainer( InventoryType::ArmoryRing );
|
||||
createInvDbContainer( InventoryType::ArmoryMain );
|
||||
createInvDbContainer( InventoryType::ArmorySoulCrystal );
|
||||
|
||||
createInvDbContainer( InventoryType::Currency );
|
||||
createInvDbContainer( InventoryType::Crystal );
|
||||
|
|
|
@ -324,7 +324,7 @@ public:
|
|||
void unequipItem( Common::GearSetSlot equipSlotId, ItemPtr pItem );
|
||||
|
||||
/*! equip a weapon, possibly forcing a job change */
|
||||
void equipWeapon( ItemPtr pItem );
|
||||
void equipWeapon( ItemPtr pItem, bool updateClass );
|
||||
|
||||
/*! get player ilvl */
|
||||
uint16_t getItemLevel() const;
|
||||
|
@ -356,7 +356,7 @@ public:
|
|||
/*! return the current amount of crystals of type */
|
||||
uint32_t getCrystal( uint8_t type ) const;
|
||||
|
||||
void updateModels( Common::GearSetSlot equipSlotId, const Core::ItemPtr& pItem );
|
||||
void updateModels( Common::GearSetSlot equipSlotId, const Core::ItemPtr& pItem, bool updateClass );
|
||||
|
||||
Common::GearModelSlot equipSlotToModelSlot( Common::GearSetSlot slot );
|
||||
|
||||
|
|
|
@ -114,7 +114,7 @@ void Core::Entity::Player::sendItemLevel()
|
|||
queuePacket( makeActorControl142( getId(), SetItemLevel, getItemLevel(), 0 ) );
|
||||
}
|
||||
|
||||
void Core::Entity::Player::equipWeapon( ItemPtr pItem )
|
||||
void Core::Entity::Player::equipWeapon( ItemPtr pItem, bool updateClass )
|
||||
{
|
||||
auto exdData = g_fw.get< Core::Data::ExdDataGenerated >();
|
||||
if( !exdData )
|
||||
|
@ -122,16 +122,17 @@ void Core::Entity::Player::equipWeapon( ItemPtr pItem )
|
|||
|
||||
auto itemInfo = exdData->get< Core::Data::Item >( pItem->getId() );
|
||||
auto itemClassJob = itemInfo->classJobUse;
|
||||
|
||||
auto currentClass = getClass();
|
||||
auto classJobInfo = exdData->get< Core::Data::ClassJob >( ( uint32_t )getClass() );
|
||||
auto currentParentClass = static_cast< ClassJob >( classJobInfo->classJobParent );
|
||||
auto newClassJob = static_cast< ClassJob >( itemClassJob );
|
||||
|
||||
if( isClassJobUnlocked( newClassJob ) )
|
||||
return;
|
||||
|
||||
// todo: check if soul crystal is equipped and use job instead
|
||||
|
||||
setClassJob( newClassJob );
|
||||
if( ( isClassJobUnlocked( newClassJob ) ) && ( currentParentClass != newClassJob ) )
|
||||
{
|
||||
if ( updateClass )
|
||||
setClassJob( newClassJob );
|
||||
else
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
// equip an item
|
||||
|
@ -139,18 +140,18 @@ void Core::Entity::Player::equipItem( Common::GearSetSlot equipSlotId, ItemPtr p
|
|||
{
|
||||
|
||||
//g_framework.getLogger().debug( "Equipping into slot " + std::to_string( equipSlotId ) );
|
||||
|
||||
updateModels( equipSlotId, pItem );
|
||||
|
||||
if( sendUpdate )
|
||||
{
|
||||
updateModels( equipSlotId, pItem, true );
|
||||
this->sendModel();
|
||||
m_itemLevel = calculateEquippedGearItemLevel();
|
||||
sendItemLevel();
|
||||
}
|
||||
else
|
||||
updateModels( equipSlotId, pItem, false );
|
||||
}
|
||||
|
||||
void Core::Entity::Player::updateModels( GearSetSlot equipSlotId, const Core::ItemPtr& pItem )
|
||||
void Core::Entity::Player::updateModels( GearSetSlot equipSlotId, const Core::ItemPtr& pItem, bool updateClass )
|
||||
{
|
||||
uint64_t model = pItem->getModelId1();
|
||||
uint64_t model2 = pItem->getModelId2();
|
||||
|
@ -160,8 +161,7 @@ void Core::Entity::Player::updateModels( GearSetSlot equipSlotId, const Core::It
|
|||
case MainHand:
|
||||
m_modelMainWeapon = model;
|
||||
m_modelSubWeapon = model2;
|
||||
// TODO: add job change upon changing weapon if needed
|
||||
// equipWeapon( pItem );
|
||||
equipWeapon( pItem, updateClass );
|
||||
break;
|
||||
|
||||
case OffHand:
|
||||
|
|
Loading…
Add table
Reference in a new issue