Jump to content
The Dark Mod Forums

Getting entity names in volume.


kingsal

Recommended Posts

Hello, something I've always been curious about:

Is there a way to get name or class of items within a certain location or volume and store this list somewhere?  Can anyone think of a map or something in the core mod that does this that I could look at. Scripts examples are preferred, rather than source code.

Related to this:

Can I look for entities by name or class within a map? For instance if I want to search for all entity names beginning with string "Guard" and return a list of names "$Guard_01, $Guard_02, ect.."

 

Would be really helpful to know,

Thanks!

 

Edited by kingsal
Link to comment
Share on other sites

13 minutes ago, kingsal said:

get name or class of all items within a certain location  or volume

You can probably use a brush with trigger_touch to achieve that effect. When activated it calls its script on all touching_ents (entities touching its volume), so you could let that script print the names of all those entities to the console and then make a condump. (this is assuming you want a list outside of the game).

Create a trigger_touch brush entity, name it "trigger_touch_brush", give it the spawnarg "call" "retrieve_names", add the below script to your map script, run the map and then use the console command "condump name_list.txt" to get a .txt into your darkmod folder.

void retrieve_names(entity touching_ent)									//gets called for each entity within the trigger_touch
{
	string touching_ent_name	=	touching_ent.getKey("name");
	string touching_ent_classname	=	touching_ent.getKey("classname");

	sys.println("classname is: " + touching_ent_classname + ", name is: " + touching_ent_name);
}


void main()
{
	sys.waitFrame();
	sys.trigger($trigger_touch_brush);	//activate trigger touch
	sys.waitFrame();
	sys.trigger($trigger_touch_brush);	//deactivate trigger touch after one frame because it's very expensive
}

Come to think of it, it'd actually be helpful for both your questions to know if you need this list as a .txt. for your reference or if you want to use these names ingame for scripting.

 

Link to comment
Share on other sites

Ah okay great! I didn't realize  trigger touches call down to entities. This is exactly what I am looking for! I'll be using the list in game, probably stored in blank strings variables to use later.

Ill give this a try and report back, thanks!

Edited by kingsal
Link to comment
Share on other sites

  • 1 month later...

(Late reply, I know.) The painful bit if you want anything useable in-game is storing/using your list, because of DoomScript's lack of arrays/lists/etc. But it can be done:

On the other question, check the Script Reference docs for getNextEntity().

Some things I'm repeatedly thinking about...

 

- louder scream when you're dying

Link to comment
Share on other sites

5 hours ago, VanishedOne said:

The painful bit if you want anything useable in-game is storing/using your list, because of DoomScript's lack of arrays/lists/etc.

Haven't looked at the linked script, but arrays can be faked using in game entities to store them, for example by storing them as spawnargs on worldspawn (can be referred via $world) or if you want a behaviour like typical array-styled containers by writing a scriptobject that mimics the behaviour.

 

Trigger_touches as proposed by Dragofer are an option, but iirc they only react to entities that can get into the volume on their own (player, ai and probably moveables). Also, having several of them can become performance houngry. In addition I guess youdon't want to check what's inside the boundaries continuosly but only in specific situations?!

FM's: Builder Roads, Old Habits, Old Habits Rebuild

Mapping and Scripting: Apples and Peaches

Sculptris Models and Tutorials: Obsttortes Models

My wiki articles: Obstipedia

Texture Blending in DR: DR ASE Blend Exporter

Link to comment
Share on other sites

6 hours ago, Obsttorte said:

Trigger_touches as proposed by Dragofer are an option, but iirc they only react to entities that can get into the volume on their own (player, ai and probably moveables). Also, having several of them can become performance houngry. In addition I guess youdon't want to check what's inside the boundaries continuosly but only in specific situations?!

It's the regular trigger brushes that only react to either AIs or the player walking into them, trigger_touch works differently by checking for all entities that are in contact with it (within or "touching"). I always only activate it for a single frame before deactivating it.

I suppose a clean & flexible way to check for entitities in a volume would be to use getNextEntity and check whether its origin lies within a certain volume(s) demarcated by 2 points. If it needs to be more precise, you could maybe use getMins and getMaxs to find the dimensions of the entity's bounding box to check whether it overlaps with the volume, or else use a trigger_touch brush to do this for you.

Btw, I found findActorsInBounds(vector mins, vector maxs); in the TDM script reference, that could come in handy at some point depending on what kingsal is doing.

 

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.

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.

  • Recent Status Updates

    • OrbWeaver

      Does anyone actually use the Normalise button in the Surface inspector? Even after looking at the code I'm not quite sure what it's for.
      · 3 replies
    • Ansome

      Turns out my 15th anniversary mission idea has already been done once or twice before! I've been beaten to the punch once again, but I suppose that's to be expected when there's over 170 FMs out there, eh? I'm not complaining though, I love learning new tricks and taking inspiration from past FMs. Best of luck on your own fan missions!
      · 4 replies
    • The Black Arrow

      I wanna play Doom 3, but fhDoom has much better features than dhewm3, yet fhDoom is old, outdated and probably not supported. Damn!
      Makes me think that TDM engine for Doom 3 itself would actually be perfect.
      · 6 replies
    • Petike the Taffer

      Maybe a bit of advice ? In the FM series I'm preparing, the two main characters have the given names Toby and Agnes (it's the protagonist and deuteragonist, respectively), I've been toying with the idea of giving them family names as well, since many of the FM series have named protagonists who have surnames. Toby's from a family who were usually farriers, though he eventually wound up working as a cobbler (this serves as a daylight "front" for his night time thieving). Would it make sense if the man's popularly accepted family name was Farrier ? It's an existing, though less common English surname, and it directly refers to the profession practiced by his relatives. Your suggestions ?
      · 9 replies
    • nbohr1more

      Looks like the "Reverse April Fools" releases were too well hidden. Darkfate still hasn't acknowledge all the new releases. Did you play any of the new April Fools missions?
      · 5 replies
×
×
  • Create New...