Author Topic: FH2 AIBehaviors Unofficial Recode  (Read 1817 times)

Offline Void

  • Moderator
  • ***
  • Posts: 162
  • AI Dev
    • View Profile
    • ESAI at Moddb
FH2 AIBehaviors Unofficial Recode
« on: 10-05-2011, 20:05:45 »
Be warned, this post is long and technical, but you will find a d/l link at the end of it.

I've recently revisited this project, and made some minor tweaks to the rewrite I did a few months ago. The official FH2 2.3 AIBehaviors.ai file has some strange issues. I can't definitively call them mistakes, I can only say that some things I found were highly irregular. I will qualify that statement with an example:

Tank Fire behavior entry from original:

Code: [Select]
aiSettings.setVehicleBehaviour Tank Fire BBFireInfantery BBPFireInfantery 4 UCFire TankWeights
This causes the urgency for the tank fire behavior to reach an unreasonably high value (in excess of 90 in some instances, where 5-8 is sufficient to make it the active behavior)

Tank Fire behavior from my recode:

Code: [Select]
aiSettings.setVehicleBehaviour Tank Fire BBFireInfantery BBPFireInfantery 4 UCTankFire UnitWeights.

The main correction here is the use of UnitWeights instead of TankWeights. Observant readers will also notice the change of urgency curve generators (from UCFire to UCTankFire). This was not strictly necessary, but is an enhancement I coded in. It seems to help keep the tanks moving as they shoot. Seems to - I am not sure.

There are a host of other changes, but they are made in such a way that the bots should show similar behaviors to that created by the official file. You should see minor bot behavior improvements if you use this file, though the differences are subtle.

Here is a full list of the changes I made, taken from the code comments:
Code: [Select]
       Forgotten Hope 2.x AIBehaviors Recode                   
                 Version 2.4 :5-10-2011
                     by Void

 Featured Changes from 2.3 Official:

- soldier weights now unique to `Infantery`

- unit weights corrected and reinstated as behavior inhibitors

- avoid inhibitors corrected and reinstated as behavior inhibitors

- change inhibitors corrected and reinstated as behavior inhibitors

- base Idle urgency now 0.1

- custom inhibitors for `Tank` Fire && Move behaviors (also applied to `ArmedCar`)

- custom UC generator for `Tank` Fire behavior (also applied to `ArmedCar`)

- unarmed `Passenger` Fire weight now 1.0 (was much higher, but here this number is used only to calculate urgency of the Change behavior)

- `Car` vehicle type now more likely to try and run over enemies

- Added LookAtWrapper interpreter entry to ALL vehicle types. If you decide to code a vehicle of any type
  to target aircraft for some reason, this should prevent CTD.

The addition of the LookAtWrapper interpreter entry to all vehicles is not strictly necessary, but since it hurts nothing I went ahead and put it in. (If you are not familiar with the LookAtWrapper bug, search for it on the BFSP forums. It is well documented)

Ok then, interested parties may Download it here

Offline djinn

  • Masterspammer
  • ****
  • Posts: 5.723
    • View Profile
Re: FH2 AIBehaviors Unofficial Recode
« Reply #1 on: 10-05-2011, 22:05:15 »
If I recall correctly, because this was me calling for changes back then too, the tanks were tweaked specifically to NOT always shoot on the move as was the case in vanilla. This was because tanks moved way faster than infantry, and so infantry were left behind.

With this tank motion, armor now fired and kept stationary, moving in for a better shot or after the enemy was dead. This allowed infantry to be the main attack force, idealy moving ahead of the armor with the armor given it cover...

However, as it was implemented by a coder who is now no longer part of the dev team, Leagion_X and later Leagion_FH, his code has become a ghost in the machine, having been somehow altered along the line by WinterHilf, later Drawde, and later, I think, Remick04.... He came back recently and admitted not quite recognizing his code from the way he had done it....


about the LookAtWrapper bug, could that be why we sometimes get random CTDs that can't be placed to any particular map? And I need to verify this, is it because bots fire at aircrafts? Does your patch fix it? And where do the patch files go. I actually want to try this and see....


So making tanks fire on the move at all times might not be the way to go - If however you CAN perfect the tactic... *rubs hands together and grins evilly*.. because now, somehow changed after his time, tanks don't maneuover around obstacles as well as they used to. On Goodwood this is a distaster since German tanks will NEVER get across the railroad successfully enough to engage their allied counterparts coming off in trickle that are easily wiped out. Once upon a time, the German counter-offensive led by the King Tiger could push the allies all the way back to their base, making Goodwood a terrific close-quarter AND armor battle - Now, its only the former..*hint, hint*


You might also note that heavy armor (i think, or medium... not sure which) is classified as a helicopter. This was to basically make use of a class that probably will never get used, to make the distinction in armor class so that later different ammo types could be used by bots depending on which armor they encountered.... rather than firing useless regular shells at much heavier tanks. Also was to make bots use smoke shells when they encounter superior armor... Also for the future, as the coder (Drawde) is no longer working with us :(
« Last Edit: 10-05-2011, 22:05:13 by djinn »

Offline Void

  • Moderator
  • ***
  • Posts: 162
  • AI Dev
    • View Profile
    • ESAI at Moddb
Re: FH2 AIBehaviors Unofficial Recode
« Reply #2 on: 11-05-2011, 00:05:45 »
Quote
If I recall correctly, because this was me calling for changes back then too, the tanks were tweaked specifically to NOT always shoot on the move as was the case in vanilla. This was because tanks moved way faster than infantry, and so infantry were left behind.

I should like to emphasize that while the code changes are major, the manifest changes to bot behavior are minor.

The code example I showed above doesn't really make tanks shoot on the move much more often, rather it seems to help a bit with bot accuracy when they do shoot on the move. And like I said, I'm not sure it is even enough of a difference to be noticeable.

Quote
about the LookAtWrapper bug, could that be why we sometimes get random CTDs that can't be placed to any particular map? And I need to verify this, is it because bots fire at aircrafts? Does your patch fix it? And where do the patch files go. I actually want to try this and see....

It easily could be. If it is related to the LAW bug, you should see an error msg pop up in windowed mode. I don't recall the exact message, but I believe it does contain the text "LookAtWrapper".

The crash does happen when a bot (in whatever vehicle) targets an aircraft - the AITemplate's Armament plugin would contain the line "setIsAntiAircraft 1" , and said vehicle does not have an interpreter entry for LookAtWrapper. This AIBehaviors file would fix that specific crash, yes.

I did notice that the Planes were missing this interpreter entry, and I believe they are coded to attack other aircraft. This could be the issue; I'm not sure. If it was an issue, then I've fixed it.

There are no "patch files" as you are thinking - the fix is simply part of the AIBehaviors.ai file I posted. You need only download that, and put it in the main fh2 \AI folder. Back up your original file first....I guess.

BTW:

The FH2 Mod has my official permission to use this code for any purpose they deem fit, to create and use derivative works based from it, and to remove my handle from the code comments. I don't need or want credit for the thing, but here it is in case it proves useful.


« Last Edit: 11-05-2011, 00:05:26 by Void »

Offline Devilman

  • I belong to Naughty Club
  • **
  • Posts: 274
    • View Profile
Re: FH2 AIBehaviors Unofficial Recode
« Reply #3 on: 13-05-2011, 10:05:06 »
@ Void
you may also want to run FH2 through the debugger and fix the several AI errors that pop up
such as below for example

typo





Offline Void

  • Moderator
  • ***
  • Posts: 162
  • AI Dev
    • View Profile
    • ESAI at Moddb
Re: FH2 AIBehaviors Unofficial Recode
« Reply #4 on: 13-05-2011, 10:05:31 »
You are not saying that was caused by my file?

Fixing typos from individual AI Templates would take me away from the ESAI project.

Offline Devilman

  • I belong to Naughty Club
  • **
  • Posts: 274
    • View Profile
Re: FH2 AIBehaviors Unofficial Recode
« Reply #5 on: 13-05-2011, 11:05:10 »
You are not saying that was caused by my file?

Fixing typos from individual AI Templates would take me away from the ESAI project.

the typo was already in FH2 (which there is only 1)
The other errors mainly refer to missing or faulty plugins

Offline Void

  • Moderator
  • ***
  • Posts: 162
  • AI Dev
    • View Profile
    • ESAI at Moddb
Re: FH2 AIBehaviors Unofficial Recode
« Reply #6 on: 13-05-2011, 20:05:56 »
Quote
The other errors mainly refer to missing or faulty plugins

I think this is a matter best left to the official FH2 devs.

 Honestly, if I somehow knew that my fixes were going to be used by the team then yeah - I would probably be willing to wade through all the AI errors and fix them. As it is, doing that would just be a huge time sink for me, and would only benefit a handful of users.

Edit 5/15/11

I have to eat those words now, since I have started working anyway on FH2 AI bug fixes.
« Last Edit: 16-05-2011, 05:05:12 by Void »