Exemplo n.º 1
0
void Skills::target_mine( NXWCLIENT ps, P_TARGET t )
{

	P_CHAR pc = ps->currChar();
	VALIDATEPC( pc );

	NXWSOCKET s = ps->toInt();
	
	P_ITEM weapon = pc->GetItemOnLayer(1);
	
	if( !canMine( pc, weapon ) )
		return;

	Location target = t->getLocation();

	pc->facexy( target.x, target.y );

	AMXEXECSVTARGET( pc->getSerial32(),AMXT_SKITARGS,MINING,AMX_BEFORE);
	
	if ( pc->hidden )
		pc->unHide();

	LOGICAL floor = false;
	LOGICAL mountain= false;

	map_st map;
	land_st land;

	pc->stm+=ores.stamina;
	if(pc->stm<0) 
		pc->stm=0;
	if(pc->stm>pc->dx) 
		pc->stm=pc->dx;
	pc->updateStats(2);

	

	int cx = abs( (int) (pc->getPosition().x - target.x) );
	int cy = abs( (int) (pc->getPosition().y - target.y) );

	if( (cx>5) || (cy>5) )
	{
		pc->sysmsg(TRANSLATE("You are to far away to reach that"));
		return;
	}

	UI32 id = t->getModel();

	if( SrvParms->minecheck > 0 && !id )
	{
		// mountains are "map0's" and no statics !!!

		data::seekMap( target.x, target.y, map );
		data::seekLand( map.id, land );

		if ( !strcmp(land.name,"rock") || !(strcmp(land.name, "mountain")) || !(strcmp(land.name, "cave")))
			mountain = true;
	}

	data::seekMap( target.x, target.y, map );
	if( !id )
		id= map.id;

	switch( id )
	{
		case 0x0ED3:
		case 0x0EDF:
		case 0x0EE0:
		case 0x0EE1:
		case 0x0EE2:
		case 0x0EE8:
			Skills::GraveDig( s );
			return;
		default:
			break;
	}

	//
	// Caves (Walls & Floors)
	//
	if( (id >= 0x025C && id <= 0x0276) ||
		(id >= 0x027D && id <= 0x0280) ||
		(id >= 0x053B && id <= 0x0553) ||
		(id == 0x056A))
		floor = true;

	// sand (Anthalir)
	if( (id>=0x0017) && (id<=0x0019) )
		floor = true;


	// check if cave floor ENDYMION USE THIS BUT SEE VALUES IN OLD CODE
	/*if ( 
		( (targetData.getModel( s )>>8)==0x05 && ( ((targetData.getModel( s )%256)>=0x3b && (targetData.getModel( s )%256)<=0x4f ) || ((targetData.getModel( s )%256)>=0x51 && (targetData.getModel( s )%256)<=0x53) || (targetData.getModel( s )%256)==0x6a ))&&
		(!( ((targetData.getModel( s )>>8)==0x02)&&
        ( ( ((targetData.getModel( s )%256)>=0x5c) && ((targetData.getModel( s )%256)<=0x76))||(((targetData.getModel( s )%256)>=0x7d)&&((targetData.getModel( s )%256)<=0x80))))))
		
		 floor=1;*/
	

	if ((SrvParms->minecheck!=0)&&(!floor)&&(!mountain))//Mine only mountains & floors
	{
		pc->sysmsg(TRANSLATE("You can't mine that!"));
		return;
	}
/*
	P_RESOURCE res = ores.getResource( target );

	ores.checkResource( target, res );

	if( !ores.thereAreSomething( res ) )
	{
		pc->sysmsg(TRANSLATE("There is no metal here to mine."));
		return;
	}

	if (pc->isMounting())
		pc->playAction(0x1A);
	else
		pc->playAction(0x0B);

	pc->playSFX(0x0125);

	if(!pc->checkSkill(MINING, 0, 1000))
	{
		pc->sysmsg(TRANSLATE("You sifted thru the dirt and rocks, but found nothing useable."));
		if( rand()%2==1)
			return; //Randomly deplete resources even when they fail 1/2 chance you'll loose ore.
	}
	ores.decreaseResource( target, res );
*/
	AmxFunction::g_prgOverride->CallFn( g_Scripts[AMXT_SKILLS][MINING].getOrdinal(), pc->getSerial32(), target.x, target.y, id);
	// AMXEXECSVTARGET(pc->getSerial32(),AMXT_SKITARGS,MINING,AMX_AFTER);
}
void Skills::target_mine( pClient client, pTarget t )
{
	pChar pc = client->currChar();
	if ( ! pc ) return;

	pItem weapon = pc->GetItemOnLayer(1);
	
	if( !canMine( client, weapon ) )
		return;

	sLocation target = t->getPosition();

	pc->facexy( target.x, target.y );

	AMXEXECSVTARGET( pc->getSerial(),AMXT_SKITARGS,skMining,AMX_BEFORE);

	if ( pc->hidden )
		pc->unHide();

	bool floor = false;
	bool mountain= false;

	map_st map;

	pc->stm+=ores.stamina;
	if(pc->stm<0) 
		pc->stm=0;
	if(pc->stm>pc->dx) 
		pc->stm=pc->dx;
	pc->updateStamina();

	
	int cx = abs( (int) (pc->getPosition().x - target.x) );
	int cy = abs( (int) (pc->getPosition().y - target.y) );

	if( (cx>5) || (cy>5) )
	{
		client->sysmessage("You are to far away to reach that");
		return;
	}

	uint32_t id = t->getModel();

	if( SrvParms->minecheck > 0 && !id )
	{
		// mountains are "map0's" and no statics !!!
		data::seekMap( target.x, target.y, map );

		string name = tiledataLand->getName(map.id);
		if ( !strcmp(name.c_str(),"rock") || !(strcmp(name.c_str(), "mountain")) || !(strcmp(name.c_str(), "cave")))
			mountain = true;
	}

	data::seekMap( target.x, target.y, map );
	if( !id )
		id= map.id;

	switch( id )
	{
		case 0x0ED3:
		case 0x0EDF:
		case 0x0EE0:
		case 0x0EE1:
		case 0x0EE2:
		case 0x0EE8:
			Skills::GraveDig(client);
			return;
		default:
			break;
	}

	//
	// Caves (Walls & Floors)
	//
	if( (id >= 0x025C && id <= 0x0276) ||
		(id >= 0x027D && id <= 0x0280) ||
		(id >= 0x053B && id <= 0x0553) ||
		(id == 0x056A))
		floor = true;

	// sand (Anthalir)
	if( (id>=0x0017) && (id<=0x0019) )
		floor = true;


	// check if cave floor ENDYMION USE THIS BUT SEE VALUES IN OLD CODE
	/*if ( 
		( (targetData.getModel( s )>>8)==0x05 && ( ((targetData.getModel( s )%256)>=0x3b && (targetData.getModel( s )%256)<=0x4f ) || ((targetData.getModel( s )%256)>=0x51 && (targetData.getModel( s )%256)<=0x53) || (targetData.getModel( s )%256)==0x6a ))&&
		(!( ((targetData.getModel( s )>>8)==0x02)&&
        ( ( ((targetData.getModel( s )%256)>=0x5c) && ((targetData.getModel( s )%256)<=0x76))||(((targetData.getModel( s )%256)>=0x7d)&&((targetData.getModel( s )%256)<=0x80))))))
		
		 floor=1;*/
	

	if ((SrvParms->minecheck!=0)&&(!floor)&&(!mountain))//Mine only mountains & floors
	{
		client->sysmessage("You can't mine that!");
		return;
	}

	pResource res = ores.getResource( target );

	ores.checkResource( target, res );

	if( !ores.thereAreSomething( res ) )
	{
		client->sysmessage("There is no metal here to mine.");
		return;
	}

	if (pc->getBody()->isMounted())
		pc->playAction(0x1A);
	else
		pc->playAction(0x0B);

	pc->playSFX(0x0125);

	if(!pc->checkSkill(skMining, 0, 1000))
	{
		clien->sysmessage("You sifted thru the dirt and rocks, but found nothing useable.");
		if( rand()%2==1)
			return; //Randomly deplete resources even when they fail 1/2 chance you'll loose ore.
	}
	ores.decreaseResource( target, res );

	AmxFunction::g_prgOverride->CallFn( AmxFunction::g_prgOverride->getFnOrdinal(AMXskMining), s);
	AMXEXECSVTARGET(pc->getSerial(),AMXT_SKITARGS,skMining,AMX_AFTER);
}