Jump to content

Recommended Posts

 

 So this script (not shown in entirety) is run for every unit that is either placed or spawned in game and is meant to assign different skill values and then some. There is a small chance that a unit will spawn as a special Agent and im trying to attach a map marker along with a voice "Agent in you area" with each agent spawned. It works but the problem while the text and voice announce for every spawned agent, the Marker only appears once or it is constantly spawning on top of itself (most likely) - somehow only locking on to the first _pos variable named over and over and im not sure why. Important part in red at bottom

 

if ((side _this == east) and (!isPlayer _this)) then {
 
                _SfaA =_this skillFinal "aimingAccuracy";
                _sFx = _sFaA * .1;
                _sFAs = _this skillFinal "aimingSpeed";
                _sFxG = _sFAs * .08;
                _sFAsh = _this skillFinal "aimingShake";
                _sFxH = _sFAsh * .1;
                _SfsD = _this skillFinal "spotDistance";
                _sFxb = _SfSd * .6;
                _SfsT = _this skillfinal "spotTime";
                _sFxc = _SfsT * .6;
                _Sfcou = _this skillFinal "courage";
                _sFxd = _Sfcou * .2;
                _Sfcom = _this skillFinal "commanding";
                _sFxe = _Sfcom * .3;
                _SfGen = _this skillFinal "general";
                _sFxf = _SfGen * .2;
                _sfRS = _this skillFinal "reloadSpeed";
                _sFxi = _sfRS * .2;            
                _this setskill ["spotDistance",_sFxb];
                _this setskill ["spotTime",_sFxc];
                _this setskill ["courage",_sFxd];
                _this setskill ["commanding",_sFxe];
                _this setskill ["general",_sFxf];
                _this setskill ["aimingAccuracy",_sFx];
                _this setSkill ["aimingSpeed", _sFxG];
                _this setSkill ["aimingShake", _sFxH];
                _this setSkill ["reloadSpeed", _sFxi];
                /* _this setUnitTrait ["camouflageCoef",0.00040]; */
                _num = (random 100);
                _lowSkill = random  [.1,.3,.6];
                
                _factionSoldier = faction _this;
                Recon_East_2 = ["KSF","ASG","RUS","MGS","PLA","HZ"];
                
                if (_factionSoldier in Recon_East_2) then {_this setSkill ["aimingAccuracy", random [0.08, 0.1, 0.2]]};
                if (_factionSoldier in Recon_East_2) then {_this setSkill ["aimingSpeed",  1]};
                if (_factionSoldier in Recon_East_2) then {_this setSkill ["aimingShake",  1]};
                if (_factionSoldier in Recon_East_2) then {_this setSkill ["spotDistance", random [0.6, 0.8, 1]]};
                if (_factionSoldier in Recon_East_2) then {_this setSkill ["spotTime", 1]};
                if (_factionSoldier in Recon_East_2) then {_this setSkill ["reloadSpeed",  1]};
                if (_factionSoldier in Recon_East_2) then {_this setSkill ["courage", 1]};
                if (_factionSoldier in Recon_East_2) then {_this setSkill ["commanding", random [0.6, 0.8, 1]]};
                if (_factionSoldier in Recon_East_2) then {_this setSkill ["General", random [0.6, 0.8, 1]]};
                if (_factionSoldier in Recon_East_2) then {_this setUnitTrait ["camouflageCoef",0.00040]};
                
                
                
                if (_num > 96) then {_this call frog_agent_1;hint "Special type 1 East Agent is born";

                 _pos = getPos _this; _markertxt = format ["Agents?" ];                                                          ///// Right here its finding the position of _this but it onlu uses this value over and over
                _markerstr = createMarker ["PLP ASSET Special Forces",_pos];
                _markerstr setMarkerShape "ICON";
                _markerstr setMarkerType "plp_mark_as_specialforces";
                _markerstr setMarkerSize [0.9,0.9];
                _markerstr setMarkerColor "ColorRed";
                _markerstr setMarkerText _markertxt};

Share this post


Link to post
Share on other sites

There cannot be 2 markers with the same name. If you try create marker with name of existing marker it will simply fail. You need to provide dynamic name in createMarker command.

Share this post


Link to post
Share on other sites

 

 Crap didnt even think of that.. so guessin create a large array of names to draw from?

Share this post


Link to post
Share on other sites

just create a dynamic marker name, like KK said, maybe something like:

_markerstr = createMarker [
	format ["PLP_ASSET_Special_Forces_%1%2", _this, random 10000],
	_pos
];



 

Share this post


Link to post
Share on other sites
38 minutes ago, hallyg said:

random 10000

there is a chance it will generate duplicate number. the  _i = _i + 1; is a better option

 

  • Like 1

Share this post


Link to post
Share on other sites

Spawn on marker problem -this script used to work no hitch but noew throws up an error from within the BIS_fnc_spawnGroup (line 128 Generic Expression)

 

 

 

 

if (!isServer) exitwith {};

_side = createCenter EAST;
_pos = player getPos [400,45];
_spos = [_pos,random 360,[100,200]];
_markertxt = format ["Nemesis"];
_markerstr = createMarker ["plp_mark_as_sniperrifle",_pos];
_markerstr setMarkerShape "ICON";
_markerstr setMarkerType "plp_mark_as_sniperrifle";
_markerstr setMarkerSize [0.9,0.9];
 
_markerstr setMarkerColor "ColorRed";
_markerstr setMarkerText _markertxt;
_grpCsat = ["o_soldier_TL_F", "O_soldier_AA_F", "o_soldier_AA_F", "o_soldier_AA_F"];
_grpCupRussia = ["CUP_O_RUS_Soldier_TL", "CUP_O_RUS_Soldier_GL", "CUP_O_RUS_Soldier_Marksman", "CUP_O_RUS_SpecOps_Scout"];
_groupSquad1 = [getMarkerPos "plp_mark_as_sniperrifle", _side, [_grpCupRussia], [], [], [0.3, 0.6]] call BIS_fnc_spawnGroup;
_leader = leader _groupSquad1;
 
_waypoint1 = _groupSquad1 addWaypoint [(getPos player),2];
_waypoint1 setWaypointType "MOVE";
 
waitUntil { { alive _x} count (units _groupSquad1) == 0 or player distance _leader > 500};
hint "You have a strange sensation you're being watched...";

 

Share this post


Link to post
Share on other sites

 

 LOL im not sure how to look inside BIS's functions to know

Share this post


Link to post
Share on other sites

Apparently it's:

	_isMan = getNumber(configFile >> "CfgVehicles" >> _type >> "isMan") == 1;

Maybe some config issue with mod units?

Did you get the same error using vanilla units?

 

Cheers

Share this post


Link to post
Share on other sites

 

 Thanks for finding that - yep checked rpt and heres the full error and thats using vanilla csat units:

 

if !(_isMan)>
14:40:59   Error position: <>> _type >> "isMan") == 1;

if !(_isMan)>
14:40:59   Error >>: Type Array, expected String
14:40:59 File A3\functions_f\spawning\fn_spawnGroup.sqf [BIS_fnc_spawnGroup], line 128
14:40:59 Error in expression <= getNumber(configFile >> "CfgVehicles" >> _type >> "isMan") == 1;

 

What confuses me is its from an old script of mine and used to work fine. I think they changed the syntax

Share this post


Link to post
Share on other sites

Why are you passing _grpCupRussia as an array to the spawnGroup function? It already is an array containing the unit classnames you want to spawn. Just pass the variable as is:

_grpCupRussia = ["CUP_O_RUS_Soldier_TL", "CUP_O_RUS_Soldier_GL", "CUP_O_RUS_Soldier_Marksman", "CUP_O_RUS_SpecOps_Scout"];
_groupSquad1 = [getMarkerPos "plp_mark_as_sniperrifle", _side, _grpCupRussia, [], [], [0.3, 0.6]] call BIS_fnc_spawnGroup;

 

  • Like 2

Share this post


Link to post
Share on other sites

 

 Yeah crap Clayman I dont why i had that in an array - strange that it did work before but thanks for spotting

Share this post


Link to post
Share on other sites

Please sign in to comment

You will be able to leave a comment after signing in



Sign In Now

×