SUBSIM Radio Room Forums



SUBSIM: The Web's #1 resource for all submarine & naval simulations since 1997

Go Back   SUBSIM Radio Room Forums > Silent Hunter 3 - 4 - 5 > SH4 Mods Workshop
Forget password? Reset here

Reply
 
Thread Tools Display Modes
Old 04-27-07, 07:23 AM   #1
mcoca
Loader
 
Join Date: Apr 2005
Location: Madrid, Spain
Posts: 86
Downloads: 0
Uploads: 0
Default [WIP] Mission edition API

Hi everybody,

Maybe I'm reinventing the wheel here, but I have the beginings of something interesting. I wanted to do some mass editing of the campaign files, to give all merchants a chance of getting a patrol boat as escort. Not wanting to do the edit by hand, I wrote a program to do it. This has evolved into a Java library to edit mission files.

Right now the library allows adding/removing/changing random groups and their units. Waypoints would be trivial to add, and with a little effort you could add pretty much everything else.

To make things clear, this is a library for writing programs, not a program in itself, so you need to know how to write Java programs to use it. But if you do, it's easy to use. As an example, if you wanted to make all elite destroyers veteran, you could use something like this:

Code:
Mission mission = new Mission ();
mission.read(filename);
for (RndGroup group : mission.getRandomGroups()) {
    for (RndUnit unit : group.getUnits()) {
        if (unit.getType() == UnitType.DESTROYER &&
                unit.getCrewRating() == CrewRating.ELITE) {
            unit.setCrewRating(CrewRating.VETERAN);
        }
    }
}
mission.write(filename);
The insides of the library are not that clean but it works.

Now, if there is enough interest in it, I can clean it up a bit, add some documentation, and release it under the GNU GPL. But the API already does what I wanted it to do, so I can't promise to develop it much further.

Anyone interested in this?
mcoca is offline   Reply With Quote
Old 04-27-07, 02:51 PM   #2
Jace11
Seasoned Skipper
 
Join Date: Mar 2005
Location: UK
Posts: 683
Downloads: 104
Uploads: 1
Default

Simple answer is yes!

I have been looking at mass changes also...

Changing speed from 5 knts for convoys
Increasing competence of escorts and merchants
etc

So far, I've been having to do most of it by hand as I can't program, so I would be interested in anything that could speed up mass editing of the campaign files.

Find/Replace is not specific enough...
Jace11 is offline   Reply With Quote
Old 04-27-07, 03:12 PM   #3
tater
Navy Seal
 
Join Date: Mar 2007
Location: New Mexico, USA
Posts: 9,023
Downloads: 8
Uploads: 2
Default

This will be cool if someone turns it into an application. Wow, really awesome.
tater is offline   Reply With Quote
Old 04-27-07, 04:45 PM   #4
mcoca
Loader
 
Join Date: Apr 2005
Location: Madrid, Spain
Posts: 86
Downloads: 0
Uploads: 0
Default

Quote:
Originally Posted by Jace11
Simple answer is yes!

I have been looking at mass changes also...
Okay, I will clean it up and upload it somewhere over the weekend. I will try to make some quick recipes for the programming-challenged

Quote:
Originally Posted by tater
This will be cool if someone turns it into an application. Wow, really awesome.
What kind of application would you like? I've thought about that, but the only two options I see are 1) a reimplementation of the mission editor, only worse, o 2) Essentially a programming language (maybe graphical) to specify conditions and changes, but with less flexibilty than a real one. Both would be a lot of work.

I'm curious what people would consider their perfect mass-edition application.
mcoca is offline   Reply With Quote
Old 04-29-07, 06:27 AM   #5
mcoca
Loader
 
Join Date: Apr 2005
Location: Madrid, Spain
Posts: 86
Downloads: 0
Uploads: 0
Default

Okay, I've changed my mind and started work on an application to make this slightly easier. The idea is to avoid the need for Java knowledge and development tools (except for the Java Virtual Machine, of course), while keeping all the power of the current API.

I can do that by integrating a different programming language (python, which is famously easy to use) into the application, so you can write your instructions in a text box, press a button, and have it run. Right now it works, although the interface is very rough. All of my Java work has been server-side and I'm still learning how to make pretty windows with it (If anyone has that knowledge, help would be appreciated).

For simple changes, what I have now is not more complex to use than editing the files by hand. As an example, if you want to change all the groups speed to 5 knots (as Jace11 mentioned), you would just write into the textbox:

Code:
group.speed = 5
group.updateWaypointSpeed ()
Right now I'm adding some small details (such as being able to choose the file to edit ), and some convenience calls to create new ships without having to fill every field. I will have that, as well as some basic documentation, either later today or tomorrow.

Is anyone interested in testing the program when it reaches that stage? I could do with a few more eyes looking at it. If so, let me know and I'll send it over. Once it's a bit more mature than that, and I have arranged for hosting somewhere, I will do a public release with full source.
mcoca is offline   Reply With Quote
Old 04-29-07, 07:27 AM   #6
Jace11
Seasoned Skipper
 
Join Date: Mar 2005
Location: UK
Posts: 683
Downloads: 104
Uploads: 1
Default

Good stuff.

Will this program be able to change some variables and not others...

Just one example:

"Spawnprobabilty=" can refer to a group like a convoy but also all the ships in that convoy have there own spawnprobabilty too..

Could you associate the search with another line or the group name or something so that one can easily replace the values for convoys and not ships..

Find/Replace cannot distinguish these apart, and my editing is taking forever...

A complete rehash of the campaign is daunting and ive only completed 1941 so far..
Jace11 is offline   Reply With Quote
Old 04-29-07, 08:15 AM   #7
mcoca
Loader
 
Join Date: Apr 2005
Location: Madrid, Spain
Posts: 86
Downloads: 0
Uploads: 0
Default

Jace11, all that is possible right now. The program has four entry fields:

- Condition for changing a group, for example:

Code:
group.groupName.contains("Jap_Convoy")
- Changes to apply to a group:

Code:
group.spawnProbability = group.spawnProbability/2
- A condition for changing each unit in the group:

Code:
unit.unitType == UnitType.DESTROYER
- Changes for units that fulfill that condition:

Code:
unit.shipClass = None
(that last one is untested, but it should remove the specific class, and thus make the destroyers a "GENERIC Destroyer")

Press the "change" button, and all japanese convoys will have half the spawn probability, and generic escorts.

I'll send you a PM once I have it ready.
mcoca is offline   Reply With Quote
Reply


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT -5. The time now is 03:04 PM.


Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright © 1995- 2025 Subsim®
"Subsim" is a registered trademark, all rights reserved.