CJ's suggestion seems like a fine idea to me. I've previously considered exposing the underlying EffectsGroups, Effects, Conditions and ValueRefs from FO as Geoff suggests-- it would have the benefit of potentially allowing the AI to really be automatically (at least nearly) totally adaptable to FOCS script changes, but I think that even relatively simple value checks would still be exceedingly messy for the AI to deal with in that fashion, let alone actually trying to be adaptable to the entire structure of a given Effect.
So, for SJ's suggestion, perhaps the parser has changed while I've been away (or my memory is simply a bit foggy), but it's seeming to me that this should be a simple scripting matter to implement, no C++ coding necessary. We could generalize the use of default/content_specific_parameters.txt (which already gets included into the stringtable for similar lookups for the UI) to be not just for customizing the UI, but also for these kinds of parameters (or else just make a new file for these kinds of parameters). At the end of default/scripting/common/misc.macros we would add the line
Code: Select all
#include ../../content_specific_parameters.txt
Within the FOCS scripts, the numeric constants would just be replaced with macro lookups, like is already done for things like MIN_RECOLONIZING_SIZE, so Cj's example FOCS script would instead look like
Code: Select all
EffectsGroup
scope = And [
Ship
OwnedBy empire = Source.Owner
]
effects = SetMaxStructure value = Value + [[SHP_REINFORCED_HULL_STRUCTURE_BONUS]]
and the corresponding AI python script would be something like
Code: Select all
# probably put this function in freeorion_tools.py
def numeric_FOCS_value(key):
lookup = fo.userString(key)
try:
return float(lookup)
except ValueError:
print_error("Error looking-up numeric scripting value for script key '%s', got '%s'" % (key, lookup))
return get_default_value(key) # from looking up in an AI table, or else some fixed value.
TECH_EFFECTS = {
# "TECHNAME": { Token1: Value1, Token2: Value2, ...}
"SHP_REINFORCED_HULL": {STRUCTURE: numeric_FOCS_value('SHP_REINFORCED_HULL_STRUCTURE_BONUS')},
"SHP_BASIC_DAM_CONT": {REPAIR_PER_TURN: numeric_FOCS_value('SHP_BASIC_DAM_CONT_BONUS')},
Am I missing something?
If I provided any code, scripts or other content here, it's released under GPL 2.0 and CC-BY-SA 3.0