当前位置: 首页>>代码示例>>C++>>正文


C++ EnchantmentStore::find方法代码示例

本文整理汇总了C++中EnchantmentStore::find方法的典型用法代码示例。如果您正苦于以下问题:C++ EnchantmentStore::find方法的具体用法?C++ EnchantmentStore::find怎么用?C++ EnchantmentStore::find使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在EnchantmentStore的用法示例。


在下文中一共展示了EnchantmentStore::find方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: GetItemEnchantMod

uint32 GetItemEnchantMod(int32 entry)
{
    if (!entry)
        return 0;

    EnchantmentStore::const_iterator tab;
    if (entry > 0)
    {
        tab = RandomItemPropEnch.find(entry);

        if (tab == RandomItemPropEnch.end())
        {
            sLog.outErrorDb("Item RandomProperty id #%u used in `item_template` but it doesn't have records in `item_enchantment_template` table.", entry);
            return 0;
        }
    }
    else
    {
        tab = RandomItemSuffixEnch.find(-entry);

        if (tab == RandomItemSuffixEnch.end())
        {
            sLog.outErrorDb("Item RandomSuffix id #%u used in `item_template` but it doesn't have records in `item_enchantment_template` table.", -entry);
            return 0;
        }
    }

    double dRoll = rand_chance();
    float fCount = 0;

    for(EnchStoreList::const_iterator ench_iter = tab->second.begin(); ench_iter != tab->second.end(); ++ench_iter)
    {
        fCount += ench_iter->chance;

        if (fCount > dRoll) return ench_iter->ench;
    }

    //we could get here only if sum of all enchantment chances is lower than 100%
    dRoll =  (irand(0, (int)floor(fCount * 100) + 1)) / 100;
    fCount = 0;

    for(EnchStoreList::const_iterator ench_iter = tab->second.begin(); ench_iter != tab->second.end(); ++ench_iter)
    {
        fCount += ench_iter->chance;

        if (fCount > dRoll) return ench_iter->ench;
    }

    return 0;
}
开发者ID:Calixa,项目名称:murlocs_434,代码行数:50,代码来源:ItemEnchantmentMgr.cpp

示例2: RandItemEnch

int* RandItemEnch(int32 item_id) {
	uint32 count = 0; ItemTemplate const* item = sObjectMgr->GetItemTemplate(item_id);
    if (item->RandomProperty) {
		EnchantmentStore::const_iterator tab = RandomItemEnch.find(item->RandomProperty);
		if (tab == RandomItemEnch.end()) return randitemench; 
		EnchStoreList::const_iterator ench_iter = tab->second.begin();
		for (EnchStoreList::const_iterator ench_iter = tab->second.begin(); ench_iter != tab->second.end(); ++ench_iter) {
			randitemench[count] = ench_iter->ench;
			count++; } }
	else {
		EnchantmentStore::const_iterator tab = RandomItemEnch.find(item->RandomSuffix);
		if (tab == RandomItemEnch.end()) return randitemench;
		EnchStoreList::const_iterator ench_iter = tab->second.begin();
		for (EnchStoreList::const_iterator ench_iter = tab->second.begin(); ench_iter != tab->second.end(); ++ench_iter) {
			randitemench[count] = ench_iter->ench;
			count++; } }
	return randitemench; }
开发者ID:Hlkz2,项目名称:ao39,代码行数:17,代码来源:ItemEnchantmentMgr.cpp

示例3: RandItemSuffix

std::string* RandItemSuffix(int32 item_id) {
	uint32 count = 0; ItemTemplate const* item = sObjectMgr->GetItemTemplate(item_id);
    if (item->RandomProperty) {
		EnchantmentStore::const_iterator tab = RandomItemEnch.find(item->RandomProperty);
		if (tab == RandomItemEnch.end()) return randitemsuffix;
		EnchStoreList::const_iterator ench_iter = tab->second.begin();
		for (EnchStoreList::const_iterator ench_iter = tab->second.begin(); ench_iter != tab->second.end(); ++ench_iter) {
			const ItemRandomPropertiesEntry* random_id = sItemRandomPropertiesStore.LookupEntry(ench_iter->ench);		
			if ((count <= 31) && (ench_iter->ench != 0)) {
				randitemsuffix[count] = random_id->nameSuffix[2]; }
			count++; } }
    else {
		EnchantmentStore::const_iterator tab = RandomItemEnch.find(item->RandomSuffix);
		if (tab == RandomItemEnch.end()) return randitemsuffix;
		EnchStoreList::const_iterator ench_iter = tab->second.begin();
		for (EnchStoreList::const_iterator ench_iter = tab->second.begin(); ench_iter != tab->second.end(); ++ench_iter) {
			const ItemRandomSuffixEntry* random_id = sItemRandomSuffixStore.LookupEntry(ench_iter->ench);		
			if ((count <= 31) && (ench_iter->ench != 0)) {
				randitemsuffix[count] = random_id->nameSuffix[2]; }
			count++; } }
		return randitemsuffix; }
开发者ID:Hlkz2,项目名称:ao39,代码行数:21,代码来源:ItemEnchantmentMgr.cpp

示例4: GetItemEnchantMod

uint32 GetItemEnchantMod(int32 entry, uint32 type)
{
    if (!entry)
        return 0;

    if (entry == -1)
        return 0;

    EnchantmentStore::const_iterator tab = type == ENCHANTMENT_RANDOM_PROPERTY ? RandomPropertyItemEnch.find(entry) : RandomSuffixItemEnch.find(entry) ;
    if (tab == (type == ENCHANTMENT_RANDOM_PROPERTY ? RandomPropertyItemEnch.end() : RandomSuffixItemEnch.end()))
    {
        sLog->outError(LOG_FILTER_SQL, "Item RandomProperty / RandomSuffix id #%u used in `item_template` but it does not have records in `item_enchantment_template` table.", entry);
        return 0;
    }

    double dRoll = rand_chance();
    float fCount = 0;

    for (EnchStoreList::const_iterator ench_iter = tab->second.begin(); ench_iter != tab->second.end(); ++ench_iter)
    {
        fCount += ench_iter->chance;

        if (fCount > dRoll)
            return ench_iter->ench;
    }

    //we could get here only if sum of all enchantment chances is lower than 100%
    dRoll = (irand(0, (int)floor(fCount * 100) + 1)) / 100;
    fCount = 0;

    for (EnchStoreList::const_iterator ench_iter = tab->second.begin(); ench_iter != tab->second.end(); ++ench_iter)
    {
        fCount += ench_iter->chance;

        if (fCount > dRoll)
            return ench_iter->ench;
    }

    return 0;
}
开发者ID:AwkwardDev,项目名称:MistCore,代码行数:40,代码来源:ItemEnchantmentMgr.cpp


注:本文中的EnchantmentStore::find方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。