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 05-03-07, 04:46 PM   #1
mcoca
Loader
 
Join Date: Apr 2005
Location: Madrid, Spain
Posts: 86
Downloads: 0
Uploads: 0
Default [REL] Automated Campaign Editor v0.4

This is the 0.3 release of the SH Batch Editor, a tool for making automated changes to the campaign files. Please consider it a beta release.

If you want to make some extensive changes to the SH4 campaign, but don't spend hours in the in-game editor, this is your tool. Just enter the values you want to set, and (if needed) the conditions a randomly generated group must fulfill to be modified, run the program, and the entire campaign will have been modified.

The changes to be made are specified as code snippets in the Python programming language (www.python.org), but the program has been designed to make it possible to use it with only a minimum of programming knowledge.

At the moment, the program only supports editing random generated groups (including contents and waypoints, so you can add or remove ships from them), but scripted elements, bases, etc, should not be affected in any way by running it. But, just in case, always make backups.

The program is available at:

http://downloads.sourceforge.net/shb...editor-0.4.zip

It is written in the Java programming language so you will need the Java Virtual Machine (version 1.5 or later), available at http://java.sun.com/ (but likely to be already installed on your computer).

This program is released under the GNU General Public License, and the linked file includes full source code for the technically inclined.

The README.txt file includes all instructions for running simple changes. If you know some programming and want to try more complex changes, in the "samples" folder of the distribution you can find the script to reproduce the changes I'm currently using in my campaign.

Finally, I really don't know how much further I will be able to develop this. That's one of the reasons for releasing it as Free Software, so that everybody who is interested can continue developing it should I no longer have time or (let's face it) interest. If anybody wants to contribute, I sure could use some help.

Hope you enjoy this.

Changes in v 0.4
  • Added option to run script directly from file.
  • Added group cloning.
  • Fixed cargoInt and cargoExt getters. Now it's internalCargo and externalCargo, as per the setters.
  • Allow logging from scripts.
  • Added Yanaran's fix to zig-zag code.
  • Fixed dateline heading and offset bugs.
Changes in v0.3:
  • Added "Output" field to GUI.
  • Added init.py initialization file.
  • Added waypoint length and heading read-only attributes.
  • Changed Waypoint loop attribute to take a Waypoint object.
  • Added sample zig-zag code to init.py

Last edited by mcoca; 06-13-07 at 05:15 PM. Reason: New release
mcoca is offline   Reply With Quote
Old 05-03-07, 04:49 PM   #2
Egan
Admiral
 
Join Date: Sep 2001
Posts: 2,019
Downloads: 15
Uploads: 0
Default

Very impressive looking. Thanks for this, it looks like it will come in very useful.
Egan is offline   Reply With Quote
Old 05-03-07, 04:50 PM   #3
ReallyDedPoet
Canadian Wolf
 
ReallyDedPoet's Avatar
 
Join Date: Jul 2006
Location: The one and only East Coast
Posts: 10,775
Downloads: 946
Uploads: 5


Default

Nice effort

RDP
__________________

Back in the Day



ReallyDedPoet is offline   Reply With Quote
Old 05-03-07, 04:50 PM   #4
Ducimus
Rear Admiral
 
Ducimus's Avatar
 
Join Date: May 2005
Posts: 12,987
Downloads: 67
Uploads: 2


Default

Very nice.
Ducimus is offline   Reply With Quote
Old 05-03-07, 04:55 PM   #5
mcoca
Loader
 
Join Date: Apr 2005
Location: Madrid, Spain
Posts: 86
Downloads: 0
Uploads: 0
Default

Almost forgot! Please consider this an "undocumented feature" for the moment, but for those who are feeling brave, the distribution includes the entire python standard library, meaning you can do all types of nifty things, including (as per Jace11's suggestion):

Code:
from random import randint
group.speed = randint(5,9)
group.updateWaypointSpeed()
Which makes the group speed random between 5 and 9 knots. Obviously, all instances of the group will travel at the same random speed

You can use any of the functions described in the python documentation...

(edit to fix problem in example)

Last edited by mcoca; 05-03-07 at 06:31 PM.
mcoca is offline   Reply With Quote
Old 05-03-07, 05:58 PM   #6
Jace11
Seasoned Skipper
 
Join Date: Mar 2005
Location: UK
Posts: 683
Downloads: 104
Uploads: 1
Default

Just re-stating my gratitude for this. It will speed things up for the people who are editing the campaign layers.

Last edited by Jace11; 05-03-07 at 06:29 PM.
Jace11 is offline   Reply With Quote
Old 05-03-07, 06:09 PM   #7
akdavis
Samurai Navy
 
Join Date: Mar 2005
Location: Fort Worth, Texas
Posts: 597
Downloads: 0
Uploads: 0
Default

This is superb, especially the random speed functionality.
__________________
-AKD
akdavis is offline   Reply With Quote
Old 05-03-07, 06:30 PM   #8
lurker_hlb3
Admiral
 
Join Date: Apr 2005
Location: San Diego Calif
Posts: 2,290
Downloads: 187
Uploads: 12
Default

What would be the code to randomly change speed on each way point i.e pt1 is 5, pt 2 is 8 etc ???
lurker_hlb3 is offline   Reply With Quote
Old 05-03-07, 06:50 PM   #9
mcoca
Loader
 
Join Date: Apr 2005
Location: Madrid, Spain
Posts: 86
Downloads: 0
Uploads: 0
Default

Thank you everybody for your support! Now, start using the thing so I can feel I haven't completely wasted my time :p

Quote:
Originally Posted by lurker_hlb3
What would be the code to randomly change speed on each way point i.e pt1 is 5, pt 2 is 8 etc ???
I'm writing from memory, but it would be something along these lines:

Code:
from random import randint
for waypoint in group.waypoints:
    waypoint.speed = randint(2,8)
Obviously, change the numbers to the ones you want. The spaces at the beginning of the third line are important, since python uses indentation to control what's inside the loop and what isn't.

BTW, if you want to get cute, there are functions to provide randomness along a probability curve, so most of the time ships will be around the middle of the range, with the occasional fast or slow one. Check the docs if you are interested.
mcoca is offline   Reply With Quote
Old 05-03-07, 06:58 PM   #10
lurker_hlb3
Admiral
 
Join Date: Apr 2005
Location: San Diego Calif
Posts: 2,290
Downloads: 187
Uploads: 12
Default

Quote:
Originally Posted by mcoca
Thank you everybody for your support! Now, start using the thing so I can feel I haven't completely wasted my time :p

Quote:
Originally Posted by lurker_hlb3
What would be the code to randomly change speed on each way point i.e pt1 is 5, pt 2 is 8 etc ???
I'm writing from memory, but it would be something along these lines:

Code:
from random import randint
for waypoint in group.waypoints:
    waypoint.speed = randint(2,8)
Obviously, change the numbers to the ones you want. The spaces at the beginning of the third line are important, since python uses indentation to control what's inside the loop and what isn't.

BTW, if you want to get cute, there are functions to provide randomness along a probability curve, so most of the time ships will be around the middle of the range, with the occasional fast or slow one. Check the docs if you are interested.

It worked perfectly, thanks very much
lurker_hlb3 is offline   Reply With Quote
Old 05-13-07, 04:14 AM   #11
mcoca
Loader
 
Join Date: Apr 2005
Location: Madrid, Spain
Posts: 86
Downloads: 0
Uploads: 0
Default

I just made a new release. Aside from the new "output" field, which allows you to select a destination for the changed files, so not to overwrite the originals, the most useful change is the support for zigzagging via new waypoints.

There is sample zigzagging code in the README. If anyone knows how to make that a bit cleaner, I would love to see it. In any case, zigzagging as currently implemented will cause odd behaviour when it interacts with random waypoints, so check your changes.

Enjoy!
mcoca is offline   Reply With Quote
Old 05-13-07, 04:39 AM   #12
terrapin
Stowaway
 
Posts: n/a
Downloads:
Uploads:
Default

Quote:
Originally Posted by mcoca
I just made a new release. Aside from the new "output" field, which allows you to select a destination for the changed files, so not to overwrite the originals, the most useful change is the support for zigzagging via new waypoints.

There is sample zigzagging code in the README. If anyone knows how to make that a bit cleaner, I would love to see it. In any case, zigzagging as currently implemented will cause odd behaviour when it interacts with random waypoints, so check your changes.

Enjoy!
Is this the actual new release you're talking about?
  Reply With Quote
Old 05-13-07, 04:43 AM   #13
mcoca
Loader
 
Join Date: Apr 2005
Location: Madrid, Spain
Posts: 86
Downloads: 0
Uploads: 0
Default

Quote:
Originally Posted by terrapin
Is this the actual new release you're talking about?
Yep. I had edited the first post with the correct URL, changes, etc. I guess I should have made it clear in my post Sorry about that.
mcoca is offline   Reply With Quote
Old 05-13-07, 04:45 AM   #14
terrapin
Stowaway
 
Posts: n/a
Downloads:
Uploads:
Default

Quote:
Originally Posted by mcoca
Quote:
Originally Posted by terrapin
Is this the actual new release you're talking about?
Yep. I had edited the first post with the correct URL, changes, etc. I guess I should have made it clear in my post Sorry about that.
Thank you!
  Reply With Quote
Old 05-13-07, 06:38 AM   #15
Yanaran
Watch
 
Join Date: Apr 2007
Posts: 29
Downloads: 0
Uploads: 0
Default

I'm having problems removing units from groups. Specifically I want to remove all tankers from task forces (so I can speed them up)

Code:
if group.groupName.find("TaskForce") != -1:
    for unit in group.units:
        if unit.type == UnitType.TANKER:
            group.units.remove(unit)

I get an error that says:
Traceback (innermost last)
File "<string>", line 2, in ?

Any ideas?
Yanaran 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 02:42 PM.


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