//-------------------------------------------------------------- // CCombatDefenderPlayer::getShield //-------------------------------------------------------------- bool CCombatDefenderPlayer::getShield(CCombatShield &shield) const { CCharacter *character = PlayerManager.getChar(_RowId); if ( !character) { return false; } CGameItemPtr shieldPtr = character->getLeftHandItem(); if (shieldPtr == NULL || shieldPtr->getStaticForm() == NULL || shieldPtr->getStaticForm()->Family != ITEMFAMILY::SHIELD ) return false; shield.Quality = shieldPtr->quality(); shield.Skill = shieldPtr->getStaticForm()->Skill; if ( shield.Skill < SKILLS::NUM_SKILLS ) { shield.SkillValue = character->getSkills()._Skills[ shield.Skill ].Current; } else shield.SkillValue = 0; shield.MaxBluntProtection = shieldPtr->getProtection(DMGTYPE::BLUNT).Max; shield.MaxPiercingProtection = shieldPtr->getProtection(DMGTYPE::PIERCING).Max; shield.MaxSlashingProtection = shieldPtr->getProtection(DMGTYPE::SLASHING).Max; shield.BluntProtectionFactor = shieldPtr->getProtection(DMGTYPE::BLUNT).Factor; shield.PiercingProtectionFactor = shieldPtr->getProtection(DMGTYPE::PIERCING).Factor; shield.SlashingProtectionFactor = shieldPtr->getProtection(DMGTYPE::BLUNT).Factor; shield.ShieldType = shieldPtr->getStaticForm()->Shield->ShieldType; shield.ArmorType = shieldPtr->getStaticForm()->Shield->ArmorType; return true; } // CCombatDefenderPlayer::getShield //
//-------------------------------------------------------------- // CCombatDefenderPlayer::getArmor //-------------------------------------------------------------- bool CCombatDefenderPlayer::getArmor( SLOT_EQUIPMENT::TSlotEquipment slot, CCombatArmor &armor ) const { CCharacter *character = PlayerManager.getChar(_RowId); if ( !character) { return false; } CGameItemPtr armorPtr = character->getItem(INVENTORIES::equipment, slot); if (armorPtr == NULL || armorPtr->getStaticForm() == NULL || armorPtr->getStaticForm()->Family != ITEMFAMILY::ARMOR) return false; armor.Quality = armorPtr->quality(); armor.Skill = armorPtr->getStaticForm()->Skill; if( armor.Skill < 0 ) { nlwarning("<CCombatDefenderPlayer::getArmor> armor.Skill negative !!!!"); armor.SkillValue = 0; } else if ( armor.Skill < SKILLS::NUM_SKILLS ) { armor.SkillValue = character->getSkills()._Skills[ armor.Skill ].Current; } else armor.SkillValue = 0; armor.MaxBluntProtection = armorPtr->getProtection(DMGTYPE::BLUNT).Max; armor.MaxPiercingProtection = armorPtr->getProtection(DMGTYPE::PIERCING).Max; armor.MaxSlashingProtection = armorPtr->getProtection(DMGTYPE::SLASHING).Max; armor.BluntProtectionFactor = armorPtr->getProtection(DMGTYPE::BLUNT).Factor; armor.PiercingProtectionFactor = armorPtr->getProtection(DMGTYPE::PIERCING).Factor; armor.SlashingProtectionFactor = armorPtr->getProtection(DMGTYPE::BLUNT).Factor; armor.ArmorType = armorPtr->getStaticForm()->Armor->ArmorType; return true; } // CCombatDefenderPlayer::getArmor //
//--------------------------------------------------- // 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 //
// **************************************************************************** void CCharacterInvView::updateClientSlot(uint32 slot, const CGameItemPtr item) { // do nothing if client is not ready if (!getCharacter()->getEnterFlag()) return; if (item != NULL) { uint32 price; RM_FABER_STAT_TYPE::TRMStatType itemBestStat; getCharacter()->queryItemPrice( item, price ); itemBestStat = item->getCraftParameters() == 0 ? RM_FABER_STAT_TYPE::Unknown : item->getCraftParameters()->getBestItemStat(); BOTCHATTYPE::TBotChatResaleFlag resaleFlag = (item->durability() == item->maxDurability() ? BOTCHATTYPE::ResaleOk : BOTCHATTYPE::ResaleKOBroken); if (item->getLockedByOwner()) { resaleFlag = BOTCHATTYPE::ResaleKOLockedByOwner; } INVENTORIES::CItemSlot itemSlot( slot ); itemSlot.setItemProp( INVENTORIES::Sheet, item->getSheetId().asInt() ); itemSlot.setItemProp( INVENTORIES::Quality, item->quality() ); itemSlot.setItemProp( INVENTORIES::Quantity, item->getStackSize() ); itemSlot.setItemProp( INVENTORIES::UserColor, item->color() ); itemSlot.setItemProp( INVENTORIES::Locked, item->getLockCount() ); itemSlot.setItemProp( INVENTORIES::Weight, item->weight() / 10 ); itemSlot.setItemProp( INVENTORIES::NameId, item->sendNameId(getCharacter()) ); itemSlot.setItemProp( INVENTORIES::Enchant, item->getClientEnchantValue() ); itemSlot.setItemProp( INVENTORIES::Price, price ); itemSlot.setItemProp( INVENTORIES::ResaleFlag, resaleFlag ); itemSlot.setItemProp( INVENTORIES::ItemClass, item->getItemClass() ); itemSlot.setItemProp( INVENTORIES::ItemBestStat, itemBestStat ); itemSlot.setItemProp( INVENTORIES::PrerequisitValid, getCharacter()->checkPreRequired( item ) ); itemSlot.setItemProp( INVENTORIES::Worned, (item->getItemWornState()==ITEM_WORN_STATE::Worned)); getCharacter()->_InventoryUpdater.setItemProps( getInventory()->getInventoryId(), itemSlot ); } else { // empty slot getCharacter()->_InventoryUpdater.resetItem( getInventory()->getInventoryId(), slot ); } // send slot update to the client getCharacter()->_InventoryUpdater.incInfoVersion(getInventory()->getInventoryId(), slot); }
bool CInterShardExchangeValidator::isExchangeAllowed(const CGameItemPtr& theItem, TShardId shardId0, TShardId shardId1) const { // allow all exchanges between characters from the same shard if (shardId0==shardId1) return true; // allow all exchanges of plot items if ( theItem->getStaticForm()->Family == ITEMFAMILY::SCROLL_R2 ) return true; // determine the maximum level for items exchanged between the 2 shards TLevelCap levelLimit= std::min(getLevelCap(shardId0),getLevelCap(shardId1)); // if item is too high level then refuse if (theItem->quality()>levelLimit) return false; // if item is flagged as non-shardExchangeable then refuse if (theItem->getStaticForm()->ShardExchangeable==false) return false; // if item is named (and not a plot item) then refuse if (!theItem->getPhraseId().empty()) return false; // we've found no reason to refuse so return true return true; }
/* * Report the accumulated XP to a participant */ void CForageProgress::reportXPTo( CCharacter *player, float factor, CGameItemPtr toolUsed ) { H_AUTO(CForageProgress_reportXPTo); // Calculate delta level between obtained quality (level) and extractor's level, add bonus for quantity sint32 deltaLevel = player->getSkillBaseValue( _UsedSkill ) - ((sint32)quality()); deltaLevel -= (sint32)(((float)(amount() - 1)) * ForageQuantityXPDeltaLevelBonusRate.get()); // Action report for xp gain TReportAction report; report.ActorRowId = player->getEntityRowId(); report.ActionNature = ACTNATURE::SEARCH_MP; report.DeltaLvl = deltaLevel; report.factor = factor; // factor=10 and deltaLevel=0 => clientXP=1000 report.Skill = _UsedSkill; // send a message if tol is worned if ( (toolUsed != NULL) && (toolUsed->getItemWornState() == ITEM_WORN_STATE::Worned) ) { const CStaticItem * form = toolUsed->getStaticForm(); if( form ) { const string msgName = ITEM_WORN_STATE::getMessageForState(ITEM_WORN_STATE::Worned); if ( !msgName.empty()) { SM_STATIC_PARAMS_1(params, STRING_MANAGER::item); params[0].SheetId = toolUsed->getSheetId(); PHRASE_UTILITIES::sendDynamicSystemMessage( report.ActorRowId, msgName, params); } } } else { // compute wear of used tool (must be in right hand) if ( toolUsed != NULL ) player->wearRightHandItem(); // report Xp Gain unless used tool is worned PROGRESSIONPVE::CCharacterProgressionPVE::getInstance()->actionReport( report, true, false ); // don't scale delta level at low level PROGRESSIONPVP::CCharacterProgressionPVP::getInstance()->reportAction(report); } // wear armor, shield and jewels player->wearArmor(); player->wearShield(); player->wearJewels(); // Store stats about progression CSheetId hl, hr; uint32 qualityl, qualityr; CGameItemPtr item = player->getLeftHandItem(); if( item == 0 ) { qualityl = 0; } else { hl = item->getSheetId(); qualityl = item->quality(); } item = player->getRightHandItem(); if( item == 0 ) { qualityr = 0; } else { hr = item->getSheetId(); qualityr = item->quality(); } //Bsi.append( StatPath, NLMISC::toString("[EAE] %s %s %d %s %d %1.2f", player->getId().toString().c_str(), hl.toString().c_str(), qualityl, hr.toString().c_str(), qualityr, report.factor) ); //EgsStat.displayNL("[EAE] %s %s %d %s %d %1.2f", player->getId().toString().c_str(), hl.toString().c_str(), qualityl, hr.toString().c_str(), qualityr, report.factor); // EGSPD::executeActionMagic(player->getId(), hl.toString(), qualityl, hr.toString(), qualityr, report.factor); }
//----------------------------------------------- // createInGameItem //----------------------------------------------- CGameItemPtr CGameItemManager::createInGameItem( uint16 quality, uint32 quantity, const NLMISC::CSheetId &sheet, const CEntityId &creatorId , const std::string * phraseId) { H_AUTO(GIM_createInGameItem); static const CSheetId preorderSheetId("pre_order.sitem"); if ( quantity == 0 || quality ==0 ) return NULL; // static const CSheetId idSheetStack("stack.sitem"); const CStaticItem* form = CSheets::getForm( sheet ); if (!form) { nlwarning("<CCharacter::createInGameItem> Cannot find form of item %s", sheet.toString().c_str()); return NULL; } CGameItemPtr item; CGameItemPtr sellingItem; // if item can be sold, get it in the sold items list if ( form->Family != ITEMFAMILY::RAW_MATERIAL && form->Family != ITEMFAMILY::HARVEST_TOOL && form->Family != ITEMFAMILY::CRAFTING_TOOL && form->Family != ITEMFAMILY::CRYSTALLIZED_SPELL && form->Family != ITEMFAMILY::ITEM_SAP_RECHARGE && form->Family != ITEMFAMILY::FOOD ) { vector< CGameItemPtr >::const_iterator it; const vector< CGameItemPtr >::const_iterator itEnd = CStaticItems::getStaticItems().end(); for( it = CStaticItems::getStaticItems().begin(); it != itEnd; ++it ) { if( (*it)->getSheetId() == sheet ) { sellingItem = *it; break; } } } switch( form->Family ) { case ITEMFAMILY::CRAFTING_TOOL: case ITEMFAMILY::HARVEST_TOOL: case ITEMFAMILY::RAW_MATERIAL: case ITEMFAMILY::TELEPORT: case ITEMFAMILY::CRYSTALLIZED_SPELL: case ITEMFAMILY::ITEM_SAP_RECHARGE: case ITEMFAMILY::MISSION_ITEM: case ITEMFAMILY::PET_ANIMAL_TICKET: case ITEMFAMILY::HANDLED_ITEM: case ITEMFAMILY::CONSUMABLE: case ITEMFAMILY::XP_CATALYSER: case ITEMFAMILY::SCROLL: case ITEMFAMILY::FOOD: case ITEMFAMILY::SCROLL_R2: case ITEMFAMILY::GENERIC_ITEM: { item = GameItemManager.createItem( const_cast< CSheetId& > ( sheet ), quality, true, true, creatorId); } break; default: { if( sellingItem != NULL ) { item = sellingItem->getItemCopy(); item->quality( quality ); if ( phraseId ) item->setPhraseId(*phraseId); } else if (sheet == preorderSheetId) { item = GameItemManager.createItem(sheet, quality, true, form->DropOrSell, creatorId); } } if( item == NULL) { nlwarning("<CCharacter::createInGameItem> Error while creating item : NULL pointer"); return NULL; } } quantity = min(quantity, item->getMaxStackSize()); item->setStackSize(quantity); return item; } // createInGameItem //