Get index of newly created client side tempent

greatguys1

Epic Adventurer
MSC Developer
Warriors of the North
MSC Archivist
Joined
Apr 20, 2013
Messages
339
Reaction score
60
Age
26
Location
Yes
I was wondering if there was a way to grab the index of a tempent (either model or sprite) in the same fashion as ent_lastcreated, or game.script.last_light_id? From within the same client side script
 

Thothie

Administrator
Staff member
Administrator
Moderator
MSC Archivist
Joined
Apr 8, 2005
Messages
16,342
Reaction score
326
Location
lost
Closest I can think of is game.tempent.index inside any update event. There is no way to modify a tempent outside of its setup and update events, but you can read its location, etc in that fashion. The same index may be referenced serverside via $get_by_idx(), provided you return the index back to the server, otherwise it's $getcl().
 

greatguys1

Epic Adventurer
MSC Developer
Warriors of the North
MSC Archivist
Joined
Apr 20, 2013
Messages
339
Reaction score
60
Age
26
Location
Yes
This always seems to return 0 in either the setup or update event, on either sprites or models.
I tried this in both events:

infomsg all game.tempent.index $getcl(game.tempent.index,index)
 
Last edited:

Thothie

Administrator
Staff member
Administrator
Moderator
MSC Archivist
Joined
Apr 8, 2005
Messages
16,342
Reaction score
326
Location
lost
Bleh, indeed... That is going to be a problem in at least one script. Shall examine for a quick code side fix.
 

Thothie

Administrator
Staff member
Administrator
Moderator
MSC Archivist
Joined
Apr 8, 2005
Messages
16,342
Reaction score
326
Location
lost
Blarg... Seems I've run into this before, judging by a code note from 2018...

Code side, I've tried clientindex, entity.index, entity.curstate.modelindex, entity.curstate.number, adding a new int cl_entity_s::GetIndex() that just returns the index, pulling g_CurrentTempEnt directly, instead of via p->, doing it all both inside and outside CLGetEntProp(), and maybe a half dozen other things - everything returns 0.

But it must have some sorta index, or it wouldn't know how to reference the darn thing for any information - lest tempents are weird, and can only be referenced sequentially as they are rendered or some such... Gonna consult with MiB.

Meantime, for SOME sorta reference, all I can figure you can do is store a counter under iuser1 or fuser1 (possibly to be stored in an array). It won't let you pull any information from the tempent, but it will let you track which tempent is which inside the update event by uniquely identifying it (and if need be, allow you to store any information you need from it, outside of the update event, into an indexed array) - if that helps your effort at all.

...and I'm going to have to make a note to fiddle with the affected scripts - don't think they actually need to reference the index in this case though, just the origin, which pulls up fine via game.tempent.origin. (edit: Looking at them more closely, seems they were just debugs that resulted in said code note - gah, memory.)
 

Thothie

Administrator
Staff member
Administrator
Moderator
MSC Archivist
Joined
Apr 8, 2005
Messages
16,342
Reaction score
326
Location
lost
I don't think it's possible. I put a debug in the create function. Got SOME stuff out of the attached entity, but it never has an index or modelindex. The engine must be doing something weird with them under the covers, though I've no idea what.
Yeah, boned. Think they just can't be indexed save at render.

Again, you can tag them at creation to tell them apart inside the update event via fuser1 or iuser1, but that seems to be a limitation from the engine end. My bad for misleading ya, coulda swore that worked.
 

greatguys1

Epic Adventurer
MSC Developer
Warriors of the North
MSC Archivist
Joined
Apr 20, 2013
Messages
339
Reaction score
60
Age
26
Location
Yes
No problem. I was trying to create a way to tether beams to a monster and offset it. I would've done this by getting accepting two monster idxs and two offsets, then spawning a tempent at the desired offset then beam those together, and follow it too. It seems I might be able to hack it by getting the beam id & updating the start & end positions whenever the tempents do. Not sure if it's possible yet but I'll get back to you on that.
 

Thothie

Administrator
Staff member
Administrator
Moderator
MSC Archivist
Joined
Apr 8, 2005
Messages
16,342
Reaction score
326
Location
lost
Eh, if you used attachments, that might be possible - would need to tweak the model though. (Less screwy server side, but also much more resource heavy.) If it's supposed to work on any mob - hrmm... Sadly no hacky way to add attachments - but if you can calc the vectors, the beam update system might let you pull it off. Vectoradd $relpos([angs],[offset]) from where you would have put the tempent, I suppose, and increment the offset or angs every 0.01 seconds (if client side, dun attempt that rapid fire server side).

Hybrid solution would be to make an invisible model with attachments you could overlay on the mob - maybe animate it for the desired beam movement.

Probably misunderstanding this though - bleery as hell, and probably shouldn't be doing major code surgery just now.
 
Top