mirror of
https://port.numenaute.org/aleajactaest/khanat-code-old.git
synced 2024-11-26 00:36:17 +00:00
Changed: #1304: Implementation of the "guild" parameter for the "recv_named_item" action
This commit is contained in:
parent
0491eee97d
commit
03d94a6300
1 changed files with 114 additions and 57 deletions
|
@ -975,7 +975,7 @@ class CMissionActionRecvNamedItem : public IMissionAction
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else if ( !_Group )
|
else if ( !_Group && !_Guild)
|
||||||
{
|
{
|
||||||
CCharacter * user = PlayerManager.getChar( entities[0] );
|
CCharacter * user = PlayerManager.getChar( entities[0] );
|
||||||
CTeam * team = TeamManager.getRealTeam(user->getTeamId());
|
CTeam * team = TeamManager.getRealTeam(user->getTeamId());
|
||||||
|
@ -986,41 +986,34 @@ class CMissionActionRecvNamedItem : public IMissionAction
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// check free room space in inventory
|
// If the case we want to give the item to the guild
|
||||||
// NB : in case of group, fail happens only if noone in the group have enough free space
|
if (_Guild)
|
||||||
CGameItemPtr itemTmp = CNamedItems::getInstance().createNamedItem(_NamedItem, _Quantity);
|
|
||||||
if( itemTmp != NULL )
|
|
||||||
{
|
{
|
||||||
sint16 neededSlotCount = (sint16) ceil( (float)_Quantity / itemTmp->getMaxStackSize() );
|
if (entities.size() == 0)
|
||||||
uint32 neededBulk = _Quantity * itemTmp->getStackBulk();
|
return;
|
||||||
itemTmp.deleteItem();
|
|
||||||
|
|
||||||
bool fail = true;
|
|
||||||
for ( uint i = 0; i < entities.size(); i++ )
|
|
||||||
{
|
|
||||||
CCharacter * user = PlayerManager.getChar( entities[i] );
|
|
||||||
if ( user )
|
|
||||||
{
|
|
||||||
CInventoryPtr invBag = user->getInventory( INVENTORIES::bag );
|
|
||||||
sint16 freeSlotcount = invBag->getFreeSlotCount();
|
|
||||||
uint32 maxBulk = invBag->getMaxBulk();
|
|
||||||
|
|
||||||
CInventoryPtr invTemp = user->getInventory( INVENTORIES::temporary );
|
CCharacter * user = PlayerManager.getChar( entities[0] );
|
||||||
if( invTemp )
|
if (!user)
|
||||||
{
|
{
|
||||||
freeSlotcount -= invTemp->getUsedSlotCount();
|
LOGMISSIONACTION("recv_fame : Invalid user");
|
||||||
maxBulk -= invTemp->getInventoryBulk();
|
return;
|
||||||
}
|
|
||||||
|
|
||||||
if( (neededSlotCount <= freeSlotcount) && ( neededBulk + invBag->getInventoryBulk() <= maxBulk) )
|
|
||||||
{
|
|
||||||
fail = false;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
}
|
||||||
if( fail )
|
|
||||||
|
CGuild * guild = CGuildManager::getInstance()->getGuildFromId(user->getGuildId());
|
||||||
|
if (!guild)
|
||||||
|
{
|
||||||
|
LOGMISSIONACTION("recv_fame : Invalid guild id '" + NLMISC::toString(user->getGuildId()) + "'");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
// add the item to inventory
|
||||||
|
CGameItemPtr item = CNamedItems::getInstance().createNamedItem(_NamedItem, _Quantity);
|
||||||
|
if (item == NULL)
|
||||||
|
{
|
||||||
|
LOGMISSIONACTION("named item '" + _NamedItem + "' is unknown");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
if (!guild->putItem(item))
|
||||||
{
|
{
|
||||||
CMissionTemplate * templ = CMissionManager::getInstance()->getTemplate( instance->getTemplateId() );
|
CMissionTemplate * templ = CMissionManager::getInstance()->getTemplate( instance->getTemplateId() );
|
||||||
if ( templ )
|
if ( templ )
|
||||||
|
@ -1032,39 +1025,103 @@ class CMissionActionRecvNamedItem : public IMissionAction
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
for ( uint i = 0; i < entities.size(); i++ )
|
||||||
|
{
|
||||||
|
CCharacter * user = PlayerManager.getChar( entities[i] );
|
||||||
|
if ( user )
|
||||||
|
{
|
||||||
|
SM_STATIC_PARAMS_2(params, STRING_MANAGER::dyn_string_id, STRING_MANAGER::integer);
|
||||||
|
params[0].StringId = item->sendNameId(user);
|
||||||
|
params[1].Int = _Quantity;
|
||||||
|
PHRASE_UTILITIES::sendDynamicSystemMessage(user->getEntityRowId(),"MIS_GUILD_RECV_NAMED_ITEM", params);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
LOGMISSIONACTION("named item '" + _NamedItem + "' is unknown");
|
// check free room space in inventory
|
||||||
return;
|
// NB : in case of group, fail happens only if noone in the group have enough free space
|
||||||
}
|
CGameItemPtr itemTmp = CNamedItems::getInstance().createNamedItem(_NamedItem, _Quantity);
|
||||||
|
if( itemTmp != NULL )
|
||||||
// apply the action to all entities
|
|
||||||
for ( uint i = 0; i < entities.size(); i++ )
|
|
||||||
{
|
|
||||||
CCharacter * user = PlayerManager.getChar( entities[i] );
|
|
||||||
if ( user )
|
|
||||||
{
|
{
|
||||||
if (!user->enterTempInventoryMode(TEMP_INV_MODE::MissionReward))
|
sint16 neededSlotCount = (sint16) ceil( (float)_Quantity / itemTmp->getMaxStackSize() );
|
||||||
continue;
|
uint32 neededBulk = _Quantity * itemTmp->getStackBulk();
|
||||||
|
itemTmp.deleteItem();
|
||||||
|
|
||||||
|
bool fail = true;
|
||||||
|
for ( uint i = 0; i < entities.size(); i++ )
|
||||||
|
{
|
||||||
|
CCharacter * user = PlayerManager.getChar( entities[i] );
|
||||||
|
if ( user )
|
||||||
|
{
|
||||||
|
CInventoryPtr invBag = user->getInventory( INVENTORIES::bag );
|
||||||
|
sint16 freeSlotcount = invBag->getFreeSlotCount();
|
||||||
|
uint32 maxBulk = invBag->getMaxBulk();
|
||||||
|
|
||||||
// add the item to inventory
|
CInventoryPtr invTemp = user->getInventory( INVENTORIES::temporary );
|
||||||
CGameItemPtr item = CNamedItems::getInstance().createNamedItem(_NamedItem, _Quantity);
|
if( invTemp )
|
||||||
if (item == NULL)
|
{
|
||||||
{
|
freeSlotcount -= invTemp->getUsedSlotCount();
|
||||||
LOGMISSIONACTION("named item '" + _NamedItem + "' is unknown");
|
maxBulk -= invTemp->getInventoryBulk();
|
||||||
return;
|
}
|
||||||
|
|
||||||
|
if( (neededSlotCount <= freeSlotcount) && ( neededBulk + invBag->getInventoryBulk() <= maxBulk) )
|
||||||
|
{
|
||||||
|
fail = false;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
if(!user->addItemToInventory(INVENTORIES::temporary, item))
|
if( fail )
|
||||||
{
|
{
|
||||||
item.deleteItem();
|
CMissionTemplate * templ = CMissionManager::getInstance()->getTemplate( instance->getTemplateId() );
|
||||||
|
if ( templ )
|
||||||
|
{
|
||||||
|
if ( templ->Tags.FailIfInventoryIsFull )
|
||||||
|
{
|
||||||
|
instance->setProcessingState(CMission::ActionFailed);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
else
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
LOGMISSIONACTION("named item '" + _NamedItem + "' is unknown");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
// apply the action to all entities
|
||||||
|
for ( uint i = 0; i < entities.size(); i++ )
|
||||||
|
{
|
||||||
|
CCharacter * user = PlayerManager.getChar( entities[i] );
|
||||||
|
if ( user )
|
||||||
{
|
{
|
||||||
SM_STATIC_PARAMS_2(params, STRING_MANAGER::dyn_string_id, STRING_MANAGER::integer);
|
if (!user->enterTempInventoryMode(TEMP_INV_MODE::MissionReward))
|
||||||
params[0].StringId = item->sendNameId(user);
|
continue;
|
||||||
params[1].Int = _Quantity;
|
|
||||||
PHRASE_UTILITIES::sendDynamicSystemMessage(user->getEntityRowId(),"MIS_RECV_NAMED_ITEM", params);
|
// add the item to inventory
|
||||||
|
CGameItemPtr item = CNamedItems::getInstance().createNamedItem(_NamedItem, _Quantity);
|
||||||
|
if (item == NULL)
|
||||||
|
{
|
||||||
|
LOGMISSIONACTION("named item '" + _NamedItem + "' is unknown");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
if(!user->addItemToInventory(INVENTORIES::temporary, item))
|
||||||
|
{
|
||||||
|
item.deleteItem();
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
SM_STATIC_PARAMS_2(params, STRING_MANAGER::dyn_string_id, STRING_MANAGER::integer);
|
||||||
|
params[0].StringId = item->sendNameId(user);
|
||||||
|
params[1].Int = _Quantity;
|
||||||
|
PHRASE_UTILITIES::sendDynamicSystemMessage(user->getEntityRowId(),"MIS_RECV_NAMED_ITEM", params);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue