Beispiel #1
0
void cheat_handle_checkpoint ( void )
{
	if ( KEY_PRESSED(set.key_checkpoint_1) || KEY_PRESSED(set.key_checkpoint_2) )
	{
		int					n = KEY_PRESSED( set.key_checkpoint_1 ) ? 0 : 1;
		struct checkpoint	*cp = gta_checkpoint_info_get( n );
		float				pos[3];

		if ( cp != NULL )
		{
			struct vehicle_info *vehicle_info = vehicle_info_get( VEHICLE_SELF, 0 );

			vect3_copy( cp->position, pos );
			pos[2] += 1.0f;
			cheat_teleport( pos, 0 );		/* XXX interior id? */

			if ( vehicle_info != NULL )
				vehicle_prevent_below_height( vehicle_info, set.checkpoint_min_height );
		}
		else
		{
			cheat_state_text( "Checkpoint does not exist." );
		}
	}
}
bool rec_sqlite_optimizeDatabase ()
{
	traceLastFunc( "rec_sqlite_optimizeTable()" );

	sqlite3 *rec_db;
	char *errmsgs;

	if ( sqlite3_open( REC_DB_NAME, &rec_db ) != SQLITE_OK )
	{
		Log( "SQLite - Error while connecting: %s", sqlite3_errmsg(rec_db) );
		sqlite3_close( rec_db );
		return false;
	}

	sqlite3_exec( rec_db, "VACUUM", NULL, NULL, &errmsgs );
	if ( errmsgs != NULL )
	{
		Log( "SQLite - Error (optimize): %s", sqlite3_errmsg(rec_db) );
		sqlite3_close( rec_db );
		return false;
	}

	cheat_state_text( "Database has been optimized" );

	sqlite3_close( rec_db );
	return true;
}
Beispiel #3
0
void cmd_tele_loc ( char *param )
{
	if ( strlen(param) == 0 )
	{
		addMessageToChatWindow( "USAGE: /m0d_tele_loc <location name>" );
		addMessageToChatWindow( "Use /m0d_tele_locations to show the location names." );
		addMessageToChatWindow( "The more specific you are on location name the better the result." );
		return;
	}

	for ( int i = 0; i < STATIC_TELEPORT_MAX; i++ )
	{
		if ( strlen(set.static_teleport_name[i]) == 0 || vect3_near_zero(set.static_teleport[i].pos) )
			continue;

		if ( !findstrinstr(set.static_teleport_name[i], param) )
			continue;

		cheat_state_text( "Teleported to: %s.", set.static_teleport_name[i] );
		cheat_teleport( set.static_teleport[i].pos, set.static_teleport[i].interior_id );
		return;
	}

	addMessageToChatWindow( "USAGE: /m0d_tele_loc <location name>" );
	addMessageToChatWindow( "Use /m0d_tele_locations to show the location names." );
	addMessageToChatWindow( "The more specific you are on location name the better the result." );
}
bool rec_sqlite_dropTable ( char *tableName )
{
	traceLastFunc( "rec_sqlite_dropTable()" );

	sqlite3 *rec_db;
	bool return_val = false;

	if ( sqlite3_open( REC_DB_NAME, &rec_db ) != SQLITE_OK )
	{
		Log( "SQLite - Error while connecting: %s", sqlite3_errmsg(rec_db) );
		sqlite3_close( rec_db );
		return false;
	}

	return_val = sqliteDB_dropTable(rec_db, tableName);
	if ( return_val == true )
		cheat_state_text( "Dropped table '%s'", tableName );

	sqlite3_close( rec_db );
	return return_val;
}
Beispiel #5
0
void cheat_damager()
{
	if (cheat_state->_generic.damag && g_Players->pLocalPlayer->iIsActive)
	{
		static DWORD dwTime = 0;
		if (GetTickCount() - dwTime > iNetModeFiringSendRate)
		{
			float curPos[3] = { pPedSelf->GetPosition()->fX, pPedSelf->GetPosition()->fY, pPedSelf->GetPosition()->fZ };
			float bodyPos[3] = { 0.0f, 0.0f, 0.0f };
			int playerId = samp_actor_find_nearest(ACTOR_ALIVE);
			if (playerId > -1 && playerId < SAMP_MAX_PLAYERS)
			{
				cheat_state_text("Атака игрока %d...", playerId);
				if (!set.damagtype && getPlayerSAMPVehicleID(playerId))
				{
					int vehId = getPlayerSAMPVehicleID(playerId);
					g_RakClient->SendFakeBulletSyncData(curPos, bodyPos, &getGTAVehicleFromSAMPVehicleID(vehId)->base.matrix[12], 2, vehId);
				}
				else g_RakClient->SendFakeBulletSyncData(curPos, bodyPos, &getGTAPedFromSAMPPlayerID(playerId)->base.matrix[12], 1, playerId);
			}
			dwTime = GetTickCount();
		}
	}
}
void cheat_handle_vehicle_recording ( struct vehicle_info *info, float time_diff )
{
	char buffer[512];
	float set_speed[3];
	float set_spin[3];

	if ( info == NULL || !set.recording_activated )
		return;
	
	traceLastFunc( "cheat_handle_vehicle_recording()" );
	
	// recording key
	if ( KEY_PRESSED(set.key_recording_record) )
	{
		if ( rec_state == RECORDING_RECORD )
		{
			rec_maxNum = rec_index;
			rec_state = RECORDING_OFF;
			return;
		}
		else if ( rec_state == RECORDING_OFF )
		{
			rec_state = RECORDING_RECORD;
			rec_maxNum = 0;
			rec_index = 0;
			rec_playNext = 0.0f;
		}
	}

	if ( KEY_PRESSED(set.key_recording_continueAfterFinish) )
		rec_continueAfterFin ^= 1;

	// play keys
	if ( (KEY_PRESSED(set.key_recording_play) || KEY_PRESSED(set.key_recording_customSpeed)
		|| KEY_PRESSED(set.key_recording_rev) || KEY_PRESSED(set.key_recording_rev_customSpeed)) )
	{
		// if record playing
		if ( rec_state >= RECORDING_PLAY )
		{
			 rec_state = RECORDING_OFF;
			 return;
		}
		else if ( rec_state == RECORDING_OFF )
		{
			// something to play?
			if ( rec_maxNum <= 0 )
			{
				rec_state = RECORDING_OFF;
				return;
			}

			rec_index = 0;
			rec_playNext = 0.0f;

			
			if ( KEY_PRESSED(set.key_recording_play) )
				rec_state = RECORDING_PLAY;
			else if ( KEY_PRESSED(set.key_recording_customSpeed) )
				rec_state = RECORDING_PLAY_CUSTOMSPEED;
			else if ( KEY_PRESSED(set.key_recording_rev) )
			{
				rec_index = (rec_maxNum-1);
				rec_state = RECORDING_PLAY_REV;
			}
			else if ( KEY_PRESSED(set.key_recording_rev_customSpeed) )
			{
				rec_index = (rec_maxNum-1);
				rec_state = RECORDING_PLAY_REV_CUSTOMSPEED;
			}

			// user set a maximum distance to entry point?
			if ( set.recording_maxDistToEntryPoint > 0.0f )
			{
				// check if current selected index is in maxRange, else look for a point closest
				// to the selected beginning, which is in the maxRange
				if ( vect3_dist(rec_pos[rec_index], &info->base.matrix[4*3]) > set.recording_maxDistToEntryPoint )
				{
					int i = rec_index;
					int rec_index_new = -1;

					// not a entry point we want (too far), lets find a better one
					while ( i >= 0 && i < rec_maxNum )
					{
						if ( vect3_dist(rec_pos[i], &info->base.matrix[4*3]) <= set.recording_maxDistToEntryPoint )
						{
							rec_index_new = i;
							break;
						}
						if ( rec_state == RECORDING_PLAY_REV || rec_state == RECORDING_PLAY_REV_CUSTOMSPEED )
							i--;
						else
							i++;
					}

					// nothing close enough found
					if ( rec_index_new == -1 )
					{
						rec_state = RECORDING_OFF;
						cheat_state_text( "Too far from route - maxDist: %0.2f", set.recording_maxDistToEntryPoint );
					}
					else
						rec_index = rec_index_new;
				}
			}
		}
	}

	if ( rec_state == RECORDING_RECORD )
	{
		pD3DFont->PrintShadow( 99, 250, D3DCOLOR_ARGB(255, 255, 0, 0), "Vehicle Recording" );

		if ( (TIME_TO_FLOAT(time_get()) - rec_playNext) < 0.0f )
			return;
		
		vect3_copy( &info->base.matrix[4*3+0], rec_pos[rec_index] );

		vect3_copy( &info->base.matrix[4*0+0], &rec_angle[rec_index][0] );
		vect3_copy( &info->base.matrix[4*1+0], &rec_angle[rec_index][3] );

		vect3_copy( info->spin, rec_spin[rec_index] );
		vect3_copy( info->speed, rec_speed[rec_index] );

		rec_index++;
		rec_playNext = TIME_TO_FLOAT(time_get()) + TIME_TO_FLOAT((float)MSEC_TO_TIME(REC_DEFAULT_WAITTIME));
		if ( rec_index == (REC_ARRAYSIZE-1) )
		{
			rec_maxNum = rec_index;
			rec_state = RECORDING_OFF;
		}
	}
	// >= because only play states should follow after RECORDING_PLAY
	else if ( rec_state >= RECORDING_PLAY )
	{
		// deactivate playing records while air brakeing/sticking
		if ( cheat_state->vehicle.air_brake || cheat_state->vehicle.stick )
		{
			rec_state = RECORDING_OFF;
			return;
		}

		// move into some better place (maybe hud?)
		_snprintf_s( buffer, sizeof(buffer)-1, "Vehicle Play Record%s%s", (rec_state == RECORDING_PLAY_REV
			|| rec_state == RECORDING_PLAY_REV_CUSTOMSPEED) ? " (Rev)" : "",
			rec_continueAfterFin ? " (Continuously)" : "" );
		_snprintf_s( buffer, sizeof(buffer)-1, "%s%s", buffer, (rec_state == RECORDING_PLAY_REV_CUSTOMSPEED
			|| rec_state == RECORDING_PLAY_CUSTOMSPEED) ? " (Custom Speed)" : "" );
		pD3DFont->PrintShadow( 99, 250, D3DCOLOR_ARGB(255, 0, 255, 0), buffer );

		// will need overtime variable for data row skipping
		float overtime = (TIME_TO_FLOAT(time_get()) - rec_playNext);

		// do nothing, if the planned next-frame time wasn't reached yet
		if ( overtime < 0.0f )
			return;
		
		vect3_copy( rec_pos[rec_index], &info->base.matrix[4*3+0] );

		vect3_copy( &rec_angle[rec_index][0], &info->base.matrix[4*0+0] );
		vect3_copy( &rec_angle[rec_index][3], &info->base.matrix[4*1+0] );

		vect3_copy( rec_spin[rec_index], set_spin );
		vect3_copy( rec_speed[rec_index], set_speed );		

		// multiply speed/spin (for ff mode) and set the playNextTick
		if ( rec_state == RECORDING_PLAY_CUSTOMSPEED || rec_state == RECORDING_PLAY_REV_CUSTOMSPEED )
		{
			vect3_mult( set_spin, set.recording_play_customSpeed, set_spin );
			vect3_mult( set_speed, set.recording_play_customSpeed, set_speed );

			// custom speed multiplier faster/higher than possible to play one by one?
			// if its not the first point (rec_playNext still default) skip a few 
			if ( overtime > 0.0f && rec_playNext != 0.0f )
			{
				// (now-plannedArrival) = overtime -> plannedArrival is way back in the past [so we gotta skip
				//   some of the rows to keep up with the recording/show it 'fluent' (or at least somehow timed correct)]

				// determine how many data rows we gotta skip ((now-plannedArrival)/timePerRow)
				float skipAble = overtime / (float)(TIME_TO_FLOAT((float)MSEC_TO_TIME(REC_DEFAULT_WAITTIME))/set.recording_play_customSpeed);
				if ( skipAble > 1.0f )
				{
					int skipAFew = ceil(skipAble);
					if ( skipAFew > 0 && rec_state >= RECORDING_PLAY_REV )
						rec_index -= skipAFew;
					else if ( skipAFew > 0 )
						rec_index += skipAFew;
				}
			}

			// calculate the time for the next data row
			rec_playNext = TIME_TO_FLOAT(time_get())
				+ (TIME_TO_FLOAT((float)MSEC_TO_TIME(REC_DEFAULT_WAITTIME))/set.recording_play_customSpeed );
		}
		else
		{
			// in case REC_DEFAULT_WAITTIME is too low, or this code is running on a slow computer
			// (or player tabbed/paused the game and refocuses the gta window)
			if ( overtime > 0.0f && rec_playNext != 0.0f )
			{
				// determine how many data rows we gotta skip
				float skipAble = overtime / (float)(TIME_TO_FLOAT(MSEC_TO_TIME(REC_DEFAULT_WAITTIME)));
				if ( skipAble > 1.0f )
				{
					int skipAFew = ceil(skipAble);
					if ( skipAFew > 0 && rec_state >= RECORDING_PLAY_REV )
						rec_index -= skipAFew;
					else if ( skipAFew > 0 )
						rec_index += skipAFew;
				}
			}

			rec_playNext = TIME_TO_FLOAT(time_get()) + TIME_TO_FLOAT(MSEC_TO_TIME(REC_DEFAULT_WAITTIME));
		}

		// inverse speed/spin (for rev mode) and set rec_index
		if ( rec_state >= RECORDING_PLAY_REV )
		{
			vect3_mult( set_spin, -1.0f, set_spin );
			vect3_mult( set_speed, -1.0f, set_speed );
			rec_index--;

			// reached end of recording
			if ( rec_index <= 0 )
			{
				if ( !rec_continueAfterFin )
					rec_state = RECORDING_OFF;
				else
				{
					if ( set.recording_maxDistToEntryPoint > 0.0f )
					{
						// deactivate, if new starting position is too far from this point
						if ( vect3_dist(rec_pos[rec_index], rec_pos[(rec_maxNum-1)]) > set.recording_maxDistToEntryPoint )
							rec_state = RECORDING_OFF;
					}
					rec_index = (rec_maxNum-1);
				}
			}
		}
		else
		{
			rec_index++;

			// reached end of recording
			if ( (rec_index >= (REC_ARRAYSIZE-1) || rec_index >= rec_maxNum) )
			{
				if ( !rec_continueAfterFin )
					rec_state = RECORDING_OFF;
				else
				{
					if ( set.recording_maxDistToEntryPoint > 0.0f )
					{
						// deactivate, if new starting position is too far from this point
						if ( vect3_dist(rec_pos[rec_index], rec_pos[0]) > set.recording_maxDistToEntryPoint )
							rec_state = RECORDING_OFF;
					}
					rec_index = 0;
				}
			}
		}	
		
		// copy new speed/spin after it has been adjusted for ff/rev mode
		vect3_copy( set_spin, info->spin );
		vect3_copy( set_speed, info->speed );			
	}
	else
	{
		rec_state = RECORDING_OFF;
	}
}
bool rec_sqlite_writeTable ()
{
	traceLastFunc( "rec_sqlite_writeTable()" );

	sqlite3 *rec_db;
	char sql_cmd[1024];
	char *errmsgs = NULL;
	int ret_exists;

	if ( rec_state == RECORDING_RECORD )
	{
		cheat_state_text( "Can't save while recording." );
		return false;
	}

	if ( rec_maxNum <= 0 )
	{
		cheat_state_text( "Nothing to be saved." );
		return false;
	}

	if ( sqlite3_open( REC_DB_NAME, &rec_db ) != SQLITE_OK )
	{
		Log( "SQLite - Error while connecting: %s", sqlite3_errmsg(rec_db) );
		sqlite3_close( rec_db );
		return false;
	}

	for ( int i = 0; i < 64; i++ ) // max default name
	{
		_snprintf_s( sql_cmd, sizeof(sql_cmd)-1, "route%i", i );
		ret_exists = sqliteDB_checkTableExists( rec_db, sql_cmd );
		// continue, if table already exists
		if ( ret_exists == 1 )
			continue;
		// quit function on fail
		if ( ret_exists == -1 )
		{
			sqlite3_close( rec_db );
			return false;
		}

		// create table with default name 'route..'
		_snprintf_s( sql_cmd, sizeof(sql_cmd)-1, "CREATE TABLE 'route%i'(", i );
		_snprintf_s( sql_cmd, sizeof(sql_cmd)-1, "%s 'index' INTEGER NOT NULL PRIMARY KEY AUTOINCREMENT," \
			"'maxNum' INTEGER NULL DEFAULT NULL," \
			"'angle1' REAL NOT NULL,'angle2' REAL NOT NULL,'angle3' REAL NOT NULL,'angle4' REAL NOT NULL," \
			"'angle5' REAL NOT NULL,'angle6' REAL NOT NULL,"\
			"'spin1' REAL NOT NULL,'spin2' REAL NOT NULL,'spin3' REAL NOT NULL," \
			"'speed1' REAL NOT NULL,'speed2' REAL NOT NULL,'speed3' REAL NOT NULL," \
			"'pos1' REAL NOT NULL,'pos2' REAL NOT NULL,'pos3' REAL NOT NULL);"
			, sql_cmd );
		sqlite3_exec( rec_db, sql_cmd, NULL, NULL, &errmsgs );
		if ( errmsgs != NULL )
		{
			Log( "SQLite - Error (executing CREATE TABLE statement): %s", errmsgs );
			sqlite3_close( rec_db );
			return false;
		}

		// add our data into the new table
		for ( int j = 0; j < rec_maxNum && j < (REC_ARRAYSIZE-1); j++ )
		{
			if ( j != 0 )
				_snprintf_s( sql_cmd, sizeof(sql_cmd)-1, "INSERT INTO 'route%i' VALUES( null, null,", i );
			else
				_snprintf_s( sql_cmd, sizeof(sql_cmd)-1, "INSERT INTO 'route%i' VALUES( null, %i,", i, rec_maxNum );
			_snprintf_s( sql_cmd, sizeof(sql_cmd)-1, "%s %0.2f, %0.2f, %0.2f, %0.2f,"
				"%0.2f, %0.2f," \
				"%0.2f, %0.2f, %0.2f," \
				"%0.2f, %0.2f, %0.2f," \
				"%0.2f, %0.2f, %0.2f" \
				");", 
				sql_cmd, rec_angle[j][0], rec_angle[j][1], rec_angle[j][2], rec_angle[j][3], 
				rec_angle[j][4], rec_angle[j][5],
				rec_spin[j][0], rec_spin[j][1], rec_spin[j][2],
				rec_speed[j][0], rec_speed[j][1], rec_speed[j][2],
				rec_pos[j][0], rec_pos[j][1], rec_pos[j][2] );

			//Log( sql_cmd );
			sqlite3_exec( rec_db, sql_cmd, NULL, NULL, &errmsgs );
			if ( errmsgs != NULL )
			{
				Log( "SQLite - Error (executing INSERT INTO statement): %s", errmsgs );
				sqlite3_close( rec_db );
				return false;
			}
		}

		cheat_state_text( "saved to 'route%i'", i );
		break;
	}

	sqlite3_close( rec_db );
	return true;
}
bool rec_sqlite_loadTable ( char *tableName )
{
	traceLastFunc( "rec_sqlite_loadTable()" );

	sqlite3 *rec_db;
	sqlite3_stmt *prep_stmt;
	int prep_step_ret;
	char sql_cmd[1024];

	if ( sqlite3_open( REC_DB_NAME, &rec_db ) != SQLITE_OK )
	{
		Log( "SQLite - Error while connecting: %s", sqlite3_errmsg(rec_db) );
		sqlite3_close( rec_db );
		return false;
	}

	// return false, if error happens, or table doesn't exist
	if ( sqliteDB_checkTableExists( rec_db, tableName ) != 1 )
	{
		sqlite3_close( rec_db );
		cheat_state_text( "table doesn't exist" );
		return false;
	}

	// stop playing/recording when loading a new route
	rec_state = RECORDING_OFF;

	_snprintf_s( sql_cmd, sizeof(sql_cmd)-1, "SELECT * FROM '%s';", tableName );
	if ( sqlite3_prepare_v2( rec_db, sql_cmd, sizeof(sql_cmd), &prep_stmt, NULL ) != SQLITE_OK )
	{
		Log( "SQLite - Error (prepare statement to load from table '%s'): %s", tableName, sqlite3_errmsg(rec_db) );
		sqlite3_close( rec_db );
		return false;
	}

	// jump to first row and set the maxNum
	prep_step_ret = sqlite3_step( prep_stmt );
	rec_maxNum = sqlite3_column_int(prep_stmt,1);

	if ( rec_maxNum > (REC_ARRAYSIZE-1) || rec_maxNum <= 0 )
	{
		Log( "Recording - load table '%s': rec_maxNum(%i) is <= 0 or greater than maximum array size!", 
			tableName, rec_maxNum );
		sqlite3_finalize( prep_stmt );
		sqlite3_close( rec_db );

		cheat_state_text( "failed to load" );
		// we changed a variable, so set maxNum to 0, so it can't be 
		// causing problems when trying to play record
		rec_maxNum = 0;
		return false;
	}

	for ( int i = 0; i < rec_maxNum; i++ )
	{
		// load our data from the table
		// do not forget to adjust these offsets when changing table design
		for ( int j = 0; j < 6; j++ )
			rec_angle[i][j] = sqlite3_column_double( prep_stmt, j+2 );
		for ( int j = 0; j < 3; j++ )
		{
			rec_spin[i][j] = sqlite3_column_double( prep_stmt, j+8 );
			rec_speed[i][j] = sqlite3_column_double( prep_stmt, j+11 );
			rec_pos[i][j] = sqlite3_column_double( prep_stmt, j+14 );
		}

		prep_step_ret = sqlite3_step( prep_stmt );
		
		// step() returned some error/unexpected value?
		if ( prep_step_ret != SQLITE_ROW && prep_step_ret != SQLITE_DONE )
		{
			Log( "SQLite - Error (prepare statement to load from table '%s' - cycle %i): %s", tableName, i, sqlite3_errmsg(rec_db) );
			sqlite3_finalize( prep_stmt );
			sqlite3_close( rec_db );
			
			cheat_state_text( "failed to load" );
			// data has been changed.. destroy record for playback
			rec_maxNum = 0;
			return false;
		}

		// we somehow reached the end (end of rows/end of loop)
		if ( i == (rec_maxNum-1) || prep_step_ret == SQLITE_DONE )
		{
			// check if its only end of one = error while loading
			if ( i != (rec_maxNum-1) || prep_step_ret != SQLITE_DONE )
			{
				Log( "Problem while loading Recording '%s': %s - MaxNum %i - cycleNum %i",
					tableName,
					prep_step_ret == SQLITE_DONE ? "End of rows" : "Not at end of rows",
					rec_maxNum, i );
				sqlite3_finalize( prep_stmt );
				sqlite3_close( rec_db );

				cheat_state_text( "failed to load" );
				// we probably got incorrect data in the recording? - set maxNum to 0
				rec_maxNum = 0;
				return false;
			}

			// we reached the end of rows at expected time (when the loop reaches maxNum-1)
			cheat_state_text( "successfully loaded route" );
		}		
	}
	sqlite3_finalize( prep_stmt );
	sqlite3_close( rec_db );
	return true;
}
Beispiel #9
0
void cheat_handle_teleport ( struct vehicle_info *vehicle_info, struct actor_info *actor_info, float time_diff )
{
	traceLastFunc( "cheat_handle_teleport()" );

	struct object_base	*base = ( vehicle_info != NULL ) ? &vehicle_info->base : &actor_info->base;
	int					i;

	// Set teleport coordinates
	for ( i = 0; i < TELEPORT_MAX; i++ )
	{
		if ( set.key_teleport_set[i] == 0 )
			continue;
		if ( KEY_PRESSED(set.key_teleport_set[i]) )
		{
			cheat_state->teleport[i].set = 1;
			matrix_copy( base->matrix, cheat_state->teleport[i].matrix );
			cheat_state->teleport[i].interior_id = gta_interior_id_get();
			cheat_state_text( "Teleport coordinates set." );
		}
	}

	// Teleport to stored coordinates
	for ( i = 0; i < TELEPORT_MAX; i++ )
	{
		if ( set.key_teleport[i] == 0 )
			continue;
		if ( KEY_PRESSED(set.key_teleport[i]) )
		{
			if ( cheat_state->teleport[i].set )
			{
				cheat_teleport_history_save();
				cheat_teleport( &cheat_state->teleport[i].matrix[4 * 3], cheat_state->teleport[i].interior_id );

				// when teleports are stored in-game, we have a copy of the matrix to preserve rotation, etc..
				matrix_copy( cheat_state->teleport[i].matrix, base->matrix );
			}
			else if ( !vect3_near_zero(set.teleport[i].pos) )
			{
				cheat_teleport_history_save();
				cheat_teleport( set.teleport[i].pos, set.teleport[i].interior_id );
			}
			else
			{
				cheat_state_text( "Teleport coordinates not set." );
				break;
			}
			break;
		}
	}

	if ( KEY_PRESSED(set.key_teleport_hist) )
	{
		struct cheat_state_teleport *teleport = NULL;

		cheat_state->teleport_hist_count--;
		if ( cheat_state->teleport_hist_count < 0 )
			cheat_state->teleport_hist_count = 0;
		else
			teleport = &cheat_state->teleport_hist[cheat_state->teleport_hist_count];

		if ( teleport != NULL && teleport->set )
		{
			cheat_teleport( &teleport->matrix[4 * 3], teleport->interior_id );
			matrix_copy( teleport->matrix, base->matrix );
			teleport->set = 0;
		}
		else
		{
			cheat_state_text( "Teleport history list is empty." );
		}
	}
}
Beispiel #10
0
void cheat_handle_stick ( struct vehicle_info *vehicle_info, struct actor_info *actor_info, float time_diff )
{
	traceLastFunc( "cheat_handle_stick()" );

	struct object_base	*base_stick, *base_self;
	struct actor_info	*actor_stick;
	struct vehicle_info *vehicle_stick;
	float				*speed_stick, *speed_self;
	float				*spin_stick, *spin_self;
	static int			id = -1;
	int					i;

	if ( KEY_PRESSED(set.key_stick) )
	{
		if ( vehicle_info != NULL )
			cheat_state->vehicle.stick ^= 1;
		else
			cheat_state->actor.stick ^= 1;
		id = actor_find( id - 1, 1, ACTOR_ALIVE | ACTOR_NOT_SAME_VEHICLE );
	}

	if ( KEY_PRESSED(set.key_stick_nearest) )
	{
		if ( vehicle_info != NULL )
			cheat_state->vehicle.stick ^= 1;
		else
			cheat_state->actor.stick ^= 1;
		id = actor_find_nearest( ACTOR_ALIVE | ACTOR_NOT_SAME_VEHICLE );
	}

	if ( (vehicle_info != NULL && cheat_state->vehicle.stick) || (actor_info != NULL && cheat_state->actor.stick) )
	{
		// remove any bad vehicle or actor stuffs
		if ( isBadPtr_GTA_pVehicle(vehicle_info) )
			vehicle_info = NULL;
		if ( isBadPtr_GTA_pPed(actor_info) )
			actor_info = NULL;

		/* check if actor has disappeared.. and if it has, switch to teh nearest */
		if ( id != -1 && actor_info_get(id, ACTOR_ALIVE) == NULL )
			id = actor_find_nearest( ACTOR_ALIVE | ACTOR_NOT_SAME_VEHICLE );

		if ( KEY_PRESSED(set.key_stick_prev) )
			id = actor_find( id, -1, ACTOR_ALIVE | ACTOR_NOT_SAME_VEHICLE );

		if ( KEY_PRESSED(set.key_stick_next) )
			id = actor_find( id, 1, ACTOR_ALIVE | ACTOR_NOT_SAME_VEHICLE );

		/* no actors to stick to */
		if ( id == -1 )
		{
			cheat_state_text( "No players found; stick disabled." );
			cheat_state->vehicle.stick = 0;
			cheat_state->actor.stick = 0;
			return;
		}

		/* get actor struct for the actor we're sticking to */
		actor_stick = actor_info_get( id, ACTOR_ALIVE | ACTOR_NOT_SAME_VEHICLE );
		if ( actor_stick == NULL )
			return;

		/* is this actor in a vehicle? */
		vehicle_stick = actor_vehicle_get( actor_stick );

		base_stick = vehicle_stick ? &vehicle_stick->base : &actor_stick->base;
		base_self = vehicle_info ? &vehicle_info->base : &actor_info->base;

		speed_stick = vehicle_stick ? vehicle_stick->speed : actor_stick->speed;
		speed_self = vehicle_info ? vehicle_info->speed : actor_info->speed;

		spin_stick = vehicle_stick ? vehicle_stick->spin : actor_stick->spin;
		spin_self = vehicle_info ? vehicle_info->spin : actor_info->spin;

		/* allow warping to work + always warp towards whatever we're sticking to...
         but only when we're in a vehicle */
		if ( KEY_PRESSED(set.key_warp_mod) && vehicle_info != NULL )
		{
			float	out[4];

			/* multiply the matrix of whatever we're sticking to with the user supplied vector */
			matrix_vect4_mult( base_stick->matrix, set.stick_vect, out );

			/* multiply the result with the negative warp-speed value, and put it in the speed vector
            (negative because we want to warp towards teh target, not away from it */
			vect3_mult( out, -set.warp_speed, speed_self );
		}

		if ( !KEY_DOWN(set.key_warp_mod) )
		{
			float	d[4] = { 0.0f, 0.0f, 0.0f, 0.0f };
			float	accel_mult = 1.0f;
			float	out[4];

			/* handle stick movement keys */
			if ( KEY_DOWN(set.key_stick_forward) )
				d[1] += 1.0f;
			if ( KEY_DOWN(set.key_stick_backward) )
				d[1] -= 1.0f;
			if ( KEY_DOWN(set.key_stick_left) )
				d[0] -= 1.0f;
			if ( KEY_DOWN(set.key_stick_right) )
				d[0] += 1.0f;
			if ( KEY_DOWN(set.key_stick_up) )
				d[2] += 1.0f;
			if ( KEY_DOWN(set.key_stick_down) )
				d[2] -= 1.0f;
			if ( KEY_DOWN(set.key_stick_in) )
				d[3] -= 1.0f;
			if ( KEY_DOWN(set.key_stick_out) )
				d[3] += 1.0f;

			if ( !near_zero(set.stick_accel_time) )
			{
				static uint32_t time_start;

				if ( !vect4_near_zero(d) )
					time_start = ( time_start == 0 ) ? time_get() : time_start;
				else
					time_start = 0;			/* no keys pressed */

				/* acceleration */
				if ( time_start != 0 )
				{
					float	t = TIME_TO_FLOAT( time_get() - time_start );
					if ( t < set.stick_accel_time )
						accel_mult *= t / set.stick_accel_time;
				}
			}

			/* calculate new vector + dist */
			if ( !vect3_near_zero(d) && !vect3_near_zero(set.stick_vect) )
			{
				for ( i = 0; i < 3; i++ )
				{
					d[i] = set.stick_vect[i] * set.stick_vect_dist + d[i] * time_diff * 8.0f * accel_mult;
				}

				set.stick_vect_dist = vect3_length( d );
				vect3_normalize( d, set.stick_vect );
			}

			/* move towards/away from the center */
			if ( !near_zero(d[3]) )
				set.stick_vect_dist += d[3] * time_diff * 40.0f * accel_mult;

			/* Teleport vehicle detachables */
			if ( vehicle_info != NULL )
				vehicle_detachables_teleport( vehicle_info, &base_self->matrix[4 * 3], &base_stick->matrix[4 * 3] );

			matrix_copy( base_stick->matrix, base_self->matrix );
			vect3_copy( speed_stick, speed_self );
			vect3_copy( spin_stick, spin_self );

			/*base_self->interior_id = base_stick->interior_id;
         gta_interior_id_set(base_stick->interior_id);*/
			/* multiply the matrix of the target with the user supplied vector */
			matrix_vect4_mult( base_stick->matrix, set.stick_vect, out );

			/* multiply the result with the user supplied vector distance */
			vect3_mult( out, set.stick_vect_dist, out );

			/* and add it to our position */
			vect3_vect3_add( &base_self->matrix[4 * 3], out, &base_self->matrix[4 * 3] );

			if ( vehicle_info != NULL )
			{
				/* Teleport detachables again :p */
				vehicle_detachables_teleport( vehicle_info, &base_stick->matrix[4 * 3], &base_self->matrix[4 * 3] );
				vehicle_prevent_below_height( vehicle_info, set.stick_min_height );
			}
			else if ( actor_info != NULL )
			{
				// new pedFlags
				actor_info->pedFlags.bIsStanding = true;
				actor_info->pedFlags.bWasStanding = true;
				actor_info->pedFlags.bStayInSamePlace = true;
			}
		}
	}
}
Beispiel #11
0
int cheat_panic ( void )
{
	traceLastFunc( "cheat_panic()" );

	static int	pstate_map = 0, // m0d's map
		pstate_d3dtext_hud = 0, // hud bar
		pstate_actor_hp_nSP = 0, // "Extra actor invincibility" patch (invulnerable single player enemies)
		pstate_actor_hp_SP = 0, // "Extra actor invincibility2" patch (no problems in SP)
		pstate_vehicle_hp = 0, // vehicle hp patch
		pstate_generic_menu = 0, // m0d's menu
		pstate_infnos = 0, // infinite NOS
		pstate_ini[INI_PATCHES_MAX],
		pstate_dummy_aligner; // this should all be a structure, static = DOING IT WRONG
	int			i;

	// sa-mp related
	static int	pstate_chat = 0, // chat
		pstate_deathlist = 0; // deathlist

	if ( KEY_PRESSED(set.key_panic) )
	{
		// toggle panic
		cheat_state->_generic.cheat_panic_enabled ^= 1;

		if ( cheat_state->_generic.cheat_panic_enabled )
		{
			struct actor_info	*actor_info = actor_info_get( ACTOR_SELF, ACTOR_ALIVE );

			if ( actor_info )
			{
				actor_info->flags &= ~ACTOR_FLAGS_INVULNERABLE;
				actor_info->weapon_slot = 0;
			}

			// remove infinite NOS
			pstate_infnos = cheat_state->vehicle.infNOS_toggle_on;
			cheat_state->vehicle.infNOS_toggle_on = false;
			patcher_remove( &patch_vehicle_inf_NOS );

			if ( pPedSelf->GetVehicle() )
			{
				CVehicle	*pVehicleSelf = pPedSelf->GetVehicle();
				CVehicle	*pVehicleTemp = NULL;

				for ( pVehicleTemp = pVehicleSelf; pVehicleTemp != NULL; pVehicleTemp = pVehicleTemp->GetTowedVehicle() )
				{
					pVehicleTemp->SetGravity( &CVector(0.0, 0.0, -1.0) );
					pVehicleTemp->SetCanBeDamaged( true );

					if ( !set.trailer_support )
						break;
				}

				// remove inf NOS
				if ( pstate_infnos )
				{
					pVehicleSelf->RemoveVehicleUpgrade( 1010 );
					//pVehicleSelf->AddVehicleUpgrade( 1010 );
				}

				// reset overrideLights, pstate not needed, will be reactivated on demand
				if ( set.enable_car_lights_at_day_time )
					pVehicleSelf->SetOverrideLights( 0 );
			}

			// hud bar, this should probably become a cheat_state
			pstate_d3dtext_hud = set.d3dtext_hud;
			set.d3dtext_hud = 0;

			// m0d's map
			pstate_map = cheat_state->_generic.map;
			cheat_state->_generic.map = 0;

			// m0d's menu
			pstate_generic_menu = cheat_state->_generic.menu;
			cheat_state->_generic.menu = 0;

			// remove "Extra actor invincibility" patch
			pstate_actor_hp_nSP = patch_actor_hp_extraInv.installed;
			patcher_remove( &patch_actor_hp_extraInv );
			pstate_actor_hp_SP = patch_actor_hp.installed;
			patcher_remove( &patch_actor_hp );

			// remove vehicle hp patch
			pstate_vehicle_hp = patch_vehicle_hp.installed;
			patcher_remove( &patch_vehicle_hp );

			// just call with null vehicle info to disable
			cheat_handle_vehicle_fly( NULL, 0.0f );

			for ( i = 0; i < INI_PATCHES_MAX; i++ )
			{
				// added to not remove volatile patches
				if ( !set.patch[i].has_volatile )
				{
					pstate_ini[i] = set.patch[i].installed;
					patcher_remove( &set.patch[i] );
				}
			}

			// turn off kill & chat
			if ( g_DeathList != NULL )
			{
				pstate_deathlist = g_DeathList->iEnabled;
				g_DeathList->iEnabled = 1;
			}
			if ( g_Chat != NULL )
			{
				pstate_chat = g_Chat->iChatWindowMode;
				g_Chat->iChatWindowMode = 2;
			}
		}
		else
		{
			// restore infinite NOS
			if ( pstate_infnos )
			{
				cheat_state->vehicle.infNOS_toggle_on = true;
				patcher_install( &patch_vehicle_inf_NOS );
			}

			// vehicle stuff
			CPed	*pPedSelf = pPools->GetPedFromRef( CPOOLS_PED_SELF_REF );
			if ( pPedSelf->GetVehicle() )
			{
				CVehicle	*pVehicleSelf = pPedSelf->GetVehicle();
				// restore inf NOS
				if ( pstate_infnos )
				{
					pVehicleSelf->AddVehicleUpgrade( 1010 );
				}
			}


			// restore "Extra actor invincibility" patch
			if ( pstate_actor_hp_nSP )
				patcher_install( &patch_actor_hp_extraInv );
			if ( pstate_actor_hp_SP )
				patcher_install( &patch_actor_hp );

			// restore vehicle hp patch
			if ( pstate_vehicle_hp )
				patcher_install( &patch_vehicle_hp );

			// restore some cheat_states
			set.d3dtext_hud = pstate_d3dtext_hud;
			cheat_state->_generic.map = pstate_map;
			cheat_state->_generic.menu = pstate_generic_menu;

			// restore patches
			for ( i = 0; i < INI_PATCHES_MAX; i++ )
			{
				if ( pstate_ini[i] )
					patcher_install( &set.patch[i] );
			}

			// restore kill & chat
			if ( g_DeathList != NULL )
			{
				g_DeathList->iEnabled = pstate_deathlist;
			}
			if ( g_Chat != NULL )
			{
				g_Chat->iChatWindowMode = pstate_chat;
			}

			// clear cheat state text
			cheat_state_text( NULL );
		}
	}

	return cheat_state->_generic.cheat_panic_enabled;
}
Beispiel #12
0
void cheat_hook ( HWND wnd )
{
	traceLastFunc( "cheat_hook()" );

	// get the time
	static uint64_t time_last;
	__time_current = __time_get();
	g_timeDiff = TIME_TO_DOUBLE(time_get() - time_last);

	// for looping
	int i;

	// install keyhook
	keyhook_maybe_install( wnd );

	// setup menu
	menu_maybe_init();
	traceLastFunc( "cheat_hook()" );

	/* initialize state */
	if ( cheat_state == NULL )
	{
		// set default cheat_state variables
		cheat_state = &__cheat_state;
		cheat_state->_generic.spoof_weapon = -1;
		cheat_state->_generic.money = set.money_enabled;
		cheat_state->_generic.weapon = set.weapon_enabled;
		cheat_state->_generic.vehicles_unlock = false;
		cheat_state->_generic.vehicles_warp_invert = true;
		cheat_state->actor.invulnerable = true;
		cheat_state->vehicle.invulnerable = true;
		cheat_state->vehicle.hp_tire_support = true;
		cheat_state->vehicle.hp_minimum_on = 1;
		cheat_state->vehicle.hp_regen_on = 1;
		cheat_state->actor.hp_regen_on = 1;
		cheat_state->vehicle.brkdance = 0;
		cheat_state->game_speed = 1.0f;
		cheat_state->vehicle.is_engine_on = 1;
		cheat_state->_generic.interior_patch_enabled = 0;

		// refreshes any cheat_state stuff set from the INI
		ini_load_setSettings();

		/* install patches from the .ini file */
		for ( i = 0; i < INI_PATCHES_MAX; i++ )
		{
			if ( set.patch[i].name != NULL && set.patch[i].ini_auto )
				patcher_install( &set.patch[i] );
		}

		if ( g_dwSAMP_Addr != NULL )
		{
			for ( i = 0; i < INI_SAMPPATCHES_MAX; i++ )
			{
				if ( set.sampPatch[i].name != NULL && set.sampPatch[i].ini_auto )
					patcher_install( &set.sampPatch[i] );
			}
		}
	}	/* end initialize state */

	// set cheat state to "off"
	cheat_state->state = CHEAT_STATE_NONE;

	/* setup & refresh actor pool */
	pool_actor = *(struct pool **)ACTOR_POOL_POINTER;
	if ( pool_actor == NULL || pool_actor->start == NULL || pool_actor->size <= 0 )
		return;

	/* setup & refresh vehicle pool */
	pool_vehicle = *(struct pool **)VEHICLE_POOL_POINTER;
	if ( pool_vehicle == NULL || pool_vehicle->start == NULL || pool_vehicle->size <= 0 )
		return;

	//////////////////////////////////////////
	// looks like we have pools so continue //
	struct actor_info	*actor_info;
	struct vehicle_info *vehicle_info;
	actor_info = actor_info_get( ACTOR_SELF, ACTOR_ALIVE );
	vehicle_info = vehicle_info_get( VEHICLE_SELF, 0 );

	/* no vehicle, and no actor. exit. */
	if ( vehicle_info == NULL && actor_info == NULL )
	{
		if ( cheat_state->actor.air_brake
		 ||	 cheat_state->actor.stick
		 ||	 cheat_state->vehicle.air_brake
		 ||	 cheat_state->vehicle.stick )
		{
			cheat_state->actor.air_brake = 0;
			cheat_vehicle_air_brake_set( 0 );
			cheat_state->actor.stick = 0;
			cheat_state->vehicle.stick = 0;
			cheat_state_text( "Air brake / stick disabled" );
		}
	}
	else
	{
		if ( vehicle_info == NULL )
		{
			if ( cheat_state->vehicle.air_brake || cheat_state->vehicle.stick )
			{
				cheat_vehicle_air_brake_set( 0 );
				cheat_state->vehicle.stick = 0;
				cheat_state_text( "Air brake / stick disabled" );
			}

			cheat_state->state = CHEAT_STATE_ACTOR;

			// reset infinite NOS toggle state
			if ( cheat_state->vehicle.infNOS_toggle_on )
			{
				cheat_state->vehicle.infNOS_toggle_on = false;
				patcher_remove( &patch_vehicle_inf_NOS );
			}
		}
		else
		{
			if ( cheat_state->actor.air_brake || cheat_state->actor.stick )
			{
				cheat_state->actor.air_brake = 0;
				cheat_state->actor.stick = 0;
				cheat_state_text( "Air brake / stick disabled" );
			}

			cheat_state->state = CHEAT_STATE_VEHICLE;
		}

		// post GTA initialization initizalization routines
		if ( m_InitStages == 0 )
		{
			// setup CGame & friends
			pGameInterface = new CGameSA();
			pPools = pGameInterface->GetPools();

			//pGameInterface->Initialize(); // all this does so far is disable modshops and pay&sprays
			// this seems to fix SAMP's load hang bug
			//pGameInterface->StartGame();

			// we have to add ourself to the pool first so that we are always the 1st ref
			// NEW --> use the global external: pPedSelf
			pPedSelf = pGameInterface->GetPools()->AddPed( (DWORD *)actor_info );
			pPedSelfSA = pPedSelf->GetPedInterface();

			// install all startup hooks
			cheat_hookers_installhooks();

			// increment stage
			m_InitStages++;
		}
		else if ( m_InitStages == 1 )
		{
			// load all the weapon models
			loadAllWeaponModels();

			// get funky
			//pGameInterface->GetAudio()->PlayBeatTrack(2);

			// increment stage
			m_InitStages++;
		}
	}

	if ( cheat_state->state != CHEAT_STATE_NONE )
	{
		// keep this updated, cos something is switching it now
		pPedSelf = pPools->GetPedFromRef( CPOOLS_PED_SELF_REF );
		pPedSelfSA = pPedSelf->GetPedInterface();
	}

	static bool chat_set_once = false;
	if ( !chat_set_once && set.d3dtext_chat )
	{
		if ( g_Chat != NULL && g_Chat->iChatWindowMode )
		{
			//Log("Disabling SA:MP chat text.");
			g_Chat->iChatWindowMode = 0;
			chat_set_once = true;
		}
	}

	// sets kill text to s0beit mode if enabled from INI
	static bool kill_set_once = false;
	if ( !kill_set_once && set.d3dtext_kill )
	{
		if ( g_DeathList != NULL && g_DeathList->iEnabled )
		{
			g_DeathList->iEnabled = 0;
			kill_set_once = true;
		}
	}

	// more random than random
	if ( rand() % 5000 == 0 )
		srand( rand() + time_get() );

	// OMGWTFBBQ?!?
	if ( cheat_panic() )
	{
		cheat_state->state = CHEAT_STATE_NONE;
		goto out;
	}

	// menus are good
	menu_run();

	// install volatile patches from the .ini file
	for ( i = 0; i < INI_PATCHES_MAX; i++ )
	{
		if ( set.patch[i].name != NULL && set.patch[i].has_volatile && set.patch[i].installed )
			patcher_install( &set.patch[i] );
	}

	// generic stuff - these want to run even though we're dead
	cheat_handle_debug( wnd );
	cheat_handle_misc();
	cheat_handle_spoof_weapon();
	cheat_handle_weapon();
	gta_game_speed_set( cheat_state->game_speed );
	cheat_main_display_debug_stuff(g_timeDiff);

	if ( cheat_state->state != CHEAT_STATE_NONE )
	{
		// generic stuff
		cheat_handle_weapon_disable();
		cheat_handle_money();

		//////////////////////////////////////////////////////////////////
		// this should be removed after reworking weapon cheat function //
		//if ( set.restore_weapons_after_death )
		//	* (uint8_t *)0x5E6320 = 0xC3;

		cheat_handle_unlock();
		cheat_handle_checkpoint();

		// do stuff :p
		if ( cheat_state->state == CHEAT_STATE_VEHICLE )
		{
			cheat_main_vehicle( g_timeDiff );
		}
		else if ( cheat_state->state == CHEAT_STATE_ACTOR )
		{
			cheat_main_actor( g_timeDiff );
		}

		if ( KEY_PRESSED(set.key_disable_Wall_Collisions) )
		{
			cheat_state->_generic.nocols_walls_enabled ^= 1;
			if ( cheat_state->_generic.nocols_walls_enabled )
				patcher_install( &patch_NoColsWalls );
			else
				patcher_remove( &patch_NoColsWalls );
		}

		for ( i = 0; i < INI_PATCHES_MAX; i++ )
		{
			if ( set.patch[i].name != NULL && KEY_PRESSED(set.patch[i].ini_hotkey) )
			{
				if ( set.patch[i].installed || set.patch[i].failed )
					patcher_remove( &set.patch[i] );
				else
					patcher_install( &set.patch[i] );
			}
		}

		for ( i = 0; i < INI_SAMPPATCHES_MAX; i++ )
		{
			if ( set.sampPatch[i].name != NULL && KEY_PRESSED(set.sampPatch[i].ini_hotkey) )
			{
				if ( set.sampPatch[i].installed || set.sampPatch[i].failed )
					patcher_remove( &set.sampPatch[i] );
				else
					patcher_install( &set.sampPatch[i] );
			}
		}

		if ( KEY_PRESSED(set.key_vehicle_jumper) )
		{
			int iVehicleID = vehicle_find_nearest( VEHICLE_ALIVE + VEHICLE_NOTBURNING );
			vehicleJumper( iVehicleID );
		}

		if ( KEY_PRESSED(set.key_vehicle_occupied_jumper) )
		{
			int iVehicleID = vehicle_find_nearest( VEHICLE_ALIVE + VEHICLE_NOTBURNING + VEHICLE_OCCUPIED );
			vehicleJumper( iVehicleID );
		}
	}	// cheat_state->state != CHEAT_STATE_NONE

	// hack some SA:MP, shall we?
	if ( g_SAMP && g_renderSAMP_initSAMPstructs )
		sampMainCheat();

out: ;
	if (gta_menu_active()) {
		keyhook_clear_states();
		*(BYTE *)0xB7CB49 = 0; // game not paused even if we are in the menu.
	}
	else
		keyhook_run();
	time_last = time_get();
}