2012-06-25 11:05:50 -06:00
|
|
|
# slay all creatures of a given race
|
2012-06-24 11:52:40 -06:00
|
|
|
|
2012-06-25 11:05:50 -06:00
|
|
|
race = $script_args[0]
|
2012-06-24 11:52:40 -06:00
|
|
|
|
2012-06-29 03:51:54 -06:00
|
|
|
checkunit = lambda { |u|
|
|
|
|
u.body.blood_count != 0 and
|
|
|
|
not u.flags1.dead and
|
|
|
|
not u.flags1.caged and
|
|
|
|
not df.map_designation_at(u).hidden
|
|
|
|
}
|
|
|
|
|
2012-06-25 11:05:50 -06:00
|
|
|
all_races = df.world.units.active.map { |u|
|
2012-06-29 03:51:54 -06:00
|
|
|
u.race_tg.creature_id if checkunit[u]
|
2012-06-25 11:05:50 -06:00
|
|
|
}.compact.uniq.sort
|
2012-06-24 11:52:40 -06:00
|
|
|
|
2012-06-25 11:05:50 -06:00
|
|
|
if !race
|
|
|
|
puts all_races
|
|
|
|
else
|
|
|
|
raw_race = df.match_rawname(race, all_races)
|
|
|
|
raise 'invalid race' if not raw_race
|
2012-06-24 11:52:40 -06:00
|
|
|
|
2012-06-25 11:05:50 -06:00
|
|
|
race_nr = df.world.raws.creatures.all.index { |cr| cr.creature_id == raw_race }
|
2012-06-24 11:52:40 -06:00
|
|
|
|
2012-06-29 03:51:54 -06:00
|
|
|
count = 0
|
2012-06-25 11:05:50 -06:00
|
|
|
df.world.units.active.each { |u|
|
2012-06-29 03:51:54 -06:00
|
|
|
if u.race == race_nr and checkunit[u]
|
2012-06-25 11:05:50 -06:00
|
|
|
u.body.blood_count = 0
|
|
|
|
count += 1
|
|
|
|
end
|
|
|
|
}
|
|
|
|
|
|
|
|
puts "slain #{count} #{raw_race}"
|
|
|
|
end
|