[micro_ai] tag: add code for using external CAs
This means that we can get rid of the engine definition macros once all MAIs have been switched to external CAs.
This commit is contained in:
parent
6c39832c86
commit
1e8fe60b3a
1 changed files with 11 additions and 3 deletions
|
@ -48,11 +48,19 @@ local function add_CAs(side, CA_parms, CA_cfg)
|
|||
engine = "lua",
|
||||
id = ca_id,
|
||||
name = ca_id,
|
||||
max_score = parms.score,
|
||||
evaluation = "return (...):" .. (parms.eval_id or parms.ca_id) .. "_eval(" .. AH.serialize(CA_cfg) .. ")",
|
||||
execution = "(...):" .. (parms.eval_id or parms.ca_id) .. "_exec(" .. AH.serialize(CA_cfg) .. ")"
|
||||
max_score = parms.score
|
||||
}
|
||||
|
||||
if parms.location then -- if using external CAs
|
||||
CA.location = parms.location
|
||||
local cfg = string.sub(AH.serialize(CA_cfg), 2, -2) -- need to strip surrounding {}
|
||||
CA.eval_parms = cfg
|
||||
CA.exec_parms = cfg
|
||||
else -- if using "regular" CAs
|
||||
CA.evaluation = "return (...):" .. (parms.eval_id or parms.ca_id) .. "_eval(" .. AH.serialize(CA_cfg) .. ")"
|
||||
CA.execution = "(...):" .. (parms.eval_id or parms.ca_id) .. "_exec(" .. AH.serialize(CA_cfg) .. ")"
|
||||
end
|
||||
|
||||
if parms.sticky then
|
||||
local unit = wesnoth.get_units { id = CA_cfg.id }[1]
|
||||
CA.sticky = "yes"
|
||||
|
|
Loading…
Add table
Reference in a new issue