Jump to content
The Dark Mod Forums

Path/target testing script for DR!


RJFerret

Recommended Posts

For debugging purposes, might a script be able to analyze AI pathing and report any dead ends, IE targets that don't exist?

 

This would catch things that are hard to find in manual beta testing, typos, deleted entities, renames, etc.

 

The hard part I imagine, if it's even possible, would be branching pathways with all the random loops we mappers like to provide.

 

Edit: Renamed thread so can be searched/found better in future. For users, this would reveal AI that would get stuck and stop moving in the map due to a missing or incorrect next target among other things.

Edited by RJFerret
  • Like 1

"The measure of a man's character is what he would do if he knew he never would be found out."

- Baron Thomas Babington Macauley

Link to comment
Share on other sites

Brilliant!

 

Not only found the one I saw on a map I was looking at, but popped up others. Even found a couple on one of my maps that's been through testing, yikes...awesome!

 

Now how may we add it to the script menu? Just prepending...

 

# Set the command name so that DarkRadiant recognizes this file

__commandName__ = 'test_targets' # should not contain spaces

__commandDisplayName__ = 'Test for Missing Targets'

 

...was not enough, I guess because it doesn't know to output to the script window?

 

Nevermind, that WAS enough, it just outputs to the console window, duh.

 

PS: I was able to add a blank line after it's output by inserting...

   	 print('')

...prior to the execute(), presumably that's kosher.

 

I feel this should be included with DR.

Edited by RJFerret

"The measure of a man's character is what he would do if he knew he never would be found out."

- Baron Thomas Babington Macauley

Link to comment
Share on other sites

No prob, and yes that kosher :) If you want to run it from the menu, it's probably best to have the final report in a message box instead of console output. Here's an amended version. Save this as a text file called missing_targets.py in your DarkRadiant/scripts/commands folder. The filename doesn't matter as long as it ends in '.py'. Then restart DR and it'll be on your scripts menu:

 

__commandName__ = 'targetCheck'
__commandDisplayName__ = 'Find missing targets'
def execute():
g_targets = {} # entityname : [targets]
g_missing = {} # entityname : [missingtargets]
class TargetFinder(SceneNodeVisitor) :
	def pre(self, node):
		if node.isEntity():
			n = node.getEntity()
			name = n.getKeyValue('name')
			targs = [t.second for t in n.getKeyValuePairs('target')]
			g_targets[name] = targs
		return 1
# Instantiate a new walker object and get list of entities/targets
walker = TargetFinder()
GlobalSceneGraph.root().traverse(walker)
# Find any targets that don't exist, and count all targets
entities = g_targets.keys()
targetcount = 0
for ent in entities:
	targetcount += len(g_targets[ent])
	missing = []
	for targ in g_targets[ent]:
		if targ not in entities:
			missing.append(targ)
	if missing:
		g_missing[ent] = missing
# generate report
msg = ''
msg += '%d entities found with %d targets' % (len(entities), targetcount) + '\n'
if not g_missing:
	msg += 'No missing targets found\n'
else:
	msg += 'Missing targets:\n'
	for ent in g_missing.keys():
		for targ in g_missing[ent]:
			msg += '%s -> %s\n' % (ent, targ)
# display report
dialog = GlobalDialogManager.createMessageBox('Missing targets', msg, Dialog.CONFIRM)
dialog.run()
if __executeCommand__:
execute()

 

EDIT: Yes I agree this would be a useful feature, maybe an element of a general "Map check" script. We had one or two other suggestions a few weeks ago...

Edited by SteveL
Link to comment
Share on other sites

Actually the prior was more useful, as I could copy/paste the results to a beta test thread.

 

The window box also goes away when you click OK, making it harder to reference or find the entities you might want to change.

 

(You'd have to pull out a piece of paper to write them down, or retype in an editor, instead of just copy/paste.)

 

So I'll be keeping the first version at least. ;-)

 

Edit: What it could do is pop up a window saying X entities found (or none) and to see the Console for the list.

Edited by RJFerret

"The measure of a man's character is what he would do if he knew he never would be found out."

- Baron Thomas Babington Macauley

Link to comment
Share on other sites

Yes, although vice-versa IMO, beforehand might be a bit better as then it happens when the box display is up. If it's after, then it doesn't kick it out until after the user has clicked OK.

 

Edit: To install, download file, move into DarkRadiant/scripts/commands folder, rename to remove the .txt (so it's -.py). If Dark Radiant is already running, use the Reload Scripts menu option. If you didn't notice in a post above, results will be retained in the Console panel.

test_targets.py.txt

Edited by RJFerret

"The measure of a man's character is what he would do if he knew he never would be found out."

- Baron Thomas Babington Macauley

Link to comment
Share on other sites

It would probably be nice if the script also piped the output to a separate text log, "test_targets.log", where it can be viewed out of game, copy/pasted, etc. I know you can do a condump but that's an extra step and there would be a host of things not pertinent at the head of the file.

Edited by Lux
Link to comment
Share on other sites

Nice script, I'll be happy to include that in the regular DR releases, when you guys say it's ready for inclusion.

 

It's very nice to see scripters making use of DR's Python interface. It was quite a lot a work!

Link to comment
Share on other sites

Up for some challenges SteveL ?

 

A script which auto-generates Visportals based on a simulated player walk-through of the map?

 

A script which resizes and repositions light volumes for all lights of a specific entity (torches) so that

the volumes only hit tris in the room where they are intended to render and also keeps the light_center

in the same absolute location and also changes the attached flame particle to match the light_center

(using offsets)?

 

These are probably too ambitious but seeing your excellent work on leak finding and this script

gives me a little confidence to make these suggestions.

Please visit TDM's IndieDB site and help promote the mod:

 

http://www.indiedb.com/mods/the-dark-mod

 

(Yeah, shameless promotion... but traffic is traffic folks...)

Link to comment
Share on other sites

I'm always up for challenges but my goodness you know how to set the bar high! If you have ideas on how these might work in practice, let's take it to another thread. At first glance, these sound tough. I think a script might run into difficulties deciding what a "room" is, at least without duplicating all the work that goes on during dmapping. And with portals, I can see how a script could work out optimal places to put portals to maximize the amount of time they spend closed (assuming the player will be standing in all parts of the visleaf for the same amount of time), but I fear no script could portal an area well unless the area had been designed with specific portal positions in mind. Re lights: Is that because the lights would be non-shadowcasting, and therefore prone to leaking into the next room? An easier fix might be to generate location settings to switch them off as the player leaves. That would still need a script to somehow work out which lights are in a given location. Hmm.

Link to comment
Share on other sites

A new thread may be the way to go.

 

As for portalizing, it doesn't have to be perfect. It merely needs to be better than an un-portaled map which we see quite a bit with new mappers.

Mappers can auto-portal then tweak portals afterwards to improve performance (etc). Yes, ideally it would be as good as possible though.

 

Even shadowed lights do calculations outside their illumination zones (though I think these are significantly smaller calcs with early outs)

so trimming the volumes would probably be helpful in that use-case too.

Please visit TDM's IndieDB site and help promote the mod:

 

http://www.indiedb.com/mods/the-dark-mod

 

(Yeah, shameless promotion... but traffic is traffic folks...)

Link to comment
Share on other sites

  • 4 weeks later...

From DR 1.8.1 pre-release thread

Yes, a button that selects them would be wonderful compared to having to wait a day or two for J to bring up the entity list, and type in the now forgotten entity name.

 

Speaking of which, perhaps the pop-up dialog should indicate the list is maintained in the console? Otherwise general users would have no way of knowing to look there, and probably need to keep re-running it to get the name of the next entity to seek.

 

Ok, here's a stab at those: test_targets.py.txt

  • Like 1
Link to comment
Share on other sites

Ran it on two maps, one with just one such entity, another with several missing target entities, everything looks good to me. I like the manner you chose to present the dialog and selection option too. It gets the RJ seal of approval (whatever that is...*imagines barking seal noises). ;-)

"The measure of a man's character is what he would do if he knew he never would be found out."

- Baron Thomas Babington Macauley

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

      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
    • nbohr1more

      Please vote in the 15th Anniversary Contest Theme Poll
       
      · 0 replies
×
×
  • Create New...