PDA

View Full Version : [TEC] AI actions and variables


urfisch
06-19-11, 08:28 AM
I cant get rid of the idea of "wolfpacks" and interaction with them. So what do experienced modders say, what we would need for this to achieve? I thought of the triggered actions ai surface-boats are fullfilling, to take it as a kind of matrix. using it lets us make the ai u-boats "sending" special variables, which let the radio message system of the game sending you a radiomessage.

;)

Thought: lets take the ai attack script as an example for interacting ai-uboats. If the ai surface boat sights a uboat, it is attacking, so a routine is called through the ai script. maybe it is possible to add another action into this script, same way as you can add controllers via s3d to different files. if we discover, what variables are used to get radio messages received (the function of the "radio message system"), we should be able to get the ai script sending messages, right? or not right?

:hmmm:

I thought, if we are able to let our ai-uboats sending a radio message when encountering a convoi (containing the coordinates), the game would be a lot more realistic!

But first we need fully functional ai-uboats. As privateer said, they had some problems, as they are just cloned "surface units".

Any ideas and thoughts on that are very welcome!!!

:up:

h.sie
06-19-11, 08:55 AM
@urfish: nice to see your initiative. do you know where the AI (scripts) are located?

urfisch
06-19-11, 09:01 AM
i think the *.sim and the *.val files are what is used for the ai-behavior. but i am not sure. this thread is dealing with ai scripts in sh5: http://www.subsim.com/radioroom/showthread.php?t=171973

h.sie
06-19-11, 09:33 AM
aircraft hasn't got *.val files, so the AI won't be in *.val.

and in the *.sim files I only find a reference name like cmdr_AIAirplane but no script or a statesmachine description.

Digging through the *.act files using OllyDbg, I found cmdr_AIAirplane in Sh3Sim.act, so I fear it's hardcoded.

TheDarkWraith
06-19-11, 11:25 AM
Only SH5 gives you the ability to define the AI behavior using scripts. SH3/4 is hardcoded for the AI routines.

h.sie
06-19-11, 12:50 PM
@TDW: Thanks for approving my suspicion.

I see two possible ways to get halfway working wolfpacks:

1) Hitmans idea: Somehow modify the airbases to allow them to spawn AI Uboats, which would mean wolfpack support based on your contact report. Start from the AI/code of the airplane (Maybe clone the AI in the memory and duplicate it but modified??) and invert the heights to negative values, so that altitude is changed for depth. With some studying, we could probably make the "inverted airplanes" come at high speed to the convoy and submerge (Instead of making an air dive) to shoot, then surface (instead of climb) to head away at high speed.

2) LGN1's idea: Teleport an convoy consisting of 3-4 Sergbutos AI-Subs to the area where you sent the contact report. This could be done with an Assembler hack. Maybe possible.

urfisch
06-19-11, 03:32 PM
interesting ideas. even the ai thing seems to be hardcoded. but hardcode must not be a limit any more...or am i wrong?

;)

just provocating..i know its a hard thing.

if i can help, let me know.

urfisch
06-19-11, 03:34 PM
Only SH5 gives you the ability to define the AI behavior using scripts. SH3/4 is hardcoded for the AI routines.

i know this is a fact. but is it a handicap for us to get wolfpacks acting? maybe you can help with your knowledge, tdw. i am sure, you can!

:)

Madox58
06-19-11, 07:48 PM
It is totally possible to 'strip' some things from other versions .act files
and plant them in SH3.

I tested doing this by 'stripping' the Air_Torpedos from SH4.
And adding a new .act file in the SH3 folder.
Added the needed controller from SH4 and it worked somewhat.
I never finished working the bugs out of the whole process because that was not what I was after and it proved what I wanted to know at that time.

What I wanted to know was simple.
It is possible to create new controllers for SH3?
The answer is Yes to an extent that I don't know.
The Air_Torpedos are not coded into the SH3 exe so why did they work?
Because the exe does not control everything.
It calls the .act files for things like that.
.act files are only .dll files with a fancy extension!
.dll files can be stripped down or built from scratch.
Write an AI_Sub.dll, rename it AI_Sub.act and create the needed controller for the .sim?

Anvart
06-20-11, 12:55 AM
I think, at first, you must creat AI_sub class for AI_sub unit (and your *.exe must "understand" this unit)... and then cmdr_AISub (as a combination of existing old controllers and new controller)... lol :D

h.sie
06-20-11, 01:40 AM
@privateer:

Thanks. I was aware that *.act are simply .dll files, since I already changed Sh3Sim.act and EnvSim.act to change e.g. torpedo reload and weather. These files also have an regular ModuleEntryPoint (DLLMain) that is called by the system loader at game load time, what is a nice place to add some executable code.:)

I also programed a separate hsie.act which was loaded successfully in order to overwrite some executable code of sh3.exe (Dll code injetion).

My problem is to completely understand and re-engineer how the AI works that is coded (probably) in Sh3Sim.act. I can find there the Strings cmdr_AIship & cmdr_AIAirplane, which could indicate that the AI is stored there. I also found huge jump-tables which could contain the addresses for the appropriate AI-routines. It will take long time to understand how they work and to change them to have something like cmdr_AISubmarine.

Importing from SH4 is a good point. Does SH4 have AI-Submarines?

h.sie
06-20-11, 02:05 AM
@Anvart: My problem: Too few knowledge regarding "controllers".

Anvart
06-20-11, 03:14 AM
...
Does SH4 have AI-Submarines?
No.
@Anvart: My problem: Too few knowledge regarding "controllers".
What do you mean?

h.sie
06-20-11, 02:02 PM
What do you mean?

I meant: I have too few overall knowledge about all necessary sh3 modding diciplines (controlllers, dat files, statesmachines) what caused me to hesitate to start working on wolfpacks. That cannot be done with a simple binary hack consisting of 3-4 lines of assembler. This needs concentrated knowledge of more than one person - teamwork. I don't like teamwork.

TheDarkWraith
06-20-11, 02:10 PM
I don't like teamwork.

There are others like me :D I prefer to work alone also. Always have and always will :up:

Anvart
06-21-11, 12:05 PM
...
I don't like teamwork.
I have the same taste. :haha:

h.sie
06-21-11, 12:48 PM
so we are 3 now...:D

SquareSteelBar
06-21-11, 01:04 PM
Four...

Maybe we should think about founding a team? :rotfl2:

TheDarkWraith
06-21-11, 01:18 PM
Four...

Maybe we should think about founding a team? :rotfl2:

usually 'independants' are head-strong and strong-willed.....bad combination when two or more try to work together :dead:

h.sie
06-21-11, 02:07 PM
OK, I am the boss. Tomorrow 10h is meeting. Anvart makes AI-Sub controller. SSB does graphics - and a BANNER! TDW does the asm part. And me.....I'm the boss as I already mentioned.

SquareSteelBar
06-21-11, 02:18 PM
O no - I'm the boss! :stare:

urfisch
06-21-11, 02:38 PM
wtf...what is goin on here? Its MY thread, so i am responsable for the design-stuff!!! For me its ok, if hsie is the boss.

:salute:

:rock:

by the way: everyone can work on his own, as long as we have a collective plan!!!

:D

h.sie
06-21-11, 05:55 PM
I just made a rest from working and started a little bit on this topic: So far, I could locate the code that controls the positions of all Campaign.scr Units on a regular basis. So I am optimistic to be able to access a certain unit (e.g. an Sergbuto-AI-Submarine) and manipulate its position (-> teleport it to a certain other position). This could be step 1 (of a huge number of steps).

urfisch
06-22-11, 04:26 AM
this is great news...

:up:

h.sie
06-22-11, 05:33 AM
Unfortunately, currently I have very little free time for modding, although it's getting interesting now. I'll report about any further progress in the Gameplay-Related Hardcode Fixes-Thread.

Magic1111
06-22-11, 05:59 AM
I'll report about any further progress in the Gameplay-Related Hardcode Fixes-Thread.

Thatīs an good Idea ! :up: All the best for your work in this progress ! :D

Best regards,
Magic

Hitman
06-22-11, 09:27 AM
Please allow me to get back to the basics, i.e. getting the game to identify whatever we create as pseudo-uboat as a submarine and attack it correspondingly.

A question/brainstorming now for all of you advanced modders:

Is it possible to assign to the Uboats in the pack the same category as the human player? I mean, can we somehow trick the AI into believing it is attacking SEVERAL human players?

Please note that it actually does that in multiplayer :hmmm:

The AI must therefore be prepared to recognize multiple submarine targets, attack all of them, and even priorize which one it will attack first or which escort/s it assigns to that task.

We would make a huge step forward if H.Sie could overwrite the ID of the AI Uboats in the memory when they spawn, and let the AI identify them as multiplayer humans.

The 2nd part would then be creating/assigning a better AI to the new "human" UBoats. But let that come later.

h.sie
06-22-11, 11:14 AM
@Hitman: I think your approach is a good one and much better than my current approach (teleporting Sergbutos Subs to the convoy after contact report).

BUT: With my current restricted knowledge of the sh3.exe code, I see NO chance to add new AI behaviour. So far, it was a good strategy for me not to overestimate my ability.

This is the reason why - at the moment - I prefer LGN1's idea, which could bring a solution in some weeks / months. And maybe, with more experience, a better solution is possible. 10 months ago, I wasn't even able to fix longer repair times. Now, 10 months later.....look at the long list of fixes....it was a good evolution, so maybe in the future time will come for new AI.

BUT: You talked to all modders, not only to me. Maybe another guy has better ideas to get a better solution for an Submarine AI. Anvart? TWD? Stiebler? privateer? I don't know about their ideas!

h.sie

h.sie
06-22-11, 11:35 AM
Addition: LGN1's idea has one advantage: It is possible. And it's not that bad: His idea in short words:

If you encounter a convoy, you have to measure its speed and course. Due to low GUI ressorces, the player has to put his measurements into the TDC dials. Then he presses "contact report": So, course and speed are transmitted to BDU.

For the BDU, an AI must be programmed: In which areas are wolfpacks available? during which time periods? some randomness......

Then, with a certain chance BDU answers: "Wait and continue contact reports" or "attack" or similar.

Depending on the convoy speed and course, some (1-4) Sergbuto Subs are teleported to the position the convoy is expected. There they wait for the convoy. They will deviate the escorts and sink some ships.

I see a chance of 25% that this idea can be done, but lower than 5% (ATM) to add new Sub-AI.


What about changing the escorts AI so that they react on Sergbutos Sub as real subs and not as surface ships??

Then we have all we need?

It's much easier to change existing behaviour that to add completely new things

Hitman
06-22-11, 12:23 PM
What about changing the escorts AI so that they react on Sergbutos Sub as real subs and not as surface ships??

Actually that is what I proposed, i.e. to trick the Ai into believing that they are other human players, using whatever reference or labelling is used in multiplayer ;)

h.sie
06-22-11, 04:34 PM
what exactly is the function of the "contact report" button? how does it work? only thing I know: if airbase is close: aircraft will come. any other functionality?

LGN1
06-23-11, 06:51 AM
Hi,

great work, h.sie! :up:

Just a few comments:

- I think there are two issues. One is getting a unit somewhere depending on the player's action, the other one the AI behavior of the unit. These two issues are independent and should be treated independently.

- I simple solution for the wolf-packs' positions and time frames would be to check the player's position and the current date. If the date is between a certain start- and end date (e.g., some month in '41 and mid '43) wolf-packs are possible. For the position you could define a rectangular containing the North- and Middle-Atlantic in which wolf-packs are possible (similar to the concept I have used for my zig-zagging script, see here for some coordinates: http://imageshack.us/photo/my-images/510/perlscriptopt.jpg/ ).

- I think the contact report message has two purposes: First, there is a chance of a friendly air attack if a base is near-by and second, there is a chance of an enemy air attack if a base is near-by (see airstrike.cfg in data/cfg). I don't know for sure, but I think if you are spotted by an enemy plane the convoy's escorts are also alerted.

- You can send a status report every two hours, but a contact report only every 12 hours. BDU orders were to send contact reports every 1 hour, IIRC (you can check the original submarine commander's handbook for the reporting orders, see below).

- As an incentive for the player to shadow convoys, it might be a good idea to give renown points for sending contact reports. At least for players using mods with the renown system (not NYGM) it would be nice.

Cheers, LGN1

Submarine commander's handbook:

http://www.hnsa.org/doc/uboat/index.htm

314.)

a) The essential contents of the reports must always be: Position, course, and speed on the enemy. Type, strength, and distribution of the enemy covering forces, and the state of the weather should be reported later to supplement these messages. Attention should be paid to the conditions of visibility and the resulting possibilities of error in estimating the distance for the reports on the position of the enemy.

b) Try to ascertain the general course of the enemy as soon as possible, from the reckoning, and report it as such (see Section II, B, No. 115).

315.) While carrying out its own attack, the submarine must transmit regular and complete contact reports, according to the following headings:

a) The two first boats to make contact, acting as "contact holders," transmit complete hourly reports.

b) As long as the two first boats transmit contact reports, the other boats signal "made contact!" once only, as soon as they have reached the convoy, or, analogously, "lost contact!", using short signals in both cases.

c) If a "contact holder" fails to send reports for longer than 1 hours, another boat must take over. This must be done without waiting for orders.

d) If a "contact holder" loses contact, it must report as soon as possible the last position of the enemy, and his course and speed.

e) All boats which have been in contact with the convoy, and lost ground in consequence of their long stay underwater, or have been driven off, must also report their own position.

316.) The "contact holders" also operate as is best for the purposes of their attack. Do not endanger your own overhauling maneuver, and the success of the attack, by approaching too close, in order to obtain (more) accurate firing data.

317.) The arrangements for guiding further submarines to the spot are greatly facilitated by the emission of D/F signals by the submarine maintaining the contact. At intervals of half an hour, the "contact holder" sends out D/F signals and a wireless signal, on a long wave-length fixed by Headquarters, defining the D/F and the distance from the enemy, according to "Standing War Orders for Submarine Commanders" ("St.Kriegsbor.B.d.U."), either at the request of other submarines, or on orders of the "Home Submarine Command," or, in certain circumstances, on its own initiative, if such orders are not received in time, and there is reason to believe that there are other submarines about. If the commander decides to send out D/F signals on his own initiative, the other submarines should first be notified by means of a wireless message or signal on the submarine's short wave.

318.) The transmission of D/F signals, however, always creates an additional danger that the "contact holder" will be spotted; consequently:,
a) Do not ask for D/F signals if dead reckoning and visibility are good.
b) Ask for D/F signals if the dead reckoning is wrong, visibility is very bad, or if nothing is sighted on the computed point of contact ("erkoppelter Treffpunkt").

SquareSteelBar
06-23-11, 06:59 AM
what exactly is the function of the "contact report" button? how does it work? only thing I know: if airbase is close: aircraft will come. any other functionality?http://www.subsim.com/radioroom/showpost.php?p=1689361&postcount=1589