Jump to content
Sign in to follow this  
TedHo

[RELEASE] Zeus Editor, Streamlined (ZES) [v0.2]

Recommended Posts

Zeus Editor, Streamlined (ZES)

Zeus Editor, Streamlined (ZES) is a short script that allows you to place/adjust objects in the Zeus editor, and then selectively export objects to SQF code by hitting [Ctrl+C].

I built this thing to help myself build forts/bunkers/camps in-game and quickly export them to clipboard. I never intended to use it to build full missions - some things are just easier via scripting. I thought this might be helpful to other mission builders and so decided to share it. If people actually do find this useful I might consider including more functions. If you are having issues getting it to work I'll be more than happy to help out.

What ZES does:

  • Export objects selected in the Zeus interface to SQF code.
  • Offers streamlined key-binds within the Zeus interface.
  • [Ctrl+C] Export objects selected in the Zeus interface (either by clicking on an object or dragging the mouse cursor to select multiple objects).
  • [Ctrl+A] Export all Zeus-editable objects to clipboard.
  • [Ctrl+Shift+E] Make nearby objects editable by Zeus.
  • [Ctrl+S]/[Ctrl+Shift+S] Toggle simulation ON/OFF for selected objects.

Currently only supports object/unit classnames, position, direction (vectorDirAndUp), and enableSimulation true/false. Does

Future plans:

  • [Ctrl+Z]/[Ctrl+Y] - Undo/Redo. Not sure if there is any performance-friendly way to do this. But it would be extremely helpful.
  • Support for markers and waypoints.
  • More info for objects/units. Stance/Animation state, behaviour, combat mode...

If people actually find this

How to use:

1. Set up a basic zeus mission. Place a Zeus module in your editor. Name the module ZE_Zeus, make sure player has access to it.

2. Run the following code either via execVM or spawn. (Though I recommend putting it in a .sqf file and execVM it in "init.sqf")

//NOTE: Make sure Zeus module is named ZE_Zeus


//Export function
ZE_ExportEntities = {

ZE_ObjectsExport = [];
_mode = toLower (_this select 0);

//Register objects to export
switch (_mode) do {
	case "all": {
		{
			_obj = _x;
			_class = typeOf _obj;
			_pos = getPosATL _obj;
			_vec = [vectorDir _obj, vectorUp _obj];
			_sim = simulationEnabled _obj;
			_grp = group _obj;
			_pack = [_class,_pos,_vec,_sim,_grp];
			ZE_ObjectsExport = ZE_ObjectsExport + [_pack];
		} forEach (curatorEditableObjects ZE_Zeus);
	};

	case "sel": {
		{
			_obj = _x;
			if (typeName _obj == typeName objNull) Then {
				_class = typeOf _obj;
				_pos = getPosATL _obj;
				_vec = [vectorDir _obj, vectorUp _obj];
				_sim = simulationEnabled _obj;
				_grp = group _obj;
				_pack = [_class,_pos,_vec,_sim,_grp];
				ZE_ObjectsExport = ZE_ObjectsExport + [_pack];
			};
		} forEach (curatorSelected select 0);
	};
};

//Compile
_compiledTxt = "//Exported with ZE";

{
	private ["_addTxt","_codeSpawn"];
	_objArr = _x;
	_class 	= _objArr select 0;
	_pos 	= _objArr select 1;
	_vec 	= _objArr select 2;
	_sim 	= _objArr select 3;
	_grp 	= _objArr select 4;
	if (isNull _grp) Then {
		_codeSpawn = format ["
_object = createVehicle [""%1"", [0,0,0], [], 0, ""CAN_COLLIDE""];",_class];
	} else {
		_side = side _grp;
		_codeSpawn = format ["
_object = createGroup %2 createUnit [""%1"", [0,0,0], [], 0, ""NONE""];",_class,_side];
	};

	if (_sim) Then {
		_addTxt = _codeSpawn + format ["
_object setPosATL %2;
_object setVectorDirAndUp %3;
", _class, _pos, _vec];
	} else {
		_addTxt = _codeSpawn + format ["
_object enableSimulation %4;
_object setPosATL %2;
_object setVectorDirAndUp %3;
", _class, _pos, _vec, _sim];
	};


	_compiledTxt = _compiledTxt + _addTxt;
} forEach ZE_ObjectsExport;

copyToClipboard _compiledTxt;

};

//Enable editing function
ZE_AddCuratorObjects = {
_nearObjs = (getPos curatorCamera) nearObjects 25;
ZE_Zeus addCuratorEditableObjects [_nearObjs,false];
};

//Handle Object simulation
ZE_ObjectSimulation = {
_mode = toLower (_this select 0);
switch (_mode) do {
	case "enable": {
		{_x enableSimulation true} forEach (curatorSelected select 0);
	};
	case "disable": {
		{_x enableSimulation false} forEach (curatorSelected select 0);
	};
};
};


//Key Stroke Handler
key_ctrl = 29;
key_shift = 42;
key_c = 46;
key_a = 30;
key_e = 18;
key_s = 31;

pressed_ctrl = false;
pressed_shift = false;
pressed_c = false;
pressed_a = false;
pressed_e = false;
pressed_s = false;

//Add Keystroke EH
ZE_AddKeyStrokeEH = {
ZE_keyDownEHId = findDisplay 312 displayAddEventHandler ["KeyDown",{
	if (_this select 1 == key_ctrl) then {pressed_ctrl = true;};
	if (_this select 1 == key_shift) then {pressed_shift = true;};
	if (_this select 1 == key_c) then {pressed_c = true;};
	if (_this select 1 == key_a) then {pressed_a = true;};
	if (_this select 1 == key_e) then {pressed_e = true;};
	if (_this select 1 == key_s) then {pressed_s = true;};
}];
ZE_keyUpEHId = findDisplay 312 displayAddEventHandler ["KeyUp",{
	if (_this select 1 == key_ctrl) then {pressed_ctrl = false;};
	if (_this select 1 == key_shift) then {pressed_shift = false;};
	if (_this select 1 == key_c) then {pressed_c = false;};
	if (_this select 1 == key_a) then {pressed_a = false;};
	if (_this select 1 == key_e) then {pressed_e = false;};
	if (_this select 1 == key_s) then {pressed_s = false;};
}];

["ZE_KeyStroke", "onEachFrame", {
	if (pressed_ctrl && pressed_a) ExitWith {
		["ALL"] call ZE_ExportEntities;
		hint "";
		["CuratorAddAddons",["ZEUS objects copied to clipboard."]] calL BIS_fnc_showNotification;
		pressed_a = false;
	};
	if (pressed_ctrl && pressed_c) ExitWith {
		["SEL"] call ZE_ExportEntities;
		["CuratorAddAddons",["SELETED objects copied to clipboard."]] calL BIS_fnc_showNotification;
		pressed_c = false;
	};
	if (pressed_ctrl && pressed_shift && pressed_e) ExitWith {
		[] call ZE_AddCuratorObjects;
		["CuratorAddAddons",["Nearby objects ENABLED for Zeus."]] calL BIS_fnc_showNotification;
		pressed_e = false;
	};
	if (pressed_ctrl && pressed_shift && pressed_s) ExitWith {
		["DISABLE"] call ZE_ObjectSimulation;
		["CuratorAddAddons",["DISABLED simulation for selected objects."]] calL BIS_fnc_showNotification;
		pressed_s = false;
	};
	if (pressed_ctrl && pressed_s) ExitWith {
		["ENABLE"] call ZE_ObjectSimulation;
		["CuratorAddAddons",["ENABLED simulation for selected objects."]] calL BIS_fnc_showNotification;
		pressed_s = false;
	};
}] call BIS_fnc_addStackedEventHandler;

};

//Remove Keystroke EH
ZE_RemoveKeyStrokeEH = {
findDisplay 312 displayRemoveEventHandler ["KeyDown",ZE_keyDownEHId];
findDisplay 312 displayRemoveEventHandler ["KeyUp",ZE_keyUpEHId];

["ZE_KeyStroke", "onEachFrame"] call BIS_fnc_removeStackedEventHandler;
};



//Handle enable/disable of EH on Zeus start/end
[] spawn {
while {true} do {
	waitUntil {sleep 0.1; !(isNull findDisplay 312)};
	[] spawn ZE_AddKeyStrokeEH;
	waitUntil {sleep 0.1; isNull findDisplay 312};
	[] spawn ZE_RemoveKeyStrokeEH;
};
};

3. Enter Zeus interface ([Y]) and build your fortress.

4. Select the objects you want to export, then hit [Ctrl+C].

5. Paste the exported script to a .sqf file. Done!

Update Log:

v0.2

  • Initial release. Pretty decent for object placement.

This work was inspired by austin_medic's Zeus Mission Builder, which does a wonderful job of exporting Zeus-created missions to SQM code.

  • Like 1
  • Thanks 1

Share this post


Link to post
Share on other sites
Guest

Release frontpaged on the Armaholic homepage.

================================================

We have also "connected" these pages to your account on Armaholic.

This means soon you will be able to maintain these pages yourself if you wish to do so. Once this new feature is ready we will contact you about it and explain how things work and what options you have.

When you have any questions already feel free to PM or email me!

Share this post


Link to post
Share on other sites

Any chance to make this type of export?

"dp_smallfactory_f";219335.296876;16534.994141;29.000477;0.000000;0.055953;1.000000;-0.000109;

"cmp_shed_f";219313.781250;16537.443360;31.977783;0.000000;0.096913;1.000001;-0.000273;

It is used by TerrainBuilder for importing objects to a new map in the making. I would really appreciate it.

Share this post


Link to post
Share on other sites
Any chance to make this type of export?

"dp_smallfactory_f";219335.296876;16534.994141;29.000477;0.000000;0.055953;1.000000;-0.000109;

Sure thing. Let me see what I can do.


It is definitely doable but could you explain what these numbers are?

If I guessed right, "dp_smallfactory_f" is the model name minus the ".p3d" at the end, "219335.296876;16534.994141;29.000477;" is posASL, I'm not sure what "0.000000;0.055953;1.000000;-0.000109;" means.

---------- Post added at 04:48 ---------- Previous post was at 02:53 ----------

Thank you Foxhound! Much appreciated.

Edited by ted_hou

Share this post


Link to post
Share on other sites
Does this also include existing Buildings ?

Don't think it can include buildings that are preplaced (though in theory he could rig it with nearestObjects probably)

Share this post


Link to post
Share on other sites
Does this also include existing Buildings ?
Don't think it can include buildings that are preplaced (though in theory he could rig it with nearestObjects probably)

I may be wrong about this but I don't think you can edit terrain objects with Zeus. nearestObjects will return their ID but you can't make them editable by Zeus. At the very best you could spawn a copy of the building though I'm not sure what good that will do. I've no experience with terrain editing so I'm afraid I won't be able to do much.

Amazing script. Thanks!

Great! Glad you found it useful!

Share this post


Link to post
Share on other sites

This script is awesome.

One thing, I don't know If I missed something, but being zeus, I execute the script created by the clipboard. And Objects are not editable by zeus

Command used to create clipboard : execvm "zes.sqf";

Command used to execute the new script : execvm "test.sqf";

when the script test.sqf is created, it looks like this :

_object = createVehicle ["Land_Factory_Hopper_F", [0,0,0], [], 0, "CAN_COLLIDE"];
_object setPosATL [13327.2,970.097,-3.8147e-006];
_object setVectorDirAndUp [[0.999848,-0.0174523,0],[0,0,1]];

But by simply adding a line like this :

ZE_zeus addCuratorEditableObjects [[_object],true ];

The said object become avalaible after the exec of the created script (execvm "test.sqf"; )

and it seems to work for all of the created objects. (I did not tried it on dedicated, yet)

I saw about the [Ctrl+Shift+E] Make nearby objects editable by Zeus. but I plan to use the script for an "entire" map, and 25m wide is clearly not enough =)

NOTE : The thing to not forget is that if the zeus module could be named ze_zeus in mission editor while creating the clipboard fortress, in my missions, this is NOT the name of my Zeus(es) so, it has to be a var_ in the begin of the script where the MM has to specify the real NAME of the Zeus.

example of the begining of the clipboardscript :

//Exported with ZE

////Define the name of the Zeus Module here
_zeus = myZeus; //change *myZeus* By the NAME of your Zeus module

///Beginning of the paste script
_object = createVehicle ["Land_Factory_Hopper_F", [0,0,0], [], 0, "CAN_COLLIDE"];
_object setPosATL [13327.2,970.097,-3.8147e-006];
_object setVectorDirAndUp [[0.999848,-0.0174523,0],[0,0,1]];
_zeus addCuratorEditableObjects [[_object],true ];

.....

What do you think about this ?

It may be interesting to add it while compiling the clipboard ?

---------- Post added at 14:54 ---------- Previous post was at 14:52 ----------

PS : I tried to directly put the code :

_object = createVehicle ["Land_Factory_Hopper_F", [0,0,0], [], 0, "CAN_COLLIDE"];
_object setPosATL [13327.2,970.097,-3.8147e-006];
_object setVectorDirAndUp [[0.999848,-0.0174523,0],[0,0,1]];

In the debug console of the game menu, and it works like a charm, really usefull to generate fortress on the fly, on a "non-scripted" Zeus Mission ;)

Share this post


Link to post
Share on other sites

Hey Keewa,

Thanks for these great feedback. Good idea about allowing users to change zeus module name. It would be easy to increase the effect radius of "making nearby objects editable", or simply make all objects editable. I might also try to make the radius dependent on camera height.

Anyway thanks for the input. And happy fortress building!

Share this post


Link to post
Share on other sites

Hm... when I try to export everything nothing happens. Nothing is inside the clipboard.

I installed it as described, no mod is running.

Share this post


Link to post
Share on other sites
Hm... when I try to export everything nothing happens. Nothing is inside the clipboard.

I installed it as described, no mod is running.

Essential steps:

1. name your zeus module ZE_zeus

2. execute initZE.sqf

When you hit Ctrl+C in ZGM interface you should see a notification saying "selected objects exported" etc.

If that still doesn't work, post your mission files and I'll take a quick look.

Share this post


Link to post
Share on other sites

I think this doesn't work anymore on 1.58. The dialogs on screen about copying work but when I go to notepad or notepad++ to paste nothing was every copied so it's blank. Would love it if this was fixed. Mission is A3wasteland v1.2 dev.

Share this post


Link to post
Share on other sites

I think this doesn't work anymore on 1.58. The dialogs on screen about copying work but when I go to notepad or notepad++ to paste nothing was every copied so it's blank. Would love it if this was fixed. Mission is A3wasteland v1.2 dev.

 

I'm sorry to hear that but now that 3DEN has come out I don't think this will be useful anymore.

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  

×