Results 1 to 10 of 10

Thread: Calling in Cobras

  1. #1

    Calling in Cobras

    Standing on the shoulders of those who have far more skill than me, I have created the following SQF that seems to work, OK. ID-CPL. Venori, who ever you are, thank you.

    It has some limitations in that ingress and egress points need to be predefined. I threw in the outbound heading from the ingress point just so that the marker could be placed anywhere and the spawned choppers could at least be moving in the desired direction toward the center of the map (I thought that made the most sense).

    What I would like to do is click 3 points in the map, instead.

    Ingress location
    CAS location
    Egress location

    Ingress and CAS locations would define an inbound vector whos direction could be assigned to the spawn function

    Code:
    [[(getMarkerPos _in) select 0, (getMarkerPos _in) select 1, 50], _az, "AH1Z", CAS_cg] call BIS_fnc_spawnVehicle;
    The same vector could be used to generate a spawn point at some distance from the CAS point along that vector, say 10K meters out. Pythagorean therom would apply if I am not mistaken.

    Just the same, the CAS point and egress point could be used to create an exit vector and the egress point would then just be 10K meters out along that vector.

    I need a little nudge in the right direction on what to read up on so that I can get the vector stuff working. Any suggestions you have are also appreciated.


    Code:
    // SQF for ARMA II
    // Call in 2-ship CAS strike (search and destroy) on position as marked on map
    // Butchered by LawnDartLeo from the work of ID-CPL. Venori (it's more him than me)
    // Place Functions module, "egress" and "ingress" markers on the map. Set outbound heading desired from ingress point.
    // Use -> null = ["ingress","egress",<0-359>] execVM "CAS_cobra.sqf"; in trigger using radio call.
    
    
    /*
    
    null = ["ingress","egress",obh] execVM "CAS_cobra.sqf";
    
    */
    
    // Input
    _in = _this select 0; // ingress marker name
    _out = _this select 1; // egress marker name
    _az = _this select 2; // ingress point outbound heading
    
    // Config
    _mapMarkText = "Click on the map to designate the CAS strike area";
    _closeMapMessage = "Close the map to initiate CAS strike";
    _CASpoint = "CAS_StrikeMarker";
    _CASMarkerType = "hd_destroy";
    _incomingMessage = "Cobra1 inbound for CAS strike on smoke, please stand by...";
    
    // Map click to determine where the strike will occur.
    CAS_Strikemarked = true;
    hint _mapMarkText;
    _mapString = format["CAS_StrikeMarker = createMarker [""%1"", _pos]; ""%1"" setMarkerType ""%2"";;CAS_Strikemarked=false",_CASpoint, _CASMarkerType];
    onMapSingleClick _mapString;
    waitUntil{!CAS_Strikemarked};
    onMapSingleClick "";
    
    // Wait till they close the map to continue.
    hint _closeMapMessage;
    waitUntil{!visibleMap};
    hintSilent "";
    
    // Have the player toss smoke to mark the spot.
    player playAction "ThrowGrenade";
    sleep 2;
    
    smoker = "SmokeShellRed" createVehicle (getMarkerPos "CAS_StrikeMarker");
    
    // Create the group and spawn 2 AH1Z named CAS_h1 and CAS_h2
    CAS_cg = creategroup west;
    _dp = [[(getMarkerPos _in) select 0, (getMarkerPos _in) select 1, 50], _az, "AH1Z", CAS_cg] call BIS_fnc_spawnVehicle;
    sleep 2;
    _dp2 = [[(getMarkerPos _in) select 0, (getMarkerPos _in) select 1, 50], _az, "AH1Z", CAS_cg] call BIS_fnc_spawnVehicle;
    CAS_h1 = _dp select 0;
    CAS_h2 = _dp2 select 0;
    CAS_planelist = [CAS_h1,CAS_h2];
    
    
    // Set behaviour
    CAS_h1 setCombatMode "Red";
    CAS_h2 setCombatMode "Red";
    CAS_h1 setBehaviour "aware";
    CAS_h1 setBehaviour "aware";
    
    
    // Set the first waypoint to where the marker was placed, second to the egress point.
    _wp = CAS_cg addWaypoint [getMarkerpos _CASpoint, 1];
    _wp setWaypointType "SAD";
    _wp1 = CAS_cg addWaypoint [getMarkerPos _out, 2];
    
    // Delete the crew and planes once they hit the egress point.
    [CAS_cg, 2] setWaypointStatements ["true", "{{deleteVehicle _x} forEach crew _x;} foreach units CAS_cg; {deletevehicle _x} foreach CAS_planelist;"];
    
    // Alert player that the CAS strike is incoming.
    sleep 5;
    (driver CAS_h1) sideChat _incomingMessage;

  2. #2
    Hi lawndartleo,

    Have you taken a look at Draper's Air Support Script (http://forums.bistudio.com/showthread.php?t=90365)?

    He uses cobras (although you can change the units to Apaches too!).

    Hope this helps.

    Best, Splicer.
    "We must either find a way or make one."
    - Hannibal

  3. #3
    That helps, too... Thanks.

    The spawn direction is the hitch right now. This guy spawns them on the ground, evidently (I have not tried the scripts, yet) and ties the spawn dir to the helo pad dir.

    His scripts also look rather graduate level and I am in preschool at the moment.

  4. #4
    Quote Originally Posted by lawndartleo View Post
    His scripts also look rather graduate level and I am in preschool at the moment.
    LOL. I just started looking into scripts a couple of weeks ago. I feel I'm just out of the womb!

    Glad I could be of some help.

    Best, Splicer.

  5. #5
    Cool!...atan2... wonderful tool. This is fun. Too bad school is starting again. Was an engineer, now going to be a nurse... but you can never take the engineer out of me.

  6. #6
    Good deal!

    I was going to major in computers/programing and ended up in chemistry!

    And like yourself, you can never take the computational/coding out of me!

    Splicer.

  7. #7
    I'm not getting how to limit the activation of the function. The function spawns 2 helos on radio alpha activation. The helos fly around, do their job and eventuially depart. It is not until that time that I want the radio alpha trigger to become available, again. I've searched and either I don't understand what I read or it doesn't seem to apply.

    Help!

  8. #8
    I'm no expert, but it seems that at the end of the sendFixed.sqf script there is a waitUntil function that waits for the planes to die.

    I'd put a // before the waitUntil function (to deactivate it) and see what happens. With luck that's what makes the menu avaible until the planes are back home.

    Best, Splicer.

  9. #9
    So that would require a second trigger with the this && <whatever>... correct? I'll give it a try.

  10. #10
    Don't know. Give it a try an see what happens.

    Like you put it before, these scripts were written at graduate level and I am also in preschool at the moment.

    Let me know how it goes. I'm very curious to get it to work right.

    UPDATE: I'd like to mention that my approach has 2 problems:

    1. The chopper won't go back to LZ1 unless, once int the water, I switch to one of the playable AI when I hear me (well... the player's voice) say "get on that chopper", so as soon as switch back to player THEN the chopper flies back home (LZ1).

    2. AND EVEN THEN I have a another problem: The chopper won't land at LZ1, it stays hovering. And if I enter the code:

    Chopper land "LAND";

    Then the @^#% pilot lands at the earliest possible place along the shore!

    This game is FUN! But, oh boy, do you have to master programing AND BIS' commands to get things to work some times...

    Best, Splicer.

Posting Permissions

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