Jump to content
Sign in to follow this  
Charles Darwin

Working LHD Elevator

Recommended Posts

create a mission and place a game logic on the map named "LHD_Center" then place an object on the right elevator you want to control the up down motion I used a folding table..name this control

in the init of control place this:

this setposASL [getposASL this select 0, getposASL this select 1, 15.3]; this enableSimulation False;

then place these files into your mission folder

init.sqf

Creates the LHD and names the elevator as elev also adds action to the object that will control the elevator

if (isServer) then {
_LHDspawnpoint = [getPosASL LHD_Center select 0, getPosASL LHD_Center select 1, -.43];
{
	_dummy = createVehicle [_x, _LHDspawnpoint, [], 0, "NONE"];
	_dummy setdir (getdir LHD_center);
	_dummy setPos _LHDspawnpoint;
} foreach ["Land_LHD_house_1","Land_LHD_house_2","Land_LHD_1","Land_LHD_2","Land_LHD_3","Land_LHD_4","Land_LHD_5","Land_LHD_6"];
elev = createvehicle ["Land_LHD_elev_R", _LHDspawnpoint, [], 0, "NONE"];
elev setdir (getdir LHD_center);
elev setPos _LHDspawnpoint;
};

act = control addAction ["Lower Elevator", "elevdown.sqf",elev,7,TRUE];
sleep 5;

elevdown.sqf

sends the elevator down to 2 meters below waterline..this allows LAV to get onboard

_object = _this select 0;
_obx = (getposasl _object select 0);
_oby = (getposasl _object select 1);
_caller = _this select 1;
_id = _this select 2;
_elev = _this select 3;

if (isServer) then 
{
_object removeaction _id;
_height = (getposASL _elev select 2);
while {_height > -17}
	do {
 _elev setposASL [getposasl _elev select 0, getposASL _elev select 1, ((getposasl _elev select 2) -.015)];
//	 _object setposASL [_obx, _oby, ((getposasl _object select 2) -.015)];
 _height = (getposASL _elev select 2);
 sleep .01;
};
act = _object addAction ["Raise Elevator", "elevup.sqf",elev,7,TRUE];
};

elevup.sqf

_object = _this select 0;
_obx = (getposasl _object select 0);
_oby = (getposasl _object select 1);
_caller = _this select 1;
_id = _this select 2;
_elev = _this select 3;

if (isServer) then 
{

_object removeaction _id;
_height = (getposASL _elev select 2);
while {_height < -.3548}
	do {
 _elev setposASL [getposasl _elev select 0, getposASL _elev select 1, ((getposasl _elev select 2) +.015)];
//	  _object setposASL [_obx, _oby, ((getposasl _object select 2) +.015)];
 _height = (getposASL _elev select 2);
 sleep .01;
};
act = control addAction ["Lower Elevator", "elevdown.sqf",elev,7,TRUE];
};

any questions just ask! :)

right now this only works when vehicles have a player in them..I will work on correcting this but for now just consider as a way to help encourage teamwork :)

Edited by Charles Darwin

Share this post


Link to post
Share on other sites



Slightly Modified Version of the above, I moved the control box off the lift and onto the catwalk to permit the use of the lift with out having to worry about being on the lift as this caused problems when infantry began to swim as the lift was moving up arma would detect the collision and kill the player who activated the lift.

Share this post


Link to post
Share on other sites

This is a great script, you can do so much with it, I'm surprised BI didn't add this feature with the game!

Oh, and can you post the new code? I would love to make this work without dying :D

Share this post


Link to post
Share on other sites
This is a great script, you can do so much with it, I'm surprised BI didn't add this feature with the game!

Oh, and can you post the new code? I would love to make this work without dying :D

Thanks for the kind words guys :D

the code in the first post is actually correct all I did was disable to control object being moved down with the elevator. In the movie I used a power generator (empty -> Objects -> Power generator) with these coordinates:

position[]={15017.712,14.180637,-54.900513};

and in it's init

[getposASL this select 0, getposASL this select 1, 14]; this enableSimulation false;

I am still working on it to improve it. Right now there must be a unit in the vehicle or else it doesnt move with the elevator. Possible remedy is to check if vehicle is empty and if it is create a unit and then delete it when the elevator stops but still working on it so we'llsee :)

---------- Post added at 03:10 AM ---------- Previous post was at 01:46 AM ----------

Hmm.just realized for some reason moving the LHD a new position messes up the setposasl/getposasl? It seems to be related to the elevation of the sea floor under the LHD marker but shouldn't it measure from the Sea Level?:confused:

Share this post


Link to post
Share on other sites

does the elevator actually go to the water? I thought it just went to the hanger deck. Very interesting job though. Keep it up. How bout making the tail plank open. I think it has one doesnt it?

Share this post


Link to post
Share on other sites

In real life no the elevator doesnt go to the water only to the hangar deck..however in real life vehicles can get to the water line via the LCAC bay which is not in arma unfortunately, I'd much rather have an LCAC and an LCAC bay but such is life..or such is arma anyway lol

---------- Post added at 05:57 AM ---------- Previous post was at 04:52 AM ----------

elevdown.sqf

//****************************** Define Stuff*******************//;

// This is the controlling object that will have the action attached to it;
_object = _this select 0;
_obx = (getposasl _object select 0);
_oby = (getposasl _object select 1);

// This is the Unit Activating the Action;
_caller = _this select 1;

//ID of the action so we can remove it;
_id = _this select 2;

//Name of the elevator object defined in the init;
_elev = _this select 3;

// Trigger that checks for vehichles so we can give them a nudge down.;
_trig = list elev_trig;


// ***************************Actual Script Stuff here*******************//;

// Check if server;
if (isServer) then 
{
// Remove the Action that was called;
_object removeaction _id;
// Check Initial height of the elevator;
_height = (getposASL _elev select 2);
//Hint for testing Purposes;
hint format ["%1 %2", (list elev_trig select 0),(list elev_trig select 1)];
//Nudge any vehicles down so they don't get stuck in mid air
{_x setposASL [getposASL _x select 0, getposASL _x select 1,((getposASL _x select 2)-.015)];
 			} foreach _trig;	
// Move the Elevator;
while {_height > -17.1}
	do {
 _elev setposASL [getposasl _elev select 0, getposASL _elev select 1, ((getposasl _elev select 2) -.015)];
// Activate the line below this if you want your control object to move down with the elevator;
//	 _object setposASL [_obx, _oby, ((getposasl _object select 2) -.015)];

//Checks the height of the elevator again so the script knows when to stop.;
 _height = (getposASL _elev select 2);
 sleep .01;
};
// Add the Action to raise the elevator.;
act = _object addAction ["Raise Elevator", "elevup.sqf",elev,7,TRUE];
};

Added something to nudge vehicles as they go down since before they would hang in mid air when the elevator started to go down. recorded a new video showing both this new feature as well as some of the limitations of the system inherent from the model BIS made. The video is incoming uploading to youtube now(need to record in something other than AVI i guess lol)

Share this post


Link to post
Share on other sites

Surprised as hell that it works even that well ....... it certainly never used to.

Well done!

Share this post


Link to post
Share on other sites

EDIT:

For some reason the youtube video editor put the end of the video at the beginning, so the first bit youll see should be at the end of the video lol

Video is processing so if it says it is unavailable at first just wait a few minutes and try again.

In the video first you'll see that it works with vehicles both with AI OR Player in them as well as with no AI or player. Then I show how there is an invisible floor that extends over the elevator on the carrier deck model that will interfere with vehicles both going down and coming up, but so far it appears more a cosmetic annoyance than a real problem, just don't put too many vehicles on the elevator it may push some of them off the back side as it goes up, and be careful with how you park vehicles when going down. The floor extends to where the carrier deck would be if the elevator was not there.

Gnat what did it used to do?

Edited by Charles Darwin

Share this post


Link to post
Share on other sites

Very nice indeed, thanks for sharing CD!

/KC

Share this post


Link to post
Share on other sites

NP happy it is being received so well :) Still wondering though if anyone knows why moving the LHD_Center would mess up the setposASL and getposASL (seemingly based on the terrain under the water on the chernarussian map) it would be a great help I don't deal with getposASL very much so I am not familiar with why it would be doing this.

Share this post


Link to post
Share on other sites

my guess is that is was planned for the LHD to have an open flight deck and LCAC bay but time/money constraints got the upper hand.there is a modeled LCAC bay but the rear doors don't open and there is no way down to the bay from inside the ship. The only reason this is possible is because the elevator is modeled as a separate piece from the rest of the flight deck so I can move w/o moving the other unfortunately it's not possible with out making a new model, to add this to the lcac bay doors

Share this post


Link to post
Share on other sites

Is there any way that we can modify how far down the elevator goes? For example, I'd like to spawn some helicopters or harriers at the height of the hangar bay and then have the elevator raise back to deck level to allow for moving the helicopter/harrier to a take-off section.

Share this post


Link to post
Share on other sites
Is there any way that we can modify how far down the elevator goes? For example, I'd like to spawn some helicopters or harriers at the height of the hangar bay and then have the elevator raise back to deck level to allow for moving the helicopter/harrier to a take-off section.

absolutely, its a really easy task to set the height just change the -17.1 in red to what ever height you like. In my mission -.345 is the default "up" height ASL of the elevator and that number is in the same location but in the elevup.sqf, though from testing it seems that the set/getposASL is not functioning correctly so you may have to fiddle with the exact height to get it right. I my testing the hangar bay was around -10 i beleive.

//****************************** Define Stuff*******************//;

// This is the controlling object that will have the action attached to it;
_object = _this select 0;
_obx = (getposasl _object select 0);
_oby = (getposasl _object select 1);

// This is the Unit Activating the Action;
_caller = _this select 1;

//ID of the action so we can remove it;
_id = _this select 2;

//Name of the elevator object defined in the init;
_elev = _this select 3;

// Trigger that checks for vehichles so we can give them a nudge down.;
_trig = list elev_trig;


// ***************************Actual Script Stuff here*******************//;

// Check if server;
if (isServer) then 
{
// Remove the Action that was called;
_object removeaction _id;
// Check Initial height of the elevator;
_height = (getposASL _elev select 2);
//Hint for testing Purposes;
hint format ["%1 %2", (list elev_trig select 0),(list elev_trig select 1)];
//Nudge any vehicles down so they don't get stuck in mid air
{_x setposASL [getposASL _x select 0, getposASL _x select 1,((getposASL _x select 2)-.015)];
 			} foreach _trig;	
// Move the Elevator;
[color="#FF0000"]while {_height > -17.1}[/color]
	do {
 _elev setposASL [getposasl _elev select 0, getposASL _elev select 1, ((getposasl _elev select 2) -.015)];
// Activate the line below this if you want your control object to move down with the elevator;
//	 _object setposASL [_obx, _oby, ((getposasl _object select 2) -.015)];

//Checks the height of the elevator again so the script knows when to stop.;
 _height = (getposASL _elev select 2);
 sleep .01;
};
// Add the Action to raise the elevator.;
act = _object addAction ["Raise Elevator", "elevup.sqf",elev,7,TRUE];

Share this post


Link to post
Share on other sites

Woohooo! I'm honored I have found a lot of really cool scripts on armaholic and I am glad I can contribute too :D

Also not to be a nag, especially since it's due to my not being very clear in my last posts, but the issue with the vehicles not moving with out AI or player in them has been fixed, but you'll need to add a trigger over the LHD elevator area and name it elev_trig. I would suggest adding a limitation describing that there is an invisible floor on the flight deck that will interfere with vehicle's when they go down or come up as shown in video

Sorry there hasn't been any improvements I work week on week off so in a few days there should be some improvements. My next goal is to automate trigger and control creation basing their positions off the LHD_center object.

Againa very honored to be frontpaged! :D

Edited by Charles Darwin

Share this post


Link to post
Share on other sites

Do you mind dropping in a working demo mission? I tried it out briefly and got "any any" in the hint when trying to lower the elevator? Haven't had time to look into it further...

/KC

Share this post


Link to post
Share on other sites

Will do! it should be a lot easier to get it working after I finish making the code self supporting by having the trigger and the control object created alongside the LHD based on the position of the LHD_center

Share this post


Link to post
Share on other sites

NP :)

As I said I am working on making it more self contained, IE the script will spawn eveything it needs based off the location and position of the LHD_center logic.

in that effort I am trying to add the actions to a spawned power generator. then attach the generator the LHD_Center at the appropriate offset, unfortunately I have hit a bit of a head scratcher.

If the control object is in mission(ie placed in editor) it works fine..if i have the script spawn it, the action isn't added:

//	control = createvehicle ["POWERgenerator", getmarkerpos "test" , [], 0, "NONE"];
control setdir (getdir LHD_center);
act = control addAction ["Lower Elevator", "elevdown.sqf",elev,7,TRUE];
control attachto [LHD_center,[18.5547,-81.7495,14.7249]];
control enablesimulation false;

any ideas?

EDIT__________________

Ok it DOES add the action but only after about 10 seconds:confused:

Edited by Charles Darwin

Share this post


Link to post
Share on other sites

Question... how do I get this to work on a dedicated server.. I can get it to work when testing locally but will not work at all on a dedicated server... I changed the isServer to isDedicated and still not working... what can I do to fix this? spent all day making changes to my map with an LHD and was quite happy with the results until now since it will not lower or raise... everything seems to be in order and as stated, it works flawlessly on my local machine testing.

-Raptor

Share this post


Link to post
Share on other sites

[/color]hmm it was working when i tested it on dedicated, I have to get to bed but Ill do some testing tomorow and see

Edited by Charles Darwin

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  

×