Jump to content

Recommended Posts

Posted
Is it possible for DCS a-10c to query a DB OR read/write a file?

Yes. But what exactly do you mean by DB? I know you mean database, but WHAT PROGRAM'S database, containing what data, and what do you want to do with it?

 

Or otherwise function as a campaign/save persistent data in MP?

 

Like the first question, more information would be appreciated. Are you asking if it is possible for DCS to save the values of flags, or unit positions? Yes. You can even save the position of every single bullet, bomb or missile. Or are you asking if it is possible to generate a mission based off of this data? That answer to that is yes- you just have to code the program that does it first.

Intelligent discourse can only begin with the honest admission of your own fallibility.

Member of the Virtual Tactical Air Group: http://vtacticalairgroup.com/

Lua scripts and mods:

MIssion Scripting Tools (Mist): http://forums.eagle.ru/showthread.php?t=98616

Slmod version 7.0 for DCS: World: http://forums.eagle.ru/showthread.php?t=80979

Now includes remote server administration tools for kicking, banning, loading missions, etc.

Posted (edited)

I would like to make a persistent MP campaign. My concept is:

 

1. Mission generates text file/injects database with text

2. Mission #2 reads file, looks for certain strings, then configures the mission according to the input

3. Mission #2 overwrites/adds onto the file, etc for mission #3 to read

 

 

Does DCS a-10 have:

1. A function to query a database of any sort

2. A function to open or write files

3. String search functions, functions to select/sort/interpret arrays etc

4. Conditions of presence for units and triggers?

Edited by tyrspawn
Posted (edited)

1. A function to query a database of any sort

2. A function to open or write files

3. String search functions, functions to select/sort/interpret arrays etc

4. Conditions of presence for units and triggers?

 

1) As of right now, there are three primary resources of data that I know of:

a) The "export" Lua environment:

For all active world objects, you can get their position, names, types, etc. from the export Lua environment function, LoGetWorldObjects. A modder can use that function, along with others, as one of the primary resources for current world data (I believe this is how things like Trackview work). See C:\Program Files\Eagle Dynamics\DCS A-10C\Config\Export\Export.lua. The file is its own readme.

 

2) The "server" Lua environment:

Some data as a group's current waypoint, can be gleaned from the "server" environment functions such as Group.getPoint, or the damage state of units can be obtained with the Unit.getLife function (Unit.getLife0 returns the unit's initial life). Though, getting the damage states of units may be a little pointless in the application you are thinking of, because as far as I know, it is not possible to generate a damaged unit at mission start.

 

3) The "mission" Lua environment:

In the mission Lua environment you can access useful things such as the "mission" table (which basically is the mission file as created by the mission editor). There is also the "db" table, which is the database of units. I recently discovered (if I remember correctly) that runtime IDs can also be found in the mission environment, which was a huge bonus. The status of flags can be found in the mission environment as well, using the same Lua functions that the game uses to evaluate the "flag is true" trigger conditions. I don't believe there is a flag table, however, I really think you have to go through the functions.

 

Anyway, as of right now, a multi-environment approach I believe must be coded from the net environment, as that has the only function that I know of to send and receive data to and from the various Lua environments, net.dostring_in. Also, I believe this means that a multi-environment approach may be impossible for single player.

 

ANYWAY, in the interest of modders, I actually implemented two data export functions in Slmod, the multi-environment .\Scripts\net\server.lua Lua mod I am working on. If you install it, (see my signature for the link), and change line 7 from:

 

export_world_objs = false

 

to:

 

export_world_objs = true

 

then it will output a list of the current world objects (including guided weapons) to Saved Games\DCS Warthog\Logs\active_units.txt every six or so seconds. Keep in mind the format of this file is subject to change, unless someone actually starts using it, at which point the format will begin to be put into a lock down. Its current format is just that of a serialized Lua table. Here's a sample:

 

   [16876033] = 
   {
       ["id"] = 16876033,
       ["coalition"] = "blue",
       ["x"] = -284654.5625,
       ["name"] = "kut 1 23",
       ["z"] = 684412.3125,
       ["objtype"] = "M1045 HMMWV TOW",
       ["group"] = "blue_Kutasi_defence",
       ["mpname"] = "kut 1 23",
       ["y"] = 45,
   }, -- end of [16876033]
   [16870657] = 
   {
       ["id"] = 16870657,
       ["coalition"] = "blue",
       ["x"] = -285468.84375,
       ["name"] = "kut 1 2",
       ["z"] = 681826.5625,
       ["objtype"] = "M163 Vulcan",
       ["group"] = "blue_Kutasi_defence",
       ["mpname"] = "kut 1 2",
       ["y"] = 45,
   }, -- end of [16870657]
   [16884225] = 
   {
       ["id"] = 16884225,
       ["coalition"] = "blue",
       ["x"] = -322872.05278526,
       ["name"] = "Pontiac_1_AIR",
       ["z"] = 624679.62903404,
       ["objtype"] = "A-10C",
       ["group"] = "Pontiac 1, Air start, primary",
       ["mpname"] = "16th Speed",
       ["y"] = 252.14927835046,
   }, -- end of [16884225]

and so on...

 

Anyway, line 10 controls a similar feature, intended to help provide a fix for events-analyzer mods that were broken with patch 1.1.0.8 (such as Moa's stats mod), you can output all the events that have most recently occurred within your mission.

 

Anyway, your stated aim of trying to recreate a mission from some kind of saved data is not unique among modders. I know a few modders (myself included) who would like to do that too, we just have other things we also want to do and don't have infinite time to do so.

 

Anyway, you will fail to perfectly recreate a mission due to a few things, such as:

Inability to fully duplicate a flag, since a flag consists of not only a value, but of a time that the flag was last set, and there is no way that I know of to edit that time;

Inability to spawn damaged units;

Inability to create weapons already in flight at mission start;

Inability to re-create an AI's current state.

You'd probably have to blow up any map objects that had died with an explosion;

and I could probably list more things that I don't think will perfectly copy over. However, you can re-create a mission PRETTY CLOSELY, and you can certainly generate a whole new mission based off of the results of the last, as many of the above problems dissappear if your goal is instead a series of dynamically linked missions rather than saving and re-creating.

 

 

ANYWAY,

 

2) A function to open or write files? Certainly. Just not in the mission or mission scripting environments, which are secure environments. Keep in mind, ED did something with their code post-1.1.0.8, which made it so that file appending does not work... hence the reason that your debrief.log is not written until the mission is over (otherwise, you would pause constantly as it was updated). Look at the Lua manual, better yet, if you are really that interested, buy the Lua manual so you can have a copy to hold in your hands (baryons are always better than leptons :) )

 

3) String search functions, functions to select/sort/interpret arrays etc? Yes, the standard Lua 5.1 string manipulation library, see the Lua manual. For sorting and array manipulation, if you do it in Lua, you use tables.

 

4) Conditions of presence for units and triggers? The mission, export and server and server environments, as already mentioned, can give you pretty much anything you need to know.

 

Anyway, by all means, if you are interested in this, you probably want to start exploring the game's Lua environment yourself. I have scratched pretty deeply into the surface, but there's still a lot for me to learn. Some of what I said above could in fact be wrong.

Edited by Speed

Intelligent discourse can only begin with the honest admission of your own fallibility.

Member of the Virtual Tactical Air Group: http://vtacticalairgroup.com/

Lua scripts and mods:

MIssion Scripting Tools (Mist): http://forums.eagle.ru/showthread.php?t=98616

Slmod version 7.0 for DCS: World: http://forums.eagle.ru/showthread.php?t=80979

Now includes remote server administration tools for kicking, banning, loading missions, etc.

Posted

Speed, I should have just read this thread before I dug that old one. This is exactly what I am looking for.

 

I would not be looking to recreate a full on mission, not trying to recreate a full-on Falcon DC. Gotta walk before we run, right? Really I would like to be able to some very simple 'checks' in a mission to see if certain units/groups were destroyed in previous missions before activating them -- eg, a SAM site was taken out in a previous mission, so I'd not want it showing up again in the very next mission.

 

Ripcord

[sIGPIC]sigpic65507_1.gif[/sIGPIC]

Posted

OK so, my original question as applied to an actual mission I am working on:

 

1. I want to have a persistent OOB throughout a campaign, hopefully in multiplayer

2. My idea would be ot have a myCampaign.txt file which the host has

3. Mission #1 goes, then at the end checks to see if certain units are alive, then outputs variables plt1dead = true, plt2dead = true to the txt file

4. Mission #2 opens and reads myCampaign.txt and then has triggers/conditions for units to be deleted

 

Is any/all of that possible?

 

Also is there an index of all DCS a-10 functions anywhere?

Posted

Sorry man, didn't mean to hijack the thread. I am also watching this discussion to see what I can learn. Very much thinking along the same lines.

 

Ripcord

[sIGPIC]sigpic65507_1.gif[/sIGPIC]

Posted

Speed, do you know if the larger virtual squadrons use any type of mod to track mission stats during multiplayer missions? Is there any way to capture each pilots events (kills, losses, flight time) for each multiplayer mission, and then save that data so it can be used for statistics?

 

Do you know how the larger virtual squardons keep track of their pilots in order to award rank or rep?

 

Thanks in advance for your help.

Z

Posted (edited)
OK so, my original question as applied to an actual mission I am working on:

 

1. I want to have a persistent OOB throughout a campaign, hopefully in multiplayer

2. My idea would be ot have a myCampaign.txt file which the host has

3. Mission #1 goes, then at the end checks to see if certain units are alive, then outputs variables plt1dead = true, plt2dead = true to the txt file

4. Mission #2 opens and reads myCampaign.txt and then has triggers/conditions for units to be deleted

 

Is any/all of that possible?

 

Yes, it all is. The main obstacle is the mission generator, the code that builds the next .miz file. That is very achievable, but just will take some work.

 

Also is there an index of all DCS a-10 functions anywhere?

 

I began a scripting guide back in 1.1.0.8. I abandoned work on it after the 1.1.0.9 patch drastically changed how mission scripts operate. I will attach it to this post... be advised, some of it is out of date. However, it gives an overview of many of the functions available in the "server" (also known as "main") environment.

 

However, there are four other readily accessible environments. The "net", "export", "mission", and "config" environments:

 

-The best document for programming Lua in the "net" environment is the readme.txt in the ./Scripts/net folder.

 

-If you open the file ./Config/Export/Export.lua with Notepad++, so long as you haven't modified it at least, then Export.lua is it's own readme file- nice job with the comments there, ED :)

 

- The mission environment has access to pretty much all of the functions that make triggers work. It also has access to the database of units in the current mission.

 

- The server environment is the main game environment, but it lacks many things that us modders want to do (the export, mission, and net environments fill in many of these gaps). See the .doc I am attaching for a very rough and unpolished guide on the functions in the server environment.

 

- The config environment.... not sure how that is useful yet.

 

The final Lua environment that I know of is the mission scripting environment. It is excessively isolated from the rest of the Lua environments- to much so, IMO. net.dostring_in cannot address it. Its only path of data in would be dofile, and its only path of data out (after modification with Slmod!) is slmod.print- which simply outputs data to dcs.log. However, I have yet to do a _G dump of the mission scripting environment post 1.1.1.0.

 

The glue that holds everything together is the net.dostring_in function. Download Slmod Beta 5.2 (see my sig) if you want to see LOTS of examples of how to use net.dostring_in. Furthermore, you will see how I use net.dostring_in to branch out from the net environment, sending data, receiving data and running Lua code in the mission, server, and export environments (hence why I chose a tree as the symbol for Slmod).

 

Your final tool is a _G dump. Lua stores all global variables in a table called _G. There are various ways of viewing the contents of _G. So dumping the contents of _G will tell you the names of all the global variables- including all the global functions of course. Figuring out what the proper input variables are for those functions- that's where the fun begins. Many of them are pretty obvious, but some are a lot harder to figure out.

Edited by Speed

Intelligent discourse can only begin with the honest admission of your own fallibility.

Member of the Virtual Tactical Air Group: http://vtacticalairgroup.com/

Lua scripts and mods:

MIssion Scripting Tools (Mist): http://forums.eagle.ru/showthread.php?t=98616

Slmod version 7.0 for DCS: World: http://forums.eagle.ru/showthread.php?t=80979

Now includes remote server administration tools for kicking, banning, loading missions, etc.

Posted
Speed, do you know if the larger virtual squadrons use any type of mod to track mission stats during multiplayer missions? Is there any way to capture each pilots events (kills, losses, flight time) for each multiplayer mission, and then save that data so it can be used for statistics?

 

Do you know how the larger virtual squardons keep track of their pilots in order to award rank or rep?

 

Thanks in advance for your help.

Z

 

I know that Moa from the 104th wrote a stats mod that does this. However, it was broken with the 1.1.0.8 patch. I am working with him to try to fix it. So yea, you can capture pilot events quite easily. In the mod I made, Slmod, I put a global variable right at the beginning, that if you set to true, will output the latest events to a file in your Saved Games/Logs folder (assuming you are the multiplayer host). Have an external program read that file, and that is how you can track stats.

  • Like 1

Intelligent discourse can only begin with the honest admission of your own fallibility.

Member of the Virtual Tactical Air Group: http://vtacticalairgroup.com/

Lua scripts and mods:

MIssion Scripting Tools (Mist): http://forums.eagle.ru/showthread.php?t=98616

Slmod version 7.0 for DCS: World: http://forums.eagle.ru/showthread.php?t=80979

Now includes remote server administration tools for kicking, banning, loading missions, etc.

Posted

Yeah, thanks to all Speed's work getting information out of Lua by various cunning means I hope to support stats for the A-10C and Ka-50 once more.

 

You can see the pilot stats for multiple servers at:

http://stallturn.com/104th/

 

Note: currently the free Java browser plugin is required, get it from http://www.java.com but I'm thinking of switching the stats back to a Google Web Toolkit app (it was originally) rather than the Java applet.

Posted
In the mod I made, Slmod, I put a global variable right at the beginning, that if you set to true, will output the latest events to a file in your Saved Games/Logs folder (assuming you are the multiplayer host). Have an external program read that file, and that is how you can track stats.

 

 

@Speed, I looked at your slmod but could you please advise on what variable I set to output the events to a file???

 

Thanks again. Sorry to bother you with this. I did look at your guide and your other posts but cannot figure it out.

Posted
@Speed, I looked at your slmod but could you please advise on what variable I set to output the events to a file???

 

Thanks again. Sorry to bother you with this. I did look at your guide and your other posts but cannot figure it out.

 

The guide is the functions "quick reference" guide, and I have not completed the full guide yet, so I don't mention this feature in quick reference guide. Look at lines 10 & 12:

--Set to true to output the latest events to the file "slmod_events.txt" in \Saved Games\DCS Warthog\Logs
events_output = false
-- if the above variable was true, then this variable controls how often the latest events are output
events_out_intv = 5

 

Set the first variable there from false to true, and you can optionally set the events_out_intv to a number different than 5 to make the events output more or less often. Be advised, if no events have happened since the last set events was output, the file will be empty when you look at it. To test it, jump into a plane as a multiplayer host, shoot some guns in little bursts for like 10 seconds, then immediately exit and check the slmod_events.txt file in your Saved Games/<BS2/A-10>/Logs folder.

Intelligent discourse can only begin with the honest admission of your own fallibility.

Member of the Virtual Tactical Air Group: http://vtacticalairgroup.com/

Lua scripts and mods:

MIssion Scripting Tools (Mist): http://forums.eagle.ru/showthread.php?t=98616

Slmod version 7.0 for DCS: World: http://forums.eagle.ru/showthread.php?t=80979

Now includes remote server administration tools for kicking, banning, loading missions, etc.

  • Recently Browsing   0 members

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