Jump to content
The Dark Mod Forums

Newbie DarkRadiant Questions


demagogue

Recommended Posts

Don't know anything about stim/response because I don't work with TDM engine, so the following may not work for you at all or TDM has something better, look at its wiki to be sure. 

Now I'm also, not really sure if the following suggestion is what you want but original idtech 4 projectiles add a https://modwiki.dhewm3.org/GetProjectileState_(script_event), see if it still works in TDM, one fast way to see if it probably does, is to see in the tdm_defs.script if the projectile state definitions are there, if they are then the GetProjectileState script func, probably works fine, and if it does, then by using those "enum" values, you can know the current state of the projectile and call a function, on any script_object script bound to the projectile, depending on its state, using https://modwiki.dhewm3.org/CallFunction_(script_event) or any TDM equivalent. 

Btw make sure to use a script_object  script and "bind" it to the projectile, using spawnarg, key/val "scriptobject" "script_object_name", in the projectile definition file (if any), if not, CallFunction will not work or break, you can use https://modwiki.dhewm3.org/HasFunction_(script_event), to make sure the function exists in the entity.

Link to comment
Share on other sites

@RedNoodles You can define custom stims and let the ai react to it by either adding a response to all ai's in your mission or by altering the scriptobject used by the ai, where you have to add a response in the init routine and define a script function with the respective actions to take place upon stim.

 

Here you can find a similar setup:

Here torch entities are stimming ai's to inform them they are there, and ai react if they are searching, but the basic functionality is similar to what you are aiming for.

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

I'm setting up a "do not kill civilians" objective, which is a bit hard to test quickly, so let me ask here if I'm doing it right. It's always kinda unclear what should be entered in the component subfields. In particular, should the "Kill target" be "Any AI of specified type" "is_civilian"? With Amount = 0?

Here's all the details:

Initial State
  INCOMPLETE
Flags:
  Mandatory - TRUE (for the moment)
  Ongoing - TRUE
  Irreversible - FALSE
  Visible - FALSE (later TRUE)

Component #1
============
Component Type:
  Type AI is killed
Flags:
  Satisfied at start - TRUE
  Irreversible - FALSE
  Boolean NOT - TRUE
  Player responsible - TRUE
Kill target:
  Any AI of specified type : is_civilian
  Amount: 0

Link to comment
Share on other sites

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

That's a pretty long, opaque article. I was hoping for a more focused suggestion. But what I gathered is:

1) "Any AI of specified type" is expecting a predefined enum, but where that is defined, I don't know. Searching the source code for "type" or SPEC_AI_TYPE wasn't fruitful. So I conclude this wiki comment can be answered in the negative: "Not sure if this is implemented yet"

2) I guess I could use the example "don't hurt AI" script, though it doesn't differentiate between player-caused and AI-caused hurt... probably won't be an issue in my case.

3) Evidently there's an "innocent" boolean I can set on each AI. Is that what the Objective Editor calls "Any AI with specified combat status"? If so, that would be my go-to solution, to decorate the 2 dozen AIs with innocent flags.

Link to comment
Share on other sites

I want to control how the AI patrols via a randomizing script; The AI goes to say Corner 1 and that triggers a script that ADDS or CHANGES the targets on Corner 2. But I get stumped on the syntax for adding or changing the target spawnarg:

When you change frobbability it looks like this

    $entity.setFrobable(1);

so I thought it would be something like this

         $path_corner_2.addTarget(industry);    

or

         $path_corner_2.addTarget("industry");    

or

        $path_corner_2.addTarget('industry');    

but no, it doesn't work...

Cheers

Link to comment
Share on other sites

A target is an entity, so if the targeted entity is called industry you'd use

$path_corner_2.addTarget($industry);   

If you wanted to turn an entity name into a string you'd use $industry.getName(), but that would no longer point to a specific entity in the map, it'd just be a string of letters.

Btw, for a string the syntax would be "industry". You might like to reference the new A to Z Scripting Guide on the wiki for this and more.

Link to comment
Share on other sites

Doesn't work that either...The guy just walk up to the path_corner (which is devoid of any targets) and stops.

In case I didn't made myself entirely clear. I want to make the AI take different paths depending on a random number generated at map start. That number shall tell the path_node to get different targets. So I want to ADD a different target spawnarg depending on the rand number.

 

    if (rand == 0)  
        {
            sys.print("\nGo to industry\n");

           $path_corner_2.addTarget($industry);    

        }

    if (rand == 1)  
        {
            sys.print("\nGo to sidewalk\n");
            $path_corner_2.addTarget($sidewalk);    
        }

 

BTW Ohh, has the scripting guides been updated/elaborated? :)

Link to comment
Share on other sites

This may seem like a stupid question, but do you call the script-function? If not, it would make sense that you don't add the target... I assume the sys.prints are to make sure that you do, but I just wanted to double check. This is something that could happen to me 😅

I just chekced the script reference page and I believe the correct way to write it would be something like sys.addTarget($path_corner_2, $industry). At least according to the wiki the entity, that the target should be added to, as well as the new target are defined inside the brackets:

scriptEvent void addTarget(entity target);

Add a target to this entity.
target: the entity to add as target
Spawnclasses responding to this event: idEntity)

I chose sys as actor, as this seems the most likely to function as an actor, but I am not 100% sure, if this is correct.

Link to comment
Share on other sites

12 minutes ago, Destined said:

This may seem like a stupid question, but do you call the script-function? If not, it would make sense that you don't add the target... I assume the sys.prints are to make sure that you do, but I just wanted to double check. This is something that could happen to me 😅

I just chekced the script reference page and I believe the correct way to write it would be something like sys.addTarget($path_corner_2, $industry). At least according to the wiki the entity, that the target should be added to, as well as the new target are defined inside the brackets:

scriptEvent void addTarget(entity target);

Add a target to this entity.
target: the entity to add as target
Spawnclasses responding to this event: idEntity)

I chose sys as actor, as this seems the most likely to function as an actor, but I am not 100% sure, if this is correct.

Sorry, that doesn't work either; it says:

 "addTarget" is not callable as a 'sys' function"

 

Link to comment
Share on other sites

I'd try seeing what happens if you manually add industry as a target to path_corner_2, to rule out that it's a problem with the ingame entities.

And yes kind of, that A to Z Scripting Guide is a new, multi-page series seeking to cover as much as possible about scripting in a single series.

@Destined the entry says that spawnclass "idEntity" responds to this, so you need to call it on an entity, and then specify the entity that should be added in the brackets. There's also only space for a single entity variable with the name "target" in the brackets.

You'd call the event on sys if the spawnclass "idThread" responded, instead of "idEntity".

Link to comment
Share on other sites

I'm probably just dumb, but I can't get it to work...I've created the changetarget entity and named it change_it and on this entity I have added Target - path_corner_2 (there's a yellow line connecting them) and the spawnarg Add - industry

Then I added this to the script 

sys.trigger($change_it);

Have also tried a direct lever in game...

 

EDIT

Ahh, I added an initial target on path_corner_2. It didn't work unless I added a temporary target...

Edited by Fieldmedic
Link to comment
Share on other sites

4 hours ago, Dragofer said:

I'd try seeing what happens if you manually add industry as a target to path_corner_2, to rule out that it's a problem with the ingame entities.

And yes kind of, that A to Z Scripting Guide is a new, multi-page series seeking to cover as much as possible about scripting in a single series.

@Destined the entry says that spawnclass "idEntity" responds to this, so you need to call it on an entity, and then specify the entity that should be added in the brackets. There's also only space for a single entity variable with the name "target" in the brackets.

You'd call the event on sys if the spawnclass "idThread" responded, instead of "idEntity".

Ah, I misinterpreted that. I thought it meant "entity, target", not "target that is an entity". Sorry for the confusion.

Link to comment
Share on other sites

Anyone have a solution for this problem?:

Because I'm using modules for walls, I have to monsterclip the hell out of each room, which means I can't place light switches in normal places like next to doors (cause AI always get caught in/near doorways without MC).  I'm also finding that even without monsterclip, if the switch is placed on the module the AI won't go near it (along with other odd behaviour).  I even tried the relight_position entity and it didn't help.

Link to comment
Share on other sites

9 hours ago, Frost_Salamander said:

Anyone have a solution for this problem?:

Because I'm using modules for walls, I have to monsterclip the hell out of each room, which means I can't place light switches in normal places like next to doors (cause AI always get caught in/near doorways without MC).  I'm also finding that even without monsterclip, if the switch is placed on the module the AI won't go near it (along with other odd behaviour).  I even tried the relight_position entity and it didn't help.

Did you put brushes behind your modules?

Link to comment
Share on other sites

33 minutes ago, JackFarmer said:

Did you put brushes behind your modules?

There is sealing geometry behind the wall modules if that's what you mean.

Link to comment
Share on other sites

Link to comment
Share on other sites

2 minutes ago, Dragofer said:

I'd make a simple brush-built test map containing only the lamp, switch and AI, to rule out that it's an issue with the lamp.

Pretty sure the lamp is OK, if I drag the switch out to the middle of the room and leave it floating there, the AI uses it.

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

    • Ansome

      Finally got my PC back from the shop after my SSD got corrupted a week ago and damaged my motherboard. Scary stuff, but thank goodness it happened right after two months of FM development instead of wiping all my work before I could release it. New SSD, repaired Motherboard and BIOS, and we're ready to start working on my second FM with some added version control in the cloud just to be safe!
      · 0 replies
    • 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
×
×
  • Create New...