slayrace: add single-creature targetting, add magma column mode

develop
jj 2012-08-03 16:59:54 +02:00
parent c1bcd270e9
commit 64a8443b5a
2 changed files with 49 additions and 7 deletions

@ -1401,18 +1401,30 @@ Kills any unit of a given race.
With no argument, lists the available races.
With the special argument 'him', targets only the selected creature.
Any non-dead non-caged unit of the specified race gets its ``blood_count``
set to 0, which means immediate death at the next game tick. May not work
on vampires and other weird creatures.
set to 0, which means immediate death at the next game tick. For creatures
such as vampires, also set animal.vanish_countdown to 2.
An alternate mode is selected by adding a 2nd argument to the command,
``magma``. In this case, a column of 7/7 magma is generated on top of the
targets until they die (Warning: do not call on magma-safe creatures. Also,
using this mode for birds is not recommanded.)
Will target any unit on a revealed tile of the map, including ambushers.
Targets any unit on a revealed tile of the map, including ambushers. Ex:
Ex:
::
slayrace gob
To kill a single creature in the same way, you can use the following line,
after selecting the unit with the 'v' cursor:
To kill a single creature, select the unit with the 'v' cursor and:
::
slayrace him
To purify all elves on the map with fire (may have side-effects):
::
rb_eval df.unit_find.body.blood_count = 0
slayrace elve magma
magmasource

@ -1,6 +1,9 @@
# slay all creatures of a given race
# race = name of the race to eradicate, use 'him' to target only the selected creature
race = $script_args[0]
# if the 2nd parameter is 'magma', magma rain for the targets instead of instant death
magma = ($script_args[1] == 'magma')
checkunit = lambda { |u|
u.body.blood_count != 0 and
@ -9,12 +12,39 @@ checkunit = lambda { |u|
not df.map_designation_at(u).hidden
}
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
ouh = df.onupdate_register(1) {
if u.flags1.dead
df.onupdate_unregister(ouh)
else
x, y, z = u.pos.x, u.pos.y, u.pos.z
z += 1 while tile = df.map_tile_at(x, y, z+1) and tile.shape_passableflow
df.map_tile_at(x, y, z).spawn_magma(7)
end
}
end
}
all_races = df.world.units.active.map { |u|
u.race_tg.creature_id if checkunit[u]
}.compact.uniq.sort
if !race
puts all_races
elsif race == 'him'
if him = df.unit_find
slayit[him]
else
puts "Choose target"
end
else
raw_race = df.match_rawname(race, all_races)
raise 'invalid race' if not raw_race
@ -24,7 +54,7 @@ else
count = 0
df.world.units.active.each { |u|
if u.race == race_nr and checkunit[u]
u.body.blood_count = 0
slayit[u]
count += 1
end
}