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


C++ ItemBase::GetItemRequirements方法代码示例

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


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

示例1: CanEquip

/* Checks if an item can be equiped in this slot */
bool Equipable::CanEquip(_Item * NewItem)
{
    /* If this is a weapon/device then we can unequip it */
	if (m_Slot >= 3 && m_Slot <= 14 && NewItem->ItemTemplateID == -1)
    {
		return true;
    }

	ItemBase * myItemBase = g_ItemBaseMgr->GetItem(NewItem->ItemTemplateID);

    /* If we fail to find an itembase - exit */
	if (!myItemBase)
    {
		return false;
    }

    int SubCat = myItemBase->SubCategory();

    /* Now check to see if this is ammo for current item */
    if (SubCat == 103 && m_UsesAmmo && !CorrectAmmo(NewItem))
    {
		m_Player->SendPriorityMessageString("The ammo does not fit here","MessageLine",2000,4);
        //printf("CanEquip - Wrong ammo\n");
        return false;
    }

    /* Cannot equip ammo without a launcher */
    if (SubCat == 103 && !m_UsesAmmo)
    {
		m_Player->SendPriorityMessageString("Weapon doesn't require ammo","MessageLine",2000,4);
		//m_Player->SendVaMessage("Weapon doesn't use ammo");
        //printf("CanEquip - Ammo with no launcher\n");
        return false;
    }

    /* Now check that the item matches the slot type */
	if ((m_Slot == 0 && SubCat != 122) ||  // Shield
        (m_Slot == 1 && SubCat != 120) ||  // Reactor
        (m_Slot == 2 && SubCat != 121) ||  // Engine
        (m_Slot >= 3 && m_Slot <= 8 && SubCat != 100 && SubCat != 101 && SubCat != 102 && SubCat != 103) || //Weapon/Ammo
        (m_Slot >= 9 && m_Slot <= 15 && SubCat != 110))  //Device
    {
		m_Player->SendPriorityMessageString("Item does not fit here","MessageLine",2000,4);
        //printf("CanEquip - Wrong item for slot\n");
		return false;
    }


    AuxSkill * Skills = &m_Player->PlayerIndex()->RPGInfo.Skills.Skill[0];

    /* Now check skill requirements */
    if ((SubCat == 100 && Skills[SKILL_BEAM_WEAPON].GetLevel() < myItemBase->TechLevel()) ||
        (SubCat == 101 && Skills[SKILL_PROJECTILE_WEAPON].GetLevel() < myItemBase->TechLevel()) ||
        (SubCat == 102 && Skills[SKILL_MISSILE_WEAPON].GetLevel() < myItemBase->TechLevel()) ||
        (SubCat == 110 && Skills[SKILL_DEVICE_TECH].GetLevel() < myItemBase->TechLevel()) ||
        (SubCat == 120 && Skills[SKILL_REACTOR_TECH].GetLevel() < myItemBase->TechLevel()) ||
        (SubCat == 121 && Skills[SKILL_ENGINE_TECH].GetLevel() < myItemBase->TechLevel()) ||
        (SubCat == 122 && Skills[SKILL_SHIELD_TECH].GetLevel() < myItemBase->TechLevel()))
    {
		m_Player->SendPriorityMessageString("You need more skill to equip this item","MessageLine",2000,4);
        //printf("CanEquip - bad skill\n");
        return false;
    }

    ItemRequirements Req = myItemBase->GetItemRequirements();

    /* Now check for race restrictions */
    if (Req.RaceRestriction & (0x01 << m_Player->Race()))
    {
        //printf("CanEquip - Race restriction\n");
		m_Player->SendPriorityMessageString("Your Race can not equip this item","MessageLine",2000,4);
        return false;
    }

    /* Also check for race lore restrictions */
    if ((m_Player->Race() == 1 && Req.LoreRestriction == 0x02) ||
        (m_Player->Race() == 2 && Req.LoreRestriction == 0x01))
    {
        //printf("CanEquip - Lore restriction\n");
		m_Player->SendPriorityMessageString("Your Lore can not equip this item","MessageLine",2000,4);
        return false;
    }

    /* Now check for profession restrictions */
    if (Req.ProfessionRestriction & (0x01 << m_Player->Profession()))
    {
		m_Player->SendPriorityMessageString("Your profession can not equip this item","MessageLine",2000,4);
        //printf("CanEquip - Profession restriction\n");
        return false;
    }

    /* Now check for level requirements */
    if ((Req.CombatRequirement > m_Player->CombatLevel()) ||
        (Req.ExploreRequirement > m_Player->ExploreLevel()) ||
        (Req.TradeRequirement > m_Player->TradeLevel()) ||
        (Req.OverallRequirement > m_Player->TotalLevel()))
    {
		m_Player->SendPriorityMessageString("You can not equip this item","MessageLine",2000,4);
        //printf("CanEquip - level restriction\n");
//.........这里部分代码省略.........
开发者ID:RavenB,项目名称:Earth-and-Beyond-server,代码行数:101,代码来源:Equipable.cpp


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