Understanding the "Balance MOD" Research Path



    We start with understanding research where the AI would start at, with the "Set_Race_Research_Spending" function under the "MAIN_SCRIPT.TXT".  Here the script gets the current research points for the empire.  Then it makes a research modifier with that number divide by 10,000.  That number will be max. out at 15, and will be used as a percent.  Next 4 main tech groups will be addedto a list called "lst_Research_Spending_Group_Name".  These 4 tech groups are as follows:

  • Cultural Advancement
  • Theoretical Science
  • Applied Science
  • Weapon Tech

After that the AI State is used to determine the based research spending amount, in percent, for each tech group.  And finally the priority level is set based on the number of wars the empire is current in.

    Next, the script goes to the "Set_Race_Research_Areas()" function.  This covers what weapon tech areas that the AI will research. It start with the early game weapons and then goes on to the most advance weapons  tech areas.  Before adding the tech area to the research list, the script check to see if the tech area is available, and that a enemy has not counter it yet.  If every thing is "True" then the tech area is added to "lst_Research_Tech_Area_Name" list.  As well as the max level of the tech area to be research is added to the "lst_Research_Tech_Area_Max_Level" list.

    After that section the script go to the "AI_research" under "SCRIPT_AI_RESEARCH.txt".  Here the script checks to see if the AI Minister is being used.  If "FALSE" the script ended there for research.  But if "TRUE" the script cont. on to the next function.

    Now the script cont. on to the "Add_Research_Items" function.  This function start with clearing the previous research spending.  Then it checks to see if the AI is in a "AI_STATE_NOT_CONNECTED" state.  This state is the only state with its own research tech areas request.  Inside this function are listed all the tech areas the AI will research.  This list is broken up into ages, which is mainly used to set max tech level limits in that age.  The value "lng_Research_Age_Max_Level" is what the script uses to set this max.  Further each age is divided up between the tech group in the following order:

  • Cultural Advancement
  •  Theoretical Science
  •  Applied Science
  • Weapon Tech

While the script goes down the tech list, it calls on a function.  With each call of the function 4 values that are sent, they are the following:

  • The tech area
  • The level the script is to research that tech area to.
  • Priority level of the tech area.
  • A Boolean value, which tells the AI if it needs to research that tech.
       

    "Add_Tech_Area" is the function called for while the script goes down the tech list.  Now first the function checks for all the following:

  • If the boolean value sent to it was "TRUE".
  • Check Priority level of the tech area to ensure it is >= the AI's current research Priority level.
  • Final that the game is not a max tech game.

Next the script checks to see if the tech area is visible, and if the tech area is not already at that level.  If both are TRUE then a value is setup to take the minimum value of the following 2 numbers:

  • The tech group value call on by "Get_Tech_Group_Spending_Pct" function.
  • Value needed to get to the next level.


Then it tells the AI to research the tech area and set the percent to research by using the above value.  With that number the process of setting the AI to research that tech area is done.  Afterward the script calls on "Set_Tech_Group_Spending_Pct" to remove the percent points used to research that tech area.

    Now had the Tech area not been visible above, then the following would have been done instead.  To start with, a function "Get_Required_Techs_For_Tech" would be called.  This function is a list of all tech area in the game with their perquisite tech area and level.  Here the current tech area gets the perquisite tech and level, and return it back to the called function.  Then the function checks to see if it can see that tech area.  If not then it stop trying to research this tech and goes back to the "Add_Research_Items" function.  If TRUE, then another minimum value is set up:

  • Level needed by the perquisite to allow for the first tech.
  • The "lng_Research_Age_Max_Level" value.

After that the function treats the perquisite tech the same as the original tech in telling the AI to research. 

    While the script is going down the tech list the weapon tech area sections it will call on a function.  This function is "Add_Wanted_Tech_Areas_For_Designs", and the value it sent with it is the max level limit.  Its with this function that the weapon tech areas, in the "Set_Race_Research_Areas()" function, are used.

    Lastly the script goes back to "Add_Research_Items" function.  And then the function checks to see if any points are left, and if so calls on "Add_Tech_Area_By_ID".  From there the points are given to each tech area to used up the rest of the research points.

 

FAQ ________________________________________________________________________

 

Add New Weapon Tech area
-----------------------------------------
1. Add tech area and level values to function "Set_Race_Research_Areas()" in "..._Main_Script.txt" where other tech are located.
   This is so that the weapon you want the race to use is given some priority in research.  Also remember the script starts with the early weapons tech areas and go on to the advance and special weapons tech areas.  You may need to use if statement with the value. 

          call lst_Research_Tech_Area_Name.add("Projectile Weapons")
          call lst_Research_Tech_Area_Max_Level.add(11)
 


2. Remove any unwanted weapons tech area. 


3. Add tech area to function "Get_Required_Techs_For_Tech()" in "Script_AI_Research.txt" and function "Get_Required_Techs_For_Tech()" in "Script_AI_GlobalResearch.txt".  Here is where the perquisite tech, and need levels, are listed for the Tech area. 

            "Projectile Weapons"            
                 set tech_name := "Ion Engines" 
                 set tech_level := 3
 
   

 4. Now go to "Main()" in "..._Setup_Script.txt" and add the value in the following format.  Now Here the values are setup as a list with the early leading into advance weapon.  Remember to use the same order you used in the "Set_Race_Research_Areas()" in "..._Main_Script.txt".  Also "AGE" are used, so watch the levels of the tech areas.   Becauses of the "AGE" used you may have to list the tech area several time.

 

            call AI_Set_Age_Research(1)
            call Add_Tech_Area("Projectile Weapons", 3, TRUE) 
            call Add_Tech_Area("Missile Weapons", 3, TRUE)  

            call Add_Tech_Area("Torpedo Weapons", 1, TRUE)  

  • Tech Area
  • Level
  • Determines if this Tech area is research or not(T/F), sometimes a value


Add Current Weapon Tech area
-----------------------------------------
1. Add tech area to function "Set_Race_Research_Areas()" in "..._Main_Script.txt" where other tech are located.
   This is so that the weapon you want the race to use is given some priority in research.  And remember weapons start with the early weapons tech areas and go on to the advance and special weapons tech areas.


         call lst_Research_Tech_Area_Name.add("Projectile Weapons")
         call lst_Research_Tech_Area_Max_Level.add(11)
 

2. Remove any unwanted weapons tech area.

 

Add New Non-Weapon Tech area
-----------------------------------------
1. Consider adding Bol (T/F) value to function "Set_Race_Script_Values()" in "..._Main_Script.txt" where other like values are located.
   This value allow a race to research/use the tech in the game.  If not setup here then all races will research the tech area.

         set bool_Race_Uses_Mines                                           := TRUE

         -Used to tell the AI to use and research mines in the game.


2. Add tech area value to function "Add_Research_Items" in "Script_AI_Research.txt" and function "AI_Set_Age_Research ()" in "Script_AI_GlobalResearch.txt".   This is a list of the tech areas the AI will research and in what order.


         call Add_Tech_Area("Mines", 6, RESEARCH_PRIORITY_CRITICAL, bool_Race_Uses_Mines)

  • Tech Area
  • Level
  • Determines if this Tech area is research or not(T/F), sometimes a value

       - Determines if this Tech area is research or not(T/F), sometimes a value
   Place the value in the list in order by which you would want the tech area to be research.
   Remember that the list uses "ages" to set an upper limit on research levels in that age.
   This may require you to call the tech area several times in order to reach the final level.

 

3. Add tech area to function "Get_Required_Techs_For_Tech()" in "Script_AI_Research.txt" and function "Get_Required_Techs_For_Tech()" in "Script_AI_GlobalResearch.txt".  Here is where the perquisite tech, and need levels, are listed for the Tech area.

 
           
"Contra - Terrene Engines":                         
                 set tech_name := "Ion Engines"               
                 set tech_level := 3
  
         

 

Allowing multi-perquisite tech area for a Tech area

1. Go to function "Get_Required_Techs_For_Tech()" in "Script_AI_Research.txt" and found the tech that you want to have more than one perquisite tech area.

 

2. Setup a if statement under that tech, which check to see if the first perquisite Tech's current level is at the needed level. 

 

      "Contra - Terren Engines"                                                                                    
          set tech_name := "Ion Engines"                                                                                              
          set tech_level := 3       

          if (Sys_Get_Empire_Research_Tech_Level(sys_long_Player_ID, tech_name) >= tech_level) then 

              set tech_name := "Physics"                                                                                    
              set tech_level := 2     

          endif  

3. Now for function "Get_Required_Techs_For_Tech()" in "Script_AI_GlobalResearch.txt" just add the value like you would for a single value input.

 

            "Contra - Terrene Engines":                                                                                                     
                 set tech_name := "Ion Engines"                                                                                           
                 set tech_level := 3

                 set tech_name := "Physics"                                                                                                
                 set tech_level := 2