Jump to content
Sign in to follow this  
jakkob4682

Getting Friendly Fire with spawned group

Recommended Posts

This is a script I'm working on, when I spawn the group they fire on each other, please help(no pre-placed enemy units). Also how would I go about finding the nearest city center for any west unit?

private ["_townCenter","_iedPos","_ied","_trig","_ambgrp","_iedCount","_townCenters","_type","_mrk","_TC","_count"];
_iedCount = 0;
_townCenters = nearestLocations[player,["CityCenter"],500];
_townCenter = _towncenters select 0;
_mk = createMarker ["mk",getPos _townCenter];
_mk  setMarkerShape "ICON";
_mk setMarkerType "DOT";
_mk setMarkerColor "ColorGreen";
_TC = createTrigger ["EmptyDetector",getPos _townCenter];
_TC setTriggerArea [150,150,0,False];
_TC setTriggerActivation ["WEST","PRESENT",True];
_TC setTriggerStatements ["this","",""];
_count = west countSide list _TC;

waitUntil {!isNull _townCenter};
if (_count >=4) then {_iedCount = _count*3} else {_iedCount = 10}; 
addIED =
{
	_eGrp = createCenter east;
	_grpE = createGroup east;
	_ambgrp = [getPos _townCenter, side player, (configFile >> "CfgGroups" >> "EAST" >> "INS" >> "INFANTRY" >> "INS_MilitiaSquad")] call BIS_fnc_spawnGroup;
	_ambgrp setBehaviour "COMBAT";
	_ambgrp setCombatMode "YELLOW";
for "_i" from 0 to _iedCount do {
	_iedPos = [getPos _townCenter,random 90,random 360]call BIS_fnc_relpos;
	_ied = createVehicle ["LAND_IED_V1_PMC",_iedpos, [], 0, "NONE"] ;
	_trig = ([getPosATL _ied, "AREA:", [5, 5, 0, false], "ACT:", ["WEST", "PRESENT", false],"STATE:",["this","deleteVehicle (thisTrigger getVariable ['ied',objNull]); createVehicle ['ACE_PipebombExplosion',getPosATL thisTrigger, [], 0, 'NONE']",""]] call CBA_fnc_createTrigger) select 0;
	_trig setVariable ["ied",_ied];
	_mrk = createMarker[format ["ied_%1",random 1000],_iedpos];
	_mrk setMarkerShape "ICON";
	_mrk setMarkerType "DOT";
	};
};
call addIED;

thanks any help in advance

---------- Post added at 17:46 ---------- Previous post was at 17:35 ----------

halp!!!

Share this post


Link to post
Share on other sites

Player isn't east side, right? But spawned units are, still are spawned for group of player's side (in BIS function parameters).

This happens, when units of classes origining by config (default) from one side are spawned in group of another, hostile side with createUnit_array, a nd used here function uses that command. If you want properly behaving units of classes not assigned by default to the group's side, should be used: createUnit

Share this post


Link to post
Share on other sites

so in other words I need to create a seperate function that adds units of a certain type and then execute from inside the code block?

Share this post


Link to post
Share on other sites

If you want spawn eastern units inside western group, vice versa or similar - needed is code working on createunit, can be a custom function. If you prefer BIS' spawnig function - spawn units of given side only with same group side (second parameter of BIS_fnc_spawnGroup should be east, not "side player" for insurgents, if player isn't east side too).

Share this post


Link to post
Share on other sites

omg i feel stupid, i copy and pasted the example from the wiki and editted it and forgot to change side lol, thank RYD

Share this post


Link to post
Share on other sites

get out of my thread....

---------- Post added at 18:20 ---------- Previous post was at 18:19 ----------

RYD another problem, i set side to east, they're now considered hostile but they wont engage me now.

Share this post


Link to post
Share on other sites

Is there any other eastern unit on map placed via editor? If no - set one anywhere, eg with 0% probability (so will not appear in game for sure). Scripted createCenter east is for some reason not sufficient to get proper hostile reaction.

Share this post


Link to post
Share on other sites

thank RYD i'll just make sure to include that in the readme for it.

---------- Post added at 18:37 ---------- Previous post was at 18:25 ----------

one more question RYD how would I get the nearestLocation of each west unit? Also, in its current version if I move to another location will it still work? i.e. spawn the group and ieds?

Share this post


Link to post
Share on other sites

I've not much time left right now, so can't create any code nor analyze yours, but in general you can use {if ((side _x) == west) then {nearest location stuff here}} foreach AllUnits to find nearest location for each western unit. Important may be, how do you save that location's position for further use. Can be stored in some array, or bind with unit via setvariable... This of course must be refreshed if unit is moving and you need current nearest location, not only initial. Can't help more right now, sorry.

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  

×