Sign in to follow this  
Salk

[KotOR] GetObjectByTag() & objects population

Recommended Posts

Hello!

I am hoping someone ( @DarthParametricor @JCarter426, maybe?) could help me figure something out.

During my testing I have been wondering in what order the game engine populates objects of the same kind and I was surprised when I made a specific test (with minimal intrusion affecting the original game installation). After the name of the object in the function GetObjectByTag(), it is possible to identify the nTh object bearing the same tag but which one in the area gets the "zero" and the successive numbers?

My test was in the Taris - South Apartments module (tar_m02aa) where we have four doors with the same tag (ptar_lockde).  One of the rooms that have such door is the room where Dia is. When I leave the Taris Apartment for the first time, there will be a cutscene and a fight. After that, I discovered that the door to Dia's room was identified as 1, meaning the remaining three doors were 0, 2 and 3.

But when the same area is reloaded (and it does not matter if it is after I save and then load or if I leave the area and then return) it seems the doors no longer have the same enumeration. Now door 1 is the next one anti-clockwise (the room that houses a female Twi'lek).

How do we make heads or tails out of this? Am I missing something obvious?

Thanks!

Share this post


Link to post
Share on other sites

I would imagine the first time in a module should be the spawn order, subsequent visits should be based on the stored GIT order.

Edit: That was kind of poorly worded. It's still spawn order in both cases, it's just that the starting module GIT ordering is not retained in the game save GIT. So the real question is "how does the engine decide the struct order when creating a GIT?".

  • Like 1

Share this post


Link to post
Share on other sites

Interesting.

But wouldn't this create havoc for all scripts that can run more than once and that trust identifying the same object each time?

Share this post


Link to post
Share on other sites

Well it's a good example for why you should always use unique tags, at least for anything plot-critical. There are a few vanilla examples where they have to tie themselves in knots to nail down a specific object like a door because there are half a dozen other objects in the level with the same tag. It's no doubt why functions like GetNearestObjectByTag exist. But then again they do rely on duplicate tags quite a bit to handle things like animating placeables, dealing with trash mobs, etc.

  • Like 1

Share this post


Link to post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Sign in to follow this