Jump to content
The Dark Mod Forums

Newbie DarkRadiant Questions


demagogue

Recommended Posts

Three little questions. It's for prefabs I'm making and planning to offer to other mappers, might make some good stuff if I figure these out.

  1. How can I designate a button that will be pressed by an AI who becomes alert, so whenever someone catches you they run to and press that button? I think I have this one figured out but would like for someone to confirm: I create a path_flee_point, which targets a path_interact, which has the button meant to be pressed as its ent. Only problem is that the paths wiki page doesn't clarify if a path_flee_point can target another path entity like a path_corner, in order to tell the AI what to do after they fled to that spot... can it do that or is it only meant to indicate a location to flee to?
  2. How do I create a lock that triggers something other than a door? What I mean by this is: I want a lock just like the ones you find on chests, it can be frobbed and either unlocked with a key or lockpicked... however once you unlock and activate it, it's not a door that opens but something else getting triggered. I pretty much want a lock-button, like say a light you can only turn on / off with a lockpick or key used on a keyhole on the wall. I don't know how to do this one as locks are always a property of atdm:mover_door entities, I've never or rarely seen them used as secure buttons for something else.
  3. What's the best way to draw a laser beam that can be toggled, but only by using the existing assets? There are three ways I'm thinking of going about this: One is to simply use a cylinder patch textured with a light texture, the "hide" flag can be used to toggle it. Another is to use a particle emitter, however I'm not aware of a good particle definition that would do the trick. The last is to use a fog light with its box radius adjusted in the shape of a stick... kinda leaning toward this one as it would then cast shadows too, will prolly go ahead and attempt it then consider other methods if that fails.
Link to comment
Share on other sites

Confirming my concern for #1 above: Fleeing AI (not armed ones either which is also a problem) will run to the flee point, however they ignore any path the flee point targets. Any way to work around that, without using a custom script?

Also don't worry about #3: I found the available options and am playing with them now.

Edited by MirceaKitsune
Link to comment
Share on other sites

Cheers! Regarding the lockbox: atdm:froblock works perfectly for what I want, I got it to turn off a lamp when being unlocked which is exactly what I wanted. There are just two problems with it at the moment:

  1. It will activate with a key, but not when being lockpicked; It allows me to use the lockpick on it, but once I'm done it doesn't unlock and I can't pick it any further. I tried both the setup in that post and the intended "lock_picktype t" + "lock_pins 10": I can successfully use the triangle lockpick on the box once, but once picked nothing will happen!
  2. Once unlocked with the key and having triggered its target, the lockbox can no longer be frobbed again. I wanted to have it so that after being picked it can be toggled like a button, plus locked again if using its key on it.

Screenshot_20201122_163722.png.61f749d0ceff9837dfbb4e3897e1a77d.png

Regarding the beam: I actually missed func_beam which is so much better than the path cylinder I was using! Got it to work very nicely... with just a little detail I'd like to change: Is there any way to make the beam cut off when any player or AI or object is standing in front of it? Or can it only render at a fixed length all the time?

Looking great otherwise... especially when used with a super thin light source to have the dot of light shine at its end too! Time for some DeusEx style traps and alarms, likely to be featured in my next FM as well :D

NuUIe0F.jpg

  • Like 1
Link to comment
Share on other sites

1 hour ago, STRUNK said:

@MirceaKitsune

About the lock I don't know how to do that ...

For the func_beam, it is just a beem between the 2 func_beams, so if it has to stop where something is in between, you should have the receiving func_beam move to the position of the surface of what is in between somehow ...

Okay. I'll wait for answers on the lock and play with it some more in the meantime... there must be a spawnarg to fix that problem. Otherwise I'm not aware of a way to make the targeted func_beam move to the nearest surface in the direction of the targeting func_beam, that I'll probably have to leave as is.

Please also let me know if there's any way (no custom script though) to make an AI run to a button and press it when alert, ideally before attacking the target it saw that alerted it. Even path_flee_point won't do anything when the AI runs there no matter what I target it to :(

Update: Fixed the lock issue. The problem seems to be that I was setting lock_pins to 10, its value must only range between 0 and 5 apparently.

Edited by MirceaKitsune
Fixed the lock issue
Link to comment
Share on other sites

4 hours ago, MirceaKitsune said:

with just a little detail I'd like to change: Is there any way to make the beam cut off when any player or AI or object is standing in front of it?

As per the TDM Script Reference wiki page, you can do a trace from the beam's origin to check whether there are solid bodies in that direction, then place the beam's end wherever that collision has taken place. Supplementary script functions even let you figure out which bone on an AI was hit, for example. The below function is the main one:

Quote

scriptEvent float trace(vector start, vector end, vector mins, vector maxs, float contents_mask, entity passEntity);

Returns the fraction of movement completed before the box from 'mins' to 'maxs' hits solid geometry when moving from 'start' to 'end'. The 'passEntity' is considered non-solid during the move.

For making an AI run to a button to start an alarm when alerted, as far as I can tell there's currently no inbuilt support for this behaviour in TDM. The path_flee would only kick in if the AI is badly wounded or unarmed. It'd be worth opening a bugtracker entry for this.

  • Like 1
Link to comment
Share on other sites

How do you hide a light entity based on distance, so that it doesn't render and eat up performance once the player is far enough? I tried "dist_check_period 1" with "hide_distance 100" but even from very far it still renders and is unaffected (even after dmap).

Also I only want the light source to turn off, not for the whole entity to be hidden meaning the light model itself would also disappear. It would be ideal if the light could fade between a min_dist and max_dist, only stop rendering once max_dist is reached... if the player can still see it relatively well they don't notice it snap on / off but rather gradually.

Link to comment
Share on other sites

  • 2 weeks later...

I've got a fortune teller working, using the card playing animation, but with a female mage body (and its maiden voice) and legacy head. I've replaced the default female mage vocalization with a custom one that inherits from it, but substitutes fortune-telling-appropriate (but stock) phrases during idle aka snd_relaxed.

My problem is that she says something only every 30-60 seconds. I want her to be much more chatty, saying a phrase every 10 seconds. Anyway to do that? I tried reducing the "idle_animation_interval" from 12 to 6 seconds. I think it increased the frequency of card playing, but not of vocalization.

There's  lot of different "idle" animations, and its not always obvious which ones support concurrent vocalization.

  • Like 1
Link to comment
Share on other sites

There are spawnargs to control the frequency of barks.  I don't recall what they are but you can look through the AI defs for them if someone else doesn't get to it first.  They aren't related to animations at all.

  • Like 1
Link to comment
Share on other sites

I'm trying to prepare a test case for something I plan to have in some FM's: Friendly AI who talk when frobbed... it''s mainly greetings or other conventional voices, just a detail but one I'd like to have. There are quite a few issues I'm not sure how to work around in this, especially without a custom script.

So far I added my AI, the atdm:conversation_info entity, and the atdm:target_startconversation entity. The conversations themselves are set up, a simple talk action on the actor of the AI. The AI has the flag "frobable 1": I can tell this works as his body lights up when you look at him (not the head but that's probably an internal issue).

The first problem is how to make the AI trigger the startconversation target when frobbed. Using "target atdm_target_startconversation_1" doesn't work, which is probably for the best as that's meant for path_corner entities. Is there something like a "target_onfrob" spawnflag that I should be using here?

The last problem would be how I could possibly turn off idle conversations while the AI is alert and obviously when they're dead! Considering I plan to make use of alliance changing too, I'd also like to turn the frob off when an AI is no longer your ally... you don't want clicking on a guard that's going to attack you if he sees you result in a "hello there" right? This part might require scripting if the base AI definition doesn't allow filtering frobbing based on the status of a character.

Edited by MirceaKitsune
Link to comment
Share on other sites

I have no experience with conversations, but for the "when frobbed do something", you could try to give the AI a frob response with the effect: trigger atdm_target_startconversation_1 via the stim/response editor. In order to test if the frob is registered by the game, you could also first try something like an effect to turn off a light, just to be sure that the frob response actually works.

Link to comment
Share on other sites

There's the frob_actionscript spawnarg, which calls scripts in your .script files. As far as I'm aware you'd need one script per AI, or a scriptobject that you apply to all AIs concerned.

Alternatively you can use the S/R system to add a response to frobbing on the AIs which triggers the startconversation entity. Would also want to make this single-use, i.e. by deleting the conversation entity or deactivating the response and deactivating frobability.

For controlling frobability, I know there are spawnargs for making attached entities un/frobable upon death, but I dont think that exists for the actual AIs. Might be most versatile to just have a script on a 1s loop that checks allegiance + alert state + whether theyve already spoken + AI_DEAD & AI_KNOCKEDOUT booleans of all AIs concerned.

Link to comment
Share on other sites

3 hours ago, Dragofer said:

There's the frob_actionscript spawnarg, which calls scripts in your .script files. As far as I'm aware you'd need one script per AI, or a scriptobject that you apply to all AIs concerned.

Alternatively you can use the S/R system to add a response to frobbing on the AIs which triggers the startconversation entity. Would also want to make this single-use, i.e. by deleting the conversation entity or deactivating the response and deactivating frobability.

For controlling frobability, I know there are spawnargs for making attached entities un/frobable upon death, but I dont think that exists for the actual AIs. Might be most versatile to just have a script on a 1s loop that checks allegiance + alert state + whether theyve already spoken + AI_DEAD & AI_KNOCKEDOUT booleans of all AIs concerned.

In the end I feel I prefer this approach, just a script without any S/R. Especially since I don't like having to use so many custom entities for every AI including new conversation definitions: With a script I could define an universal system for interactive talking... if I can pass arguments from the spawnarg I could even customize the voice this way! It would also fix the dead / alert / allied issue... the AI can remain frobable but simply do nothing if the character isn't in a state to talk.

It seems neither the wiki nor Darkradiant spawnarg docs help me with frob_actionscript. How do I call a script function from it, ideally with the voice passed as a parameter? In this case would I use:

frob_actionscript mytalkfunction("my_snd_shader")

I also need to know which checks and functions I can use: First how do I check if the AI is dead? Then how do I check the AI's alert level? Lastly how do I check the AI's team and see if they're allied or neutral to the player? Once all those checks are preformed, how do I tell the AI to play a random voice from the sound shader (eg: tdm_ai_pro_greet_guard_to_civilian) with lipsyncing and everything working? If I'm lucky maybe I can also have the AI turning their head toward the player while talking... if there's such a function please let me know so I can add it to the list! And I should probably not allow the player to make the AI interrupt itself by spamming the use key... can I know when the voice finished playing and tell the script to wait while the character's still talking?

One more little thing: I plan to use this in campaigns too. IIRC map scripts are defined as mapname.script. Is it possible to have a script universal to a campaign, so that I don't have to copy the script file for each individual map in the list?

Edited by MirceaKitsune
Link to comment
Share on other sites

It's actually "frob_action_script", which is why a search didn't find it. I wouldn't try to pass a parameter, just make a different script function for each AI, and hard-code the sound shader (and anything else) within the script body.

Link to comment
Share on other sites

23 hours ago, MirceaKitsune said:

One more little thing: I plan to use this in campaigns too. IIRC map scripts are defined as mapname.script. Is it possible to have a script universal to a campaign, so that I don't have to copy the script file for each individual map in the list?

Yes, this is what the script folder is for, which you can find in some FMs. You need to #include them by mentioning them in a line in the tdm_custom_scripts.script file in the same folder.

As for everything else you asked about, I believe everything can be found on the TDM Script Reference wiki page, definitely worth familiarising yourself with that page if you want to do scripting. Use ctrl + f to look for words like "look".

Useful tip: if you play a sound shader, it'll automatically return its duration. So you can use i.e.

float sound_duration = $ai1.startSound("snd_conversation1", SND_CHANNEL_ANY, false);

(In this case you need to create a spawnarg called snd_conversation1 with the soundshader on the AI).

This function isn't that good for talking because it doesnt handle lip animations and interruptions, and it doesn't look like there's a function specifically for talking, so it'd be better to just switch to the conversation system and simply look up the sound duration in DR's speaker creator (new feature in 2.9) and store it as a spawnarg on the AI.

Link to comment
Share on other sites

RE your other questions, I find a text search through

https://wiki.thedarkmod.com/index.php?title=TDM_Script_Reference/2.06

to be frequently helpful in the absence of other info, albeit challenging due to no actual examples as it would appear in a script.

For instance, there's a getTeam() function. (BTW, there is substantial wiki material about teams.)

I do recall seeing a forum thread a while ago in which people discussed trying to get a talking AI to face the player... the consensus seemed pessimistic.

Link to comment
Share on other sites

14 minutes ago, Geep said:

RE your other questions, I find a text search through

https://wiki.thedarkmod.com/index.php?title=TDM_Script_Reference/2.06

to be frequently helpful in the absence of other info, albeit challenging due to no actual examples as it would appear in a script.

This makes me think it could be quite useful to have a page of example script lines with functions from that page. Together with useful tips, i.e. that startSound requires you to put the soundshader into a spawnarg beginning with snd_ on the entity. Maybe also some more generic examples, like how to pass parameters, set up a trigger_touch or make a script repeat x number of times.

Probably going to have to be a different page because the Script Reference looks like it gets automatically generated with each TDM version.

 

And yes, regarding head turning towards the player, that didn't go well in Painter's Wife. The (sitting) AI would always be off by 60-90°, even if I bound invisible entities to the player that the AI could look at.

Link to comment
Share on other sites

Thanks for the answers. The biggest problem sounds like the fact that playing a sound on the AI from the script won't handle lip-sync, as well as making sure the voice won't be interrupted if the AI says something else so they don't have two sounds coming out of them. That's a huge limitation! Is there really nothing that can be done here?

If I'm doing it this way I'd rather not use the conversation editor nor S&R system: I wanted to go that route if this was possible with just entities, with scripting it only feels right if the function can handle everything and I only use spawnargs on the AI to customize it. I'll go ahead and experiment with what was said so far just to get a code basis going... if we figure out the last problems maybe I can post it separately for other creators to use in their FM's too :)

Link to comment
Share on other sites

Lots of issues, can't find answers to many of them on the Wiki. The script crashes so I can't even test till I fix those.

First of all the #include argument complains that no file name is given when one is. My tdm_custom_scripts.script contains the line "#include script/ai_frob.script", but this causes the engine to crash with the error "#include without file name". How can there be no file name when I just wrote it in that line?!

To clarify the last basics: How do I refer to the entity triggering the script function? Your response above implies I use $ai1... as I refer to the player using $player1 I'm assuming this should be it. The other question is how I fetch the spawnarg: Your response suggests I just use the name of the spawnarg in the startSound call, thus I take it that it's converted automatically?

I'm checking if the AI is dead or alive, which I understand is stored in an AI_DEAD flag. But how do I access this flag? I tried "if(!$ai1.AI_DEAD)" but I get a crash: Unknown value "AI_DEAD". The same thing occurs for "if($ai1.AI_AlertLevel == 0)".

Even without those checks in place the script won't work yet. The AI entity has spawnargs "snd_talk tdm_ai_pro_greet_guard_to_civilian" and "frob_action_script ai_frob" (my function is "void ai_frob()"). However this code block will not do anything when I highlight and use the AI:

float sound_duration = $ai1.startSound("snd_talk", SND_CHANNEL_ANY, false);
float sound_duration_alt = $ai1.startSound("tdm_ai_pro_greet_guard_to_civilian", SND_CHANNEL_ANY, false);
$ai1.lookAt($player1, sound_duration);

Update: The above code starts working when I replace $ai1 with $atdm_ai_proguard_1 so something is wrong with that notation. Obviously I want a single common function so I don't want to hardcode AI entity names, what's the proper notation to refer to self? I can hear the sound but sadly there's indeed no lip syncing, however the AI also looks at the player correctly so there is some success.

Edited by MirceaKitsune
Update
Link to comment
Share on other sites

Managed to fix all of the above issues! Except for two which are the last things I need to finish the script: Detecting if the AI is dead or alert. Please let me know how to properly check the AI_DEAD and AI_AlertLevel flags.

The AI can be made to properly speak a line using ai.bark("snd_greeting_generic"). Only limitation is that the sound needs to be defined in the vocal set, you can't use custom sounds... a small price to pay for salvation :)

  • Like 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.

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

    • Petike the Taffer  »  DeTeEff

      I've updated the articles for your FMs and your author category at the wiki. Your newer nickname (DeTeEff) now comes first, and the one in parentheses is your older nickname (Fieldmedic). Just to avoid confusing people who played your FMs years ago and remember your older nickname. I've added a wiki article for your latest FM, Who Watches the Watcher?, as part of my current updating efforts. Unless I overlooked something, you have five different FMs so far.
      · 0 replies
    • Petike the Taffer

      I've finally managed to log in to The Dark Mod Wiki. I'm back in the saddle and before the holidays start in full, I'll be adding a few new FM articles and doing other updates. Written in Stone is already done.
      · 4 replies
    • nbohr1more

      TDM 15th Anniversary Contest is now active! Please declare your participation: https://forums.thedarkmod.com/index.php?/topic/22413-the-dark-mod-15th-anniversary-contest-entry-thread/
       
      · 0 replies
    • JackFarmer

      @TheUnbeholden
      You cannot receive PMs. Could you please be so kind and check your mailbox if it is full (or maybe you switched off the function)?
      · 1 reply
    • OrbWeaver

      I like the new frob highlight but it would nice if it was less "flickery" while moving over objects (especially barred metal doors).
      · 4 replies
×
×
  • Create New...