Jump to content
Sign in to follow this  
panther42

Building/House Door animation function

Recommended Posts

I was messing around trying to come up with something in response to this thread:

selecting building doors for animation

I've created a small function, which will return the following for buildings/houses, etc with animated doors:

Display Name - from cfg

Position - from config(this is the selectionPosition used on the building to place the "open door" action and animation

Statement - proper commands to open/close doors on building

I would like to expand this, if there is interest. I would like to add the building positions(easy enough, I was going to use the CBA function, but thought I would not require it right away). I also want to add the actual positions of the doors in world coordinates. Ran into a snag there, have another thread started regarding that.

The function can be called in a script, or trigger like I have in the demo. Or any other creative way you see fit.

Required to pass to the function is:

Position/Object - if you change what I have in the trigger, you may need to comment out:

_nBuilding = nearestBuilding _position;
diag_log format["nearestBuilding: %1", _nBuilding];
_houses = position _position nearobjects ["house",_radius];
diag_log format["nearObjects: %1", _houses];

Radius

Right now, I have most of the returns spitting out code to the log(diag_log). I run LogExpert(which is great by the way), and use it while I work in windowed mode.

Any building which does not have animated doors will spit out in a silent hint.

Okay, on with the code:

init.sqf

FindDoors = compile (preprocessFileLineNumbers "scripts\fn_findBuildingDoors.sqf");

fn_findBuildingDoors.sqf

// Find the selectionPosition of working doors on buildings
// return the activation statement
// version 1.0 by panther42 - November 2012

private["_position", "_radius", "_DoorArray", "_ActArray", "_GarbageArray", "_bldgsFound", "_i", "_bldg", "_cfgBldg", "_animated", "_act", "_cfgDisplay", "_cfgPosition"];

_position = _this select 0;
_radius = _this select 1;
_DoorArray = [];
_ActArray = [];
_GarbageArray = [];

_bldgsFound = (nearestObjects [_position, ["Building"], _radius]);

//next two are for comparison purposes.../////////////////////
diag_log format["nearestObjects: %1", _bldgsFound];
_nBuilding = nearestBuilding _position;
diag_log format["nearestBuilding: %1", _nBuilding];
_houses = position _position nearobjects ["house",_radius];
diag_log format["nearObjects: %1", _houses];
///////////////////////////////////////////////////////////

for "_i" from 0 to ((Count _bldgsFound) - 1) do 
{
	_bldg = typeOf (_bldgsFound select _i);
	_cfgBldg = (configFile >> "cfgVehicles" >> _bldg );
	_animated = getNumber (_cfgBldg >> "animated"); //tried using this to sort, but found out some buildings with animated doors do not have this config entry!
	_act = (_cfgBldg >> "UserActions");

		if (count _act > 0) then
		{
			private ["_j"];
			for "_j" from 0 to ((Count _act) - 1) do
			{
				_cfgDisplay = getText (_act select _j >> "displayName");
				_cfgPosition = getText (_act select _j >> "position");
				_cfgStatement = getText (_act select _j >> "statement");
				_ActArray set [_j,[_cfgDisplay,_cfgPosition,_cfgStatement]];
				_DoorArray set [_i,[_bldg,_ActArray]];
			};	
		}
		Else
		{
		_GarbageArray set [count _GarbageArray,_bldg];
		_DoorArray set [_i,_bldg];
		};

};
hintSilent format["Sorry, no animated doors found for: %1", _GarbageArray];
diag_log format ["%1", _GarbageArray];
_DoorArray = _DoorArray - _GarbageArray;
diag_log format ["%1", _DoorArray];
// return	
_DoorArray

And the demo mission...very simple, radius is set to 25m, and activate using Radio Alpha

p42_bldgDoor.Takistan

If you see something which can/could be made better, feel free to edit, but please share with the rest of us.:)

Let me know what you think.

thanks

panther42

By the way, the output looks like this:

"[["Land_House_L_3_EP1",[["Open door","osa Door_1","this animate ["Dvere1", 0]"],["Close door","osa Door_1","this animate ["Dvere1", 1]"],["Open door","osa Door_2","this animate ["Dvere2", 0];this animate ["Dvere3", 0]"],["Close door","osa Door_2","this animate ["Dvere2", 1];this animate ["Dvere3", 1]"]]]]"

Edited by panther42

Share this post


Link to post
Share on other sites

Most walls/gates are of type house, I believe. You will need to utilize the "house" search, and change up the function. Right now it is using "Building". I can edit later when at home, so it includes a switch...

I don't know if Mondkalb has made an animation for this one, if it's from MBG buildings...

Share this post


Link to post
Share on other sites

Yea right it is form MGB. I try to change it up. Thanks for your answer ;)

E://

Okay i'm a noob :D Think i do something wrong. I wait until you are at home :>

Edited by DeadalusHD

Share this post


Link to post
Share on other sites

If you run the function as is, do you get anything to print out in your log for:

diag_log format["nearestObjects: %1", _bldgsFound];

diag_log format["nearestBuilding: %1", _nBuilding];

diag_log format["nearObjects: %1", _houses];

Share this post


Link to post
Share on other sites

DeadalusHD, this is what I got:

"[["MBG_Cinderwall_5_Gate_InEditor",[["Open Gate","Gate_AP","this animate ["Gate_L",1];this animate ["Gate_R",1];[this, 'Gate_AP', 'MBG_SndSrc_GateOpen',2.5] execvm 'MBG_Killhouses\s\MPSoundV2.sqf';"],["Close Gate","Gate_AP","this animate ["Gate_L",0];this animate ["Gate_R",0];[this, 'Gate_AP', 'MBG_SndSrc_GateClose',6] execvm 'MBG_Killhouses\s\MPSoundV2.sqf';"]]]]"

No changes to the code, it was output to the log file

Just name your gate, for example gate1.

Make a trigger with the following, and place on top of gate:

axis a 5, axis b 5

Blufor Repeatedly - (or change to your side)

Present

Condition: this

On Act: gate1 animate ["Gate_L",1]; gate1 animate ["Gate_R",1];

On Dea: gate1 animate ["Gate_L",0]; gate1 animate ["Gate_R",0];

Edited by panther42

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  

×