Jump to content
Sign in to follow this  
BL1P

Using condition of presence

Recommended Posts

I would like to create multiple base templates with vehicles and objects set to use a condition of presence that reads a variable from a file in the mission.

The file would select a random preplaced base pos then it will set a variable to true on that pos and false to all other positions.

Is there a way to then set the condition of presence to true based on the created variables using a preprocessFile type thing ?

Thanks.

BL1P

Share this post


Link to post
Share on other sites

You could place an object, like a game logic, and put this in its init line:

call (compile preprocessFileLineNumbers "initPreprocessed.sqf");

Make sure you place this object before anything else in the editor, just to make sure it's called very early. Init lines, condition of presence etc. are executed in the order of mission.sqm. In other words, in the order of placement.

Or, you could use cfgFunctions preInit, in your description.ext:

class cfgFunctions {

class YourFunctions {

	tag = "BL1P";

	class Init {

		class init { file = "initPreprocessed.sqf"; preInit = 1; };

	};

};

};

Both would archive what you're looking for.

More about initialization order here

Share this post


Link to post
Share on other sites

Thanks sxp2high

Trying it with the gamelogic atm.

gamelogic init

call (compile preprocessFileLineNumbers "BL1P_startpos_fnc.sqf");

BL1P_startpos_fnc.sqf

if (!isDedicated) exitwith {diag_log "I am not a dedicated server i was Kicked from BL1P_startpos.sqf"};

diag_log "====----- start of starpos function ----====";

private ["_StartMarkerSelect","_position"];

//--- created a random number from 0 - 3
_StartMarkerSelect = round random 2;
diag_log format["_StartMarkerSelect = %1",_StartMarkerSelect];

//--- set all start variables to false
START0 = false; publicVariable "START0";
START1 = false; publicVariable "START1";
START2 = false; publicVariable "START2";
diag_log format["START0 = %1",START0];
diag_log format["START1 = %1",START1];
diag_log format["START2 = %1",START2];

//--- use the random number to select the marker to use
switch (_StartMarkerSelect) do 
{ 
	case 0: 
	{
		diag_log "case 0 ";
		"respawn_west" setMarkerPosLocal (markerPos "START0");//--- move respawn marker to start marker
		diag_log "respawn is moved";
		_position = getmarkerpos "START0";
		diag_log format ["_position = %1",_position];
		{
		_x setpos _position;
		}foreach playableunits;
		diag_log format ["postion for playableunits moved to %1",_position];
		START0 = true; publicVariable "START0"; //--- set start var as true
	};
	case 1: 
	{
		diag_log "case 1 ";
		"respawn_west" setMarkerPosLocal (markerPos "START1");
		diag_log "respawn is moved";
		_position = getmarkerpos "START1";
		diag_log format ["_position = %1",_position];
		{
		_x setpos _position;
		}foreach playableunits;
		diag_log format ["postion for playableunits moved to %1",_position];
		START1 = true; publicVariable "START1";
	};
	case 2: 
	{
		diag_log "case 2 ";
		"respawn_west" setMarkerPosLocal (markerPos "START2");
		diag_log "respawn is moved";
		_position = getmarkerpos "START2";
		diag_log format ["_position = %1",_position];
		{
		_x setpos _position;
		}foreach playableunits;
		diag_log format ["postion for playableunits moved to %1",_position];
		START2 = true; publicVariable "START2";
	};
};
diag_log "============================";
diag_log format ["START0 = %1",START0];
diag_log format ["START1 = %1",START1];
diag_log format ["START2 = %1",START2];

diag_log "====----- end of starpos function ----====";

3 vehicles

mission.sqm

class Vehicles
{
	items=3;
	class Item0
	{
		presenceCondition="START0";
		position[]={1746.6208,5.5,5784.626};
		id=9;
		side="EMPTY";
		vehicle="B_MRAP_01_F";
		skill=0.60000002;
	};
	class Item1
	{
		presenceCondition="START1";
		position[]={1714.9448,5.5,5656.4395};
		id=10;
		side="EMPTY";
		vehicle="B_MRAP_01_F";
		skill=0.60000002;
	};
	class Item2
	{
		presenceCondition="START2";
		position[]={1671.865,5.5,5509.0483};
		id=11;
		side="EMPTY";
		vehicle="B_MRAP_01_F";
		skill=0.60000002;
	};
};

players get moved to the start pos ok

respawn gets moved

but vehicles are not spawning for some reason ?

Edited by BL1P

Share this post


Link to post
Share on other sites

Sorry, I never worked with condition of presence, I just assumed. Tried it myself, looks like the init line call method is kicking in too late. Conditions of presence seem to be checked very early, even before init lines.

The cfgFunctions method with preInit works though. :)

Share this post


Link to post
Share on other sites
Sorry, I never worked with condition of presence, I just assumed. Tried it myself, looks like the init line call method is kicking in too late. Conditions of presence seem to be checked very early, even before init lines.

The cfgFunctions method with preInit works though. :)

No worries m8 it got me further than I had been without your help :)

Could you give me an example of how the cfgFunctions is used I am unsure on how that works ? or a do this for dummies explanation :)

If not no worries ill do some reading on the biki

Share this post


Link to post
Share on other sites

Dont know if something like this helps you out with what your trying or atleast give you some ideas.

Download

On the runway you will find two bases i have setup. I have saved their setup by using BIS_fnc_objectsGrabber and placed them in the init.sqf as global variables smallOP and largeVehOP.

I have then placed down multiple gamelogics each one setting a variable on its self of the type of base to spawn at that location (ignore the fact the GL's are location gamelogics, i was experimenting to see of they actually report as locations on the map, just a plain old GL will do).

In the center of these you will find a GL that runs a script "RandomBaseStart.sqf".

waitUntil {!isNull player};
bases = synchronizedObjects _this;
rndBase = bases select (floor (random (count bases)));
objects = missionNamespace getVariable	(rndBase getVariable "baseType");
[getPosATL rndBase, getdir rndBase, objects] call Bis_fnc_objectsMapper;
player setpos getpos rndBase;
player setDir getDir rndBase;

This waits until the player is spawned.

Gets all the base GL's synced to it and chooses a random one.

It then gets the "baseType" variable of the selected GL and converts it to the contents of the globals found in init.sqf via missionNamespace.

It then uses objectMapper to spawn the objects at GL's location and rotation.

And finally places the player at the base location and direction.

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  

×