All Guardian MAIs: add optional ca_score parameter
This commit is contained in:
parent
9b8be208ed
commit
f8e242d5ac
2 changed files with 12 additions and 19 deletions
|
@ -12,11 +12,8 @@ return {
|
|||
local unit = wesnoth.get_units{ id = cfg.id }[1]
|
||||
|
||||
-- Check if unit exists as sticky BCAs are not always removed successfully
|
||||
if unit and (unit.moves > 0) then
|
||||
return 300000
|
||||
else
|
||||
return 0
|
||||
end
|
||||
if unit and (unit.moves > 0) then return cfg.ca_score end
|
||||
return 0
|
||||
end
|
||||
|
||||
-- cfg parameters: id, distance, seek_x, seek_y, avoid_x, avoid_y
|
||||
|
@ -117,9 +114,9 @@ return {
|
|||
-- Check if unit exists as sticky BCAs are not always removed successfully
|
||||
if unit then
|
||||
if ((unit.x ~= cfg.return_x) or (unit.y ~= cfg.return_y)) then
|
||||
return 100010
|
||||
return cfg.ca_score
|
||||
else
|
||||
return 99990
|
||||
return cfg.ca_score - 20
|
||||
end
|
||||
end
|
||||
return 0
|
||||
|
@ -154,9 +151,8 @@ return {
|
|||
local unit = wesnoth.get_units { id = cfg.id }[1]
|
||||
|
||||
-- Check if unit exists as sticky BCAs are not always removed successfully
|
||||
if unit and (unit.moves > 0) then
|
||||
return 100010
|
||||
end
|
||||
if unit and (unit.moves > 0) then return cfg.ca_score end
|
||||
return 0
|
||||
end
|
||||
|
||||
--Check if an enemy is detected in filter_location_enemy (or filter_location) and attack it or start the "move" randomly function
|
||||
|
@ -295,11 +291,8 @@ return {
|
|||
local unit = wesnoth.get_units { id = cfg.id }[1]
|
||||
|
||||
-- Check if unit exists as sticky BCAs are not always removed successfully
|
||||
if unit and (unit.moves > 0) then
|
||||
return 100010
|
||||
else
|
||||
return 0
|
||||
end
|
||||
if unit and (unit.moves > 0) then return cfg.ca_score end
|
||||
return 0
|
||||
end
|
||||
|
||||
-- cfg parameters: id, distance, s_x, s_y, g_x, g_y
|
||||
|
|
|
@ -279,21 +279,21 @@ function wesnoth.wml_actions.micro_ai(cfg)
|
|||
|
||||
if (cfg.guardian_type == 'stationed_guardian') then
|
||||
required_keys = { "id", "distance", "station_x", "station_y", "guard_x", "guard_y" }
|
||||
CA_parms = { { ca_id = 'mai_guardian_stationed', score = 100010, sticky = true } }
|
||||
CA_parms = { { ca_id = 'mai_guardian_stationed', score = cfg.ca_score or 300000, sticky = true } }
|
||||
|
||||
elseif (cfg.guardian_type == 'zone_guardian') then
|
||||
required_keys = { "id", "filter_location" }
|
||||
optional_keys = { "filter_location_enemy", "station_x", "station_y" }
|
||||
CA_parms = { { ca_id = 'mai_guardian_zone', score = 100010, sticky = true } }
|
||||
CA_parms = { { ca_id = 'mai_guardian_zone', score = cfg.ca_score or 300000, sticky = true } }
|
||||
|
||||
elseif (cfg.guardian_type == 'return_guardian') then
|
||||
required_keys = { "id", "return_x", "return_y" }
|
||||
CA_parms = { { ca_id = 'mai_guardian_return', score = 300000, sticky = true } }
|
||||
CA_parms = { { ca_id = 'mai_guardian_return', score = cfg.ca_score or 100010, sticky = true } }
|
||||
|
||||
elseif (cfg.guardian_type == 'coward') then
|
||||
required_keys = { "id", "distance" }
|
||||
optional_keys = { "seek_x", "seek_y","avoid_x","avoid_y" }
|
||||
CA_parms = { { ca_id = 'mai_guardian_coward', score = 300000, sticky = true } }
|
||||
CA_parms = { { ca_id = 'mai_guardian_coward', score = cfg.ca_score or 300000, sticky = true } }
|
||||
|
||||
else
|
||||
H.wml_error("[micro_ai] tag (guardian) guardian_type= key is missing or has unknown value")
|
||||
|
|
Loading…
Add table
Reference in a new issue