To change target you can search for the, "current target" address in CE.
Then use WriteProcessMemory in your app, to change the target.
example | working offset (from RF Asyura)
Code:
DWORD rdm(HANDLE& handle, DWORD read_address){
DWORD b; ReadProcessMemory(handle, (DWORD*)read_address, &b, 4, NULL);
return b;
}
void wdm(HANDLE& handle, DWORD write_address, DWORD value){
WriteProcessMemory(handle, (DWORD*)write_address, &value, 4, NULL);
}
// [[0x00F41214] + 0x04] | 'current target' offset
HANDLE window_handle;
DWORD GetCurrentTarget(){
DWORD pointer = rdm(window_handle, 0x00F41214) + 0x04;
return rdm(window_handle, pointer);
}
void SetCurrentTarget(DWORD target_index){
DWORD pointer = rdm(window_handle, 0x00F41214) + 0x04;
wdm(window_handle, pointer, target_index);
}
Also you will need to create a function, to search for the target by name.
I guess the easiest way would be to do a signature scan, to find out nearby npcs/players, and return the address/index.
Or try searching for offsets.
About 'hitting the monster', the easiest would be to do an auto clicker / simulate keys.
The other method might require calling assembly functions. (Attack function in our case)
Similar to this..