Bay 12 Games Forum

Please login or register.

Login with username, password and session length
Advanced search  
Pages: [1] 2 3 ... 6

Author Topic: DFHack Plugin: Digging Invaders Version 0.6  (Read 59016 times)

expwnent

  • Bay Watcher
    • View Profile
DFHack Plugin: Digging Invaders Version 0.6
« on: June 11, 2013, 08:52:42 am »

This plugin makes it so that invaders can dig, remove buildings, and remove constructions in order to get to your dwarves. It still needs to be tested a lot more, but it seems to work well enough for now. Please tell me if there are any problems. Ideally, test it on as small a world as possible with a short history to minimize file size in case I need to see the save.

This is a beta. Please backup your saves before using, and regularly savescum as you use it. It seems to work but be careful.

Invaders will never dig unless they cannot path to any of your dwarves. If there's a path from the invaders to at least one of your dwarves, the plugin won't do anything until that is no longer the case. Otherwise, when there's a new invasion, the plugin runs a very complicated pathfinding algorithm from a selected invader to all of your dwarves. It then figures out what action is necessary, and assigns the job to the selected invader. This repeats until the invaders can path to one of your dwarves. By default, the job assigned is performed MUCH more slowly than the typical speed, so walling yourself off is a perfectly valid strategy if you think you can hold them off long enough for them to get bored and leave.

The plugin is highly configurable. You can set the pathfinding costs for walking, digging, removing buildings, removing "rough" constructions, and removing other constructions separately. Rough constructions are made from boulders. This makes it so that you can make invaders unlikely to dig if it is possible to reach your fort by only removing constructions and buildings, for example. You can also set the job delay for digging, removing buildings, and removing constructions. By default, the delay is 1000, which is probably too slow. The last time I checked, at just under 500 FPS, it took about a minute for them to dig out one tile. You can specify a set of races that are allowed to dig. Setting the cost of something to -1 disables it.

In order to prevent gruesome FPS death, you can specify the maximum number of edges per tick that the pathfinding algorithm will process. The default is 100. Setting it lower will make invaders take more in-game time to figure out how to dig to your dwarves, but will have less impact on FPS. Setting it higher does the opposite. Setting it to -1 removes the limit. You should set this to be as high as possible without noticeably lowering FPS.

There are still ways of making your fort uninvadable. The purpose of the plugin is to make the easiest ones less useful.


Known Limitations

There is currently no way of undigging the tiles that the invaders dig. I am open to suggestions of a fair way of doing this. I certainly don't want to create a way of repeatedly mining the same mineral veins indefinitely. To reduce the problem, increase the dig cost to something very high (1000000 should do, depending on the other costs) and ensure that there is a path to your dwarves that does not require any digging, or disable digging completely.

Ramps are extremely troublesome and made this plugin several times harder to write. Please test ramps thoroughly in combination with hatches, bridges, etc. I am not entirely certain they work.

Invaders do not properly avoid warm/wet stone. They will consider tiles that contain high water or any magma to be impassible, but they could accidentally trigger a flood.

Invaders do not attempt to avoid cave-ins. Fortunately, this rarely happens in practice. It is difficult to imagine a situation where invaders would cause a cave-in when the player did not deliberately design the fortress to make that happen.

Invaders do not build constructions or bridges. This means they cannot traverse empty space.

Invaders do not deconstruct bridges or unusable hatches. This is because deconstructing a hatch must be done from one tile over, and it's too complicated for now to make them possibly dig out one tile over specifically to be able to remove a hatch. Deconstructing a bridge is even worse, and could potentially even lead to an inconsistent invasion plan. Suppose that between point A and point B there's a bridge, and below part of the B side of the bridge is point C. They might decide to walk across the bridge, then deconstruct and dig down. This would cut off access to the rest of the invaders.

Invaders do not dig ramps, though they may use existing ones. If they could dig ramps, they might be able to get slightly shorter paths. It would also make the algorithm even more painfully complicated.

Invaders do not chop down trees. I have no intention of changing this.

Invaders do not have any way of draining liquids that may be in the way. If you have a fort submerged in water or magma, it is uninvadable.

All invaders use the same work costs for the distance metric, and all invaders have the same job delays. This can now be set separately.

If an invader is digging a tile, the tile will still flash in the same way as when one of your dwarves is digging. I don't know any easy way of fixing this.

Jobs assigned to invaders can be cancelled by the player. If this happens, they will just run the pathfinding algorithm again and probably reassign the same job. The job delay would start over in this case, so it's possible to cheat them into making no progress by repeatedly cancelling the jobs. I don't know a good way around this, but I consider it only a minor problem.

Invaders will only do one job at a time, even if multiple jobs could plausibly be done at the same time.

Invaders will only make a 1 tile wide path. Changing this would be massively difficult and would be of little value.

Every time invaders finish the most recent job, they start the pathfinding over again. This is because the state of the map may have changed while they were digging enough to change the most efficient path. It can also help reduce the issue that the distance metric does not perfectly measure the amount of work required.

If the state of the map changes sufficiently while computing pathfinding, then pathfinding will be started over. Cheating players can exploit this by having lots of strategically-placed repeater-powered doors and hatches that flip regularly. If the path that it computes is no longer a valid solution, pathfinding will start over. It does not have to remain the optimal path.

The pathfinding algorithm uses Dijkstra's algorithm, instead of A*. Any nontrivial admissible heuristic for A* would be too slow to compute due to the wide range of costs.

For a particular unit to be eligible, it must have at least one usable body part that can grasp, and all of its body parts that can grasp must be usable. Even if they have a hundred hands, chopping off even one makes them ineligible.

Invaders will not "cheat". They cannot, for example, deconstruct a building or construction from above or below.

Invaders are omniscient about the layout of the map, including unrevealed tiles. This is intentional. If they only knew about tiles they had already explored, they would end up digging much more.

Saving and loading will make pathfinding start over.


Download Link: http://dffd.wimbli.com/file.php?id=7748

This version of the plugin will ONLY work with DFHack version 0.34.11-r4. The link contains both the linux and the windows version of the plugin.

Type "help diggingInvaders" for exact usage.


Changelog:

0.6: Fixed a horrible game-crashing, save-corrupting bug. The bug only existed on windows, so linux users shouldn't panic, but maybe update just in case.
0.5: can set costs and delays for different races separately, and it differentiates between rough constructions (made from boulders) and smooth constructions (made from blocks or bars).
0.1: first release
« Last Edit: May 16, 2014, 11:07:59 am by expwnent »
Logged

Godlysockpuppet

  • Bay Watcher
  • [Insert wit here]
    • View Profile
Re: DFHack Plugin: Digging Invaders Version 0.1
« Reply #1 on: June 11, 2013, 11:21:04 am »

Wow... Does this actually work?  :o
Logged

Matoro

  • Bay Watcher
  • if you drive alone you drive with hitler
    • View Profile
Re: DFHack Plugin: Digging Invaders Version 0.1
« Reply #2 on: June 11, 2013, 01:19:28 pm »

Now make Forgotten Beasts and HFS dig and we have some serious problems.
Logged

expwnent

  • Bay Watcher
    • View Profile
Re: DFHack Plugin: Digging Invaders Version 0.1
« Reply #3 on: June 12, 2013, 03:27:52 pm »

Wow... Does this actually work?  :o

Yep!

Now make Forgotten Beasts and HFS dig and we have some serious problems.

They'd have to have a grasp in order to hold a pick, but I guess that'd be possible. It might even be possible to make reanimated limbs dig. That'd be both funny and terrifying.
Logged

Njals

  • Bay Watcher
    • View Profile
Re: DFHack Plugin: Digging Invaders Version 0.1
« Reply #4 on: June 13, 2013, 06:18:06 am »

They need to have a pick in the first place, don't they?

Pokolov

  • Escaped Lunatic
    • View Profile
    • WordPress plugins
Re: DFHack Plugin: Digging Invaders Version 0.1
« Reply #5 on: June 13, 2013, 06:58:26 am »

i think yes . That's really nice work thanks .
Logged

expwnent

  • Bay Watcher
    • View Profile
Re: DFHack Plugin: Digging Invaders Version 0.1
« Reply #6 on: June 13, 2013, 08:59:09 am »

They need to have a pick in the first place, don't they?

No, it'll just create one for them.
Logged

Meph

  • Bay Watcher
    • View Profile
    • worldbicyclist
Re: DFHack Plugin: Digging Invaders Version 0.1
« Reply #7 on: June 14, 2013, 06:06:53 am »

I love you.

I heard you speaking about this here and there, for months, but I did not realize it is close to beta. I wholeheartely approve, and will use this for my mod for sure. Not for goblins, but most likely the cavern races. Antmen and Skaven that dig into your fortress from the caverns.

It is always only one of the invaders that is able to dig?
Example: 100 units, 1 guy digging, with an automatically generated pick.

Can this designated digger be killed, to stop the mining? (or will he be replaced by his fellows)

Can digging animals be done? (Either targeted to your fortress, or digging around randomly like meandering animals walk around)

You say that can remove constructions. Wouldnt this cause them to simply raze a wall, instead of digging a tunnel underneath it? If yes, can it be seperated, to make one invader race be able to dig (Say: Ratmen), while another invader race is able to raze walls? (say: Giants)

Could smoothed walls/constructed walls be made safe? (like the Dungeon Keeper system, rock can be dug, but you can still secure yourself by building walls around you.)

I would love to help testing, but I only have access to a netbook that runs DF at 30-40fps, first year, 7 units. I cant do anything with it really.
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 :::

expwnent

  • Bay Watcher
    • View Profile
Re: DFHack Plugin: Digging Invaders Version 0.1
« Reply #8 on: June 14, 2013, 09:17:08 am »

It is always only one of the invaders that is able to dig?
Example: 100 units, 1 guy digging, with an automatically generated pick.

Can this designated digger be killed, to stop the mining? (or will he be replaced by his fellows)

One digger will dig at a time, but will be replaced if there's another eligible digger.

Can digging animals be done? (Either targeted to your fortress, or digging around randomly like meandering animals walk around)

Right now they'd just have to have a GRASP part for a pick. It's more set up for targetted digging. Digging around aimlessly would be possible, I guess. I'd have to think of a reasonable way of doing it though, and worry more about cave-ins.

You say that can remove constructions. Wouldnt this cause them to simply raze a wall, instead of digging a tunnel underneath it? If yes, can it be seperated, to make one invader race be able to dig (Say: Ratmen), while another invader race is able to raze walls? (say: Giants)

They remove constructions in the same way that your dwarves do. Different abilities of different races wouldn't be too complicated.

Could smoothed walls/constructed walls be made safe? (like the Dungeon Keeper system, rock can be dug, but you can still secure yourself by building walls around you.)

I could separate them into a different category. Then you could set cost, delay, and whether different races could get past them.
Logged

Deon

  • Bay Watcher
  • 💀 💀 💀 💀 💀
    • View Profile
Re: DFHack Plugin: Digging Invaders Version 0.1
« Reply #9 on: June 14, 2013, 10:44:36 am »

Quote
I could separate them into a different category. Then you could set cost, delay, and whether different races could get past them.
That would be amazing.
Logged
▬(ஜ۩۞۩ஜ)▬
✫ DF Wanderer ✫ - the adventure mode crafting and tweaks
✫ Cartographer's Lounge ✫ - a custom worldgen repository

Rumrusher

  • Bay Watcher
  • current project : searching...
    • View Profile
Re: DFHack Plugin: Digging Invaders Version 0.1
« Reply #10 on: June 14, 2013, 11:56:49 am »

next step is to have them build stuff and soon goblins could build a city on your doorstep.
Logged
I thought I would I had never hear my daughter's escapades from some boy...
DAMN YOU RUMRUSHER!!!!!!!!
"body swapping and YOU!"
Adventure in baby making!Adv Homes

Godlysockpuppet

  • Bay Watcher
  • [Insert wit here]
    • View Profile
Re: DFHack Plugin: Digging Invaders Version 0.1
« Reply #11 on: June 14, 2013, 12:05:21 pm »

I sent putnam a pm, and I thought I may as well share what I said here (It's an idea, please excuse the format as it was to putnam)
Spoiler (click to show/hide)
Logged

sackhead

  • Bay Watcher
    • View Profile
Re: DFHack Plugin: Digging Invaders Version 0.1
« Reply #12 on: June 15, 2013, 08:04:13 am »

that is just awsome
Logged

Di

  • Bay Watcher
    • View Profile
Re: DFHack Plugin: Digging Invaders Version 0.1
« Reply #13 on: June 15, 2013, 01:09:03 pm »

One digger will dig at a time, but will be replaced if there's another eligible digger.
Does eligible digger mean any invader of that race or eligible diggers are chosen at the beginning of the invasion?
Can we specify which caste is capable of digging?

You made me want to play DF again. (Not this week though, but I'll definitely try this a bit later)
Logged
Quote from: Creamcorn
Dwarf Fortress: Where you meet the limit of your imagination, moral compass, sanity and CPU processor.
http://www.bay12forums.com/smf/index.php?topic=103080.0 Fix sober vampires!
http://www.bay12forums.com/smf/index.php?topic=91442.0 Dwarven Cognitive Science

expwnent

  • Bay Watcher
    • View Profile
Re: DFHack Plugin: Digging Invaders Version 0.1
« Reply #14 on: June 15, 2013, 02:34:29 pm »

An eligible digger must be an invader of an appropriate race, and it must have a grasp part. You cannot specify it at a caste level. They are replaced if killed or made ineligible.
Logged
Pages: [1] 2 3 ... 6