Page 2 of 12 FirstFirst 123456 ... LastLast
Results 11 to 20 of 117

  Click here to go to the first Developer post in this thread.  

Thread: Line Of Sight (Example Thread)

  1. #11
    CWR² Developer SaOk's Avatar
    Join Date
    Nov 23 2006
    Location
    Helsinki, Finland
    Posts
    1,341
    Author of the Thread
    For the AI functions in Zub mission, I am looping nearEntities check in about every 3. second ((getposATL _z) nearEntities [["Ins_Soldier_Base","RU_Soldier_Base","CDF_Soldier_ Base","GUE_Soldier_Base"],120]). You could loop it for 50m, when check the LOS´s. Already much less units to count that then. E.g. you could check the nearentities for group leader, then what enemies he see and then stop group.

    Edit: Or try nearTargets.

  2. #12
    First Sergeant
    Join Date
    Oct 30 2009
    Location
    Brisbane, Australia
    Posts
    981
    SaOK, that's a really excellent implementation of the new lineintersects function.

    I tried your formula in a very small script which just makes AI units in the player's group kneel/crouch if they have line of sight of an enemy less than 150m away. Seems to work pretty well and doesn't cripple the computer.

    Uncommenting this line: //0 = _unit fireAtTarget [_enemy]; , and decreasing the sleep =10 to sleep=1 or less, might also help in CQB as per maturin's suggestion

    PHP Code:
    //UNITS IN PLAYER"S GROUP WILL AUTOMATICALLY KNEEL/CROUCH IF THEY HAVE LINE OF SIGHT OF NEAR ENEMIES
    // Original idea by SaOK

    //Enemies within 150m of unit
    _nearenemies 
    {
    _unit _this select 0;
    _nearunits nearestobjects [_unit,["man"],150];
        {
        if (
    side _x == eastthen {[_unit_xcall _los};
        } foreach 
    _nearunits;
    };

    //Does unit have line of sight with enemy?
    _los 
    {
    _unit _this select 0;
    _enemy _this select 1;
    if (((
    abs(([_unit_enemycall BIS_fnc_dirTo) - direction _unit)) <= 90 || (abs(([_unit_enemycall BIS_fnc_dirTo) - direction _unit)) >= 270) && !(lineIntersects [[getposASL _enemy select 0getposASL _enemy select 1,(getposASL _enemy select 2)+((_enemy selectionPosition "pilot"select 2)],[getposASL _unit select 0getposASL _unit select 1,(getposASL _unit select 2)+((_unit selectionPosition "pilot"select 2)]])) then 
        
    {
        
    _unit setunitpos "MIDDLE";
        
    //0 = _unit fireAtTarget [_enemy];
        
    };
    };

    //Main loop
    while {true} do 
    {
        {
        
    _x setunitpos "UP";
        [
    _xcall _nearenemies;
        } foreach 
    units group player;
    sleep 10;
    }; 

  3. #13

  4. #14
    Quote Originally Posted by maturin View Post
    I think the biggest problem this could solve would be forcing AI to stop and shoot at units he has line of sight to that are under 50m away. If the scripts works instantly or close to it, the AI could actually be aware and competent in urban CQB.
    Would be even better, if it'd check how much of one's body is in LOS. If you stick the tip of your head up behind a window the AI shouldn't magically shoot you in the head, when it isn't aware of you.

    "...to boldly go where no one has gone before."

    Steam ID: Click me! | Origin ID: MrCharles9206

  5. #15
    @Saok & tpw:

    Splendid developments, thanks for sharing.

    Hee, these new commands look like making a number of neat developments possible; particularly amusing as a couple of posters immediately labelled them "useless" in the beta thread.

  6. #16
    Not the best video quality, but lineIntersects is not limited to AI stuff
    (I have another video but I'm too lazy to upload it)

    Please watch fullscreen and in HD



    Edit: lineIntersects is called 30 times per frame in this example.

    Xeno
    Last edited by Xeno; Jun 5 2012 at 20:17.

  7. #17
    does anyone have an idea when the official 1.61 will be released?

  8. #18
    First Lieutenant Kremator's Avatar
    Join Date
    Jun 8 2007
    Location
    Cambridge, UK
    Posts
    5,075
    Ummm what has this got to do with the lineIntersects?

    The full patch will be out when it is ready TM

  9. #19
    Quote Originally Posted by Kremator View Post
    Ummm what has this got to do with the lineIntersects?

    The full patch will be out when it is ready TM
    just asked because the commands only work with the beta for now. sorry for pushing this in here

  10. #20
    CWR² Developer SaOk's Avatar
    Join Date
    Nov 23 2006
    Location
    Helsinki, Finland
    Posts
    1,341
    Author of the Thread
    I updated the first post with example mission and updated the code to follow new eyePos command that is less heavy than the earlier method to get head´s position. Also added terrain check but it dosent seem to work for at least desert map. But the example works normally with objects/vegetarion/houses.

Page 2 of 12 FirstFirst 123456 ... LastLast

Similar Threads

  1. Line Of Sight code
    By Wolffy.au in forum ARMA 2 & OA : MISSIONS - Editing & Scripting
    Replies: 0
    Last Post: Feb 8 2011, 02:13
  2. Script/function request: Line-of-sight check
    By [FRL]Myke in forum ARMA 2 & OA : MISSIONS - Editing & Scripting
    Replies: 12
    Last Post: Dec 4 2009, 02:48
  3. Is getting line of Sight possible in anyway?
    By Second in forum ARMA - MISSION EDITING & SCRIPTING
    Replies: 13
    Last Post: Jun 22 2007, 20:28
  4. Non-Line-of-Sight Launch System (NLOS-LS)
    By Thunnder Bunny in forum ADDONS & MODS: DISCUSSION
    Replies: 0
    Last Post: Feb 24 2007, 01:11
  5. RPG - line of sight...
    By VecteR in forum TROUBLESHOOTING
    Replies: 12
    Last Post: Nov 25 2001, 11:48

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •