AI Resource Bonus
Posts: 59
Posts: 139
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.
Posts: 3421 | Subs: 11
Posts: 59
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?
Posts: 139
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.
Posts: 59
Posts: 139
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.
Posts: 59
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?
Posts: 139
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.
Posts: 59
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.
Posts: 139
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:
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:
-- 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.
Posts: 59
Posts: 139
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.)
Posts: 59
Posts: 59
Posts: 139
Also, they have to have your mod too. (Edit: "I think".)
Livestreams
77 | |||||
31 | |||||
29 | |||||
16 | |||||
11 | |||||
1 | |||||
655 | |||||
14 | |||||
1 |
Ladders Top 10
-
#Steam AliasWL%Streak
- 1.653231.739+13
- 2.838223.790+1
- 3.35057.860+15
- 4.590233.717+6
- 5.278108.720+29
- 6.306114.729+2
- 7.645.928+5
- 8.922406.694+1
- 9.1118621.643-1
- 10.265138.658+2
Replay highlight
- cblanco ★
- 보드카 중대
- VonManteuffel
- Heartless Jäger
Board Info
2 posts in the last week
28 posts in the last month
Welcome our newest member, KETTA
Most online: 2043 users on 29 Oct 2023, 01:04 AM