// **************************************************************************** void CCharacterInvView::onItemChanged(uint32 slot, INVENTORIES::TItemChangeFlags changeFlags) { H_AUTO(OnItemChange); if ( changeFlags.checkEnumValue(INVENTORIES::itc_inserted) || changeFlags.checkEnumValue(INVENTORIES::itc_lock_state) || changeFlags.checkEnumValue(INVENTORIES::itc_enchant) || changeFlags.checkEnumValue(INVENTORIES::itc_worned) ) { const CGameItemPtr item = getInventory()->getItem(slot); nlassert(item != NULL); updateClientSlot(slot, item); } else if (changeFlags.checkEnumValue(INVENTORIES::itc_removed)) { // Cleanup the item in player inventory updateClientSlot(slot, NULL); } else if (changeFlags.checkEnumValue(INVENTORIES::itc_hp)) { const CGameItemPtr item = getInventory()->getItem(slot); nlassert(item != NULL); // get new worn state ITEM_WORN_STATE::TItemWornState wornState = item->getItemWornState(); item->computeItemWornState(); // if states differs send a message if (wornState != item->getItemWornState()) { if (getCharacter() != NULL) { string msgName = ITEM_WORN_STATE::getMessageForState(item->getItemWornState()); if ( !msgName.empty()) { SM_STATIC_PARAMS_1(params, STRING_MANAGER::item); params[0].SheetId = item->getSheetId(); CCharacter::sendDynamicSystemMessage( getCharacter()->getEntityRowId(), msgName, params); } } } // send slot update to the client updateClientSlot(slot, item); } if (changeFlags.checkEnumValue(INVENTORIES::itc_info_version)) { getCharacter()->_InventoryUpdater.syncInfoVersion(getInventory()->getInventoryId(), slot); } }
// **************************************************************************** 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); }
/* * 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); }
//----------------------------------------------- // CFaberPhrase validate //----------------------------------------------- bool CFaberPhrase::validate() { H_AUTO(CFaberPhrase_validate); if ( !CraftSystemEnabled ) return false; CCharacter * c = (CCharacter *) CEntityBaseManager::getEntityBasePtr( _ActorRowId ); if( c == 0 ) { nlwarning("<CFaberPhrase::validate> Player character not found but his crafting action still running!!!"); return false; } // test entity can use action if (c->canEntityUseAction() == false) { return false; } // check right hand item is a crafting tool CGameItemPtr rightHandItem = c->getRightHandItem(); if (rightHandItem == NULL || rightHandItem->getStaticForm() == NULL || rightHandItem->getStaticForm()->Family != ITEMFAMILY::CRAFTING_TOOL) { PHRASE_UTILITIES::sendDynamicSystemMessage(_ActorRowId, "CRAFT_NEED_CRAFTING_TOOL"); return false; } // check tool is not worned if( rightHandItem->getItemWornState() == ITEM_WORN_STATE::Worned ) { PHRASE_UTILITIES::sendDynamicSystemMessage(_ActorRowId, "CRAFT_NEED_CRAFTING_TOOL"); return false; } // check quality of right hand item (need be >= Recommended (level of item)) if (rightHandItem->recommended()+49 < _Recommended) { PHRASE_UTILITIES::sendDynamicSystemMessage(_ActorRowId, "CRAFT_NEED_RECOMMENDED_CRAFTING_TOOL"); return false; } // entities cant craft if in combat /* commented as test of right hand item is now made... TDataSetRow entityRowId = CPhraseManager::getInstance().getEntityEngagedMeleeBy( _ActorRowId ); if (TheDataset.isAccessible(entityRowId)) { PHRASE_UTILITIES::sendDynamicSystemMessage(_ActorRowId, "CANT_CRAFT_ENGAGED_IN_MELEE"); return false; } */ const sint32 focus = c->getScores()._PhysicalScores[ SCORES::focus ].Current; if ( focus < _FocusCost ) { PHRASE_UTILITIES::sendDynamicSystemMessage(_ActorRowId, "CANT_CRAFT_NOT_ENOUGHT_FOCUS"); c->unlockFaberRms(); return false; } const sint32 hp = c->currentHp(); if (hp <= 0 || c->isDead()) { PHRASE_UTILITIES::sendDynamicSystemMessage(_ActorRowId, "CANT_CRAFT_WHEN_DEAD"); c->unlockFaberRms(); return false; } /// todo alain : test if on mount // store vector of pointer on raw material item if( state() == Evaluated ) { if( c->lockFaberRms() ) { _Mps.clear(); _MpsFormula.clear(); if( c->getFillFaberRms( _Mps, _MpsFormula, _LowerRmQuality ) == false ) //TODO check exec step { c->unlockFaberRms(); PHRASE_UTILITIES::sendDynamicSystemMessage(_ActorRowId, "CANT_FOUND_RM"); return false; } } else { c->unlockFaberRms(); PHRASE_UTILITIES::sendDynamicSystemMessage(_ActorRowId, "CANT_LOCK_RM"); return false; } } return true; }// CFaberPhrase validate