Login

russian armor

AI Resource Bonus

29 Mar 2015, 07:15 AM
#1
avatar of TheChosenOne

Posts: 59

Is it possible like in the first CoH to adjust or turn off the AI Resource Bonus? I like the challenge of the harder difficulties just hate the "cheating" mechanic the AI has.
29 Mar 2015, 21:04 PM
#2
avatar of trigg

Posts: 139

You could make a Win Condition mod with a script that iterates over the players and makes and adjustment if the player isn't human.

However, I'm not sure how much harder the "harder difficulties" would be without a resource boost. There's not a lot of intelligence in the AI's play.
29 Mar 2015, 21:13 PM
#3
avatar of Janne252
Admin Black Badge
Patrion 15

Posts: 3421 | Subs: 11

Harder AI difficulty is for example more aggressive. Easy AI won't do anything for a while after capturing 1 or 2 territory sectors.
30 Mar 2015, 21:31 PM
#4
avatar of TheChosenOne

Posts: 59

jump backJump back to quoted post29 Mar 2015, 21:04 PMtrigg
You could make a Win Condition mod with a script that iterates over the players and makes and adjustment if the player isn't human.

However, I'm not sure how much harder the "harder difficulties" would be without a resource boost. There's not a lot of intelligence in the AI's play.


Well, would you kindly walk me through how I would edit the Win Condition?
31 Mar 2015, 06:52 AM
#5
avatar of trigg

Posts: 139

Do you need to start with how to make a Win Condition, or just with the script modifications?

p.s. - Tomorrow I may be busy testing and fixing my existing stuff with the March release, so don't be alarmed if I don't respond for a couple of days.
31 Mar 2015, 07:00 AM
#6
avatar of TheChosenOne

Posts: 59

Which ever allows me to edit the resource bonus the AI gets.
1 Apr 2015, 05:13 AM
#7
avatar of trigg

Posts: 139

Start by reading Janne252's guide "Modding: Getting started with the official tools" in the Guides section here at coh2.org. Follow the instructions for installing and configuring the tools.

In the next section, "The first mod", we diverge from those instructions at Figure 5 - you want to pick WinConditionPack instead of PropertyBagGrouopPack. However, go ahead and read that section before you start, for a suggestion on what directory to create for your mod(s) and what kind of image to create if you want a preview image. (If you are going to publlish your mod, a preview image will make it look much more professional. Just use a screenshot if you're not an artist.)

Also, decide on a name for the mod. For this example I will call it "No Cheating AI WC".

Now, do everything through Figure 5, except tell it you want to make a win condition instead of a pbg. The wizard that pops up will look a little different, and here is what you need to do for each field:

Mod file: Click the button with three dots. In the pop-up, navigate to the directory you created to hold your mods,type in the file name no-cheatin-ai-wc.mod, and press Save. It will create a default file for you, which we can talk about later.

Name: Enter "No Cheating AI WC", without the quotes.

Preview Image: If you made a preview image, put it in the directory you made for the mod, and use the "..." button to find it and add it. If you're skipping the image, just skip this field entirely.

Win Condition File: Do just like for Mod File, exept call it .win

Scar File: Ditto, except call it .scar

Leave the box at the bottom unchecked to create an annihilation mod. (If you want a VP mod, we'll have to experiment because I haven't done that yet. Presumably checking the box causes it to create different starting files for you.)

Click 'OK' and it will close the wizard.

Back in the mod builder, drag the horzontal line near the bottom up until it's just below the "data" and "info" folders at the top. If you don't do this you won't see all the output, and your build might fail without you being able to see that it did, or why.

Use the Build menu to build it, and make sure it does not show any errors. Start the game, create a skirmish, and make sure you can see your mod in the Win Condition options. Actually start a game. You won't see anything interesting yet, but that will tell you that everything is working.

Once you get that far, post again that you got there OK, and we'll talk about the intersting part - editing the script to make the changes you want.
3 Apr 2015, 02:13 AM
#8
avatar of TheChosenOne

Posts: 59

jump backJump back to quoted post1 Apr 2015, 05:13 AMtrigg
Start by reading Janne252's guide "Modding: Getting started with the official tools" in the Guides section here at coh2.org. Follow the instructions for installing and configuring the tools.

In the next section, "The first mod", we diverge from those instructions at Figure 5 - you want to pick WinConditionPack instead of PropertyBagGrouopPack. However, go ahead and read that section before you start, for a suggestion on what directory to create for your mod(s) and what kind of image to create if you want a preview image. (If you are going to publlish your mod, a preview image will make it look much more professional. Just use a screenshot if you're not an artist.)

Also, decide on a name for the mod. For this example I will call it "No Cheating AI WC".

Now, do everything through Figure 5, except tell it you want to make a win condition instead of a pbg. The wizard that pops up will look a little different, and here is what you need to do for each field:

Mod file: Click the button with three dots. In the pop-up, navigate to the directory you created to hold your mods,type in the file name no-cheatin-ai-wc.mod, and press Save. It will create a default file for you, which we can talk about later.

Name: Enter "No Cheating AI WC", without the quotes.

Preview Image: If you made a preview image, put it in the directory you made for the mod, and use the "..." button to find it and add it. If you're skipping the image, just skip this field entirely.

Win Condition File: Do just like for Mod File, exept call it .win

Scar File: Ditto, except call it .scar

Leave the box at the bottom unchecked to create an annihilation mod. (If you want a VP mod, we'll have to experiment because I haven't done that yet. Presumably checking the box causes it to create different starting files for you.)

Click 'OK' and it will close the wizard.

Back in the mod builder, drag the horzontal line near the bottom up until it's just below the "data" and "info" folders at the top. If you don't do this you won't see all the output, and your build might fail without you being able to see that it did, or why.

Use the Build menu to build it, and make sure it does not show any errors. Start the game, create a skirmish, and make sure you can see your mod in the Win Condition options. Actually start a game. You won't see anything interesting yet, but that will tell you that everything is working.

Once you get that far, post again that you got there OK, and we'll talk about the intersting part - editing the script to make the changes you want.


Alright, followed your instructions down to a Tee. What be the next steps?
3 Apr 2015, 06:39 AM
#9
avatar of trigg

Posts: 139

Great! Now, do you want to make the minimal possible change, or do you want to set it up to offer several variants? For example, offering different amounts of AI resource reduction?

Also, do you want to use the same reduction for all four AI levels?

While you're waiting for me to see your reply, go ahead and look at the three files it made for you. You can open them with a text editor. The .mod is really a .xml, the .win is some program-like text that they probably parse with custom code in the game, and the .scar is a script written in Relic's variant of the lua scripting language. All we'll need to change is the script, but you might as well take a peak at the others. If you want to go minimalist we'll just add some stuff near the end of the script file, or if you want to go fancy we'll add some new files.
3 Apr 2015, 10:19 AM
#10
avatar of TheChosenOne

Posts: 59

jump backJump back to quoted post3 Apr 2015, 06:39 AMtrigg
Great! Now, do you want to make the minimal possible change, or do you want to set it up to offer several variants? For example, offering different amounts of AI resource reduction?

Also, do you want to use the same reduction for all four AI levels?

While you're waiting for me to see your reply, go ahead and look at the three files it made for you. You can open them with a text editor. The .mod is really a .xml, the .win is some program-like text that they probably parse with custom code in the game, and the .scar is a script written in Relic's variant of the lua scripting language. All we'll need to change is the script, but you might as well take a peak at the others. If you want to go minimalist we'll just add some stuff near the end of the script file, or if you want to go fancy we'll add some new files.


Ok, Everything appears to check out. Basically all I want is to zero out the Resource Bonus the AI gets at Hard and Expert. I don't really bother with the Normal or Easy AI in matches. Essentially all I want is to make it so the AI has the same resource income as players do at the start of the game. Nothing too fancy.
4 Apr 2015, 00:28 AM
#11
avatar of trigg

Posts: 139

OK, we'll keep it simple, and you can elaborate it later if you wish.

I don't know how much cheat the AI gets, so for this example I'll guess it at +50% for the hard AI and +100% for the expert AI, and multiply their rates by 0.67 and 0.5 respectively, to set them back to normal. I think you can get the actual number by playing a comp stomp, then looking at the AI's resource incomes vs. yours at the very beginning of the game.

We will modify the .scar file by adding some code near the bottom. The last few lines should look like this, except for the three asterisks I am adding to show where we're going to put the new code:
Code
local function WinCondition_Init()
Rule_AddInterval(WinCondition_Check, 3)
***
end

Scar_AddInit(WinCondition_Init)

Don't add the asterisks. If you want to know what all the functions do, search the web for coh2 updated scar documentation.

Here is the code we will add. Anything after two dashes is a comment. I'm reducing the indentation to three per level of depth instead of their 8-character tab, to minimize the amount of wrapping you see when you read this:
Code
-- My Stuff: ------------------------------------------------------------------
for p = 1, World_GetPlayerCount() do -- iterate over all the players
local player = World_GetPlayerAt(p) -- get more information about this player
if (AI_IsAIPlayer(player)) then
if (AI_GetDifficulty(player)==AD_Hard) then
Modify_PlayerResourceRate(player,RT_Manpower,0.67,MUT_Multiplication)
Modify_PlayerResourceRate(player,RT_Munition,0.67,MUT_Multiplication)
Modify_PlayerResourceRate(player,RT_Fuel,0.67,MUT_Multiplication)
end
if (AI_GetDifficulty(player)==AD_Hardest) then
Modify_PlayerResourceRate(player,RT_Manpower,0.5,MUT_Multiplication)
Modify_PlayerResourceRate(player,RT_Munition,0.5,MUT_Multiplication)
Modify_PlayerResourceRate(player,RT_Fuel,0.5,MUT_Multiplication)
end
end -- loop over all the players
-- End of My Stuff. ----------------------------------------------------------

All that should be where the three asterisks are in the first example. The different indentation doesn't matter, so you can just paste it in.

I haven't ever used AD_Hardest, but that's what the documentation says. Sometimes it's out of date, so if it gives an error my first guess would be AD_Expert for CoH2.

Save the file and rebuild your mod. (Notice that 'build' only works the first time; now you have to 'rebuild', or else 'clean' it first.) You shouldn't get any errors, because the code is not processed at this step, but make a habit of checking for errors anyway.

Now run the game using your mod. If there is an error in the code the game will pause at the very start, and it will say something like "fatal scar execution error - game paused" in the middle of the screen. If it does that, open the console and scroll up to find where it tells what line number in the code it didn't like. Then you'll have to find that line number in your code, counting blank lines as well as code and comments. We'll talk more about that if it happens.

Play the game and see if it feels right. I tried the x0.67 for the hard AI last night, and it really cut back on the AI's bombardments. Or if you don't want to go by feel, play a complete game and look at the AI income rates in the replay as compared to your own.

Let us know how it works.
4 Apr 2015, 01:44 AM
#12
avatar of TheChosenOne

Posts: 59

Thanks man, I never worked with the .scar coding before. It's all pretty new to me. Really appreciate the help.
10 Apr 2015, 11:16 AM
#13
avatar of trigg

Posts: 139

For the record:

I added some debug code to one of my WC mods, and as expected the AI gets increasing resource incomes as you go up from Easy to Expert. Standard gets the same as a human player.

A couple of quirks:

There isn't an increase in munitions between Standard and Hard. I found that surprising, given how busily it will hit you with air raids.

The internal rates are per second rather than per minute, so they are all floating point values. There is a surprising amount of noise between the individual player's values - nothing significant (except per below), but more than you would expect from fp accuracy issues.

For Expert only, the AI on one team may get 5%-10% more income than the same AI on the other team. Sometimes swapping factions makes the difference go away. I have not been able to pin down exactly what is causing the effect.


I put out a "Slugfest Special" option for my infantry emphasis game mode, which among other things neutralizes the AI cheat rates by multiplying them by the individual AI player's human/AI starting rate ratio. (This makes most of the noise go away, but surprisingly doesn't fix the variations in the Expert AI's rates. Something strange is going on there.)
13 Apr 2015, 21:12 PM
#14
avatar of TheChosenOne

Posts: 59

Thanks for the info. I'm not sure either.
14 Apr 2015, 22:52 PM
#15
avatar of TheChosenOne

Posts: 59

Ok so I came across a problem. The game runs fine single player. But when others join the game just freezes at the beginning.
15 Apr 2015, 07:14 AM
#16
avatar of trigg

Posts: 139

Look at the console and see if there's an error message relating to the script.

Also, they have to have your mod too. (Edit: "I think".)
2 users are browsing this thread: 2 guests

Livestreams

unknown 14
Germany 1

Ladders Top 10

  • #
    Steam Alias
    W
    L
    %
    Streak
Data provided by Relic Relic Entertainment

Replay highlight

VS
  • U.S. Forces flag cblanco ★
  • The British Forces flag 보드카 중대
  • Oberkommando West flag VonManteuffel
  • Ostheer flag Heartless Jäger
uploaded by XXxxHeartlessxxXX

Board Info

609 users are online: 609 guests
1 post in the last 24h
7 posts in the last week
39 posts in the last month
Registered members: 49060
Welcome our newest member, starkindustries
Most online: 2043 users on 29 Oct 2023, 01:04 AM