Jump to content
Sign in to follow this  
Woodpeckersam

Adding Numbers/Text to variable name?

Recommended Posts

Hi there im kinda stuck on something... how would i go about adding specific text/numbers to the end of a variable... an explanation...

//Image you call this script...
["spawn","grpy2"] execVM "groups.sqf";

//Which loads this script... (it's made up)
_markerPos = _this select 0;
_groupname = _this select 1;

"_groupname"+1 = createGroup east;
"_groupname"+1ld = "_groupname"+1 createUnit ["TK_Soldier_SL_EP1", getMarkerPos _markerPos,[],0.8,"Lieutenant"];

As you can see i would like to allow users to input any group name they like and it would change the entire variable name throughout the script. This would be useful when you need to add loads more units... you would have to go through the list bit by bit... Here is an example of a manually created "createUnit" script that i would need to change every time i want to add a new group...

private ["_grpy1","_grpy1ld","_grpy1ld2","_grpy1ld3","_grpy1ld4","_grpy1ld5","_grpy1ld6","_grpy1ld7"];


_grpy1 = createGroup east;
_grpy1ld = _grpy1 createUnit ["TK_Soldier_SL_EP1", getMarkerPos "grpy1",[],0.8,"Lieutenant"];
_grpy1ld setVehicleVarName "grpy1ld" ;
_grpy1ld2 = _grpy1 createUnit ["TK_Soldier_MG_EP1", getMarkerPos "grpy1",[],0.7,"Sergeant"];
_grpy1ld3 = _grpy1 createUnit ["TK_Soldier_HAT_EP1", getMarkerPos "grpy1",[],0.7,"Sergeant"];
_grpy1ld4 = _grpy1 createUnit ["TK_Soldier_LAT_EP1", getMarkerPos "grpy1",[],0.7,"Sergeant"];
_grpy1ld5 = _grpy1 createUnit ["TK_Soldier_GL_EP1", getMarkerPos "grpy1",[],0.5,"Corporal"];
_grpy1ld6 = _grpy1 createUnit ["TK_Soldier_Spotter_EP1", getMarkerPos "grpy1",[],0.5,"Corporal"];
_grpy1ld7 = _grpy1 createUnit ["TK_Soldier_MG_EP1", getMarkerPos "grpy1",[],0.5,"Corporal"];
_grpy1ld2 = _grpy1 createUnit ["TK_Soldier_HAT_EP1", getMarkerPos "grpy1",[],0.5,"Corporal"];
_grpy1ld3 = _grpy1 createUnit ["TK_Soldier_AR_EP1", getMarkerPos "grpy1",[],0.5,"Private"];
_grpy1ld4 = _grpy1 createUnit ["TK_Soldier_AT_EP1", getMarkerPos "grpy1",[],0.3,"Private"];
_grpy1ld2 = _grpy1 createUnit ["TK_Soldier_EP1", getMarkerPos "grpy1",[],0.3,"Private"];
_grpy1ld3 = _grpy1 createUnit ["TK_Soldier_EP1", getMarkerPos "grpy1",[],0.2,"Private"];
_grpy1ld4 = _grpy1 createUnit ["TK_Soldier_EP1LAT_EP1", getMarkerPos "grpy1",[],0.2,"Private"];
_null = [leader _grpy1,"basepoint1","fortify","delete:",600,"template:",2,"respawn"] execVM "scripts\upsmon.sqf";
{_x removeWeapon "NVGoggles"} forEach units leader _grpy1;

then to manually change all the code for another group

private ["_grpy2","_grpy2ld","_grpy2ld2","_grpy2ld3","_grpy2ld4","_grpy2ld5","_grpy2ld6","_grpy2ld7"];


_grpy2 = createGroup east;
_grpy2d = _grpy2 createUnit ["TK_Soldier_SL_EP1", getMarkerPos "grpy2",[],0.8,"Lieutenant"];
_grpy2ld setVehicleVarName "grpy2ld" ;
_grpy2ld2 = _grpy2 createUnit ["TK_Soldier_MG_EP1", getMarkerPos "grpy2",[],0.7,"Sergeant"];
_grpy2ld3 = _grpy2 createUnit ["TK_Soldier_HAT_EP1", getMarkerPos "grpy2",[],0.7,"Sergeant"];
_grpy2ld4 = _grpy2 createUnit ["TK_Soldier_LAT_EP1", getMarkerPos "grpy2",[],0.7,"Sergeant"];
_grpy2ld5 = _grpy2 createUnit ["TK_Soldier_GL_EP1", getMarkerPos "grpy2",[],0.5,"Corporal"];
_grpy2ld6 = _grpy2 createUnit ["TK_Soldier_Spotter_EP1", getMarkerPos "grpy2",[],0.5,"Corporal"];
_grpy2ld7 = _grpy2 createUnit ["TK_Soldier_MG_EP1", getMarkerPos "grpy2",[],0.5,"Corporal"];
_grpy2ld2 = _grpy2 createUnit ["TK_Soldier_HAT_EP1", getMarkerPos "grpy2",[],0.5,"Corporal"];
_grpy2ld3 = _grpy2 createUnit ["TK_Soldier_AR_EP1", getMarkerPos "grpy2",[],0.5,"Private"];
_grpy2ld4 = _grpy2 createUnit ["TK_Soldier_AT_EP1", getMarkerPos "grpy2",[],0.3,"Private"];
_grpy2ld2 = _grpy2 createUnit ["TK_Soldier_EP1", getMarkerPos "grpy2",[],0.3,"Private"];
_grpy2ld3 = _grpy2 createUnit ["TK_Soldier_EP1", getMarkerPos "grpy2",[],0.2,"Private"];
_grpy2ld4 = _grpy2 createUnit ["TK_Soldier_EP1LAT_EP1", getMarkerPos "grpy2",[],0.2,"Private"];
_null = [leader _grpy2,"basepoint1","fortify","delete:",600,"template:",2,"respawn"] execVM "scripts\upsmon.sqf";
{_x removeWeapon "NVGoggles"} forEach units leader _grpy2;

I hurt my hand copying and pasting this script then change all the number 1's into number 2's.

Notice i changed the numbers, im just demonstrating how time consuming it is to do things this way...

Let me know if this is hard to understand

---------- Post added at 05:24 PM ---------- Previous post was at 05:17 PM ----------

If i could then get the time consuming work to work in just ONE script, then i could have loads of scripts with different group types... such as...

Groups\LargeFortify.sqf :

Contains Units from Above

Groups\MediumAmbush.sqf :

Contains Units from Above Except Removing 2 Sergeants, 2 Corporals's

Groups\SmallPatrol.sqf:

Contains A Sergeant Squad Leader, A Corporal Sniper, and 3 Private Rifleman

Groups\ArtyFortify.sqf

Contains 3 Spotters 1 Group Leader.

(create as many as you need)

Then when you need them to spawn just call either of the scripts above... or create lots of execVM's inside one script to spawn them all at the same time by calling that script inside another....

Of course these would be made to work with UPSMON.sqf

Share this post


Link to post
Share on other sites

Think you might be overcomplicating this. What is the purpose of storing the groups in variables. What are you going to use them for later?

Storing just the groups in an array would suffice for most situations I think where you need to keep track of them.

Just create the group in the script file and "return" the group.

Edited by Muzzleflash

Share this post


Link to post
Share on other sites

Well the main purpose is to be able to call the groups at a later stage, and without manually changing each code of every group using the scripts would make it much more easier. And with this would allow UPSMON to work.

I would not have any idea how to call UPSMON in a group array, remove NVGoggles, change their weapons, change their skills amongst other things... you know? And individually too.

edit: Sorry missed out a question of yours.

Basically i got a bit peeved at the fact my teammates can see in the dark 1000 miles away, when the player cant (which is what i want) I want them to be able to communicate and give orders. I want the player not to know the enemy is there. And then at a certain point, after... lets say... patrolling a house the player has to talk to his group leader, another team member runs to the leader to tell him that he has spotted the enemy... at that point i would like the enemy to spawn and go pass the house, thus spawning other enemies in the town to fortify it or patrol it, and for the player's group to engage with. Would need about 10 large groups, 18 small groups and 5 medium groups (roughly).

Edited by WoodyUK

Share this post


Link to post
Share on other sites

I hurt my hand copying and pasting this script then change all the number 1's into number 2's.

BIS_fnc_spawnGroup :)

Share this post


Link to post
Share on other sites

Thank you will BIS_fnc_spawnGroup help what i want to accomplish? Dynamically creating groups later in game?

This is for singleplayer also...

edit::

SOrry i didnt mean dynamically as such i meant being able to call as many groups as i want at the same time, using 1 script for a certain type of group

Edited by WoodyUK

Share this post


Link to post
Share on other sites

Hiya, im back again. Thanks Kylania for suggesting the BIS_fnc_spawnGroup function mate :D it works... with a small problem however.

Have a look here...

_null = ["mcPat","MecPatrolSmall",_patty] execVM "scripts\Spawn\Spawn.sqf";
sleep 2;
pattywp1 = group _patty addwaypoint [[getmarkerpos "patty1" select 0, getmarkerpos "patty2" select 1, 0], 0, 1];
[group _patty, 1] setWaypointType "MOVE";
[group _patty, 1] setWaypointBehaviour "SAFE";

So i can call this script no problem, the group spawns... Spawn.sqf works fine :D

private ["_marker","_type","_name","_units","_rank","_skill"];

_marker = _this select 0;
_type = _this select 1;
_name = _this select 2;

{_x removeWeapon "NVGoggles"} forEach units leader _name;

switch (_type) do
{
    case "Large": 
    {
         _units = ["TK_Soldier_SL_EP1", "TK_Soldier_MG_EP1", "TK_Soldier_HAT_EP1", "TK_Soldier_LAT_EP1", "TK_Soldier_GL_EP1","TK_Soldier_Spotter_EP1","TK_Soldier_MG_EP1","TK_Soldier_AR_EP1","TK_Soldier_AT_EP1","TK_Soldier_EP1","TK_Soldier_EP1","TK_Soldier_EP1"];
         _rank = ["LIEUTENANT", "SERGEANT", "SERGEANT", "CORPORAL", "CORPORAL","CORPORAL","CORPORAL","PRIVATE","PRIVATE","PRIVATE","PRIVATE","PRIVATE"];
         _skill = [0.8,0.7,0.6,0.6,0.5,0.5,0.4,0.4,0.4,0.3,0.3,0.2];
         _name = [getMarkerPos _marker, east,  _units,[], _rank, _skill,[],[],round (random 360)] call BIS_fnc_spawnGroup;
    };

    case "Medium": 
    {
         _units = ["TK_Soldier_SL_EP1", "TK_Soldier_MG_EP1", "TK_Soldier_GL_EP1","TK_Soldier_Spotter_EP1","TK_Soldier_AR_EP1","TK_Soldier_EP1","TK_Soldier_EP1","TK_Soldier_EP1"];
         _rank = ["LIEUTENANT", "SERGEANT", "CORPORAL","CORPORAL","PRIVATE","PRIVATE","PRIVATE","PRIVATE"];
         _skill = [0.8,0.6,0.5,0.4,0.4,0.4,0.3,0.2];
         _name = [getMarkerPos _marker, east, _units,[], _rank, _skill,[],[],round (random 360)] call BIS_fnc_spawnGroup;
    };

    case "Small": 
    {
         _units =  ["TK_Soldier_SL_EP1", "TK_Soldier_MG_EP1","TK_Soldier_Spotter_EP1","TK_Soldier_EP1","TK_Soldier_EP1"];
         _rank =  ["SERGEANT", "CORPORAL","PRIVATE","PRIVATE","PRIVATE"];
         _skill = [0.5,0.4,0.4,0.4,0.3];
         _name = [getMarkerPos _marker, east, _units,[], _rank, _skill,[],[],round (random 360)] call BIS_fnc_spawnGroup;
};

    case "MecPatrolSmall": 
    {
         _units =  ["TK_Soldier_SL_EP1", "TK_Soldier_MG_EP1","TK_Soldier_Spotter_EP1","TK_Soldier_EP1","TK_Soldier_EP1"];
         _rank =  ["SERGEANT", "CORPORAL","PRIVATE","PRIVATE","PRIVATE"];
         _skill = [0.5,0.4,0.4,0.4,0.3];
         _name = [getMarkerPos _marker, east, _units,[], _rank, _skill,[],[],round (random 360)] call BIS_fnc_spawnGroup;
         _name = [markerPos _marker, 180, "LandRover_MG_TK_EP1", _name] call BIS_fnc_spawnVehicle;
    };
    case "ArtyTeam": 
    {
         _units =  ["TK_Soldier_SL_EP1", "TK_Soldier_MG_EP1","TK_Soldier_Spotter_EP1","TK_Soldier_EP1","TK_Soldier_EP1"];
         _rank =  ["SERGEANT", "CORPORAL","CORPORAL","PRIVATE","PRIVATE"];
         _skill = [0.6,0.6,0.5,0.4,0.3];
         _name = [getMarkerPos _marker, east, _units,[], _rank, _skill,[],[],round (random 360)] call BIS_fnc_spawnGroup;
    };

    case "smallPatrol": 
    {
         _units = ["TK_Soldier_SL_EP1","TK_Soldier_Spotter_EP1","TK_Soldier_EP1","TK_Soldier_EP1"];
         _rank =  ["CORPORAL","PRIVATE","PRIVATE","PRIVATE"];
         _skill = [0.5,0.4,0.4,0.4];
         _name = [getMarkerPos _marker, east, _units,[], _rank, _skill,[],[],round (random 360)] call BIS_fnc_spawnGroup;
    };     
};

The problem is though... the group doesnt move. I've tried it with the addWaypoint command, the doMove command, the move command... the group just doesnt wanna move....

Oh and calling the UPSMON.sqf script on these newly created groups doesnt work too...

Can someone help?

Also am i right in saying that _groups should not be declared private?

Share this post


Link to post
Share on other sites

Not sure if I am on the right lines but this might help:

call {grp = [getMarkerPos "ic", EAST, (configFile >> "CfgGroups" >> "East" >> "BIS_TK_INS" >> "Infantry" >> "TK_INS_Group")] call BIS_fnc_spawnGroup; [grp, getmarkerPos "ic", 50] call bis_fnc_taskAttack};

Edited by dale0404

Share this post


Link to post
Share on other sites

Hey there dale.

Doesnt that command causes a random group to attack a position?

What i would like would be to spawn loads of enemies in a village.. no problem... but working with UPSMON Script.

And some other groups will be spawned specifically for depth and immersion...

In the case you see above in my previous post, the player and his group sees the enemy coming towards to house they are hiding in, however i wanted the group to just walk past as if they are patrolling. Which causes the player and his group to hide, however they can be seen and if the player's team does get caught by the enemy, the mission goes off into an entirely different direction.

---------- Post added at 01:05 AM ---------- Previous post was at 12:56 AM ----------

ps i know how to make the mission go in a different direction... no big deal :D

Share this post


Link to post
Share on other sites

I would guess that it's not working because your using local variables but trying to use them globally.

What you create in one script won't work in the other unless it's global.

Share this post


Link to post
Share on other sites

so in that case i would have to remove anything that has a "_" before it, and remove the private[""]; command?

---------- Post added at 01:11 AM ---------- Previous post was at 01:10 AM ----------

in the main script i mean... it's fine inside spawn.sqf

---------- Post added at 01:15 AM ---------- Previous post was at 01:11 AM ----------

removing "_" doesnt work

Share this post


Link to post
Share on other sites

I couldn't actually get your spawn to work are they units from an addon?, it was giving me errors in the BIS_function module.

Anyway I did substitute the actual bit that does the spawn for one I was using earlier and that spawned fine.

I then put the waypoint part into the spawn code but it didn't work.

I then changed that to a different way of setting up the waypoint and they do move now.

The Medium spawn is the only one that works for me.

_patty isn't working as the name so I used _name throughout and ss it's all in the same script local vs global isn't an issue right now.

// null=[marker,type,name] execvm "spawns.sqf";

private ["_marker","_type","_name","_units","_rank","_skill"];
_temp = createcenter East; 
_marker = _this select 0;
_type = _this select 1;
_name = _this select 2;
sleep 2;


switch (_type) do
{
    case "Large": 
    {
         _units = ["TK_Soldier_SL_EP1", "TK_Soldier_MG_EP1", "TK_Soldier_HAT_EP1", "TK_Soldier_LAT_EP1", "TK_Soldier_GL_EP1","TK_Soldier_Spotter_EP1","TK_Soldier_MG_EP1","TK_Soldier_AR_EP1","TK_Soldier_AT_EP1","TK_Soldier_EP1","TK_Soldier_EP1","TK_Soldier_EP1"];
         _rank = ["LIEUTENANT", "SERGEANT", "SERGEANT", "CORPORAL", "CORPORAL","CORPORAL","CORPORAL","PRIVATE","PRIVATE","PRIVATE","PRIVATE","PRIVATE"];
         _skill = [0.8,0.7,0.6,0.6,0.5,0.5,0.4,0.4,0.4,0.3,0.3,0.2];
         _name = [getMarkerPos _marker, east,  _units,[], _rank, _skill,[],[],round (random 360)] call BIS_fnc_spawnGroup;

    };

    case "Medium": 
    {
    _units = ["TK_Soldier_SL_EP1", "TK_Soldier_MG_EP1", "TK_Soldier_GL_EP1","TK_Soldier_Spotter_EP1","TK_Soldier_AR_EP1","TK_Soldier_EP1","TK_Soldier_EP1","TK_Soldier_EP1"];
         _rank = ["LIEUTENANT", "SERGEANT", "CORPORAL","CORPORAL","PRIVATE","PRIVATE","PRIVATE","PRIVATE"];
         _skill = [0.8,0.6,0.5,0.4,0.4,0.4,0.3,0.2];
         _name = [getMarkerPos _marker, east, _units,[], _rank, _skill,[],[],round (random 360)] call BIS_fnc_spawnGroup;
    };

    case "Small": 
    {
         _units =  ["TK_Soldier_SL_EP1", "TK_Soldier_MG_EP1","TK_Soldier_Spotter_EP1","TK_Soldier_EP1","TK_Soldier_EP1"];
         _rank =  ["SERGEANT", "CORPORAL","PRIVATE","PRIVATE","PRIVATE"];
         _skill = [0.5,0.4,0.4,0.4,0.3];
         _name = [getMarkerPos _marker, east, _units,[], _rank, _skill,[],[],round (random 360)] call BIS_fnc_spawnGroup;
    };

    case "MecPatrolSmall": 
    {
    _units =  ["TK_Soldier_SL_EP1", "TK_Soldier_MG_EP1","TK_Soldier_Spotter_EP1","TK_Soldier_EP1","TK_Soldier_EP1"];
         _rank =  ["SERGEANT", "CORPORAL","PRIVATE","PRIVATE","PRIVATE"];
         _skill = [0.5,0.4,0.4,0.4,0.3];
         _name = [getMarkerPos _marker, east, _units,[], _rank, _skill,[],[],round (random 360)] call BIS_fnc_spawnGroup;
         _nameGRP = [markerPos _marker, 180, "LandRover_MG_TK_EP1", _name] call BIS_fnc_spawnVehicle;
         {[_x] joinsilent _name} foreach _nameGRP; // Make Vehicle & Units Into One Group;
    };
    case "ArtyTeam": 
    {
         _units =  ["TK_Soldier_SL_EP1", "TK_Soldier_MG_EP1","TK_Soldier_Spotter_EP1","TK_Soldier_EP1","TK_Soldier_EP1"];
         _rank =  ["SERGEANT", "CORPORAL","CORPORAL","PRIVATE","PRIVATE"];
         _skill = [0.6,0.6,0.5,0.4,0.3];
         _name = [getMarkerPos _marker, east, _units,[], _rank, _skill,[],[],round (random 360)] call BIS_fnc_spawnGroup;
    };

    case "smallPatrol": 
    {
         _units = ["TK_Soldier_SL_EP1","TK_Soldier_Spotter_EP1","TK_Soldier_EP1","TK_Soldier_EP1"];
         _rank =  ["CORPORAL","PRIVATE","PRIVATE","PRIVATE"];
         _skill = [0.5,0.4,0.4,0.4];
         _name = [getMarkerPos _marker, east, _units,[], _rank, _skill,[],[],round (random 360)] call BIS_fnc_spawnGroup;
    };     
};

{_x removeWeapon "NVGoggles"} forEach units leader _name;

_wp = _name addWaypoint [[getmarkerpos "patty1" select 0, getmarkerpos "patty2" select 1, 0], 0, 1];
_wp    setWaypointType   "MOVE";
_name  setBehaviour      "SAFE";



// pattywp1 = group _name addwaypoint [[getmarkerpos "patty1" select 0, getmarkerpos "patty2" select 1, 0], 0, 1];
// [group  _name, 1] setWaypointType "MOVE";
//[group _name, 1] setWaypointBehaviour "SAFE";

Updated version, Now spawns all groups and Vehicle.

Edited by F2k Sel

Share this post


Link to post
Share on other sites

Hiya,

Thanks for having a look at that script for me :D I'll check it out as soon as possible.

Ahh apologies for not explaining in greater detail... The units I have used are the takistani army units. Maybe you don't have OA? No matter though, I'll test it using the units you have used then put the takistani units back in. :D

Share this post


Link to post
Share on other sites
Hiya,

Thanks for having a look at that script for me :D I'll check it out as soon as possible.

Ahh apologies for not explaining in greater detail... The units I have used are the takistani army units. Maybe you don't have OA? No matter though, I'll test it using the units you have used then put the takistani units back in. :D

I do have OA, strange they don't work for me I'll look into it later.

Oh it's just dawned on me, as I don't have any enemy units on the map the script will need a createcenter command

_temp = createcenter EAST;

There's still a problem with the case "MecPatrolSmall": probably as it's spawning a vehicle and group with same name.

I think I've sorted the vehicle problem, I now have the units spawned join the vehicle group and make it one group.

Updated in post 11.

I'm still not sure how to pass a name to the group though..

.

Edited by F2k Sel

Share this post


Link to post
Share on other sites

Hey again :D

Thanks again for that vehicle to group code. It works a bunch! :D

This is a very tough subject, i am still wondering how to pass a name to the group... i now have 2 seperate scripts. The first one is the same as above (what you have been editing) this will be for spawning groups around the town.

The other one will be used for scripting specific movement of a new group. It doesnt work a great deal... the group spawns, the group moves, but getting it to work... "waitUntil leader of _name" is near a marker... it just doesnt want to know.

Spawn.sqf (same you have been editing - works great as far as i know. I cant seem to tell if calling the UPSMON.sqf script actually works)

private ["_marker","_type","_name","_units","_rank","_skill","_where"];

_marker = _this select 0;
_type = _this select 1;
_name = _this select 2;
_where = _this select 3;

sleep 2;
{_x removeWeapon "NVGoggles"} forEach units leader _name;

switch (_type) do
{
    case "LargeFort": 
    {
         _units = ["TK_Soldier_SL_EP1", "TK_Soldier_MG_EP1", "TK_Soldier_HAT_EP1", "TK_Soldier_LAT_EP1", "TK_Soldier_GL_EP1","TK_Soldier_Spotter_EP1","TK_Soldier_MG_EP1","TK_Soldier_AR_EP1","TK_Soldier_AT_EP1","TK_Soldier_EP1","TK_Soldier_EP1","TK_Soldier_EP1"];
         _rank = ["LIEUTENANT", "SERGEANT", "SERGEANT", "CORPORAL", "CORPORAL","CORPORAL","CORPORAL","PRIVATE","PRIVATE","PRIVATE","PRIVATE","PRIVATE"];
         _skill = [0.8,0.7,0.6,0.6,0.5,0.5,0.4,0.4,0.4,0.3,0.3,0.2];
         _name = [getMarkerPos _marker, east,  _units,[], _rank, _skill,[],[],round (random 360)] call BIS_fnc_spawnGroup;
         sleep 5;
         _null = [leader  _name,_where,"fortify","delete:",600,"template:",2,"respawn"] execVM "scripts\upsmon.sqf";
    };

    case "MediumFort": 
    {
         _units = ["TK_Soldier_SL_EP1", "TK_Soldier_MG_EP1", "TK_Soldier_GL_EP1","TK_Soldier_Spotter_EP1","TK_Soldier_AR_EP1","TK_Soldier_EP1","TK_Soldier_EP1","TK_Soldier_EP1"];
         _rank = ["LIEUTENANT", "SERGEANT", "CORPORAL","CORPORAL","PRIVATE","PRIVATE","PRIVATE","PRIVATE"];
         _skill = [0.8,0.6,0.5,0.4,0.4,0.4,0.3,0.2];
         _name = [getMarkerPos _marker, east, _units,[], _rank, _skill,[],[],round (random 360)] call BIS_fnc_spawnGroup;
         _null = [leader  _name,_where,"fortify","delete:",600,"template:",2,"respawn"] execVM "scripts\upsmon.sqf";
    };

    case "SmallFort": 
    {
         _units =  ["TK_Soldier_SL_EP1", "TK_Soldier_MG_EP1","TK_Soldier_Spotter_EP1","TK_Soldier_EP1","TK_Soldier_EP1"];
         _rank =  ["SERGEANT", "CORPORAL","PRIVATE","PRIVATE","PRIVATE"];
         _skill = [0.5,0.4,0.4,0.4,0.3];
         _name = [getMarkerPos _marker, east, _units,[], _rank, _skill,[],[],round (random 360)] call BIS_fnc_spawnGroup;
         _null = [leader  _name,_where,"fortify","delete:",600,"template:",2,"respawn"] execVM "scripts\upsmon.sqf";
};

    case "SmallMecPat": 
    {
         _units =  ["TK_Soldier_SL_EP1", "TK_Soldier_MG_EP1","TK_Soldier_Spotter_EP1","TK_Soldier_EP1","TK_Soldier_EP1"];
         _rank =  ["SERGEANT", "CORPORAL","PRIVATE","PRIVATE","PRIVATE"];
         _skill = [0.5,0.4,0.4,0.4,0.3];
         _name = [getMarkerPos _marker, east, _units,[], _rank, _skill,[],[],round (random 360)] call BIS_fnc_spawnGroup;
         _name = [markerPos _marker, 180, "LandRover_MG_TK_EP1", _name] call BIS_fnc_spawnVehicle;
    };
    case "ArtyTeamFort": 
    {
         _units =  ["TK_Soldier_SL_EP1", "TK_Soldier_MG_EP1","TK_Soldier_Spotter_EP1","TK_Soldier_EP1","TK_Soldier_EP1"];
         _rank =  ["SERGEANT", "CORPORAL","CORPORAL","PRIVATE","PRIVATE"];
         _skill = [0.6,0.6,0.5,0.4,0.3];
         _name = [getMarkerPos _marker, east, _units,[], _rank, _skill,[],[],round (random 360)] call BIS_fnc_spawnGroup;
    };

    case "SmallPat": 
    {
         _units = ["TK_Soldier_SL_EP1","TK_Soldier_Spotter_EP1","TK_Soldier_EP1","TK_Soldier_EP1"];
         _rank =  ["CORPORAL","PRIVATE","PRIVATE","PRIVATE"];
         _skill = [0.5,0.4,0.4,0.4];
         _name = [getMarkerPos _marker, east, _units,[], _rank, _skill,[],[],round (random 360)] call BIS_fnc_spawnGroup;
    };
};

sleep 2;

And here is PatrolHouse.sqf - not working very well...

private ["_units","_rank","_skill","_name","_wp","_ld","_nameGRP","_marker"];

_name = _this select 0;
_ld = leader _name;

_units =  ["TK_Soldier_SL_EP1", "TK_Soldier_MG_EP1","TK_Soldier_Spotter_EP1","TK_Soldier_EP1","TK_Soldier_EP1"];
_rank =  ["SERGEANT", "CORPORAL","PRIVATE","PRIVATE","PRIVATE"];
_skill = [0.5,0.4,0.4,0.4,0.3];
_name = [getMarkerPos "mcPat", east, _units,[], _rank, _skill,[],[],round (random 360)] call BIS_fnc_spawnGroup;
_nameGRP = [markerPos "mcPat", 180, "LandRover_MG_TK_EP1", _name] call BIS_fnc_spawnVehicle;
{[_x] joinsilent _name} foreach _nameGRP; // Make Vehicle & Units Into One Group;


sleep 15;
_wp = _name addWaypoint [[getmarkerpos "patty1" select 0, getmarkerpos "patty1" select 1, 0], 0, 1];
_wp setWaypointType   "MOVE";
_name setBehaviour "SAFE";
_name setSpeedMode "LIMITED";

waitUntil {(_ld distance getMarkerPos "patty1") <= 10};
sleep 5;
_wp = _name addWaypoint [[getmarkerpos "patty2" select 0, getmarkerpos "patty2" select 1, 0], 0, 1];
_wp setWaypointType   "MOVE";
_name setBehaviour "SAFE";
_name setSpeedMode "LIMITED";

waitUntil {(_ld distance getMarkerPos "patty2") <= 10};
sleep 5;
_wp = _name addWaypoint [[getmarkerpos "patty3" select 0, getmarkerpos "patty3" select 1, 0], 0, 1];
_wp setWaypointType   "MOVE";
_name setBehaviour "SAFE";
_name setSpeedMode "LIMITED";

waitUntil {(_ld distance getMarkerPos "patty3") <= 10};

---------- Post added at 03:07 PM ---------- Previous post was at 03:03 PM ----------

edit: its confirmed... calling UPSMON in the Spawn.sqf script doesnt work at all. I dont get no error, but it doesnt work... grr

and in the PatrolHouse.sqf it gives me an error for "_ld = leader _name" maybe using BIS_fnc_spawnGroup wasnt the bestest of ideas? Unless someone knows how to name units (specifically the group leader) of any created groups using BIS_fnc_spawnGroup.

Share this post


Link to post
Share on other sites

I can't test right now but you are naming the leader before the group is spawned and the same when removing the goggles. The units don't exist until spawned.

_wp =  _name addWaypoint [[getmarkerpos "patty1" select 0, getmarkerpos "patty1" select 1, 0], 0, 1];
_wp    setWaypointType   "MOVE";
_name  setBehaviour      "SAFE";

waitUntil {(leader _name  distance getMarkerPos "patty1") <= 10};

_wp =  _name addWaypoint [[getmarkerpos "patty2" select 0, getmarkerpos "patty2" select 1, 0], 0, 1];
_wp    setWaypointType   "MOVE";
_name  setBehaviour      "Aware";

That will work for simple waypoints.

I have the script calling the upsmon code but all they do is surrender.

I think that's what I'll do :confused:

It seems there are a few people having problems using UPSMON with spawned units.

Using "SPAWNED" should enable this to work with spawned units but it doesn't help me.

null = [leader _name,"town","SPAWNED","fortify","delete:",600,"template:",2,"respawn"] execVM "scripts\upsmon.sqf"; 

.

Edited by F2k Sel

Share this post


Link to post
Share on other sites

I'll play around with the code regarding upsmon. cheers :D

as for the PatrolHouse.sqf script they move to the first waypoint and then stay there... it seems as if it is not picking up the leader (leader distance marker)

private ["_units","_rank","_skill","_name","_wp"];

_name = _this select 0;

_units =  ["TK_Soldier_SL_EP1", "TK_Soldier_MG_EP1","TK_Soldier_Spotter_EP1","TK_Soldier_EP1","TK_Soldier_EP1"];
_rank =  ["SERGEANT", "CORPORAL","PRIVATE","PRIVATE","PRIVATE"];
_skill = [0.5,0.4,0.4,0.4,0.3];
_name = [getMarkerPos "mcPat", east, _units,[], _rank, _skill,[],[],round (random 360)] call BIS_fnc_spawnGroup;
{_x removeWeapon "NVGoggles"} forEach units leader _name;

sleep 15;
_wp = _name addWaypoint [[getmarkerpos "patty1" select 0, getmarkerpos "patty1" select 1, 0], 0, 1];
_wp setWaypointType   "MOVE";
_name setBehaviour "SAFE";

waitUntil {(leader _name  distance getMarkerPos "patty1") <= 15};
ld1 sideChat "Right Lads, that patrol has gone. Lets continue on";
{_x setUnitPos "auto"} foreach units ld1; 
{_x setBehaviour "danger"} foreach units ld1;
gogo = false;
sleep 5;
_wp = _name addWaypoint [[getmarkerpos "patty2" select 0, getmarkerpos "patty2" select 1, 0], 0, 1];
_wp setWaypointType   "MOVE";
_name setBehaviour "SAFE";

waitUntil {(leader _name  distance getMarkerPos "patty2") <= 10};
sleep 5;
_wp = _name addWaypoint [[getmarkerpos "patty3" select 0, getmarkerpos "patty3" select 1, 0], 0, 1];
_wp setWaypointType   "MOVE";
_name setBehaviour "SAFE";

waitUntil {(leader _name  distance getMarkerPos "patty2") <= 10};
exit;

spawned groups... bah lol if only there was an easier solution.

---------- Post added at 06:18 PM ---------- Previous post was at 06:13 PM ----------

i used ld1 sidechat format ["The leader of %1 is %2",_name,leader _name]

and it returned something like this..

The leader of 0 1-3-H is 0 1-3-H:1...

So it doesnt even give the group a proper name...

(i corrected the name it appeared as)

---------- Post added at 06:27 PM ---------- Previous post was at 06:18 PM ----------

Ah i got PatrolHouse.sqf working! :D Thanks ever so much for working with me on this F2k Sel :D

Here is the working script.

private ["_units","_rank","_skill","_name"];

_name = _this select 0;

_units =  ["TK_Soldier_SL_EP1", "TK_Soldier_MG_EP1","TK_Soldier_Spotter_EP1","TK_Soldier_EP1","TK_Soldier_EP1"];
_rank =  ["SERGEANT", "CORPORAL","PRIVATE","PRIVATE","PRIVATE"];
_skill = [0.5,0.4,0.4,0.4,0.3];
_name = [getMarkerPos "mcPat", east, _units,[], _rank, _skill,[],[],round (random 360)] call BIS_fnc_spawnGroup;
{_x removeWeapon "NVGoggles"} forEach units leader _name;

sleep 15;
leader _name move getMarkerPos "patty1";

waitUntil {(leader _name  distance getMarkerPos "patty1") <= 15};

ld1 sideChat "Right Lads, that patrol has gone. Lets continue on";
{_x setUnitPos "auto"} foreach units ld1; 
{_x setBehaviour "danger"} foreach units ld1;

gogo = false;
sleep 5;

leader _name move getMarkerPos "patty2";
waitUntil {(leader _name  distance getMarkerPos "patty2") <= 10};

sleep 5;
leader _name move getMarkerPos "patty3";

waitUntil {(leader _name  distance getMarkerPos "patty2") <= 10};
exit;

Now need to check how to get UPSMON to work with Spawned Units.

---------- Post added at 06:31 PM ---------- Previous post was at 06:27 PM ----------

wow i must have been blinded by the real truth... UPSMON DOES work F2k Sel :D With that suggestion you posted! :D Wooho thanks buddy!

Edited by WoodyUK

Share this post


Link to post
Share on other sites

Glad you have it sorted, I still can't do anything but surrender.

  case "Small": 
    {
    _units =  ["TK_Soldier_SL_EP1", "TK_Soldier_MG_EP1","TK_Soldier_Spotter_EP1","TK_Soldier_EP1","TK_Soldier_EP1"];
         _rank =  ["SERGEANT", "CORPORAL","PRIVATE","PRIVATE","PRIVATE"];
         _skill = [0.5,0.4,0.4,0.4,0.3];
         _name = [getMarkerPos _marker, east, _units,[], _rank, _skill,[],[],round (random 360)] call BIS_fnc_spawnGroup;
         sleep 3;
         //leader _name setDammage 1;  //kills leader of the group test only
         _null = [leader _name,"town","SPAWNED","fortify","delete:",600,"template:",2,"respawn"] execVM "scripts\upsmon.sqf";  
         _pass = 1;
    };

The leader exists as I can kill him, There has to be a reason it's doing this.

.

Share this post


Link to post
Share on other sites

F2k Sel - How about i give you the mission i am doing (look and do what you want with it, this mission is helping me building my scripting knowledge, so it could be a full mission in the end or just a mission to help me get my scripting skills up) and check to see if mission works with UPSMON without causing surrender.

Let me know if you want to check it out.

Share this post


Link to post
Share on other sites

WoodyUK as you know on the other thread I have found a fix even if I don't Know how it works. I assume using a call restarts UPSMON.

I don't make missions myself I just like to play with any interesting scripts.

This one looked useful so I thought I'd take a look and it has helped me to sort a few things out.

The fix was to use a call for anyone that's interested.

call {[leader _name ,"town","SPAWNED","fortify","delete:",600,"template:",2,"respawn"] execVM "scripts\upsmon.sqf";};

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
Sign in to follow this  

×