Jump to content
The Dark Mod Forums

Newbie DarkRadiant Questions


Recommended Posts

5 hours ago, Dragofer said:

@JackFarmer the circling suggests the AI is trying to get to a position but can't get close enough because something is in the way (monsterclip or the door). It might be the switch is too close to the door / the path_corner is too close to the switch or the door. I'd suggest spreading the switch & the path_corner out more.

(An AI can't get closer than 16 units to a monsterclip wall, and doors/moveables seem to dynamically create monsterclip walls around themselves).

Btw the correct way to use path_interact is to use "ent" spawnarg with the name of the entity to interact with.

a.  setup with path corners only, switch moved away from the sliding doors: no difference (AI walks in circles)

b. setup with path corners and path interact, switch at original position: works perfectly and looks like from a textbook (however, this setup causes the before mentioned problems when switches are used by other AI or the player)

Should "a" work in general? I cannot recall a previous mission with such a door/switch setup.

I have the feeling, that the AI does not "see" that the sliding doors are closed. I am just wondering how it works with regular doors. Does the code check the condition of the VP and therefore commands the AI to either open or close the doors? However, my sliding door includes a working VP as well.

Covering the sliding doors with identical solid brushes does not work as the brushes cannot be bind to the doors. Even if that would work, the code would not know that they are (the solid brushes) part of the door/switch setup.

I will try something with AAS Obstacle or MC/nodrawsolid as fs and have it linked to the doors.

Edited by JackFarmer
Link to comment
Share on other sites


Give me a simple test map with the AI, the path corners, the switches, the doors and their visportal, all monsterclip in the area, and I'll try to see what's going on.

When a mission is loaded, if a door has a switch targeting it, the door makes a list with all switches in it. When the AI approaches the door, and he's told by pathfinding that it's closed, the presence of a switch list should send him to the closest switch to open the door. Once he's through the open door, he'll go to the other switch and close the door behind him.


  • Like 2
Link to comment
Share on other sites

I have an archer with a lootbag. I'd like to set up a frob_action_script that fires when any arrow is stolen from his quiver. But not interfere with normal pickpocketing of the lootbag. Possible? (Or using other solutions, e.g, S/R ?)

Link to comment
Share on other sites

S/R is best for this, takes a total of 5s if you've done it before:

Select the pouch -> go to top and click Entity -> Stim/Response -> Response tab -> add Response 'frob' -> right-click & 'add' effect in the box on the right -> change the new effect to run_script with your thread name.

Plenty of other effects available too, and you can also make these happen in response to a 'Trigger' instead of a 'Frob'.

Link to comment
Share on other sites

For the new spawnarg-controlled func_mover STRUNK and I are developing I'd like to make it trigger its targets upon reaching certain positions (position # = the # of motions away from the starting point)

I've implemented this for a single position, but I'd like to allow the mapper to specify an indefinite number of positions via spawnargs.

For this I think I'm missing, and would appreciate advice on:

(1) something like numTargets and getTarget(#), but for my custom spawnarg series trigger_at_positionx instead of targetx

(2) the correct way to form this conditional: if(current_position == any of the positions retrieved by (1))


For (1), it looks like numTargets and getTarget(#) are hardcoded, so I'm not sure how I can derive something that works for a custom spawnarg.

For (2), all the C tutorials I found mention things like != and <=, but never something like if(number == 3, 4 or 7).

Edited by Dragofer
Link to comment
Share on other sites


Select the pouch -> go to top and click Entity -> Stim/Response -> Response tab -> add Response 'frob' -> right-click & 'add' effect in the box on the right -> change the new effect to run_script with your thread name.

OK, I'm stopped at the first step. In DR there's no pouch to select... but actually I'm interested in the arrows in the quiver, not the pouch. There is no quiver or arrow to select, but there are spawnargs, e.g., def_attach_3 atdm:prop_quiver_arrow.

I can of course select the archer, but then how does S/R know if it's the frobbing of the purse or the arrow that's appropriate?

Link to comment
Share on other sites

Setting up S/R for def_attached items is more complicated, but should work basically the same. The problem is that you cannot directly use the S/R editor, but have to create all the spawnargs manually. I would create a dummy entity and set up the response effects you want with the S/R editor. That way you have all the spawnargs you need. In order to set them up on the arrow, you have to give the arrow a name via the spawnarg "name_attach3" (e.g. "name_attach3" "special_arrow") and set each spawnarg that was created for the S/R on the dummy entity with "set XY on special_arrow" "YZ". See this Wiki-Page in the section "== Example, attaching a key to an AI == (bikerdude)". Not 100% sure if this works as intended, but it would be what I would try first. An alternative, that should definitely work, would be to write a new definition for the attached arrow: Again, use a dummy entity to create the S/R spawnargs. Then copy the definition of atdm:prop_quiver_arrow to a new definition file, rename the definition to a unique name (e.g. "atdm:prop_quiver_arrow_special"), add the S/R spawnargs created via the editor to the definition and change the spawnarg def_attach_3 on the AI to the new name. The latter alternative is especially useful, if you want to have this response on more than one AI, because you only have to set up the spawnargs once and can easily give the special arrow to various AI by changing the def_attach_3 spawnarg.

  • Like 2
Link to comment
Share on other sites


A simplified version of your first method worked for me. To the archer I added these spawnargs:

"name_attach3" "quiver_arrow"

"set frob_action_script on quiver_arrow" "FrobbedQuiverArrow"

And added the FrobbedQuiverArrow function to the <FM>.script

Edited by Geep
Link to comment
Share on other sites

This is, of course, also an option. I only think that you overwrite the regular frob_action_script that way. I am not sure what this does on the def_attached arrow (most likely add an arrow to the inventory), but if this is not important to you, it is fine.

Link to comment
Share on other sites


That's pretty weird indeed, Do you have filters on in darkradiant that might prevent you from seeing these in the editor? Did you try selecting only the arches and moving them up, and then see ingame if these "pataches" also moved? Did you try deleting things 1 by one, each time checking in game if the "patches" are still there, to sort out where they come from? Did you make it all func_static?

Just a few suggestions, for I really don't know what this is ...

Edited by STRUNK
Link to comment
Share on other sites

I'm trying to make a new target entity called target_keyval to be able to change the spawnarg value of an entity, like a door. So far the script is running and the sys.println(); prints the right strings to the console, but it does not work . Somehow $target_name.setKey("m_key","m_value"); doesn't take the strings I try to feed it. When I put it manually in the script it does work ...

#ifndef __TARGET_KEYVAL__
#define __TARGET_KEYVAL__

object target_keyval

	string	m_target_name;
	string	m_key;
	string	m_value;
	void	init();
	void	set_key_value();

void target_keyval::init()
	m_target_name			= getKey("target0");
	m_key					= getKey("set_spawnarg");
	m_value					= getKey("set_value");

void target_keyval::set_key_value()
	$m_target_name.setKey("m_key", "m_value"); //When I manually put $atdm_3panel_104x56_1.setKey("trigger_on_open","0"); it works.

#endif __TARGET_KEYVAL__

Does anyone have a clue how to fix this?


Edited by STRUNK
Link to comment
Share on other sites

I'm encountering the same issue with sys.waitFor(self) in a scriptobject for a new func_mover: it doesn't wait at all. The only time sys.waitFor() will work is if I put it in a map script and manually enter a name: sys.waitFor($func_mover_1). Won't work with placeholder names, i.e. sys.waitFor(mover_name);


When I put it manually in the script it does work ...

Is something like the below broken for you even when it's in a map script?

string spawnarg_name;
string spawnarg_value;

$door_1.setKey(spawnarg_name, spawnarg_value); 

If yes, then we may have encountered the same problem.

Link to comment
Share on other sites



Could be. I didn't try in map script. Maybe it should somehow be in an other syntax, or should be "fed" different but I tried all combinations, leaving at least one value "fed" by the script, but it only works if I manually type all values.

Here is defenition:



//Custom definition for target_keyval

entityDef target_keyval
        "inherit"                                "atdm:target_base"
        "spawnclass"                            "idTarget"
        "editor_displayFolder"                    "Targets"
        "editor_usage"                            "This function can change the key value of a spawnarg of a targeted entity."
        "editor_color"                            "1 0 0"
        "editor_mins"                            "-3 -3 -3"
        "editor_maxs"                                "3 3 3"
        "editor_var 1_set_ spawnarg"                    "Name of the spawnarg that should get a different value"
        "editor_var 2_set_ key"                        "Changes the key value of the set spawnarg of the targeted entity"
        "nodraw"                                "1"
        "scriptobject"                            "target_keyval"
        "frob_action_script"                    "set_key_value"
        "set_spawnarg"                                 "Name of the spawnarg"
        "set_value"                                 "New value for the spawnarg"
        //Stim/Response to call the frob_action_script when triggered.
        "sr_class_1"                            "S"
        "sr_type_1"                                "STIM_TRIGGER"
        "sr_state_1"                            "1"
        "sr_class_2"                            "R"
        "sr_type_2"                                "STIM_TRIGGER"
        "sr_state_2"                            "1"
        "sr_effect_2_1"                            "effect_frob"
        "sr_effect_2_1_arg1"                    "_SELF"


Summoning @Obsttorte  : P

Edited by STRUNK
Link to comment
Share on other sites

9 hours ago, STRUNK said:

I'm trying to make a new target entity called target_keyval to be able to change the spawnarg value of an entity, like a door. 


And you don't want to use the existing "target_setkeyval"?

Keep in mind that some spawnargs are read and initialized only at spawn time, and changing them later will have no effect.

  • Thanks 1
Link to comment
Share on other sites

Taking a closer look at your script line, the syntax is in fact off. It should be m_target_name.setKey(m_key, m_value).

When you use a $ you tell the script to look for an entity in your map that's actually called m_target_name, but what you really want is to use m_target_name as a placeholder for whatever your init script found when it did getKey("target0"). That needs no $.

Similarly for m_key and m_value, when you put those in quotations you're telling the script to literally set a spawnarg "m_key" with the value "m_value". But again, you want to use them as placeholder names so they should be input without any extra formating.

$m_target_name.setKey("m_key", "m_value")
Edited by Dragofer
  • Thanks 1
Link to comment
Share on other sites

Also, you can make a repeating script to find and apply to all targets. In this case I just triggered the targets.

float i;				//integer
entity target;			//placeholder name for any targets found

for( i = 0; i < numTargets( ); i++ )
		target = getTarget(i);


If anyone could show me how to do this for other spawnargs than "target" I'd very much appreciate that.

Edited by Dragofer
  • Thanks 1
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

    • The Black Arrow

      I was playing Skyrim, got bored fast. Got back to The Dark Mod just for one mission, played "Somewhere above the City" which is not really a great mission but still good, as in above-average.
      My biggest regret is living in this country, where there's a heat wave, I am sweating at 20c and I really wish for temperatures below 5c.
      · 10 replies
    • Skaruts

      Is there something wrong with the forums lately, or is it my browser? I've been having trouble formatting posts, and just now I couldn't format anything at all.
      I'm using Vivaldi.
      Usually I have to: select text, click bold, nothing happens, select again, click bold, then it works. 
      Same for other stuff, like creating spoilers, bullet points, links. Nothing works the first time. 
      · 1 reply
    • STiFU

      Back from a spontaneous 1-week trip to Lanzarote with wife and son. I hope beta testing has been going well...
      · 1 reply
    • datiswous

      Whenever I eat fried chicken these days I think of this scene in The Black Mage..

      · 1 reply
    • Mortem Desino

      Even though I've been absent a long while, I still find myself dreamily wishing for the free time to do TDM mission development. When working on new research projects I'll find myself involuntarily thinking, "hee hee this could be a fun texture or readable or bit of map architecture." Or I find myself absentmindedly responding out loud to odd noises with a drunkguard-like "must've been rats!"
      · 3 replies
  • Create New...