OFPEC Forum

Editors Depot - Mission Editing and Scripting => Arma2 - Editing/Scripting General => Topic started by: Mr.Peanut on 18 Oct 2010, 20:57:17

Title: Detecting a side center
Post by: Mr.Peanut on 18 Oct 2010, 20:57:17
Is there any way of testing if a side's center already exists before creating one? For example, a script requires a civilian side, but it is unknown whether the mission maker has added civ units or not.

If I "createCenter Civilian" on a map that already has civs, will it break anything?
Title: Re: Detecting a side center
Post by: Worldeater on 18 Oct 2010, 21:26:19
Excellent question. I wonder if the dude who wrote this found out yet:

Quote from: \modules\ambient_combat\data\fsms\ambientcombat.fsm
//TODO: dangerous? What if the mission already did this? Somehow check that.
private ["_centerW", "_centerE", "_centerG", "_centerC"];
_centerW = createCenter west;
_centerE = createCenter east;
_centerG = createCenter resistance;
_centerC = createCenter civilian;

From my experience it's fine to create multiple centers for one side.

Title: Re: Detecting a side center
Post by: i0n0s on 18 Oct 2010, 22:13:45
Code: [Select]
_group = createGroup civilian;
if (isNull _group) then {
    createCenter civilian;
    resistance setFriend [east, 0];
} else {
    deleteGroup _group;
};
Title: Re: Detecting a side center
Post by: Mr.Peanut on 19 Oct 2010, 01:17:46
thanks. why did you include
Code: [Select]
resistance setFriend [east, 0];
?
Title: Re: Detecting a side center
Post by: i0n0s on 19 Oct 2010, 01:18:51
Because that code was original for resistance and I forgot to remove it.
That code was added since new created sides are friendly to anyone.