Bay 12 Games Forum

Please login or register.

Login with username, password and session length
Advanced search  

Author Topic: Lightning Regional Interaction / Weather  (Read 722 times)

dikbutdagrate

  • Bay Watcher
    • View Profile
Lightning Regional Interaction / Weather
« on: June 08, 2023, 04:06:33 pm »

I was interested in modding in lightning strikes into the game.  Does anyone know of any good preexisting mods which implement this?

I've seen mods from earlier editions of DF that use custom tile sets, and do some crazy animation stuff, like with lightning guns. But I'm not sure how viable those sorts of approaches are now.

They should also probably occur only during storms, or while it's raining.

Is there anyway of getting a "lightning", whatever that ends up being, to spawn on a random above ground tile, and then create a vertical trail up to the highest z level and back?  Alternatively, maybe a stone could spawn somewhere in a loaded area's max z-height, and then plummet to the ground, all while producing "clouds of boiling lightning"?

Thoughts, idea, suggestions, etc?
Logged

Ulfarr

  • Bay Watcher
  • Going on a pilgrimage to Mars
    • View Profile
Re: Lightning Regional Interaction / Weather
« Reply #1 on: June 09, 2023, 05:02:43 am »

Since no one answered, I'll make a suggestion but I don't know if it will work.

According to the wiki, v 0.47.01 added some new functionalities to custom interactions.

1) [I_TARGET:A:LOCATION], [IT_LOCATION:RANDOM_NEARBY_LOCATION:A:X]

These tokens can be used to specify a location (A) in the local map and then force an interaction to target a random tile within a given radius (X) from the specified location (A). That could be used to emulate random lighting strikes in the map, but I don't think it can be used to find the hightest point/"shortest path" for the electric discharge.

2) [I_EFFECT:SUMMON_UNIT], [CREATURE:<creature token>:<caste token>] 

These can be used to summon a custom "lighting" creature at the targeted location. I don't now how one would emulate the effect of electricity passing through any creature/tree/whatever might be in that location. It might be possible to make the "lighting" creature use a custom interaction/syndrome attack to paralyze/burn/cause nerve damage at whatever else is there but it might be too complicated. A far more simplistic (and non realistic) approach would be to make the "lighting" creature's temperature high enough to ignite anything around it.

3) [IE_TIME_RANGE:<minimum ticks>:<maximum ticks>]

This can be used to unsummon the "lightning" creature so there aren't any remains for your dwarves to gather/stockpile.

Logged
Bring Kobold Kamp to LNP! graphics compatibility fix.

So the conclusion I'm getting here is that we use QSPs because dwarves can't pilot submarines.

dikbutdagrate

  • Bay Watcher
    • View Profile
Re: Lightning Regional Interaction / Weather
« Reply #2 on: June 09, 2023, 06:19:04 pm »

Since no one answered, I'll make a suggestion but I don't know if it will work.

According to the wiki, v 0.47.01 added some new functionalities to custom interactions.

1) [I_TARGET:A:LOCATION], [IT_LOCATION:RANDOM_NEARBY_LOCATION:A:X]

These tokens can be used to specify a location (A) in the local map and then force an interaction to target a random tile within a given radius (X) from the specified location (A). That could be used to emulate random lighting strikes in the map, but I don't think it can be used to find the hightest point/"shortest path" for the electric discharge.

2) [I_EFFECT:SUMMON_UNIT], [CREATURE:<creature token>:<caste token>]

Right, so this is where DFhack I guess has to come in. When the interaction happens, it triggers an automated lua script, which picks a random above ground tile on the surface, and then calculates the highest targetable z point above that area, and then changes to the target's z coordinate to that spot.

It's interesting that you suggested a creature, because if we use a short lived one, one that lives for 4 ticks, it could use an interaction and vanish. This would allow us to get away with some stuff that we might not otherwise be able to get away with in vanilla. However, if we're already involving DFhack to target tiles on the z axis, then this doesn't seem particularly necessary.

Alright, so let's say we have managed to randomly target a tile on the map, and then raised that target to the highest possible z elevation above it through an automated script, and further, we now have access to lua for whatever comes next.

My idea, is for the lighting to Etch-a-Sketch its way down to the surface by shifting 1x and/or 1y coordinate during each z-level transition, and producing an instantly evaporating boulder of flashing "lightning" for each z level, (because thats the best I got), which has a fixed temp of 5x magma. Every z level transition, the script checks for whether its targeting a ground tile, if it is, it creates a cave in explosion of lightning dust, and then terminates. (It could also play a sound effect?)

I'm not sure if the lightning's path should be purely cosmetic, or if it should attempt to model natural lightning in some manner. Like, have it determine if moving over x number of spaces as it climbs down, will allow it to travel faster through a tree within range that it can strike, rather than continuing to travel through air.
Logged

Ulfarr

  • Bay Watcher
  • Going on a pilgrimage to Mars
    • View Profile
Re: Lightning Regional Interaction / Weather
« Reply #3 on: June 10, 2023, 07:05:38 am »

I'm not well versed in lua (or programmig in general) but if you are going to use DFHAck what's the point of trying to use regional interactions, wouldn't be easier to just write a script that

1) Finds a random point in the map (on the highest z-level/sky) and defines it as the lighting source
2) Determines the end point (highest ground z level/highest tree/highest constructed wall)
3) Generate a path between the source and the end tiles either directly or randomly ( say the next tile in the path is chosen randomly from among a 3x3 box below the previous tile)
4) In the first tick create a lighting (creature/material) in the source tile and in each tick after that, remove the lighting form the previous tile and create a new one in the next one.

To be honest though and in the spirit of brainstorming, I don't see the point of simulating the lighting bolt's path. Since it's a mostly vertical path through the highest of z levels, most players aren't going to see it unless they just happen to view the exact z level in the bolt's path. As far as game mechanics are concerned the only relevant things are to define the end tile and to make something happen to whatever exists in that tile.

I don't want to dissuade you though, I do think "rule of cool" and "because I can" are good enough as justifications for a mod's existance.
Logged
Bring Kobold Kamp to LNP! graphics compatibility fix.

So the conclusion I'm getting here is that we use QSPs because dwarves can't pilot submarines.

dikbutdagrate

  • Bay Watcher
    • View Profile
Re: Lightning Regional Interaction / Weather
« Reply #4 on: June 10, 2023, 03:48:26 pm »

Mostly, I just wanted to model lightning, to see how far the rabbit hole could go.  And but also, to allow for HFS inorganic creatures to show up that are made out of the substance, which could be butchered, in order to produce items made out of an 'X' creature's lightning, which could be really fun, because the script could trigger the lightning bolt script, whenever those particular items happen to be thrown or launched into the air.

But yeah, ultimately, the simplest solution is to actually just spawn a tree mid air, just off the ground or whatever. It'll collapse into a multi z tile cave in dust explosion. And if the tree's material is set to be made of 'lightning'.  Then well... that happens!

In arena mode theres a function to actually spawn trees, however, this feature isn't accessible via the raw interaction tokens. Interesting to note though, the create-tree.lua script available in DFhack actually borrows the arena mode function, in order to spawn in trees. Which makes a lot of sense.
Logged

Timeless Bob

  • Bay Watcher
    • View Profile
Re: Lightning Regional Interaction / Weather
« Reply #5 on: June 30, 2023, 09:52:43 pm »

Lightning could be a single tree that grows insanely quickly before exploding into magma-hot cave-in dust. This has the option of causing the first layer to develop "lightning strike" holes too.

oops.  ninja'd
Logged
L33tsp34k does to English what Picasso did to faces.

Dwarfopoly
The Luckiest Tourist EVER
Bloodlines of the Forii

dikbutdagrate

  • Bay Watcher
    • View Profile
Re: Lightning Regional Interaction / Weather
« Reply #6 on: July 25, 2023, 01:54:38 am »

Lightning could be a single tree that grows insanely quickly before exploding into magma-hot cave-in dust. This has the option of causing the first layer to develop "lightning strike" holes too.

oops.  ninja'd

As much as I already enjoy the timeless classic parable of "Johnny LIGHTNINGSEED", who, innuendos aside, strolls across the world, planting his seeds, which invariably blow all things surrounding them the kingdom fuck, I'm not entirely sure that trees can grow that quickly.

Wait, actually, yes they can. And I know this! From personal experience no less. I had a tree keep spawning in this shallow public pool I made for the dwarves, which resulted in these yearly fatalities, as it would explode the pool's floor tiles, which was a cave in effect. When trees burn down, it's the same deal, cave in dust. So, we have a tree that boils as like sub-zero temperatures, and goes boom.

Not really simulating lightning physics though, but the ideas cool.
Logged