Jump to content
johnnyboy

Generate AI path for building

Recommended Posts

13 minutes ago, johnnyboy said:

 

With my script we are recording a series of positions, and unit may pause at each position.  When pausing at a position unit will use his normal enemy detection/targeting/fighting AI and engage any enemy.  So we record much smaller path files (20 or less positions can clear a house), and unit can engage any enemy it encounters.

 

I see.

 

I'll look forward to your progress then. 🙂

Share this post


Link to post
Share on other sites

@johnnyboy

Agree, our approaches are very similar.  So starting out, we're basically detecting/creating (the functional equivalent of) a nav mesh.

 

1 hour ago, johnnyboy said:

Anyway, I hope its doable and I would love it if some mad russian  took it on!!!!  

 

OK, let me see what I can cook up!  (Again no promises, you know in case win the lottery, get hit by bus and turn into vegetable, get hired out of blue by BI and move to Czech Republic, etc)  [Runs off to evil lair to begin diabolical experimentation...]

  • Haha 2

Share this post


Link to post
Share on other sites

Without path LODs you can add all points you want, that will not work with move/addWaypoint.

Now, If you want to play some movements + apply velocity from pt to pt, that can be  tricky for a fair result.

 

Here is a video, Vanilla Arma, small script and waypoints. Successes and fails.
 

 

  • Like 4

Share this post


Link to post
Share on other sites

I'll be happy if I can just send a single MG42 guy into a building, up the stairs, over to a window, have him face out the window and shoot at people, and then later get him back out of the building, and do all this reliably.  Especially the part where he is able to exit the building eventually.  That's the genius of johnnyboy's script/idea.

 

OK it's not much yet, but here's what I've got so far:

 

Scan-Buildings-1.png

  • Like 2
  • Thanks 1

Share this post


Link to post
Share on other sites
2 minutes ago, madrussian said:

OK it's not much yet, but here's what I cooked up so far:

Pretty!  Progress is good!

Share this post


Link to post
Share on other sites

Here's another vid to keep MadRussian inspired.

(Although its not a single building path, which is what MadRussian is working on).  Here we see AI climb 3 flights of stairs, cross 3 different building roof tops, jump from one building to another, step over low wall, jump to roof of van, and down to the ground.

  • Like 6

Share this post


Link to post
Share on other sites

Rooftop chases and van jumping? You gotsta have dat funk mang

 

Recommend playing this while watching johnny's kick*ss video. You might recognize the brother on the left

  • Like 1
  • Haha 2

Share this post


Link to post
Share on other sites
2 hours ago, froggyluv said:

Rooftop chases and van jumping? You gotsta have dat funk mang

F*** Yeah Baby!  Bring us the Funk!  I recognize that dude...he's a bad muthafugga...shut yo' mouth!...but we're talkin' 'bout F'Love!....we can dig it!!!

  • Like 1

Share this post


Link to post
Share on other sites

just posted to follow you guys work, since i think this is some awesome work, and a great idea. 👍👍:thumb_down:

  • Thanks 1

Share this post


Link to post
Share on other sites
On ‎4‎/‎13‎/‎2019 at 10:38 PM, pierremgi said:

Yep! the radius -1 implies ASL position. you need to use AGLToASL...

 

Here is the way I sweep a building with a unit. Place it in front of a house, name it bob, and follow it.


 


0 = bob spawn {
  params ["_unit"];
  _initPos = getPosASL _unit;
  _init0 = _initPos;
  _nearHouse = (nearestTerrainObjects [_unit,["house"],100] select {count (_x buildingPos -1)>0} select 0);

  _bPos = _nearHouse buildingPos -1;

// _bPos is the building position array

  for "_i" from count _bPos -1 to 0 step -1 do {

// I apply on positions 2 filters: first one for level/stage of the building, second one for the nearest position from the last treated
    _bPosArr = _bPos apply {[round ((2+(AGLToASL _x select 2))/2), _initPos distanceSqr AGLToASL _x,_x]};
    _bPosArr sort true;

// I'm using the precise waypoint coordinate with radius -1 (no need to use setWaypointHousePosition)
    _wp = group _unit addWaypoint [AGLToASL (_bPosArr select 0 select 2),-1];
    _wp setWaypointTimeout [0.5,0.5,0.5];

// deleting the used position as I'm sorting again for nearest pos
    _initPos = AGLToASL (_bPosArr select 0 select 2);
    _bPos = _bPos - [_bPosArr select 0 select 2];
  };
 group _unit addwaypoint [_init0,-1];

// follow the arrow as test
  _boo = createVehicle ["Sign_Arrow_Yellow_F",[0,0,0],[],0,"can_collide"];
  _boo spawn {
    while {true} do {
      _this setpos waypointPosition [group bob,currentWaypoint group bob];
    };
  };
};

Sometimes (not so often) the guy is stuck in door frame, especially when investigating balcony.

Vanilla AI is opening doors and don't pass thru walls, as I tested so far.
The building level/stage filter seems fine but can be optimized.

The nearest next position works fine also but sometimes the path to reach it is ... amazing. I think there is nothing to do except for scripting paths inside a modded building. I don't know how to do that. But that could be clearly the alternate solution for Rube Goldberg JohnnyBoy script. :torture:

 

 

I was thinking myself yesterday about scripting some sort of search building command and heyho I discover there is an active thread on it! oh, joy. 

I tried the script from PIERREMGI above - posted the script into a trigger minus the comments and set for radio alpha. Stuck bob next to a building lo and behold bob searched the building.

Some doors he just ghosted through but some he opened. Seems to me that the basic framework is there and works but what it needs is checks for doors and  door states to make it more accurate. But even with that I was impressed how well this bit of script worked.

Ive always been a lurker here but this topic persuaded me to actually sign up and make a comment. So there is a downside to everything. 😉

 

  • Like 3
  • Thanks 1

Share this post


Link to post
Share on other sites
On 4/14/2019 at 7:38 AM, pierremgi said:

Yep! the radius -1 implies ASL position. you need to use AGLToASL...

 

Here is the way I sweep a building with a unit. Place it in front of a house, name it bob, and follow it.


0 = bob spawn {
  params ["_unit"];
  _initPos = getPosASL _unit;
  _init0 = _initPos;
  _nearHouse = (nearestTerrainObjects [_unit,["house"],100] select {count (_x buildingPos -1)>0} select 0);

  _bPos = _nearHouse buildingPos -1;

// _bPos is the building position array

  for "_i" from count _bPos -1 to 0 step -1 do {

// I apply on positions 2 filters: first one for level/stage of the building, second one for the nearest position from the last treated
    _bPosArr = _bPos apply {[round ((2+(AGLToASL _x select 2))/2), _initPos distanceSqr AGLToASL _x,_x]};
    _bPosArr sort true;

// I'm using the precise waypoint coordinate with radius -1 (no need to use setWaypointHousePosition)
    _wp = group _unit addWaypoint [AGLToASL (_bPosArr select 0 select 2),-1];
    _wp setWaypointTimeout [0.5,0.5,0.5];

// deleting the used position as I'm sorting again for nearest pos
    _initPos = AGLToASL (_bPosArr select 0 select 2);
    _bPos = _bPos - [_bPosArr select 0 select 2];
  };
 group _unit addwaypoint [_init0,-1];

// follow the arrow as test
  _boo = createVehicle ["Sign_Arrow_Yellow_F",[0,0,0],[],0,"can_collide"];
  _boo spawn {
    while {true} do {
      _this setpos waypointPosition [group bob,currentWaypoint group bob];
    };
  };
};

Sometimes (not so often) the guy is stuck in door frame, especially when investigating balcony.

Vanilla AI is opening doors and don't pass thru walls, as I tested so far.
The building level/stage filter seems fine but can be optimized.

The nearest next position works fine also but sometimes the path to reach it is ... amazing. I think there is nothing to do except for scripting paths inside a modded building. I don't know how to do that. But that could be clearly the alternate solution for Rube Goldberg JohnnyBoy script. :torture:

@pierre MGI Just tried this out myself and was also impressed. Works really well.

  • Like 1

Share this post


Link to post
Share on other sites

I decided to try out pierreMGI  bit of script in a house clearing scenario and it worked nicely. Set up Bob ( my best guy) to search a building full of bad guys and he managed to blast them all as he worked his way through and finally out of the house. So of course I decided Bob needed a harder mission. I set him a series of waypoints down a street with a trigger setting of this script at selected houses as he worked his way down. BUT, of course this didn't work. Because Bob loses all his existing waypoints as soon as this script runs ( I think?) so he just completed the script the first time then stood there like a dumb ass.

So my question then was how to get Bob to follow a set of given waypoints and break into this script and then resume his waypoints. Basically Bob needs a way to be reminded what his waypoints were before he searches a building so that he can continue his tasks after the search.  I've looked for a command that might insert these new scripted waypoints into Bobs existing given waypoint list. But  I haven't worked out how to do that yet. I  wondered if using copywaypoints to copy his wps to a ghost group then copying them back after the script is run each time might be a simple way. That would mean copying bobs list of waypoints at the start of the building search script then restoring them at the end? 

Share this post


Link to post
Share on other sites

You can insert waypoints with addWaypoint and the right index.

 

Here is an example, for Bob as unit, with edited waypoints but entering houses (with more than 5 positions) while progressing.
Perhaps the counter and indexes are not optimized. I don't know. I don't want to spend to much time on that. Try to understand the principle:


 

bob spawn {
  params ["_unit","_nBuildings"];
  _grp = group _unit;
  _initialWpts = waypoints _grp;
  _cnt = 1;
  {createVehicle ["Sign_Arrow_green_F", waypointPosition _x,[],0,"can_collide"]} forEach _initialWpts;
  while {_unit distanceSqr waypointPosition (_initialWpts select count _initialWpts -1) > 25} do {

    waitUntil {_nBuildings = nearestTerrainObjects [waypointPosition [_grp,currentWaypoint _grp],["house","tourism"],50] select {count (_x buildingPos -1)> 5 && isnil {_x getVariable "BuildingTreated"}}; count _nBuildings >0 && currentWaypoint _grp == _cnt};
    _building = _nBuildings #0;
    _building setVariable ["BuildingTreated",true];
    while {currentWaypoint _grp >2} do {deleteWaypoint [_grp,1]};
    _currentwpt = currentWaypoint _grp;
        
    _bpos = _building buildingPos -1;
    _initPos = getPosASL _unit;
    _init0 = _initPos;
    for "_i" from count _bPos -1 to 0 step -1 do {
      _bPosArr = _bPos apply {[-round ((-2+(AGLToASL _x select 2))/2), _initPos distanceSqr AGLToASL _x,_x]};
      _bPosArr sort true;
      _wp = _grp addWaypoint [AGLToASL (_bPosArr select 0 select 2),-1,_currentwpt];
      createVehicle ["Sign_Arrow_yellow_F", waypointPosition _wp,[],0,"can_collide"];
      _wp setWaypointTimeout [0.5,0.5,0.5];
      _initPos = AGLToASL (_bPosArr select 0 select 2);
      _bPos = _bPos - [_bPosArr select 0 select 2];
    };
    _cnt = _currentwpt + count (_building buildingPos -1);
  };
};

0 = [] spawn {
  _boo = createVehicle ["Sign_Arrow_F",[0,0,0],[],0,"can_collide"];
  _boo spawn {
    while {true} do {
      _this setpos waypointPosition [group bob,currentWaypoint group bob];
      systemChat str currentWaypoint group bob:
      uisleep 0.5
    };
  };
};

 

Share this post


Link to post
Share on other sites

Many thanks for the response PIERREMGI.  A quick test of that code throws up an invalid number in expression error for me though.  

Share this post


Link to post
Share on other sites
17 minutes ago, The Real Bunc said:

Many thanks for the response PIERREMGI.  A quick test of that code throws up an invalid number in expression error for me though.  

Hi @pierremgi and Real Bunc.  Can you guys please take this discussion to another thread or private messages?  The purpose of this thread was to calculate a path of move points for a building without using building selection positions and waypoints.  That is a completely different problem than what Pierre is helping with you with.  I'm trying to find a completely new way to navigate a building WITHOUT using building selection positions

 

No offense guys, but this discussion is off topic for this thread and cluttering it up.

 

Thanks!

  • Like 1

Share this post


Link to post
Share on other sites

Ok no problem it simply seemed he had demonstrated a much simpler and workable way of achieving much the same end result. Best of luck with your quest. 

  • Thanks 1

Share this post


Link to post
Share on other sites
4 minutes ago, The Real Bunc said:

Ok no problem it simply seemed he had demonstrated a much simpler and workable way of achieving much the same end result. Best of luck with your quest. 

Pierre is a very smart guy and I respect all his contributions (don't get me wrong!).  Its just a different problem to solve.  Thanks!

  • Like 2

Share this post


Link to post
Share on other sites

Here's a little something to help keep the dream alive:

 

Scan-Buildings-2.png

 

"The Porch, the whole Porch, and nothing but the Porch, so help me God!"

 

Scan-Buildings-3.png

  • Like 6

Share this post


Link to post
Share on other sites

O.k. I'm a little stuck here, what is it that I'm looking at that is so different ?

 

AI using buildings, rooftops, balconies, stairs etc ?

Share this post


Link to post
Share on other sites
25 minutes ago, madrussian said:

 

"The Porch, the whole Porch, and nothing but the Porch, so help me God!"

Holy shit dude, that is beautiful.

Share this post


Link to post
Share on other sites
2 hours ago, madrussian said:

Here's a little something to help keep the dream alive:

 

Scan-Buildings-2.png

 

"The Porch, the whole Porch, and nothing but the Porch, so help me God!"

 

Scan-Buildings-3.png

 

Holy S man those nodes...so many glorious nodes! You've gone full matrix Neo

 

@chrisb: What you're seeing is the AI being given the ability to traverse indoor or generally very restricted areas outside of just the general given Building Positions. Building Positions are often nonsensical or at the very least pretty restrictive. Have you ever wondered why you cant order your AI to any part of a building , or why they just stop when given a certain building position and wander outside like Basset Hounds? Ever contemplated why they must walk in that very slow tactical crouch even when S is hitting the fan all around them and they should be running? Me too, and now we are saved as both JohnnyBoy and MadRussian have BloodPinkySworn they will solve all of these problems and more -luxury!!

  • Like 1
  • Haha 2

Share this post


Link to post
Share on other sites
10 hours ago, froggyluv said:

 

Holy S man those nodes...so many glorious nodes! You've gone full matrix Neo

 

@chrisb: What you're seeing is the AI being given the ability to traverse indoor or generally very restricted areas outside of just the general given Building Positions. Building Positions are often nonsensical or at the very least pretty restrictive. Have you ever wondered why you cant order your AI to any part of a building , or why they just stop when given a certain building position and wander outside like Basset Hounds? Ever contemplated why they must walk in that very slow tactical crouch even when S is hitting the fan all around them and they should be running? Me too, and now we are saved as both JohnnyBoy and MadRussian have BloodPinkySworn they will solve all of these problems and more -luxury!!

 

I can see they are making more positions, just it's not new. 😉

 

Plus the old ai mods did a good job, this will do no better really for players. The current positions are fairly good, well for A2 that I play, not sure for A3, do they not have building positions in 3. Provided you use an ai mod that keeps your ai awake, then the problem doesn't really exist, or not to the extent that you will notice as a player.

 

Also I would add to this, 'playable unit', tactics, placements, orders, control.

 

I get it, that many players play the series like COD, but it's not meant to be played that way really. Could be the style your playing needs adjusting and not extra nodes.

Share this post


Link to post
Share on other sites
4 hours ago, chrisb said:

 

I can see they are making more positions, just it's not new. 😉

 

Plus the old ai mods did a good job, this will do no better really for players. The current positions are fairly good, well for A2 that I play, not sure for A3, do they not have building positions in 3. Provided you use an ai mod that keeps your ai awake, then the problem doesn't really exist, or not to the extent that you will notice as a player.

 

Also I would add to this, 'playable unit', tactics, placements, orders, control.

 

I get it, that many players play the series like COD, but it's not meant to be played that way really. Could be the style your playing needs adjusting and not extra nodes.

 

 Man you gotta be kidding me - this opens up opportunity for AI not limits them and to say this adds to a COD type gameplay is just small minded. Ive seen the AI mod you've literally been raving about for years -KAI -sorry man buts it not that impressive and no it doesnt allow for this. Your obviously completely happy and satiated with how it allows you to play Arma 2 and really, good for you man, but its pretty short sighted and frankly asinine to come into these guys thread who are working on something you're seemingly just not able to comprehend and start demeaning it's impact only to (yet again) tell everyone how happy you are with the 'never released to the public but beyond the sun good KAI'.KAI aint shit holmes, sorry to tell yas. Half the buildings in Tanoa dont even have Building Positions in the big cities and the AI cant access the ones built up on terraces did you ever think about how this could impact that? Really the amount of things one could add strategically is limitless if AI is given this ability but ill let you stay content in your little happy place rather than list them for you.

  • Like 2
  • Haha 1

Share this post


Link to post
Share on other sites
13 minutes ago, froggyluv said:

 

 Man you gotta be kidding me - this opens up opportunity for AI not limits them and to say this adds to a COD type gameplay is just small minded. Ive seen the AI mod you've literally been raving about for years -KAI -sorry man buts it not that impressive and no it doesnt allow for this. Your obviously completely happy and satiated with how it allows you to play Arma 2 and really, good for you man, but its pretty short sighted and frankly asinine to come into these guys thread who are working on something you're seemingly just not able to comprehend and start demeaning it's impact only to (yet again) tell everyone how happy you are with the 'never released to the public but beyond the sun good KAI'.KAI aint shit holmes, sorry to tell yas. Half the buildings in Tanoa dont even have Building Positions in the big cities and the AI cant access the ones built up on terraces did you ever think about how this could impact that? Really the amount of things one could add strategically is limitless if AI is given this ability but ill let you stay content in your little happy place rather than list them for you.

 

Yeah o.k. 🤣

Share this post


Link to post
Share on other sites
16 hours ago, madrussian said:

Here's a little something to help keep the dream alive:

 

Scan-Buildings-2.png

 

"The Porch, the whole Porch, and nothing but the Porch, so help me God!"

 

Scan-Buildings-3.png

Keep it up, I see great potential here, not only for AI. 

I'm curious in how you get the floor points (blue) and how do you distinguish wall from floor, is lineIntersectsSurfaces involved by any chance?

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

×