Jump to content
The Dark Mod Forums

Access an entity created by def_attach from a script


Recommended Posts

I've been trying to finish off a handful of projects and experiments I had started a while ago, and remembered that I ran into a roadblock.  I was trying to build some custom entities with slightly complex behavior and had wanted to access a def_attach'd entity from the script on its parent object.  These script functions sounded pretty close:

scriptEvent entity getAttachment(string attName);

Get the attached entity with the given attachment name Will be NULL if the name is invalid or if the entity no longer exists
Spawnclasses responding to this event: idActor

scriptEvent entity getAttachmentInd(float index);

Get the attached entity at the given index. Will be NULL if the index is invalid or the entity no longer exists
index: starts at 0
Spawnclasses responding to this event: idActor

scriptEvent float getNumAttachments();

Return the number of attachments on an AI. Used to iterate through the attachments if desired.
Spawnclasses responding to this event: idActor

But as you can see, they only apply to idActors.  I dug into the source code and found that the code that handles all 3 of these functions just calls into the idEntity base class to retrieve the attachment, and there does not appear to be anything specific to idActor with those.  As such, I'm fairly certain that these script events could be moved to idEntity without breaking any existing usages (assuming script event inheritance works as expected).  Are there any downsides to doing this? 

I can create a bugtracker entry and/or provide a patch if there are no objections.

Link to comment
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.

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.


  • Recent Status Updates

    • peter_spy

      Perhaps an unpopular opinion: TDM team might benefit from someone with actual QA experience; someone with naturally and professionally developed curiosity, who is interested in how and why things work, how they break At least to me it's kind of mind-boggling how untested some rather important features are (first the absence alert feature for items, now the rope +body carry behavior).
      · 4 replies
    • nbohr1more

      The Dark Mod is hosting an Ask Me Anything thread on the PC Gaming reddit forum:  https://www.reddit.com/r/pcgaming/comments/10nfcwj/hello_we_are_the_international_development_team/
      Feel free to join the discussion there
      · 2 replies
    • stgatilov

      Bumped into an interesting piece of wisdom called Hyrum's Law:
      With a sufficient number of users of an API, it does not matter what you promise in the contract: all observable behaviors of your system will be depended on by somebody.
      · 5 replies
    • The Black Arrow

      I love playing The Dark Mod when it's cold in my place. Bonus points when it's a bit (or even very) dark and it's raining, too.
      · 2 replies
    • The Black Arrow

      I've been having stutters in Vulkan, apparently it's Nvidia Drivers' fault, so I reverted to 512 according to this: https://www.nvidia.com/en-us/geforce/forums/geforce-graphics-cards/5/505679/regular-microstutter-in-vulkan-applications-after-/?topicPage=40

      And no, that did NOT fix it. What's going on? My GPU is an RTX 2070, by the way.
      · 4 replies
  • Create New...