本文整理汇总了C++中LPITEM::GetAttributeCount方法的典型用法代码示例。如果您正苦于以下问题:C++ LPITEM::GetAttributeCount方法的具体用法?C++ LPITEM::GetAttributeCount怎么用?C++ LPITEM::GetAttributeCount使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类LPITEM
的用法示例。
在下文中一共展示了LPITEM::GetAttributeCount方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: RemoveBuffFromItem
void CBuffOnAttributes::RemoveBuffFromItem(LPITEM pItem)
{
if (0 == m_bBuffValue)
return ;
if (NULL != pItem)
{
if (pItem->GetCell() < INVENTORY_MAX_NUM)
return;
std::vector <BYTE>::iterator it = find (m_p_vec_buff_wear_targets->begin(), m_p_vec_buff_wear_targets->end(), pItem->GetCell() - INVENTORY_MAX_NUM);
if (m_p_vec_buff_wear_targets->end() == it)
return;
int m = pItem->GetAttributeCount();
for (int j = 0; j < m; j++)
{
TPlayerItemAttribute attr = pItem->GetAttribute(j);
TMapAttr::iterator it = m_map_additional_attrs.find(attr.bType);
// m_map_additional_attrs에서 해당 attribute type에 대한 값을 제거하고,
// 변경된 값의 (m_bBuffValue)%만큼의 버프 효과 감소
if (it != m_map_additional_attrs.end())
{
int& sum_of_attr_value = it->second;
int old_value = sum_of_attr_value * m_bBuffValue / 100;
int new_value = (sum_of_attr_value - attr.sValue) * m_bBuffValue / 100;
m_pBuffOwner->ApplyPoint(attr.bType, new_value - old_value);
sum_of_attr_value -= attr.sValue;
}
else
{
sys_err ("Buff ERROR(type %d). This item(%d) attr_type(%d) was not in buff pool", m_bPointType, pItem->GetVnum(), attr.bType);
return;
}
}
}
}
示例2: AddBuffFromItem
void CBuffOnAttributes::AddBuffFromItem(LPITEM pItem)
{
if (0 == m_bBuffValue)
return ;
if (NULL != pItem)
{
if (pItem->GetCell() < INVENTORY_MAX_NUM)
return;
std::vector <BYTE>::iterator it = find (m_p_vec_buff_wear_targets->begin(), m_p_vec_buff_wear_targets->end(), pItem->GetCell() - INVENTORY_MAX_NUM);
if (m_p_vec_buff_wear_targets->end() == it)
return;
int m = pItem->GetAttributeCount();
for (int j = 0; j < m; j++)
{
TPlayerItemAttribute attr = pItem->GetAttribute(j);
TMapAttr::iterator it = m_map_additional_attrs.find(attr.bType);
// m_map_additional_attrs에서 해당 attribute type에 대한 값이 없다면 추가.
// 추가된 값의 (m_bBuffValue)%만큼의 버프 효과 추가
if (it == m_map_additional_attrs.end())
{
m_pBuffOwner->ApplyPoint(attr.bType, attr.sValue * m_bBuffValue / 100);
m_map_additional_attrs.insert(TMapAttr::value_type(attr.bType, attr.sValue));
}
// m_map_additional_attrs에서 해당 attribute type에 대한 값이 있다면, 그 값을 증가시키고,
// 변경된 값의 (m_bBuffValue)%만큼의 버프 효과 추가
else
{
int& sum_of_attr_value = it->second;
int old_value = sum_of_attr_value * m_bBuffValue / 100;
int new_value = (sum_of_attr_value + attr.sValue) * m_bBuffValue / 100;
m_pBuffOwner->ApplyPoint(attr.bType, new_value - old_value);
sum_of_attr_value += attr.sValue;
}
}
}
}
示例3: On
bool CBuffOnAttributes::On(BYTE bValue)
{
if (0 != m_bBuffValue || 0 == bValue)
return false;
int n = m_p_vec_buff_wear_targets->size();
m_map_additional_attrs.clear();
for (int i = 0; i < n; i++)
{
LPITEM pItem = m_pBuffOwner->GetWear(m_p_vec_buff_wear_targets->at(i));
if (NULL != pItem)
{
int m = pItem->GetAttributeCount();
for (int j = 0; j < m; j++)
{
TPlayerItemAttribute attr = pItem->GetAttribute(j);
TMapAttr::iterator it = m_map_additional_attrs.find(attr.bType);
if (it != m_map_additional_attrs.end())
{
it->second += attr.sValue;
}
else
{
m_map_additional_attrs.insert(TMapAttr::value_type(attr.bType, attr.sValue));
}
}
}
}
for (TMapAttr::iterator it = m_map_additional_attrs.begin(); it != m_map_additional_attrs.end(); it++)
{
m_pBuffOwner->ApplyPoint(it->first, it->second * bValue / 100);
}
m_bBuffValue = bValue;
return true;
}