Jump to content

[ANN] Web-based Lua debug console for DCS: World missions


FSFIan

Recommended Posts

Update: I will no longer maintain this project; if you came here for the Lua Console, check out DCS-BIOS, which includes a Lua Console starting with release 0.8.0 and is a lot easier to set up.

 

Links: Witchcraft on GitHub | Tutorial video

 

"DCS Witchcraft" is the working title of my latest project. The idea is to establish a communications channel (line-delimited JSON over a TCP connection) from a running DCS: World mission to the outside world (a node.js server process) and explore the new possibilities that open up.

 

While I still don't know where this project will lead me and most of it has not even left the planning stage yet (and possibly never will), it has already produced one useable result: a debug console for Lua scripts.

 

The debug console allows you to execute arbitrary snippets of Lua code in a running mission and look at the return values. I hope this will speed up the development and debugging of custom Lua scripts and make it more fun to do. You can also use it to inspect and change flags, so it can help you with debugging even if you stick to the predefined triggers.

 

For setup instructions, see the repository on GitHub. (Use the "Download ZIP" button on the right)

To get an impression of what you can do with it before installing, see the screenshot on GitHub Pages.

 

I'd appreciate it if the first person who tries to get it working would post the result here so I know whether the installation instructions are understandable and complete.

 

If you get it working, have fun playing around with it and try to avoid infinite loops ;)


Edited by [FSF]Ian
  • Like 1
Link to comment
Share on other sites

I have just pushed a new experiment. The "Lua Interaction" map mode will call lua functions on map events. See the new snippet template in the Lua Console for details.

 

The new template lets you interactively place HMMWVs into the running mission. You too can be the owner of your very own HMMWV Archway!

 

hmmwv_arch_small.png

Link to comment
Share on other sites

I think they already implemented your template into bridges on one of the last patches...

 

Too bad there's no Unit:setPosition(), or we could just make bridges teleport the stupid AI from one side to the other... but are you saying there was a version of DCS where the AI could actually manage to negotiate a bridge?

Link to comment
Share on other sites

Wait ... are ... are you saying, this is the first step for an "interactive, in-game Mission Editor"? Like, interactive placing/moving objects and units? Add some sort of export functionality so that the result can be saved and then imported into the regular mission?

 

And when you are already working on it ... isn't this the basis for a "Dynamic Campaign" system? Like ... the mission designer prepares several "mission modules" (i.e. partial missions with units that do some stuff) that then will be imported dynamically based on rules and triggers that your server keeps an eye on?

Link to comment
Share on other sites

Wait ... are ... are you saying, this is the first step for an "interactive, in-game Mission Editor"? Like, interactive placing/moving objects and units? Add some sort of export functionality so that the result can be saved and then imported into the regular mission?

 

And when you are already working on it ... isn't this the basis for a "Dynamic Campaign" system? Like ... the mission designer prepares several "mission modules" (i.e. partial missions with units that do some stuff) that then will be imported dynamically based on rules and triggers that your server keeps an eye on?

 

Yes, both of those things would be possible to implement. All the building blocks are out there somewhere.

 

Here are some thoughts on this off the top of my head:

1) Such a project requires time and effort. If even half of the ideas in the following list are to be implemented, we will need to have several people working on this.

 

2) We need to identify what features are worth implementing. I have no experience making missions, so I would need mission makers to tell me what the biggest annoyances are and we'd need to think about possible solutions together.

 

The overall goal would be to increase the number of high-quality missions both by making new things possible and by making things that are currently possible easier to do.

 

3) Some things the witchcraft platform lets you do that you cannot do in the stock Lua environment:

- add your own user interface

- perform calculations outside of DCS: World (i.e. without blocking the simulation)

- easily communicate with external programs that can be written in another language (e.g. building line-of-sight calculations in a C++ program)

 

4) A first step for a replacement mission editor might be to use an existing mission as a template for everything that is not implemented (i.e. weather settings, warehouses, etc) and focus on editing groups, units and scripts. We may be able to ignore the built-in trigger system almost entirely as long as we replace it with a great scripting system.

 

We could also eliminate some hacks that are currently used in scripts, such as defining a polygon by placing a dummy unit -- a "replacement" mission editor could offer a feature to draw a polygon on the map that would be available as a global variable from mission scripts.

 

5) Things like routes should become first-class objects. I should be able to edit a route and then assign it to multiple units or reference it from a script.

 

6) If it is considered part of the design from the beginning of the project, it should be possible to make this a multiplayer mission editor, i.e. allow multiple people to edit the same mission at once.

 

7) Entirely different project 1: Re-implement the "F10 map view part" of Combined Arms, i.e. enable RTS-style "drag a box and right-click" movement controls

 

8) Entirely different project 2: Add web-based user interfaces to things like troop transport scripts so you can load any unit into any viable transport and nothing is pre-determined by pre-placed trigger zones.

Link to comment
Share on other sites

Some awesome ideas ...

 

I think, the "Dynamic Mission" idea is a bigger project. A lot of potential possibilities, but also a lot of work ...

 

But for mission designers, already a huge step forward would be to have the ability to place and rotate units interactively. Placing units so that they are not blocked by buildings, or just are neatly aligned (making a FARP or some other sort of base) is a PITA.

 

The mission would be created as usual in the ME, including all the stuff that is available already (stock tools like triggers, lua scripts, etc.). But instead of the very time consuming cycle of

 

  1. start mission
  2. watch units
  3. end mission
  4. adjust a few units in the ME
  5. go back to 1

it would be immensely helpful if this fine tuning could be done interactively directly in the game.

 

 

 

For example:

Select a single unit, perform "move 10 meters forward", perform "turn 45 deg. right"

or select a group of units, "align all units right, 90 deg.", "set spacing 10 meters"

 

 

Then these changes need somehow to get back into the original mission file. (exporting the relevant data in a .MIZ file compatible way should not be too difficult.)

Link to comment
Share on other sites

I think what ENO meant is that there's a bug where units get stuck at bridges and pile up.

 

Ian, will this be merged with the mission planner you made?

I think it's a good idea to make it as a multiplayer editor.

 

We've been using the planner with the save mission script to run big scale campaigns, right now there's a limitation with CA moving units, it creates lag and therefore creates a problem to run big scale missions, one solution is to use scripted waypoints or AI, if using your new console can create such options it would solve some of these issues.

 

Also, this will allow us to have real time updates to our server website, as discussed on the other thread you started, using cache would be beneficial.

Link to comment
Share on other sites

Some awesome ideas ...

But for mission designers, already a huge step forward would be to have the ability to place and rotate units interactively.

 

I have pushed a new version to GitHub that has something like this.

 

1. Set up your mission to load MIST and start witchcraft, then run it

2. Move your units to the desired positions. You can either do this using Combined Arms when the unit can be player-driven, or...

2a. in the Lua Console, execute the "move units (Lua Interaction)" template

2b. select "Lua Interaction" mode on the map

2c. click a unit to start moving, rotate using mousewheel, click again to stop moving

3. Select "Save Unit Positions" in the map, select your original .miz file, click "save as", click download link under the button

 

 

Ian, will this be merged with the mission planner you made?

I think it's a good idea to make it as a multiplayer editor.

 

It will not be merged into the mission planner because it is built on top of different JS libraries (Mission Planner: jQuery and OpenLayers 2, witchcraft: (jQuery), angular.js, OpenLayers 3 Beta), but I expect that it will at some point grow to the point that it includes all the features found in the mission planner.

Link to comment
Share on other sites

Ian;2108874']I have pushed a new version to GitHub that has something like this.

 

1. Set up your mission to load MIST and start witchcraft, then run it

2. Move your units to the desired positions. You can either do this using Combined Arms when the unit can be player-driven, or...

2a. in the Lua Console, execute the "move units (Lua Interaction)" template

2b. select "Lua Interaction" mode on the map

2c. click a unit to start moving, rotate using mousewheel, click again to stop moving

3. Select "Save Unit Positions" in the map, select your original .miz file, click "save as", click download link under the button

 

 

 

 

It will not be merged into the mission planner because it is built on top of different JS libraries (Mission Planner: jQuery and OpenLayers 2, witchcraft: (jQuery), angular.js, OpenLayers 3 Beta), but I expect that it will at some point grow to the point that it includes all the features found in the mission planner.

This is awesome!

 

I must admit, I struggled a bit until I understood the concept of the template/script that has to be executed first before I could use the functionality on the map display. But then I was able to place and align units easily.

 

I encountered some quirks, though:

1. when viewing a unit in-game (F7 view on the unit's group or as ground commander in one of the units) and I selected an (other) unit of that group with the "UnitMover", the in-game view was reset and I could not actually see what I was doing. This is probably due the script setting the unit to invisible or something like that while being under "UnitMover"-control? Is there a chance to prevent that from happening?

But in any case, even if this is not possible, it already saves one a lot of time going back and forth between ME and game...

 

2. the DCS.log is spammed with

00477.331 INFO    SCRIPTING: mist.scheduleFunction, error in scheduled function: [string "T:\temp\DCS.openbeta\/~mis00003D88"]:4241: Object doesn't exist
00477.509 INFO    SCRIPTING: witchcraft read error: timeout

I could not yet narrow down when these are occuring. Just a random thought: what happens if I execute, i.e. the UnitMover script several times ... what happens with the event handlers? Can this cause the log messages somehow (i.e. "zombie" event handlers that still react somehow, but don't see on what they should act on?)

 

3. In the map view only blue units are updated. Red units are not displayed at all.

 

And a question: what is the "Ping" function supposed to do on the map view? :o)

Link to comment
Share on other sites

1. when viewing a unit in-game (F7 view on the unit's group or as ground commander in one of the units) and I selected an (other) unit of that group with the "UnitMover", the in-game view was reset and I could not actually see what I was doing.

That's because to move a single unit, we have to respawn the whole group. Just make sure that you are not viewing the group of the unit you are moving.

(You can use the "spawn HMMWV" template to make a "spotter unit" if you want to.)

 

2. the DCS.log is spammed with

00477.331 INFO    SCRIPTING: mist.scheduleFunction, error in scheduled function: [string "T:\temp\DCS.openbeta\/~mis00003D88"]:4241: Object doesn't exist
00477.509 INFO    SCRIPTING: witchcraft read error: timeout

I could not yet narrow down when these are occuring. Just a random thought: what happens if I execute, i.e. the UnitMover script several times ... what happens with the event handlers? Can this cause the log messages somehow (i.e. "zombie" event handlers that still react somehow, but don't see on what they should act on?)

I'll have to look into that. There are no "zombie" event handlers; the event handlers are simply stored in global variables, so they are replaced every time you re-execute the block. It's probably something with the way I establish and maintain the TCP connection.

 

 

3. In the map view only blue units are updated. Red units are not displayed at all.

The map is currently hard-coded to only display blue units, but that can be easily changed.

 

And a question: what is the "Ping" function supposed to do on the map view? :o)

You can use that if multiple people are looking at the map to point a location out to each other.

Link to comment
Share on other sites

One other thought ... I haven't tried it, yet, but which units are written to the mission file when performing "Save Unit Positions" on the map view? All units or only those I touched with the UnitMover (or other "Lua Interaction"?)?

 

It would probably desirable to only write back units that were "interacted with". As the mission has to be running to use i.e. the UnitMover, it will have units that were already following their respective routes and doing their tasks and stuff. If those were also saved back to the mission file, it would probably mess up things big time?

Link to comment
Share on other sites

Doing some tests seems to be working nicely.

1. Why do I only see one coalition units on the map after enabling the units (BLUE)?

Is it controlable per link as in the planner? Can we do it to work by country?

2. when there are 2 users, it is very slow and hard to control.

3. Creating units or moving units are shown in the map, I suggest changing that they will be moved only whne clicked in the map and not following the cursor.

4. Allowing movement of ground units only on land, airplane/helicopter units everywhere with respect to available altitude, ship in sea areas.

5. Will it be possible to have a loadout screen?

6. Show Trigger Zones?

7. Now, the big question, can we spawn units that are 'Client' available? like creating slots? and then removing slots?

This will allow us to create flights like in Falcon BMS.

 

 

 

Another question -

To go even further to a campaign like in Falcon, we need resources, which we already have in the DCS ME that we can set.

How about a script for automatic ground warfare?

 

I'm working currently on something as follows -

Resources:

1. Each side has several facilities (Army,Factories,Radars).

2. Each facility has resource warehouses.

3. Each relevant warehouse is linked to the close facility warehouse

(fuel to fuel, weapons to weapons etc...)

 

Automatic Commander System (ACS)

Setting:

1. Attacking - 50% of the coalition units are advancing towards the

closes enemy facility.

2. Defending - 100% of the coalition units are holding positions.

3. Consolidating - 100% of all units are holding positions until the

ACS system has a new Setting.

 

Facility Balance: (Starting values depends on number of facilities, Default 200)

1. Army - Between x2-x5 value.

2. Factories - Between x2-x5 value.

3. Radars - x1 value. (Has a value also by not detecting incoming units).

 

Morale: (Starting value is 0, morale will have positive or negative effect)

1. Plane lost - -1

2. Plane destroyed - +1

3. Building destroyed - +5

4. Building lost - -2

5. Building repaired - +2 (Facility buildings will repair/respawn

after 2 hours).

6. Vehicle lost - -1

7. Vehicle destroyed - +1

8. Vehicle repaired - +1 (Engineering groups will go through the map

and reach locations of destroyed vehicles, after 2 hours in the area

the tank would respawn at the nearest Army facility, these groups are

not subdue to the ACS setting).

 

ACS Setting -

Attacking: Coaltion(Morale + Facility Balance) > Coaltion(Morale +

Facility Balance)

Defending: Coaltion(Morale + Facility Balance) < Coaltion(Morale +

Facility Balance)

Consolidating: Coaltion(Morale + Facility Balance) ~= Coaltion(Morale +

Facility Balance)


Edited by xcom
Link to comment
Share on other sites

Doing some tests seems to be working nicely.

1. Why do I only see one coalition units on the map after enabling the units (BLUE)?

Is it controlable per link as in the planner? Can we do it to work by country?

2. when there are 2 users, it is very slow and hard to control.

3. Creating units or moving units are shown in the map, I suggest changing that they will be moved only whne clicked in the map and not following the cursor.

4. Allowing movement of ground units only on land, airplane/helicopter units everywhere with respect to available altitude, ship in sea areas.

5. Will it be possible to have a loadout screen?

6. Show Trigger Zones?

7. Now, the big question, can we spawn units that are 'Client' available? like creating slots? and then removing slots?

This will allow us to create flights like in Falcon BMS.

 

 

1. The map is hard-coded to only display blue units right now (holdover from a previous experiment). We'll have to think about what the visibility rules should be and then implement that.

2. In its current state, a lot of the parts are not intended to be used by more than one person simultaneously.

3. The idea is to interactively fine-tune unit positions, you need them to follow the cursor for that. You should be able to change the code of the "move units" template to do what you want, though.

4. Possible to implement, but waaay down there on the priority list, i.e. won't fix for now

5. I think its possible to implement, but it would require extracting a database of the possible loadout combinations.

6. The map can be made to show just about anything.

7. Unfortunately, this is impossible. You cannot do any changes to client aircraft while the mission is running, because the clients do not expect that. IIRC if you try to deactivate a "Client" group the game just crashes and the closest you can come to shut down a player slot is immediately killing anyone who enters it. (EDIT: deactivating works, unless you deactivate a previously deactivated slot when a player has clicked on the slot but has not clicked "fly" yet -- then it crashes my game).

More importantly, you cannot add new slots at runtime or change the waypoints of existing ones (I ran into this problem when developing the mission planner).

 

Any change to "Client" units would require you to save and restart the mission.

 

 

 

Another question -

To go even further to a campaign like in Falcon, we need resources, which we already have in the DCS ME that we can set.

How about a script for automatic ground warfare?

 

 

Yes, we need that and it is a worthwhile project because improving upon the current AI is definitely possible.

 

The following limitations come to mind:

- No way to set the remaining ammo of a unit from Lua

- No way to set warehouse contents from Lua (that I know of)

 

I'm working currently on something as follows -

Resources:

1. Each side has several facilities (Army,Factories,Radars).

2. Each facility has resource warehouses.

3. Each relevant warehouse is linked to the close facility warehouse

(fuel to fuel, weapons to weapons etc...)

 

Automatic Commander System (ACS)

Setting:

1. Attacking - 50% of the coalition units are advancing towards the

closes enemy facility.

2. Defending - 100% of the coalition units are holding positions.

3. Consolidating - 100% of all units are holding positions until the

ACS system has a new Setting.

 

Facility Balance: (Starting values depends on number of facilities, Default 200)

1. Army - Between x2-x5 value.

2. Factories - Between x2-x5 value.

3. Radars - x1 value. (Has a value also by not detecting incoming units).

 

Morale: (Starting value is 0, morale will have positive or negative effect)

1. Plane lost - -1

2. Plane destroyed - +1

3. Building destroyed - +5

4. Building lost - -2

5. Building repaired - +2 (Facility buildings will repair/respawn

after 2 hours).

6. Vehicle lost - -1

7. Vehicle destroyed - +1

8. Vehicle repaired - +1 (Engineering groups will go through the map

and reach locations of destroyed vehicles, after 2 hours in the area

the tank would respawn at the nearest Army facility, these groups are

not subdue to the ACS setting).

 

ACS Setting -

Attacking: Coaltion(Morale + Facility Balance) > Coaltion(Morale +

Facility Balance)

Defending: Coaltion(Morale + Facility Balance) < Coaltion(Morale +

Facility Balance)

Consolidating: Coaltion(Morale + Facility Balance) ~= Coaltion(Morale +

Facility Balance)

 

DotA: DCS Edition, anyone? Although you probably couldn't spawn the creeps as fast as the A-10s and Ka-50s could kill them.

 

I'd like to have some sort of ground unit AI and combine it with improving the recon aspect of the game so that part of the challenge is finding and then plotting a safe ingress and egress route to your enemy before you even start up your airplane.


Edited by [FSF]Ian
Link to comment
Share on other sites

For ground warfare two possible starting points

http://forums.eagle.ru/showthread.php?t=120195

http://forums.eagle.ru/showthread.php?t=120675

 

Think of IL2 and DCG and how when building a DCG campaign you used to define a road, rail and sea routes system and you will see where these could go. Particularly the first can be used to define a road system from red to blue main objectives. Rail isn't so controllable in DCS but I imagine perhaps sea routes could be created using similar concept scripts.

Link to comment
Share on other sites

For ground warfare two possible starting points

http://forums.eagle.ru/showthread.php?t=120195

http://forums.eagle.ru/showthread.php?t=120675

 

Think of IL2 and DCG and how when building a DCG campaign you used to define a road, rail and sea routes system and you will see where these could go. Particularly the first can be used to define a road system from red to blue main objectives. Rail isn't so controllable in DCS but I imagine perhaps sea routes could be created using similar concept scripts.

 

Thank you for these links, they will come very handy!

I suggest doing a console script with this routes script, it would be nice to have a way in the console to move group of units according to predefined routes, these routes could go between several trigger zone, each one a different facility that holds resources, that way the advancement will be always through the facilities which could trigger capturing the facilities.

Link to comment
Share on other sites

For ground warfare two possible starting points

http://forums.eagle.ru/showthread.php?t=120195

http://forums.eagle.ru/showthread.php?t=120675

 

Think of IL2 and DCG and how when building a DCG campaign you used to define a road, rail and sea routes system and you will see where these could go. Particularly the first can be used to define a road system from red to blue main objectives. Rail isn't so controllable in DCS but I imagine perhaps sea routes could be created using similar concept scripts.

 

That's great stuff! It will come in handy when we implement persistence of mission state.

 

I have never used IL2 or DCG but those sound like concepts worth implementing in an alternate mission editor for power users.

Link to comment
Share on other sites

Just to note that I checked mist.getGroupRoute (which is used by route.lua) and it should work for helos, ships,planes and vehicles I believe - so I think theoretically route.lua could be used to define sea routes, helo resupply routes, cargo and transport aircraft resupply routes as well as vehicle routes.

 

I think I will try to build an example DCG style mission and see how it goes.

Link to comment
Share on other sites

In my opinion, the key element that DCS miss is a Armed Assault style GUI integration for mission designer. In that game, anyone with some scripting knowledge can create an in-game GUI which can be used for various things.

 

18s9lSw.jpg

 

This would unlock a lot of things editor-wise

Link to comment
Share on other sites

While I cannot add to the games own user interface, we may come close by making a simple web UI.

 

The trick will be to associate a browser session to a player somehow. Maybe the web page can display a short code that you have to type into DCS chat or something.

 

If you make the UI simple enough to work in the steam overlay, the player won't neccessarily require a second device (unfortunately, I couldn't get the map to display in the steam overlay). On the other hand, a lot of players will have access to a laptop, second computer, tablet or a wifi-enabled phone.

Link to comment
Share on other sites

Also, a good addition would be to have a voice communication server which gets connected to automatically when you join the server, something like the IVC in Falcon.

But, this is of course, wishful thinking :)

 

It would be possible to do as a client-side mod, but probably not worth the effort for saving the user a few clicks.

Link to comment
Share on other sites

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...