本文整理汇总了C++中LPITEM::SetForceAttribute方法的典型用法代码示例。如果您正苦于以下问题:C++ LPITEM::SetForceAttribute方法的具体用法?C++ LPITEM::SetForceAttribute怎么用?C++ LPITEM::SetForceAttribute使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类LPITEM
的用法示例。
在下文中一共展示了LPITEM::SetForceAttribute方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: PutAttributes
bool DSManager::PutAttributes(LPITEM pDS)
{
if (!pDS->IsDragonSoul())
{
sys_err ("This item(ID : %d) is not DragonSoul.", pDS->GetID());
return false;
}
BYTE ds_type, grade_idx, step_idx, strength_idx;
GetDragonSoulInfo(pDS->GetVnum(), ds_type, grade_idx, step_idx, strength_idx);
DragonSoulTable::TVecApplys vec_basic_applys;
DragonSoulTable::TVecApplys vec_addtional_applys;
if (!m_pTable->GetBasicApplys(ds_type, vec_basic_applys))
{
sys_err ("There is no BasicApply about %d type dragon soul.", ds_type);
return false;
}
if (!m_pTable->GetAdditionalApplys(ds_type, vec_addtional_applys))
{
sys_err ("There is no AdditionalApply about %d type dragon soul.", ds_type);
return false;
}
int basic_apply_num, add_min, add_max;
if (!m_pTable->GetApplyNumSettings(ds_type, grade_idx, basic_apply_num, add_min, add_max))
{
sys_err ("In ApplyNumSettings, INVALID VALUES Group type(%d), GRADE idx(%d)", ds_type, grade_idx);
return false;
}
float fWeight = 0.f;
if (!m_pTable->GetWeight(ds_type, grade_idx, step_idx, strength_idx, fWeight))
{
return false;
}
fWeight /= 100.f;
int n = MIN(basic_apply_num, vec_basic_applys.size());
for (int i = 0; i < n; i++)
{
const SApply& basic_apply = vec_basic_applys[i];
BYTE bType = basic_apply.apply_type;
short sValue = (short)(ceil((float)basic_apply.apply_value * fWeight - 0.01f));
pDS->SetForceAttribute(i, bType, sValue);
}
BYTE additional_attr_num = MIN(number (add_min, add_max), 3);
std::vector <int> random_set;
if (additional_attr_num > 0)
{
random_set.resize(additional_attr_num);
std::list <float> list_probs;
for (int i = 0; i < vec_addtional_applys.size(); i++)
{
list_probs.push_back(vec_addtional_applys[i].prob);
}
if (!MakeDistinctRandomNumberSet(list_probs, random_set))
{
sys_err ("MakeDistinctRandomNumberSet error.");
return false;
}
for (int i = 0; i < additional_attr_num; i++)
{
int r = random_set[i];
const SApply& additional_attr = vec_addtional_applys[r];
BYTE bType = additional_attr.apply_type;
short sValue = (short)(ceil((float)additional_attr.apply_value * fWeight - 0.01f));
pDS->SetForceAttribute(DRAGON_SOUL_ADDITIONAL_ATTR_START_IDX + i, bType, sValue);
}
}
return true;
}
示例2: RefreshItemAttributes
bool DSManager::RefreshItemAttributes(LPITEM pDS)
{
if (!pDS->IsDragonSoul())
{
sys_err ("This item(ID : %d) is not DragonSoul.", pDS->GetID());
return false;
}
BYTE ds_type, grade_idx, step_idx, strength_idx;
GetDragonSoulInfo(pDS->GetVnum(), ds_type, grade_idx, step_idx, strength_idx);
DragonSoulTable::TVecApplys vec_basic_applys;
DragonSoulTable::TVecApplys vec_addtional_applys;
if (!m_pTable->GetBasicApplys(ds_type, vec_basic_applys))
{
sys_err ("There is no BasicApply about %d type dragon soul.", ds_type);
return false;
}
if (!m_pTable->GetAdditionalApplys(ds_type, vec_addtional_applys))
{
sys_err ("There is no AdditionalApply about %d type dragon soul.", ds_type);
return false;
}
// add_min°ъ add_maxґВ ґх№М·О АРАЅ.
int basic_apply_num, add_min, add_max;
if (!m_pTable->GetApplyNumSettings(ds_type, grade_idx, basic_apply_num, add_min, add_max))
{
sys_err ("In ApplyNumSettings, INVALID VALUES Group type(%d), GRADE idx(%d)", ds_type, grade_idx);
return false;
}
float fWeight = 0.f;
if (!m_pTable->GetWeight(ds_type, grade_idx, step_idx, strength_idx, fWeight))
{
return false;
}
fWeight /= 100.f;
int n = MIN(basic_apply_num, vec_basic_applys.size());
for (int i = 0; i < n; i++)
{
const SApply& basic_apply = vec_basic_applys[i];
BYTE bType = basic_apply.apply_type;
short sValue = (short)(ceil((float)basic_apply.apply_value * fWeight - 0.01f));
pDS->SetForceAttribute(i, bType, sValue);
}
for (int i = DRAGON_SOUL_ADDITIONAL_ATTR_START_IDX; i < ITEM_ATTRIBUTE_MAX_NUM; i++)
{
BYTE bType = pDS->GetAttributeType(i);
short sValue = 0;
if (APPLY_NONE == bType)
continue;
for (int j = 0; j < vec_addtional_applys.size(); j++)
{
if (vec_addtional_applys[j].apply_type == bType)
{
sValue = vec_addtional_applys[j].apply_value;
break;
}
}
pDS->SetForceAttribute(i, bType, (short)(ceil((float)sValue * fWeight - 0.01f)));
}
return true;
}