Jump to content

sarogahtyp

Member
  • Content Count

    2494
  • Joined

  • Last visited

  • Medals

Posts posted by sarogahtyp


  1. Okay guys, with ur hints it is now a good working script and it works with a dedicated server too.

    If anyone wish to use it just do it.

     

    The only thing what I dont like with it is that the driver the spawned AI and the vehicle must be in the same group.

    I created a new group and moved all into that.

    I wish I could let the driver/player in his own group. but i think there is no solution for that problem.

     

    But as I said, script is working now and I m happy with it.

     

    Thanks a lot.
     

     

     

    
    if (!isServer) exitWith {true};
    /*
    	Author: Sarogahtyp
    	Title: SSAIG - Sarogahtyps Simple AI Gunners
    
    	Description: Embarks AI gunners for a player driven vehicle. Is thought to be executed server/HC-side and not on client.
    
    	Arguments:
    	object - vehicle which should be filled with AI gunners
    	
    	Return value:
    	boolean - true if script has been finished
    */
    
    params [["_vec", objNull, [objNull]]];
    
    if ((!(_vec in vehicles) and !isPlayer _vec) or isNull _vec or damage _vec isEqualTo 1) exitWith {true};
    
    _player = driver _vec;
    
    if (!isPlayer _player or isNull _player or !alive _player) exitWith {true};
    
    if (isNull objectParent _player) exitWith {["You can get AI gunners for any vehicle here."] remoteExec ["hintSilent", _player]; true}; 
    
    _spawn_pool = ["B_Soldier_GL_F","B_HeavyGunner_F"];
    _turrets = fullCrew [_vec, "", true];
    _squadpos = _vec getPos [10, random 360];
    _squad = createGroup [west, false];
    _vec_full = true;
    
    // ********** Check if there is a seat where an AI can be spawned and spawn it
    {
     _x params ["_c_t1", "_c_t2", "_c_t3", "_c_t4", "_c_t5"];
    
     //turret empty?
     if(isNull _c_t1) then  
     {
      //is turret just a "turret" type?
      if(toLower _c_t2 isEqualTo "turret") then
      {
       _unit = _squad createUnit [(selectRandom _spawn_pool), (_squadpos getPos [2, (random 360)]), [], 0, "NONE"];
       _unit assignAsTurret [_vec, _c_t4];  
       _unit moveInTurret [_vec, _c_t4];
       _vec_full = false;
      }
      else
      {
       // is turret gunner seat?
       if(toLower _c_t2 isEqualTo "gunner") then
       {
        _unit = _squad createUnit [(selectRandom _spawn_pool), (_squadpos getPos [2, (random 360)]), [], 0, "NONE"];
        _unit assignAsGunner _vec;
        _unit moveInGunner _vec; 
        _vec_full = false;
       }
       else
       {
        // is turret commander seat?
        if(toLower _c_t2 isEqualTo "commander") then
        {
         _unit = _squad createUnit [(selectRandom _spawn_pool), (_squadpos getPos [2, (random 360)]), [], 0, "NONE"];
         _unit assignAsCommander _vec;  
         _unit moveInCommander _vec; 
         _vec_full = false;
        }
        else
        {
         // is turret cargo seat and one can fire a gun from it?
         if(toLower _c_t2 isEqualTo "cargo" and _c_t5) then
         {
          _unit = _squad createUnit [(selectRandom _spawn_pool), (_squadpos getPos [2, (random 360)]), [], 0, "NONE"];
          _unit assignAsCargo _vec;  
          _unit moveInCargo [_vec, _c_t3];
          _vec_full = false;
         }; // cargo end
        }; // commander end
       }; // gunner end
      }; // turret end
     }; // empty seat end
     true
    } count _turrets;
    
    //exit if no AI was spawned
    if (_vec_full) exitWith {["You ve no empty seat to shoot from on your vehicle."] remoteExec ["hintSilent", _vec]; true};
    
    ["AI gunners embarked. They ll engage enemies now."] remoteExec ["hintSilent", _player];
    
    //track _units for later deletion
    [_vec, _squad] spawn 
    {
     params ["_vec", "_squad"];
     
     // make squad agressive and skilled
     _squad setCombatMode "RED";
     _squad setBehaviour "COMBAT";
    
    {
     _x setSkill 1;
     _x setskill ["aimingAccuracy", 1];
     _x setskill ["aimingShake", 1];
     _x setskill ["aimingSpeed", 1];
     _x setskill ["endurance", 1];
     _x setskill ["spotDistance", 1];
     _x setskill ["spotTime", 1];
     _x setskill ["courage", 1];
     _x setskill ["reloadSpeed", 1];
     _x setskill ["commanding", 1];
     _x setskill ["general", 1];
     true
    } count (units _squad);
    
     _timeout = time + 3600;
    	
     waitUntil 
     {
      sleep (60 + random 60); 
      (damage _vec isEqualTo 1 or isNull _vec or {alive _x} count units _squad < 1 or time > _timeout)
     };
    
     _squad deleteGroupWhenEmpty true;
    
     {
      deleteVehicle _x;
      true
     } count units _squad;
    };
    true

     

    • Like 1

  2. 1. assignAsCargo does not take array as right argument.

    2. moveInCargo's right argument's second element in array must be Number, i.e. cargoIndex, not Array (in your case turretPath)

    3. Even if you use _c_t3 instead of _c_t4 you might not sit all soldiers from squad on the same place (using same cargo index for all). Collect all free cargo indexes and move one soldier per one cargo index.

     

    Thank u.  U found the mistakes in the  uncommented code but i think i dont need the cargo seats cause they r also turrets and r coverd by the "handle turrets" part of the script.

     

    _temp_squad consist of 1 unit only so point 3. isnt a mistake.

     

    but my main problem is that the AI gets out of the vecs instantly after embarking it.


  3. _unit = _this select 0;
    if (_unit ammo "autocannon_35mm" < _ammoCountForFlak) then 
    {
     (_unit) setAmmo ["autocannon_35mm", 680];
     _tarPos = [];
     _target = 0;
    
     if (isPlayer (assignedGunner _unit)) then 
     {
      _target = cursorTarget;
    
      if (_unit distance _target < _maxDistance) then 
      {
       _tarPos = getPos _target;
      };
     } 
     else 
     {
      _possTar = _unit nearTargets _maxDistance;
      if ((count _possTar) > 0) then
      {
       _threat = 0;
       {
        if (_x select 3 > _threat) then 
        {
         _threat = _x select 3;
         _target = _x select 4;
         _tarPos = getPos _target;
        };
                
       } forEach _possTar;
    
       _unit fireAtTarget [_target];
      };
     };
    
     if ((count _tarPos) > 0) then 
     {
      _tarX = _tarPos select 0;
      _tarY = _tarPos select 1;
      _tarZ = _tarPos select 2;
    
      if (_tarZ > _targetMinHeight) then 
      {
       _flakDis = ((speed _target) * (_speedDispersion / 100)) + ((_unit distance _target) * (_distanceDispersion / 500));
       _disX = (random (_flakDis * 2)) - _flakDis;
       _disY = (random (_flakDis * 2)) - _flakDis;
       _disZ = (random (_flakDis * 2)) - _flakDis;
       _flak = "SmallSecondary" createVehicle [_tarX + _disX, _tarY + _disY, _tarZ + _disZ];
      };
     };
    };
    

    i think the problem is located in line 28.

    the variable _target contains 0 at this point but it should be the target object.

     

    in line 10 this is done correct but only if the assigned gunner is _unit.

    In the else case after line 18 there is no such object assignment for variable target.

    because of that _target is the number as it was inited. In this case 0.

    You cant get the position of a number.

     

    that where wrong thoughts... just thinking about again.


  4. With ur help I got some working peace of code now. Thank u for that.
    But there r some problems with it.

    First, would someone tell me how I can do a spoiler in this forum, please?

    The main problem is that it works perfect in 2D editors preview but if i test it at my dedicated server then the spawned A.I. is directly moved into the vehicle via moveIn command but then it gets out instantly.
    After that it tries to get in again and again but it will get out instantly every time.

    Only for copilots of huron and ghosthawk it is working. They dont leave the vehicle.

     

     

     

    ai_gunners.sqf:

     

    if (isServer) then
    {
     _vec = _this select 0;
     _player = driver _vec;
     _turrets = fullCrew [_vec,"", true];
     _squadpos = getMarkerPos "gunnermarker";
     _turret_num = (count _turrets)-1;
     _leader = false;
     _squad = [];
    
     for "_x" from 0 to _turret_num do
     {
      _cur_tur = _turrets select _x; //get values for actual vec
      _c_t1 = _cur_tur select 0; //unit at seat or objNull
      _c_t2 = _cur_tur select 1; //role for seat (driver,gunner,commander,turret,cargo)
      _c_t3 = _cur_tur select 2; //cargo index
      _c_t4 = _cur_tur select 3; //path to seat
      _c_t5 = _cur_tur select 4; //boolean value, true if a person is able to fire from this seat
    
      if(isNull _c_t1) then //check if seat is empty
      {
    // ******* handle commander seat
       if((_c_t2 == "commander") or (_c_t2 == "Commander")) then //check role of seat
       {
        _temp_squad = [_squadpos, WEST, 1] call BIS_fnc_spawnGroup; //spawn 1 soldier
    
        {
         _x setSkill 1;
         _x assignAsCommander _vec;
         _x assignAsTurret [_vec, _c_t4];
         [_x] allowGetIn true;
         [_x] orderGetIn true;
         _x moveInCommander _vec;
        }forEach units _temp_squad;
    
        if (!_leader) then //move ai in the correct squad
        {
         _squad = _temp_squad;
         _leader = true;
        }
        else
        {
         {
          [_x] join _squad;
         }forEach units _temp_squad;
        };
       };
    
    // ******* handle gunner seat
    
       if((_c_t2 == "gunner") or (_c_t2 == "Gunner")) then
       {
        _temp_squad = [_squadpos, WEST, 1] call BIS_fnc_spawnGroup;
    
        {
         _x setSkill 1;
         _x assignAsGunner _vec;
         _x assignAsTurret [_vec, _c_t4];
         [_x] allowGetIn true;
         [_x] orderGetIn true;
         _x moveInGunner _vec;
        }forEach units _temp_squad;
    
        if (!_leader) then
        {
         _squad = _temp_squad;
         _leader = true;
        }
        else
        {
    
         {
          [_x] join _squad;
         }forEach units _temp_squad;
        };
       };
    
    // ******* handle turret
    
       if((_c_t2 == "turret") or (_c_t2 == "Turret")) then
       {
        _temp_squad = [_squadpos, WEST, 1] call BIS_fnc_spawnGroup;
    
        {
         _x setSkill 1;
         _x assignAsTurret [_vec, _c_t4];
         [_x] allowGetIn true;
         [_x] orderGetIn true;
         _x moveInTurret [_vec, _c_t4];
        }forEach units _temp_squad;
    
        if (!_leader) then
        {
         _squad = _temp_squad;
         _leader = true;
        }
        else
        {
    
         {
          [_x] join _squad;
         }forEach units _temp_squad;
        };
       };
    
    /* this part is not working for some reason but it could be unnecessary because all desired A.I. is spawning without it
    
    // ******* handle cargo
       if(((_c_t2 == "cargo") or (_c_t2 == "Cargo")) and (_c_t5 == true)) then
       {
        _temp_squad = [_squadpos, WEST, 1] call BIS_fnc_spawnGroup;
    
        {
         _x setSkill 1;
         _x assignAsCargo [_vec, _c_t4];
         [_x] allowGetIn true;
         [_x] orderGetIn true;
         _x moveInCargo [_vec, _c_t4];
        }forEach units _temp_squad; 
    
        if (!_leader) then
        {
         _squad = _temp_squad;
         _leader = true;
        }
        else
        {
    
         {
          [_x] join _squad;
         }forEach units _temp_squad;
        };
       };
    */
    
      }; //empty seat check end
     }; // for do end
    
    //make the squad aggressive
     _squad setCombatMode "RED";
     _squad setBehaviour "COMBAT";
    
     waitUntil //wait for players death or until he is disconnected
     {
      sleep 1;
      (!(alive _player) or (isNull _player))
     };
    
    // delete whole squad
    
     {
      deleteVehicle _x;
     } forEach units _squad;
    }; //Server end

  5. You may take a look into the config. They will surely give you the seats.

    How can I do that by scipt?

    okay for commander and gunner i think this this could be a solution:

     

    if (isNil {commander _vec}) then{hint "no commander 
    seat";}else{hint "commander seat available";};

    Edit: I found allTurrets now but I dont know what FFV-turrets are. Could someone explain it?

     

    Edit: FFV means Fire From Vehicle

    • Like 1

  6. Hey guys,

    i hope for ur help. I wanna spawn AI gunners for a vehicle the player has chosen to drive.

    createVehicleCrew is no option cause i wont spawn inside of the vec. I wanna spawn outside and let em get in.

     

    For that I wanna know if the vehicle chosen by player has a gunner and/or a commander seat and how much turrets it has.
    Also I need to get the correct turretPath to that turrets.

     

    Additional it would be nice to spawn some AI which should take their seat at these cargo seats from where they are able to shoot with their own guns.

    So I need the cargo index of that seats

    Any help is apreciated. Thanks a lot.


  7. How is this done? Is there a way I can turn the 3D file into an SQM?

     

    If u mean how to convert the binariezed mission.sqm to a text format mission.sqm:

     

    "Save As:"  >> delete the hook from save binariezed.


  8. Every variable has a limit somewhere, represented by the bits or bytes its using. In that case its 8 bits or 1 byte as u calculated above.

    I think the next possible size would be 2 bytes which means 16 bit and a maximum value of 65536 states represented in that 16 bits which means it could be 65535 players then because 0 is a state too.

     

    I ve never seen a server with about 200 players ( maybe i never looked for it). Why should that value be increased?


  9. I m sorry, but i ve never tried that.

     

    You could try to find a solution with cameraEffect but i think u have to create a camera first.

     

    Here is a tutorial for a bullet cam which u can use to understand how camera creation works.

     

    http://killzonekid.com/arma-scripting-tutorials-a-simple-bullet-cam/

     

    with cameraEffect you can force a fixed camera view for external cam.

     

    Also u should post ur script to let us look for mistakes.


  10. Anybody knows how to make this work?  :mellow:

     

    Without ur init.sqf its a kind of guessing instead of knowing about it.

     

    First I think it should be done for all clients.

    The "regular" Namespace ist the MissionNamespace so the following on each client should do the job:

    RscSpectator_allowFreeCam = false;

    Alternative as it is a global variable u could execute the following on the server or headless client (or any other client) only:

    RscSpectator_allowFreeCam = false;
    publicVariable "RscSpectator_allowFreeCam";

    That will set the variable and broadcast it to every client.

     

     

    The last alternative is to broadcast it while using setVariable with the public parameter (last parameter):

     

     

    missionNamespace setVariable ["RscSpectator_allowFreeCam", false, true];
    • Like 1

  11. I can confirm that issue at domination map hosted on dedicated linux server.

    If I connect with my client PC i get a bird/crow sometimes.

    If I disconnect to lobby and choose another role/player then i can connect and play as usual.

    If I diconnect to lobby again after that and choose the first role where i became a bird then i can play as soldier again, too.

     

    That happend 2 times today.

     

    And no i ve none hacked, cracked content on my PC.

     

    Edit: I forgot to say that I imported the mission for use with eden 3d editor and uploaded it to the dedicated server with those mission.sqm which is in eden format now.

     

     

    After rolling back to 2D version of the mission pbo file i never saw a seagull again.


  12. i would do a script for that which is started by a trigger or waypoint.

    u should not write all of that stuff in the init line.

    in a script u could use the name of the tank as a global variable of it.

    if ur tank is named TANK1 then u could use

    _tank = TANK1;

    and the local variable _tank represents ur TANK1.

    same with _target.

    name ur target TARGET1

    and in the script u can do

    _target = TARGET1

    but u ve to learne some scripting for it as the init line is very limited...


  13. as i said provide the informations i requested in my first post to get help.

    i strongly recommend again to not use that auto detection script cause its not released for arma3.

    there are people got it running with arma3 but they changed something in that script as u can read here

    https://forums.bistudio.com/topic/145948-elecs-headlessclient-auto-detection-switch/

    i m interested in helping u but not with that scipt and not without the requested information.


  14. i would suggest

    onMapSingleClick "";

    after your loop is finished.


    Container:

    Spoiler

     


    
    Saro_fnc_rnd_civ_bomber =
    {
     params [["_civ", objNull,[objNull]], ["_chance", 3, [0]]];
    
     if ((random 100 > _chance) || (isNull _civ)) exitWith {true};
    
     _this spawn
     { 
      params ["_bomber"];
      private _target_players = [];
    
      while {(alive _bomber) && !(isNull _bomber)} do
      {
    
       // wait until players are in range
       waitUntil 
       {
        sleep (5 + random 10);
        _target_players = (allPlayers - entities "HeadlessClient_F") select {(alive _x) && ((_x distance _bomber) < 200)};
        ((count _target_players > 0) || !(alive _bomber) || (isNull _bomber))
       };
    
       // end everything if suicide bomber is already dead
       if (!(alive _bomber) || (isNull _bomber)) exitWith {};
    
       // follow nearest player
       while {alive _bomber && !(isNull _bomber)} do
       {
        private _plyr_cnter = 0;
        private _sort_array = []
    
        // get nearest player
        _target_players = _target_players apply {[_x distance _bomber, _x]};
        _target_players sort true;
        _target = _target_players select 0 select 1;
        _can_see = [_target, "VIEW", _bomber] checkVisibility [eyePos _target, eyePos _bomber];
        _wp = currentWaypoint group _bomber;
        _wp setWaypointPosition [position _target, 0];
        if ((_can_see < 0.3) || _close2target) then
        {
         _wp setWaypointSpeed "FULL";
        }
        else
        {
         _wp setWaypointSpeed "NORMAL";
        }; 
     
    
       } // end follow while
       
          
        _boom = "M_Mo_82mm_AT_LG" createVehicle (getPos _this);
      } // main while end
     } //spawn end
    } //fnc end

     

     


  15. Only the last group will have that name:

     

    The group is already assigned to the _group1 variable. If you need this variable to be global so that it is usable in your next trigger, simply remove the underscore before "group1". Keep in mind, however, that if you run this spawn code more than once, only the last spawned group will be "group1".

     

    You should use an array to spawn and handle multiple groups

×