Bay 12 Games Forum

Please login or register.

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

Author Topic: Forcing sieges - a script and research  (Read 15265 times)

mifki

  • Bay Watcher
  • works secretly...
    • View Profile
    • mifki
Forcing sieges - a script and research
« on: June 27, 2017, 07:10:29 pm »

I tried to force a siege by creating an army, a controller and targeting the fort. It seems to work just fine, so now I'm unsure whether just no one tried that, or there are known issues with this approach.

Anyway, here's the script https://gist.github.com/pronvit/e256267e3c65c0e89e08b1aa947df600

The script accepts the following parameters:

-civ HUMAN -race [ GOBLIN TOAD ] -count [ 2 10 ] -undead -debug -cleanup

-civ is optional. If not present, will find a civ for the first race. If present, it can be a race name (will find a civ), or a part of english civ name. Can also be "self" if you can't think of anything better.
-race is require and can be either one value or a list.
-count is required and can be either one value or a list with number of items matching races.
-undead is optional if you're a fan of corpses.
-debug is optional.
-cleanup is optional and will delete the created army controller.

I think doing the cleanup if generally better, but it needs more testing. I've had some crashes when generating a 100 goblin siege both with cleanup and without but not sure whether it's a vanilla DF crash because of a large number of units or is caused by the script.

There are also comments in the code about what some unidentified fields might do.

PatrikLundell

  • Bay Watcher
    • View Profile
Re: Forcing sieges - a script and research
« Reply #1 on: June 28, 2017, 03:01:35 am »

There's recently been a discussion about generating sieges in some thread on the forums (which you may have read already). What I understood from it was that DF had a tendency to crash on generation of invader units, in particular if many were generated at the same time.
Anyway, it's something I think those who want the old thin air regular sieges back could make use of, so it's a worthwhile research topic, although I don't have useful information.
Logged

danamlund

  • Escaped Lunatic
    • View Profile
Re: Forcing sieges - a script and research
« Reply #2 on: June 28, 2017, 09:58:32 am »

This script forces a real invasion.

This should completely eliminate crashes regarding unit spawn, because dwarf fortress knows how to spawn units without crashing itself. I spawned 200 units about 10 times without any crashes (I could not get my unit spawning script below a 20% crash rate)

It will also generate appropriate skills and equipment given the invading civilization (it even looks to be based on materials available to a given civilization in a given save).

This script also understands pets. A goblin invasion of 100 goblins and 100 cave dragons is great fun.

My only concern is how dwarf fortress handles armies created out of thin air. If an army flees, where does it go? could it wander around  and cause lag or crashes down the line? I did not try running a game fr a long time after an invasion.

It is easy to set up an appropriately challenging invasion with any combination of creatures you can think of.
It has great mod support because it automatically equips creatures with appropriate gear.

In short, this is extremely cool.

Some simple parameters I could get a lot of fun out of are: "-civ GOBLIN -race GOBLIN -count 200".
Parameters supporting multiple races would be even cooler, e.g.: "-civ GOBLIN -races [ GOBLIN OGRE CAVE_DRAGON ] -counts [ 100 20 5 ]"
Logged

Roses

  • Bay Watcher
    • View Profile
Re: Forcing sieges - a script and research
« Reply #3 on: June 28, 2017, 10:40:45 am »

This is very very promising. I never tried it myself but I know there were some attempts at creating armies that didn't play out, maybe you just were able to piece it all together!
Logged

scourge728

  • Bay Watcher
    • View Profile
Re: Forcing sieges - a script and research
« Reply #4 on: June 28, 2017, 01:35:52 pm »

Woah, this could be VERY useful for ending my fortress WITHOUT rendering it just as unplayable

mifki

  • Bay Watcher
  • works secretly...
    • View Profile
    • mifki
Re: Forcing sieges - a script and research
« Reply #5 on: June 28, 2017, 04:28:38 pm »

My only concern is how dwarf fortress handles armies created out of thin air. If an army flees, where does it go? could it wander around  and cause lag or crashes down the line? I did not try running a game fr a long time after an invasion.

The initial created army stops existing when it's converted to actual units on screen. I don't know what happens to fleeing invasion units - do they form another army or just disappear? Anyway, given the number of armies existing in game all the time (1000+), several more won't make big difference.

Some simple parameters I could get a lot of fun out of are: "-civ GOBLIN -race GOBLIN -count 200".
Parameters supporting multiple races would be even cooler, e.g.: "-civ GOBLIN -races [ GOBLIN OGRE CAVE_DRAGON ] -counts [ 100 20 5 ]"

Yep, I'll add those, but I'm better at research than maintaining in long term, so hopefully someone will create a proper script for inclusion in dfhack.


EDIT: Looks like the army is deleted but the army controller still exists after siege start. Maybe if they flee, they form a new army with that controller. We can either remove the controller ourselves or leave it as is and let them go. Somehow when in the beginning I was experimenting with races to get e.g. a toad invasion, they were always fleeing, but now I can't make them to, to see what happens.

PatrikLundell

  • Bay Watcher
    • View Profile
Re: Forcing sieges - a script and research
« Reply #6 on: June 29, 2017, 02:02:19 am »

I think there's a flag in the units that can be set to make them flee, but I've never used it.
Logged

Putnam

  • Bay Watcher
  • DAT WIZARD
    • View Profile
Re: Forcing sieges - a script and research
« Reply #7 on: June 29, 2017, 05:16:39 am »

now I'm unsure whether just no one tried that

i did, but the various parts of the stuff were less known

Hesperid

  • Bay Watcher
    • View Profile
Re: Forcing sieges - a script and research
« Reply #8 on: June 29, 2017, 07:52:20 am »

I've also toyed with armies and controllers, but never made a script for public consumption because the unknown variables being set to these magic values makes the new armies crash-prone in long term play.

They are clearly used for something, because they are set to various values in the armies the AI sends around, and are read by instructions when observed through a debugger. For example, the two values that you've commented as
Quote
-- these two are some histfig id, can be invalid so don't seem to affect anything

are in fact meant to be the army leader and the civ leader who sent the army. Other values don't even have a guess associated but are initialized anyway. Whoever uses this script is setting up their whole savegame for unpredictable segfaults somewhere in the future, and that's just the observable measure of whatever issues are arising from invalid army/controller values. You should back up the save prior to running this if you're attached to that world.
Logged

Rumrusher

  • Bay Watcher
  • current project : searching...
    • View Profile
Re: Forcing sieges - a script and research
« Reply #9 on: June 29, 2017, 08:42:23 am »

kinda wonder if this could be used to send armies to other npc sites to force a siege of their own? for adventure mode.
the idea of getting a sieged by another player fort seems like a fun project to set up.
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

Hesperid

  • Bay Watcher
    • View Profile
Re: Forcing sieges - a script and research
« Reply #10 on: June 29, 2017, 10:42:28 am »

You can set the target site and pathfinding target to whatever site you want, and then watch the army march there in adventure mode. Unfortunately when they arrive there you're most likely in for a segfault.

If you just guide an enemy army close to a site and then seal the deal by hopping out of travel mode to observe the battle in person, you can get the army to slaughter the whole village/site. This doesn't produce war/battle events for legends mode however, just X killed Y in Sitename -messages.
Logged

mifki

  • Bay Watcher
  • works secretly...
    • View Profile
    • mifki
Re: Forcing sieges - a script and research
« Reply #11 on: June 29, 2017, 05:12:21 pm »

are in fact meant to be the army leader and the civ leader who sent the army. Other values don't even have a guess associated but are initialized anyway. Whoever uses this script is setting up their whole savegame for unpredictable segfaults somewhere in the future, and that's just the observable measure of whatever issues are arising from invalid army/controller values. You should back up the save prior to running this if you're attached to that world.

Thanks, if you know which is who, would be good to name these two fields properly.

Of course it needs more testing but I wouldn't be so worried. We're not creating armies and releasing them to roam the world, the army is converted into actual units the very next tick and deleted, so if this doesn't crash, I don't think the values we set will matter later, especially taking into account that most of them look just like some parameters - as opposed to ids referencing other objects which may cause crashes if set to invalid values.

As I mentioned before, the army controller is not deleted, so that might be a problem. I'll now try to delete it, basically we want to use army/controller just to make the game create units for us the right way, and then we want to cleanup everything.

Roses

  • Bay Watcher
    • View Profile
Re: Forcing sieges - a script and research
« Reply #12 on: June 29, 2017, 05:45:39 pm »

I'll play around with this this weekend, I'll probably whip up one or two scripts for configurable sieges (I was in the middle of using the create-unit method) I'll probably try and add options for customizable equipments and skills. I know armies usually pick from the races available materials and items, but it would be nice if you could have a siege of say, 50 humans in full steel plate, or something. This will probably involve deleting all the equipment they arrive with and making plate equipment for them, but I was already doing that for the create-unit method so I should be able to just tie them together.

A couple questions before I start testing;

1. Have you tested the effects of all the hard coded numbers you have in there? (e.g. a.unk_a0 = 50) I don't want to go through the process of testing them all if they don't have any noticeable effects.
2. Can a single army have more than one b = df.army.T_unk_2c:new()?
3. Have you tried creating an army of your own race/civ and having it arrive at your fort? I'm just wondering what would happen.
4. What determines that the army arrives at your fort and not somewhere else? Is it ac.unk_8 = df.global.ui.site_id?
5. Are the units spawned historical figures? I'm assuming you aren't going to get any of the civs nobles or anything?
Logged

mifki

  • Bay Watcher
  • works secretly...
    • View Profile
    • mifki
Re: Forcing sieges - a script and research
« Reply #13 on: June 29, 2017, 06:10:14 pm »

I'll play around with this this weekend, I'll probably whip up one or two scripts for configurable sieges (I was in the middle of using the create-unit method) I'll probably try and add options for customizable equipments and skills. I know armies usually pick from the races available materials and items, but it would be nice if you could have a siege of say, 50 humans in full steel plate, or something. This will probably involve deleting all the equipment they arrive with and making plate equipment for them, but I was already doing that for the create-unit method so I should be able to just tie them together.

A couple questions before I start testing;

1. Have you tested the effects of all the hard coded numbers you have in there? (e.g. a.unk_a0 = 50) I don't want to go through the process of testing them all if they don't have any noticeable effects.
2. Can a single army have more than one b = df.army.T_unk_2c:new()?
3. Have you tried creating an army of your own race/civ and having it arrive at your fort? I'm just wondering what would happen.
4. What determines that the army arrives at your fort and not somewhere else? Is it ac.unk_8 = df.global.ui.site_id?
5. Are the units spawned historical figures? I'm assuming you aren't going to get any of the civs nobles or anything?

I'm now adding -civ -race -count parameters, so wait for an updated version.

1. I've added comments to those I've identified. In general, I'd expect T_unk_2c parameters to get reflected in units while other army parameters affect e.g. how it travels the world and therefore maybe not doing anything in our case, but of course if may not be true for some of them. The only thing I'm curious about is item_type/mat_type/mat_index which should do something since they're identified, but I couldn't notice any difference.

2. Sure.

3. I've tried, they seem to fight as usual.



4. Yes, if unk_8 is set to another value, the siege doesn't happen.

5. You get just regular units generated based on T_unk_2c. If you want histfigs you need to add them to army.members. Since that's more likely to have adverse effects on the world, I haven't tried.

Max™

  • Bay Watcher
  • [CULL:SQUARE]
    • View Profile
Re: Forcing sieges - a script and research
« Reply #14 on: June 29, 2017, 06:51:36 pm »

Huh, I've manipulated their position and shit all day long, fucked with the number of units present, never tried to just insert an army from scratch though, nicely done.

I know if flags[0] is true it's an adventurer army, I use that with gm-editor to hop around the map in travel mode.
I think the item/mat/type entries might be tent types?
I was thinking of the unk_8 as the target because I used that to move an army to a town I was in so they would march into town because they crashed me when I bumped into them in travel mode due to the game shitting itself trying to suddenly load ~4100 elves simultaneously in an ambush arrangement.
Logged
Pages: [1] 2 3