ruby: add method for basic xml ref-target support, tweak scripts/slayrace
parent
17d06b969b
commit
412e8608d8
@ -1,19 +1,26 @@
|
||||
# slay all creatures of a given race (default = goblins)
|
||||
# slay all creatures of a given race
|
||||
|
||||
race = $script_args[0] || 'GOBLIN'
|
||||
race = $script_args[0]
|
||||
|
||||
all_races = df.world.raws.creatures.all.map { |cr| cr.creature_id }
|
||||
raw_race = df.match_rawname(race, all_races)
|
||||
raise 'invalid race' if not raw_race
|
||||
all_races = df.world.units.active.map { |u|
|
||||
u.race_tg.creature_id if not u.flags1.dead and not df.map_designation_at(u).hidden
|
||||
}.compact.uniq.sort
|
||||
|
||||
race_nr = df.world.raws.creatures.all.index { |cr| cr.creature_id == raw_race }
|
||||
count = 0
|
||||
if !race
|
||||
puts all_races
|
||||
else
|
||||
raw_race = df.match_rawname(race, all_races)
|
||||
raise 'invalid race' if not raw_race
|
||||
|
||||
df.world.units.active.each { |u|
|
||||
if u.race == race_nr and u.body.blood_count != 0
|
||||
u.body.blood_count = 0
|
||||
count += 1
|
||||
end
|
||||
}
|
||||
race_nr = df.world.raws.creatures.all.index { |cr| cr.creature_id == raw_race }
|
||||
count = 0
|
||||
|
||||
puts "slain #{count} #{raw_race}"
|
||||
df.world.units.active.each { |u|
|
||||
if u.race == race_nr and u.body.blood_count != 0 and not u.flags1.dead
|
||||
u.body.blood_count = 0
|
||||
count += 1
|
||||
end
|
||||
}
|
||||
|
||||
puts "slain #{count} #{raw_race}"
|
||||
end
|
||||
|
Loading…
Reference in New Issue