Bay 12 Games Forum

Please login or register.

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

Author Topic: Possibility of creating multi-tile creatures (now under development)  (Read 6413 times)

bloop_bleep

  • Bay Watcher
    • View Profile

So, I was thinking that it might not be completely impossible to implement multi-tile creatures with DFHack.

The basic idea I had was this -- multi-tile creatures would consist of a "parent" creature and many "child" creatures. The parent creature is the creature that gets exposed to legends mode and historical records ("<name> is a <parent creature>. It was one of the first of its kind." or "This <parent creature> has devoured ten in its lust for blood!"), while the child creatures get exposed to direct adventure/fortress mode gameplay. The children would each represent one tile of the creature, and would be connected to each other using a network of either dragging or grappling references. Units in adventure mode or fortress mode would interact with each child creature separately, attacking its components as if it were standalone.

There are several accomplishments that have to be made in order for this to work:

  • Prevent children creatures from being exposed to legends mode records. Some of this can be accomplished by adding [DOES_NOT_EXIST] to children creatures, but creating them anyway when it is determined that a multi-tile creature should be spawned. Additionally, whenever a child creature becomes a histfig, through killing a fortress member or something similar, the histfig endowment could be passed along to the parent creature, or deleted if the parent is already a histfig.
  • Prevent parent creatures from being exposed to direct adventure/fortress mode gameplay. For this, I am very doubtfully guessing that it might be sufficient to just set the position to (-30000, -30000, -30000), as if the unit is offloaded, and nullifying any position-dependent data like pathing information. Something else might be needed, though.
  • Bridge the gap between parent and children creatures, so that effects to one happen to the other as well. The most important aspect of this is that injuries to one class of creature correspond to injuries to the other class of creatures. This just might be accomplished, just might, by making the parent and child creatures share the same body part pointers (though of course each child would only have the body parts that logically should be part of itself.) Another thing that this implies is that when parent creatures appear in adventure/fortress mode, the child creatures spawn as well. This can be done by nullifying parent creatures on loading as described above and creating all the child creatures according to the body parts of the parent.
  • Implement AI for the whole multi-tile creature. Quite possibly the hardest of the bunch. This has two categories.
    • Peaceful movement AI. Using dragging references, it might be possible to avoid doing very much at all -- only one of the children would be allowed to path (the only one that is not being dragged), and the rest would just follow behind.
    • Combat AI. At first this can just be left to the default -- only the child creatures able to touch the opponent will attack, and the rest of the body would stay in place. (Or perhaps the pathing child will charge at the opponent, bringing the rest of the body which will attack as well?) Once a more sophisticated combat AI is desired, one possibility is very temporarily placing the parent creature on top of the attacker, and letting it choose an attack. Then whichever body part(s) are chosen to attack will begin to move towards the opponent. The time cost for each attack could be dynamically changed to account for the time needed for the requisite child creature to move into place.

Are there any thoughts on this, and further suggestions on how this might be done? I might start working on this, after I get my moving-machines plugin up to the point I want it.
« Last Edit: March 10, 2019, 02:30:27 pm by bloop_bleep »
Logged
Quote from: KittyTac
The closest thing Bay12 has to a flamewar is an argument over philosophy that slowly transitioned to an argument about quantum mechanics.
Quote from: thefriendlyhacker
The trick is to only make predictions semi-seriously.  That way, I don't have a 98% failure rate. I have a 98% sarcasm rate.

Rumrusher

  • Bay Watcher
  • current project : searching...
    • View Profile
Re: Possibility of creating multi-tile creatures (discussion)
« Reply #1 on: January 20, 2019, 12:39:30 pm »

well you could just have a snake be made up of multiple units being dragged around by a chain, and Wagons do exist.
probably doable to make a bunch of units just share the same historical unit id so they all register their actions under the same name and title.
having created a multi tiled wagon dragon through use of chaining up a bunch of wagons together through a drag script


the head is the only one able to move around and attack, the others are in a constant state of being tug along
...or just dfhack edit the image tile that represents the unit and have it span across multiple tiles.
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

Bumber

  • Bay Watcher
  • REMOVE KOBOLD
    • View Profile
Re: Possibility of creating multi-tile creatures (discussion)
« Reply #2 on: January 20, 2019, 07:25:36 pm »

The hardest part would be preventing them from trying to run through 1-tile openings when the combat AI kicks in. Would it be best to just have them be immobile and teleport them around? That might make it hard to keep track of their current speed, though. Best bet would be to somehow disable the AI and do your own basic one. Peaceful wandering would be simple enough, but combat pathing sounds really difficult.

...or just dfhack edit the image tile that represents the unit and have it span across multiple tiles.
You'd want to be able to target and attack the parts.
« Last Edit: January 20, 2019, 07:34:22 pm by Bumber »
Logged
Reading his name would trigger it. Thinking of him would trigger it. No other circumstances would trigger it- it was strictly related to the concept of Bill Clinton entering the conscious mind.

THE xTROLL FUR SOCKx RUSE WAS A........... DISTACTION        the carp HAVE the wagon

A wizard has turned you into a wagon. This was inevitable (Y/y)?

bloop_bleep

  • Bay Watcher
    • View Profile
Re: Possibility of creating multi-tile creatures (discussion)
« Reply #3 on: January 20, 2019, 10:21:05 pm »

Oh, yeah... multi-tile creatures can't path to the same places that normal ones can...

Alright, time to formally define/expand upon some of the idea. Multi-tile creatures will be defined as a directed tree of creatures, every creature (expect one -- the root creature) having a parent. The creatures, at all times, must satisfy two constraints:

  • No two creatures can occupy the same position.
  • Every creature, except the root, must always be adjacent (possibly diagonally) to its parent.

Then, define the width of a creature tree as:

  • If the tree has one node, the width is 1.
  • If the tree has more than one node, the width is the sum of widths of the sub-trees.

Let us suppose that all multi-tile creatures can fit through spaces that are at least as wide as the tree. (This is... not actually true, but let us assume it for the purpose of simplicity.)

Define w as the width of a particular creature tree. Then, it will probably be necessary to re-implement the A* search algorithm, which is the same as the original except it only allows tiles where the entirety of a w * w square centered on the tile is walkable. Then the rest of the multi-creature can be situated within the w-wide path that the root creature "sweeps out" as it moves.

Although the A* algorithm can work without storing information between runs, it might prove to be a performance benefit to maintain at least some sort of walkability cache for each type of multi-tile creature present on the map at any time. It will probably increase RAM usage by a lot, so maybe it could be enabled only when they are at most a certain number of types of multi-tile creatures present on the map. Though, as they say, premature optimization is the root of all evil, so this will only come much further into development.

EDIT: Come to think of it, the multi-tile cache could just consist of booleans instead of the full 16-bit integers of the original walkability cache, so RAM usage might not be all that bad.
« Last Edit: January 20, 2019, 10:24:42 pm by bloop_bleep »
Logged
Quote from: KittyTac
The closest thing Bay12 has to a flamewar is an argument over philosophy that slowly transitioned to an argument about quantum mechanics.
Quote from: thefriendlyhacker
The trick is to only make predictions semi-seriously.  That way, I don't have a 98% failure rate. I have a 98% sarcasm rate.

Rumrusher

  • Bay Watcher
  • current project : searching...
    • View Profile
Re: Possibility of creating multi-tile creatures (discussion)
« Reply #4 on: January 20, 2019, 10:43:10 pm »

hmm animated trees sounds like a cool concept.
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

bloop_bleep

  • Bay Watcher
    • View Profile
Re: Possibility of creating multi-tile creatures (discussion)
« Reply #5 on: January 20, 2019, 11:52:33 pm »

hmm animated trees sounds like a cool concept.

That could also be possible, with an immobile multi-tile machine, but on top of pathing there's also the problem of motor planning of the limbs, which could end up being even more complex, especially in combat.
Logged
Quote from: KittyTac
The closest thing Bay12 has to a flamewar is an argument over philosophy that slowly transitioned to an argument about quantum mechanics.
Quote from: thefriendlyhacker
The trick is to only make predictions semi-seriously.  That way, I don't have a 98% failure rate. I have a 98% sarcasm rate.

Warmist

  • Bay Watcher
  • Master of unfinished jobs
    • View Profile
Re: Possibility of creating multi-tile creatures (discussion)
« Reply #6 on: January 21, 2019, 03:24:21 am »

i'm just posting to say you are insane!

Keep it up :)

Meph

  • Bay Watcher
    • View Profile
    • worldbicyclist
Re: Possibility of creating multi-tile creatures (discussion)
« Reply #7 on: January 21, 2019, 04:00:33 am »

Suggestions for creatures:
 - Whales
 - Sea snakes
 - Jellyfish
 - Giant worms
 - Giant snakes
 - Golems/Clouds
 - Armies of tiny units, like fairies/insects
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 :::

bloop_bleep

  • Bay Watcher
    • View Profile
Re: Possibility of creating multi-tile creatures (discussion)
« Reply #8 on: January 23, 2019, 12:22:51 am »

Suggestions for creatures:
 - Whales
 - Sea snakes
 - Jellyfish
 - Giant worms
 - Giant snakes
 - Golems/Clouds
 - Armies of tiny units, like fairies/insects

Though all of those are great suggestions, the idea I was thinking of was that the plugin would be able to load multi-tile creature descriptions from a file, like perhaps a new type of raw file. In that case modders using my plugin could just write into a text file instead of editing my code directly.

And I was also focusing my thought process around "limb-y" creatures, since those have easily-definable components. Whales and stuff like that might have potentially hundreds of creatures inside, so defining each of those separately in a raw file would be nigh-impossible. Not to mention the performance hit from that, without special optimization. Maybe later I could add layer definitions to multi-tile creatures, so you could simply specify a three-thick layer of "blubber" units at some position within the multi-tile creature.
Logged
Quote from: KittyTac
The closest thing Bay12 has to a flamewar is an argument over philosophy that slowly transitioned to an argument about quantum mechanics.
Quote from: thefriendlyhacker
The trick is to only make predictions semi-seriously.  That way, I don't have a 98% failure rate. I have a 98% sarcasm rate.

bloop_bleep

  • Bay Watcher
    • View Profile
Re: Possibility of creating multi-tile creatures (discussion)
« Reply #9 on: March 10, 2019, 04:42:21 am »

So! I have been working on this recently, and have gotten to the first milestone of merely loading the creature template and spawning multi-tile creatures on request!

The currently available commands are "mtcreatures load" and "mtcreatures spawn" -- the former takes the absolute path to a file of a creature template as the only argument, while the latter takes the creature template ID and the ID of the root unit to spawn from, in that order.

"mtcreatures load" loads a creature template into memory and assigns it the next ID in line. The creature template file is a text file with that is constructed using certain rules; these rules and a sample is given below.


Code: (test_mtc.txt) [Select]
<start>
DWARF
0
<start>
DWARF
1
<end>
<start>
DWARF
2
<end>
<end>

Using the above template I was able to spawn a three-dwarf conglomerate in arena mode (root is bottom right).



I can post the source code if anyone is interested in seeing it.
« Last Edit: March 22, 2019, 11:26:17 pm by bloop_bleep »
Logged
Quote from: KittyTac
The closest thing Bay12 has to a flamewar is an argument over philosophy that slowly transitioned to an argument about quantum mechanics.
Quote from: thefriendlyhacker
The trick is to only make predictions semi-seriously.  That way, I don't have a 98% failure rate. I have a 98% sarcasm rate.

Bumber

  • Bay Watcher
  • REMOVE KOBOLD
    • View Profile
Re: Possibility of creating multi-tile creatures (now under development)
« Reply #10 on: March 11, 2019, 12:05:59 pm »

7 dwarves combine to form Dwarftron:
Code: [Select]
...☺....☺/
./≡☺≡\./..
☺.≡≡≡.☺...
..|.|.....
..☺.☺.....

Left leg dwarf!
Right leg dwarf!
Left arm dwarf!
And my axe!
Right arm dwarf!
Head dwarf!
And I'll form the beard!
Logged
Reading his name would trigger it. Thinking of him would trigger it. No other circumstances would trigger it- it was strictly related to the concept of Bill Clinton entering the conscious mind.

THE xTROLL FUR SOCKx RUSE WAS A........... DISTACTION        the carp HAVE the wagon

A wizard has turned you into a wagon. This was inevitable (Y/y)?

bloop_bleep

  • Bay Watcher
    • View Profile
Re: Possibility of creating multi-tile creatures (now under development)
« Reply #11 on: March 12, 2019, 02:08:05 am »

I have a question regarding DF's unit struct. How can I cause the pathfinder to be entirely disabled for a certain unit, or at least take no effect? Specifically, I either want to stop the unit from taking jobs and trying to path somewhere, or prevent them from moving even if a job is taken.
Logged
Quote from: KittyTac
The closest thing Bay12 has to a flamewar is an argument over philosophy that slowly transitioned to an argument about quantum mechanics.
Quote from: thefriendlyhacker
The trick is to only make predictions semi-seriously.  That way, I don't have a 98% failure rate. I have a 98% sarcasm rate.

Warmist

  • Bay Watcher
  • Master of unfinished jobs
    • View Profile
Re: Possibility of creating multi-tile creatures (now under development)
« Reply #12 on: March 12, 2019, 03:25:36 am »

I have a question regarding DF's unit struct. How can I cause the pathfinder to be entirely disabled for a certain unit, or at least take no effect? Specifically, I either want to stop the unit from taking jobs and trying to path somewhere, or prevent them from moving even if a job is taken.
Afaik spam it's "thinking" (not sure about exact name) counter. This disabled all AI though.

Edit: also if you find any way to do that it would really help with multiplayer project. Maybe it's worth to just inject something in pathing logic that overwrites "this unit needs pathing recalculated" logic
« Last Edit: March 12, 2019, 03:38:38 am by Warmist »
Logged

thefriendlyhacker

  • Bay Watcher
    • View Profile
Re: Possibility of creating multi-tile creatures (now under development)
« Reply #13 on: March 12, 2019, 06:25:23 pm »

...
Afaik spam it's "thinking" (not sure about exact name) counter. This disabled all AI though.
...
I believe it is the counters.think_counter variable you are thinking of. However, while I remember units holding still in the past when firing projectiles (which uses the think counter), I am pretty sure they now respond to station orders even when the think_counter is set, so it might not be sufficient for bloop_bleep's purposes.

On a related note, there are also the issues of dodging, knockback and grappling throws. I don't know how much dragging/grappling will prevent those.
Logged
Fallout Equestria Redux - that's right, it's back

Roses

  • Bay Watcher
    • View Profile
Re: Possibility of creating multi-tile creatures (now under development)
« Reply #14 on: March 13, 2019, 10:43:36 am »

What about giving the body part creatures IMMOBILE and NOTHOUGHT?
Logged
Pages: [1] 2