ExpAI recruiting: fix AI crash for unit type with unknown race
This commit is contained in:
parent
20b36d2713
commit
59397a40b5
1 changed files with 3 additions and 1 deletions
|
@ -802,7 +802,9 @@ return {
|
|||
for attack_range, count in pairs(unit_attack_range_count[recruit_id]) do
|
||||
bonus = bonus + 0.02 * most_common_range_count / (attack_range_count[attack_range]+1)
|
||||
end
|
||||
bonus = bonus + 0.03 * wesnoth.races[wesnoth.unit_types[recruit_id].__cfg.race].num_traits^2
|
||||
local race = wesnoth.races[wesnoth.unit_types[recruit_id].__cfg.race]
|
||||
local num_traits = race and race.num_traits or 0
|
||||
bonus = bonus + 0.03 * num_traits^2
|
||||
if target_hex[1] then
|
||||
recruitable_units[recruit_id].x = best_hex[1]
|
||||
recruitable_units[recruit_id].y = best_hex[2]
|
||||
|
|
Loading…
Add table
Reference in a new issue