Log in

View Full Version : [WIP] Automatic log-book editor


LGN1
12-21-10, 02:12 PM
Hi,

I am currently working on a perl script that automatically adds entries to the captain's log book depending on what happened during a patrol. Here is an example:

Stock log book entries:

http://img338.imageshack.us/img338/6000/shortox.th.jpg (http://img338.imageshack.us/i/shortox.jpg/)

Uploaded with ImageShack.us (http://imageshack.us)

Log book after running the script:

http://img502.imageshack.us/img502/3721/longhx.th.jpg (http://img502.imageshack.us/i/longhx.jpg/)

Uploaded with ImageShack.us (http://imageshack.us)

The script uses the *.crp file of a save-game which contains all entries in the 'console' during a patrol. It reads these entries, looks for certain patterns, and adds corresponding entries to the log book. At the moment it looks for these entries (first line is the text in the 'console', the second line the corresponding text that is added to the log book. The third line is the time in hours that must pass before another entry of this kind is added. E.g., this allows you to have weather reports only every 24h in your log book):

EntryText=Torpedo Impact!
EntryText=Torpedo impact.
0
EntryText=Torpedo missed, sir!
EntryText=Torpedo missed.
0
EntryText=Torpedo is a dud, sir!
EntryText=Torpedo is a dud.
0
EntryText=Tube 1 ready, sir!
EntryText=Tube 1 reloaded.
0
EntryText=Tube 2 ready, sir!
EntryText=Tube 2 reloaded.
0
EntryText=Tube 3 ready, sir!
EntryText=Tube 3 reloaded.
0
EntryText=Tube 4 ready, sir!
EntryText=Tube 4 reloaded.
0
EntryText=Tube 5 ready, sir!
EntryText=Tube 5 reloaded.
0
EntryText=Tube 6 ready, sir!
EntryText=Tube 6 reloaded.
0
EntryText=Firing tube 1, sir!
EntryText=Firing tube 1.
0
EntryText=Firing tube 2, sir!
EntryText=Firing tube 2.
0
EntryText=Firing tube 3, sir!
EntryText=Firing tube 3.
0
EntryText=Firing tube 4, sir!
EntryText=Firing tube 4.
0
EntryText=Firing tube 5, sir!
EntryText=Firing tube 5.
0
EntryText=Firing tube 6, sir!
EntryText=Firing tube 6.
0
EntryText=Crash dive
EntryText=Crash dive.
0
EntryText=Man the deck gun
EntryText=Order to man the deck gun.
0
EntryText=Man the flak gun(s)
EntryText=Order to man the flak gun.
0
EntryText=We're under attack, sir!
EntryText=Under attack.
1
EntryText=Enemy is pinging us, sir!
EntryText=Destroyer is using ASDIC.
1
EntryText=Depth charges in the water, sir!
EntryText=Depth charges.
1
EntryText=Detecting radar signals!
EntryText=Radar signals detected!
6
EntryText=We have to surface, sir!
EntryText=We have to surface.
0
Keyword=Wind Speed
EntryText=
24
Keyword=Sound contact, sir! Merchant
EntryText=Sonar operator reports sound contact.
6
Keyword=Sound contact, sir! Warship
EntryText=Sound operator reports warship.
6
Keyword=Ship spotted, sir!
EntryText=Ship spotted.
6
Keyword=Aircraft spotted, sir!
EntryText=Aircraft spotted.
1
Keyword=Submarine spotted, sir!
EntryText=Submarine spotted.
1
Keyword=damaged, sir!
Remove=7
0
Keyword=destroyed, sir!
Remove=7
0
Keyword=Flooding in
Remove=7
1
Keyword=repaired, sir!
Remove=7
0
Keyword=intact, sir!
Remove=7
0
Keyword=Diesel fuel reserve down to
Remove=8
0

At the moment these entries are still very short and I would like to replace them with longer once. It would be great if you could make some suggestions for better entries (but please keep in mind that they must be quite generic).

Thanks for any suggestions!

Cheers, LGN1

PS: After a patrol these entries can also be easily extended by JScones excellent Patrol-Log editor in SH Commander!

Hitman
12-21-10, 02:57 PM
Amazing mate :o

Magic1111
12-21-10, 03:25 PM
WOW, very good Idea !!!! :up:

Best regards,
Magic:salute:

Myxale
12-21-10, 03:30 PM
Together with SH3 LogEditor this will be as close as it gets to a real logbook!

Kudos mate°!!°

Delareon
12-21-10, 04:22 PM
Hi,
...
EntryText=Torpedo missed, sir!
EntryText=Torpedo missed.
0
EntryText=Torpedo is a dud, sir!
EntryText=Torpedo is a dud.
0
EntryText=Tube 1 ready, sir!
EntryText=Tube 1 reloaded.
0
EntryText=Tube 2 ready, sir!
EntryText=Tube 2 reloaded.
0
...

First i have to say its an excellent idea and would add much immersion to the game.
Then my questions :)
Are these entrys your Entrys or the Entries of the game?
I ask because if u search for that patterns it will not work in german i assume.

LGN1
12-21-10, 05:36 PM
Thanks for the encouraging words!

At the moment I have only a German and English version. However, it's easy to add other languages if someone wants to support them. It's also very easy to add other words/items as you like.

The script is quite easy to modify,..., but since I don't know how to program a GUI, you have to have perl :-? For people using my other perl scripts it's not a problem, however, I guess for quite a few players it might be different. Depending on the interest, I might write an extended documentation explaining how to use the script (and perl) in more detail :hmmm: It might be also good for people who want to use the zigzag script.

Anyway, any suggestions for good entries for firing torpedoes,... :D

Cheers, LGN1

Sailor Steve
12-21-10, 09:04 PM
Looks pretty cool so far! :sunny:

FUBAR295
12-21-10, 11:50 PM
WOW!!!

Look forward to more.:):DL:):DL

Good Hunting,
FUBAR295

Gerald
12-21-10, 11:55 PM
Cool, :up:

CherryHarbey
12-22-10, 03:10 AM
LGN1,
Very interesting stuff, I used to update my logs in SH3 Commander with most of this, but had to stop as it was consuming too much paper during patrols and too much time after patrols.
I used to include "evasion begun" and "evasion complete" entries which could be tied to the requests for silent running on/off.

I also used include oxygen level reports whilst under long evasions but not if I was diving to keep out of a storm. (or the 100% report you get after every dive!) Can your script include IF statements? or maybe just include the 50% 25% 10% reports?

And the Medic!!!!!! text could be linked to crew wounded/killed

Just my suggestions, feel free to ignore if it isn't easy to do

LGN1
12-22-10, 10:04 AM
Hi,

here is an automatically generated log of an interesting patrol.

Page 1: I am leaving Brest on the 30. Dec. 1942. Many radar warnings and crash dives because of airplanes in the Bay of Biscay.

http://img228.imageshack.us/img228/9076/17007994.th.jpg (http://img228.imageshack.us/i/17007994.jpg/)

Page 2: 4. Jan. 1943. I receive a radar warning and dive. The sound operator reports a warship and merchant. I found a convoy. I shoot 5 torpedoes, but only 3 hit. Two ships sunk. Destroyer starts to use ASDIC.

http://img84.imageshack.us/img84/7159/45582310.th.jpg (http://img84.imageshack.us/i/45582310.jpg/)

Page 3: I find a slow tanker behind the convoy and sink it. 5. to 15. Jan. only weather reports. Poor visibility and strong winds. At least no planes.

http://img255.imageshack.us/img255/3997/47974786.th.jpg (http://img255.imageshack.us/i/47974786.jpg/)

Page 4: For training purposes I order the crew to man the deck gun and flak. Planes start to show up again.

http://img413.imageshack.us/img413/9114/41394702.th.jpg (http://img413.imageshack.us/i/41394702.jpg/)

Page 5 to 7: The boat is damaged by a plane. After receiving a radar warning and diving, the sound operator reports a merchant and warship. Another convoy. I shoot four torpedoes. 3 hits, 2 ships sunk. Another convoy is found after diving because of a radar warning. I shoot 3 torpedoes. 3 hits, 2 ships sunk. Destroyer starts to throw depth charges. Fuel down to 50%.

http://img20.imageshack.us/img20/4295/58926088.th.jpg (http://img20.imageshack.us/i/58926088.jpg/)

http://img256.imageshack.us/img256/9794/60495245.th.jpg (http://img256.imageshack.us/i/60495245.jpg/)

http://img543.imageshack.us/img543/7722/40986002.th.jpg (http://img543.imageshack.us/i/40986002.jpg/)

Page 8: Trip back through the Bay of Biscay. Many radar warnings. Feb. 7th 1943 sound operator reports sound contact. Our escort.

http://img834.imageshack.us/img834/4650/80251663.th.jpg (http://img834.imageshack.us/i/80251663.jpg/)


It's quite interesting, the crew did not spot a single ship. All contacts were made via radar warnings. I wonder whether it worked that well in real-life, too. I doubt it.

As you can see the entries are quite generic because you don't have much information. However, the automatically generated log can serve well as a first draft for a more detailed log with JScones' SH3 Patrol Log Editor.

Rickster1
12-22-10, 11:10 AM
Superb, back to SH3 from SH5

h.sie
12-22-10, 11:13 AM
Great Idea. Sh3 is not yet dead. NOT YET.

Could it work in the background during gameplay?

Delareon
12-22-10, 11:16 AM
Ah suggestion: as i see for example in the log for the sunked Passagierdampfer.
There are many messages which are similiar like the "Torpedotreffer". All the same time and the same message. Would it be possible to group them?
for example "3 Torpedotreffer" or when u launch many torpedos in small intervalls something like "Torpedoschuss aus Rohren 3, 4, 5, 6".

Just an idea if its possible to implement would be nice, because of a shorter log ;)

rea00cy
12-22-10, 01:37 PM
This is cool! I look forward to seeing this mod ready to use.

Happy hunting,

rea00cy

LGN1
12-22-10, 02:54 PM
Great Idea. Sh3 is not yet dead. NOT YET.

Could it work in the background during gameplay?

No, I don't think so (without touching hard-code). You need a save-game (Global Explorer's great SH3 Generator does the same). Being able to add comments to the log book (and the map) during playing would be one of the greatest additions for gameplay/immersion. Maybe you can find a way how to add comments during gameplay :D

Ah suggestion: as i see for example in the log for the sunked Passagierdampfer.
There are many messages which are similiar like the "Torpedotreffer". All the same time and the same message. Would it be possible to group them?
for example "3 Torpedotreffer" or when u launch many torpedos in small intervalls something like "Torpedoschuss aus Rohren 3, 4, 5, 6".

Just an idea if its possible to implement would be nice, because of a shorter log ;)

It's certainly possible, however, it requires additional coding :hmmm: There are many such things that are possible if you 'connect' different entries (at the moment all entries are treated independently). E.g., if the crew spots a merchant and warship in quick succession, you could add a comment that a convoy has been spotted. All possible, but more involved because you cannot do things just entry-by-entry. I'm not sure whether it's worth the effort because the player can quickly change the entries later depending on the situation and the coding can quickly become quite involved (checking all possible combinations,...). I guess in a first version I will just treat the entries independently.

Cheers, LGN1

DaveP63
12-22-10, 06:21 PM
Amazing piece of work! Can't wait to see it implemented :salute:

CherryHarbey
01-02-11, 12:36 PM
LGN1,
is this still work in progress or wasn't there enough interest or has it just taken a back seat during the festive period?
really looking forward to seeing this published if it possible.

LGN1
01-05-11, 01:12 PM
LGN1,
is this still work in progress or wasn't there enough interest or has it just taken a back seat during the festive period?
really looking forward to seeing this published if it possible.

It's still work in progress. I just took a back seat and also worked on some other things.

Cheers, LGN1

frau kaleun
01-05-11, 01:55 PM
really looking forward to seeing this published if it possible.

Me too, looks very cool.

JScones
01-05-11, 08:05 PM
No, I don't think so (without touching hard-code). You need a save-game (Global Explorer's great SH3 Generator does the same). Being able to add comments to the log book (and the map) during playing would be one of the greatest additions for gameplay/immersion. Maybe you can find a way how to add comments during gameplay :D
Having spent many months on this back in 2005 (there's posts here from the time referencing it), I can say this can easily be achieved through the use of a simple TSR that regularly polls the .crp file looking for changes. It may require the player to save the patrol first (can't quite remember now if the file is written as an event takes place or when the game is saved), but it was certainly doable - I know because I had a prototype running in Oct2005 (and a public release beta in Jan2006). One of the many functions I ultimately planned to add to SH3CTSR.exe, but never did because I foresaw the below...

Ah suggestion: as i see for example in the log for the sunked Passagierdampfer.
There are many messages which are similiar like the "Torpedotreffer". All the same time and the same message. Would it be possible to group them?
for example "3 Torpedotreffer" or when u launch many torpedos in small intervalls something like "Torpedoschuss aus Rohren 3, 4, 5, 6".

Just an idea if its possible to implement would be nice, because of a shorter log ;)
And thus why I never implemented the "extended" logbook functionality and left it at the "basic" functionality that it currently has...to do it right requires a lot of work and lookup tables (with underlaying logic) to ensure that the output is exactly as one would expect a Kaleun to write. So no ", sir!" or repeating "Ship sighted!" or "Torpedo fired!" entries. Anything non-authentic would just lead to "can you fix/change" posts which would just lead to a never ending spiral. To avoid this requires a lot of upfront work defining the text and the logic to replace the default text (remembering that the text varies between mods, so you need a dynamic solution that will work with any mod, or at least an easy way to make it adjustable for any mod) to ensure a contextually correct patrol log.

Good luck! If there is anything I can do to help (I still have some of my notes, my prototypes and lookup files), just let me know.

LGN1
01-06-11, 08:34 AM
Thanks a lot for the input, JScones :up:

I was hoping that you would show up with some comments because I thought that you probably have thought about this before and you have a huge knowledge about it!

I completely agree with you that it is a huge amount of work to get a decent automatic log (maybe even impossible with the limited information in the crp file). However, I had the following ideas in my mind when I started it:

- A perfect, automatic log is not possible (at least for me). However, even having a few more distinct events in the log file would be a big improvement (e.g., torpedo hits so that it's documented if you hit something that did not sink).

- A non-perfect log can be corrected/adjusted later with your excellent patrol editor, i.e., the program creates a first rough draft. It's up to the player to do the fine finishing. For players using your patrol editor it might be a help and reduces the amount of typing.

- I limit myself to distinct events that do not happen very often. For others I have an option that there must be some (adjustable) time delay between instances. E.g., 'ship spotting' entries must be x hours apart. This is only a very rough 'logic', but works ok for me.

Clearly, this is not a perfect log! However, at least for me it's better than the original log.

At first I did not want to present the script here, but just use it for myself. However, when looking at the Tell us what you are upto in your current campaign (http://www.subsim.com/radioroom/showthread.php?t=151090) thread I thought that it might be useful for others, too. I hope, it's clear to everyone here that this will never be a tool for creating a perfect log automatically.

Cheers, LGN1

PS: I would really like to test your beta. Is it still available somewhere?

Could you please comment on this part of your post a bit more:

...through the use of a simple TSR that regularly polls the .crp file looking for changes. It may require the player to save the patrol first (can't quite remember now if the file is written as an event takes place or when the game is saved), but it was certainly doable...

JScones
01-06-11, 05:18 PM
I was hoping that you would show up with some comments because I thought that you probably have thought about this before and you have a huge knowledge about it!
I spent about 6 months, maybe a little more, on it. Just didn't have the time to do it the way I wanted to.

- A perfect, automatic log is not possible (at least for me). However, even having a few more distinct events in the log file would be a big improvement (e.g., torpedo hits so that it's documented if you hit something that did not sink).
Yes, even just a few entries, such as the weather, would be beneficial.

Talking about the weather, I am not sure I agree with the 24 hour limitation. Given weather reports are requested manually by the player at any time, it stands to reason that the response would be recorded in their log book.

PS: I would really like to test your beta. Is it still available somewhere?
I hope so - I still have the emails and results. Will check my archive drive shortly.

Could you please comment on this part of your post a bit more:

...through the use of a simple TSR that regularly polls the .crp file looking for changes. It may require the player to save the patrol first (can't quite remember now if the file is written as an event takes place or when the game is saved), but it was certainly doable...
The simplest way of doing it is to create a console app that runs while SH3 is running.

When it starts, have it find all .crp files in the user's savegame folder and store the last modified date for each (you need to do this because you won't know the career the player wants to use up front, a problem I didn't have with SH3Cmdr).

Then have the console app "wait" for SH3.exe to close. Once this occurs, the app can requery the .crp files. Any that have a newer modified date can be assumed to have changed. Run your function against these .crp files. For SH3Cmdr users you'll find only one career and one .crp file tends to change in a session, but this way will capture those who play multiple careers in one session.

There's other ways of doing it (if you knew the user was running SH3Cmdr you could easily obtain details of the career the player intended to use, because SH3Cmdr writes the info "into" SH3, but if you want compatibility with non SH3Cmdr users, you won't be able to do this).

The entries Beery and I tentatively started with were:

45=The base was changed to: %s
57=Flotilla is disbanded. You are transferred to %s.
520=We have casualties, sir!
590=Medic called to attend to a wounded man.|N|3; Meediiiiiic!!!
591=We have sustained casualties on deck.|N|3; Men down on the deck!
592=We have flooding, sir!
593=We have heavy flooding, sir!
594=We have critical flooding, sir!
597=Torpedo Impact!
598=Enemy is pinging us, sir!
599=Enemy ship engaging us, sir!
600=Enemy aircraft engaging us, sir!
602=We're under attack, sir!
603=Depth charges in the water, sir!
604=We're taking damage, sir!
606=Enemy ship is ramming us, sir!
607=Destroyer in attack run!
633=%s damaged, sir!
634=%s destroyed, sir!
650=Firing tube %d, sir!
662=All torpedoes expended, sir!
810=Ship spotted, sir! Bearing %03d! %s range!
811=Aircraft spotted, sir! Bearing %03d! %s range!
814=Radar contact, sir! Bearing %03d! %s range!
815=Sound contact, sir! %s %s %s Bearing %03d! %s range!
816=Radio Report Received! %s %s, %s, Course %s, Speed %d KTS!
817=Detecting radar signals!
4128=Clouds %s, Precipitations %s, Fog %s|Wind Speed %d meters per second, direction %3d.
4140=She's going down!
4141=She's going down!
4142=She's going down!
4180=Ship sunk!|%s|%s, %d tons
4181=Aircraft destroyed!|%s|%s

These are the entries we thought were most relevant to the log book, not the subsequent "log book friendly" text. In some instances all we did was remove the ", sir!" text (dynamically, to cater for mod changes to the entries), in others we completely rewrote the entry to something that would make more contextual sense in a logbook.

Some other entries we toyed with:

595=Hull damaged, sir!
601=We have been detected, sir!
707=%s repaired, sir!
708=%s ready, sir!
709=%s intact, sir!
1003=Rig for silent running
1004=Secure from silent running
1035=Crash dive
1042=Deploy decoys
4419=We're out of diesel fuel sir!
4421=Batteries empty, sir!
4423=We're out of oxygen!
4425=We're out of compressed air, sir!
Battery recharged 100%, sir!
Oxygen reserve 100%, sir!
Compressed air reserve 100%, sir!
4520=Engaging target with deck gun!
4521=Engaging target with flak gun!
4811=Report sent!