Adjust siege engine targeting weights.

Stop shooting at leaving caravan guards for one.
develop
Alexander Gavrilov 2014-04-17 22:10:43 +04:00
parent c27c38e4c0
commit 63d256c1e9
2 changed files with 37 additions and 15 deletions

@ -133,21 +133,41 @@ function saveRecent(unit)
end
function getBaseUnitWeight(unit)
local flags1 = unit.flags1
local rv = 1
if unit.mood == df.mood_type.Berserk
or dfhack.units.isOpposedToLife(unit)
or dfhack.units.isCrazed(unit)
then
rv = rv + 1
else
if dfhack.units.isCitizen(unit) then
return -10
elseif unit.flags1.diplomat or unit.flags1.merchant then
return -2
elseif unit.flags1.tame and unit.civ_id == df.global.ui.civ_id then
return -30
elseif flags1.diplomat or flags1.merchant or flags1.forest then
return -5
elseif flags1.tame and unit.civ_id == df.global.ui.civ_id then
return -1
else
local rv = 1
if unit.flags1.marauder then rv = rv + 0.5 end
if unit.flags1.active_invader then rv = rv + 1 end
if unit.flags1.invader_origin then rv = rv + 1 end
if unit.flags1.invades then rv = rv + 1 end
if unit.flags1.hidden_ambusher then rv = rv + 1 end
return rv
end
end
if flags1.marauder then rv = rv + 0.5 end
if flags1.active_invader then rv = rv + 1 end
if flags1.invader_origin then rv = rv + 1 end
if flags1.invades then rv = rv + 1 end
if flags1.hidden_ambusher then rv = rv + 1 end
if unit.counters.unconscious > 0 then
rv = rv * 0.3
elseif unit.job.hunt_target then
rv = rv * 3
elseif unit.job.destroy_target then
rv = rv * 2
elseif unit.relations.group_leader_id < 0 and not flags1.rider then
rv = rv * 1.5
end
return rv
end
function getUnitWeight(unit)

@ -1340,9 +1340,11 @@ static bool canTargetUnit(df::unit *unit)
CHECK_NULL_POINTER(unit);
if (unit->flags1.bits.dead ||
unit->flags3.bits.ghostly ||
unit->flags1.bits.caged ||
unit->flags1.bits.hidden_in_ambush)
unit->flags1.bits.left ||
unit->flags1.bits.incoming ||
unit->flags1.bits.hidden_in_ambush ||
unit->flags3.bits.ghostly)
return false;
return true;