New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Added MemoryAccess class #191
Conversation
|
Whoops, build fails. You should update ScriptHook version, it has a new function to get game version. Or instead implement it without ScriptHook... |
|
Very nice! (Typo: MemoryAccess::GetEtityHandleList() is missing an 'n'.) |
|
They store all entities in one pool... Understandable with all these entity natives |
|
|
||
| for (int i = 0; i < entities->Length; i++) | ||
| { | ||
| if (Native::Function::Call<bool>(Native::Hash::DOES_ENTITY_EXIST, entities[i])) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Maybe, you should use IS_ENTITY_AN_OBJECT ?
|
Scripthook version is updated, can you try building again @crosire? |
|
Did address change after last patch? |
|
@JohnnyCrazy , today released the new version of scripthook. |
|
Need to mention that I don't have the steam version and I took the memory offset from this thread: http://gtaforums.com/topic/795898-is-there-a-way-to-get-all-vehiclespeds-yet/?p=1067571965 So it might not work on steam version. |
|
May suggest waiting til the new pool offsets are found before committing this |
|
By the way, do we need Vehicle[] allVeh = World.GetAllEntities().Where( ent => Function.Call<bool>( Hash.IS_ENTITY_A_VEHICLE, ent.Handle ) ).Cast<Vehicle>().ToArray();and etc |
|
If someone can find memory dumps of all the different versions I could try to find offsets. |
|
Having get all peds, props, vehicles and entities is the best bet. It's quicker getting a list of vehicles through memory access class than it is to get a list of entities, then check each one to see if it's a vehicle then make a new list for vehicles |
|
But all entities including are in one list, unlike previous GTA games. So I think putting a few functions like GetAllVehicles etc. for convinience is a good idea. Edit: and, considering this pool contains the maximum of 300 entities it shouldn't affect performance. |
|
Any thought @crosire , @JohnnyCrazy ? |
|
I agree, there is a lot of boilerplate code. Since there are no anonymous lambdas in c++ CLI, what about following approach: array<Ped ^> ^World::GetAllPeds()
{
array<Entity ^> ^entities = GetAllPeds();
return System::Array::FindAll(entities, gcnew System::Predicate<Entity ^>(Entity::IsPed));
}
//And so on for Props/VehiclesThis would just require 3 Functions in the Entity-class ( But wait for @crosire first :) |
|
@JohnnyCrazy should I add these functions to the Entity class? Sounds like we really need them. |
|
Oh and btw, I am working on a signature scanning solution so we don't have to hardcode offsets for each version. |
|
@Sergeeeek You wouldnt be able to add functions for peds/props/vehicles to the entity class as they reference the entity class |
|
@Sergeeeek will need checking RW - 0x2A08808, Steam - 0x2A0DE50 |
|
@Zorg93 nvm, gonna add signature scanning in the next commit. |
|
is that not going to be rather slow |
|
@Zorg93 it's done only once per launch and only creates a minor lag spike, haven't measured it but it's hard to spot in the game. |
|
Ah, makes sense, May try and figure a way to automatically get global address pointer aswell |
|
So I though I could add methods like IsPed, IsVehicle and such as static methods to the Entity class. Is that a good idea? And should I do it in separate pull request? |
|
@Sergeeeek |
|
Also, could someone test if signature scanning works with different game versions? I tested with 1.0.350.2 nosteam version. It should be fine but it's better to test it anyway. |
And a few functions to World class to read entities directly from memory. I'm a bit of a C++ noob so code will probably have to be refactored...
No need to hardcode offsets anymore.
|
Once the appveyor builds I'll test with 1.0.372.2 NOSTEAM, how should I test, just call get all entities and see how many it finds? |
|
@Zorg93 yeah, just call one of the new functions and see if it returns anything. |
|
@Zorg93 awesome! |
|
Just need someone to test on one of the steam builds, I've looked at the code in ida and it looks identical so i see no reason for it to fail |
|
Works fine on latest steam version. |
|
Sooo, @crosire ? |
| { | ||
| if (Native::Function::Call<bool>(Native::Hash::DOES_ENTITY_EXIST, entities[i])) | ||
| { | ||
| Entity^ ent = (Entity ^)gcnew Prop(entities[i]); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Wait, this is wrong, we shouldnt do this. Will write more tomorrow.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Agreed, that makes all returned entites props, which (according to the function name) isn't the case. There could be peds or vehicles in there too.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
something like this would be better
if (Native::Function::Call(Native::Hash::DOES_ENTITY_EXIST, entities[i]))
{
if (Native::Function::Call(Native::Hash::IS_ENTITY_A_PED, entities[i]))
{
ents->Add(gcnew Ped(entities[i]));
}
else if (Native::Function::Call(Native::Hash::IS_ENTITY_A_VEHICLE, entities[i]))
{
ents->Add(gcnew Vehicle(entities[i]));
}
else if (Native::Function::Call(Native::Hash::IS_ENTITY_AN_OBJECT, entities[i]))
{
ents->Add(gcnew Prop(entities[i]));
}
}
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yea, then we also don't need Entity.IsVehicle (...) methods, since we can use ent is Vehicle.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@JohnnyCrazy ok, sounds like a good idea. I did it in the first place because you can't create Entity because it's abstract and Prop only has a constructor redefined and no additional properties or functions.
|
Ok, I think I used the wrong pool address. The current pool this code uses only has entities like peds and vehicles (no objects) what are also not that far away. So basically you can't just get ALL entities from this pool. I think I found the right one though, gonna investigate more. |
|
I noticed this address has issues, but It did find some props. |
|
@Zorg93 oh, maybe it's only objects with activated physics then. I've made some tests with getting all entities and applying force to them, not all entities reacted (peds don't react at all until you push them, aka activate physics on them). Especially noticeable on objects that are about 30-40 meters in front of you, they are never affected by this. |
|
@Sergeeeek Its not just that, Things like Police helicopters I could never find, sometimes police swap guys would be found other times they wouldnt, It seemed random, even when they were close to me |
|
Merged (even though Github fails to see that) =). |

And a few functions to World class to read entities directly from
memory. I'm a bit of a C++ noob so code will probably have to be
refactored... Should fix #13