Binesi 10 Posted September 19, 2009 (edited) So, try this in the init field: nul = spawn { waituntil {BIS_fnc_init}; _newObjs = [getpos this, (random 360), "Camp2_INS"] call (compile (preprocessFileLineNumbers "ca\modules\dyno\data\scripts\objectMapper.sqf")); grpD = [getpos this, Resistance, ["GUE_Soldier_CO", "GUE_Soldier_MG", "GUE_Soldier_1", "GUE_Soldier_2", "GUE_Soldier_3", "GUE_Soldier_GL"], [], ["LIEUTENANT", "CORPORAL", "CORPORAL", "PRIVATE", "PRIVATE", "PRIVATE"]] call BIS_fnc_spawnGroup; [grpD, getpos this] call BIS_fnc_taskDefend; }; The only problem is that this doesn't appear to process as expected. It looks like this actually becomes the player and the camp and defender always spawn at the same location as the player when I start the mission. However I did end up thinking in similar lines as you and I edited my last post to show it. Edited September 19, 2009 by Binesi Typo Share this post Link to post Share on other sites
Murklor 10 Posted September 19, 2009 If I understand spawn correctly, basicly it create an instance of the script called (or in this case an inline function). Meaning "this" is useless inside it. Should be possible to do [this] spawn { ... thisUnit = _this select 0 ... }, no? Share this post Link to post Share on other sites
shuko 59 Posted September 19, 2009 Yes, "this" needs to be passed to the spawn obviously. Point of my example was just to add waituntil (and spawn since you cant sleep/wait in init fields). Share this post Link to post Share on other sites
Binesi 10 Posted September 19, 2009 Ok, all good. Thanks for the help. Here is my (final?) iteration of a random camp defense script to paste in the init field of a location logic. Should be self explanatory for anyone needing something like this. _comp = [this] spawn { if (isServer) then { sleep 0.1; waituntil {BIS_fnc_init}; _position = getPos (_this select 0); _units = ["GUE_Soldier_CO", "GUE_Soldier_GL", "GUE_Soldier_MG", "GUE_Soldier_AT", "GUE_Soldier_Sniper", "GUE_Soldier_1", "GUE_Soldier_2", "GUE_Soldier_3"]; _rank = ["LIEUTENANT", "SERGEANT", "CORPORAL", "CORPORAL", "CORPORAL", "PRIVATE", "PRIVATE", "PRIVATE"]; _skill = [(0.4 + random 0.6), (0.4 + random 0.4), (0.4 + random 0.3), (0.4 + random 0.3), (0.4 + random 0.3), (0.2 + random 0.3), (0.2 + random 0.3), (0.2 + random 0.3)]; _side = Resistance; _random = [4, 0.5]; _object = [_position, (random 360), "Camp2_INS"] call (compile (preprocessFileLineNumbers "ca\modules\dyno\data\scripts\objectMapper.sqf")); sleep 0.1; _group = [_position, _side, _units, [], _rank, _skill, [], _random] call BIS_fnc_spawnGroup; sleep 1; [_group, _position] call BIS_fnc_taskDefend; } } The way I am using this is I have some markers setup at different map locations grouped to a "Locations" Game Logic. Combined with this script I get a camp placed randomly at one of the markers with a semi random set of defenders. Now the only problem is the predefined camps mostly are poorly implemented. The Russian ones usually have ammo crates buried in the ground and static defenses completely blocked from firing. And then from what I have seen of the AI it will only man 2 static defenses at most and will completely ignore available vehicles. Some of these camps have BMP3s and tanks etc that the AI will not even try to utilize. The defensive structures like towers, bunkers, etc will also be completely ignored by the AI. There is only a small portion of the available compositions which can be placed for any useful purpose. Share this post Link to post Share on other sites
Binesi 10 Posted September 21, 2009 Actually, here is a much better version run as a separate script: /* SpawnComp.sqf by Binesi Based partly on BIS code found in the functions module. Usage: comp = [this, _type, _group, _side, _units, _required] execVM "Server/CMP/Server_SpawnComp.sqf" */ if ((isServer) || (!isNull (_this select 0)) || (count (_this select 4) > 1)) then { _position = getPos (_this select 0); _type = _this select 1; // Name of composition _group = _this select 2; // Name for group _side = _this select 3; // Side for group _units = _this select 4; // Array of unit types to spawn (at least 2 required) _required = _this select 5; // Minimum units to create from _units array. The rest will be random 50%. //-- Create Composition _comp = [_position, (getDir (_this select 0)), _type] call (compile (preprocessFileLineNumbers "ca\modules\dyno\data\scripts\objectMapper.sqf")); sleep 0.1; //-- Create Group _group = createGroup _side; _i = 0; { if (_i == 0) then { //-- Create group leader _safepos = [_position,1,8,1,0,1,0] call BIS_fnc_findSafePos; _man = _group createUnit [_x,_safepos, [], 0, "FORM"]; //_man addEventHandler ["killed",{_this execVM 'Common\UnitKilled.sqf'}]; // CHANGE ME _man setCombatMode "RED"; _man setBehaviour "AWARE"; _man setRank "SERGEANT"; _man setSkill (0.4 + random 0.6); _group selectLeader _man; } else { if (_i == 1) then { //-- Create assistant group leader _safepos = [_position,1,8,1,0,1,0] call BIS_fnc_findSafePos; _man = _group createUnit [_x,_safepos, [], 0, "FORM"]; //_man addEventHandler ["killed",{_this execVM 'Common\UnitKilled.sqf'}]; // CHANGE ME _man setSkill (0.4 + random 0.4); } else { //-- Create regular squad members //-- Should this unit be skipped? private ["_skip"]; _skip = false; //-- Has the required number been reached? if (_i > (_required - 1)) then { //-- Randomize the spawn chance if ((random 1) > 0.50) then { _skip = true }; }; if (!_skip) then { _safepos = [_position,1,8,1,0,1,0] call BIS_fnc_findSafePos; _man = _group createUnit [_x,_safepos, [], 0, "FORM"]; //_man addEventHandler ["killed",{_this execVM 'Common\UnitKilled.sqf'}]; // CHANGE ME _man setRank "PRIVATE"; _man setSkill (0.2 + random 0.5); }; }; }; _i = _i + 1; } forEach _units; sleep 1; [_group, _position] call BIS_fnc_taskDefend; } Don't use a Game Logic for this. Use a concrete block or something so you don't waste game resources. After you place that where you want the camp to be use something like this for the init: deleteCollection this; null = [this, "Camp2_INS", "TestGroup", East, ["Ins_Soldier_CO", "Ins_Soldier_GL", "Ins_Soldier_MG", "Ins_Soldier_AR", "Ins_Soldier_AT", "Ins_Soldier_Sniper", "Ins_Soldier_Medic", "Ins_Soldier_1", "Ins_Soldier_2"], 4] execVM "SpawnComp.sqf" And there you go, a nice little camp with some believable semi-random defenders. Share this post Link to post Share on other sites
Bunny75 10 Posted September 24, 2009 (edited) I'm having problems with the call BIS_fnc_spaawnGroup. This arty_guard_grp_1 = [_guard_pos_1, EAST, (configFile >> "CfgGroups" >> "East" >> "RU" >> "Mechanized" >> "RU_MechInfSquad_1")] call BIS_fnc_spawnGroup Will not function with this (it only moves to formation after spawning): _gpwp1 = arty_guard_grp_1 addWaypoint [getPos arty_1, 100]; _gpwp1 setWaypointType "SAD"; _gpwp1 setWaypointSpeed "LIMITED"; _gpwp1 setWaypointBehaviour "AWARE"; _gpwp1 setWaypointCombatMode "RED"; And If I make 2 spawn groups, only first of them will spawn: _guard_pos_1 = [(getPos arty_1 select 0) - 50, (getPos arty_1 select 1) - 50, 0]; _guard_pos_2 = [(getPos arty_1 select 0) + 20, getPos arty_1 select 1, 0]; arty_guard_grp_1 = [_guard_pos_1, EAST, (configFile >> "CfgGroups" >> "East" >> "RU" >> "Mechanized" >> "RU_MechInfSquad_1")] call BIS_fnc_spawnGroup arty_guard_grp_2 = [_guard_pos_2, EAST, (configFile >> "CfgGroups" >> "East" >> "RU" >> "Motorized" >> "RU_MotInfSection_Patrol")] call BIS_fnc_spawnGroup WTF? ---------- Post added at 11:09 AM ---------- Previous post was at 09:22 AM ---------- Is there a limit using BIS_fnc_spawnGroup ? Edited September 24, 2009 by Bunny75 Share this post Link to post Share on other sites
cobra4v320 27 Posted September 24, 2009 (edited) Bunny Try this: _gpwp1 = arty_guard_grp_1 addWaypoint [Position arty_1, 100]; _guard_pos_1 = [(getPos arty_1 select 0) - 50, (getPos arty_1 select 1) - 50, 0]; _guard_pos_2 = [(getPos arty_1 select 0) + 20, getPos arty_1 select 1, 0]; sleep 1; arty_guard_grp_1 = [_guard_pos_1, EAST, (configFile >> "CfgGroups" >> "East" >> "RU" >> "Mechanized" >> "RU_MechInfSquad_1")] call BIS_fnc_spawnGroup; arty_guard_grp_2 = [_guard_pos_2, EAST, (configFile >> "CfgGroups" >> "East" >> "RU" >> "Motorized" >> "RU_MotInfSection_Patrol")] call BIS_fnc_spawnGroup; Edited September 24, 2009 by cobra4v320 Share this post Link to post Share on other sites
Bunny75 10 Posted September 24, 2009 Bunny Try this: _gpwp1 = arty_guard_grp_1 addWaypoint [Position arty_1, 100]; Nope :confused: Share this post Link to post Share on other sites
cobra4v320 27 Posted September 24, 2009 Bunny Read above, also did you forget to use a semicolon? Are you trying to spawn this on arty_1 or near arty_1? Share this post Link to post Share on other sites
Bunny75 10 Posted September 24, 2009 Bunny Read above, also did you forget to use a semicolon? Oh dear god what a noob I am :butbut: I'm sorry, I really am. *shoots himself* Share this post Link to post Share on other sites
december 0 Posted September 24, 2009 (edited) Is anyone using this in MP? I use the following script as suggested earlier in this thread to create some tanks and units but I keep getting tanks created for players and the server. if (!isServer) exitWith {}; _vehicle_types = ["T90"]; _max_dist_between_waypoints = 700; _grpe1 = createGroup east; _vec_type = floor (random count _vehicle_types); [(getpos posm21), random 360, _vehicle_types select _vec_type, _grpe1] call BIS_fnc_spawnVehicle; _grpe2 = createGroup east; _vec_type = floor (random count _vehicle_types); [(getpos posm22), random 360, _vehicle_types select _vec_type, _grpe2] call BIS_fnc_spawnVehicle; I have tried "if (isServer) then {" But same result. I am just about to give up on this function and go back to the old way of scripting to create units.:mad: Edited September 24, 2009 by december Share this post Link to post Share on other sites
shuko 59 Posted September 24, 2009 if (isserver) then { blabla call BIS_fnc_spawnVehicle; }; Works fine for me. Share this post Link to post Share on other sites
Bunny75 10 Posted October 8, 2009 _aa_dist = (random 200)+300; _aa_pos_0 = [(getPos target_building select 0) + _aa_dist, getPos target_building select 1, getPos target_building select 2]; guard_aa_0 = [_aa_pos_0, 0, "2S6M_Tunguska", East] call BIS_fnc_spawnVehicle; So this works fine and dandy. Tunguska created in the right place. Problem is when I try to refer to it in other .sqf later: guard_aa_0 reveal _target; guard_aa_0 doWatch _target; guard_aa_0 doTarget _target; This holds the .sqf and the tunguska doesn't react to the commands given. Doing the same thing for tunguska that had been added in the editor, all works fine? Share this post Link to post Share on other sites
Rommel 2 Posted October 8, 2009 _gunner = gunner guard_aa_0; _gunner reveal _target; _gunner doWatch _target; _gunner doTarget _target; I have a sneaky suspicion this might work. If not, then make sure the guard_aa_0 is actually what it is meant to be. Use a hint or a sidechat message to confirm it is indeed crewed and is named what you think. Share this post Link to post Share on other sites
Bunny75 10 Posted October 8, 2009 (edited) Nope, no worky Seems if I even try to get the name it stops the .sqf Edited October 8, 2009 by Bunny75 Share this post Link to post Share on other sites
AgentD 10 Posted October 8, 2009 Maybe try playing with setVehicleVarName? Share this post Link to post Share on other sites
Big_Daddy 10 Posted October 8, 2009 (edited) spawnvehicle Returns: Array: 0: new vehicle (Object). 1: all crew (Array of Objects). 2: vehicle's group (Group). so.. _gunner = gunner (guard_aa_0 select 0); _gunner reveal _target; _gunner doWatch _target; _gunner doTarget _target; Edited October 8, 2009 by Big_Daddy added Rommel's suggestion Share this post Link to post Share on other sites
muttly 10 Posted November 5, 2009 Hi all So ive set up a radio trigger and put getPos player, side player, (configFile >> "CfgGroups" >> "West" >> "USMC" >> "Infantry" >> "USMC_FireTeam_AT")] call BIS_fnc_spawnGroup the units spawn but how do i get them to join me so iam squad leader cheers:) Share this post Link to post Share on other sites
CombatComm 10 Posted November 10, 2009 Is there no A10 squadron? Whatsup with that? lol Share this post Link to post Share on other sites
manzilla 1 Posted November 21, 2009 (edited) _grp = [position spawngroup, side player, (configFile >> "CfgGroups" >> "West" >> "USMC" >> "Infantry" >> "USMC_InfSquad")] call BIS_fnc_spawnGroup _wp = _grp addWaypoint [getpos guy, 0]; _wp setWaypointType "MOVE"; _wp setWaypointSpeed "FULL"; How do I set this up? Add it to a game logic? That doesn't seem to work. EDIT: I got the group to spawn. I put the above code into the init.sqf then place a GL named "spawngroup", but they don't move. What do I do about the wp? Edited November 21, 2009 by Manzilla Share this post Link to post Share on other sites
Heatseeker 0 Posted November 22, 2009 I got the group to spawn. I put the above code into the init.sqf then place a GL named "spawngroup", but they don't move. What do I do about the wp? "SpawnGroup" doesnt need to be a logic, it can be an editor placed object. If you dont have something named "guy" in the editor it wont work i guess, but the function works well combined with taskDefend or taskPatrol :) . Share this post Link to post Share on other sites
manzilla 1 Posted November 22, 2009 (edited) "SpawnGroup" doesnt need to be a logic, it can be an editor placed object. If you dont have something named "guy" in the editor it wont work i guess, but the function works well combined with taskDefend or taskPatrol :) . Thanks heatseeker! Hmmm. I have something called "guy" in the Editor as well. I'll try something else though. EDIT: Not sure why but I've placed an invisible H and named it "guy" but the group still doesn't move after spawning. Edited November 22, 2009 by Manzilla Share this post Link to post Share on other sites
manzilla 1 Posted November 22, 2009 Even this doesn't work: _grp1 = [position spawngroup, side player, (configFile >> "CfgGroups" >> "West" >> "USMC" >> "Infantry" >> "USMC_InfSquad")] call BIS_fnc_spawnGroup _wp = _grp1 addWaypoint [position wp1, 0]; _wp setWaypointType "MOVE"; _wp setWaypointSpeed "FULL"; _wp = _grp1 addWaypoint [position wp2, 0]; _wp setWaypointType "MOVE"; _wp setWaypointSpeed "FULL"; _wp = _grp1 addWaypoint [position wp3, 0]; _wp setWaypointType "DISMISS"; _wp setWaypointSpeed "FULL"; Not sure why the group will not move. I have 3 invisible H's named wp1, wp2, and wp3 but the spawned group does not move. Does anyone have any suggestions? Share this post Link to post Share on other sites
shuko 59 Posted November 22, 2009 You've made sure the group is actually spawned? Share this post Link to post Share on other sites
manzilla 1 Posted November 22, 2009 Yes sir. It sure spawns at the invisible H named "spawngroup" but they don't move. I've tried it with GL's too. No luck. Share this post Link to post Share on other sites