2013-03-15 17:51:04 -06:00
|
|
|
# exterminate creatures
|
2012-06-24 11:52:40 -06:00
|
|
|
|
2012-08-03 08:59:54 -06:00
|
|
|
# race = name of the race to eradicate, use 'him' to target only the selected creature
|
2012-12-12 16:13:16 -07:00
|
|
|
# use 'undead' to target all undeads
|
2012-06-25 11:05:50 -06:00
|
|
|
race = $script_args[0]
|
2012-12-12 16:13:16 -07:00
|
|
|
|
2012-08-03 08:59:54 -06:00
|
|
|
# if the 2nd parameter is 'magma', magma rain for the targets instead of instant death
|
|
|
|
magma = ($script_args[1] == 'magma')
|
2012-06-24 11:52:40 -06:00
|
|
|
|
2012-06-29 03:51:54 -06:00
|
|
|
checkunit = lambda { |u|
|
2012-12-12 16:13:16 -07:00
|
|
|
(u.body.blood_count != 0 or u.body.blood_max == 0) and
|
2012-06-29 03:51:54 -06:00
|
|
|
not u.flags1.dead and
|
2012-12-12 16:13:16 -07:00
|
|
|
not u.flags1.caged and not u.flags1.chained and
|
|
|
|
#not u.flags1.hidden_in_ambush and
|
2012-06-29 03:51:54 -06:00
|
|
|
not df.map_designation_at(u).hidden
|
|
|
|
}
|
|
|
|
|
2012-08-03 08:59:54 -06:00
|
|
|
slayit = lambda { |u|
|
|
|
|
if not magma
|
|
|
|
# just make them drop dead
|
|
|
|
u.body.blood_count = 0
|
|
|
|
# some races dont mind having no blood, ensure they are still taken care of.
|
|
|
|
u.animal.vanish_countdown = 2
|
|
|
|
else
|
|
|
|
# it's getting hot around here
|
|
|
|
# !!WARNING!! do not call on a magma-safe creature
|
2013-03-15 17:51:04 -06:00
|
|
|
ouh = df.onupdate_register("exterminate ensure #{u.id}", 1) {
|
2012-08-03 08:59:54 -06:00
|
|
|
if u.flags1.dead
|
|
|
|
df.onupdate_unregister(ouh)
|
|
|
|
else
|
|
|
|
x, y, z = u.pos.x, u.pos.y, u.pos.z
|
2012-12-12 16:13:16 -07:00
|
|
|
z += 1 while tile = df.map_tile_at(x, y, z+1) and
|
|
|
|
tile.shape_passableflow and tile.shape_passablelow
|
2012-08-03 08:59:54 -06:00
|
|
|
df.map_tile_at(x, y, z).spawn_magma(7)
|
|
|
|
end
|
|
|
|
}
|
|
|
|
end
|
|
|
|
}
|
|
|
|
|
2012-10-10 11:25:30 -06:00
|
|
|
all_races = Hash.new(0)
|
|
|
|
|
|
|
|
df.world.units.active.map { |u|
|
2012-12-12 16:13:16 -07:00
|
|
|
if checkunit[u]
|
|
|
|
if (u.enemy.undead or
|
|
|
|
(u.curse.add_tags1.OPPOSED_TO_LIFE and not
|
2012-12-12 17:47:58 -07:00
|
|
|
u.curse.rem_tags1.OPPOSED_TO_LIFE))
|
2012-12-12 16:13:16 -07:00
|
|
|
all_races['Undead'] += 1
|
|
|
|
else
|
|
|
|
all_races[u.race_tg.creature_id] += 1
|
|
|
|
end
|
|
|
|
end
|
2012-10-10 11:25:30 -06:00
|
|
|
}
|
2012-06-24 11:52:40 -06:00
|
|
|
|
2012-12-12 16:13:16 -07:00
|
|
|
case race
|
|
|
|
when nil
|
2012-10-10 11:25:30 -06:00
|
|
|
all_races.sort_by { |race, cnt| [cnt, race] }.each{ |race, cnt| puts " #{race} #{cnt}" }
|
2012-12-12 16:13:16 -07:00
|
|
|
|
2013-03-15 17:51:04 -06:00
|
|
|
when 'help', '?'
|
|
|
|
puts <<EOS
|
|
|
|
Kills all creatures of a given race.
|
|
|
|
With no argument, lists possible targets with their head count.
|
|
|
|
With the special argument 'him' or 'her', kill only the currently selected creature.
|
|
|
|
With the special argument 'undead', kill all undead creatures/thralls.
|
|
|
|
|
2013-03-15 18:36:49 -06:00
|
|
|
The targets will bleed out on the next game tick, or if they are immune to that, will vanish in a puff of smoke.
|
2013-03-15 17:51:04 -06:00
|
|
|
|
|
|
|
The special final argument 'magma' will make magma rain on the targets instead.
|
|
|
|
|
|
|
|
Ex: exterminate gob
|
2013-03-15 18:46:31 -06:00
|
|
|
exterminate elve magma
|
2013-03-15 17:51:04 -06:00
|
|
|
exterminate him
|
|
|
|
EOS
|
|
|
|
|
|
|
|
when 'him', 'her'
|
2012-08-03 08:59:54 -06:00
|
|
|
if him = df.unit_find
|
|
|
|
slayit[him]
|
|
|
|
else
|
2012-12-12 16:13:16 -07:00
|
|
|
puts "Select a target ingame"
|
2012-08-03 08:59:54 -06:00
|
|
|
end
|
2012-12-12 16:13:16 -07:00
|
|
|
|
|
|
|
when /^undead/i
|
|
|
|
count = 0
|
|
|
|
df.world.units.active.each { |u|
|
|
|
|
if (u.enemy.undead or
|
|
|
|
(u.curse.add_tags1.OPPOSED_TO_LIFE and not
|
2012-12-12 17:47:58 -07:00
|
|
|
u.curse.rem_tags1.OPPOSED_TO_LIFE)) and
|
2012-12-12 16:13:16 -07:00
|
|
|
checkunit[u]
|
|
|
|
slayit[u]
|
|
|
|
count += 1
|
|
|
|
end
|
|
|
|
}
|
|
|
|
puts "slain #{count} undeads"
|
|
|
|
|
2012-06-25 11:05:50 -06:00
|
|
|
else
|
2012-10-10 11:25:30 -06:00
|
|
|
raw_race = df.match_rawname(race, all_races.keys)
|
2013-03-15 18:36:49 -06:00
|
|
|
if not raw_race
|
|
|
|
puts "Invalid race, use one of #{all_races.keys.sort.join(' ')}"
|
|
|
|
throw :script_finished
|
|
|
|
end
|
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-08-03 08:59:54 -06:00
|
|
|
slayit[u]
|
2012-06-25 11:05:50 -06:00
|
|
|
count += 1
|
|
|
|
end
|
|
|
|
}
|
|
|
|
puts "slain #{count} #{raw_race}"
|
2012-12-12 16:13:16 -07:00
|
|
|
|
2012-06-25 11:05:50 -06:00
|
|
|
end
|