//---------------------------------------------------------------------------- // CStaticItems::buildOntItem use faber system for make an item // //---------------------------------------------------------------------------- CGameItemPtr CStaticItems::buildOnetItem( CSheetId sheet ) { const CStaticItem * staticItem = CSheets::getForm( sheet ); if( staticItem != 0 ) { if( staticItem->Family != ITEMFAMILY::AMMO && staticItem->Family != ITEMFAMILY::ARMOR && staticItem->Family != ITEMFAMILY::JEWELRY && staticItem->Family != ITEMFAMILY::MELEE_WEAPON && staticItem->Family != ITEMFAMILY::RANGE_WEAPON && staticItem->Family != ITEMFAMILY::SHIELD ) return 0; if( staticItem->CraftPlan == CSheetId::Unknown ) { nlwarning("SI: Item %s have an unknown plan", sheet.toString().c_str() ); return 0; } if( staticItem->Family == ITEMFAMILY::MELEE_WEAPON || staticItem->Family == ITEMFAMILY::RANGE_WEAPON || staticItem->Family == ITEMFAMILY::AMMO || staticItem->Family == ITEMFAMILY::ARMOR || staticItem->Family == ITEMFAMILY::SHIELD || staticItem->Family == ITEMFAMILY::JEWELRY ) { CFaberPhrase phrase; vector< CSheetId > Rm; vector< CSheetId > RmFormula; // select raw material used for craft item selectRmForCraft( staticItem->CraftPlan, Rm, RmFormula ); // craft item and return it's pointer return phrase.systemCraftItem( staticItem->CraftPlan, Rm, RmFormula ); } else { nlwarning("SI: Item %s has not a good family to be sell family='%s'", sheet.toString().c_str(), ITEMFAMILY::toString(staticItem->Family).c_str() ); return 0; } } else { nlwarning("SI: Can't found static form for item %s", sheet.toString().c_str() ); return 0; } }
bool operator()(const CSheetId &a, const CSheetId &b) { return a.toString()<b.toString(); }
//--------------------------------------------------- // createItem : // //--------------------------------------------------- //CGameItemPtr CGameItemManager::createItem( CEntityId& id, CSheetId& sheetId, uint16 quality, sint16 slot, bool destroyable, bool dropable , const CEntityId &creatorId ) CGameItemPtr CGameItemManager::createItem( const CSheetId& sheetId, uint16 quality, bool destroyable, bool dropable , const CEntityId &creatorId ) { H_AUTO(GIM_createItem1); // test if the item already exists // map<CEntityId,CGameItemPtr>::iterator itIt = _Items.find( id ); // if( itIt != _Items.end() ) // { // nlwarning("<CGameItemManager::createItem> The item %s already exists",id.toString().c_str()); // return NULL; // } // MALKAV 22/01/03 : get owner, if owner not found, returns before creating the item and display a simple warning // CGameItemPtr ownerItem = NULL; // if( owner != CEntityId::Unknown ) // { // ownerItem = getItem( owner ); // BOMB_IF(ownerItem == NULL ,"Bad owner found for item",return NULL); // } // // create a new item // CGameItemPtr item = getNewItem( id, sheetId, quality, destroyable, dropable ); CGameItemPtr item = getNewItem(sheetId, quality, destroyable, dropable ); if( item != NULL ) { // nldebug("<CGameItemManager::createItem> create item %s with owner %s",id.toString().c_str(), owner.toString().c_str()); // (*item)->Owner = owner; (*item)->setCreator( creatorId ); // insert the item in the map // _Items.insert( make_pair(id,item) ); // _Items.insert( item ); // insert the item in the children of the owner // MALKAV 22/01/03 : test the owner existence sooner and use a warning instead of an nlerror to keep going // if( owner != CEntityId::Unknown ) // { // CGameItemPtr ownerItem = getItem( owner ); // if( ownerItem!=NULL ) // { // (*ownerItem)->addChild( item, slot ); // } // else // { // nlerror("<CGameItemManager::createItem> Can't find the owner item %s",owner.toString().c_str()); // } // } } else { // nlwarning("<CGameItemManager::createItem> Can't create the item %s with invalid sheet '%s'", id.toString().c_str(), sheetId.toString().c_str()); nlwarning("<CGameItemManager::createItem> Can't create an item with invalid sheet '%s'", sheetId.toString().c_str()); } log_Item_Create(item->getItemId(), item->getSheetId(), item->getStackSize(), item->quality()); return item; } // createItem //