Beispiel #1
0
void *key_thread( void *arg ) {
	struct termios t;

	tcgetattr(STDIN_FILENO, &t); //get the current terminal I/O structure
	t.c_lflag &= ~ICANON; //Manipulate the flag bits to do what you want it to do
	tcsetattr(STDIN_FILENO, TCSANOW, &t); //Apply the new settings

	char key = ' ';
	while( !exit_bot ) {
		key = getchar();
		switch( key ) {
			case 49: // '1'
				finished_quest = true;
				missing_quest  = true;
				printf( "[%s] Restarting loop as requested\n", currentDateTime().c_str());
				break;
			case 50: // '2'
				printf( "[%s] X/Y: %i,%i - HP: %i - Current Quest: %i - Kills/Req: %i of %i\n", currentDateTime().c_str(), player_x, player_y, player_health, lastQL.curquest, lastQL.curkills, lastQL.reqkills );
				break;
			case 51: // '3'
				requestLog( player_id );
				break;
			case 52: // '4'
				printf( "[%s] Dumping Unit Map to File\n", currentDateTime().c_str());
				dumpUnitMap();
				break;
			case 53: // '5'
				printf( "[%s] Sending logout\n", currentDateTime().c_str());
				finished_quest = true;
				missing_quest  = true;
				logout( player_id );
				break;
			case 54: // '6'
				ping_success = false;
				doLogin();
				break;
			case 55: // '7'
				have_quest = false;
				finished_quest = true;
				missing_quest  = true;
				Say( player_id, (char*)"-quitquest", 10 );
				printf( "[%s] Forcing player to abandon quest and start over\n", currentDateTime().c_str());
				break;
			case 48:
				printf( "[%s] Logging off and exiting\n", currentDateTime().c_str());
				finished_quest = true;
				missing_quest  = true;
				logout( player_id );
				SLEEP( 200 );
				exit_bot = true;
				break;
		}
	}
}
/**
    Method to cancel registration
    @Param - VEN2B Class pointer
    @return - status
 */
bool cancelParty::CancelParty(VEN2b *ven)
{
	ucmlogging log;
	sqliteDB sdb;
	bool regStatus = false;
	try
	{
		//Cancel Request from VEN
		auto_ptr<CancelPartyRegistration> cancelRegistration = ven->cancelPartyRegistration();

		oadrPayload *payload = cancelRegistration->response();
		xmlFileCreation requestLog("cancelPartyRegistration.xml", cancelRegistration->requestBody());

		if (payload == NULL || !payload->oadrSignedObject().oadrCanceledPartyRegistration().present())
		{
			log.logger("Received unexpected payload" , ucmlogging::Error);
			sdb.sqliteDBwriteString("errormsg","Received unexpected Payload from server!!!Failed to cancel registration!!!", hmiven, "hmivenflag");
			xmlFileCreation responseLog("canceledPartyRegistration.xml", cancelRegistration->responseBody());
			return false;
		}

		oadrCanceledPartyRegistrationType *response = &payload->oadrSignedObject().oadrCanceledPartyRegistration().get();

		if (response->eiResponse().responseCode().compare("200") != 0)
		{
			log.logger("Received unexpected response code: " + response->eiResponse().responseCode(), ucmlogging::Error);
			sdb.sqliteDBwriteString("errormsg","Received unexpected Response code  from server: " + response->eiResponse().responseCode() + "Failed to  cancel registration!!!", hmiven, "hmivenflag");
			xmlFileCreation responseLog("canceledPartyRegistration.xml", cancelRegistration->responseBody());
			return false;
		}

		//log file creation.
		xmlFileCreation responseLog("canceledPartyRegistration.xml", cancelRegistration->responseBody());

		log.logger("Cancel Registration Done!!! " ,ucmlogging::Info);
		//Clear Registration
		clearRegistration cr;
		cr.clearregistration();

		regStatus = true;
	}
	catch (CurlException& ex)
	{
		log.logger("caught exception: " + string(ex.what()) + "!!!Failed to cancel registration!!!",ucmlogging::Error);
		sdb.sqliteDBwriteString("errormsg",string(ex.what())+ "!!!Failed to cancel registration!!!", hmiven, "hmivenflag");
	}

	return regStatus;
}
/**
    Method to send createopt schedule payload
     @param pointer to class VEN2b
     @param Start time
     @param Stop time
     @param Reason
     @param Resource
     @Return status
 */
bool OptScheduleCreate::OptSchCreate(VEN2b *venCreateOpt, string startTime, string stopTime, string reason, string resource)
{
	ucmlogging log;
	sqliteDB sdb;
	bool Status = false;
	time_t starttime;
	time_t stoptime;
	stringstream stream;
	int duration;

	//to get marketcontext
	reportRegister rr;

	OptReasonValue reasonVal(reason);
	OptSchedule sched(OptTypeType::optOut, reasonVal, rr.getMarketContext(),resource, "");

	DurationModifier dval("SECONDS");
	stream<<startTime;
	stream>>starttime;
	stream.clear();
	stream<<stopTime;
	stream>>stoptime;
	duration = (stoptime-starttime);

	sched.addAvailable(starttime, duration, dval.SECONDS);
	try
	{
		//OptSchCreate Request from VEN
		auto_ptr<CreateOptSchedule> createopt = venCreateOpt->createOptSchedule(sched);

		oadrPayload *payload = createopt->response();
		xmlFileCreation requestLog("oadrCreateOpt.xml", createopt->requestBody());

		if (payload == NULL || !payload->oadrSignedObject().oadrCreatedOpt().present())
		{
			log.logger("Received unexpected payload" , ucmlogging::Error);
			sdb.sqliteDBwriteString("errormsg","Received unexpected Payload from server!!!Failed to createopt schedule!!!", hmiven, "hmivenflag");
			xmlFileCreation responseLog("oadrCreatedOpt.xml", createopt->responseBody());
			return false;
		}

		oadrCreatedOptType *response = &payload->oadrSignedObject().oadrCreatedOpt().get();

		if (response->eiResponse().responseCode().compare("200") != 0)
		{
			log.logger("Received unexpected response code: " + response->eiResponse().responseCode(), ucmlogging::Error);
			sdb.sqliteDBwriteString("errormsg","Received unexpected Response code  from server: " + response->eiResponse().responseCode() + "Failed to  createopt schedule!!!", hmiven, "hmivenflag");
			xmlFileCreation responseLog("oadrCreatedOpt.xml", createopt->responseBody());
			return false;
		}

		//log file creation.
		xmlFileCreation responseLog("oadrCreatedOpt.xml", createopt->responseBody());
		setOptIdVal(response->optID());
		Status = true;
	}
	catch (CurlException& ex)
	{
		log.logger("caught exception: " + string(ex.what()) + "!!!Failed to createopt schedule!!!",ucmlogging::Error);
		sdb.sqliteDBwriteString("errormsg",string(ex.what())+ "!!!Failed to createopt schedule!!!", hmiven, "hmivenflag");
	}

	return Status;

}
Beispiel #4
0
// This is our botting thread
void *main_thread( void *arg ) {
	
// NPC details
// ModelInfo - Model: 496, Weapon: 85, Shield: 0, Helmet: 0, Color: 0199
// ModelInfo - Model: 496, Weapon: 85, Shield: 0, Helmet: 0, Color: 0344
	uint16 quest_giver = 0;
	uint16 other_guard = 0;


	int xs[] = { 1343, 1338, 1343, 1348, 1354, 1358, 1354, 1354, 1354, 1358, 1354, 1348, 1343, 1338, 1343, 1343 };
	int ys[] = {  888,  884,  888,  888,  888,  884,  888,  893,  899,  904,  899,  899,  899,  904,  899,  893 };

	int total = 0;

	while( !exit_bot ) {
		// Make sure we are logged in before we continue
		while( !loggedin ) {
			SLEEP( 1000 );
		}

		have_quest = false;

		requestLog( player_id );
		SLEEP( 5000 );

		if( !have_quest && lastQL.curquest != 0x57 ) {
			port( player_id, 2 );

			SLEEP( 2000 );

			transXY( player_id, ( 758 + rand()%2 ), ( 2333 + rand()%2 ));

			SLEEP( 1500 );

			/*while( 1 ) {
				for( auto& x: um_units ) {
					printf(  "Player: %i | X,Y: %i,%i | ModelInfo - Model: %i, Weapon: %i, Shield: %i, Helmet: %i, Color: %04X\n", 
						x.second.id, x.second.movement.positionX, x.second.movement.positionY, x.second.models.model, x.second.models.weapon, x.second.models.shield, x.second.models.helmet, x.second.models.colorbits );
				}
				fprintf( out, "\n" );
				SLEEP( 2000 );
			}*/

			other_guard = 0;
			while( other_guard == 0 ) {
				other_guard = locateUnit( 496, 85, 0, 0, 0x0244 );
				SLEEP( 1000 );
			}

			while( um_units.count( other_guard ) == 0 ) {
				SLEEP( 1000 );
			}

			clickUnit( player_id, other_guard, um_units[ other_guard ].movement.positionY );
			SLEEP( 2000 );

			Say( player_id, (char*)"Pix Animus Task", 15 );
			SLEEP( 2000 );
			Say( player_id, (char*)"OK", 2 );
			SLEEP( 2000 );
			Say( player_id, (char*)"-quitquest", 10 );
			SLEEP( 2000 );

			transXY( player_id, ( 762 + rand()%3 ), 2329 );
			SLEEP( 2000 );

			quest_giver = 0;
			while( quest_giver == 0 ) {
				quest_giver = locateUnit( 496, 85, 0, 0, 0x0099 );
				SLEEP( 1000 );
			}

			while( um_units.count( quest_giver ) == 0 ) {
				SLEEP( 1000 );
			}

			clickUnit( player_id, quest_giver, um_units[ quest_giver ].movement.positionY );
			SLEEP( 2000 );

			Say( player_id, (char*)"warlock task", 12 );
			SLEEP( 2000 );

			Say( player_id, (char*)"OK", 2 );
			SLEEP( 2000 );
		} else {
			port( player_id, 8 );
			SLEEP( 2000 );
		}

		port( player_id, 7 );
		SLEEP( 2000 );
		

		finished_quest = false;
		missing_quest  = false;

		createSkelly( player_id, 1346, 896 );
		SLEEP( 1500 );
		createSkelly( player_id, 1348, 896 );
		SLEEP( 1500 );

		Say( player_id, (char*)"-battle", 7 );
		SLEEP( 1500 );

		int index = 0;
		while( !finished_quest ) {
			if( aliveUnitsRadius( 200 )) {
				rotFlesh( player_id );
				SLEEP( 1000 );
			}
			transXY( player_id, xs[ index ], ys[ index ] );
			SLEEP( 1000 );
			if( !CheckRadius(( xs[ index ] * 20 ), ( ys[ index ] * 20 ), player_x, player_y, 200 )) {
				printf( "[%s] Radius check failed. Restart everything: %i/%i %i/%i\n", currentDateTime().c_str(), ( xs[ index ] * 20 ), ( ys[ index ] * 20 ), player_x, player_y );
				Say( player_id, (char*)"-quitquest", 10 );
				SLEEP( 1000 );
				finished_quest = true;
				missing_quest  = true;
			}
			if( index == 15 ) {
				index = 0;
				if(( rand()%5 ) == 3 ) {
					Say( player_id, (char*)"-battle", 7 );
					SLEEP( 500 );
				}

				requestLog( player_id );
				SLEEP( 500 );
			} else {
				index++;
			}
		}

		if( !missing_quest ) {
			Say( player_id, (char*)"-destroy", 8 );
			SLEEP( 2000 );

			port( player_id, 2 );
			SLEEP( 2000 );

			quest_giver = 0;
			while( quest_giver == 0 ) {
				quest_giver = locateUnit( 496, 85, 0, 0, 0x0099 );
				SLEEP( 1000 );
			}

			while( um_units.count( quest_giver ) == 0 ) {
				SLEEP( 1000 );
			}

			clickUnit( player_id, quest_giver, um_units[ quest_giver ].movement.positionY );
			SLEEP( 2000 );

			port( player_id, 8 );
			SLEEP( 10000 );


			total++;

			printf( "[%s] Quest Done. #%i\n", currentDateTime().c_str(), total );
		}
	}

	//SLEEP( 10000 );

}