Jump to content

Idea: Global Variable for Linking Scripts


Recommended Posts

Idea: A global variable script runs before any diplomacy, production, research or planning scripts run. This would allow the AI to implement a coherent strategy by activating different related scripts.

Example:

Global Variable Folder

{

#NAME= German Sub_warfare

#Trigger=10 (10% to activate)

#Level=2

#Global=10

The #Global is what the Global Variable is set to. Acceptable Values 1 to 9999. The global variable can be accessed by related allied nations. USA and UK scripts can both be activated from a common variable. This allows the USA and UK to pursue a cooordinated strategy to ensure that both nations; for example, invade France at the same time.

#DATE=1939/07/01

#SUBMARINE_CONDITION=[X][2,5]

Unit typem, Country and number of (Min, Max) units of specificed type that country X has. You may not want to activate the Sub_warfare option if all German subs have been sunk or the UK navy is too large.

#TYPE_CONDITION=X[unit type- air, land or naval][min,max]

This condition refers to the total number of spotted and not destroyed units of a particular type - Air, Land or Naval for a particular country. You may not want to launch a Battle for the Atlantic if the enemy navy is too large.

}

Then in the production script you would have a line that reads:

#Global_Activation=10

This production script would only activate as long as the Global Variable was equal to 10.

In the Research script you would have a line that reads:

#Global_Activation=10

This research script would only activate if the Global Variable was equal to 10.

Of course, it would need more variables - activation, cancelations, date, etc. but just an idea for linking scripts.

----------------------------

[ April 11, 2006, 02:31 PM: Message edited by: Edwin P. ]

Link to comment
Share on other sites

There will be an allied invasion, but in the scripts it is coded into the seperate allied and UK scripts.

I would like to have a chance for an Operation Torch and have the UK and USA launch combined operations without it being hard coded into the scripts of both countries. That means that if USA decides on option A, then UK will decide on option A also.

PS: The scripting commands are quite powerful as is. Have a look at them. This suggestion would just make them more powerful.

Link to comment
Share on other sites

Update: Figured out how to link AI Scripts - its a shortcut, but it works.

It appears that I can use #ACTIVATE_POSITION to link the activation of several scripts.

How so? If AI moves Unit to XX,YY then that can serve as an activation trigger for Planning, Research, Purchase and Diplomacy Scripts. Move unit to a different tile and it can activate a different set of scripts. The key is to have the linked scripts all refer to a common occupied tile. This should work assuming that the AI does not move another unit to that tile or another tile used to activate these scripts on its own.

Example: 10% Planning Script moves Allied Corps to Tile XX,YY (ie Tile SW of Scarpa Flow).

If Corps is in this tile this this activates Script to research Bombers x3, activates Script to purchase Bombers x3 and activates script to research Long Range x2.

I will try it tonight and see if it works, but it should from what the comments in the templates say.

[ April 13, 2006, 12:40 PM: Message edited by: Edwin P. ]

Link to comment
Share on other sites

Yep, you can pretty much have all countries on the same side doing the same thing or work together on a strategy with the activation scripts.

It will require a lot of work. But think of it this way, you do not have to build a game from scratch!

Link to comment
Share on other sites

×
×
  • Create New...