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 > SHIII Mods Workshop
Forget password? Reset here

Reply
 
Thread Tools Display Modes
Old 03-22-10, 07:23 AM   #1
LGN1
Ace of the Deep
 
Join Date: Mar 2006
Posts: 1,138
Downloads: 147
Uploads: 12
Default [REL] SH3 Campaign Editor tools: Deleting units, extracting units and more zigzag

Present Readme:

Perl scripts for editing SH3 campaign files, Readme.

Version 0.5

Written by LGN1, July 2010


This package contains six Perl scripts for editing SH3 campaign files. In order to use them you need Perl on your system (see below).

**************************************
PosTimeFilter.pl script:
-------------------
The first script, called PosTimeFilter.pl, extracts all units from the campaign layers that enter a specified area during a specified time. The script will first ask the relevant data (see PosTimeFilter.jpg):

First, it asks whether you want to modify the Campaign_SCR.mis file (enter 's', without the ''), the Campaign_RND.mis file ('r'), or the Campaign_LND.mis file ('l').

Second, it will ask the start date of the date 'window'. The default value is shown in brackets (just press enter to choose the default option).

Third, it will ask the end date of the date 'window'.

Finally, it will ask for the upper longitude, lower longitude, upper latitude, and lower lattitude of the rectangle in which the traffic will NOT be deleted. The desired values can be obtained from the Mission Editor (see MissionEditorCoord.jpg. Be careful, the Mission Editor shows meters and the script wants kilometers). A rough overview for the North Atlantic can be seen in Worldmap.jpg.

After these steps the scripts checks all the units and reports how many it found,... You can then choose to delete the units outside the area/time. The modified file is called PosTime_Campaign_*.mis. The original file Campaign_*.mis is not modified.
**************************************


**************************************
zigzag.pl script (for an example for GWX see ReadmeMedCampaign.txt):
--------------------------------------------------------------------
This script adds a zigzag pattern around the main course of all units satisfying user-specified criteria. It only works for the Campaign_RND.mis file. In detail, the criteria are (see zigzag.jpg):

Max. distance: the maximum distance a group will travel on average without changing course.

Zigzag angle: the average angle for the zigzag pattern around the main course.

Probability for switching zigzag pattern: higher values lead to a less regular zigzag pattern.

Min. ColumnsNo: groups with less columns than the specified value will not zigzag.

Max. ColumnsNo: groups with more columns than the specified value will not zigzag.

Min. Speed: groups with a speed below the chosen value (at any waypoint) will not zigzag.

Max. Speed: groups with a speed above the chosen value (again, at any waypoint) will not zigzag.

Check origin: groups containing a unit from either Japan, Spain, Germany, Sweden, Ireland, Italy, Finland, Portugal, or Environmental will not zigzag.

Min. spawn probability: only groups with a spawn probability higher than the chosen value will zigzag.

Zigzag only for escorted (e), only for unescorted (u), or for all (a) (default a): Allows the user to limit the zigzagging to either escorted groups or unescorted groups.

Start/End date: only groups that exist between start and end date will zigzag.

Zigzag in North Sea: adds zigzag patterns to the North Sea (see Worldmap.jpg for exact area).

Zigzag in Bay of Biscay: same for Bay of Biscay (see Worldmap.jpg for exact area).

Upper longitude,...: boundary values for the area in which groups zigzag (in addition to North Sea, Bay of Biscay if chosen).

The modified file is called ZigZag_Campaign_RND.mis. The original file is not modified. The random radii around all the zigzag waypoints do not overlap. Usually, the random radius is equal to the distance of the waypoint to the main course. This guarantees random course changes. The Loop feature has been disabled for zigzagging units.
**************************************


**************************************
ClassFilter.pl script (mainly for Mission/Campaign designer):
-------------------------------------------------------------
This script extracts all groups/units that contain a specified class, e.g., KLS, NavalBase, Minefield,... from the Campaign_*.mis files. A new Campaign_*.mis file (called 'ClassName'_Campaign_*.mis) is created which contains only the groups containing the specified class (the original file is not touched). You can choose whether you want to extract only groups consisting purely of the chosen type or groups that have at least one unit with the chosen class.
**************************************


**************************************
OriginFilter.pl script (mainly for Mission/Campaign designer):
-------------------------------------------------------------
The same as ClassFilter.pl but in this case you can choose the origin not the class. If you want to choose the class and the origin, just run both scripts after each other. Don't forget to rename the campaign file in-between.
**************************************


**************************************
TypeFilter.pl script (mainly for Mission/Campaign designer):
-------------------------------------------------------------
The same as ClassFilter.pl but in this case you can choose the type not the class. Again, you can combine all the filters. Just rename in-between running the different scripts.
**************************************


**************************************
RemoveClass.pl script:
-------------------------------------------------------------
This script removes all groups/units that contain a specified class, e.g., KLS, NavalBase, Minefield,... from the Campaign_*.mis files. A new Campaign_*.mis file (called 'Rem_ClassName'_Campaign_*.mis) is created which contains only the groups not containing the specified class (the original file is not touched).
**************************************


**************************************
Some important notes:
---------------------

1) These scripts are my first Perl scripts and they are probably not 100% foolproof. Unreasonable input parameters may lead to messed-up campaign layers. It is not checked whether the input parameters make sense.

2) With the given zigzag script it is very easy to overload the campaign layer with waypoints. I recommend to first reduce the size of the campaign layers with the first script before adding new zigzag waypoints. Just choose an area you will not leave during the patrol.

3) Use the available parameters to keep the number of new waypoints in a reasonable range. For instance, if you think that attacking convoys is already difficult enough, use Max. ColumnsNo = 1 to have only single ships and one column convoys zigzag. You may also limit the zigzagging to a smaller area where you will spend most of your time during a patrol. Clearly, a small max. distance makes it more realistic and challenging, but also increases the number of waypoints! In general, one has to find an appropriate balance between zigzag area, zigzagging groups, and zigzag distance. User feedback is very important here. Please share your experiences!

4) The zigzag script does not check whether a new waypoint is on land. I guess this is no problem if you are not close to land (I think ships that are not rendered just travel over land). If you are close, the ships might end up on the beach. So, you either stay away from the coast or, even better, avoid to use the zigzag script in areas close to land. If you use it in these areas, you may later check with the Mission Editor whether there are any waypoints on land (and correct it if necessary).

4) The scripts report how many units they found, how many they removed,... It's a good idea to check whether they found all the units and whether the new files have the correct number of ships (just open the files with Notepad and look for the number of the last unit/group). You can also check whether the last unit/group in the new file is also the last unit in the Mission Editor. If not, then there is a problem with renumbering. I have never encountered any such problem, but it is better if you check it also.
The zigzag script writes the new data with different number of decimal digits (not always six). I guess that's fine. If you don't like it, just open the new file in the Mission Editor and save it again. All numbers should have six decimal digits now.

5) Feel free to modify/improve the script as you wish. If you do so, please share it with others. The script is probably not very elegant, but straight-forward. If you have any question don't hesitate to ask.

6) Use at own risk! Please post any feedback here:

http://www.subsim.com/radioroom/showthread.php?t=165794

Cheers, LGN1

Not for comercial use!

**************************************
Getting Perl and using the script:
----------------------------------

you can download Perl from here:

http://www.perl.org/get.html

After installing it, go to 'Start' and click 'Run...'. Enter 'cmd' and press OK. You should now have a window similar to the one in PosTimeFilter.jpg. Go to the directory with the script and the Campaign* files you want to modify (If you have the files on the Desktop write 'cd Desktop' and press return. That should be enough).
Now enter 'perl PosTimeFilter.pl' or 'perl zigzag.pl' depending on which script you want to run. Press return and enter the parameters. Return and you are done.


Old post:

Hi,

ships in SH3 change course much less frequently than they did in real life. In principle, this can be easily changed by adding more waypoints to the campaign layers. However, since these layers are already quite large, adding more waypoints directly is not feasible in practice. Therefore, ships in SH3 zigzag not very much. A very informative thread about this topic can be found here:

http://www.subsim.com/radioroom//sho...d.php?t=139391

In order to achieve a more challenging zigzag behavior of the ships in SH3, I have written two Perl scripts (similar to an existing tool for SH4: http://www.subsim.com/radioroom/showthread.php?t=113918 ; Perl can be obtained from here: http://www.perl.org/get.html ):

The first script allows the user to automatically delete all units in the SRC and RND layer that do not enter a given (rectangular) area. The user can also specify a date 'window'. Thus, it is very easy to adjust campaign layers depending on your patrol area.

The second script allows the user to automatically add zigzag waypoints (with an average distance and angle) to user-specified units in the RND layer. One can choose:

- max. average distance between waypoints,
- average zigzag angle with respect to main course,

Units options:

- min./max. number of columns,
- min./max. speed,
- date 'window',
- min. spawn probability,
- option to switch off the zigzag for axis and neutral units,
- user specified (rectangular) area for zigzagging (two rectangles for Bay of Biscay and North Sea already implemented). Repeated use of the script allows more areas.

Currently I am testing the script and it seems everything works fine. Manual targeting is now much more challenging because you cannot simply shadow the target for a few hours, position yourself ahead of it, and wait until it arrives. U-Jagdtools become more important now!

For a date 'window' 1.1.1941 to 1.1.1942, zigzag area: Long: -3250 to 0, Lat: 3400 to 7600 (see screenshot below), average distance between waypoints 80km (7kn ship changes course roughly every 6 hours), I obtained a RND file of size 1.57 MB (stock GWX: 8.37 MB). For a distance of 50km I obtained 1.67 MB.

Some final remarks:

- Unfortunately, I don't know how to check whether waypoints are on land. However, I guess waypoints over land are no problem if you are not close (outside of render area). The best thing is to choose the zigzag area not too close to land.

- this is the first perl program/script I have written; so it is probably not the most elegant one. However, it should be easy to understand if someone wants to change something.

Screenshot:




Download:

http://www.subsim.com/radioroom/down...o=file&id=1681

Last edited by LGN1; 07-19-10 at 07:58 AM.
LGN1 is offline   Reply With Quote
Old 03-22-10, 08:08 AM   #2
Hitman
Pacific Aces Dev Team
 
Hitman's Avatar
 
Join Date: Sep 2002
Location: Spain
Posts: 6,109
Downloads: 109
Uploads: 2


Default

Very, very interesting
__________________
One day I will return to sea ...
Hitman is offline   Reply With Quote
Old 03-22-10, 08:48 AM   #3
Uber Gruber
Stowaway
 
Posts: n/a
Downloads:
Uploads:
Default

Ooooooo.....me likey
  Reply With Quote
Old 03-22-10, 08:57 AM   #4
Rubini
Ocean Warrior
 
Join Date: May 2005
Location: Săo Paulo Brazil
Posts: 2,728
Downloads: 132
Uploads: 0
Default

Yeah, Seems very intereting and useful.

The waypoints area over land can be or not a problem. I can asure you that GWX and NYGM don't have this problem because we spent a lot of time in the past just looking for this issue.

But as you said isn't a big issue anyway, the problem is major at spawn point, when , if at land, will be not spawned at all.
__________________
One gamer's must-have mod is another gamer's waste of time.
-Sailor Steve
Rubini is offline   Reply With Quote
Old 03-22-10, 09:27 AM   #5
LGN1
Ace of the Deep
 
Join Date: Mar 2006
Posts: 1,138
Downloads: 147
Uploads: 12
Default

Thanks for the nice words At present the script is still rather basic. However, it can be easily understood by anyone who is willing to deal with it and it offers many cool possibilities to quickly adapt the campaign layers.

I don't know how many players want to use it, so I don't know how useful it is to implement more areas like the North Sea and Bay of Biscay. Obviously, the Med is difficult also. It requires several rectangles to cover it properly

Maybe I add a 'Med area'

Cheers, LGN1
LGN1 is offline   Reply With Quote
Old 03-22-10, 09:49 AM   #6
Hitman
Pacific Aces Dev Team
 
Hitman's Avatar
 
Join Date: Sep 2002
Location: Spain
Posts: 6,109
Downloads: 109
Uploads: 2


Default

If I understood it right, we script manually (Or choose an already scripted one) a convoy route and then run the editor so that it sets a zizag pattern along the existing convoy route? Or will it create the route from scratch? If so, how can we define historic routes?
__________________
One day I will return to sea ...
Hitman is offline   Reply With Quote
Old 03-22-10, 11:28 AM   #7
LGN1
Ace of the Deep
 
Join Date: Mar 2006
Posts: 1,138
Downloads: 147
Uploads: 12
Default

Hi Hitman,

yes, you choose a campaign_RND.mis file, specify the parameters, and the script then adds the zigzagging along the course.

Here's an example with your/GWX med. campaign_RND file:



Seconds later after running the script, it looks like this (the random radius for the waypoints is not shown):



All units satisfying the specified parameters now zigzag along the old route. In the example the ships change their course on average every 50km (approx. 4h@7kn). The RND size increased from 1.3 to 2 MB (158 of 343 units zigzag, 4455 waypoints added). The SRC file is not touched.

Cheers, LGN1
LGN1 is offline   Reply With Quote
Old 03-22-10, 11:40 AM   #8
LGN1
Ace of the Deep
 
Join Date: Mar 2006
Posts: 1,138
Downloads: 147
Uploads: 12
Default

Just to further clarify: in the above example all units with the following characteristics zigzag:

- Speed: never below 5kn and never above 15kn.

- Single ships and convoys with up to 5 columns zigzag (slow, broad convoys don't zigzag. See thread linked in first post).

- Units/convoys that include a:
German,
Italian,
Japanese,
Irish,
Finnish,
Swedish,
Spanish,
or Environmental
unit, do not zigzag (in order to keep the RND file small).

Cheers, LGN1
LGN1 is offline   Reply With Quote
Old 03-22-10, 11:45 AM   #9
Sailor Steve
Eternal Patrol
 
Sailor Steve's Avatar
 
Join Date: Nov 2002
Location: High in the mountains of Utah
Posts: 50,369
Downloads: 745
Uploads: 249


Default

That's pretty cool stuff!
__________________
“Never do anything you can't take back.”
—Rocky Russo
Sailor Steve is offline   Reply With Quote
Old 03-22-10, 04:09 PM   #10
Hitman
Pacific Aces Dev Team
 
Hitman's Avatar
 
Join Date: Sep 2002
Location: Spain
Posts: 6,109
Downloads: 109
Uploads: 2


Default

Amazing

Looking forward to get it

Another question:

What happens to the former radius of the waypoints? Can it happen that large radius causes convoys to circle in a small area once the editor has been run and it has added zigzags? I'm asking this because after implementing the zigzags the legs seem to be much smaller, so if they are displaced due to random radius this could eventually cause a problem.

BTW if you are interested in programming another useful tool, then do one that allows MERGUING different text files for convoy routes. That would allow creating a whole campaign from separatedly scripted parts, making things much easier.
__________________
One day I will return to sea ...
Hitman is offline   Reply With Quote
Old 03-22-10, 05:45 PM   #11
LGN1
Ace of the Deep
 
Join Date: Mar 2006
Posts: 1,138
Downloads: 147
Uploads: 12
Default

Hi Hitman,

to avoid possible problems, I have already taken care that the random radii (???) do not overlap. At the moment the random radius is max. 20% of the max. distance you specify (in an extreme case the distance between the waypoints is only 50% of max. distance, two waypoints ===> roughly 20% of specified max. distance. I guess this is enough randomness). Usually, the random radius is equal to the distance of the waypoint from the main course axis (but, as I said, max. 20% of specified max. distance). These things however can be easily tweaked.

Another thing I had to tweak was the loop feature. At the moment I have just disabled looping to other waypoints for the zigzagging units (obviously, the waypoint counting is changed). I don't know yet how serious this is for the gameplay. In general, I think this tool can easily change the whole style of playing, no easy 90 degrees shot after shadowing a straight-running merchant for some time Try to catch/shadow a 12kn merchant at 16km distance that changes course every 2-2.5 hours I guess that will be a really tough game

Concerning the tool you are mentioning: I am not sure whether I understand it. You want a tool that takes several RND/SRC layers and merges them to a single layer (doesn't the editor have such a feature )? Anyway, such a tool should be quite easy to program (on the first look).

Cheers, LGN1
LGN1 is offline   Reply With Quote
Old 03-23-10, 05:35 AM   #12
Ktl_KUrtz
Samurai Navy
 
Ktl_KUrtz's Avatar
 
Join Date: Aug 2008
Location: U-30
Posts: 597
Downloads: 910
Uploads: 12
Default

Excellent!
I am looking forward to using it!
Thanks.
KUrtz
__________________
Schleichfahrt Rudder: GWX KC.vQ
https://www.mediafire.com/file/taz1r...XKC.vQ.7z/file
Ktl_KUrtz is offline   Reply With Quote
Old 03-23-10, 11:29 AM   #13
Hitman
Pacific Aces Dev Team
 
Hitman's Avatar
 
Join Date: Sep 2002
Location: Spain
Posts: 6,109
Downloads: 109
Uploads: 2


Default

Quote:
Concerning the tool you are mentioning: I am not sure whether I understand it. You want a tool that takes several RND/SRC layers and merges them to a single layer
Yes I want to use the mission editor for example to script my artic convoys, then open a new file and separately script my patrols around the british isles, then f.e. a thrid file with the caribbean convoys. And then, a tool that can mergue all three files in one, or simply add them to an existing campaign RND file. This makes convoy scripting much easier, as you work one by one and then the tool merges them into the basic campaign file you are working with.

Quote:
(doesn't the editor have such a feature )?
Uhhh not that I'm aware of ... or does it???
__________________
One day I will return to sea ...
Hitman is offline   Reply With Quote
Old 03-23-10, 01:38 PM   #14
SquareSteelBar
Sea Lord
 
Join Date: May 2006
Location: U-73
Posts: 1,638
Downloads: 632
Uploads: 0
Default

SH3 MissionEditor has a merge feature:

menu bar -> 'File' -> 'Merge with...'
SquareSteelBar is offline   Reply With Quote
Old 03-23-10, 01:47 PM   #15
Hitman
Pacific Aces Dev Team
 
Hitman's Avatar
 
Join Date: Sep 2002
Location: Spain
Posts: 6,109
Downloads: 109
Uploads: 2


Default

Quote:
SH3 MissionEditor has a merge feature:

menu bar -> 'File' -> 'Merge with...'


How many hours of work that could have saved me
__________________
One day I will return to sea ...
Hitman 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 11:07 AM.


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.