Beispiel #1
0
BOOL AbilityMachining::IsGemConflict(Obj_Human* pHuman, BYTE GemIndex, BYTE EquipIndex)
{
__ENTER_FUNCTION

	Assert( pHuman );

	//const	_ITEM* pGem = pHuman->GetItem(GemIndex);
	//const	_ITEM* pEquip = pHuman->GetItem(EquipIndex);

	Item*	pGemItem	 = HumanItemLogic::GetBagItem(pHuman,GemIndex);
	Item*	pEquipItem	 = HumanItemLogic::GetBagItem(pHuman,EquipIndex);

	UINT uGemSerialNumber = pGemItem->GetItemTableIndex();

	LuaInterface* pLuaInterface;
	pLuaInterface = pHuman->getScene()->GetLuaInterface();
	_ITEM tmpGem;
	for( INT i=0; i<pEquipItem->GetGemSlotMax(); ++i )
	{
		UINT idx;

		idx = pEquipItem->GetEquipGemInfo(i).m_GemIndex;
		if( idx < 1 )
			continue;

		if( pLuaInterface->ExeScript_DDD(	ABILITY_LOGIC_SCRIPT, 
											"IsGemConflict",
											(INT)pHuman->getScene()->SceneID(), 
											(INT)uGemSerialNumber, 
											(INT)idx )
			)
		{
			return FALSE;
		}
	}

	return TRUE;

__LEAVE_FUNCTION

	return FALSE;
}
Beispiel #2
0
ORESULT AbilityMachining::CanUseAbility(Obj_Human* pHuman)
{
__ENTER_FUNCTION

	Assert( pHuman );

	AbilityOpera* pAbilityOpera;

	pAbilityOpera = pHuman->GetAbilityOpera();
	Assert( pAbilityOpera );

	switch( pAbilityOpera->m_SubType )
	{
	case NORMAL_TYPE:
		return AbilityCompound::CanUseAbility(pHuman);
	case GEM_COMPOUND:
		{
			ORESULT res;
			res = Ability::CanUseAbility(pHuman);
			if( res != OR_OK )
			{
				return res;
			}

			if( (pAbilityOpera->m_BagPos[0] < 0) || (pAbilityOpera->m_BagPos[0] >= MAX_BAG_SIZE)
			 || (pAbilityOpera->m_BagPos[1] < 0) || (pAbilityOpera->m_BagPos[1] >= MAX_BAG_SIZE)
			 )
			{
				Assert(FALSE);
				return OR_ERROR;
			}

			//const	_ITEM* pGem1 = pHuman->GetItem(pAbilityOpera->m_BagPos[0]);
			//const	_ITEM* pGem2 = pHuman->GetItem(pAbilityOpera->m_BagPos[1]);
			
			Item*	pGem1Item = HumanItemLogic::GetBagItem(pHuman,pAbilityOpera->m_BagPos[0]);
			Item*	pGem2Item = HumanItemLogic::GetBagItem(pHuman,pAbilityOpera->m_BagPos[1]);

			Assert( (pGem1Item != NULL) && (pGem2Item != NULL) );

			if( (pGem1Item->GetItemClass() != ICLASS_GEM) || (pGem2Item->GetItemClass() != ICLASS_GEM) )
			{
				return OR_STUFF_LACK;
			}

			if((pGem1Item->GetItemIndex() != pGem2Item->GetItemIndex())// (pGem1Item->GetItemQual() != pGem2Item->GetItemQual())
			 )
			{
				return OR_STUFF_LACK;
			}

			//if(  >= MAX_GEM_QUALITY ) // pGem1Item->GetItemQual()没法再升了
			//{
			//	return OR_CANNOT_UPGRADE;
			//}

			return OR_OK;
		}
		break;
	case GEM_EMBED:
		{
			ORESULT res;
			res = Ability::CanUseAbility(pHuman);
			if( res != OR_OK )
			{
				return res;
			}

			if( (pAbilityOpera->m_BagPos[0] < 0) || (pAbilityOpera->m_BagPos[0] >= MAX_BAG_SIZE)
			 || (pAbilityOpera->m_BagPos[1] < 0) || (pAbilityOpera->m_BagPos[1] >= MAX_BAG_SIZE)
			 )
			{
				Assert(FALSE);
				return OR_ERROR;
			}

			//const	_ITEM* pGem = pHuman->GetItem(pAbilityOpera->m_BagPos[0]);
			//const	_ITEM* pEquip = pHuman->GetItem(pAbilityOpera->m_BagPos[1]);

			Item*		pGemItem	=	HumanItemLogic::GetBagItem(pHuman,pAbilityOpera->m_BagPos[0]);
			Item*		pEquipItem	=	HumanItemLogic::GetBagItem(pHuman,pAbilityOpera->m_BagPos[1]);
			Assert( (pGemItem != NULL) && (pEquipItem != NULL) );

			if( (pGemItem->GetItemClass() != ICLASS_GEM) || (pEquipItem->GetItemClass() != ICLASS_EQUIP) )
			{
				return OR_STUFF_LACK;
			}

			if( IsGemConflict(pHuman, pAbilityOpera->m_BagPos[0], pAbilityOpera->m_BagPos[1]) == FALSE )
			{
				return OR_GEM_CONFLICT;
			}

			LuaInterface* pLuaInterface;
			pLuaInterface = pHuman->getScene()->GetLuaInterface();

			if( pEquipItem->GetGemSlotMax() <= pEquipItem->GetEquipGemCount()
				|| pLuaInterface->ExeScript_DDD(	ABILITY_LOGIC_SCRIPT, 
													"TooManyGems",
													(INT)pHuman->getScene()->SceneID(),
													(INT)pHuman->GetID(),
													(INT)pAbilityOpera->m_BagPos[1] )
			 )
			{
				return OR_GEM_SLOT_LACK;
			}

			return OR_OK;
		}
		break;
	default:
		Assert(FALSE);
		return OR_ERROR;
	}

	return OR_WARNING;

__LEAVE_FUNCTION

	return OR_ERROR;
}
Beispiel #3
0
ORESULT AbilityInlay::CanUseAbility(Obj_Human* pHuman)
{
__ENTER_FUNCTION

	Assert( pHuman );

	AbilityOpera* pAbilityOpera;

	pAbilityOpera = pHuman->GetAbilityOpera();
	Assert( pAbilityOpera );

	ORESULT res;
	res = Ability::CanUseAbility(pHuman);
	if( res != OR_OK )
	{
		return res;
	}

	CHAR MaterialBagIndex1 = (CHAR)pAbilityOpera->m_BagPos[2];
	CHAR MaterialBagIndex2 = (CHAR)pAbilityOpera->m_BagPos[3];
	if( (pAbilityOpera->m_BagPos[0] < 0)  || (pAbilityOpera->m_BagPos[0] >= MAX_BAG_SIZE)
	 || (pAbilityOpera->m_BagPos[1] < 0)  || (pAbilityOpera->m_BagPos[1] >= MAX_BAG_SIZE)
	 || (MaterialBagIndex1>= MAX_BAG_SIZE)|| (MaterialBagIndex2>= MAX_BAG_SIZE)
	 )
	{
		Assert(FALSE);
		return OR_ERROR;
	}

	Item* pGemItem = HumanItemLogic::GetBagItem( pHuman, pAbilityOpera->m_BagPos[0] );
	Item* pEquipItem = HumanItemLogic::GetBagItem( pHuman, pAbilityOpera->m_BagPos[1] );
	Item* pMaterialItem1 = NULL;
	Item* pMaterialItem2 = NULL;
	if( MaterialBagIndex1 != -1 )
	{
		pMaterialItem1 = HumanItemLogic::GetBagItem( pHuman, pAbilityOpera->m_BagPos[2] );
		Assert( pMaterialItem1 != NULL );
	}
	if( MaterialBagIndex2 != -1 )
	{
		pMaterialItem2 = HumanItemLogic::GetBagItem( pHuman, pAbilityOpera->m_BagPos[3] );
		Assert( pMaterialItem2 != NULL );
	}
	Assert( (pGemItem != NULL) && (pEquipItem != NULL) );

	if( (pGemItem->IsLock())
	 || (pEquipItem->IsLock())
	 || (pGemItem->IsPWLock())
	 || (pEquipItem->IsPWLock())
	 || (pGemItem->GetItemClass() != ICLASS_GEM)
	 || (pEquipItem->GetItemClass() != ICLASS_EQUIP)
	 )
	{
		return OR_STUFF_LACK;
	}

	//if( pHuman->__GetAbilityLevel(pAbilityOpera->m_AbilityID) < pGemItem->GetItemQual() )
	//{
	//	return OR_NO_LEVEL;
	//}

	if( IsGemConflict(pHuman, pAbilityOpera->m_BagPos[0], pAbilityOpera->m_BagPos[1]) == FALSE )
	{
		return OR_GEM_CONFLICT;
	}

	LuaInterface* pLuaInterface;
	pLuaInterface = pHuman->getScene()->GetLuaInterface();

	if( pEquipItem->GetGemSlotMax() <= pEquipItem->GetEquipGemCount()
	 || pLuaInterface->ExeScript_DDD(	ABILITY_LOGIC_SCRIPT, DEF_GEM_COUNT_CHECK,
										(INT)pHuman->getScene()->SceneID(),
										(INT)pHuman->GetID(),
										(INT)pAbilityOpera->m_BagPos[1] )
	 )
	{
		return OR_GEM_SLOT_LACK;
	}

	if( pLuaInterface->ExeScript_DDDD(	ABILITY_LOGIC_SCRIPT, DEF_IS_GEM_FIT_EQUIP,
										(INT)pHuman->getScene()->SceneID(),
										(INT)pHuman->GetID(),
										pGemItem->GetItemTableIndex(),
										pAbilityOpera->m_BagPos[1] ) == 0
	 )
	{ // 判断宝石和装备是否匹配
		return OR_GEM_NOT_FIT_EQUIP;
	}

	return OR_OK;

__LEAVE_FUNCTION

	return OR_ERROR;
}