adric21
Well-Known Member
- Joined
- Apr 26, 2016
- Messages
- 277
- Solutions
- 1
- Reaction score
- 72
Code:
Item* Player::getEquippedItem(slots_t slot) const
{
Item* item = getInventoryItem(slot);
if(!item)
return NULL;
switch(slot)
{
case SLOT_LEFT:
case SLOT_RIGHT:
return item->getWieldPosition() == SLOT_HAND ? item : NULL;
default:
break;
}
return item->getWieldPosition() == slot ? item : NULL;
}
-----------------------------ADD----------------------
Item* Player::getFirstItemById(uint32_t id) const
{
Item* tmpItem = NULL;
Container* tmpContainer = NULL;
std::list<Container*> listContainer;
for(int32_t slot = SLOT_FIRST; slot <= SLOT_LAST; slot++){
if((tmpItem = getInventoryItem((slots_t)slot))){
if(tmpItem->getID() == id){
return tmpItem;
}
else if((tmpContainer = tmpItem->getContainer())){
listContainer.push_back(tmpContainer);
}
}
}
ItemList::const_iterator it;
while(!listContainer.empty()){
Container* container = listContainer.front();
listContainer.pop_front();
for(it = container->getItems(); it != container->getEnd(); ++it){
if((tmpItem = *it)){
if(tmpItem->getID() == id){
return tmpItem;
}
else if((tmpContainer = tmpItem->getContainer())){
listContainer.push_back(tmpContainer);
}
}
}
}
return NULL;
}
_________________________________________________________________________
IN SPELLS.CPP CHAGE
if(!(item = player->getInventoryItem((slots_t)i)))
--------------TO-------------
if(!(item = player->getFirstItemById((uint32_t)i)))
_________________________________________________________________________
IN PLAYER.H
under
Item* getInventoryItem(slots_t slot) const;
----------------add--------------
Item* Player::getFirstItemById(uint32_t id) const;