Forum Jump :

Author Message


Posts: 1
Rank:


Level: Member

Country: uk
Location:
Occupation:
Age: 30
In-game name: [pXa] XMortX

 
#1 Posted at 2018-03-13 09:58        
     
Hi All,
I have tried to write a script that fails in my editor saying its receiving 0 in the position array when it expects 3.
Hopefully someone can explain what i have done wrong here?
Also to improve this i would like the unit to produce a set of waypoints it walks to, then stops for an amount of time before moving on to the next if anyone has suggestions how to do that.
Fairly green on Arma 3 scripting so help would be very appreciated.
Cheers in advance guys

private ["_pos", "_unitname"]
_pos = [] call BIS_fnc_randomPos; 
_unit = createAgent ["C_scientist_F", _pos, [], 0, "CAN_COLLIDE"];
_unitname = "peddler";
_initinit = format["[{
(objectFromNetId '%1') setVehicleVarName '%4'; 
(objectFromNetId '%1') setunitpos '%2'; 
(objectFromNetId '%1') disableAI '%3';
(objectFromNetId '%1') setVehicleAmmo %5;
(objectFromNetId '%1') setUnitAbility %6;
(objectFromNetId '%1') setDir %7;
}]", (netId _unit), "AUTO", "MOVE", _unitname, 0, 0.60000002, random 360]; 
[call compile format["%1",_initinit],"BIS_fnc_spawn", true, false] spawn BIS_fnc_MP; 
_unit call compile format ["%1=_this; publicvariable '%1'", _unitname]; 


Author Message


Posts: 143
Rank:


Level: Member

Country: us
Location: Pennsylvania
Occupation:
Age:
In-game name: Xian

 
#2 Posted at 2018-03-16 13:02        
     
Line 2 seems to be the culprit. Try using BIS_fnc_findSafePos instead:

[center, minDist, maxDist, objDist, waterMode, maxGrad, shoreMode, blacklistPos, defaultPos] call BIS_fnc_findSafePos
https://community.bistudio.com/wiki/BIS_fnc_findSafePos


One example from the wiki is :
_pos = [player, 1, 150, 3, 0, 20, 0] call BIS_fnc_findSafePos;
"Find position minimum 1m from from player but not further than 150m, not closer than 3m to any other object, not in the water, maximum gradient of 20, not on the shoreline"


As for your waypoints, if you wanted them to be random you could take a look at BIS_fnc_taskPatrol
https://community.bistudio.com/wiki/BIS_fnc_taskPatrol

This post was edited by XianGrim (2018-03-21 21:01, 185 days ago)