Jump to content

ArmaMan360

Member
  • Content Count

    464
  • Joined

  • Last visited

  • Medals

Posts posted by ArmaMan360


  1. All of a sudden a new problem. Sigh.

     

    Enemy AI spawned with DAC "on the fly" feature have suddenly become allies to me. They dont fire at me, however enemy spawned with spawngroup script attack me in the same mission. I am playing as east, and this is my spawn DAC script for testing purpose:

    // spawn enemy
    _values = ["z1",[1,0,0],[1,1,2,2],[],[],[],[1,1,1,0]];
    [_sidepos,80,80,0,0,_values] call DAC_fNewZone;
    

    WHat is the issue Silola?

    Nevermind. Res_Side was set to wrong.. :P


  2. Ok I have got a lead on this. I believe this line inside infantry_fnc.sqf is calling the diver pool line #16:

    if (surfaceiswater _pos) then {_pool=[_faction,1] call eos_fnc_getunitpool;}else{_pool=[_faction,0] call eos_fnc_getunitpool;};
    

    Because inside UnitPools.sqf, this is mentioned at line #261:

    if (_type isEqualTo 1) then {_tempArray=_diverPool};
    

    Now I do not know how to ignore surfaceiswater and spawn nothing there. I mean I just want stuff to spawn on land. I cant be going underwater to kill the last remaining diver guy.

     

    Anyone?

    Thank you.

    My question still remains unsolved guys. Please help :(


  3. It's ok for me :)

     

    Silola

    All of a sudden a new problem. Sigh.

     

    Enemy AI spawned with DAC "on the fly" feature have suddenly become allies to me. They dont fire at me, however enemy spawned with spawngroup script attack me in the same mission. I am playing as east, and this is my spawn DAC script for testing purpose:

    // spawn enemy
    _values = ["z1",[1,0,0],[1,1,2,2],[],[],[],[1,1,1,0]];
    [_sidepos,80,80,0,0,_values] call DAC_fNewZone;
    

    WHat is the issue Silola?


  4. Assuming, position has to be completely random among all possible positions, one way would be:

    _insideSpots = [];
    
    	{
    	_bPos = _x buildingPos 0;
    	_insideSpots = [];
    	_ct = 0;
    	
    	while {not ((_bPos select 0) == 0)} do
    		{
    		_insideSpots pushBack _bPos;
    		_ct = _ct + 1;
    		_bPos = _x buildingPos _ct;
    		};
    	}
    foreach _blds;
    
    _myPos = _insideSpots select (floor (random (count _insideSpots)));
    
    _veh setPos _myPos;
    

    1. Gathering all defined positions from all detected houses;

    2. Choosing randomly one of these positions;

    3. Placing _veh on this spot. 

     

    Note, in this way all positions have equal chance to be used, so the more positions defined in given building, the bigger chance, _veh will go there. To have instead equal chance for each house, for example something like this instead:

    _houses = [];
    
    	{
    	_bPos = _bldg buildingPos 0;
    	if not ((_bPos select 0) == 0) then
    		{
    		_houses pushBack _x
    		}
    	}
    foreach _blds;
    
    _bldg = _houses select (floor (random (count _houses)));
    
    _insideSpots = [];
    
    _bPos = _bldg buildingPos 0;
    _insideSpots = [_bPos];
    _bPos = _bldg buildingPos 1;
    _ct = 1;
    
    while {not ((_bPos select 0) == 0)} do
    	{
    	_insideSpots pushBack _bPos;
    	_ct = _ct + 1;
    	_bPos = _x buildingPos _ct;
    	};
    
    _myPos = _insideSpots select (floor (random (count _insideSpots)));
    
    _veh setPos _myPos;
    

    1. Collect from found buildings only those containing at least one defined position;

    2. Choose randomly one of them;

    3. Collect all positions in this chosen house;

    4. Pick at random one of these positions;

    5. Place _veh there.

    Rydy, this isnt working:

    call compile preprocessfile "SHK_pos\shk_pos_init.sqf";
    
    _sidepos = getMarkerPos "m1";
    _side = createCenter west;
    
    _groupHVT = createGroup east;
    _veh = _groupHVT createUnit ["O_officer_F", _sidepos, [], 0, "NONE"];
    sleep 0.3;
    
    removeAllWeapons _veh;
    removeAllAssigneditems _veh;
    removevest _veh;
    removeHeadgear _veh;
    _veh setCaptive true;
    _veh disableAI "move";
    _veh switchMove "Acts_SittingWounded_out";
    _veh disableAI "ANIM";
    
    sleep 0.4;
    
    _minus = nearestObjects [_sidepos,["PowerLines_Wires_base_F","Lamps_base_F","Piers_base_F","Land_NavigLight"],300];
    _blds = _sidepos nearObjects ["House",300];
    _blds = _blds - _minus;
    
    sleep 0.4;
    
    _houses = [];
    
    	{
    	_bPos = _bldg buildingPos 0;
    	if not ((_bPos select 0) == 0) then
    		{
    		_houses pushBack _x
    		}
    	}
    foreach _blds;
    
    _bldg = _houses select (floor (random (count _houses)));
    
    _insideSpots = [];
    
    _bPos = _bldg buildingPos 0;
    _insideSpots = [_bPos];
    _bPos = _bldg buildingPos 1;
    _ct = 1;
    
    while {not ((_bPos select 0) == 0)} do
    	{
    	_insideSpots pushBack _bPos;
    	_ct = _ct + 1;
    	_bPos = _x buildingPos _ct;
    	};
    
    _myPos = _insideSpots select (floor (random (count _insideSpots)));
    
    _veh setPos _myPos;
    
    
    sleep 0.3;
    

    It keeps spawning him at the default place.


  5. OK this is not working:

     

    call compile preprocessfile "SHK_pos\shk_pos_init.sqf";
    
    sleep 1;
    
    _sidepos = getMarkerPos "m1";
    _side = createCenter west;
    
    sleep 2;
    
    // Add task
    //Task ID-Task name-Task description and some other options
    ["Task9",true,["Some snipers have wandered in this area. Finish them","Snipers Spotted!", "Snipers Spotted!"],
    _sidepos, "AUTOASSIGNED",6,true,true] call BIS_fnc_setTask;
    
    // Spawn enemy officer
    for "_i" from 1 to (3 + floor(random 5)) do {
    _newpos = [_sidepos, [5,15], random 360, 0] call SHK_pos;
    _groupHVT = createGroup west;
    _veh = _groupHVT createUnit ["B_sniper_F", _newpos, [], 0, "NONE"];
    _veh setRank "COLONEL";
    _veh setSkill 1;
    _enmc = _i;
    _veh addEventHandler ["killed", {_enmc = _enmc -1; if (_enmc != 0) then { hintsilent format["Enemy remaining : %1",_enmc]}}];
    _groupHVT setBehaviour "SAFE";
    [_groupHVT, _sidepos, 300] call BIS_fnc_taskPatrol;
    sleep 0.6;
    };
    
    sleep 1;
    

  6. In addition, I just noticed that you are counting from 3 to (5 + floor(random 3)). That makes not much sense.

     

    You could count from 1 to (3 +(floor random 3))

     

    LOLLLL I cannot stop laughing after this. You are so right. I was trying to achieve minimum 3 units and bang you are so on target. My poor skills. lol

     

     

    Yes I will try sure Thanks. However I was always of the impression that any variable inside a script needs to be with an underscore if it is not already a previously defined function. Honestly, I tend to stay away from the function defining process as I find it soo mind boggling with all the { class tag .... thing going around, lol.

     

    I only play SP and I am happy with such intermediate scripting achieving my goals :D

    I will publish the mission for all asap. Its based on Altis and is 95% completed with 11 different random missions in all. More than 50 random locations possible. Its got logistics, a mobile HQ, a base, random start time, AI recruitment, and maybe even a small cutscene at the start :P

     

    And heck lot of SP fun ^^


  7. I think R3vo is suggesting to take this part out completely.

    Event handlers are persistant. You add it once and it will (with a few exceptions in multiplayer) remain until it is removed. Running that code will add an endless amount of the same event handler to each until until killed. Additionally, you will be adding that event handler to ALL units in the mission, regardless of side.

    Just add this code immediately after the "setSkill" call and before the "_groupHVT setBehaviour " call:

    _veh addEventHandler ["killed", {_enmc = _enmc -1; if (_enmc != 0) then {    hintsilent format["Enemy remaining : %1",_enmc]}}];
    Additionally, note that in your script example, the above line was missing an ending semi-colon. Also, this event handler will fail anyway because the variable "_enmc" is a local variable to the script you are running. "_enmc" needs to be declared as a public variable so it can be accessed outside of the scope of your script.

     

    Thank you Tyger, yeah I just copy pasted that line without removing the original.

     

    So I will add that line right after setskill as you mentioned, but I am sorry to bug you, how do I achieve turning _enmc as a local variable? Should I add this at the start of the script?:

    _enmc = _this select 0;
    

    P.S.: This is being utilized in a purely SP environment. If this is way too complicated than how you could have achieved then please give me an alternate line of codes. I am more than willing to adapt. In this side mission, no enemy will be spawned other than random number of snipers.


  8. I would already add an eventHandler to the units just after you spawned them.

     

     

    _veh = _groupHVT createUnit ["B_sniper_F", _newpos, [], 0, "NONE"];

     

    _veh addEventhandler....

     

    In addition, you can use the for loop to create an array with all the freshly spawned units. Use the following command for that.

     

    https://community.bistudio.com/wiki/pushBack

     

    Dear R3vo, your answer is a piece of art.

     

    Is this correct?

    for "_i" from 3 to (5 + floor(random 3)) do {
    _newpos = [_sidepos, [5,15], random 360, 0] call SHK_pos;
    _groupHVT = createGroup west;
    _veh = _groupHVT createUnit ["B_sniper_F", _newpos, [], 0, "NONE"];
    _veh setRank "COLONEL";
    _veh setSkill 1;
    _groupHVT setBehaviour "SAFE";
    [_groupHVT, _sidepos, 20] call BIS_fnc_taskPatrol;
    _veh pushBack _i;
    
    _enmc = {alive _veh and side _veh == west} count allUnits;
    while (enmc > 1) do {
    {
    _veh addEventHandler ["killed", {_enmc = _enmc -1; if (_enmc != 0) then {
    hintsilent format["Enemy remaining : %1",_enmc]}}]
    } foreach allunits;
    sleep 0.4;
    };
    
    _veh addEventHandler ["killed", {_enmc = _enmc -1; if (_enmc != 0) then {
        hintsilent format["Enemy remaining : %1",_enmc]}}]
    
    sleep 0.6;
    
    };

  9. The variation with BIS_fnc_selectRandom is ~ 1%, so pretty much negligible. It will probably even become zero if  n - > infinite

    Hmmmm. But when I restarted the mission over and over again, it frequently chose the nearer positions as the markers with higher numbers in their names were placed farther away.

    I donno man. Maybe a better way? You personally use selectrandom?


  10. _sidepos = getMarkerPos "m1";
    _side = createCenter west;
    
    sleep 1;
    
    // Add task
    //Task ID-Task name-Task description and some other options
    ["Task9",true,["Some snipers have wandered in this area. Finish them","Snipers Spotted!", "Snipers Spotted!"],
    _sidepos, "AUTOASSIGNED",6,true,true] call BIS_fnc_setTask;
    
    // Spawn enemy officer
    for "_i" from 3 to (5 + floor(random 3)) do {
    _newpos = [_sidepos, [5,15], random 360, 0] call SHK_pos;
    _groupHVT = createGroup west;
    _veh = _groupHVT createUnit ["B_sniper_F", _newpos, [], 0, "NONE"];
    _veh setRank "COLONEL";
    _veh setSkill 1;
    _groupHVT setBehaviour "SAFE";
    [_groupHVT, _sidepos, 20] call BIS_fnc_taskPatrol;
    
    sleep 0.6;
    
    };
    
    sleep 1;
    
    _enmc = {alive _x and side _x == west} count allUnits;
    while (enmc > 1) do {
    	{
    	_x addEventHandler ["killed", {_enmc = _enmc -1; if (_enmc != 0) then {
    	hintsilent format["Enemy remaining : %1",_enmc]}}]
    	} foreach allunits;
    	sleep 0.4;
    };
    
    // task complete hint
    ["Task9","Succeeded"] call BIS_fnc_taskSetState;
    

    Fix it please :)


  11. _one = 0;
    _two = 0;
    _three = 0;
    _four = 0;
    _five = 0;
    
    for "_i" from 1 to 100000 do
    {
        _num = [1,2,3,4,5] call BIS_fnc_selectRandom;
        
        switch (_num) do {
            case 1: { _one = _one + 1 };
            case 2: { _two = _two + 1 };
            case 3: { _three = _three + 1 };
            case 4: { _four = _four + 1 };
            case 5: { _five = _five + 1 };
        };
        hintSilent format ["One: %1\nTwo: %2\n Three: %3\n Four: %4\n Five: %5\n",_one,_two,_three,_four,_five];
    };

    Whatever you heard, it's not true ;)

     

     

    I was referring to this :https://forums.bistudio.com/topic/131090-round-random-unexpected-behaviour-round-floor-expected-behaviour/ :)


  12. I got these arrays:

    _city = ["city1","city2","city3","city4","city5","city6","city7","city8","city9","city10","city11","city12","city13","city14","city15","city16","city17","city18","city19","city20","city21","city22","city23","city24","city25","city26","city27","city28","city29","city30","city31","city32","city33"];
    
    _base = ["base1","base2","base3","base4","base5","base6","base7","base8","base9","base10","base11","base12","base13","base14","base15","base16","base17","base18","base19","base20","base21","base22"];
    
    _allloc = ["city1","city2","city3","city4","city5","city6","city7","city8","city9","city10","city11","city12","city13","city14","city15","city16","city17","city18","city19","city20","city21","city22","city23","city24","city25","city26","city27","city28","city29","city30","city31","city32","city33","base1","base2","base3","base4","base5","base6","base7","base8","base9","base10","base11","base12","base13","base14","base15","base16","base17","base18","base19","base20","base21","base22"];
    
    

    These are 3 arrays, _city = 33 values, _base = 22 values, and _allloc = 55 values. Each is a marker name for random mission location. So I will be utilizing a value from only one of these 3 main arrays at a time.

     

    I read about an issue with bis_fnc_selectrandom "leaving out" the first and last value and more probability towards whats in between.

     

    Which is the best way now to return a truely random value which is like throwing a 6-sided die, where the possibility throughout is 1/6.

     

    Any of the following 3 or whatever the geniuses in the community would like to suggest. :)

    _pos = _city Bis_fnc_selectRandom; // or
    _pos = floor (random _city); // or
    _pos = round random _city; //
    
    

    By the way I am running 1.52 Arma client not Dev Build as there changes to the selectrandom i guess :)

    Thanks :)


  13. Thank you all. Considering I have got a unit _veh created. How do I put him in a house? I am having trouble adopting this approach in entirety. Any leads please? As per Rydy's example, now what?

    _minus = nearestObjects [_sidepos,["PowerLines_Wires_base_F","Lamps_base_F","Piers_base_F","Land_NavigLight"],300];
    _blds = _pos nearObjects ["House",300];
    _blds = _blds - _minus;
    

  14. I am using the following script at the end of my random objectives mission to delete the entire spawned AO elements:

    .....
    {if (!(isplayer _x)) then {deleteVehicle _x;};} foreach nearestobjects [_setpos,[
    	"air","StaticWeapon","Landvehicle"
    	],1000];
    	sleep 10;
    {if (!(isplayer _x)) then {deleteVehicle _x;};} foreach nearestobjects [_setpos,[
    	"man"
    	],1000];
    

    Works great. But, it also deletes my squad mates which belong to east side. And there are certain tasks which spawn near my base so I am afraid this script will delete the soldiers at my base  also as it deletes everything !(isplayer). I wish to add just a  side check in it along with !(isPlayer). I have tried this also but doesnt work:

    {if (!(isplayer _x) && side _x == west) then {deleteVehicle _x;};} foreach nearestobjects [_setpos,[
    	"air","StaticWeapon","Landvehicle"
    	],1000];
    	sleep 10;
    {if (!(isplayer _x) && side _x == west) then {deleteVehicle _x;};} foreach nearestobjects [_setpos,[
    	"man"
    	],1000];
    

    Any one? Thanks.


  15. Ok ... there is no DAC initialization within your mission and that's the reason for all the error messages.

     

    If you use the addon version, then u have to insert the DAC logic (intern or extern) to initialize DAC.

    But if you use the script version of DAC, then u need the following code line (first line) within your init.sqf:

     

    DAC_Basic_Value = 0; execVM "DAC\DAC_Config_Creator.sqf";

     

    Otherwise you can't call any DAC function without any error.

    Basicly DAC shows you a small message, after the initialization process was successful, as u can see here ...

     

    XTpWhwn.png

     

    And now .... good luck with your mission ;)

     

    Silola

     

    ====================================================

     

    As long as you edit your mission, turn on the DAC markers, in order to see what happens, during a new DAC zone is generated:

     

    DAC_Marker = 1;

    Thanks :)


  16. Here's a list of objects I filter out of the nearobjects house_f result.

    _excludedbuildings = ["Land_TTowerSmall_1_F", "Land_Dome_Big_F", "Cargo_Patrol_base_F", "Cargo_House_base_F", "Cargo_Tower_base_F", "Cargo_HQ_base_F","Piers_base_F", "PowerLines_base_F", "PowerLines_Wires_base_F", "PowerLines_Small_base_F", "Land_PowerPoleWooden_L_F",  /*"Lamps_base_F",*/ "Land_Research_HQ_F", "Land_Research_house_V1_F", "Land_MilOffices_V1_F", "Land_TBox_F", "Land_Chapel_V1_F","Land_Chapel_Small_V2_F",  "Land_Chapel_Small_V1_F", "Land_BellTower_01_V1_F", "Land_BellTower_02_V1_F", "Land_fs_roof_F","Land_fs_feed_F", "Land_Windmill01_ruins_F", "Land_d_Windmill01_F", "Land_i_Windmill01_F","Land_i_Barracks_V2_F", "Land_spp_Transformer_F", "Land_dp_smallFactory_F", "Land_Shed_Big_F", "Land_Metal_Shed_F","Land_i_Shed_Ind_F","Land_Communication_anchor_F", "Land_TTowerSmall_2_F", "Land_Communication_F","Land_cmp_Shed_F", "Land_cmp_Tower_F", "Land_u_Shed_Ind_F", "Land_TBox_F"];
    
    

    Omg thats a handful. Thanks O.O

×