The International Simutrans Forum

 

Author Topic: Changes to the smoke-parameter for buildings (and ideas around that)  (Read 678 times)

0 Members and 1 Guest are viewing this topic.

Offline Vladki

  • Devotee
  • *
  • Posts: 3241
    • My addons, mostly roadsigns, pak128.cs
  • Languages: EN, CS
Uff, it seems that forum has lost some messages from yesterday. So first, attached a patch for pak128.CS which can be applied to pak128 as well.

Parameters:
Smoke=smoke_name - stays as it was
SmokeUplift=x - default is 16 - and that is the speed was used before, and shown in the video above. Special value is 0, which makes the smoke stay in place, and can be used if you want precise control of the animation. Also good for development to see if the tile/offsets are right. Planned use case is flames on oil rig (pak128.britain-ex). Higher values makes the smoke rise up faster.
SmokeLifetime=x - default is 2499 - that is the old default, again used in the video, it is approximately in miliseconds. If the factory makes any noises, it feels good to make the smokelife equal to the noise duration. Special value is 2497, which is used for vehicles. Smokes with lifetime=2497 are properly rotated, while others are just discarded upon rotation.
SmokeTile[0-3]=x,y - the tiles at which the smoke originates. Index is rotation. (0,0) is top (NW) corner, (0,y) is on western side, (x,0) on northern side, no defaults.
SmokeOffset[0-3]=x,y - the offset within the tile (top of chimney). X offset is measured from the center of tile, tile borders are +/- 32. Y offset is measured from the bottom of tile (SE corner), and is always negative. For pak64 the offset is in pixels, for other paksets it has to be divided or multiplied accordingly (pak128 divide by 2, pak192 divide by 3, pak32 multiply by 2, ...); if smoketile[n] is specified smokeoffset[n] must be specified too. No defaults.
Sensible is to specify rotations (0), (0,1), or (0,1,2,3). I have not tried what happens if 3 rotations are specified. Also there is no check if the number of smoke rotation matches the number of factory rotations.

Legacy:
SmokeSpeed is (and was) ignored
SmokeTile=x,y (without index), or if unspecified defaults to (0,0) - tile specified as above, but automatically rotated according to factory rotations. (code unchanged)
SmokeOffset=x,y (without index), default (0,0) - smoke offset as above, but y-offset is internally increased by -8 (i.e. old yoffset -10 has same effect as new offset -18). This -8 was hardcoded and is still used for vehicles. For factories with multiple rotations, the offsets are somewhat rotated, code unmodified. (But the offset rotation algorithm is just weird, and was the primary cause why I started this patch).
Smokelifetime and smokeuplift is ignored if legacy non-indexed smoketile/smokeoffset is used.

So, for factories with one rotation, it is safe to use the legacy specs, just keep in mind the -8 special offset. Otherwise I recommend using the new syntax.

« Last Edit: March 31, 2020, 06:26:57 PM by Vladki »

Offline Leartin

  • Devotee
  • *
  • Posts: 1403
  • PAK-DEV P192C
  • Languages: DE, EN
Re: Changes to the smoke-parameter for buildings (and ideas around that)
« Reply #1 on: March 31, 2020, 06:48:58 PM »
so just to be sure:

- the random offset for each puff is still in place and cannot be removed nor increased?
- using SmokeLifetime, can you make it that each smoke puff lasts exactly until the next spawns, or is that impossible due to dynamic spawn speed?
- in pak192comic, smoke can't be positioned pixel perfect, since each offset-increase moves it by 3 pixels?
- Is there a hard limit to the offset? That is, could it happen that a chimney is so high, you can't reach it with offset?

- If I have a factory without rotations but four chimneys, I now can define four rotations for that factory with identical graphics and can then set the smoke on a different chimney for each rotation - which would result in the factory spawning in with a "random" rotation, therefore "random" active chimney?

Offline Vladki

  • Devotee
  • *
  • Posts: 3241
    • My addons, mostly roadsigns, pak128.cs
  • Languages: EN, CS
Re: Changes to the smoke-parameter for buildings (and ideas around that)
« Reply #2 on: March 31, 2020, 08:18:04 PM »
- the random offset for each puff is still in place and cannot be removed nor increased?
no, that randomization is removed. Every puff starts at exactly the same spot. Randomized is the wind effect instead.

Quote
- using SmokeLifetime, can you make it that each smoke puff lasts exactly until the next spawns, or is that impossible due to dynamic spawn speed?
No, you cannot be sure when the next puff is generated, due to pax/mail/electric boost, supply shortages. Even during my testing with power plant (and no pax) I have seen different puff rates just by different rate of supplies for the powerplant. (played with JIT=2)

Quote
- in pak192comic, smoke can't be positioned pixel perfect, since each offset-increase moves it by 3 pixels?
Unfortunately yes.

Quote
- Is there a hard limit to the offset? That is, could it happen that a chimney is so high, you can't reach it with offset?
xoffset is sitn8, i.e. +/-127 , yoffset is sint16, i.e. +/- 32767. So I hope this is enough for all factories except space elevators. :-)

Quote
- If I have a factory without rotations but four chimneys, I now can define four rotations for that factory with identical graphics and can then set the smoke on a different chimney for each rotation - which would result in the factory spawning in with a "random" rotation, therefore "random" active chimney?
Yes.

I have had a look at the code, if you define more "smoke rotations" than "image rotations" the extra smoke rotations would be ignored. So for the above trick you have to define four rotations with the same images.

Offline Dwachs

  • DevTeam, Coder/patcher
  • Administrator
  • *
  • Posts: 4665
  • Languages: EN, DE, AT
Re: Changes to the smoke-parameter for buildings (and ideas around that)
« Reply #3 on: April 03, 2020, 02:37:38 PM »
There was a bug in the factory-writer code. Please recompile makeobj with r9014 and then recreate all the factory pak files

Offline Vladki

  • Devotee
  • *
  • Posts: 3241
    • My addons, mostly roadsigns, pak128.cs
  • Languages: EN, CS
Re: Changes to the smoke-parameter for buildings (and ideas around that)
« Reply #4 on: April 03, 2020, 06:21:01 PM »
thanks Dwachs.   I'd like to post to the original thread. It seems that the "make_dirty" part of code is still not perfect. When the game is zoomed in or out it happens that the smoke often remains in the last position for quite some time. But not always. So far it did not happen in default zoom...