Page 1 of 2 12 LastLast
Results 1 to 10 of 18

Thread: Spawned unit Attacks!

  1. #1

    Spawned unit Attacks!

    I try and try, but I cant figure out, how to make spawned unit go to nearest unit from list [s1,s2...Techpriest] and attack it.

  2. #2
    Quote Originally Posted by KanePayne View Post
    I try and try, but I cant figure out, how to make spawned unit go to nearest unit from list [s1,s2...Techpriest] and attack it.
    If it's some kind of WH40k units, you'd better post this in their topic.

    WW1 ArmA:CWA Mod || Romans and Barbarians ArmA:CWA Mod
    Goodbye W0lle, we'll miss you

  3. #3
    Private First Class
    Join Date
    Oct 31 2011
    Posts
    12
    Author of the Thread
    :/
    Im asking for solution of my problem, I just want to know is there anything like
    _this comandtarget/attack/whatever [s1,s2,s3]
    I look everywhere and cant find solution in google or this forum.

    I figured out first part, but still cant make nearest target detector.
    Last edited by KanePayne; Dec 24 2011 at 13:10.

  4. #4
    Ok, so you'll need the findunit.sqf function, which can be found on OFPEC or just copy and paste this in a "findunit.sqf" script file :

    Spoiler:


    Then the command to make your unit move to the nearest unit of the given array are the following script lines :
    Code:
    myarray = [s1,s2...Techpriest]
    _closest = ([_unit, 9999, my_array] call findUnits) select 0
    _unit domove getpos _closest

  5. #5
    Private First Class
    Join Date
    Oct 31 2011
    Posts
    12
    Author of the Thread
    Could you guide me a bit more? I have everything set, no errors, but spawned unit still doesnt move.

  6. #6
    There was a typo here :

    Code:
    my_array = [s1,s2...Techpriest]
    _closest = ([_unit, 9999, my_array] call findUnits) select 0
    _unit domove getpos _closest
    Anyway, could you post your spawning script here ? The unit must be out of a group i guess, so you may add some :

    Code:
    [_unit] join grpnull
    after the spawning.

  7. #7
    Private First Class
    Join Date
    Oct 31 2011
    Posts
    12
    Author of the Thread
    "SoldierE" createUnit [spawn1,WAVE1,"M1=this",1,"PRIVATE"]; [this] exec "Hunt.sqs"
    Thats all.

  8. #8
    Code:
    "SoldierE" createUnit [spawn1,WAVE1,"M1=this",1,"PRIVATE"]; [M1] exec "Hunt.sqs"
    By the way the hunt.sqs should look like :

    Code:
    _unit = _this select 0
    my_array = [s1,s2...Techpriest]
    
    [_unit] join grpnull
    _closest = ([_unit, 9999, my_array] call findUnits) select 0
    ~1
    _unit domove getpos _closest
    
    exit
    Last edited by ProfTournesol; Dec 24 2011 at 14:10.

  9. #9
    Private First Class
    Join Date
    Oct 31 2011
    Posts
    12
    Author of the Thread
    Thnx, works fine now.
    Maybe I'll prepare template & put somewhere.

    EDIT:

    I tested It and AI goes to first unit from
    my_array = [s1,s2...Techpriest]
    No matter the distance
    Last edited by KanePayne; Dec 24 2011 at 14:29.

  10. #10
    Quote Originally Posted by KanePayne View Post
    Thnx, works fine now.
    Maybe I'll prepare template & put somewhere.

    EDIT:

    I tested It and AI goes to first unit from

    No matter the distance
    Mmm... could you post the exact content of my_array ?

Page 1 of 2 12 LastLast

Posting Permissions

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