Animals MAIs: get rid of animal_type= key

The previous value of animal_type= now goes directly into ai_type=
This commit is contained in:
mattsc 2013-10-22 07:48:32 -07:00
parent 361e56c6a1
commit 7388dbbee5

View file

@ -307,97 +307,92 @@ function wesnoth.wml_actions.micro_ai(cfg)
end
--------- Micro AI Animals - side-wide and BCA AIs ------------------------------------
elseif (cfg.ai_type == 'animals') then
if (cfg.animal_type == 'big_animals') then
required_keys = { "filter"}
optional_keys = { "avoid_unit", "filter_location", "filter_location_wander" }
CA_parms = { { ca_id = "mai_animals_big", score = cfg.ca_score or 300000 } }
elseif (cfg.ai_type == 'big_animals') then
required_keys = { "filter"}
optional_keys = { "avoid_unit", "filter_location", "filter_location_wander" }
CA_parms = { { ca_id = "mai_animals_big", score = cfg.ca_score or 300000 } }
elseif (cfg.animal_type == 'wolves') then
required_keys = { "filter", "filter_second" }
optional_keys = { "avoid_type" }
local score = cfg.ca_score or 90000
CA_parms = {
{ ca_id = "mai_animals_wolves", score = score },
{ ca_id = "mai_animals_wolves_wander", score = score - 1 }
}
elseif (cfg.ai_type == 'wolves') then
required_keys = { "filter", "filter_second" }
optional_keys = { "avoid_type" }
local score = cfg.ca_score or 90000
CA_parms = {
{ ca_id = "mai_animals_wolves", score = score },
{ ca_id = "mai_animals_wolves_wander", score = score - 1 }
}
local wolves_aspects = {
{
aspect = "attacks",
facet = {
name = "ai_default_rca::aspect_attacks",
id = "dont_attack",
invalidate_on_gamestate_change = "yes",
{ "filter_enemy", {
{ "not", {
type=cfg.avoid_type
} }
local wolves_aspects = {
{
aspect = "attacks",
facet = {
name = "ai_default_rca::aspect_attacks",
id = "dont_attack",
invalidate_on_gamestate_change = "yes",
{ "filter_enemy", {
{ "not", {
type=cfg.avoid_type
} }
}
} }
}
}
if (cfg.action == "delete") then
delete_aspects(cfg.side, wolves_aspects)
else
add_aspects(cfg.side, wolves_aspects)
end
elseif (cfg.animal_type == 'herding') then
required_keys = { "filter_location", "filter", "filter_second", "herd_x", "herd_y" }
optional_keys = { "attention_distance", "attack_distance" }
local score = cfg.ca_score or 300000
CA_parms = {
{ ca_id = "mai_animals_herding_attack_close_enemy", score = score },
{ ca_id = "mai_animals_sheep_runs_enemy", score = score - 1 },
{ ca_id = "mai_animals_sheep_runs_dog", score = score - 2 },
{ ca_id = "mai_animals_herd_sheep", score = score - 3 },
{ ca_id = "mai_animals_sheep_move", score = score - 4 },
{ ca_id = "mai_animals_dog_move", score = score - 5 }
}
elseif (cfg.animal_type == 'forest_animals') then
optional_keys = { "rabbit_type", "rabbit_number", "rabbit_enemy_distance", "rabbit_hole_img",
"tusker_type", "tusklet_type", "deer_type", "filter_location"
}
local score = cfg.ca_score or 300000
CA_parms = {
{ ca_id = "mai_animals_new_rabbit", score = score },
{ ca_id = "mai_animals_tusker_attack", score = score - 1 },
{ ca_id = "mai_animals_forest_move", score = score - 2 },
{ ca_id = "mai_animals_tusklet", score = score - 3 }
}
elseif (cfg.animal_type == 'swarm') then
optional_keys = { "scatter_distance", "vision_distance", "enemy_distance" }
local score = cfg.ca_score or 300000
CA_parms = {
{ ca_id = "mai_animals_scatter_swarm", score = score },
{ ca_id = "mai_animals_move_swarm", score = score - 1 }
}
elseif (cfg.animal_type == 'wolves_multipacks') then
optional_keys = { "type", "pack_size", "show_pack_number" }
local score = cfg.ca_score or 300000
CA_parms = {
{ ca_id = "mai_animals_wolves_multipacks_attack", score = score },
{ ca_id = "mai_animals_wolves_multipacks_wander", score = score - 1 }
}
elseif (cfg.animal_type == 'hunter_unit') then
required_keys = { "id", "home_x", "home_y" }
optional_keys = { "filter_location", "rest_turns", "show_messages" }
-- id= key is required also for CA deletion
if (not cfg.id) then
H.wml_error("[micro_ai] tag (hunter_unit) is missing required parameter: id")
end
CA_parms = { { ca_id = "mai_animals_hunter_unit", score = cfg.ca_score or 300000, sticky = true } }
}
if (cfg.action == "delete") then
delete_aspects(cfg.side, wolves_aspects)
else
H.wml_error("[micro_ai] tag (animals) animal_type= key is missing or has unknown value")
add_aspects(cfg.side, wolves_aspects)
end
elseif (cfg.ai_type == 'herding') then
required_keys = { "filter_location", "filter", "filter_second", "herd_x", "herd_y" }
optional_keys = { "attention_distance", "attack_distance" }
local score = cfg.ca_score or 300000
CA_parms = {
{ ca_id = "mai_animals_herding_attack_close_enemy", score = score },
{ ca_id = "mai_animals_sheep_runs_enemy", score = score - 1 },
{ ca_id = "mai_animals_sheep_runs_dog", score = score - 2 },
{ ca_id = "mai_animals_herd_sheep", score = score - 3 },
{ ca_id = "mai_animals_sheep_move", score = score - 4 },
{ ca_id = "mai_animals_dog_move", score = score - 5 }
}
elseif (cfg.ai_type == 'forest_animals') then
optional_keys = { "rabbit_type", "rabbit_number", "rabbit_enemy_distance", "rabbit_hole_img",
"tusker_type", "tusklet_type", "deer_type", "filter_location"
}
local score = cfg.ca_score or 300000
CA_parms = {
{ ca_id = "mai_animals_new_rabbit", score = score },
{ ca_id = "mai_animals_tusker_attack", score = score - 1 },
{ ca_id = "mai_animals_forest_move", score = score - 2 },
{ ca_id = "mai_animals_tusklet", score = score - 3 }
}
elseif (cfg.ai_type == 'swarm') then
optional_keys = { "scatter_distance", "vision_distance", "enemy_distance" }
local score = cfg.ca_score or 300000
CA_parms = {
{ ca_id = "mai_animals_scatter_swarm", score = score },
{ ca_id = "mai_animals_move_swarm", score = score - 1 }
}
elseif (cfg.ai_type == 'wolves_multipacks') then
optional_keys = { "type", "pack_size", "show_pack_number" }
local score = cfg.ca_score or 300000
CA_parms = {
{ ca_id = "mai_animals_wolves_multipacks_attack", score = score },
{ ca_id = "mai_animals_wolves_multipacks_wander", score = score - 1 }
}
elseif (cfg.ai_type == 'hunter_unit') then
required_keys = { "id", "home_x", "home_y" }
optional_keys = { "filter_location", "rest_turns", "show_messages" }
-- id= key is required also for CA deletion
if (not cfg.id) then
H.wml_error("[micro_ai] tag (hunter_unit) is missing required parameter: id")
end
CA_parms = { { ca_id = "mai_animals_hunter_unit", score = cfg.ca_score or 300000, sticky = true } }
--------- Patrol Micro AI - BCA AI ------------------------------------
elseif (cfg.ai_type == 'patrol_unit') then
required_keys = { "id", "waypoint_x", "waypoint_y" }