Jump to content
The Dark Mod Forums

Putting an AI to a completely new path


Sotha

Recommended Posts

The problem to be solved:

I basically have AI's going on patrol routes. Then I have an event which changes the AI patrol routes completely.

I want to trigger a change of patrol route for an AI who is already walking on another path.

 

I know the following so far:

  • Giving a new target to the AI with response 'Add target' works. But only if the AI has no target in the beginning. If he is already targetting something, 'add target' does nothing.
  • Giving the AI a new spawnarg 'target' with the response 'set spawnarg' doesn't work at all. (I'm not sure what this response is for, if someone knows please tell me.)
  • There is the response 'Remove targets', which sounds perfect, but it does nothing. Calling such a response on an AI who is walking a path does not stop him.
  • I CAN change the patrol route by teleporting the path_corners to new locations, but this is not a very elaborate solution as I'd need to teleport all the path nodes. Not much flexibility there. What if the new path needs more, less or new path_nodes?
  • I've noticed that there exists a target entity called 'atdm:target_changetarget,' which sounds like it could be of benefit, but I've found absolutely no documentation for it. Any info on that would be great.

All attempts to help are greatly appreciated.

Clipper

-The mapper's best friend.

Link to comment
Share on other sites

Yes that entity is very obscure. I can find nothing about it on an internal search. All we have is the description:

 

When triggered, this entity changes (adds or removes) a target from the connected entity. Target removals always happen before additions.

 

So, a lever to the atdm:target_changetarget which is targetting say Path1 will remove Path1 as its target and create a new target for itself. But what? I've sometimes seen a spawnarg something like entity_name but don't know if tha pplies here. Also, is it only a one-off or can it be switched over and over.

 

Apart from trial and error of the above there is also scripting. I've ran out of time tonight but I could look into that tomorrow if you want.

 

Failing which the teleport path entities though crude should work. You set up the max number of path entities and any route that needs less you include them all anyway. It does no harm to have extra path corners along a straigh route for instance.

Link to comment
Share on other sites

Hey, wait a minute...

*Does a quick test*

 

Oh yes, it seems I thought the entire thing incorrectly.

It is not the AI who should get the new targets, but the path_corners!

 

If I make a stim-response thingy which does 'Add target' for a path_corner, it will work. So basically I could have set all the path_nodes in the AI's initial route to point to the first node of the new patrol route. When the change occurs, the AI seems to walk about two path_corners on the old route and then proceed to the new route. The change is not immediate.

 

As for 'clear targets' response, it works the same way: I can halt the AI by clearing targets from the path_nodes. The problem with this method is that the AI will never walk again. He stops and you cannot give him new targets or anything.

 

So, the AI-to-new-route has been solved in some capacity, but the solution is not the best possible because the AI will not react to it immediately. This is still much better option than the node teleportation, however.

 

I'd still love to hear what this mysterious 'atdm:target_changetarget' entity does. Maybe the best solution is somewhere hidden in the logic of this entity?

Clipper

-The mapper's best friend.

Link to comment
Share on other sites

You problems with the "chagetarget", "addtarget" etc can be that some spawnargs are parsed at entity spawn. So if entity A has entity B as target, it parses that, stores B somewhere then does whatever it does. If you later change B to C, the entity A might not notice this if it has somewhere internally still stored B.

 

Not sure if this pertains to path_nodes, but it might well be. For instance, if you remove a path_node from the game, the AI also has a pointer to its first path_node (so it knows it route) and changing this path_node (or removing it) will invalidate the AI route.

 

It would probably be easiest to add a new script event for you, say $ai1.PatrolTo( $new_path_node ) so when called,the AI forgets its route, adds the new path node to its patrol and proceeds from there. The method would then take care of all the internal AI memory and stuff.

 

I can look into this if you add a tracker entry and make a testmap with two path node patrol loops.

 

Edit: There is a "randomPath" script event, you could try to remove all path_node targets from the AI, add the new path_node target, then call that so it "randomly" chooses the only path that is left.

"The reasonable man adapts himself to the world; the unreasonable one persists in trying to adapt the world to himself. Therefore, all progress depends on the unreasonable man." -- George Bernard Shaw (1856 - 1950)

 

"Remember: If the game lets you do it, it's not cheating." -- Xarax

Link to comment
Share on other sites

It would probably be easiest to add a new script event for you, say $ai1.PatrolTo( $new_path_node ) so when called,the AI forgets its route, adds the new path node to its patrol and proceeds from there. The method would then take care of all the internal AI memory and stuff.

Yes, that would be the best solution.

 

I can look into this if you add a tracker entry and make a testmap with two path node patrol loops.

Okay, I'm on it.

Clipper

-The mapper's best friend.

Link to comment
Share on other sites

I've searched through the def for atdm:target_changetarget and it gives these two spawnargs:

 

	"remove"				"The name of the target which should be removed from the entity targetted by this changetarget ent. If empty, nothing happens."

 

	"add"				"The name of the target which should be added to the entity targetted by this changetarget ent. If empty, nothing happens."

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

    • nbohr1more

      The FAQ wiki is almost a proper FAQ now. Probably need to spin-off a bunch of the "remedies" for playing older TDM versions into their own article.
      · 1 reply
    • nbohr1more

      Was checking out old translation packs and decided to fire up TDM 1.07. Rightful Property with sub-20 FPS areas yay! ( same areas run at 180FPS with cranked eye candy on 2.12 )
      · 2 replies
    • taffernicus

      i am so euphoric to see new FMs keep coming out and I am keen to try it out in my leisure time, then suddenly my PC is spouting a couple of S.M.A.R.T errors...
      tbf i cannot afford myself to miss my network emulator image file&progress, important ebooks, hyper-v checkpoint & hyper-v export and the precious thief & TDM gamesaves. Don't fall yourself into & lay your hands on crappy SSD
       
      · 7 replies
    • 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.
      · 7 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
×
×
  • Create New...