Bay 12 Games Forum

Please login or register.

Login with username, password and session length
Advanced search  

Show Posts

This section allows you to view all posts made by this member. Note that you can only see posts made in areas you currently have access to.

Topics - bloop_bleep

Pages: 1 [2] 3
16
How do I do what the title says? I know that I could do some arithmetic to look up which block the item is in, that loop through all the items in that block, checking if the coordinates match, but I feel like there's an easier way.

17
DF Modding / Script for asexual reproduction.
« on: October 21, 2017, 01:17:42 am »
Hey everyone,

I've been researching a lot of scripts recently and have finally lopped together Frankenstein-style a script that allows specified races to reproduce asexually. (Originally it was a script for a community fortress that allowed lawnmowers specifically to reproduce asexually, but I generalized it.) I was hoping all of you more experienced modders could take a look and see if I have done everything correctly. (I haven't tested it yet, unfortunately.)

Code: [Select]
local usage = [====[

asex_reproduce
==============
Allows asexual reproduction of specified races.

Arguments:

``-help``
    Prints this help message.
``-enable``
    Enables this script.
``-disable``
    Disables this script
``-start RACE -chance FLOAT -length NUMBER``
    Starts asexual reproduction for RACE. Every 50 ticks any non-pregnant members of RACE have a FLOAT chance of becoming pregnant. Pregnancies last for NUMBER ticks.
``-stop RACE``
    Stops asexual reproduction for RACE.
]===]


local utils = require 'utils'
local repeat_util = require 'repeat-util'

local IMPREGNATION_REPEAT = 50

local impregnation_table = {}
local rng = dfhack.random.new()

local function select_caste(race)
    local n = rng.random(99)
    local raws = df.global.world.raws.creatures.all[race]
    for i, chance in ipairs(raws.pop_ratio) do
        if n < chance then
            return i
        end
        n = n - chance
    end
end

--local function gen_random_genes(race, caste)
--end

local function impregnate_unit(unit, impregnation_data)
    unit.pregnancy_timer = impregnation_data.length
    unit.pregnancy_caste = select_caste(unit.race)
    unit.pregnancy_genes = unit.appearance.genes --gen_random_genes(unit.race, unit.pregnancy_caste)
end

local function impregnate_race(race_name, impregnation_data)
    for i, unit in ipairs(df.global.world.units.all) do
        if df.global.world.raws.creatures.all[unit.race_id] == race_name then
            if unit.pregnancy_timer == 0 then
                if generator.drandom() < impregnation_data.chance then
                    impregnate_unit(unit, impregnation_data)
                end
            end
        end
    end
end

local function impregnate_races()
    for race, data in pairs(impregnation_table) do
        impregnate_race(race, data)
    end
end



local function begin_scheduling()
    repeat_util.scheduleEvery('impregnate_races()', IMPREGNATION_REPEAT, 'ticks', impregnate_races)
end

local function stop_scheduling()
    repeat_util.cancel('impregnate_races()')
end

local enabled = true
begin_scheduling()

validArgs = validArgs or utils.invert({
    'help',
    'enable',
    'disable',
    'start',
    'chance',
    'length',
    'stop'
})

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

if args.help then
    print(usage)
    return
end

if args.enable and not enabled then
    enabled = true
    begin_scheduling()
    return
end

if args.disable and enabled then
    enabled = false
    end_scheduling()
    return
end

if args.start then
    impregnation_table[args.start] = { chance = tonumber(args.chance), length = tonumber(args.length) }
    return
end

if args.stop then
    impregnation_table:remove(args.stop)
    return
end

If you have any other suggestions/additions, let me know!

(Additional note: As you may see from the code, I was thinking of making the script randomly generate new genes, since currently it just copies the parent's genes, but I have no idea how to do that. Ideas?)

18
DF Modding / devel/watch-minecarts crashing
« on: September 28, 2017, 01:27:46 am »
I've encountered a strange problem. Whenever I boot up my save, the first time I run devel/minecarts, it outputs the entries for several vehicles, but then crashes with this message:

Code: [Select]
...XXXX\df_43_05_win/hack/scripts/devel/watch-minecarts.lua:17: attempt to index a nil value (local 'item')
stack traceback:
        ...XXXX\df_43_05_win/hack/scripts/devel/watch-minecarts.lua:17: in global 'compare_one'
        ...XXXX\df_43_05_win/hack/scripts/devel/watch-minecarts.lua:53: in global 'compare_all'
        ...XXXX\df_43_05_win/hack/scripts/devel/watch-minecarts.lua:74: in local 'script_code'
        C:\Users\XXXXX\df_43_05_win\hack\lua\dfhack.lua:562: in function 'dfhack.run_script_with_env'
        (...tail calls...)

The second and any subsequent times I run it, it outputs nothing and crashes with the same message. I have to completely reload DF to be able to get the first message again. What's going on here?

EDIT: While we're at it, does anybody know the solution to the very problem which prompted me to use watch-minecarts in the first place? Basically, I have a highest-speed roller on top of a spiraling downward track. The minecart would go down several z-levels and then derail diagonally. This sounds a lot like corner ramp derailing, but that only happens with upward corner ramps and in my design any extraneous velocity created by one corner ramp would be immediately remedied by the next corner.

19
Okay guys, I'm tired and should've probably have been in bed by now, but I just got a radical idea that is probably impossible and most definitely crazy.

What if we could allow steam machines to be built *without DFHack*? That is, pure vanilla raw modding.

Hear me out. Suppose we create 6 different material types -- north-flowing, south-flowing, west-flowing, east-flowing, up-flowing, and down-flowing steam. (They would all display as "Steam" in-game.) The trick here is we define steam pipes, valves, and all that as creatures, and have these steam types give syndromes to them.

For example, suppose we have an E/W steam pipe. West-flowing steam would trigger the pipe to produce more west-flowing steam, allowing the next E/W pipe to pick up that new steam, and the next, and so on. Similarly with east-flowing steam. However, all the other steam types won't affect the E/W pipe at all.

With corner pipes, steam of the type of *the opposite* of one of the corner directions would produce steam of the other corner direction. (In the case of a N/E pipe, S steam would produce E steam, and W steam would produce N steam.)

Valves can react to only one steam type. Suppose there is an E/W valve that only allows steam to flow E. E steam would affect the valve but W steam wouldn't.

Pressure-operated valves can also be made -- we could have an E/W valve allow passage only if it has a tag set by N steam.

There are a couple concerns:
  • Unless we can restrict the flow of steam in only one direction, steam can pass between pipes it shouldn't (e.g. two W/E pipes situated above each other vertically can pick up on each other's steam.)
  • I'm not that sure how it would possible to construct these machines in Fortress mode. We could use pastures, but then how do we make the components themselves? They are creatures, after all.
  • It doesn't fit into roleplay that well (and is a bit confusing) that steam components seem to be leaking steam.

Maybe this is all a sleep-deprived ramble or I actually have something here. I don't know. I'll find out in the morning.

20
Curses / What's going on in your LCS?
« on: August 25, 2017, 06:34:44 pm »
I've noticed there's no thread like this like there is in the upper forums. Basically, just post what's been happening recently in your LCS games.

I'll start. I'm a newbie, just started playing LCS a few days ago. I failed spectacularly due to stupid mistakes in my first few games (got my founder killed because I sent him to raid the crack house, accidentally bailed out of a car while trying to escape police, got my fighting squad accosted by police because I set them to do legal fundraising, etc.) I haven't died yet in my new game, though. I currently have a lot of sleeper judges, a pro hacking team, a decent fighting squad, and two heavily-upgraded and heavily-stocked safehouses. I've just started experimenting with seduction; I have a couple love-slaves already in my employ.

21
DF Dwarf Mode Discussion / Commanding dwarven armies
« on: August 12, 2017, 06:20:22 pm »
I have a question about the next release. If you become the mountainhome do you get to command your civilization's armies? I doubt it but I just wanted to check.

22
DF Adventure Mode Discussion / Do motor nerves heal?
« on: August 08, 2017, 10:27:06 pm »
Hello, I have a question. I brought my new peasant adventurer to a cathedral where a crime organization had taken up camp. I killed quite a few criminals, but eventually I was attacked by more of them than I could handle at one time. I was badly wounded and only managed to save myself by jumping into the cathedral's water pool. The health menu said that a motor nerve had been severed in my left hand; I got out of the water and waited for 2 in-game hours, but it still didn't heal.

My question is: is it possible for motor nerves to heal? I worked really hard on this adventure and don't want it to be cut short by something like this.

23
DF Modding / Mounts?
« on: August 01, 2017, 03:24:38 am »
How is it possible to determine/set the mount of a specific creature? I'm thinking of Lua scripts again.

24
DF Dwarf Mode Discussion / How to find out map rejection reasons
« on: July 29, 2017, 11:32:47 pm »
I'm trying to gen a world using the PerfectWorldDF utility and am having some trouble. I would like to know the reason my maps keep getting rejected; I didn't see anything in gamelog.txt or errorlog.txt, other than the acknowledgement that the world has started generating. Is there some setting I could use to log map rejections? Pretty much everything else seems to be logged in either of the two aforementioned files.

25
DF Adventure Mode Discussion / How to rip away weapon?
« on: July 27, 2017, 05:01:32 pm »
The answer to this might be obvious, but how do you rip away a weapon? I've been trying to learn Kisat Dur by storming a goblin fortress and have successfully grabbed a woodcutter's axe. The only options in the wrestle menu are to take down or to release.

26
DF Dwarf Mode Discussion / Ashes left over after forest fire
« on: July 27, 2017, 03:42:57 pm »
I have several questions about the ashes that are left over after a forest is devastated by a dragon or other such fire-breathing creature. Can they be removed at all, using water flushing or something like that? What will be left after the ashes are removed and can trees & vegetation grow again after the removal?

27
How do I allow an adventurer to interact with a custom item in his inventory in a specific way using the 'I' key?
Also, how do I temporarily override the function of a specific key and replace it with my own callback, and then be able to change it back?

I'm talking about Lua scripts now, not C++ plugins.

28
DF Adventure Mode Discussion / Best way to train fighting skills?
« on: June 30, 2017, 03:03:25 pm »
Hello everyone. I'm sure this has been asked before somewhere, but what is the best way to train fighting skills? I'm looking for something repetitive that I can do for a pretty long time without moving around too much. Wildlife seems to be too rare to efficiently do this, and going crundle-hunting in the caverns usually gets me lost. Though I suspect that it's probably because I usually go for the kill once I disable an opponent, instead of practicing on it, but I'm not sure which body parts I should attack and in which order for best training potential. Thanks in advance for any help.

EDIT: Also, my companion got badly injured after fighting a cyclops and is currently unconscious. Should I leave him there to die or is there a way to carry him?

29
DF Adventure Mode Discussion / Necromancer as ringleader
« on: June 29, 2017, 12:22:03 am »
Hello everyone. I'm a total noob at Adventure Mode, and I have a question. I made an adventurer, fully kitted him out in armor, gave him an axe and went off to go kill some bandits. I then happened to see a flashing N with a tilde over it. First I assumed it was a werebeast, but then I saw it was a necromancer ringleader. What should I do in this case? Perhaps I should take him out first so he can't raise any corpses? But what if there are more necromancers hiding there somewhere? Thanks in advance.

30
DF Modding / How to hide all below ground tiles
« on: June 25, 2017, 11:07:27 am »
Sorry for posting 2 new topics in less than a 12-hour period, but I have another problem. I revealed the whole map, but I didn't unreveal before I saved, meaning when I loaded the map back up again I couldn't unreveal. How do I rectify this? It's worth noting that I haven't dug anything out yet, so it is sufficient to simply hide all subterranean tiles. There's probably no tool that can do this, but perhaps someone can whip up a script? Thanks in advance.

Pages: 1 [2] 3