Bay 12 Games Forum

Please login or register.

Login with username, password and session length
Advanced search  
Pages: 1 ... 294 295 [296] 297 298 ... 373

Author Topic: DFHack 0.34.11 r3  (Read 1456120 times)

Meph

  • Bay Watcher
    • View Profile
    • worldbicyclist
Re: DFHack 0.34.11 r3
« Reply #4425 on: August 23, 2013, 12:50:25 am »

Putnam, thanks :) I can test this script on the crashing save I have, see what happens. I am curious what falconne/ag will say about it.

Once I am at it: I get these sometimes in the dfhack commmand window:

Soundesense-season cant find the correct season. I assume it is because I replaced the string dump for "has arrived on the calender" and "is upon you" with different wording, like "is upon you. Active Civs: Humans, Cave-Civs, Warlocks." I guess I can just alter the wording in the .lua to fit the new strings?
Quote
...DF v3f\Dwarf Fortress\hack\scripts/soundsense-season.lua:23: attempt to conca
tenate field '?' (a nil value)
stack traceback:
        ...DF v3f\Dwarf Fortress\hack\scripts/soundsense-season.lua:23: in funct
ion <...DF v3f\Dwarf Fortress\hack\scripts/soundsense-season.lua:21>

This is from some products in custom workshops. I dont know which script gives this errorlog, so I never quite figure out what to do about it. I just ignored it. Anyone knows the script name?
Quote
This script requires a workshop job selected in the 'q' mode
« Last Edit: August 23, 2013, 01:06:49 am by Meph »
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 :::

Putnam

  • Bay Watcher
  • DAT WIZARD
    • View Profile
Re: DFHack 0.34.11 r3
« Reply #4426 on: August 23, 2013, 12:54:43 am »

I just edited the script so that it checks the shortest hive product time after it loads a world. It probably won't work otherwise.

Newest version:

Code: [Select]
function buildingIsHive(building)
    if not string.find(tostring(building),"hivest") then return false else return true end
end

function itemIsHive(item)
    for k,v in ipairs(item.subtype.tool_use) do
        if v==12 then return true end
    end
    return false
end

function buildingHasProductButNoBees(building)
    local buildingHasProduct = false
    local buildingHasNoBees = true
    for k,v in ipairs(building.contained_items) do
        if string.find(v.item,"verminst") then return false end
        if string.find(v.item,"toolst") and not itemIsHive(v.item) then buildingHasProduct = true end
    end
    if buildingHasProduct then return true else return false end --already checked if bees; if bees, then false anyway.
end

function getShortestHiveProductTime()
    local shortestHiveProductTime = 2^128 --get a larger number than that for your time, eh?
    for _,creature in ipairs(df.global.world.raws.creatures.all) do
        for k,length in ipairs(creature.hive_product_1) do
            shortestHiveProductTime=(length<shortestHiveProductTime) and length or shortestHiveProductTime --neat but incomprehensible lua trick
        end
    end
    return shortestHiveProductTime
end

function checkForBuggyHives()
    for k,building in ipairs(df.global.world.buildings.all) do
        if buildingIsHive(building) and buildingHasProductButNoBees(building) then
            for _,v in building.contained_items do
                local item = v.item
                if string.find(v.item,"toolst") and itemIsHive(v.item) then item.flags.in_building=false end
            end
        end
    end
end

function fixHiveCrashRepeater()
    checkForBuggyHives()
    dfhack.timeout(shortestHiveProductTime-1,'ticks',fixHiveCrashRepeater) --if someone makes a hive that goes every 1 tick i would be so mad
end

dfhack.onStateChange.fixHiveCrash = function(code) --Many thanks to Warmist for pointing this out to me!
    shortestHiveProductTime=getShortestHiveProductTime()
    if code==SC_WORLD_LOADED then
        dfhack.timeout(1,'ticks',fixHiveCrashRepeater)
    end
end

dfhack.onStateChange.fixHiveCrash()

ag

  • Bay Watcher
    • View Profile
Re: DFHack 0.34.11 r3
« Reply #4427 on: August 23, 2013, 01:14:17 am »

This is more like it:

Code: [Select]
function process_hive(hive)
    for i,iinfo in ipairs(hive.contained_items) do
        if df.item_verminst:is_instance(iinfo.item) then
            return
        end
    end

    local found = false

    for i,iinfo in ipairs(hive.contained_items) do
        if iinfo.use_mode == 0 and iinfo.item.flags.in_building then
            found = true
            iinfo.item.flags.in_building = false
        end
    end

    if found then
        print('Fixed a broken hive at ('..hive.x1..','..hive.y1..','..hive.z..')')
    end
end

for i,hive in ipairs(df.global.world.buildings.other.HIVE) do
    process_hive(hive)
end

Also, I think you can't possibly time any repeating check to always catch the condition before a crash can happen unless you make it run every frame, because every hive has its own independent timers for creation of products and job creation (the crashing bit).
Logged

Meph

  • Bay Watcher
    • View Profile
    • worldbicyclist
Re: DFHack 0.34.11 r3
« Reply #4428 on: August 23, 2013, 01:17:21 am »

So I'll include the script, name it "crashfix_hive.lua", and let people know that this option exists, if they should have that problem again. And I'll try both scripts on that save. :)
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 :::

Putnam

  • Bay Watcher
  • DAT WIZARD
    • View Profile
Re: DFHack 0.34.11 r3
« Reply #4429 on: August 23, 2013, 01:21:34 am »

(i would go with ag's because he's totally right about that repeating thing)

ag

  • Bay Watcher
    • View Profile
Re: DFHack 0.34.11 r3
« Reply #4430 on: August 23, 2013, 01:32:06 am »

The best way to fix this crash is by a C++ tweak, because it can be made to run its code exactly when the function that crashes is called, and not at any other time. Plus, the check itself will incur almost no overhead.

Btw, note that you are supposed to use is_instance to check the type of objects, instead of comparing strings ;)
Logged

Boltgun

  • Bay Watcher
  • [UTTERANCES]
    • View Profile
Re: DFHack 0.34.11 r3
« Reply #4431 on: August 23, 2013, 02:58:16 pm »

In case you need a reaction randomly triggering a siege, here's a script :
https://gist.github.com/Devduweb/6323075

It requires the force event script. Depending of the given probabilities, will pick a civilization to lay siege on you.
You need to edit the 'entities' array first to fit your mod, currently there is all the vanilla civs, dwarves being commented out to prevent tragedies.

This ignores all triggers and such, and will create ambushes if the selected civilization do that.
Logged

Roses

  • Bay Watcher
    • View Profile
Re: DFHack 0.34.11 r3
« Reply #4432 on: August 24, 2013, 04:09:06 pm »

Is it possibly to add and remove creature classes with DFHack? Syndrome classes just aren't cutting it for what I want to do.
Logged

Putnam

  • Bay Watcher
  • DAT WIZARD
    • View Profile
Re: DFHack 0.34.11 r3
« Reply #4433 on: August 24, 2013, 04:10:44 pm »

No, not really. Creature classes are stored in the creature raw, not in the unit.

Meph

  • Bay Watcher
    • View Profile
    • worldbicyclist
Re: DFHack 0.34.11 r3
« Reply #4434 on: August 25, 2013, 04:27:24 am »

Roses, tell me what you try to do, maybe I can come up with something.
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 :::

Grewon

  • Escaped Lunatic
    • View Profile
Re: DFHack 0.34.11 r3
« Reply #4435 on: August 25, 2013, 08:56:28 am »

I modified warmist's syndrome script from here so that it searches for the vampire syndrome id by checking the syndrome's displayed name(in this case vampire), and then infects the selected unit with the vampire syndrome, effectively making him a vampire. It also seems to work with necromancers.
Code: [Select]
function assignSyndrome(target,syn_id)
    if target==nil then
        qerror("Not a valid target")
    end
    local ns=df.unit_syndrome:new()
    local trg_syn=df.syndrome.find(syn_id)
    ns.type=trg_syn.id
    --ns.year=
    --ns.year_time=
    ns.ticks=1
    ns.unk1=1
    for k,v in ipairs(trg_syn.ce) do
        local sympt=df.unit_syndrome.T_symptoms:new()
        sympt.ticks=1
        sympt.flags=2
        ns.symptoms:insert("#",sympt)
    end
    target.syndromes.active:insert("#",ns)
end
function makeVampire(unit)
for i=0,#df.global.world.raws.syndromes.all-1 do
for j=0,#df.global.world.raws.syndromes.all[i].ce-1 do
for k,v in pairs(df.global.world.raws.syndromes.all[i].ce[j]) do
if k=="name" then
if v=="vampire" then --this can be changed to necromancer
print("Found vampire syndrome id:"..i)
assignSyndrome(unit,i)
print("Infected unit with vampire syndrome.")
return
end
end
end
end
end
end
local unit=dfhack.gui.getSelectedUnit()
makeVampire(unit)


P.S. this simple cure script removes all syndromes in case you want to undo the effects of the first script, or even if you want to cure genuinely infected units.
Code: [Select]
local unit=dfhack.gui.getSelectedUnit()
while #unit.syndromes.active > 0 do
unit.syndromes.active:erase(0)
end
while #unit.body.wounds > 0 do
unit.body.wounds:erase(0)
end
unit.body.wound_next_id=1
Logged

Roses

  • Bay Watcher
    • View Profile
Re: DFHack 0.34.11 r3
« Reply #4436 on: August 25, 2013, 10:48:45 pm »

Roses, tell me what you try to do, maybe I can come up with something.

I want to make hybrid classes, so you have to get to say rank 2 warrior and rank 2 priest to become a rank 1 paladin. I can't think of a way to do this with syndrome classes and such because interactions only have IT_CANNOT_HAVE_SYNDROME_CLASS and syndromes allowed/iimmune tags are for creature classes. I suppose I could make separate castes for each rank and each rank combination, but I think that might become overwhelming.

What I would like the most is to not have to use transformations at all, honestly, but CE_DISPLAY_NAME is fixed once it is assigned and there is no way to change skill learn rates with syndromes. That way I could have castes that are more or less suited for different tasks, but let the player choose how they want to play.
« Last Edit: August 25, 2013, 11:51:54 pm by Roses »
Logged

Meph

  • Bay Watcher
    • View Profile
    • worldbicyclist
Re: DFHack 0.34.11 r3
« Reply #4437 on: August 26, 2013, 03:35:15 am »

Like you said, castes would allow more functionality, but are more difficult to set up.

What you can do is give all dwarves as self-targeted interaction, to be repeated every 5000 ticks or so that adds the SYN_CLASS:NO_PALADIN_W and NO_PALADIN_P (and all other hybrid-classes you want). Then, when the dwarf gets the warrior rank2, he gets an interaction that blocks NO_PALADIN_W. Priest Rank2 blocks NO_PALADIN_P. You can do this using cannot-have-syn-class. The Warrior2 interaction is selftargeted, has no end, and adds SYN_CLASS:BLOCK_NO_PALADIN_W, and the Priest2 interaction is selftargeted, has no end, and adds SYN_CLASS:BLOCK_NO_PALADIN_P. The paladin_w and paladin_p of course have CANNOT_HAVE_SYN_CLASS:BLOCK_NO_PALADIN_W/P.

Step1: Dwarf gets syn-classes that blocks Paladin Transformation.
Step2: Warrior and Priests get interactions that block the blocking interaction.
Step3: The dwarf is now a valid target for Paladin Transformation.
Step4: Profit.
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 :::

ag

  • Bay Watcher
    • View Profile
Re: DFHack 0.34.11 r3
« Reply #4438 on: August 26, 2013, 08:11:12 am »

Logged

Meph

  • Bay Watcher
    • View Profile
    • worldbicyclist
Re: DFHack 0.34.11 r3
« Reply #4439 on: August 26, 2013, 08:42:29 am »

Nice. :) I guess its better then the crashfix you posted earlier, because the crashfix must be run after someone knows that the problem exists, but this tweak will prevent the crash from happening in the first place? Do I have to compile it myself?  Its probably just me, but I couldnt find a download button. ^^

I also got this save send to me: http://dffd.wimbli.com/file.php?id=7931. The crashfix you posted does not fix it, and its not spatter-add, so if you have more time to spend on crashes, feel free to have a look. I can replicate the crash, but have no idea what might be the cause, as most of the time with crashes.  :-\
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 ... 294 295 [296] 297 298 ... 373