Jump to content

Elevator Script for Players and Vehicles [WIP/Prototype]


Axe Cop

Recommended Posts

I had an idea about doing an elevator script to extend the base building a little or just for some fun with ArmA/Epoch! :D

 

Here is a video of the current prototype: (and don't laugh I got stuck after I fell from the roof  :P)

Just recorded another video to show how to call an elevator, I've placed 4 stops around the house, looks kinda funny yeah :D

If anyone is wondering, I use the preview version of the metal floor to display the stop points of the elevator.. some item has to be present so you can call the elevator there and the positions get saved to the database. This item can be changed in the config but the preview items have no collisions so you can just travel through it and it's easy to see where the elevator can stop.

 

Everything is saved to the database without any need to modify the server files or database structure. It only updates the "CharacterID" field in the "object_data" table like safes or locked door also do in Epoch, I don't want to bore you with the technical details but I encoded the elevator and stop point ID's in an 8 digit long code, always starting with "6976" (that is ASCII code for "EL" :P), the next 3 digits are the elevator ID and the last the elevator stop ID. Meaning you can have up to 10 stops per elevator (0-9) for now. It looks like this (without the "-"), just in case you want to find an elevator in the database or whatever.

ID 8 digits: EL-ID-STID = 6976-###-#

e.g the ID's of an elevator with 2 additional stop points: 69760010 -> 69760011 -> 69760012

 

The elevator can be build similar to the in-place upgrade system from Epoch, so just look at a metal floor (item can also be changed in the config) and you will get an option "Upgrade to Elevator" and "Upgrade to Elevator Stop", the elevator stop can only be build if there is an elevator in range (max. range for the elevator to travel can be changed, default 25m), you have to select an elevator first (the select action will be available if you look at an elevator, also new built elevator are selected by default).

Once you have built an elevator with at least 1 stop point you can just look at it and select "Activate Elevator: Next Stop" or "Activate Elevator: Previous Stop", it will then find and move to the next/previous stop. If there is no stop in range you get a message and nothing happens, the menu could be hidden if there is no next stop for the elevator but in the first version the actions are always shown.

You can also call the elevator at any stop point, it will travel along the way, stopping at every stop point and wait there (default 5 sec. can be changed in the config).

 

Installation and configuration

Ok now to the installation and configuration of the elevator script. The script is only client side, so very easy to add to your mission file!

You can get the current scripts here: https://github.com/vos/dayz/tree/master/elevator just download the whole folder and extract it to your mission file.

To enable the script on your server add this line to your init.sqf at the end of the block "if (!isDedicated) then {" (so just above the next "};" should be fine):

["elevator"] execVM "elevator\elevator_init.sqf";

Assuming your have the elevator folder with the scripts in your mission root, the only parameter of the script "elevator" is the folder relative to your mission file, it's needed to load the other scripts from that folder. You can change it to "scripts\elevator" if your put the elevator-folder there for example.

 

That is all you have to do to install the elevator script on your server, there are some config variables you can change, take a look at the file "elevator_init.sqf" where it says "global variables", you can change the values there, but I would suggest changing it in your init.sqf like the Epoch settings, e.g.:

ELE_MaxRange = 100; // maximum range the elevator can travel / stop points can be built (in meter)
ELE_Speed = 5; // speed of the elevator (meters per second)
ELE_StopWaitTime = 0; // disable the wait time if you call the elevator
...
["elevator"] execVM "elevator\elevator_init.sqf";

Added building requirements and upgrade animation to build the elevator and elevator stops. Default requirements are:

ELE_RequiredBuildTools = ["ItemToolbox", "ItemCrowbar"]; // required tools for building an elevator and elevator stop
ELE_RequiredBuildItems = [["PartGeneric",4], "PartEngine", "ItemGenerator", "ItemJerrycan"]; // required items to build an elevator
ELE_RequiredBuildStopItems = [["PartGeneric",4]]; // required items to build an elevator stop

You will get the default messages from Epoch if you are missing the tools or items.

 

There are no access restrictions yet! Any player can built or use an elevator with this version, so keep that in mind if you want to use it on a live server. I already have some ideas to use the default car keys to use an elevator, that should work.. unless your have some better ideas for access control? :)

 

Just one more thing, as I use the "MetalFloor_Preview_DZ" for the elevator stop by default, if you want to keep it like that you have to add that class to your allowed objects in Epoch, otherwise Epoch will delete it right after you upgrade a metal floor to a stop point. To do that the class needs to be added to the file "dayz_code\init\variables.sqf", at line 466 there is a list "dayz_allowedObjects", just add "MetalFloor_Preview_DZ" to that list and copy the file to your mission folder as usual (the file is referenced in the init.sqf). if you don't want to do that just replace the stop class with this config variable:

ELE_StopClass = "MetalFloor_Preview_DZ";

Replace the classname with whatever you like, I didn't test any other but the elevator will just travel there and you can call the elevator with looking at that object.

 

Remember this is still work in progress, there might be bugs and maybe the elevator ID gets changed so already built elevators might not work after an update, but you can already play around with the script and tell me what you think, Ideas are welcome... :)

Edited by Axe Cop
Link to comment
Share on other sites

I have an idea about building a elevator model that could be used, I recommended to AxeCop that he uses  the "Notebook" (laptop) ingame as a sort of control panel within a elevator build

 

you're contribution to the community surely hasn't gone unnoticed, if anyone deserves recognition for his contributions its you, keep up the good work :)  

Link to comment
Share on other sites

Yeah the elevator itself can be build out of anything in the game, but I don't know about desync or whatever if it will be to complex, so keep it simple at first. :)

The elevator works for everything that will be near the platform, so players + vehicles at least.

It might look weird but objects can't fall through when it's moving (even with heavy desync)..

Link to comment
Share on other sites

After looking at the vid of it mate, personally I LOVE IT, and I know if you can get this either tied to UID or some object that the player/friendly that builds it works for them, then I can see a rash of different bases being made..

Umm maybe like the combo-lock or safe locking technique would work... unsure, I've never really looked into that code....

 

But yeah mate,  your putting some awesome stuff out there atm....NICE WORK.. and I can almost guarrantee that almost all of server admins will want this, or they're player base will be hounding them for it.

 

With what you've done so far, Is it possible for it to go more than 1 storey high, sorta like an express elevator, but with a limit of say 4 or 5 high... I can see some crazy bases getting planned now in my head

 

 

Bags

Link to comment
Share on other sites

Thanks Bags, one of the problems with this is to save the elevator state to the database, maybe I could (mis)use the CharacterID field for that (like safes and doors do it now lol).

My idea was to just do the elevator movement/direction based on the environment, meaning you place a special item at every stop for the elevator, and then get a menu when looking at the item for "move to next/previous stop" (and calling the elevator to that stop if it isn't there) or something like that, the script can find the next stop by itself without saving it to the database. With a solution like that you can make the elevator go where you like in a certain range of course.

For example you set a stop on the ground (where you build the elevator itself) and another 10m away, no matter where it is there should be a direct line of sight of course but other then that it does not matter if it is on top or diagonal or wherever from the first stop you know, the elevator will just travel in that direction. :)

 

Edit: I had a weird idea, maybe it is possible to use the "inventory" field of the database to save the elevator state and owner, etc.. but I have to check if that doesn't interfere with other parts from the Epoch code, but essentially the inventory is not used for building parts.. :P

Edited by Axe Cop
Link to comment
Share on other sites

Maybe it's possible to "attach" the objects together to make it smoother?

In the video above I did attach everything to the plattform, but as you can see the plattform itself looks weird, but the little bird next to the player is perfectly smooth.. maybe I try something else but attaching everything with each other is no solution haha :D

Link to comment
Share on other sites

Hey some updates on my elevator script.

 

I implemented most of the important stuff today, so I might release the first version soon.

The elevator is working and saving "everything" needed to the database (no need to modify the database or the server files, it just uses the CharacterID field with my special encoded stuff you will see lol).

For now you are able to create elevators and my so called stop points with the in-place upgrade option, where the elevator will stop (duh) and can be called from. There ca be up to 9 stop points for each elevator so in total 10 stories high (it just uses 1 digit so might be extened to 100 stories with 2 digits but I guess that's enough for now). You get actions to move to the next or previous stop point if you look at the platform and the elevator can be called from any stop point and travel along all points to where you called it, it can't go straight because the stop points might not be in line, so you can place them all over the place within the max. range beween every point! looks kinda funny if you do that in zig-zag :D

Most settings can be customized with global variables like Epoch itself.

 

Ok now one of the major problems is the animation of the elevator itself, it works like it should be in the direction, speed and whatever I want it to go (after I added all vector calculation in myself..), BUT it's "laggy" at most times, all I do is set the position of the elevator in a specific interval like by default 30 times per second, the script can run much faster of course but should be enough and if I log all values to the arma report file they are all there, BUT the stupid arma engine just displays only every 100th or so, which means the elevator jumps with big steps if the server is running slow or whatever the problem is. I don't know yet if I can fix that, the elevator works most times, but due to the major lag you can fall off and die possibly.. maybe some of you have an idea to do smooth animations with scripts, maybe there is no solution but we will see :)

 

I think I will release the source code tomorrow, so you can see it yourself if you have a test server, I'm going to update my video as well.

Link to comment
Share on other sites

Ok I think I found the "error" why my animation was so choppy.. NEVER try to move base building parts handled by Epoch or the server, I don't know where the problem is since the position changes are not reflected in the database or anything but when I just spawn a new metal floor it works, but using one that is already in the game it is choppy as hell! why? :D

Anyway then I just spawn a new one to be moved around, I had to spawn something there anyway since you have to call the elevator back to its origin, but when there is nothing you can't call it! lol

 

Will release it later totay or tomorrow then. :)

Link to comment
Share on other sites

Works a treat =)

You are fast :D

 

I am looking into other methods of animating the elevator platform, this works good on your local PC, but might look choppy for ther players..

it should still work if there are more players and vehicles on the platform, just looks weird :/

Link to comment
Share on other sites

Yeah as I've said the ArmA engine can't handle script animation that well, it only works smooth on the client who created the elevator (so if it is local to the client because the heavy desync ArmA has all the time).. :/

You notice it already when you a driving around with a car and you are NOT the driver (vehicles are always local to the driver as of the arma wiki, which makes sense).

 

Anyway I was playing around with the camCreate command, but I can't spawn metal floors with that, but it says you can spawn vehicles in with that command,.. that would be a solution but not easy to implement.

Problem with vehicles (or moving metal floors it is the same) is, the position gets synced to all clients, so every player on the server no matter where you are will receive it.. with the camCreate command it stays local only on your client so it could be send to only players in a specified range of the elevator and it would be a smooth animation..

 

Well the wiki for camCreate (http://community.bistudio.com/wiki/camCreate) says "type: String - either "camera", "seagull" or any other class name of OFP vehicles.", maybe it is really only for  OFP vehicles and not ArmA or DayZ vehicles but that makes no sense to me.. :D to bad there are these restriction with ArmA scriping.

Link to comment
Share on other sites

Please sign in to comment

You will be able to leave a comment after signing in



Sign In Now
×
×
  • Create New...