Example #1
0
LOGICAL  checkWearable(P_CHAR pc, P_ITEM pi)
{
	NXWSOCKET s = pc->getSocket();
	if (s < 0)
		return false;
	if( (pi->getId()>>8) >= 0x40)  // LB, client crashfix if multi-objects are moved to PD
		return false;
	tile_st tile;

	data::seekTile(pi->getId(), tile);

	if( ( clientDimension[s]==3 ) &&  (tile.quality==0) )
	{
		pc->sysmsg(TRANSLATE("You can't wear that"));
		return false;
	}
	else 
	{
		P_ITEM outmost = pi->getOutMostCont();
		P_CHAR vendor = pointers::findCharBySerial( outmost->getContSerial() );
		if( ISVALIDPC( vendor ) && ( vendor->getOwnerSerial32() != pc->getSerial32() ) )
		{
			return false;
		}

	}
	if ( !pc->IsGM() && pi->st > pc->getStrength() && !pi->isNewbie() ) // now you can equip anything if it's newbie
	{
		pc->sysmsg(TRANSLATE("You are not strong enough to use that."));
		return false;
	}
	else if ( !pc->IsGM() && !checkItemUsability(pc, pi, ITEM_USE_WEAR) )
	{
		return false;
	}
	else if ( (pc->getId() == BODY_MALE) && ( pi->getId()==0x1c00 || pi->getId()==0x1c02 || pi->getId()==0x1c04 || pi->getId()==0x1c06 || pi->getId()==0x1c08 || pi->getId()==0x1c0a || pi->getId()==0x1c0c ) ) // Ripper...so males cant wear female armor
	{
		pc->sysmsg(TRANSLATE("You cant wear female armor!"));
		return false;
	}
	else if ((((pi->magic==2)||((tile.weight==255)&&(pi->magic!=1))) && !pc->canAllMove()) ||
			( (pi->magic==3|| pi->magic==4) && !(pi->getOwnerSerial32()==pc->getSerial32())))
	{
		return false;
	}
	return true;
}
Example #2
0
/*!
\brief wrap for check usability
\author Xanathar
\return bool
\param pc player trying using
\param pi pointer to item to be used
\param type type of usability
\remarks Luxor - Added REQSKILL command support, three bug fix applied 
*/
bool checkItemUsability(P_CHAR pc, P_ITEM pi, int type)
{
	g_nType = type;
	VALIDATEPIR(pi, false);
	VALIDATEPCR(pc, false);

	NXWSOCKET s = pc->getSocket();

	if( !pi->isNewbie() && ! pc->IsGM())
	{
		if ( pi->st > pc->getStrength() ) 
		{
			pc->sysmsg(TRANSLATE("You are not strong enough to use that."));
			return false;
		}
		if ( pi->dx > pc->dx )
		{
			pc->sysmsg(TRANSLATE("You are not quick enough to use that."));
			return false;
		}
		if ( pi->in > pc->in )
		{
			pc->sysmsg(TRANSLATE("You are not intelligent enough to use that."));
			return false;
		}
		//Luxor: REQSKILL command support
		if (pi->reqskill[0] > 0 && pi->reqskill[1] > 0 )
		{
			if (pi->reqskill[1] > pc->skill[pi->reqskill[0]]) {
				pc->sysmsg(TRANSLATE("You are not skilled enough to use that."));
				return false;
			}
		}
		if ( (pi->getGender() != INVALID && pi->getGender() != GENDER_NEUTRAL ) && pi->getGender() != pc->getGender() )
		{
			if ( pi->getGender() == 1 ) // it's a man item
				pc->sysmsg(TRANSLATE("Only males of your species may use that !"));
			else if ( pi->getGender() == 2 ) // it's a man item
				pc->sysmsg(TRANSLATE("Only females of your species may use that !"));
			else
				pc->sysmsg(TRANSLATE("You may not use that !")); // Damn, whats the political correct term for "Get some recreational extensions to your body"
			return false;
		}
		if ( Race::isRaceSystemActive() )
			if ( pi->getRace() != INVALID && pi->getRace() != pc->getRace() )
			{
				pc->sysmsg(TRANSLATE("Your race may not use this item!")); // Hope no one sues me because of racial discrimination in item use
				return false;
			}


	}

	if (s >-1 && s < now) //Luxor
	{
		
		if (pi->amxevents[EVENT_IONCHECKCANUSE]==NULL) return true;
		return (0!=pi->amxevents[EVENT_IONCHECKCANUSE]->Call(pi->getSerial32(), pc->getSerial32(), g_nType));
		/*
		AmxEvent* event = pi->getAmxEvent( EVENT_IONCHECKCANUSE );
		if ( !event ) return true;
		return ( 0 != event->Call(pi->getSerial32(), s, g_nType ) );
		*/
	}
	return true;
}