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


C++ cItems类代码示例

本文整理汇总了C++中cItems的典型用法代码示例。如果您正苦于以下问题:C++ cItems类的具体用法?C++ cItems怎么用?C++ cItems使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


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

示例1: AddRandomArmorDropItem

void cMonster::AddRandomArmorDropItem(cItems & a_Drops, unsigned int a_LootingLevel)
{
	MTRand r1;
	if (r1.randInt() % 200 < ((m_DropChanceHelmet * 200) + (a_LootingLevel * 2)))
	{
		if (!GetEquippedHelmet().IsEmpty())
		{
			a_Drops.push_back(GetEquippedHelmet());
		}
	}

	if (r1.randInt() % 200 < ((m_DropChanceChestplate * 200) + (a_LootingLevel * 2)))
	{
		if (!GetEquippedChestplate().IsEmpty())
		{
			a_Drops.push_back(GetEquippedChestplate());
		}
	}

	if (r1.randInt() % 200 < ((m_DropChanceLeggings * 200) + (a_LootingLevel * 2)))
	{
		if (!GetEquippedLeggings().IsEmpty())
		{
			a_Drops.push_back(GetEquippedLeggings());
		}
	}

	if (r1.randInt() % 200 < ((m_DropChanceBoots * 200) + (a_LootingLevel * 2)))
	{
		if (!GetEquippedBoots().IsEmpty())
		{
			a_Drops.push_back(GetEquippedBoots());
		}
	}
}
开发者ID:4264,项目名称:cuberite,代码行数:35,代码来源:Monster.cpp

示例2: AddRandomRareDropItem

void cMonster::AddRandomRareDropItem(cItems & a_Drops, cItems & a_Items, unsigned int a_LootingLevel)
{
	MTRand r1;
	unsigned int Count = static_cast<unsigned int>(static_cast<unsigned long>(r1.randInt()) % 200);
	if (Count < (5 + a_LootingLevel))
	{
		size_t Rare = static_cast<size_t>(r1.randInt()) % a_Items.Size();
		a_Drops.push_back(a_Items.at(Rare));
	}
}
开发者ID:rhamilton1415,项目名称:cuberite,代码行数:10,代码来源:Monster.cpp

示例3: AddRandomRareDropItem

void cMonster::AddRandomRareDropItem(cItems & a_Drops, cItems & a_Items, unsigned int a_LootingLevel)
{
	MTRand r1;
	unsigned int Count = r1.randInt() % 200;
	if (Count < (5 + a_LootingLevel))
	{
		int Rare = r1.randInt() % a_Items.Size();
		a_Drops.push_back(a_Items.at(Rare));
	}
}
开发者ID:4264,项目名称:cuberite,代码行数:10,代码来源:Monster.cpp

示例4: GetDrops

void cPainting::GetDrops(cItems & a_Items, cEntity * a_Killer)
{
	if ((a_Killer != nullptr) && a_Killer->IsPlayer() && !static_cast<cPlayer *>(a_Killer)->IsGameModeCreative())
	{
		a_Items.push_back(cItem(E_ITEM_PAINTING));
	}
}
开发者ID:1285done,项目名称:cuberite,代码行数:7,代码来源:Painting.cpp

示例5: GetDrops

void cItemFrame::GetDrops(cItems & a_Items, cEntity * a_Killer)
{
	if ((a_Killer != NULL) && a_Killer->IsPlayer() && !((cPlayer *)a_Killer)->IsGameModeCreative())
	{
		a_Items.push_back(cItem(E_ITEM_ITEM_FRAME));
	}
}
开发者ID:Kortak,项目名称:MCServer,代码行数:7,代码来源:ItemFrame.cpp

示例6: GetDrops

void cSheep::GetDrops(cItems & a_Drops, cEntity * a_Killer)
{
	if (!m_IsSheared)
	{
		a_Drops.push_back(cItem(E_BLOCK_WOOL, 1, m_WoolColor));
	}
}
开发者ID:JoeClacks,项目名称:MCServer,代码行数:7,代码来源:Sheep.cpp

示例7: AddRandomWeaponDropItem

void cMonster::AddRandomWeaponDropItem(cItems & a_Drops, short a_LootingLevel)
{
	MTRand r1;
	if (r1.randInt() % 200 < ((m_DropChanceWeapon * 200) + (a_LootingLevel * 2)))
	{
		if (!GetEquippedWeapon().IsEmpty()) a_Drops.push_back(GetEquippedWeapon());
	}
}
开发者ID:axisd,项目名称:MCServer,代码行数:8,代码来源:Monster.cpp

示例8: TossItems

void cPlayer::TossItems(const cItems & a_Items)
{
	m_Stats.AddValue(statItemsDropped, a_Items.Size());

	double vX = 0, vY = 0, vZ = 0;
	EulerToVector(-GetYaw(), GetPitch(), vZ, vX, vY);
	vY = -vY * 2 + 1.f;
	m_World->SpawnItemPickups(a_Items, GetPosX(), GetEyeHeight(), GetPosZ(), vX * 3, vY * 3, vZ * 3, true); // 'true' because created by player
}
开发者ID:Kortak,项目名称:MCServer,代码行数:9,代码来源:Player.cpp

示例9: AddRandomDropItem

void cMonster::AddRandomDropItem(cItems & a_Drops, unsigned int a_Min, unsigned int a_Max, short a_Item, short a_ItemHealth)
{
	MTRand r1;
	int Count = r1.randInt() % (a_Max + 1 - a_Min) + a_Min;
	if (Count > 0)
	{
		a_Drops.push_back(cItem(a_Item, Count, a_ItemHealth));
	}
}
开发者ID:4264,项目名称:cuberite,代码行数:9,代码来源:Monster.cpp

示例10: AddRandomUncommonDropItem

void cMonster::AddRandomUncommonDropItem(cItems & a_Drops, float a_Chance, short a_Item, short a_ItemHealth)
{
	MTRand r1;
	int Count = r1.randInt() % 1000;
	if (Count < (a_Chance * 10))
	{
		a_Drops.push_back(cItem(a_Item, 1, a_ItemHealth));
	}
}
开发者ID:4264,项目名称:cuberite,代码行数:9,代码来源:Monster.cpp

示例11: AddRandomDropItem

void cMonster::AddRandomDropItem(cItems & a_Drops, unsigned int a_Min, unsigned int a_Max, short a_Item, short a_ItemHealth)
{
	MTRand r1;
	int Count = static_cast<int>(static_cast<unsigned int>(r1.randInt()) % (a_Max + 1 - a_Min) + a_Min);
	if (Count > 0)
	{
		a_Drops.push_back(cItem(a_Item, static_cast<char>(Count), a_ItemHealth));
	}
}
开发者ID:rhamilton1415,项目名称:cuberite,代码行数:9,代码来源:Monster.cpp

示例12: AddItems

int cInventory::AddItems(cItems & a_ItemStackList, bool a_AllowNewStacks)
{
	int TotalAdded = 0;
	for (cItems::iterator itr = a_ItemStackList.begin(); itr != a_ItemStackList.end();)
	{
		int NumAdded = AddItem(*itr, a_AllowNewStacks);
		if (itr->m_ItemCount == NumAdded)
		{
			itr = a_ItemStackList.erase(itr);
		}
		else
		{
			itr->m_ItemCount -= NumAdded;
			++itr;
		}
		TotalAdded += NumAdded;
	}
	return TotalAdded;
}
开发者ID:36451,项目名称:MCServer,代码行数:19,代码来源:Inventory.cpp

示例13: CopyToItems

void cItemGrid::CopyToItems(cItems & a_Items) const
{
	for (int i = 0; i < m_NumSlots; i++)
	{
		if (!m_Slots[i].IsEmpty())
		{
			a_Items.push_back(m_Slots[i]);
		}
	}  // for i - m_Slots[]
}
开发者ID:JoeClacks,项目名称:MCServer,代码行数:10,代码来源:ItemGrid.cpp

示例14: ConvertToPickups

void cBlockBedHandler::ConvertToPickups(cWorldInterface & a_WorldInterface, cItems & a_Pickups, NIBBLETYPE a_BlockMeta, int a_BlockX, int a_BlockY, int a_BlockZ)
{
	short Color = E_META_WOOL_RED;
	a_WorldInterface.DoWithBedAt(a_BlockX, a_BlockY, a_BlockZ, [&](cBedEntity & a_Bed)
		{
			Color = a_Bed.GetColor();
			return true;
		}
	);
	a_Pickups.Add(cItem(E_ITEM_BED, 1, Color));
}
开发者ID:ThuGie,项目名称:MCServer,代码行数:11,代码来源:BlockBed.cpp

示例15: GetSlots

void cWindow::GetSlots(cPlayer & a_Player, cItems & a_Slots) const
{
	a_Slots.clear();
	a_Slots.reserve(GetNumSlots());
	for (cSlotAreas::const_iterator itr = m_SlotAreas.begin(), end = m_SlotAreas.end(); itr != end; ++itr)
	{
		int NumSlots = (*itr)->GetNumSlots();
		for (int i = 0; i < NumSlots; i++)
		{
			const cItem * Item = (*itr)->GetSlot(i, a_Player);
			if (Item == NULL)
			{
				a_Slots.push_back(cItem());
			}
			else
			{
				a_Slots.push_back(*Item);
			}
		}
	}  // for itr - m_SlotAreas[]
}
开发者ID:Solexid,项目名称:MCServer,代码行数:21,代码来源:Window.cpp


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