Jump to content
Sign in to follow this  
frosties

Spawning enemy

Recommended Posts

Im playing around with the idea of spawning enemy once entering an area, for the sake of not having everything place in the editor.

im using:

Trigger with this in on act:

_h = []execVM "spawnai.sqf";

spawnai.swf

_group1 = [getMarkerPos"spwn1", east, ["TK_Soldier_EP1","TK_Soldier_EP1","TK_Soldier_EP1"]] call BIS_fnc_spawnGroup;

Is there a way for me to put something in the soldiers init file through this way of doing it?

The soldiers are spawning alright, but i need them to have a patrolscript called from the INIT field.

Share this post


Link to post
Share on other sites

You don't need to pass it through the init field. You can just use the group directly:

_group1 = [getMarkerPos"spwn1", east, ["TK_Soldier_EP1","TK_Soldier_EP1","TK_Soldier_EP1"]] call BIS_fnc_spawnGroup;
[_group1] execvm "patrol.sqf";

Assuming patrol takes group in, if not. If it takes a unit instead do:

[leader _group1] execvm "patrol.sqf";

Share this post


Link to post
Share on other sites

Maybe i should have posted the INIT that i needed as well :)

This is the init i have in the soldier in question:

nul=[this,"garmarud_patrol","random","min:",10,"max:",25] execVM "ups.sqf"

Im using the UPS script to spawn enemies in towns, and working on getting them to spawn when a BLUEFOR is getting close o the town.

Share this post


Link to post
Share on other sites

It's irrelevant what the init would be, just apply it to the examples. ;)

Share this post


Link to post
Share on other sites

frostie i am trying to achieve the exact same yhing but without the ups or maybe eith i actually never thought of ups any way mate do you mind placing the code for your spawn and patrol files so i can have a look.

Share this post


Link to post
Share on other sites

I have this function that might help you. It requires CBA.

I like the CBA functions more than UPSMON or UPS. :)

/*
   Description:
   Spawns a group from CfgGroups and 
   enters them into a CBA_fnc_task


   Parameter(s):
   _this select 0: Faction configuration (string);
   _this select 1: Spawn position (position array);
   _this select 2: taskDefend, taskAttack or taskPatrol (string);
   _this select 3: Radius;
   _this select 4: 
       taskDefend: Disable patroling (boolean);
       taskAttack: Destination (position array);
       taskPatrol: N/A.

   Initialisation:

   HLF_fnc_spawnGroup = compile preprocessFileLineNumbers "HLF_fnc_spawnGroup.sqf";

   Call:

       taskDefend:
   _myGroup = ["BIS_TK",(getMarkerPos "spawnPos"),"taskDefend",200,true] call HLF_fnc_spawnGroup;

       taskAttack:
   _myGroup = ["BIS_CZ",(getMarkerPos "spawnPos"),"taskAttack",200,(getMarkerPos "attackPos")] call HLF_fnc_spawnGroup;

       taskPatrol:
   _myGroup = ["BIS_BAF",(getMarkerPos "spawnPos"),"taskPatrol",200] call HLF_fnc_spawnGroup;

   Notes:
   Returns the group for use in other scripts.
*/

private ["_faction",
        "_group",
        "_location",
        "_task",
        "_radius",
        "_disablePatrol",
        "_destination"
];

_faction = _this select 0;
_location = _this select 1;
_task = _this select 2;
_radius = _this select 3;

switch (_task) do {
   case "taskDefend" : {_disablePatrol = _this select 4};
   case "taskAttack" : {_destination = _this select 4};
   case "taskPatrol" : {};
};


switch (_faction) do {
   case "USMC" : {_group = [_location,  WEST, (configFile >> "CfgGroups" >> "West" >> "USMC" >> "Infantry" >> "USMC_InfSquad")] call BIS_fnc_spawnGroup};
   case "CDF" : {_group = [_location,  WEST, (configFile >> "CfgGroups" >> "West" >> "CDF" >> "Infantry" >> "CDF_InfSquad")] call BIS_fnc_spawnGroup};
   case "RU" : {_group = [_location,  EAST, (configFile >> "CfgGroups" >> "East" >> "RU" >> "Infantry" >> "RU_InfSquad")] call BIS_fnc_spawnGroup};
   case "INS" : {_group = [_location,  EAST, (configFile >> "CfgGroups" >> "East" >> "INS" >> "Infantry" >> "INS_InfSquad")] call BIS_fnc_spawnGroup};
   case "GUE" : {_group = [_location,  GUER, (configFile >> "CfgGroups" >> "Guerrila" >> "GUE" >> "Infantry" >> "GUE_InfSquad")] call BIS_fnc_spawnGroup};

   case "BIS_US" : {_group = [_location, WEST, (configFile >> "CfgGroups" >> "West" >> "BIS_US" >> "Infantry" >> "US_RifleSquad")] call BIS_fnc_spawnGroup};
   case "BIS_CZ" : {_group = [_location,  WEST, (configFile >> "CfgGroups" >> "West" >> "BIS_CZ" >> "Infantry" >> "ACR_InfantryPatrol")] call BIS_fnc_spawnGroup};
   case "BIS_GER" : {_group = [_location,  WEST, (configFile >> "CfgGroups" >> "West" >> "BIS_GER" >> "Infantry" >> "KSKTeam")] call BIS_fnc_spawnGroup};
   case "BIS_TK" : {_group = [_location,  EAST, (configFile >> "CfgGroups" >> "East" >> "BIS_TK" >> "Infantry" >> "TK_InfantrySquad")] call BIS_fnc_spawnGroup};
   case "BIS_TK_INS" : {_group = [_location,  EAST, (configFile >> "CfgGroups" >> "East" >> "BIS_TK_INS" >> "Infantry" >> "TK_INS_Group")] call BIS_fnc_spawnGroup};
   case "BIS_TK_GUE" : {_group = [_location,  GUER, (configFile >> "CfgGroups" >> "Guerrila" >> "BIS_TK_GUE" >> "Infantry" >> "TK_GUE_Group")] call BIS_fnc_spawnGroup};
   case "BIS_UN" : {_group = [_location,  GUER, (configFile >> "CfgGroups" >> "Guerrila" >> "BIS_UN" >> "Infantry" >> "UN_Patrol")] call BIS_fnc_spawnGroup};

   case "BIS_BAF" : {_group = [_location,  WEST, (configFile >> "CfgGroups" >> "West" >> "BIS_BAF_MTP" >> "Infantry" >> "BAF_Section_MTP")] call BIS_fnc_spawnGroup};
   case "PMC_BAF" : {_group = [_location,  GUER, (configFile >> "CfgGroups" >> "Guerrila" >> "PMC_BAF" >> "Infantry" >> "PMC_Security_Detail")] call BIS_fnc_spawnGroup};
};

switch (_task) do {
   case "taskDefend" : {
       [_group, _location, _radius,1,_disablePatrol] call CBA_fnc_taskDefend;
       if (debug) then {
           player sideChat format ["%1: Faction is %2, location is %3, radius is %4, disable patroling is %5",_task,_faction, _location,  _radius, _disablePatrol];
       };
   };
   case "taskAttack" : {
       [_group, _destination, _radius] call CBA_fnc_taskAttack;
       if (debug) then {
           player sideChat format ["%1: Faction is %2, location is %3, radius is %4, destination is %5",_task,_faction, _location,  _radius, _destination];
       };
   };
   case "taskPatrol" : {
       [_group, _location, _radius] call CBA_fnc_taskPatrol;
       if (debug) then {
           player sideChat format ["%1: Faction is %2, location is %3, radius is %4",_task,_faction, _location, _radius];
       };
   };
};

_group

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  

×