Bay 12 Games Forum

Please login or register.

Login with username, password and session length
Advanced search  
Pages: 1 ... 62 63 [64] 65 66 ... 242

Author Topic: DFHack 50.11-r6  (Read 795493 times)

Putnam

  • Bay Watcher
  • DAT WIZARD
    • View Profile
Re: DFHack 0.44.05-r2 | 0.44.07-alpha1 (dev)
« Reply #945 on: March 20, 2018, 04:52:02 am »

fix/dead-units

PatrikLundell

  • Bay Watcher
    • View Profile
Re: DFHack 0.44.05-r2 | 0.44.07-alpha1 (dev)
« Reply #946 on: March 20, 2018, 05:29:08 am »

Thanks Putnam!

The script looks a bit problematic to me at a first look. It looks a the "dead" flag, which seems to really be misnamed, as incoming invaders (and probably others) have this flag set before they enter the map, so that flag seems to be more of an "inactive" flag than a "not living any more" flag.
If I remember correctly, there's a "killed" flag, but I don't know if it's connected to only a subset of death causes.

Note that the above is preliminary guesswork, not any results and definitely not based on any testing, yet.

Edit: The first unit the script wanted to remove that wasn't "killed" was an incoming bugbat that couldn't enter because there was already a bugbat in the way. After a number of days the bugbat swarm shifted within the confined area they spawned in so the one the script wanted to remove could enter, and the script no longer wants to remove it (unsurprisingly).

Edit2: I've tried to reverse the incorrect removals of the script by locating all "dead" but not "killed" units that were in the "bad" vector but not the "active" one and move them. This resulted in a number of dead units appearing on the surface: a couple of giant fire-flies, a pile of wagon wood and dead yaks (I know I've had a bugged caravan earlier), and a ton of critters appearing in the cavern entrances, with lots of units still to enter. The dead unit list filled up with a fair number of units (but smaller than the total number killed), and the bogus equipment in my stocks disappeared. Interestingly, no sapient units appeared (4 yaks from the bugged caravan did). The dead unit list was easily cleared by running fix/dead-units again (with the script modified to only remove "killed" units, not ones merely "dead").
There's still more testing needed, as I'd need to see the script trying to remove a "civilized" unit to determine whether it ought to or not. Also, I haven't investigated where all the questers stuck in limbo went, i.e. if the units actually disappeared or if they are still there, just not with their equipment showing.

Edit 3: A lot of the units that were removed prematurely won't enter the map because there are now obstructions there (walls I've built to secure 2 caverns, a cavern tree). If the units' pos is hacked to a free spot corpses of the old ones spawn there (I guess the units spawn and then die of old age immediately) at a fairly slow pace. When reaching the end of the list some of the units are actually alive, and new ones won't enter at that spot until the one already there moves (I had that happen naturally with an FB earlier today, where it was announced but did not appear until a fair while later when a cave blob moved out of the spot).

Edit 4: Yes, the script definitely causes trouble with inbound legal units. I've just had an announcement of 82 quester units in one fat dump, and when I run the script after about half of them had entered the map it seems to want to remove the other half.

Edit 5: And at least one of them is one who's been in limbo for entering my fortress 11 years ago, while another one is fresher. Anyway, it seems moving units back from "bad" to "active" can get them back into play.
« Last Edit: March 20, 2018, 12:44:34 pm by PatrikLundell »
Logged

FantasticDorf

  • Bay Watcher
    • View Profile
Re: DFHack 0.44.05-r2 | 0.44.07-alpha1 (dev)
« Reply #947 on: March 21, 2018, 01:06:50 pm »

Grown wood was recently discovered to be sorted as a exclusively non-plant/animal object when sorted by stockpiles, as well as its further products (cages, goods, logs, armor, training weapons) when produced by elves with the occasional bug where the objects are mis-represented, would it be at all possible to identify the boolean as mentioned by Toady and apply the value and description onto objects at will? I may just be behind in my knowledge of the GM-editor's new and/or forgetting its current functions though since i haven't used df-hack since 43.05

I would think it opens possibilities somewhere for people who want to pursue using these objects.
Logged

PatrikLundell

  • Bay Watcher
    • View Profile
Re: DFHack 0.44.05-r2 | 0.44.07-alpha1 (dev)
« Reply #948 on: March 21, 2018, 02:15:25 pm »

Grown wood was recently discovered to be sorted as a exclusively non-plant/animal object when sorted by stockpiles, as well as its further products (cages, goods, logs, armor, training weapons) when produced by elves with the occasional bug where the objects are mis-represented, would it be at all possible to identify the boolean as mentioned by Toady and apply the value and description onto objects at will? I may just be behind in my knowledge of the GM-editor's new and/or forgetting its current functions though since i haven't used df-hack since 43.05

I would think it opens possibilities somewhere for people who want to pursue using these objects.
item_flags2.grown?
Logged

AVE

  • Bay Watcher
    • View Profile
Re: DFHack 0.44.05-r2 | 0.44.07-alpha1 (dev)
« Reply #949 on: March 27, 2018, 07:39:36 am »

Can artifact-quality level items be generated with dfhack (looks like create-item can support only masterwork quality level)? If not, is it due to the need to write artifact item into the history of the world?
Logged

PatrikLundell

  • Bay Watcher
    • View Profile
Re: DFHack 0.44.05-r2 | 0.44.07-alpha1 (dev)
« Reply #950 on: March 27, 2018, 09:45:14 am »

Can artifact-quality level items be generated with dfhack (looks like create-item can support only masterwork quality level)? If not, is it due to the need to write artifact item into the history of the world?
Without knowing what the script looks like, artifacts indeed require extra efforts, such as creating an artifact record for them and enter that into the artifact structure. You'd also need to set the artifact flag in the item, but that's trivial. I don't know if you also have to enter an entry about its creation in the history. Someone has made some kind of artifake mod, which you may want to look at (although that still doesn't guarantee what's done there is "complete").
Logged

AVE

  • Bay Watcher
    • View Profile
Re: DFHack 0.44.05-r2 | 0.44.07-alpha1 (dev)
« Reply #951 on: March 27, 2018, 10:17:09 am »

Artifake just sets item quality to 6, removes wear and wear-timer (both are set to 0) and in case of weapon ups his sharpness to 10000. It is nothing done there in order to properly insert artifact into the world, it is just crude advmode cheat from its looks.
Logged

Putnam

  • Bay Watcher
  • DAT WIZARD
    • View Profile
Re: DFHack 0.44.05-r2 | 0.44.07-alpha1 (dev)
« Reply #952 on: March 27, 2018, 02:35:33 pm »

Code: (custom-artifact.lua) [Select]
-- Makes it so that the world will always have certain artifacts in certain sites when world loads.
--@ module = true
--Author Putnam

local usage = [===[

modtools/custom-artifact
=====================
This tool, when run, checks if the specific item has an artifact record somewhere in the world
and places the artifact at a valid site (which can be constrained by arguments) if it is not found.

Arguments::

    -itemType type
        the type of item that will have an artifact spawned
        examples:
            WEAPON:ITEM_WEAPON_PICK
            RING
     -itemMat mat
         the material of the newly generated item
         examples:
            INORGANIC:IRON
            CREATURE_MAT:DWARF:BRAIN
            PLANT_MAT:MUSHROOM_HELMET_PLUMP:DRINK
     -name name
        the item's name
        should be set, will just go with no name if not
     -amount num
         the minimum artifacts required
         will continue to create new artifacts until this amount is reached
         this argument is optional and will default to 1
     -ignoreExisting
         will create (num) artifacts named (name) regardless of existing artifacts of that type
         do not use in onload scripts, will overrun world with that artifact type given enough reloads
     -specificEntityType [ entity1 entity2 ... ]
        entity filter, will only spawn in these entity's sites
        examples:
            MOUNTAIN
            EVIL
            FOREST
            PLAINS
     -specificSiteType [ site1 site2 ... ]
        site filter, will only spawn in these site types
        examples:
            CAVE_DETAILED
            DARK_FORTRESS
            TREE_CITY
            CITY
     -help
         displays this message
]===]

local utils=require('utils')

validArgs = utils.invert({
    'itemType',
    'amount',
    'itemMat',
    'specificEntityType',
    'specificSiteType',
    'ignoreExisting',
    'name',
    'help'
})

function getItemType(item) --just kinda grabbed this from item-trigger, like the help dialogue above
    local itemType
    if item:getSubtype() ~= -1 and dfhack.items.getSubtypeDef(item:getType(),item:getSubtype()) then
        itemType = df.item_type[item:getType()]..':'..dfhack.items.getSubtypeDef(item:getType(),item:getSubtype()).id
    else
        itemType = df.item_type[item:getType()]
    end
    return itemType
end

function mysplit(inputstr, sep) --https://stackoverflow.com/questions/1426954/split-string-in-lua
    if sep == nil then
        sep = "%s"
    end
    local t={} ; i=1
    for str in string.gmatch(inputstr, "([^"..sep.."]+)") do
        t[i] = str
        i = i + 1
    end
    return t
end

local function findTranslation(str)
    for k,v in ipairs(df.global.world.raws.language.translations) do
        if v.name==str then return k,v end
    end
    return false
end

function createArtifact(itemType,itemSubtype,name,material,entityFilter,siteFilter)
    local newArtifact = df.artifact_record:new()
    newArtifact.id=df.global.artifact_next_id
    local rng=dfhack.random.new(os.time(),df.global.artifact_next_id)
    local eligibleSites={}
    for _,site in ipairs(df.global.world.world_data.sites) do
        if site.civ_id~=-1 then
            local thisSiteType=df.site_type[site.type]
            if thisSiteType and (not entityFilter or entityFilter[df.historical_entity.find(site.civ_id).entity_raw.code]) and (not siteFilter or siteFilter[thisSiteType]) then
                table.insert(eligibleSites,site.id)
            end
        end
    end
    local pickedSite=eligibleSites[rng:random(#eligibleSites)+1]
    newArtifact.anon_1=-1000000  --TODO: REPLACE REPLACE REPLACE REPLACE REPLACE ALL OF THESE ANON IS BAD
    newArtifact.anon_2=-1000000
    newArtifact.anon_3=-1000000
    newArtifact.anon_4=pickedSite
    newArtifact.anon_5=1
    newArtifact.anon_6=-1
    newArtifact.anon_7=-1
    newArtifact.anon_8=-1
    newArtifact.anon_12=pickedSite
    newArtifact.anon_13=1
    newArtifact.anon_14=-1
    newArtifact.anon_15=-1
    newArtifact.anon_16=-1
    newArtifact.anon_17=250
    newArtifact.anon_18=0
    newArtifact.anon_19=3
    if name then
        newArtifact.name.has_name=true
        newArtifact.name.first_name=name
    end
    local newUnit = df.unit:new() --temp boi
    newUnit.pos.x=df.global.world.units.active[0].pos.x
    newUnit.pos.y=df.global.world.units.active[0].pos.y
    newUnit.pos.z=df.global.world.units.active[0].pos.z
    local newItem = df.item.find(dfhack.items.createItem(itemType,itemSubtype,material.type,material.index,newUnit))
    newUnit:delete()
    newUnit=nil
    newItem.id=df.global.item_next_id
    newItem.pos.x=-30000
    newItem.pos.y=-30000
    newItem.pos.z=-30000
    local artifactRef=df.general_ref_is_artifactst:new()
    artifactRef.artifact_id=newArtifact.id
    newItem.general_refs:insert('#',artifactRef)
    newItem.flags.artifact=true
    newItem.flags.artifact_mood=true
    newItem.maker=-1
    newItem.masterpiece_event=-1
    newItem.quality=df.item_quality.Artifact
    newArtifact.item=newItem
    local newEvent=df.history_event_artifact_storedst:new()
    newEvent.artifact=newArtifact.id
    newEvent.unit=-1
    newEvent.histfig=-1
    newEvent.site=pickedSite
    df.global.world.history.events:insert('#',newEvent)
    df.global.world.artifacts.all:insert('#',newArtifact)
    df.world_site.find(pickedSite).artifacts:insert('#',newArtifact)
    df.global.artifact_next_id=df.global.artifact_next_id+1
end

if moduleMode then
    return
end

local args = utils.processArgs({...}, validArgs)

if args.help or not args.itemType or not args.itemMat then
    print(usage)
    return
end

local itemType,itemSubtype

local itemTypeSplit=mysplit(args.itemType,':')

local itemTypeStr,itemSubtypeStr=itemTypeSplit[1],itemTypeSplit[2]

itemType=df.item_type[itemTypeStr]

if not itemType then
    qerror('Could not find item type: '..args.itemType)   
end

if #itemTypeSplit>1 then
    local temp
    for _,itemdef in ipairs(df.global.world.raws.itemdefs.all) do
        if itemdef.id == itemSubtypeStr then
            itemSubtype=itemdef.subtype
            break
        end
    end
    if not itemSubtype then
        qerror('Could not find item type: '..args.itemType)
    end
end

args.amount=args.amount and tonumber(args.amount) or 1

local totalArtifactsOfItemType=0

if not args.ignoreExisting then
    for k,v in ipairs(df.global.world.artifacts.all) do
        if getItemType(v.item)==args.itemType then
            totalArtifactsOfItemType=totalArtifactsOfItemType+1
        end
    end
end

local itemMat=args.itemMat and dfhack.matinfo.find(args.itemMat) or false

if totalArtifactsOfItemType<args.amount then
    for i=totalArtifactsOfItemType,args.amount-1,1 do
        createArtifact(itemType,itemSubtype,args.name,itemMat,args.specificEntityType and utils.invert(args.specificEntityType),args.specificSiteType and utils.invert(args.specificSiteType))
    end
end

This could likely be rather easily modified so that it keeps the artifact within the current dwarf mode site.

lethosor

  • Bay Watcher
    • View Profile
Re: DFHack 0.44.05-r2 | 0.44.07-beta1 (dev)
« Reply #953 on: March 29, 2018, 08:51:37 am »

A couple people asked for support for Toady's fixed 0.44.07 Linux build, so here is a release for that:
https://github.com/DFHack/dfhack/releases/edit/0.44.07-beta1

(In hindsight, I should have known Toady was going to release 0.44.08 around then...)
Logged
DFHack - Dwarf Manipulator (Lua) - DF Wiki talk

There was a typo in the siegers' campfire code. When the fires went out, so did the game.

PatrikLundell

  • Bay Watcher
    • View Profile
Re: DFHack 0.44.05-r2 | 0.44.07-beta1 (dev)
« Reply #954 on: March 29, 2018, 09:08:17 am »

It's unfortunate fix/dead-units wasn't fixed, as it currently causes harm.
Logged

lethosor

  • Bay Watcher
    • View Profile
Re: DFHack 0.44.05-r2 | 0.44.07-beta1 (dev)
« Reply #955 on: March 29, 2018, 09:23:54 am »

Sorry. I checked for pull requests but not issues, so I missed it.
Edit: merged the flags2.killed change, and confirmed that it no longer affects a test caravan in ways that it shouldn't.
« Last Edit: March 29, 2018, 09:48:38 am by lethosor »
Logged
DFHack - Dwarf Manipulator (Lua) - DF Wiki talk

There was a typo in the siegers' campfire code. When the fires went out, so did the game.

PatrikLundell

  • Bay Watcher
    • View Profile
Re: DFHack 0.44.05-r2 | 0.44.07-beta1 (dev)
« Reply #956 on: March 29, 2018, 10:55:56 am »

Sorry. I checked for pull requests but not issues, so I missed it.
Edit: merged the flags2.killed change, and confirmed that it no longer affects a test caravan in ways that it shouldn't.
The reason I made an issue rather than a pull request was that I had made a few other changes I wanted comments on before creating a pull request...
I don't think a caravan is a good positive test subject, as there's a specific check for merchants that should exclude those from being culled when they shouldn't. Still, the flags2.killed flag is the important part.
Logged

lethosor

  • Bay Watcher
    • View Profile
Re: DFHack 0.44.05-r2 | 0.44.08-alpha1 (dev)
« Reply #957 on: March 29, 2018, 01:12:54 pm »

New release with 0.44.08 support and that fix: https://github.com/DFHack/dfhack/releases/tag/0.44.08-alpha1
Logged
DFHack - Dwarf Manipulator (Lua) - DF Wiki talk

There was a typo in the siegers' campfire code. When the fires went out, so did the game.

PatrikLundell

  • Bay Watcher
    • View Profile
Re: DFHack 0.44.05-r2 | 0.44.08-alpha1 (dev)
« Reply #958 on: March 29, 2018, 01:47:09 pm »

That was very quick!
Logged

lethosor

  • Bay Watcher
    • View Profile
Re: DFHack 0.44.05-r2 | 0.44.08-alpha1 (dev)
« Reply #959 on: March 29, 2018, 01:56:35 pm »

Indeed. Ben's script to automatically find symbols finished about a minute before Toady's devlog post:
Spoiler (click to show/hide)
Logged
DFHack - Dwarf Manipulator (Lua) - DF Wiki talk

There was a typo in the siegers' campfire code. When the fires went out, so did the game.
Pages: 1 ... 62 63 [64] 65 66 ... 242