Coding

 Reply to this postStart new topic

Entity types

DK22
post Jan 23 2012, 05:23 PM
Post #1


Member

Posts: 197
From: Liberty City, Shoreside
Joined: 15-July 10



I have the CPlaceable adress, how can I check is it car/ped/building etc.?
Go to the top of the page
 
+Quote Post
Deji
post Jan 23 2012, 08:06 PM
Post #2


Coding like a Rockstar!

Group Icon

Posts: 1,468
From: ???
Joined: 28-May 09



There are lots of ways, really.

You can just check the value of the VMT field matches the VMT base address of a ped/vehicle etc. But you have to ensure to get all the right VMT addresses. For example, your code might end up assuming the pointer is not of a ped, because it doesn't match the CPed VMT address.

You can loop through the entity pools and see which one has a pointer that matches. Of course, this way takes a lot more processing. However, it can be considered more sensible than checking the address of the VMT.

Unfortunately, the best solution is also a solution which you'll have to do some documentation for first.. CEntity has members in which should actually specify what type of entity it is. There is the model (but model checking is probably not such a good idea). And of course...
CODE
00000036 info            db ?                   ; object type (low 3 bits: 0 - object, 1 - building...


The low 3 bits apparently specify the object type... perhaps the rest of the flags contain info on what other type of entity it is. I recall seeing functions in SA using SOMETHING in the CEntity class ot check the entity type. But I can't recall where and the CEntity class is surprisingly not yet fully documented.

So if you find anything else out about CEntity, please share smile.gif


--------------------
Go to the top of the page
 
+Quote Post
Deji
post Feb 9 2012, 01:57 PM
Post #3


Coding like a Rockstar!

Group Icon

Posts: 1,468
From: ???
Joined: 28-May 09



Probably a bit late now, but MTA had an enum of entity types (almost certainly provided by R*):
CODE
enum eEntityType
{
    ENTITY_TYPE_NOTHING,
    ENTITY_TYPE_BUILDING,
    ENTITY_TYPE_VEHICLE,
    ENTITY_TYPE_PED,
    ENTITY_TYPE_OBJECT,
    ENTITY_TYPE_DUMMY,
    ENTITY_TYPE_NOTINPOOLS
};


Defined where I said, in the class:
CODE
    //********* BEGIN CEntityInfo **********//
    BYTE nType : 3; // what type is the entity              // 54 (2 == Vehicle)
    BYTE nStatus : 5;               // control status       // 54
    //********* END CEntityInfo **********//


Definitely the best option wink.gif


--------------------
Go to the top of the page
 
+Quote Post
DK22
post Feb 12 2012, 12:56 AM
Post #4


Member

Posts: 197
From: Liberty City, Shoreside
Joined: 15-July 10



Something like this
CODE
a = byte [Entity.type] // 0x36
a & 7 // and
if a == ENTITY_TYPE_VEHICLE
Go to the top of the page
 
+Quote Post
Wesser
post Feb 12 2012, 10:05 AM
Post #5


The Assistant

Posts: 84
From: Matera, IT
Joined: 16-June 11



When I was writing the Full Nitro Control mod, I did these findings:

CEntity + 0x36 - [byte] Entity type:
0x02 = Player as driver
0x12 = Quiet driver
0x1A = Suspicious driver (when slightly or heavily collided, unlike cops who are never quiet)
0x22 = No driver
0x2A = Destroyed
0x4A = Player as driver is exiting or being wasted, busted or hijacked

This post has been edited by Wesser: Feb 12 2012, 11:07 AM
Go to the top of the page
 
+Quote Post
Reply to this postStart new topic

1 User(s) are reading this topic (1 Guests and 0 Anonymous Users)
0 Members: