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 end
function getBaseUnitWeight(unit) function getBaseUnitWeight(unit)
if dfhack.units.isCitizen(unit) then local flags1 = unit.flags1
return -10 local rv = 1
elseif unit.flags1.diplomat or unit.flags1.merchant then
return -2 if unit.mood == df.mood_type.Berserk
elseif unit.flags1.tame and unit.civ_id == df.global.ui.civ_id then or dfhack.units.isOpposedToLife(unit)
return -1 or dfhack.units.isCrazed(unit)
then
rv = rv + 1
else else
local rv = 1 if dfhack.units.isCitizen(unit) then
if unit.flags1.marauder then rv = rv + 0.5 end return -30
if unit.flags1.active_invader then rv = rv + 1 end elseif flags1.diplomat or flags1.merchant or flags1.forest then
if unit.flags1.invader_origin then rv = rv + 1 end return -5
if unit.flags1.invades then rv = rv + 1 end elseif flags1.tame and unit.civ_id == df.global.ui.civ_id then
if unit.flags1.hidden_ambusher then rv = rv + 1 end return -1
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 end
return rv
end end
function getUnitWeight(unit) function getUnitWeight(unit)

@ -1340,9 +1340,11 @@ static bool canTargetUnit(df::unit *unit)
CHECK_NULL_POINTER(unit); CHECK_NULL_POINTER(unit);
if (unit->flags1.bits.dead || if (unit->flags1.bits.dead ||
unit->flags3.bits.ghostly ||
unit->flags1.bits.caged || 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 false;
return true; return true;