mirror of
https://github.com/SapphireServer/Sapphire.git
synced 2025-04-26 14:37:44 +00:00
Merge pull request #326 from NotAdam/develop
#314: fix items created via //gm item having incorrect data
This commit is contained in:
commit
ff380bde32
4 changed files with 34 additions and 50 deletions
|
@ -79,16 +79,16 @@ public:
|
|||
{
|
||||
Scene00003( player );
|
||||
},
|
||||
nullptr, eventId );
|
||||
nullptr, eventId );
|
||||
}
|
||||
else if(actor == Eobject1 )
|
||||
else if( actor == Eobject1 )
|
||||
{
|
||||
player.eventActionStart( getId(), 0x0E,
|
||||
[&]( Entity::Player& player, uint32_t eventId, uint64_t additional )
|
||||
{
|
||||
Scene00005( player );
|
||||
},
|
||||
nullptr, eventId );
|
||||
nullptr, eventId );
|
||||
}
|
||||
else if( actor == Eobject2 )
|
||||
{
|
||||
|
@ -97,7 +97,7 @@ public:
|
|||
{
|
||||
Scene00007( player );
|
||||
},
|
||||
nullptr, eventId );
|
||||
nullptr, eventId );
|
||||
}
|
||||
else if( actor == Eobject3 )
|
||||
{
|
||||
|
@ -106,7 +106,7 @@ public:
|
|||
{
|
||||
Scene00009( player );
|
||||
},
|
||||
nullptr, eventId );
|
||||
nullptr, eventId );
|
||||
}
|
||||
else if( actor == Eobject4 )
|
||||
{
|
||||
|
@ -124,13 +124,13 @@ public:
|
|||
{
|
||||
Scene00013( player );
|
||||
},
|
||||
nullptr, eventId );
|
||||
nullptr, eventId );
|
||||
}
|
||||
};
|
||||
|
||||
private:
|
||||
|
||||
void checkQuestcompletion( Entity::Player& player )
|
||||
void checkQuestCompletion( Entity::Player& player )
|
||||
{
|
||||
auto currentCC = player.getQuestUI8BH( getId() );
|
||||
|
||||
|
@ -172,7 +172,7 @@ private:
|
|||
player.playScene( getId(), 2, HIDE_HOTBAR,
|
||||
[&]( Entity::Player& player, const Event::SceneResult& result )
|
||||
{
|
||||
if( player.hasQuest( 65644 ) || player.hasQuest( 65645 ) )
|
||||
if( player.hasQuest( Quest0 ) || player.hasQuest( Quest1 ) )
|
||||
{
|
||||
if( result.param2 == 1 )
|
||||
{
|
||||
|
@ -199,7 +199,7 @@ private:
|
|||
player.playScene( getId(), 4, HIDE_HOTBAR,
|
||||
[&]( Entity::Player& player, const Event::SceneResult& result )
|
||||
{
|
||||
checkQuestcompletion( player );
|
||||
checkQuestCompletion( player );
|
||||
player.setQuestBitFlag8( getId(), 7, true );
|
||||
} );
|
||||
}
|
||||
|
@ -218,7 +218,7 @@ private:
|
|||
player.playScene( getId(), 6, HIDE_HOTBAR,
|
||||
[&]( Entity::Player& player, const Event::SceneResult& result )
|
||||
{
|
||||
checkQuestcompletion( player );
|
||||
checkQuestCompletion( player );
|
||||
player.setQuestBitFlag8( getId(), 6, true );
|
||||
} );
|
||||
}
|
||||
|
@ -237,7 +237,7 @@ private:
|
|||
player.playScene( getId(), 8, HIDE_HOTBAR,
|
||||
[&]( Entity::Player& player, const Event::SceneResult& result )
|
||||
{
|
||||
checkQuestcompletion( player );
|
||||
checkQuestCompletion( player );
|
||||
player.setQuestBitFlag8( getId(), 5, true );
|
||||
} );
|
||||
}
|
||||
|
@ -256,7 +256,7 @@ private:
|
|||
player.playScene( getId(), 10, HIDE_HOTBAR,
|
||||
[&]( Entity::Player& player, const Event::SceneResult& result )
|
||||
{
|
||||
checkQuestcompletion( player );
|
||||
checkQuestCompletion( player );
|
||||
player.setQuestBitFlag8( getId(), 4, true );
|
||||
} );
|
||||
}
|
||||
|
@ -275,7 +275,7 @@ private:
|
|||
player.playScene( getId(), 12, HIDE_HOTBAR,
|
||||
[&]( Entity::Player& player, const Event::SceneResult& result )
|
||||
{
|
||||
checkQuestcompletion( player );
|
||||
checkQuestCompletion( player );
|
||||
player.setQuestBitFlag8( getId(), 3, true );
|
||||
} );
|
||||
}
|
||||
|
@ -294,7 +294,7 @@ private:
|
|||
player.playScene( getId(), 14, HIDE_HOTBAR,
|
||||
[&]( Entity::Player& player, const Event::SceneResult& result )
|
||||
{
|
||||
checkQuestcompletion( player );
|
||||
checkQuestCompletion( player );
|
||||
player.setQuestBitFlag8( getId(), 2, true );
|
||||
} );
|
||||
}
|
||||
|
|
|
@ -134,7 +134,10 @@ Core::ItemPtr Core::Inventory::createItem( uint32_t catalogId, uint16_t quantity
|
|||
auto pDb = g_fw.get< Db::DbWorkerPool< Db::CharaDbConnection > >();
|
||||
auto itemInfo = pExdData->get< Core::Data::Item >( catalogId );
|
||||
|
||||
uint8_t itemAmount = quantity;
|
||||
if( !itemInfo )
|
||||
return nullptr;
|
||||
|
||||
uint16_t itemAmount = quantity;
|
||||
|
||||
if( itemInfo->stackSize == 1 )
|
||||
itemAmount = 1;
|
||||
|
@ -144,16 +147,14 @@ Core::ItemPtr Core::Inventory::createItem( uint32_t catalogId, uint16_t quantity
|
|||
|
||||
uint8_t flags = 0;
|
||||
|
||||
// std::string itemName( itemInfo->name );
|
||||
|
||||
ItemPtr pItem( new Item( catalogId ) );
|
||||
ItemPtr pItem = make_Item( getNextUId(),
|
||||
catalogId,
|
||||
itemInfo->modelMain,
|
||||
itemInfo->modelSub );
|
||||
|
||||
pItem->setStackSize( itemAmount );
|
||||
pItem->setUId( getNextUId() );
|
||||
pItem->setModelIds( itemInfo->modelMain, itemInfo->modelSub );
|
||||
pItem->setCategory( static_cast< ItemUICategory >( itemInfo->itemUICategory ) );
|
||||
|
||||
pDb->execute( "INSERT INTO charaglobalitem ( CharacterId, itemId, catalogId, stack, flags ) VALUES ( " +
|
||||
pDb->execute( "INSERT INTO charaglobalitem ( CharacterId, itemId, catalogId, stack, flags ) VALUES ( " +
|
||||
std::to_string( m_pOwner->getId() ) + ", " +
|
||||
std::to_string( pItem->getUId() ) + ", " +
|
||||
std::to_string( pItem->getId() ) + ", " +
|
||||
|
@ -161,7 +162,6 @@ Core::ItemPtr Core::Inventory::createItem( uint32_t catalogId, uint16_t quantity
|
|||
std::to_string( flags ) + ");" );
|
||||
|
||||
return pItem;
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
@ -739,13 +739,14 @@ Core::ItemPtr Core::Inventory::loadItem( uint64_t uId )
|
|||
try
|
||||
{
|
||||
auto itemInfo = pExdData->get< Core::Data::Item >( itemRes->getUInt( 1 ) );
|
||||
bool isHq = itemRes->getUInt( 3 ) == 1 ? true : false;
|
||||
ItemPtr pItem( new Item( uId,
|
||||
bool isHq = itemRes->getUInt( 3 ) == 1;
|
||||
|
||||
ItemPtr pItem = make_Item( uId,
|
||||
itemRes->getUInt( 1 ),
|
||||
itemInfo->modelMain,
|
||||
itemInfo->modelSub,
|
||||
static_cast< ItemUICategory >( itemInfo->itemUICategory ),
|
||||
isHq ) );
|
||||
isHq );
|
||||
|
||||
pItem->setStackSize( itemRes->getUInt( 2 ) );
|
||||
|
||||
return pItem;
|
||||
|
|
|
@ -1,46 +1,31 @@
|
|||
#include <Common.h>
|
||||
#include <Exd/ExdDataGenerated.h>
|
||||
#include <CommonGen.h>
|
||||
|
||||
#include "Framework.h"
|
||||
#include "Item.h"
|
||||
|
||||
extern Core::Framework g_fw;
|
||||
|
||||
Core::Item::Item()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
Core::Item::Item( uint32_t catalogId ) :
|
||||
m_id( catalogId ),
|
||||
m_isHq( false )
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
Core::Item::Item( uint64_t uId, uint32_t catalogId, uint64_t model1, uint64_t model2, Common::ItemUICategory categoryId, bool isHq ) :
|
||||
Core::Item::Item( uint64_t uId, uint32_t catalogId, uint64_t model1, uint64_t model2, bool isHq ) :
|
||||
m_id( catalogId ),
|
||||
m_uId( uId ),
|
||||
m_category( categoryId ),
|
||||
m_model1( model1 ),
|
||||
m_model2( model2 ),
|
||||
m_isHq( isHq )
|
||||
{
|
||||
auto pExdData = g_fw.get< Data::ExdDataGenerated >();
|
||||
auto itemInfo = pExdData->get< Core::Data::Item >( catalogId );
|
||||
|
||||
m_delayMs = itemInfo->delayms;
|
||||
m_physicalDmg = itemInfo->damagePhys;
|
||||
m_magicalDmg = itemInfo->damageMag;
|
||||
m_weaponDmg = ( m_physicalDmg != 0 ) ? m_physicalDmg : m_magicalDmg;
|
||||
m_autoAttackDmg = static_cast< float >( m_weaponDmg * m_delayMs ) / 3000;
|
||||
m_category = static_cast< Common::ItemUICategory >( itemInfo->itemUICategory );
|
||||
m_itemLevel = itemInfo->levelItem;
|
||||
}
|
||||
|
||||
Core::Item::~Item()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
float Core::Item::getAutoAttackDmg() const
|
||||
{
|
||||
return m_autoAttackDmg;
|
||||
|
|
|
@ -9,10 +9,8 @@ class Item
|
|||
{
|
||||
|
||||
public:
|
||||
Item();
|
||||
Item( uint32_t catalogId );
|
||||
Item( uint64_t uId, uint32_t catalogId, uint64_t model1, uint64_t model2, Common::ItemUICategory categoryId, bool isHq = false );
|
||||
~Item();
|
||||
Item( uint64_t uId, uint32_t catalogId, uint64_t model1, uint64_t model2, bool isHq = false );
|
||||
~Item() = default;
|
||||
|
||||
uint32_t getId() const;
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue