Bay 12 Games Forum

Please login or register.

Login with username, password and session length
Advanced search  
Pages: 1 ... 30 31 [32] 33 34 ... 44

Author Topic: Putnam's DFHack scripts  (Read 120613 times)

Putnam

  • Bay Watcher
  • DAT WIZARD
    • View Profile
Re: Putnam's DFHack scripts
« Reply #465 on: December 07, 2013, 12:46:05 am »

Here's a new one.

Code: [Select]
[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?

Code: [Select]
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
« Last Edit: December 07, 2013, 04:56:20 am by Putnam »
Logged

Roses

  • Bay Watcher
    • View Profile
Re: Putnam's DFHack scripts
« Reply #466 on: December 07, 2013, 02:27:12 am »

Hmm, this looks awesome. Can totally use it as a D&D like wish spell. Couple questions;

1. What does the skill do? (Make it more likely to roll higher?)
2. Are there any limitations to what you can do with the SYN_CLASS tags or is it just the same as triggering commands like normal?
3. Can this be tied to a projectileExpansion and/or itemSyndrome?
Logged

Putnam

  • Bay Watcher
  • DAT WIZARD
    • View Profile
Re: Putnam's DFHack scripts
« Reply #467 on: December 07, 2013, 02:33:19 am »

1. It checks the skill and adds the skill's level (weighted) to the roll. For example, if you chose 20, you'd get d20+(skill). If you chose 100, you'd get d100+(skill*5). 20 is legendary+5, 1 is novice, etc.
2. It's only scripts, AFAIK, maybe even lua scripts, which is unfortunate.
3. Yes, with syndromeTrigger.

EDIT: That version has a ridiculously easy-to-fix showstopper btw, which is why it's not on anywhere but that post right now.

EDIT 2: Fixed version here
« Last Edit: December 07, 2013, 05:16:51 am by Putnam »
Logged

Roses

  • Bay Watcher
    • View Profile
Re: Putnam's DFHack scripts
« Reply #468 on: December 07, 2013, 10:49:23 am »

This is awesome. Definitely going to be using it. Does it work in r3 and r4?
Logged

Putnam

  • Bay Watcher
  • DAT WIZARD
    • View Profile
Re: Putnam's DFHack scripts
« Reply #469 on: December 07, 2013, 02:28:27 pm »

I'm not sure about r3; the dfhack.random.new() function is new to me, so it may not have been in r3.

Roses

  • Bay Watcher
    • View Profile
Re: Putnam's DFHack scripts
« Reply #470 on: December 07, 2013, 04:00:34 pm »

Well I am planning on upgrading everything to r4 so that works fine.
Logged

Roses

  • Bay Watcher
    • View Profile
Re: Putnam's DFHack scripts
« Reply #471 on: December 25, 2013, 10:07:03 am »

Is it possible to add syndromes with the skillroll script?

EDIT: And is is possible to make it affected by mental or physical attributes instead of skills?
« Last Edit: December 25, 2013, 12:52:08 pm by Roses »
Logged

Putnam

  • Bay Watcher
  • DAT WIZARD
    • View Profile
Re: Putnam's DFHack scripts
« Reply #472 on: December 26, 2013, 07:59:46 pm »

1. Yeah, with some sort of syndrome add script.

2. Good idea, definitely possible.

Roses

  • Bay Watcher
    • View Profile
Re: Putnam's DFHack scripts
« Reply #473 on: December 27, 2013, 12:59:14 am »

Hmm, guess it's about time I start to learn about dfhack and how to write scripts then :)
Logged

Putnam

  • Bay Watcher
  • DAT WIZARD
    • View Profile
Re: Putnam's DFHack scripts
« Reply #474 on: December 27, 2013, 02:45:57 am »

Hmm, guess it's about time I start to learn about dfhack and how to write scripts then :)

Here's a function to apply the syndrome given a syn id to get you started:

Code: [Select]
local function alreadyHasSyndrome(unit,syn_id)
    for _,syndrome in ipairs(unit.syndromes.active) do
        if syndrome.type == syn_id then return true end
    end
    return false
end

local function assignSyndrome(target,syn_id) --taken straight from here, but edited so I can understand it better: https://gist.github.com/warmist/4061959/. Also implemented expwnent's changes for compatibility with syndromeTrigger.
    if target==nil then
        return nil
    end
    if alreadyHasSyndrome(target,syn_id) then
        local syndrome
        for k,v in ipairs(target.syndromes.active) do
            if v.type == syn_id then syndrome = v end
        end
        if not syndrome then return nil end
        syndrome.ticks=1
        return true
    end
    local newSyndrome=df.unit_syndrome:new()
    local target_syndrome=df.syndrome.find(syn_id)
    newSyndrome.type=target_syndrome.id
    newSyndrome.year=df.global.cur_year
    newSyndrome.year_time=df.global.cur_year_tick
    newSyndrome.ticks=1
    newSyndrome.unk1=1
    for k,v in ipairs(target_syndrome.ce) do
        local sympt=df.unit_syndrome.T_symptoms:new()
        sympt.ticks=1
        sympt.flags=2
        newSyndrome.symptoms:insert("#",sympt)
    end
    target.syndromes.active:insert("#",newSyndrome)
    return true
end

From there, you'll probably want something to search for a specific syn_class or something.

Cocoprimate

  • Bay Watcher
    • View Profile
Re: Putnam's DFHack scripts
« Reply #475 on: December 29, 2013, 11:20:11 pm »

Excuse me,

If I want to force a dragon to come, I have to type "force megabeast dragon"?
Logged
The story of Aban Diamondtowns the Charms of Society, dwarf legend, and his descent into the depths. (SPOILER)
http://www.bay12forums.com/smf/index.php?topic=79229.0

Putnam

  • Bay Watcher
  • DAT WIZARD
    • View Profile
Re: Putnam's DFHack scripts
« Reply #476 on: December 29, 2013, 11:22:32 pm »

You can't force any specific megabeast.

Cocoprimate

  • Bay Watcher
    • View Profile
Re: Putnam's DFHack scripts
« Reply #477 on: December 29, 2013, 11:31:36 pm »

So just "force megabeast" ?

Does it arrive automatically or does it take some time?
Logged
The story of Aban Diamondtowns the Charms of Society, dwarf legend, and his descent into the depths. (SPOILER)
http://www.bay12forums.com/smf/index.php?topic=79229.0

Putnam

  • Bay Watcher
  • DAT WIZARD
    • View Profile
Re: Putnam's DFHack scripts
« Reply #478 on: December 30, 2013, 12:09:02 am »

Should be quite presently after the command is issued.

If nothing happens, you haven't reached the conditions yet. Not much I can do about that AFAIK.

Meph

  • Bay Watcher
    • View Profile
    • worldbicyclist
Re: Putnam's DFHack scripts
« Reply #479 on: December 30, 2013, 12:53:43 am »

There also have to be megabeasts alive. Vanilla worldgen adds very few to the world, and most die. You could raise the amount in the adv. worldgen, to make sure you still got some to fight.
Logged
::: ☼Meph Tileset☼☼Map Tileset☼- 32x graphic sets with TWBT :::
::: ☼MASTERWORK DF☼ - A comprehensive mod pack now on Patreon - 250.000+ downloads and counting :::
::: WorldBicyclist.com - Follow my bike tours around the world - 148 countries visited :::
Pages: 1 ... 30 31 [32] 33 34 ... 44