コード例 #1
0
/*!
\brief Snoop into container
\author Unknow, completly rewritten by Endymion
\param snooper the snooper
\param cont the contanier
*/
void snooping( P_CHAR snooper, P_ITEM cont )
{
	VALIDATEPC(snooper);
	NXWCLIENT ps = snooper->getClient();
	if( ps == NULL ) return;
	NXWSOCKET s = ps->toInt();
	VALIDATEPI(cont);
	P_CHAR owner = cont->getPackOwner();
	VALIDATEPC(owner);
	char temp[TEMP_STR_SIZE];

	if (snooper->getSerial32() == owner->getSerial32())
		snooper->showContainer(cont);
	else if (snooper->IsGMorCounselor())
		snooper->showContainer(cont);
	else
	if ((char_inRange(snooper, owner, 2)) ||(item_inRange(snooper, cont, 2)))
	{
		if ( owner->HasHumanBody() && ( owner->getOwnerSerial32()==snooper->getSerial32()))
			snooper->showContainer(cont);
		else if ( owner->npcaitype == NPCAI_PLAYERVENDOR)
				snooper->showContainer(cont);
		else
		{
			if ((cont->getContSerial()>1) && (cont->getContSerial() != snooper->getSerial32()) )
			{
				
				if ( owner->amxevents[EVENT_CHR_ONSNOOPED])
				{
					g_bByPass = false;
					owner->amxevents[EVENT_CHR_ONSNOOPED]->Call( owner->getSerial32(), snooper->getSerial32());
					if (g_bByPass==true) return;
				}
				/*
				owner->runAmxEvent( EVENT_CHR_ONSNOOPED, owner->getSerial32(), s);
				if (g_bByPass==true)
					return;
				*/
				snooper->objectdelay=SrvParms->snoopdelay * MY_CLOCKS_PER_SEC + uiCurrentTime;
				if ( owner->IsGMorCounselor())
				{
					snooper->sysmsg( TRANSLATE("You can't peek into that container or you'll be jailed."));// AntiChrist
					sprintf( temp, TRANSLATE("%s is trying to snoop you!"), snooper->getCurrentNameC());
					owner->sysmsg(temp);
					return;
				}
				else if (snooper->checkSkill( SNOOPING, 0, 1000))
				{
					snooper->showContainer(cont);
					snooper->sysmsg( TRANSLATE("You successfully peek into that container."));
				}
				else
				{
					snooper->sysmsg( TRANSLATE("You failed to peek into that container."));
					if ( owner->npc )
						owner->talk(s, TRANSLATE("Art thou attempting to disturb my privacy?"), 0);
					else {
						sprintf( temp, TRANSLATE("You notice %s trying to peek into your pack!"), snooper->getCurrentNameC());
						owner->sysmsg( temp );
					}
					snooper->IncreaseKarma(-ServerScp::g_nSnoopKarmaLoss);//AntiChrist
					snooper->modifyFame(-ServerScp::g_nSnoopFameLoss);//AntiChrist
					setCrimGrey(snooper, ServerScp::g_nSnoopWillCriminal);
				}
			}
		}
	}
	else {
		snooper->sysmsg(TRANSLATE("You are too far away!"));
	}
}
コード例 #2
0
void cMakeMenu::loadFromScript( P_CHAR pc )
{
	VALIDATEPC(pc);

	NXWCLIENT ps = pc->getClient();
	if( ps==NULL ) return;

    cScpIterator* iter = Scripts::Create->getNewIterator("SECTION MAKEMENU %i", section);
    if (iter==NULL) return;

	std::vector<std::string> names; //name
	std::vector<std::string> models; //models
    
	this->mat[0].number = ( mat[0].id!=0 )? pc->CountItems( mat[0].id, mat[0].color ) : 0;
	this->mat[1].number = ( mat[1].id!=0 )? pc->CountItems( mat[1].id, mat[1].color ) : 0;

	//da passare a checkReq PDPD
	

	cMakeItem* imk = NULL;
    pc->making=skill;

	oldmenu->style=MENUTYPE_ICONLIST;

/* makemenu menu
SECTION MAKEMENU 1
{
    Blacksmithing
    1416 Armor
    RESOURCE 10
    SKILL 500
    MAKEMENU 3
    13BA Weapons
    RESOURCE 3
    SKILL 100
    MAKEMENU 4
    1BC3 Shields
    RESOURCE 8
    SKILL 250
    MAKEMENU 2
    09ed Misc
    RESOURCE 6
    SKILL 150
    MAKEMENU 105
}
*/
/* makemenu item
SECTION MAKEMENU 2002
{
    Golden Ring Mail
    13F2 Gloves
    RESOURCE 10
    SKILL 338
    ADDITEM $item_golden_ringmail_gloves
    13EF Sleeves
    RESOURCE 14
    SKILL 385
    ADDITEM $item_golden_ringmail_sleeves
    13F1 Leggings
    RESOURCE 16
    SKILL 408
    ADDITEM $item_golden_ringmail_leggings
    13ED Tunic
    RESOURCE 18
    SKILL 432
    ADDITEM $item_golden_ringmail_tunic
}
*/

enum MakeParamType {
MAKE_NEED_NAME = 0, //Blacksmithing
MAKE_NEED_INFO, //1416 Armor
MAKE_NEED_RESOURCE, //RESOURCE 10
MAKE_NEED_SKILL, //SKILL 500
MAKE_NEED_MENUORITEM, //MAKEMENU 3  or ADDITEM $item_golden_ringmail_tunic
};

	MakeParamType type = MAKE_NEED_NAME;
	bool error=false;
	bool canSee = true;
	int item = INVALID;

    int loopexit=0;
    do
    {
		std::string lha;
		std::string rha;
        
	    iter->parseLine(lha, rha);

		if( lha[0]=='{' )
			continue;

		if( lha[0]=='}' )
			break;

		switch( type ) {

			case MAKE_NEED_NAME: //Blacksmithing
				string2wstring( lha, oldmenu->title );
				type = MAKE_NEED_INFO;
				break;

			case MAKE_NEED_INFO: { //1416 Armor
				item++;
				names.push_back( rha );
				models.push_back( lha );
				type = MAKE_NEED_RESOURCE;
				break;
			}
			case MAKE_NEED_RESOURCE: //RESOURCE 10
		        if( lha!="RESOURCE" ) {
					if ( item > INVALID ) //Luxor
						LogWarning("create.xss, MAKEMENU %i: Expected 'RESOURCE <num>' after '%s'!", section, names[item].c_str() );
					error=true;
				}
				else {
					int needs = str2num(rha);

					imk = new cMakeItem();
					
					imk->skillToCheck=this->skill;
					imk->reqitems[0].id=mat[0].id;
					imk->reqitems[0].color=mat[0].color;
					imk->reqitems[0].number=needs;
					imk->reqitems[1].id=mat[1].id;
					imk->reqitems[1].color=mat[1].color;
					imk->reqitems[1].number=needs;

					type=MAKE_NEED_SKILL;
				}
				break;
			case MAKE_NEED_SKILL:  //SKILL 500
				if( lha!="SKILL" )
				{
					LogWarning("create.xss, MAKEMENU %i: Expected 'SKILL <num>' after RESOURCE !", section );
					error=true;
		        }
				else {

					imk->minskill=str2num(rha);
				    imk->maxskill=imk->minskill*SrvParms->skilllevel; // by Magius(CHE)
					if( imk->maxskill<200 )
						imk->maxskill=200;

					if( !imk->checkReq( pc, true, &this->mat[0] ) )
					{
						safedelete( imk );
						item--;
						names.pop_back();
						models.pop_back();
						canSee = false;
					}
					else {
						makeItems.push_back( imk );
						
						std::wstring w;
						char b[TEMP_STR_SIZE];
						if( mat[0].id!=0 ) {
							sprintf( b, "%s %s - [%d/%d.%d]", models[item].c_str(), names[item].c_str(), imk->reqitems[0].number, imk->minskill/10, imk->minskill%10 );
						}
						else {
							sprintf( b, "%s %s", models[item].c_str(), names[item].c_str() );
						}
						string2wstring( std::string( b ), w );
						oldmenu->addMenuItem( 0, item, w );
						type=MAKE_NEED_MENUORITEM;
						canSee = true;
					}
					type=MAKE_NEED_MENUORITEM;
				}
				break;
			case MAKE_NEED_MENUORITEM: //MAKEMENU 3  or ADDITEM $item_golden_ringmail_tunic
				if( ( lha=="MAKEMENU" ) || ( lha=="ADDITEM" ) ) {
					if( canSee )
						imk->command = new cScriptCommand( lha, rha );
					type = MAKE_NEED_INFO;
				}
				else {
					LogWarning("create.xss, MAKEMENU %i: Expected'MAKEMENU or ADDITEM after 'SKILL %i'!", section, imk->minskill );
					error=true;
				}
				break;
		}
	}
	while( !error  && (++loopexit < MAXLOOPS) );


    if( item<=0 ) {
        ps->sysmsg( TRANSLATE("You aren't skilled enough to make anything with what you have.") );
    }

	safedelete(iter);
	if( error ) {
		ConOut( "[ERROR] on cration of makemenu %d\n", section );
        return;
	}

}
コード例 #3
0
void newbieitems(P_CHAR pc)
{

	VALIDATEPC(pc);
	
	NXWCLIENT ps=pc->getClient();
	if(ps==NULL)
		return;

	int first, second, third, storeval, itemaddperskill, loopexit = 0;
	char sect[512];
	char whichsect[105];
	cScpIterator* iter = NULL;

	first = bestskill(pc);
	second = nextbestskill(pc, first);
	third = nextbestskill(pc, second);
	if (pc->baseskill[third] < 190)
		third = 46;

	for (itemaddperskill = 1; itemaddperskill <= 5; itemaddperskill++)
	{
		switch (itemaddperskill)
		{
			// first of all the general section with the backpack, else where we put items?
			case 1: strcpy(whichsect, "SECTION ALLNEWBIES");		break;
			case 2:
				if ( (pc->getId() == BODY_MALE) && (pc->getOldId() == BODY_MALE) )
					strcpy(whichsect, "SECTION MALENEWBIES");
				else
					strcpy(whichsect, "SECTION FEMALENEWBIES");
				break;
			case 3: sprintf(whichsect, "SECTION BESTSKILL %i", first);	break;
			case 4: sprintf(whichsect, "SECTION BESTSKILL %i", second);	break;
			case 5: sprintf(whichsect, "SECTION BESTSKILL %i", third);	break;
			default:
				ErrOut("Switch fallout. newbie.cpp, newbieitems()/n"); // Morrolan
		}

		sprintf(sect, whichsect);
		char script1[1000], script2[1000];
		safedelete(iter);
		iter = Scripts::Newbie->getNewIterator(sect);
		if (iter==NULL) return;

		do
		{
			iter->parseLine(script1,script2);

			if (script1[0] == '@') pc->loadEventFromScript(script1, script2); 	// Sparhawk: Huh loading character events 
												// from newbie item scripts????

			if (script1[0] != '}')
			{
				if (!(strcmp("PACKITEM", script1)))
				{
					std::string itemnum, amount;
					splitLine( script2, itemnum, amount );
					int amt = ( amount != "" )? str2num( amount ) : INVALID; //ndEndy defined amount
					P_ITEM pi_n = item::CreateFromScript( str2num( itemnum ), pc->getBackpack(), amt );
					if (ISVALIDPI(pi_n)) {
						pi_n->priv |= 0x02; // Mark as a newbie item
					}
					strcpy(script1, "DUMMY");
				}
				else if (!strcmp("BANKITEM", script1))
				{
					std::string itemnum, amount;
					splitLine( script2, itemnum, amount );
					int amt= (amount!="")? str2num( amount ) : INVALID;
					P_ITEM pi = item::CreateFromScript( str2num( itemnum ), pc->GetBankBox(), amt );
					if (ISVALIDPI(pi)) {
						pi->priv |= 0x02; // Mark as a newbie item
					}
					strcpy(script1, "DUMMY");
				}
				else if (!strcmp("EQUIPITEM", script1))
				{
					P_ITEM pi = item::CreateFromScript( script2 );
					if (ISVALIDPI(pi))
					{
						pi->priv |= 0x02; // Mark as a newbie item
						pi->setCont(pc);
						storeval = pi->getScriptID();
					}
					strcpy(script1, "DUMMY");
				}
			}
		}
		while ((script1[0] != '}') &&(++loopexit < MAXLOOPS));
	
		safedelete(iter);
	}
	
	// Give the character some gold
	if ( goldamount > 0 )
	{
		item::CreateFromScript( "$item_gold_coin", pc->getBackpack(), goldamount );
	}


}
コード例 #4
0
/*!
\brief Send packet to player
\author Endymion
\since 0.83a
\param pc the player who send to
*/
void cServerPacket::send( P_CHAR pc ) {
	VALIDATEPC( pc )
	send( pc->getClient() );
};