Here's a new one.
[SYN_CLASS:\COMMAND][SYN_CLASS:skillroll][SYN_CLASS:\WORKER_ID] This may be what you think it is.
[SYN_CLASS:MELEE_COMBAT] Can use any skill.
[SYN_CLASS:20] Rolls d20. Skill will be weighted to this value.
[SYN_CLASS:DICEROLL_1] If diceroll ends up as one...
[SYN_CLASS:kill][SYN_CLASS:\SKILL_UNIT_ID] Theoretical kill-given-unit-id command; slayrace doesn't do so.
[SYN_CLASS:DICEROLL_10] If diceroll is between 1 and 10 (2-10, inclusive)...
[SYN_CLASS:force][SYN_CLASS:migrants][SYN_CLASS:player] Force migrants.
[SYN_CLASS:DICEROLL_19] If diceroll is between 10 and 19 (11-19, inclusive)...
[SYN_CLASS:fullheal][SYN_CLASS:\SKILL_UNIT_ID] Fully heals unit.
[SYN_CLASS:DICEROLL_20] If diceroll is at least 20...
[SYN_CLASS:shapechange][SYN_CLASS:\SKILL_UNIT_ID] Turns unit into any creature permanently.
Ain't that fun?
local args={...}
local unit = df.unit.find(args[1])
local rando=dfhack.random.new()
local roll=rando:random(tonumber(args[3]))
local result=math.floor(roll+(dfhack.units.getEffectiveSkill(unit,df.job_skill[args[2]])*(tonumber(args[3])/20)))
local i=4
local command={}
local scriptIsFinished
repeat
local arg=args[i]
if arg:find('DICEROLL') then
local dicerollnumber=tonumber(arg:match('%d+')) --yes this is truly naive as hell; I imagine if you put DICEROLL3%moa5oam3 it'll return 353.
if dicerollnumber>=result then
repeat
i=i+1
if not args[i]:find('DICEROLL') then
if args[i]~='\\SKILL_UNIT_ID' then table.insert(command,args[i]) else table.insert(command,args[1]) end
end
until arg:find('DICEROLL')
dfhack.run_script(table.unpack(command))
scriptIsFinished=true
end
else
i=i+1
end
until i>#args or scriptIsFinished