Jump to content
Sign in to follow this  
Weedburner

How to Spawn a Group with Name and Init Added

Recommended Posts

I tried dozens of sripts till now but somehow it doesnt work.

I can spawn Enemys thats no Problem.

But how the Hell i spawn a Group of selected Enemys (Unit Classnames added to Script) which have a Group Name and a Code added to their INIT??

In all of my Missions the UPSMON script is used so the Enemys act beliveable realistic.But to add the Upsmon the Groups must have Names and a Code in the Init Field.

When i add all Enemys from the Beginn the Server FPS drops to 4-6,so i have to Spawn them.But i couldnt found anything that Spawns a Group which has a Name and the needed Code in the Init Field. This is the needed Code for Init Field:

nul=[this,"town","nomove"] execVM "scripts\upsmon.sqf";

So how i Spawn a group of Soldiers with Name and Init????

Share this post


Link to post
Share on other sites

First: Please choose right subforum next time! This questions should be in "Mission editing&scripting".

Second, your problem:

- create group

For each Unit:

- spawn Unit

- use SetVehcileVarName to give the unit "a name"

- rewrite the function for the init field and change "this" to a specific unit reference

Example code (not tested):

_myGroup = [url="http://community.bistudio.com/wiki/createGroup"]createGroup [/url]east;
_tempSoldier = _myGroup [url="http://community.bistudio.com/wiki/createUnit_array"]createUnit[/url] ["RU_Soldier",[%PositionArray%],[],0,"FORM"]
_tempSoldier [url="http://community.bistudio.com/wiki/setVehicleVarName"]setVehicleVarName[/url] "Soldier1" // This will give the unit "a name", like the name field in the editor 
_null = [_tempSoldier,"town","nomove"] execVM "scripts\upsmon.sqf";
// Repeat the the last 3 lines for each soldier you want to spawn in this group

Share this post


Link to post
Share on other sites
First: Please choose right subforum next time! This questions should be in "Mission editing&scripting".

Second, your problem:

- create group

For each Unit:

- spawn Unit

- use SetVehcileVarName to give the unit "a name"

- rewrite the function for the init field and change "this" to a specific unit reference

Example code (not tested):

_myGroup = [url="http://community.bistudio.com/wiki/createGroup"]createGroup [/url]east;
_tempSoldier = _myGroup [url="http://community.bistudio.com/wiki/createUnit_array"]createUnit[/url] ["RU_Soldier",[%PositionArray%],[],0,"FORM"]
_tempSoldier [url="http://community.bistudio.com/wiki/setVehicleVarName"]setVehicleVarName[/url] "Soldier1" // This will give the unit "a name", like the name field in the editor 
_null = [_tempSoldier,"town","nomove"] execVM "scripts\upsmon.sqf";
// Repeat the the last 3 lines for each soldier you want to spawn in this group

I will use correct Forum next time,i thought this is ok cause the description was "Discussion on editing SQF´s"

Many people already tried to help me but nothing worked.Your Script is different,i hope it will work i will try out now ;)

PS: If you dont know UPSMON try it,its an Edit of UPS,MON stands for Monsada the creater i guess.

It is so cool.

90% of all Coop Missions work like this: When Player gets the Task some enemys will spawn.Enemys will stand around at their spawnpoint without moving,simple cannonfodder not more.

But when you use UPSMON the Enemys wont stand at 1 place as cannonfodder,they attack you,interact with each other for example Flank Attacks.They have a much better and realistic Behaviour.You realy should try out.

---------- Post added at 09:11 AM ---------- Previous post was at 08:37 AM ----------

First: Please choose right subforum next time! This questions should be in "Mission editing&scripting".

Second, your problem:

- create group

For each Unit:

- spawn Unit

- use SetVehcileVarName to give the unit "a name"

- rewrite the function for the init field and change "this" to a specific unit reference

Example code (not tested):

_myGroup = [url="http://community.bistudio.com/wiki/createGroup"]createGroup [/url]east;
_tempSoldier = _myGroup [url="http://community.bistudio.com/wiki/createUnit_array"]createUnit[/url] ["RU_Soldier",[%PositionArray%],[],0,"FORM"]
_tempSoldier [url="http://community.bistudio.com/wiki/setVehicleVarName"]setVehicleVarName[/url] "Soldier1" // This will give the unit "a name", like the name field in the editor 
_null = [_tempSoldier,"town","nomove"] execVM "scripts\upsmon.sqf";
// Repeat the the last 3 lines for each soldier you want to spawn in this group

This dont works

I tried

_myGroup = createGroup east;

_tempSoldier = _myGroup createUnit ["RU_Soldier",getpos spawn1,[],0.8,"Sergeant"];

_tempSoldier setVehicleVarName "Soldier1" ;

_tempSoldier2 = _myGroup createUnit ["RU_Soldier",getpos spawn1,[],0.6,"Private"];

_tempSoldier2 setVehicleVarName "Soldier2" ;

_tempSoldier3 = _myGroup createUnit ["RU_Soldier",getpos spawn1,[],0.6,"Private"];

_tempSoldier3 setVehicleVarName "Soldier3" ;

_tempSoldier4 = _myGroup createUnit ["RU_Soldier",getpos spawn1,[],0.6,"Private"];

_tempSoldier4 setVehicleVarName "Soldier4" ;

_null = [_tempSoldier,"town","nomove"] execVM "scripts\upsmon.sqf";

_null = [_tempSoldier2,"town","nomove"] execVM "scripts\upsmon.sqf";

_null = [_tempSoldier3,"town","nomove"] execVM "scripts\upsmon.sqf";

_null = [_tempSoldier4,"town","nomove"] execVM "scripts\upsmon.sqf";

// Repeat the the last 3 lines for each soldier you want to spawn in this group

Functionmanager is on Map,I also used a game logic with the Init for Center-East

But it still didnt works.

I added the last 2 Lines with SetVehiceVarName and the last line of Code to a working group spawn script of me,group will spawn,upsmon starts too initialize too but then it stopes with mesage "no alive members" so its not correctly inited to the spawned group

Edited by Weedburner

Share this post


Link to post
Share on other sites

I did a short search and found (Link):

Select the leader of squad, on the init exec UPSMON with the parameters you need.
So, you don't need to call the init for every soldier, only for the leader of the group!

So i suggest:

_myGroup = createGroup east;
_tempSoldier = _myGroup createUnit ["RU_Soldier",getpos spawn1,[],0.8,"Sergeant"];
_tempSoldier setVehicleVarName "Soldier1" ;
_tempSoldier2 = _myGroup createUnit ["RU_Soldier",getpos spawn1,[],0.6,"Private"];
_tempSoldier2 setVehicleVarName "Soldier2" ;
_tempSoldier3 = _myGroup createUnit ["RU_Soldier",getpos spawn1,[],0.6,"Private"];
_tempSoldier3 setVehicleVarName "Soldier3" ;
_tempSoldier4 = _myGroup createUnit ["RU_Soldier",getpos spawn1,[],0.6,"Private"];
_tempSoldier4 setVehicleVarName "Soldier4" ;
[color=SeaGreen][b]_null = [leader _myGroup,"town","nomove"] execVM "scripts\upsmon.sqf";[/b][/color]

And "town" must be a marker name on your map.

Hope this will help you a step forward.

Share this post


Link to post
Share on other sites
I did a short search and found (Link):

So, you don't need to call the init for every soldier, only for the leader of the group!

So i suggest:

_myGroup = createGroup east;
_tempSoldier = _myGroup createUnit ["RU_Soldier",getpos spawn1,[],0.8,"Sergeant"];
_tempSoldier setVehicleVarName "Soldier1" ;
_tempSoldier2 = _myGroup createUnit ["RU_Soldier",getpos spawn1,[],0.6,"Private"];
_tempSoldier2 setVehicleVarName "Soldier2" ;
_tempSoldier3 = _myGroup createUnit ["RU_Soldier",getpos spawn1,[],0.6,"Private"];
_tempSoldier3 setVehicleVarName "Soldier3" ;
_tempSoldier4 = _myGroup createUnit ["RU_Soldier",getpos spawn1,[],0.6,"Private"];
_tempSoldier4 setVehicleVarName "Soldier4" ;
[color=SeaGreen][b]_null = [leader _myGroup,"town","nomove"] execVM "scripts\upsmon.sqf";[/b][/color]

And "town" must be a marker name on your map.

Hope this will help you a step forward.

I knew only the Leader needed it,but you said all Soldiers need it so i made it too all.But it doesnt work.I tried to use the setVehicleVarName and _null = [leader _myGroup,"town","nomove"] execVM "scripts\upsmon.sqf";[/b][/color] on a other Group Spawn Script i use normal,then a Group Spawns,but the Init Code doesnt get transported to the Spawned Soldiers.

I have Upsmon set to Debug so i can see if the group is acepted by Upsmon or not.Everytime comes message that there would be no alive members in the group

So there 2 Error-Options. 1.Group doesnt accept its name so UPSMON cant find it, or 2.Init don get transported to group.

I think its the first cause UPSMON tries to initialize but cand find alive members.

Translation to German cause HeliJunkie is German (perhaps i can the describe the Problem better in my native language)

Also wegen der Serverperformance muss ich die Gegner erst im spielverlauf spawnen,sie müssen aber UPSMON haben und brauchen dafür nul=[this,"town","nomove"] execVM "scripts\upsmon.sqf";

Ich hab das Script was du zuletzt geschrieben hast in eine sqf datei gepackt die durch einen trigger aufgerufen wird,aber es passiert gar nichts.Der Funktionsmanager ist auf der Map.Habe das Script cp.sqf gennant und der auslöser hat bei aktivierung nul=execVM "cp.sqf"

Aber wie gesagt es passiert gar nichts,upsmon versucht nicht zu initialisieren und es spawnen auch keine soldaten

Wenn ich das etVehicleVarName and _null = [leader _myGroup,"town","nomove"] execVM "scripts\upsmon.sqf";[/b][/color]in einem anderen gruppenspawnscript einbaue spawnt eine Gruppe,Upsmon versucht auch zu initializieren aber findet keine lebenden gruppenmitglieder.

Also entweder wird der Name oder der Init Code nicht an die gespawnte Gruppe transportiert.

Norrin hat es bei ähnlichen Problem so gemacht das all einheiten in einer Markerquadratbox das selbe Init kriegen.Weis aber nicht wie das geht.

Share this post


Link to post
Share on other sites

Old thread i know but, I have an issue very similar with what I am trying to do. I'm using UPSMON and want a chopper to be spawned in on Trigger Activation (VIA Radio command) with a squad of units,( which i'll specify) in its cargo. However i want the chopper to drop off the units on board within 200 meters of a players position, and then for the squad who was just inserted to begin running upsmon script in the area. I would like the chopper to delete when it has returned to it sstart location. I also need to edit each of the soldier INIT field that i created in the copper cargo ( i want them to have a specific loadout ie weapons etc.)

I've been searching as i had a script a while back that did this, it basically allowed me to call a reinforcement squad who was choppered in, and would land and begin patrolling the area until it was clear, they would then call the chopper and then leave. Once they left they were deleted and i was able to call them in again. This script used some parts of UPS or UPSMON but i cant find it anywhere. Thanks in advance.

UPDATE***** Well i got the Chopper and unit spawned and doing as I stated above. I just need to add to each units init field in the script(for custom gear ie weapons backpack etc)but am unsure where to do that at. I'm a noobie at scripting! But here is what I am using thus far:

HIalldone1 = 0;

HIalldone2 = 0;

_x1 = (getpos HIlogical1 select 0);

_y1 = (getpos HIlogical1 select 1);

_alt1 = 100;

_lz = HIDropZone1;

_lz setpos position player;

_HeliCrew = Creategroup WEST;

_Huey = ([[_x1, _y1, _alt1], 0, "UH60M_EP1", _HeliCrew] call BIS_fnc_spawnVehicle) select 0;

_Huey setvehiclevarname "_Huey";

_HeliCrew setbehaviour "stealth";

_HeliCrew setcombatmode "yellow";

player reveal _Huey;

_Cavalry1 = CreateGroup WEST;

"mar_wmsot_crye_ldr_1" createunit [[(_x1), (_y1),_alt1], _Cavalry1, "this assignascargo _Huey; this moveincargo _Huey", 1, "sergeant"];

"mar_wmsot_crye_ldr_1" createunit [[(_x1), (_y1),_alt1], _Cavalry1, "this assignascargo _Huey; this moveincargo _Huey", 1, "corporal"];

"mar_wmsot_crye_ldr_1" createunit [[(_x1), (_y1),_alt1], _Cavalry1, "this assignascargo _Huey; this moveincargo _Huey", 1, "corporal"];

"mar_wmsot_crye_ldr_1" createunit [[(_x1), (_y1),_alt1], _Cavalry1, "this assignascargo _Huey; this moveincargo _Huey", 1, "corporal"];

"mar_wmsot_crye_ldr_1" createunit [[(_x1), (_y1),_alt1], _Cavalry1, "this assignascargo _Huey; this moveincargo _Huey", 1, "corporal"];

"mar_wmsot_crye_ldr_1" createunit [[(_x1), (_y1),_alt1], _Cavalry1, "this assignascargo _Huey; this moveincargo _Huey", 1, "corporal"];

"mar_wmsot_crye_ldr_1" createunit [[(_x1), (_y1),_alt1], _Cavalry1, "this assignascargo _Huey; this moveincargo _Huey", 1, "corporal"];

"mar_wmsot_crye_ldr_1" createunit [[(_x1), (_y1),_alt1], _Cavalry1, "this assignascargo _Huey; this moveincargo _Huey", 1, "corporal"];

_Cavalry1 setbehaviour "aware";

_Cavalry1 setcombatmode "yellow";

hwp0 = _HeliCrew addwaypoint [getpos _lz, 90];

hwp1 = _HeliCrew addWaypoint [getpos _lz,0];

hwp2 = _HeliCrew addWaypoint [getpos HIlogical1,0];

hwp0 setwaypointtype "MOVE";

hwp1 setwaypointtype "TR UNLOAD";

hwp2 setwaypointtype "MOVE";

hwp2 setwaypointstatements ["true", "HIalldone1 = 1"];

cwp2 = _Cavalry1 addwaypoint [getpos _lz, 50];

cwp2 setwaypointformation "LINE";

cwp2 setwaypointstatements ["true", "HIalldone2 = 1"];

cwp2 setwaypointtype "MOVE";

"SmokeShellGreen" createVehicle (position player);

while {((HIalldone2==0) and (alive _Huey))} do {

sleep 1;

};

if !(alive _Huey) then {end};

{

[(units _Cavalry1) select 0, "I1","spawned","delete:",120] execVM "scripts\upsmon.sqf";

} foreach units _Cavalry1;

while {((HIalldone1 == 0) AND (alive _Huey))} DO {

sleep random 5;

};

if (alive _Huey) then {_Huey setdamage 1};

deletegroup _Cavalry1;

deletegroup _HeliCrew;

Powered by

So I need each of the "mar_marines" to have custom gear thus adding something like this to their init field after being spawned :this addbackpack "rb_backpack_1"

Thanks again! Credit to this post for most of my script http://forums.bistudio.com/showthread.php?97893-Spawned-helicopter-refusing-to-unload-squad

Edited by cjust89

Share this post


Link to post
Share on other sites

I need to also make the spawned group delete after x amount of seconds on the ground. So they fly in, unload, patrol for 600 seconds, then delete.

OR

to have the ability of the spawned squad to be extracted from the same chopper after x amount of seconds patrolling and to then delete the group and helo.

I know upsmon has the ability to determine an area clear or not, so if they are called in on the player, and setup to patrol 300m within the players radius, once the area was determined all clear they would delete, or call back chopper, leave, and then delete.

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  

×