Jump to content
Taylor1984

Add actions for all houses of a specific kind

Recommended Posts

Hi

 

In the map Fallujah 2 there are a lot of houses that you can't enter. However, they often have rooftops with doors leading out to the roof, even if they are just textures.

 

What I want to do is add an action to get in the door on the ground level of the houses and get out of the door on the roof. Unfortunatley there are like a 100 of these houses in this map and I would very much like be able to get on the roof of all of them.

 

Is there a way to check when you are close to a specific kind of house and by getting the direction of said house calculating where the door is, creating an invisible H at the position of the door, adding an action to the H to 'go up to the roof' and then get teleported up to the roof?


I guess this would be a script that continuously checked whether you are close to a house of a certain kind?

 

Thanks

Share this post


Link to post
Share on other sites

You can probably do the first thing you suggested, just use nearestTerrainObjects or nearestBuilding to get the houses and then do the calculation for where to place your object to which you're gonna add the addaction. 

Share this post


Link to post
Share on other sites

Just in order to use this you need to remove from the code :

 

line:100 the "!"

if (!(typeOf _x in _Exclude_Buildings)) then {

 

and this :   ( with the last  "}" of the if below , line :135 )

_buildingPositions = [_x] call BIS_fnc_buildingPositions;
_count = count _buildingPositions;

if (_count > 4) then {

 

So the Exclude list will be actually , the list of the buildings that you want to change.

Share this post


Link to post
Share on other sites

First get the class name of the building you want.

Get closer to the building and execute this code in the debug console:

_nBuilding = nearestBuilding player;
copyToClipBoard str typeOf _nBuilding;

This will copy in the clip board the class name you need.

 

Then in the init.sqf put this code:

if (isServer) then {

  _pos = getArray(configFile >> "CfgWorlds" >> worldName >> "centerPosition");
  _blds = nearestobjects [_pos,["your_Building_class_name"], 20000]; // Put your building class name.
  
  {
  _doorH = "VR_3DSelector_01_complete_F" createVehicle (_x getRelPos [0,0]); // Replace [0,0] by the relative position you want for the door compared to the building.
  _doorH addaction ["your action name", "yourScript.sqf"]; // Configure your addaction as you wish
  } forEach _blds;
  
 };

But i think you can't add an action to an invisible object so i've put an VR object ("VR_3DSelector_01_complete_F") instead.

The only problem is that you will see the VR object at the door.

 

See getRelPos command for the relative position of the door.

  • Like 1

Share this post


Link to post
Share on other sites
7 hours ago, Crazy_Man said:

_blds = nearestobjects [_pos,["your_Building_class_name"], 20000];

 

Hello there Crazy_Man !

 

You can also use "wordsize" instead of "20000" and it is also possible to attach an addaction to a trigger.

  • Thanks 1

Share this post


Link to post
Share on other sites

Wow, you guys are the best. I've tried scripting in Flashpoint and Arma since 2002 but I still get stuck all the time.

 

I'll try to put a script together from what you wrote and then get back to you.

 

Thanks

  • Like 1

Share this post


Link to post
Share on other sites

I started by trying Crazy_Man's script and it worked like a charm. The VR object at the door was a fun touch but since I'm aiming for realism I would need to have something invisible for the 'door' instead. What I usually do when I place an object that when you add an action to doesn't show the action when you look at it (for instance a manhole) is that I instead check the distance between the player and the object and then add the action to the player when the player is like 3 meters away and then remove it when he is farther than 3 meters from the object. I know it's not as good since it's easy to miss the action being added but I don't know any other way.

 

This is however what I had in mind for this script, but I don't really know how to add this feature to Crazy_Man's script even though I'm trying at the moment.

 

Thanks

Share this post


Link to post
Share on other sites

Goofed around a bit and came up with this:

 

//roof access

//initPlayerLocal.sqf

//array structure: [["BuildingClassName",[entryPosition1,entryPosition2,entryPosition3],[roofPosition1,roofPosition2,roofPosition3]]];
//positions need to be in modelspace format
//retrieve positions using:
//cursorObject worldToModelVisual getposatl player

_roofAccess = [["Land_MultistoryBuilding_03_F",[[11.5654,-0.246582,-25.9038],[2.13477,17.0049,-26.0029],[-7.50781,13.2588,-25.9038],[-1.31836,4.89502,-25.9038],[-7.0752,-1.81104,-24.2182],[0.0898438,-13.0679,-25.9038],[11.585,12.7637,-25.9038]],[[-1.01367,11.0376,25.919]]]];

GOM_fnc_buildingTypes = _roofAccess apply {_x#0};
GOM_fnc_entryPositions = _roofAccess apply {_x#1};
GOM_fnc_roofPositions = _roofAccess apply {_x#2};

player setVariable ["GOM_fnc_accessingAllowed",true];

addMissionEventHandler ["Draw3D", {

	if (player distance2d cursorObject < 20 AND {typeOf cursorObject in GOM_fnc_buildingTypes}) then {
		_index = GOM_fnc_buildingTypes find typeOf cursorObject;
		_entryPositions = GOM_fnc_entryPositions # _index;
		_roofPositions = GOM_fnc_roofPositions # _index;
		_checkDistance = 20;
		_lockout = 10;//time needed to pass until roof access can be used again for this player
		_color = [[1,0,0,1],[0,1,0,1]] select (player getVariable ["GOM_fnc_accessingAllowed",false]);


	{
		_pos = cursorObject modelToWorldVisual _x vectorAdd [0,0,1.5];
		drawIcon3D ["", _color, _pos, 0, 0, 0, "Roof Access", 1, 0.05, "PuristaMedium"];

		if (player distance2d _pos < 1 AND vectorMagnitude velocity player < 0.1 AND (player getVariable ["GOM_fnc_accessingAllowed",false])) then {
			player setVariable ["GOM_fnc_accessingAllowed",false];
			player setposASL (cursorObject modelToWorldVisualWorld selectRandom _roofPositions);
			_reset = _lockout spawn {
				sleep _this;
				player setVariable ["GOM_fnc_accessingAllowed",true];
			}

		};

	} forEach (_entryPositions select {!(lineIntersects [eyePos player,(cursorObject modelToWorldVisualWorld _x vectorAdd [0,0,1.5]),player])});

	{
		_pos = cursorObject modelToWorldVisual _x vectorAdd [0,0,1.5];
		drawIcon3D ["", _color, (cursorObject modelToWorldVisual _x vectorAdd [0,0,1.5]), 0, 0, 0, "Ground Access", 1, 0.05, "PuristaMedium"];

		if (player distance2d _pos < 1 AND vectorMagnitude velocity player < 0.1 AND (player getVariable ["GOM_fnc_accessingAllowed",false])) then {
		player setVariable ["GOM_fnc_accessingAllowed",false];
		player setposASL (cursorObject modelToWorldVisualWorld selectRandom _entryPositions);
		_reset = _lockout spawn {
			sleep _this;
			player setVariable ["GOM_fnc_accessingAllowed",true];
		}

		};
	} forEach (_roofPositions select {!(lineIntersects [eyePos player,(cursorObject modelToWorldVisualWorld _x) vectorAdd [0,0,1.5],player])});

	};
}];

This will put you on a random position on the roof when going up, and on a random position on the ground when going down, if multiple positions are available.

Plenty of space to customize it, simply add further building types by using the respective class names and retrieve positions as mentioned in the comments.

 

 

Cheers

  • Like 2
  • Thanks 1

Share this post


Link to post
Share on other sites

I tried it out and it was really cool Grumpy Old Man but can you make it so that addactions appear instead of drawIcon3D so you can choose whether to go up on the roof? That would be good for if you were walking close to the building and just wanted to go past it and not actually access the roof at that point.

Share this post


Link to post
Share on other sites
1 hour ago, Taylor1984 said:

I tried it out and it was really cool Grumpy Old Man but can you make it so that addactions appear instead of drawIcon3D so you can choose whether to go up on the roof? That would be good for if you were walking close to the building and just wanted to go past it and not actually access the roof at that point.

Sure, this will only move you around after using the addAction, which will show up if you're at an access point and standing still:


_roofAccess = [["Land_MultistoryBuilding_03_F",[[11.5654,-0.246582,-25.9038],[2.13477,17.0049,-26.0029],[-7.50781,13.2588,-25.9038],[-1.31836,4.89502,-25.9038],[-7.0752,-1.81104,-24.2182],[0.0898438,-13.0679,-25.9038],[11.585,12.7637,-25.9038]],[[-1.01367,11.0376,25.919]]]];

GOM_fnc_buildingTypes = _roofAccess apply {_x#0};
GOM_fnc_entryPositions = _roofAccess apply {_x#1};
GOM_fnc_roofPositions = _roofAccess apply {_x#2};

player setVariable ["GOM_fnc_accessingAllowed",true];

_ID = player addAction
[
    "Access Roof",
    {
        params ["_target", "_caller", "_actionId", "_arguments"];
        _pos = _target getVariable ["GOM_fnc_position",[]];
        _target setPosASL _pos;
        _target setVariable ["GOM_fnc_position",[]];
			_reset = 10 spawn {
				sleep _this;
				player setVariable ["GOM_fnc_accessingAllowed",true];
		}
    },
    [],
    1.5,
    true,
    true,
    "",
    "_this isEqualTo _target AND !((_target getVariable ['GOM_fnc_position',[]]) isEqualTo [])",
    50,
    false,
    "",
    ""
];

player setVariable ["GOM_fnc_roofAccessActionID",_ID];

addMissionEventHandler ["Draw3D", {

	if (player distance2d cursorObject < 25 AND {typeOf cursorObject in GOM_fnc_buildingTypes}) then {
		_index = GOM_fnc_buildingTypes find typeOf cursorObject;
		_entryPositions = GOM_fnc_entryPositions # _index;
		_roofPositions = GOM_fnc_roofPositions # _index;
		_checkDistance = 20;
		_color = [[1,0,0,1],[0,1,0,1]] select (player getVariable ["GOM_fnc_accessingAllowed",false]);


	{
		_pos = cursorObject modelToWorldVisual _x vectorAdd [0,0,1.5];
		drawIcon3D ["", _color, _pos, 0, 0, 0, "Roof Access", 1, 0.05, "PuristaMedium"];

		if (player distance2d _pos < 1 AND vectorMagnitude velocity player < 0.1 AND (player getVariable ["GOM_fnc_accessingAllowed",false]) AND (player getVariable ["GOM_fnc_position",[]]) isEqualTo []) then {
			player setVariable ["GOM_fnc_position",cursorObject modelToWorldVisualWorld selectRandom _roofPositions];
			player setVariable ["GOM_fnc_accessingAllowed",false];
			player setUserActionText [player getVariable ["GOM_fnc_roofAccessActionID",-1],"Move to roof"];


		};

	} forEach (_entryPositions select {!(lineIntersects [eyePos player,(cursorObject modelToWorldVisualWorld _x vectorAdd [0,0,1.5]),player])});

	{
		_pos = cursorObject modelToWorldVisual _x vectorAdd [0,0,1.5];
		drawIcon3D ["", _color, (cursorObject modelToWorldVisual _x vectorAdd [0,0,1.5]), 0, 0, 0, "Ground Access", 1, 0.05, "PuristaMedium"];

		if (player distance2d _pos < 1 AND vectorMagnitude velocity player < 0.1 AND (player getVariable ["GOM_fnc_accessingAllowed",false]) AND (player getVariable ["GOM_fnc_position",[]]) isEqualTo []) then {
		player setVariable ["GOM_fnc_accessingAllowed",false];
					player setUserActionText [player getVariable ["GOM_fnc_roofAccessActionID",-1],"Move to ground level"];

			player setVariable ["GOM_fnc_position",cursorObject modelToWorldVisualWorld selectRandom _entryPositions];

		};
	} forEach (_roofPositions select {!(lineIntersects [eyePos player,(cursorObject modelToWorldVisualWorld _x) vectorAdd [0,0,1.5],player])});

	};
}];

Cheers

  • Like 2
  • Thanks 1

Share this post


Link to post
Share on other sites

https://steamcommunity.com/sharedfiles/filedetails/?id=708665067

 

 

DES Elevator

Description:

This is a small addon, that allows player to access roof tops and balconies. It is inspiered by Zooloo75's Acces Points script.

Usage:

Just go to a door of the five usable buildings and select "Go to roof" or "Go to balcony", then you will be teleported.

Available buildings:

Tanoa

Land_MultistoryBuilding_01_F
Land_MultistoryBuilding_03_F
Land_MultistoryBuilding_04_F
Land_Shop_City_04_F
Land_Shop_City_05_F
Land_Hotel_02_F
Land_Cathedral_01_F

CUP

Land_OrlHot

Land_Mil_House
Land_Mil_House_dam
Land_A_MunicipalOffice
Land_HouseB_Tenement

Land_Mil_House_EP1
Land_Mil_House_dam_EP1
Land_Dum_istan2_01
Land_Dum_istan2_02
Land_Dum_istan2_03
Land_Dum_istan2_03a
Land_Dum_istan2_04a
Land_Dum_istan3_hromada
Land_Dum_mesto3_istan
Land_Dum_istan4
Land_Dum_istan4_big
Land_Dum_istan4_big_inverse
Land_Dum_istan4_detaily1
Land_Dum_istan4_inverse

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

×