Jump to content

PYL2 GB MiMec could make your life easier


c6_lefuneste
 Share

Recommended Posts

What is Pyl2GB MiMec ?

Python Il2 Great Battle Mission Mechanic is a python library to automatize some painfull processes in IL2 GB mission creation.

The IL2 mission editor is powerfull, but the mechanics of mission involve creation of lot of "MCU" and link (target, object, OnReports, OnEvents,...) between objects that make things quite complicated, especially if you want to modify/update mission.

The group feature is powerfull but may be also cumbersome if you want to update things that are scattered between groups.

The mid term target of MiMec is to remove from the 3D editor as most as possible MCU and link creation , and put all the mission logic into python program with high level, human understandable functions, that should hide all this MCU and other things.

Currently it will just allow you to load a mission, search and modify by lot any mission objects, then save the mission into a new one.

 

The following use case can be already done with few python lines:

  • change height of lot of objects (planes, vehicle, blocks, Waypoint,...) by adding 50m for example.
  • set country of all blocks around a given position or an object
  • update Complex Trigger to replace planes/vehicules scripts and country (usefull if you import AA group that were not design for the planes of the current mission, for example)

 

It is totally opensource and available here : https://github.com/lefufu/PylGBMiMec

If some want to participate, I will grant them access to the project, and explanation of the code if needed. Just ask.

This is not the best python code you may have seen, but it seems to work.

 

I must start the wiki to explain all functions and object properties. For the moment there is a short summary in the readme. I hope it will help you.

After reading it, you should have a look on the template mission : it will give you an idea of what can be done.

 

Thanks for your feedback.

 

I started this project to practice a bit more python,  it takes me more time than intially planned, so I won't work again on  it if nobody is finding interest.

 

  • Like 1
  • Thanks 2
  • Upvote 1
Link to comment
Share on other sites

Hello Lefuneste, this is indeed very interesting. I have been threatening for some time to break the things that need to be in the mission editor (objects, 3D placement) from things that are logic and could be done in a different way (all behaviors, basically). Up until this point, as you saw in the durability thread, I have only done fairly simple tweaks. I'm still not 100% sure I want to jump in with both feet to this kind of thing, it would be quite a departure from how we currently build missions on Combat Box.

 

It's probably worth asking @coconut and @LLv34_Temuri for their opinion, I know they have done significant work on the mission files and underlying maps. Coconut for years ran a very successful dynamic campaign system (and I believe is building a new one currently) and Temuri is the brains behind the Finnish Virtual Pilots "dynamic war" campaign which has received very good feedback recently (I am planning to start playing it tonight, in fact!).

 

Some random thoughts about how I might design missions, if I had code/library support to do so. I am not a Python expert - if I were doing this myself it would be C# (I created CB Radio using C# and was very productive, that's just because I know the language, I have nothing against Python).

  • Combat Box missions have player airfields, objectives, influence zones, and (now) SRS radio call-outs.
  • I'd love to be able to 'decorate' groups in the mission with 'behaviors', and to indicate in the mission editor what behaviors I want, maybe through some kind of 'tagging' convention. That way I can tag a player airfield as "no vulching" and have the right underlying stuff be added to the mission.
  • Icons usually represent objectives. So if I had a group with a single icon in it, and I tag it as an objective, I would like to add behaviors. Some way to track things killed within the group and to mark the objective destroyed. When destroyed, on Combat Box, we draw a big black X over the target. It would be nice if the X was added because of the tagged objective, rather than added by hand in the editor.
  • Objectives also need to wire themselves up to the global scoreboard and victory conditions. It would be nice if this were automatic.

To be clear, I'm not asking for you to implement these things, just that they are the kinds of things I think about when I'm editing an objective for the 50th time or trying to ensure everything is wired up correctly.

Link to comment
Share on other sites

@Alonzo Indeed, I started working on something similar 5 years ago or so, and it's the basis for my dynamic mission generation. Available at https://github.com/deneuxj/SturmovikMission

So basically it looks like programmatic mission generation for IL-2 GB is available for multiple (well, two) programming languages and environments: Python and .net.

 

Link to comment
Share on other sites

One thing I’ve been meaning to do for a while is to write a script that replaces object’s Model and Script values with selected ones, but as it’s just a find&replace operation that can be done with Notepad++ on certain type of files in certain folder (including subfolders), I haven’t done it. Our target groups are nowadays quite simple (java side is a lot more complex), but every now and then there might be a need for a tweak, in which case it needs to be propagated to all groups, and can be laborious.

Link to comment
Share on other sites

1 hour ago, coconut said:

@Alonzo Indeed, I started working on something similar 5 years ago or so, and it's the basis for my dynamic mission generation. Available at https://github.com/deneuxj/SturmovikMission

So basically it looks like programmatic mission generation for IL-2 GB is available for multiple (well, two) programming languages and environments: Python and .net.

 

That's very cool. I didn't realize you were still maintaining it, it looks very active. As I understand it, F# is usable from C# since they are both CLR languages. But is that a sensible thing to do? (It's been a long time since I did any functional programming, I don't think I want to dive into the F# directly).

Link to comment
Share on other sites

The library should be usable from C#, but I've never tried to use it that way, and I would expect that some corners might need softening. All F#-specific types (Option, immutable collections such as lists and maps) are CLR types, and should be usable from C#. It will look a bit ugly, but if the provided functionality is valuable enough, it might be worth it.

 

One potentially troublesome part is the type provider: The library parses a sample mission file, and automatically generate types from it. That part needs to be triggered by F# code, but it should be easy enough to write.

 

The library is available on NuGet, for .net standard 2.1, the name of the package is SturmovikMission.DataProvider. You won't be able to reference it directly from C# though, so you would need a thin F# library project just for that, and then reference that from C#.

Link to comment
Share on other sites

31 minutes ago, coconut said:

The library should be usable from C#, but I've never tried to use it that way, and I would expect that some corners might need softening. All F#-specific types (Option, immutable collections such as lists and maps) are CLR types, and should be usable from C#. It will look a bit ugly, but if the provided functionality is valuable enough, it might be worth it.

 

One potentially troublesome part is the type provider: The library parses a sample mission file, and automatically generate types from it. That part needs to be triggered by F# code, but it should be easy enough to write.

The library is available on NuGet, for .net standard 2.1, the name of the package is SturmovikMission.DataProvider. You won't be able to reference it directly from C# though, so you would need a thin F# library project just for that, and then reference that from C#.

I didn't know that work. If I knew it, I won't have done MiMec..  I had a look in it, it seems to me a bit more complicated to use than python...

 

For example

Select all objects of newMission containing "Plane" in their name :

planeList=findObject(newMission, Name='Plane')

 

modify all objects previously found:

modify_kv(newMission, planeList, XPos=changedX, AILevel=1, Name=changedName, Enabled=0, Country=CountryID['Germany'])

 

This line change XPos by adding  10 on it, add "_test" at the end of the object name, set Enabled to 0 and Country to Germany for each objects in planeList.

Of course, you can do less or more changes and can build planeList with a lot of other criterias.

 

 

1 hour ago, LLv34_Temuri said:

One thing I’ve been meaning to do for a while is to write a script that replaces object’s Model and Script values with selected ones, but as it’s just a find&replace operation that can be done with Notepad++ on certain type of files in certain folder (including subfolders), I haven’t done it. Our target groups are nowadays quite simple (java side is a lot more complex), but every now and then there might be a need for a tweak, in which case it needs to be propagated to all groups, and can be laborious.

That's exactly  what MiMec is doing as it is, as it can modify all "key=value" properties. You can add on your python program somthing to parse a directory for all mission files

Edited by c6_lefuneste
  • Upvote 1
Link to comment
Share on other sites

  • 1 month later...

Hi there

 

Without checking the source code because I'm not familiar with python....

 

Repairing older missions should be possible

 

In most (all???) cases there are some lines missing or units do not exist any more.

Setting up a database with the default content for each item (Trigger Timer, ...)

parsing the existing content

and adding not existing content could do that.

 

Example:

Update implemented 'Haze'

 

Options
{
...

  Haze = 0;
  WindLayers
  {

...

 

Just let the 'Haze' line be added to the mission file in the right place...

 

Same for the 'units'

Logging 'non existant' units

These lines could be used (if a datababs with existing items is implemented)

            Model = "graphics\planes\bf109e7\bf109e7.mgm";
            Script = "LuaScripts\WorldObjects\Planes\bf109e7.txt";

 

 

Deci

Link to comment
Share on other sites

  • 1 month later...
19 hours ago, super-truite said:

Just found this. I was starting to develop something similar. Will definitely give it a try! 

 

Super !

I stopped to work on it for the moment because it seems that no mission creators are intersted by MiMec way to handle missions (they do not know what they are loosing 🙂 ).

If you want I can give you rights on the github project and explanations to help you to do what you want.

Link to comment
Share on other sites

sure! I need to organize a bit what I need to do in order  to make the interaction more productive and then let's talk. I will be all set next week-end I guess

Link to comment
Share on other sites

OK I tried to play with it. It works great, congrats for the really clear template. It is really intuitive to replace things. 

My use case: what I want to do is to be able to separate object placement 
from mission logic in order to be able to create new map faster.  The idea is along the line of what @Alonzo said if I understand correctly.


The simple case:
1) create a template mission  with all the logic of the multiplayer game mode I am developing. Each objects that need manual positioning will have a special name ("tag" in Alonzo's post), for instance Name = "defence_axis_flag1_vehicle_1". This vehicle and other will be linked to a mess of MCUs I do not want to see when designing a new mission (it gets really painful to connect everything and to even see what I am doing).

2) create a simple mission where I only place the objects that need manual positioning.
3) execute a script that  modify the positions of the tagged vehicles in the template mission

4) write to a new mission file

This is so far doable easily using your script. 

 

A more complex use case is when I have some new objects from the 'simple mission' to insert in the template. Typically I cannot predict in advance the number of waypoints I need for each objects in the general template and I'd rather add them later (between step 3 and 4) using a script to have some flexibility. It seems I cannot insert new objects easily using your script. But anyway this is already a good start and I can anyway just do an ugly scripted copy pasta of a bunch of waypoint to hack my way out and start creating a bunch of mission at the speed of light 😄. Or I could add a really huge number of waypoints in the template and delete the unneeded ones 🤪. we will see ...

Link to comment
Share on other sites

Ok, got it working for the simplest case:
 

Untitled-1.png

In the "simple mission" I dropped all timers/MCUs and all what I call the mission logic and kept only units and waypoints that need to be set manually at some position. All the waypoints/units have the same names in the template and simple missions. It then modify the positions in the initial template (hence with all the logic setup) using @c6_lefuneste's script. Not quite all the functionalities I need but it will give some ideas to other server admins that need to copy paste the same mission logic over and over 🙈. The rest of what I need is too specific to my use case I guess.

Edited by super-truite
Link to comment
Share on other sites

For the moment it's not possible to add object, but I may add this feature, just by creating a template file with needed object (one per type) and then implementing a copy/paste feature.

For waypoints, I had in mind to allow to select a group of MCU waypoint and then affect it to an other object. The function would then do all the needed connexions and mechanics to make it work. You can even imagine to have ToT function, right speed for each plane (cruise, climb,...),  icons created automatically on map,...

The long term target of MiMecs is to replace mission logic you are doing now by importing MCU by high level python functions.

Link to comment
Share on other sites

In fact, in my case I can do the opposite: instead of "decorating" with MCUs the objects of a simple mission, I build a template with all MCUs and I use the simple mission to modify the positions of elements in the template. But it is because I always have the same template for all my missions that I am able to do it this way. I think my use case is similar to most MP game modes though. The only thing that would be neat to make this use case entirely doable with your framework is to add the possibility to remove element from ids. This way I can make a general template with more stuff than what I will need for some missions derived from the template. For instance, I can add  a lot of waypoints  for each objects in the template. In my simple mission, for some objects, I won't need all the waypoints and I will delete them. What I do is the following: 

1) use your class to move all the objects in the template mission class instance to the positions of the ones that are present in the simple mission

2) find the ids of the objects that are present in the template but not in the simple mission (the not needed waypoints for instance).

3) write to temporary file

3) remove all the objects corresponding to the ids in 2) in the temporary file using an ugly script I did in 5 minutes 🙈

4) write to the final mission file

Step 3) could be probably done easily with your class provided minor modifications

 

I am not sure if this is covering all the use cases you could think of but it is already something!

 

 

Link to comment
Share on other sites

  • 2 weeks later...
  • 2 months later...
LF_Sire

Hello.

I'm trying to use MiMec to orient big smokes in to wind direction.

I'm very new to Phyton but I hope good enough.

When I use my script on simpler missions it works, but I tried it on a PWCG mission.

Simpler mission:
image.png.d0e239c4aaa81d4010965616cc7db674.png

Complex (PWCG) Mission:
image.png.18372c5cbf8bdacbae61c5c178971e1e.png

Warnings on simpler mission are not important and program works.
But there are other kind of errors on complex mission I can not understand.

May be someone can help.

Files attached.
Thx

Smoke_orienter.zip

Link to comment
Share on other sites

c6_lefuneste
39 minutes ago, LF_Sire said:

Hello.

I'm trying to use MiMec to orient big smokes in to wind direction.

I'm very new to Phyton but I hope good enough.

When I use my script on simpler missions it works, but I tried it on a PWCG mission.

Simpler mission:
image.png.d0e239c4aaa81d4010965616cc7db674.png

Complex (PWCG) Mission:
image.png.18372c5cbf8bdacbae61c5c178971e1e.png

Warnings on simpler mission are not important and program works.
But there are other kind of errors on complex mission I can not understand.

May be someone can help.

Files attached.
Thx

Smoke_orienter.zip 434 kB · 0 downloads

Hello. I will have a look this week end. It's strange that PWCG creates specific things...

  • Like 1
Link to comment
Share on other sites

c6_lefuneste

Hello. It should be fixed in 3.2. At least the code is not crashing.

Problem was double : PWCG use "train" instead "Train" and there was a case with "-" in carriage name that was not handled.

  • Thanks 2
Link to comment
Share on other sites

  • 3 weeks later...
jollyjack

Sideliner:  I was interested how the new map-emitter fire effects workout regarding wind.

Well i set all wind to zero here, in the first campaign mission Fortress Stalingrad (set to mission for testing) .....

The old mapemitter's smoke points to the left, the newer Loop City Fire's smoke goes right. (latter quite simpler programming).

The benefit of the new loop-mapemitter is that is hasn't those irritant synchronous on-off visuals.

 

Some bat file algorithm job to exchange them would be welcome for all old missions and campaigns for mission makers.

Can hear po' ole' Gambit & BlackSix already grumping about changes to be made yet again;

I guess IL2 is too busy with the new BoN stuff for now LoL.

 

City Firre Loop test.jpg

Edited by jollyjack
Link to comment
Share on other sites

12 hours ago, jollyjack said:

Sideliner:  I was interested how the new map-emitter fire effects workout regarding wind.

Well i set all wind to zero here, in the first campaign mission Fortress Stalingrad (set to mission for testing) .....

The old mapemitter's smoke points to the left, the newer Loop City Fire's smoke goes right. (latter quite simpler programming).

The benefit of the new loop-mapemitter is that is hasn't those irritant synchronous on-off visuals.

 

Some bat file algorithm job to exchange them would be welcome for all old missions and campaigns for mission makers.

 

The old emitters needed to be rotated to match the wind. Do the new emitters automatically do the right thing?

 

I'd love it if someone made a batch file. It might not be that simple, though -- my missions have two emitters each on a 10 second "start" cycle. The new emitter needs just 1 effect, and if you want it to switch off you have to do so explicitly (on the old ones you could just stop doing the 'start' trigger).

 

I'm slowly fixing this as I make new missions but going through all the old ones is time consuming.

  • Upvote 1
Link to comment
Share on other sites

jollyjack

ah, did not know that. with wind amount set to 0 however you'd expect that smoke goes up straight up.

near where i live there are oil refineries, steam often goes straight up, and then it moves sideways hitting a layer where there's wind.

Nice sight.

 

BTW a Q:

Stalingrad city. it seems that the buildings are always damaged in IL2; do you know if there's an undamaged setting for the city?

Most Stalingrad blocks have no adjustable damage setting

I  found only a few blocks that had edit-able damage settings, mostly with industrial items, like a coal storage compound.

 

Volgograd had se many nice palaces and buildings LoL. And most of them still exist ...

Edited by jollyjack
Link to comment
Share on other sites

SYN_Vander

The Stalingrad buildings have no undamaged version of the objects. You can check in the mission editor.

Edited by SYN_Vander
  • Like 1
Link to comment
Share on other sites

jollyjack

Jusr did, i pity IL2 Stalingrad, permanent rubble, almost like Beirut ..

Link to comment
Share on other sites

SYN_Vander

Remember this was created back in 2012. IL2 BoS was the first instalment of the new IL2 franchise. I can imagine there was some time pressure and some corners were cut. Before the big battle started, the city was already in ruins, why create pristine buildings? Also, could have been a decision to get better performance.

Edited by SYN_Vander
Link to comment
Share on other sites

  • 1 month later...
SYN_Vander

Sorry to have derailed....

 

I like the idea of a toolset for mission building. But how about a mission generator with a proper API that can be used by others to make a more 'high' level mission editor based on a web UI for instance? It could also be used to generate missions for campaigns/careers.

 

The question is how to describe a mission in a more high level way. What are the concepts? Flights, Objectives, Patrol Zones ....

Link to comment
Share on other sites

super-truite

Because it would be a lot of work and because you would not have the 3d editor. I think there was actually a project like this, but it is not maintained anymore.

Edit: 

 

Link to comment
Share on other sites

coconut
Posted (edited)
8 hours ago, SYN_Vander said:

Sorry to have derailed....

 

I like the idea of a toolset for mission building. But how about a mission generator with a proper API that can be used by others to make a more 'high' level mission editor based on a web UI for instance? It could also be used to generate missions for campaigns/careers.

 

The question is how to describe a mission in a more high level way. What are the concepts? Flights, Objectives, Patrol Zones ....

 

I've done something like this: https://github.com/deneuxj/SturmovikCampaign/blob/master/MissionGen/MissionFileGeneration.fs#L674

It's primarily meant to work with my dynamic online campaign system, but I've had ideas of exposing blocks for other uses as well.

 

This might not be the place to discuss my tools, further discussions can take place in

 

Edited by coconut
Link to comment
Share on other sites

c6_lefuneste
On 5/16/2021 at 11:25 AM, SYN_Vander said:

Sorry to have derailed....

 

I like the idea of a toolset for mission building. But how about a mission generator with a proper API that can be used by others to make a more 'high' level mission editor based on a web UI for instance? It could also be used to generate missions for campaigns/careers.

 

The question is how to describe a mission in a more high level way. What are the concepts? Flights, Objectives, Patrol Zones ....

What about PWCG ?

The idea of Mimec is lowering workload for hand made mission, to allow mission designer to focus only on parts that make mission really unique and enjoyable... I made the first brick, but unfortunatelly, it seems that it's not interesting for most people. Maybe I will try to find time to create higher level functions, but not for the moment...

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

×
×
  • Create New...