I guess, in this situation you could use the object linking extension.
When the player get in to a car, simply link the actual car object to the player and when you move the care, take in to account only the one that is linked to the player. After, when the player get out of the car just simply delete the link.
This is exactly the kind of situation when the object linking extension is useful.
Maybe you could take advantage of the object linking in this case too:
Condition: “Pick a random group_car”
Action: link group_car to testman
Condition: Take in to account all group_car linked to testman
Action: Move testman to goup_car.X(), group_car.Y()
Also, don’t forget, when testman stop driving, delete the link in case you want him to pick an other random car again, but in case you want the npc to stick to the same car, you can leave the link.
But in case you have multiple npc’s looking for a car, accidentally they may pick the same car…
It could be fun actually more npc trying to get the same car
but in case you don’t want that, you may need to use an object variable for each car to store information if the car is picked by an npc already or not.
Just do the following :
At the beginning
For each group_car repeat: (this is an actual event, do not ignore it, you need to use this special for each event):
Do = 0 to group_car.Variable(picked)
This way you set the variable for each instance of each car in the map. And when you pick one, check the variable first:
Condition: “Pick a random group_car”
Sub-Condition: group_car.Variable(picked) = 0
Action: link group_car to testman AND Do = 1 to group_car.Variable(picked)
Condition: Take in to account all group_car linked to testman
Action: Move test man to goup_car.X(), group_car.Y()
This way, a car going to be linked only to a single testman, but there is an other problem. If a car is already picked, the testman need to attempt to pick an other random car again, and again, and again until it find a free one, to do that, you could put the actual car picking event in to an external event end just run it until the npc find a free car or you can use a while event to run the pick car events while the npc find one that is free.
As an alternative, at the beginning maybe you could just link a car to an npc manually through object variables.
Try something like this:
Testman:
Do = 1 to Variable(counter)
For each testman repeat:
Do = Variable(counter) to testman.Variable(ID)
Do + 1 to Variable(counter)
Group_Car:
Do = 1 to Variable(counter)
For each group_car repeat:
Do = Variable(counter) to group_car.Variable(ID)
Do + 1 to Variable(counter)
This events going to generate unique ID number for each testman and car.
Link each testman to the car with the same ID:
Main event: For each object testman:
-------Sub event:For each object group_car:
----------Sub even: testman.Variable(ID) = group_car.Variable(ID)
-------------Action: link group_car to testman
Move each testman to the linked car:
For each object testman:
Condition: take in to account all group_car linked to testman
Action: Move testman to group_car.X(), group_car.Y()