Forum Jump :

Author Message


Posts: 76
Rank:


Level: Member

Country: au
Location:
Occupation: Student/DIY minor scripter
Age: 24
In-game name: Drew

 
#1 Posted at 2012-08-24 18:12        
     
Howdy, I am currently attempting to have a part in a mission where you have to 'Hold the front lines' with waves of aggressors. I am trying to use the "!alive unit" function, but to minimal success. What I want is the exact opposite. Instead of doing the action UNTIL the unit dies, I want it to do the action AFTER the unit has died. I this way, I could only make a new wave role in after the current wave has been destroyed, preventing you having 80 enemy units converging on your location... Any help would be appreciated.

=Foxhound]You can add 250.004 smileys to your post but not a proper title and proper info?[/quote]

Author Message

Pirin  



Posts: 1547
Rank:


Level: Member

Country: us
Location: Atlanta, GA
Occupation: IT
Age: 46
In-game name: kylania

 
#2 Posted at 2012-08-24 18:49        
     
This demo mission was to spawn traffic, but it's basically the same thing, wait till units get to a specific area or are dead then do it all over again.


Advertisement


Author Message


Posts: 76
Rank:


Level: Member

Country: au
Location:
Occupation: Student/DIY minor scripter
Age: 24
In-game name: Drew

 
#3 Posted at 2012-08-25 04:09        
     
I am trying to cut up the script and make it do what I want, but I don't know what unctions I can use for it.

Added 1 hour 6 minutes later:

I had a bit of a scout looking for the spawning names of groups. I am trying to have a constantly spawning flow of groups, but I can't get the names of the groups to spawn them in. Any help would be appreciated.

This post was edited by Dutchy (2012-08-25 05:16, ago)

=Foxhound]You can add 250.004 smileys to your post but not a proper title and proper info?[/quote]

Author Message

Pirin  



Posts: 1547
Rank:


Level: Member

Country: us
Location: Atlanta, GA
Occupation: IT
Age: 46
In-game name: kylania

 
#4 Posted at 2012-08-25 06:40        
     
You can find the names of groups to use with the configfile version of spawnGroup here:

http://community.bistudio.com/wiki/Ambient_Combat_Manager_-_Group_types


Author Message


Posts: 76
Rank:


Level: Member

Country: au
Location:
Occupation: Student/DIY minor scripter
Age: 24
In-game name: Drew

 
#5 Posted at 2012-08-25 08:49        
     
I have borrowed and cut up segements of that script. I thought I had it all good, but when I spawn into the mission to trigger a group of units to spawn, walk 20 M and then despawn, nothing happens. Here's what I am running at the moment.
Group spawning test
If anyone could have a look through it and see what dumb mistake I have made, that'd be great.

Added 6 minutes later:

Or, if you can't access that, my script is this:
waituntil {!isnil "bis_fnc_init"};

_GroupClass = _this select 0; // Group class (string)
_spawnPos = _this select 1; // Spawning location (position)
_spawnDir = _this select 2; // Spawning azimuth (number)
_destPos = _this select 3; // Destination location (position)
_GroupSide = if (count _this > 4) then {_this select 4} else {WEST}; // Group side (SIDE)
_travelSpeed = if (count _this > 5) then {_this select 5} else {"LIMITED"}; // Waypoint speed (string)
_travelBehaviour = if (count _this > 6) then {_this select 6} else {"CARELESS"}; // Group behaviour (string)
_destructionDistance = if (count _this > 7) then {_this select 7} else {20}; // Distance from destination to delete (number)
_destructionDelay = if (count _this > 8) then {_this select 8} else {2}; // Delay in seconds after reaching destination to delete (number)

if (isServer) then {
	// Spawn the group.  Make sure the Functions Module is on map.
	_spawngroup = [_spawnPos, _spawnDir, _GroupClass, _GroupSide] call BIS_fnc_spawnGroup;
	
	// Name the vehicle and group and set them to careless.
	_spawngroupActual = _spawngroup select 0; // vehicle spawned.
	_svGroup = _spawngroup select 2; // group of vehicle so waypoints work.
	_svGroup setBehaviour _travelBehaviour; // Make sure they don't get distracted.
	
	// Give the vehicle a waypoint to where the player is and make drive there.
	_wp0 = _svGroup addwaypoint [_destPos, 0];
	_wp0 setwaypointtype "MOVE";
	_wp0 setWaypointSpeed _travelSpeed;

	// Once you're within set distance of the waypoint (or destroyed/damaged), delete the vehicle and group members if still there.
	waitUntil{_spawngroupActual distance _destPos < _destructionDistance OR !canMove _spawngroupActual OR {alive _x} count units _spawngroupActual == 0};
	sleep _destructionDelay;
	{deleteVehicle _x} forEach units _svGroup;  // If anyone got out of the vehicle, delete them too.
	deleteGroup _svGroup;  // Free up the group slot.
};

This post was edited by Dutchy (2012-08-25 08:56, ago)

=Foxhound]You can add 250.004 smileys to your post but not a proper title and proper info?[/quote]

Author Message


Posts: 1524
Rank:


Level: Member

Country: uk
Location:
Occupation:
Age:
In-game name:

 
#6 Posted at 2012-08-25 15:06        
     
Couldn't download the file, is says not available.
Please include the way you call the script and good practice to include it in the script, it saves alot of time trying to work out what goes where and we can tell what your trying to achieve.

// null=[that,that,whatever] execvm "callscript.sqf"

Is it a vehicle spawning script or group spawning script.

Your using BIS_fnc_spawnGroup; but then I read this // Name the vehicle and group and set them to careless.


but later I don't see where your deleteing the vehicle.

Very confusing


Author Message


Posts: 76
Rank:


Level: Member

Country: au
Location:
Occupation: Student/DIY minor scripter
Age: 24
In-game name: Drew

 
#7 Posted at 2012-08-25 15:21        
     
Sorry, yeah, I'm kinda just messing with stuff I only just understand. I have 2 markers set up, one names groupStart and ond named groupEnd. I have a trigger linked to the player, in it's OnAct line:
nul = ["RU_InfSection", getMarkerPos "GroupStart", 270, getMarkerPos "GroupEnd", WEST, "FAST", "DANGER"] 
I have the function module on the map (I'm pretty sure it doesn't work otherwise) The TRUE script is:
waituntil {!isnil "bis_fnc_init"};

_GroupClass = _this select 0; // Group class (string)
_spawnPos = _this select 1; // Spawning location (position)
_spawnDir = _this select 2; // Spawning azimuth (number)
_destPos = _this select 3; // Destination location (position)
_GroupSide = if (count _this > 4) then {_this select 4} else {WEST}; // Group side (SIDE)
_travelSpeed = if (count _this > 5) then {_this select 5} else {"LIMITED"}; // Waypoint speed (string)
_travelBehaviour = if (count _this > 6) then {_this select 6} else {"CARELESS"}; // Group behaviour (string)
_destructionDistance = if (count _this > 7) then {_this select 7} else {20}; // Distance from destination to delete (number)
_destructionDelay = if (count _this > 8) then {_this select 8} else {2}; // Delay in seconds after reaching destination to delete (number)

if (isServer) then {
	// Spawn the group.  Make sure the Functions Module is on map.
	_spawngroup = [_spawnPos, _spawnDir, _GroupClass, _GroupSide] call BIS_fnc_spawnGroup;
	
	// Name the group and set them to careless.
	_spawngroupActual = _spawngroup select 0; // group spawned.
	_svGroup = _spawngroup select 2; // group the group so waypoints work.
	_svGroup setBehaviour _travelBehaviour; // Make sure they don't get distracted.
	
	// Give the group a waypoint to where the player is and make them travel there.
	_wp0 = _svGroup addwaypoint [_destPos, 0];
	_wp0 setwaypointtype "MOVE";
	_wp0 setWaypointSpeed _travelSpeed;

	// Once you're within set distance of the waypoint (or destroyed/damaged), delete the group members if still there.
	waitUntil{_spawngroupActual distance _destPos < _destructionDistance OR !canMove _spawngroupActual OR {alive _x} count units _spawngroupActual == 0};
	sleep _destructionDelay;
	{deleteVehicle _x} forEach units _svGroup;
	deleteGroup _svGroup;  // Free up the group slot.
};
The reason it had vehicles and that is because I cut it from this:
//////////////////////////////////////////////////////////////////
// Function file for ArmA 2: Operation Arrowhead
// Created by: kylania
//////////////////////////////////////////////////////////////////

// Default usage:
// nul = ["MtvrSupply_DES_EP1", getMarkerPos "truckStart", 180, getMarkerPos "truckEnd"] execVM "runRoute.sqf";

// Useage with specific position instead of markers:
// nul = ["MtvrSupply_DES_EP1", [5053.31, 6821.45, 0], 270, [4680.65, 5793.69, 0]] execVM "runRoute.sqf";

// Optional usage as OPFOR truck (Default is WEST)
// nul = ["V3S_Open_TK_EP1", getMarkerPos "truckStart", 45, getMarkerPos "truckEnd", EAST] execVM "runRoute.sqf";

// Optional usage as truck driving FAST (Default is "LIMITED")
// nul = ["MtvrSupply_DES_EP1", getMarkerPos "truckStart", 90, getMarkerPos "truckEnd", WEST, "FAST"] execVM "runRoute.sqf";

// Optional usage as truck driving FAST and DANGER (Default is "CARELESS")
// nul = ["MtvrSupply_DES_EP1", getMarkerPos "truckStart", 60, getMarkerPos "truckEnd", WEST, "FAST", "DANGER"] execVM "runRoute.sqf";

// Optional usage as helicopter flying FAST and DANGER deleted 300 meters from it's waypoint. (Default is 20)
// nul = ["Mi17_UN_CDF_EP1", [getMarkerPos "hStart" select 0, getMarkerPos "hStart" select 1, 100], 330, getMarkerPos "hEnd", WEST, "FAST", "DANGER", 300] execVM "runRoute.sqf";

// Optional usage as helicopter flying FAST and DANGER deleted 300 meters from it's waypoint after 60 seconds. (Default is 10)
// nul = ["Mi17_UN_CDF_EP1", [getMarkerPos "hStart" select 0, getMarkerPos "hStart" select 1, 100], 330, getMarkerPos "hEnd", WEST, "FAST", "DANGER", 300, 60] execVM "runRoute.sqf";

// start: [5053.31,6821.45,0.00158691] - 234.173
// end: [4680.65,5793.69,0.00169373] - 76.2395

// Wait till the Functions module is ready.
waituntil {!isnil "bis_fnc_init"};

_vehClass = _this select 0; // Vehicle class (string)
_spawnPos = _this select 1; // Spawning location (position)
_spawnDir = _this select 2; // Spawning azimuth (number)
_destPos = _this select 3; // Destination location (position)
_vehSide = if (count _this > 4) then {_this select 4} else {WEST}; // Group side (SIDE)
_driveSpeed = if (count _this > 5) then {_this select 5} else {"LIMITED"}; // Waypoint speed (string)
_driveBehaviour = if (count _this > 6) then {_this select 6} else {"CARELESS"}; // Group behaviour (string)
_destructionDistance = if (count _this > 7) then {_this select 7} else {20}; // Distance from destination to delete (number)
_destructionDelay = if (count _this > 8) then {_this select 8} else {10}; // Delay in seconds after reaching destination to delete (number)

if (isServer) then {
	// Spawn the vehicle.  Make sure the Functions Module is on map.
	_sv = [_spawnPos, _spawnDir, _vehClass, _vehSide] call BIS_fnc_spawnVehicle;
	
	// Name the vehicle and group and set them to careless.
	_svActual = _sv select 0; // vehicle spawned.
	_svGroup = _sv select 2; // group of vehicle so waypoints work.
	_svGroup setBehaviour _driveBehaviour; // Make sure they don't get distracted.
	
	// Give the vehicle a waypoint to where the player is and make drive there.
	_wp0 = _svGroup addwaypoint [_destPos, 0];
	_wp0 setwaypointtype "MOVE";
	_wp0 setWaypointSpeed _driveSpeed;

	// Once you're within set distance of the waypoint (or destroyed/damaged), delete the vehicle and group members if still there.
	waitUntil{_svActual distance _destPos < _destructionDistance OR !canMove _svActual OR {alive _x} count crew _svActual == 0};
	sleep _destructionDelay;
	{deleteVehicle _x} forEach crew _svActual; 
	deletevehicle _svActual; 
	{deleteVehicle _x} forEach units _svGroup;  // If anyone got out of the vehicle, delete them too.
	deleteGroup _svGroup;  // Free up the group slot.
};
I barely know what i'm doing so a majority of it has been guess work and mild research. The script above is for spawning a supply truck and taking it to another place and despawning it. A link for the actual page is, as Pirin stated, here.

=Foxhound]You can add 250.004 smileys to your post but not a proper title and proper info?[/quote]

Author Message


Posts: 1524
Rank:


Level: Member

Country: uk
Location:
Occupation:
Age:
In-game name:

 
#8 Posted at 2012-08-25 15:45        
     
Try this use the call at top of script to execute the code, save as "spawnGRP.sqf"
// null=[["CDF_Soldier_TL", "CDF_Soldier", "CDF_Soldier_Medic", "CDF_Soldier_GL", "CDF_Soldier_AR"],getmarkerpos "groupstart",0,getmarkerpos "GroupEnd",WEST,"FULL","DANGER",100,2] execvm "spawnGRP.sqf";
waituntil {!isnil "bis_fnc_init"};

_GroupClass = _this select 0; // Group class (string)
_spawnPos = _this select 1; // Spawning location (position)
_spawnDir = _this select 2; // Spawning azimuth (number)
_destPos =  (_this select 3); // Destination location (position)
_GroupSide = if (count _this > 4) then {_this select 4} else {WEST}; // Group side (SIDE)
_travelSpeed = if (count _this > 5) then {_this select 5} else {"LIMITED"}; // Waypoint speed (string)
_travelBehaviour = if (count _this > 6) then {_this select 6} else {"CARELESS"}; // Group behaviour (string)
_destructionDistance = if (count _this > 7) then {_this select 7} else {20}; // Distance from destination to delete (number)
_destructionDelay = if (count _this > 8) then {_this select 8} else {2}; // Delay in seconds after reaching destination to delete (number)



if (isServer) then {
	//_spawngroup = creategroup _GroupSide;
	// Spawn the group.  Make sure the Functions Module is on map.
	_spawngroup = [_spawnPos,_GroupSide,_GroupClass,[],[],[],[],[],_spawnDir] call BIS_fnc_spawnGroup;
	// Name group and set them to careless.
	_spawngroupActual = leader _spawngroup; // leader spawned.
	_svGroup = _spawngroup; // 
	_svGroup setBehaviour _travelBehaviour; // Make sure they don't get distracted.
	
	// Give the group a waypoint 
	_wp0 = _svGroup addwaypoint [_destPos, 0];
	_wp0 setwaypointtype "MOVE";
	_wp0 setWaypointSpeed _travelSpeed;

	// Once you're within set distance of the waypoint delete group
	waitUntil{_spawngroupActual distance _destPos < _destructionDistance OR !canMove _spawngroupActual OR {alive _x} count units _spawngroupActual== 0};
	sleep _destructionDelay;
	{deleteVehicle _x} forEach units _svGroup;  // Delete group
	deleteGroup _svgroup;  // Free up the group slot.
	
	
};


Author Message


Posts: 76
Rank:


Level: Member

Country: au
Location:
Occupation: Student/DIY minor scripter
Age: 24
In-game name: Drew

 
#9 Posted at 2012-08-25 16:52        
     
Perfect! Now, I want to have it loop about four- five times, then, run another script (similiar) to spawn, say three tanks. I want some more stuff added to it later, but one at a time. Much appreciated! *THUMBS UP*

Added 31 minutes later:

I've come across one minor problem with your script, the unit's are only respawning under certain conditions (can't tell exactly what they are) and often not respawning at all. Am I doing something wrong?

This post was edited by Dutchy (2012-08-25 17:24, ago)

=Foxhound]You can add 250.004 smileys to your post but not a proper title and proper info?[/quote]

Author Message


Posts: 1524
Rank:


Level: Member

Country: uk
Location:
Occupation:
Age:
In-game name:

 
#10 Posted at 2012-08-25 20:50        
     
I ran about two hundred waves of infantry without any spawning issued.

This will spawn vehicles it's much the same as before with an extra parameter for the number of vehicles.

However I'd would really take a look at the link Pirin gave you as it's much better for vehicles.

// null=["M1A1",getmarkerpos "vehstart",90,getmarkerpos "vehend",WEST,"FULL","AWARE",10,2,3] execvm "spawn_veh.sqf";
waituntil {!isnil "bis_fnc_init"};

_GroupClass = _this select 0; // Group class (string)
_spawnPos = _this select 1; // Spawning location (position)
_spawnDir = _this select 2; // Spawning azimuth (number)
_destPos =  (_this select 3); // Destination location (position)
_GroupSide = if (count _this > 4) then {_this select 4} else {WEST}; // Group side (SIDE)
_travelSpeed = if (count _this > 5) then {_this select 5} else {"LIMITED"}; // Waypoint speed (string)
_travelBehaviour = if (count _this > 6) then {_this select 6} else {"CARELESS"}; // Group behaviour (string)
_destructionDistance = if (count _this > 7) then {_this select 7} else {20}; // Distance from destination to delete (number)
_destructionDelay = if (count _this > 8) then {_this select 8} else {2}; // Delay in seconds after reaching destination to delete (number)
_veh_qty = if (count _this > 9) then {_this select 9} else {1};// number of vehicles per wave (number)


if (isServer) then {

for "_i = 0" to (_veh_qty-1) do {
 sleep 0.2;
	// Spawn the group.  Make sure the Functions Module is on map.
	_spawngroup = [ _spawnPos,_spawnDir, _GroupClass,_GroupSide ] call BIS_fnc_spawnvehicle;
	// Name the vehicle and group and set them to careless.
	_spawngroupActual = _spawngroup select 0; // vehicle spawned.
	_svGroup = _spawngroup select 2; // group of vehicle so waypoints work.
	_svGroup setBehaviour _travelBehaviour; // Make sure they don't get distracted.

	// Give the vehicle a waypoint to where the player is and make drive there.
	_wp0 = _svGroup addwaypoint [_destPos, 0];
	_wp0 setwaypointtype "MOVE";
	_wp0 setWaypointSpeed _travelSpeed;
	waitUntil {_spawngroupActual distance _spawnPos > 10};// wait for space to spawn
};
	// Once you're within set distance of the waypoint (or destroyed/damaged), delete the vehicle and group members if still there.
	waitUntil{_spawngroupActual distance _destPos < _destructionDistance OR !canMove _spawngroupActual OR {alive _x} count units _spawngroupActual== 0};
	sleep _destructionDelay;
	{deleteVehicle _x} forEach units _svGroup;  // If anyone got out of the vehicle, delete them too.
	deleteGroup _svgroup;  // Free up the group slot.
	deleteVehicle _spawngroupActual;// delete vehicle
};

This post was edited by F2kSel (2012-08-26 20:15, ago)


Author Message


Posts: 76
Rank:


Level: Member

Country: au
Location:
Occupation: Student/DIY minor scripter
Age: 24
In-game name: Drew

 
#11 Posted at 2012-08-26 07:55        
     
Alright, everything's working just fine now. The next thing I want to do is have it so that the group and tanks only despawn about 10 seconds after you kill them, then don't respawn. This way I could set the amount of times they respawn by duplicating the spawn section of the script.

=Foxhound]You can add 250.004 smileys to your post but not a proper title and proper info?[/quote]

Author Message


Posts: 4
Rank:


Level: Member

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

 
#12 Posted at 2012-12-23 16:15        
     
I dont see how this helps. Im not trying to spawn units into my group when a unit dies from my group, I want to return to the FOB and "talk" to a predetermined unit and have it added into my squad or dismiss a unit upon request.


Author Message


Posts: 76
Rank:


Level: Member

Country: au
Location:
Occupation: Student/DIY minor scripter
Age: 24
In-game name: Drew

 
#13 Posted at 2012-12-24 04:59        
     
That's funny, I could have sworn you said
Anusmangler:
I want to be able to replace units as they die
. Silly me, must be my imagination

=Foxhound]You can add 250.004 smileys to your post but not a proper title and proper info?[/quote]

Author Message


Posts: 4
Rank:


Level: Member

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

 
#14 Posted at 2012-12-25 00:03        
     
you read correctly, But i want say like 1 of each type (just as a example) standing at the FOB when I talk to them I want to be able to have them join or dismiss them from my squad. I see what you mean but i want them to join into my squad so yes this helps in a way but not having units join in my squad when I "chat" with them. I know its possible Ive seen it done I just cant find the mission and/or the video on youtube....I'm not looking for answers Im looking just for a How-to or at least a general tutorial on this type of scripting.