Ormand
Posts: 682
Joined: 2/17/2009 Status: offline
|
This can be done, but does require modifying events. I made a variant for the 4Seasons-Models that does just this. There are aspects of the system that I don't quite understand as they are probably in the engine. In a nutshell, here is how the AI makes factories. Notice RegimeVar#15, which is "AI factory points". When the value of this RegimeVar >= 4000 for an AI regime, the AI will build a factory. I tend to think that this specific RegimeVar and value are hard-coded. In the A "New Dawn" scenarios, event #14 "All turns: AI build points rising" controls the rate that RegimeVar#15 increases each turn. It is based on the production the current regime has through CheckRegimeProducingProductionPoints(regime#). Basically, it adds this number divided by 100 to RegimeVar#15 every turn (with bounes for AI+ and AI++). You can use this event to control how quickly the AI reaches 4000 points. For example, I basically divided this number by the current number of factories+1 in the regime. So, once the AI built one factory, the rate would be 1/2 as fast. There are many options. Once the AI can build a factory, it has to decide which factory. This is controlled via the event specified in the LocType definition under the tab "AI autobuild". This is the "AI Prio Mod Event", which in "A New Dawn" is event#15. Event#15 actually just returns a random number to the engine via the function SetCardXY. Exactly how, I am not sure. But, functionally, what happens is that the engine cycles through the LocTypes that are set to "AI Can Free Build = True" and the one with the largest random number is built. After the LocType is built, it calls the event specified in "AIAfterBuildEvent", which in "A New Dawn" is Event#16. All this does is to reduce RegimeVar#15 by 4000. You can probably control the probability for which factory type via RegimeVar variables. I believe the engine cycles through the AI buildable LocTypes, so you can make a counter, and also store the number of each type of factory in a RegimeVar. Thereby writing code to control probabilities based on what is built. You could also give regime weights, say favoring artillery, etc. These would all be variables that you store in a RegimeVar. Lastly, you can change whether a LocType can be built with the function ExecLocTypeBuildable(LocType#,0(1)). I used this to make a variant of a scenario so that factories couldn't be built. You could use this to stop an AI regime from building factories after a certain number.
< Message edited by Ormand -- 12/21/2016 9:33:38 AM >
|