Jump to content
The Dark Mod Forums
Sign in to follow this  
kingsal

Getting entity names in volume.

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

Share this post


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

 

Share this post


Link to post
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

Share this post


Link to post
Share on other sites

(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

Share this post


Link to post
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

WIP's: Several. Although after playing Thief 4 I really wanna make a city mission.

Mapping and Scripting: Apples and Peaches

Sculptris Models and Tutorials: Obsttortes Models

My wiki articles: Obstipedia

Texture Blending in DR: DR ASE Blend Exporter

Share this post


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

 

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  

×
×
  • Create New...