Jump to content

Recommended Posts

Hello everyone,

I need a little help I try to create, through a script, a combination of modules to add a civilian presence to the cities crossed by the player.

 

The problem is that at the launch of the mission, despite the generation of three modules (visible and existing in Zeus mode) the main module (ModuleCivilianPresence_F) does not link with the other two modules (ModuleCivilianPresenceSafeSpot_F and ModuleCivilianPresenceUnit_F), and I have the following error message :

 

"bis_fnc_moduleCivilianPresence [x] Civilian Presence L-Alpha 1-2: 1 terminated." There are at least 1 spawnpoint and 1 position module. "

 

How to make dialogue, synchronize the three modules, created via a script, ingame ?

This is just a piece of extracted code; the rest of my project works perfectly :

 

Do not pay attention to the two ways to create a unit, both ways work exactly the same, I put the necessary characters to hide the text for reading the script > /* and */

_townLoc = nearestLocations [getPos player, ["NameVillage","NameCity","NameCityCapital","NameLocal","CityCenter","Airport"], 2500];

if ((count _townLoc) > 0) then
{
	sleep 0.01;
	_townPos = locationPosition (_townLoc select 0);

	/*
	sleep 0.50;
	_MCP_Spawn = (createGroup sideLogic) createUnit ["ModuleCivilianPresenceUnit_F",_townPos,[],0,"NONE"];
	_MCP_Spawn setvariable ['BIS_fnc_initModules_disableAutoActivation', false];
	sleep 0.50;
	_MCP_SafeSpot = (createGroup sideLogic) createUnit ["ModuleCivilianPresenceSafeSpot_F",_townPos,[],0,"NONE"];
	_MCP_SafeSpot setvariable ['BIS_fnc_initModules_disableAutoActivation', false];
	sleep 0.50;
	_MCP_Module = (createGroup sideLogic) createUnit ["ModuleCivilianPresence_F",_townPos,[],0,"NONE"];
	_MCP_Module setvariable ['BIS_fnc_initModules_disableAutoActivation', false];
	*/

	sleep 0.50;
	_MCP_SafeSpot = "ModuleCivilianPresenceSafeSpot_F" createUnit [_townPos, createGroup sideLogic, "this setVariable ['BIS_fnc_initModules_disableAutoActivation', false];", 0.6, "PRIVATE"];
	sleep 0.50;
	_MCP_Spawn = "ModuleCivilianPresenceUnit_F" createUnit [_townPos, createGroup sideLogic, "this setVariable ['BIS_fnc_initModules_disableAutoActivation', false];", 0.6, "PRIVATE"];
	sleep 0.50;
	_MCP_Module = "ModuleCivilianPresence_F" createUnit [_townPos, createGroup sideLogic, "this setVariable ['BIS_fnc_initModules_disableAutoActivation', false];", 0.6, "PRIVATE"];
};

Otherwise I also tried another method : 

I to place the necessary modules in the 3den editor, then move them by script when the player is near a locality.

The modules change position, but the created civil entities always go to the moduleCivilianPresenceSafeSpot module's initial position, ie the position of the module when it was placed in the editor, even if it was changed position. :/

  • Like 1

Share this post


Link to post
Share on other sites

Thank you very much for your help, but this script is part of a more complex project.

I absolutely have to use BI resources.

 

But thanks anyway :satisfied:

  • Thanks 1

Share this post


Link to post
Share on other sites

You can place triggers to spawn/despawn civilians and make them move from a house to another. no need to add modules for that.

Share this post


Link to post
Share on other sites

Hi, I needed also this module so I figured how to place it via script.

 

Here's my code that does that, it's not perfect code but WIP and it only shows you how to create the modules:

 

_grp = createGroup civilian;

placeoneSpot = 
{
_pos = getmarkerpos _this;
_m1 = _grp createUnit ["ModuleCivilianPresenceSafeSpot_F", _pos, [], 0, "NONE"];
_m1 setVariable ["#capacity",5];
_m1 setVariable ["#usebuilding",true];
_m1 setVariable ["#terminal",false];
//_m1 setVariable ["#type",5];

_m2 = _grp createUnit ["ModuleCivilianPresenceUnit_F", _pos, [], 0, "NONE"];

//systemchat format["--> %1 %2", _m1,_m2];
};

"marker_0" call placeoneSpot;
"marker_1" call placeoneSpot;

_cen = getpos player;

_m = _grp createUnit ["ModuleCivilianPresence_F", [0,0,0], [], 0, "NONE"];
_m setVariable ["#area",[_cen,1000,1000,0,true,-1]];  // Fixed! this gets passed to https://community.bistudio.com/wiki/inAreaArray 

_m setVariable ["#debug",true]; // Debug mode on

_m setVariable ["#useagents",true];
_m setVariable ["#usepanicmode",false];

_m setVariable ["#unitcount",10];

 

You need "marker_0" and "marker_1" on the map for this to work. Don't place them too near player it maybe that the civilians wont spawn then.

 

No need for sync.

 

  • Like 3
  • Thanks 1

Share this post


Link to post
Share on other sites

Fixed bug in _m setVariable ["#area"

should now be in proper format

  • Thanks 1

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

×