Jump to content
Sign in to follow this  
lethal

request for debugging help

Recommended Posts

Ive been working on a set of scripts to make the ai use the new buildings in oa more effectively and i am having trouble with one particular logic bug that i can't figure out.

what this script does is basically take the players squad and make them clear the nearest (pathed) building from the bottom up quickly while taking the shortest path and using their manpower most effectively.

this is just a test script hence the use of the player squad and not anything more elaborate. i just wanna get this basic functionality down before integrating it into something bigger.

to test place yourself in the editor along with some units in your squad and run the script any way you see fit (action, radio etc..).

I get the error that on a later iteration through the main loop the variable _closest is not getting any value assinged and is causing an error a few lines below (line 148) and i have experimented a bit (hence all the hints ;) ) bur cant figure out how to fix it.

since i've been sitting and staring at this damn script for too long now and need some sleep i'm posting this here in hopes a fresh set of eyes can point me in the right direction.

http://pastie.org/1163945

Share this post


Link to post
Share on other sites

Just ran it through squint which says

"'_closest' assigned to without being declared private (may corrupt outer variable)"

Since '_closest' doesn't already exist at the point where you assign to it (lines 140,143) a new local variable is created but it only exists in a very limited scope (the immediately enclosing braces). What you should do is add a private declaration (probably at the top of the file) to make sure that _closest is visible inside the whole while-loop.

Share this post


Link to post
Share on other sites

i had it declared private before but removed that declaration for test purposes. gonna try again tho - maybe i missed something.

btw that tool looks really interesting. looks like you did some fine work there - gonna try it out myself :)

anyways - thanks for taking the time

edit:

fixed it - thanks for pointing me in the right direction.

i refactored a little and moved that while loop inside another inline function with private declarations and that did the trick :)

quite impressive seeing a whole ai squad clear a building quickly btw :D - now i just have to have them exit safely XD

for anyone interested heres the fixed and slightly updated version:

http://pastie.org/1164813

Edited by lethal

Share this post


Link to post
Share on other sites

Please sign in to comment

You will be able to leave a comment after signing in



Sign In Now
Sign in to follow this  

×