Jump to content
Sign in to follow this  
xALIENAx

AI "go to" or Man position

Recommended Posts

Im wondering how I could do this scripting wise. Im refering to getting AI units to go to specific locations on a building (in much the way you can order your squad to.. say.. stand in a 2nd floor window)

Im a little lost with this one as im Unsure how to find an exact object name for a specific building?

ive been playing with the editor for some time and ive always wanted to have my AI make better use of the buildings in urban areas :D

Share this post


Link to post
Share on other sites

Put a logic next to the building, then turn on IDs in the editor and get the object's ID. I'll assume it's "123456" for this and you want to go to position #1...

Put in the logic's init: TheBuilding1 = nearestObject [getpos this, 123456];

Now you've got a reference to the building, "TheBuilding1", you can use in the script.

Then give your guy the command YourSoldier doMove ((getpos TheBuilding1) buildingPos 1)

That should work - it's completely untested and I've never tried it myself, but this:

this setpos (((getpos this) nearestobject 123456) buildingpos 1); puts unit THIS into building 123456, so I've just used the same method on the doMove command. Hope it works - let me know, I'd be interested :)

Share this post


Link to post
Share on other sites
I'll assume it's "123456" for this and you want to go to position #1...

Hold on there. BuildingPos indicies start at 0. That means for position #1 (as it appears in game or WP menu), you would use buildingPos 0. A lot of people either forget or don't realize this, and probably wonder why their AI are moving to the wrong place.

Share this post


Link to post
Share on other sites

Thanks much guys.. ive just tested it with a few units from verious factions, setting my self as a civ so i could go into thier midst and verify they are indeed where i want them, works a treat. now just gota go in and edit the missions i want to make use of this :D

should be alot more dynamic for my special forces campighn with the enemies actually uisng whats there rather then just standing next to buildings i want them guarding.

Share this post


Link to post
Share on other sites
Hold on there. BuildingPos indicies start at 0. That means for position #1 (as it appears in game or WP menu), you would use buildingPos 0. A lot of people either forget or don't realize this, and probably wonder why their AI are moving to the wrong place.

Yup, you're right - it's something I tend to forget unless I'm actually looking at the building in the game (with the move-to order ready, so it gives the "normal" positions),

Thanks much guys.. ive just tested it with a few units from verious factions, setting my self as a civ so i could go into thier midst and verify they are indeed where i want them, works a treat.

Excellent. I'll have to add that to my little code snippets list :)

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  

×