Home   Help Search Login Register  

Author Topic: Detecting a side center  (Read 1492 times)

0 Members and 1 Guest are viewing this topic.

Offline Mr.Peanut

  • Former Staff
  • ****
  • urp!
Detecting a side center
« 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?
« Last Edit: 20 Oct 2010, 15:35:30 by Mr.Peanut »
urp!

Offline Worldeater

  • Former Staff
  • ****
  • Suum cuique
Re: Detecting a side center
« Reply #1 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.

try { return true; } finally { return false; }

Offline i0n0s

  • Moderator
  • *****
Re: Detecting a side center
« Reply #2 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;
};

Offline Mr.Peanut

  • Former Staff
  • ****
  • urp!
Re: Detecting a side center
« Reply #3 on: 19 Oct 2010, 01:17:46 »
thanks. why did you include
Code: [Select]
resistance setFriend [east, 0];
?
urp!

Offline i0n0s

  • Moderator
  • *****
Re: Detecting a side center
« Reply #4 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.