Merge remote-tracking branches 'sv-esk/iscitizen' and 'sv-esk/validation' into develop

develop
lethosor 2016-03-04 19:09:26 -05:00
commit b6f1650a01
2 changed files with 17 additions and 16 deletions

@ -818,26 +818,22 @@ bool Units::isCitizen(df::unit *unit)
// except that the game appears to let melancholy/raving // except that the game appears to let melancholy/raving
// dwarves count as citizens. // dwarves count as citizens.
if (!isDwarf(unit) || !isSane(unit))
return false;
if (unit->flags1.bits.marauder || if (unit->flags1.bits.marauder ||
unit->flags1.bits.invader_origin || unit->flags1.bits.invader_origin ||
unit->flags1.bits.active_invader || unit->flags1.bits.active_invader ||
unit->flags1.bits.forest || unit->flags1.bits.forest ||
unit->flags1.bits.merchant || unit->flags1.bits.merchant ||
unit->flags1.bits.diplomat) unit->flags1.bits.diplomat ||
unit->flags2.bits.visitor ||
unit->flags2.bits.visitor_uninvited ||
unit->flags2.bits.underworld ||
unit->flags2.bits.resident)
return false; return false;
if (unit->flags1.bits.tame) if (!isSane(unit))
return true; return false;
return unit->civ_id == ui->civ_id && return isOwnGroup(unit);
unit->civ_id != -1 &&
!unit->flags2.bits.underworld &&
!unit->flags2.bits.resident &&
!unit->flags2.bits.visitor_uninvited &&
!unit->flags2.bits.visitor;
} }
bool Units::isDwarf(df::unit *unit) bool Units::isDwarf(df::unit *unit)
@ -901,7 +897,7 @@ bool Units::isOwnGroup(df::unit* unit)
for (size_t i = 0; i < histfig->entity_links.size(); i++) for (size_t i = 0; i < histfig->entity_links.size(); i++)
{ {
auto link = histfig->entity_links[i]; auto link = histfig->entity_links[i];
if (link->entity_id == ui->group_id && (*link).getType() == df::histfig_entity_link_type::MEMBER) if (link->entity_id == ui->group_id && link->getType() == df::histfig_entity_link_type::MEMBER)
return true; return true;
} }
return false; return false;

@ -6,7 +6,7 @@
modtools/force modtools/force
============== ==============
This tool triggers events like megabeasts, caravans, invaders, and migrants. This tool triggers events like megabeasts, caravans, and migrants.
=end]] =end]]
local utils = require 'utils' local utils = require 'utils'
@ -44,7 +44,6 @@ arguments:
WildlifeCurious WildlifeCurious
WildlifeMischievous WildlifeMischievous
WildlifeFlier WildlifeFlier
CivAttack
NightCreature NightCreature
-civ entity -civ entity
specify the civ of the event, if applicable specify the civ of the event, if applicable
@ -54,7 +53,7 @@ arguments:
EVIL EVIL
28 28
]]) ]])
print('force: -eventType [Megabeast, Migrants, Caravan, Diplomat, WildlifeCurious, WildlifeMischievous, WildlifeFlier, CivAttack, NightCreature] -civ [player,ENTITY_ID]') print('force: -eventType [Megabeast, Migrants, Caravan, Diplomat, WildlifeCurious, WildlifeMischievous, WildlifeFlier, NightCreature] -civ [player,ENTITY_ID]')
return return
end end
@ -67,7 +66,13 @@ end
if args.civ == 'player' then if args.civ == 'player' then
args.civ = df.historical_entity.find(df.global.ui.civ_id) args.civ = df.historical_entity.find(df.global.ui.civ_id)
elseif args.civ then elseif args.civ then
local civ = args.civ
args.civ = findCiv(args.civ) args.civ = findCiv(args.civ)
if not args.civ then
error('Invalid civ: ' .. civ)
end
elseif args.eventType == 'Caravan' or args.eventType == 'Diplomat' then
error('Specify civ for this eventType')
end end
if args.eventType == 'Migrants' then if args.eventType == 'Migrants' then