1. Factorio
  2. News

Factorio News

Friday Facts #335 - Scenario changes, Damage effect filtering

Read this post on our website.

Team production changes

Improving the Team production challenge was prompted by this Reddit post. Team production was made back in 2016 to test the multiplayer networking of the 0.14 update with a larger number of players without the overhead of having a large factory. Since then it has not really had much love.

So after 4 years of accruing wisdom, I started making some general improvements.

[h3]Choose your teams[/h3]
I think this is one of the main suggestions people had for team production. The scenario just shuffled the players and assigned people randomly, and you could end up all alone playing against your two best friends.

Now I believe anybodies first choice would be to add a GUI to handle this. I will go on about GUIs later, but short story is, I didn't want to add a GUI. They add a lot of complexity, and my development mood these days is to keep things simple and small in scope.

So I added little colored launchpads!



I think it is quite intuitive, you will instantly be able to see which team has which players, you will see what map position you will be in when the round starts, etc. Another benefit is that if you want to spectate, you can simply just not walk onto a launchpad, and use the map view to see what's going on (before, there was a button you would press to join the spectators team).

The idea to use tinted concrete came from Albert, as originally it was just a tinted square rendering over the tiles (which didn't need any new prototypes defined) and it looked very janky. A consequence of this is that we now have colored concrete tiles in the game. There is no item available to place color concrete, but players will be able to access them in the editor mode.

[h3]General cleanup[/h3]
This is the not so glamorous but still important polishing we need to make. Things such as fixing GUI styles, switching the loaders to stack inserters, making sure the map sets are making sense, etc.

I also spent some time making the challenges more predictable, the logic before could give a lot of variance to the difficulty of the production objectives, and make things hard to balance. One problem I see in the future, is that the production challenges are 'hardcoded' for the base game. If I find some more time later I might work on a system to more procedurally create the objectives.

Wave defense changes

I was inspired by some comments a few weeks ago, saying that the Wave defense scenario was a bit of a pushover, especially with a couple of players working together. So I thought an easy adjustment would be to scale the 'wave power' somehow to the number of players. It was a simple change and we released it with 0.18.4 a few weeks ago. Jobs a good'un right?

Well after play-testing it more extensively over the weekend, I realised it wasn't quite so simple...

[h3]More biters; more money[/h3]
A major problem is that the players earn bounty for every biter that it killed. So if I make the waves bigger, then the players earn so much more money, and can buy so many more upgrades, that the scenario is even less challenging than before.

The solution to this is quite abrupt, I just remove the bounty from the units, and this makes the design work better in my eyes:
  • Bounty is only earned from spawners and worms.
  • You can't sit inside your walls and earn money for upgrades; You need to actively go out of your base to earn upgrades.
  • Players could set up infinite money farms by spawn camping the biters; This is no longer possible.


A consequence of this is that the upgrade prices and bounties needed to be rebalanced, which was actually a little bit easier since the number of spawners and worms is way more predictable.

[h3]Predictable attack locations[/h3]
I also noticed that biters spawning would always hit the base defences at the same places very reliably. This is great if you are the player and only want to invest 1 flamethrower turret to repel all the attacks.

https://cdn.factorio.com/assets/img/blog/fff-335-waves-before.mp4

So I added an extra command to the biters orders, that tells them to first go to a random point within the base, and from there go and attack the silo. This means that the positions where biters intersect your defences will be less predictable.

https://cdn.factorio.com/assets/img/blog/fff-335-waves-after.mp4

[h3]More wave power; same wave size[/h3]
Another observation I made is that even though I increased the 'wave power', the number of biters was still being limited by the number of nearby spawners. This was due in part to a mix of me being clever with optimization and wanting to not make the groups too big. In short the spawning would work something like this:
  • Determine the wave power, bases on factors such as wave number, player count, difficulty.
  • Determine how many spawners we spawn from, something between 4 and 15 typically.
  • For each spawner, pick a random number of biters to spawn, between 20 and 30.
  • Spawn the biters, and remove their 'cost' from the wave power. If we have no more wave power we stop.
  • Once we have gone through all spawners, we are done (even if there is a lot of wave power left).
The problem here, is that we are constrained by the spawner count and unit count. Even if wave power was 10x higher, the logic could still just decide to spawn 50 small biters from 4 bases and call it done.

Well okay I was a clever boy, and now lets remove all this complicated logic and keep it simple:
  • Determine the wave power, bases on factors such as wave number, player count, difficulty.
  • Determine how many spawners we spawn from, something between 5 and 20 typically.
  • Divide the wave power by how many spawners we have.
  • Keep spawning units at the spawners until all the wave power is used up.
This way, if we have 10x more wave power, no matter how many bases we spawn from, the wave will be 10x more powerful.

[h3]Infinite map option[/h3]
I had a few requests for this, and it wasn't so hard to add. If enabled, the Wave defense map will be infinite instead of an island, and the only way to win will be to launch a rocket.

New scenario - Rocket rush

Adding a new scenario at this point of development is a surprise to be sure, but hopefully a welcome one. The concept for this is that you are on the 'space platform', and you are preparing to land on the surface, and once on the planet you need to launch a rocket as fast as possible. You start with all technologies unlocked, and some money to buy starting equipment.



Once you and your friends are prepped, you head down to the launchpad to start.



And then that is pretty much it, you get teleported to the surface, and play the game as usual. We can afford to add this scenario because it is so small in scope and so simple, and it took less time to make this new scenario from scratch than updating what we already have. Maybe it is not the best thing since sliced bread, but I am hoping that my small investment of a few weekends will at least give some players a few more hours of enjoyment. I would be interested in adding more 'small scope simple scenarios' in the coming months, if we have enough time. If you have ideas that might fit this definition, please let me know (but no promises).

Damage effect filtering

It is the classic problem, we optimise a system so its 5x faster, and then we use it 5x more. This time it is the case of flamethrowers and particles again. With 0.18 we added the damage effects for entities, and we generally like the way it works. However when this is combined with flamethrowers, we encounter some problems.

https://cdn.factorio.com/assets/img/blog/fff-335-biter-damage.mp4

First you might say, "It doesn't make sense that a burning biter will spurt blood", and I would agree. Second you might say "That is a lot of blood", and I would agree with that too. In fact it is 1,416 damage events worth of blood particles. The way flamethrowers currently work means they do a small amount of damage very frequently, in contrast to say a grenade which does a high amount of damage in a single action. Even with all the particle optimizations, the performance would once again suffer due to the sheer quantity of particles being created.

So Rseding has gone ahead and killed 2/3 birds with 1 stone, and added damage type filtering to the entity damaged and entity died trigger effects. This means for our immediate problem of bloody burning biters, we can just filter the damage effect to not occur if the damage type is fire, which solves it perfectly. In the longer term the benefits are even greater, as we now have the capability to for instance, make custom dying effects for being run over, or damaged by laser, or dying by poison etc.

Well that solves half the problem, but still, 1,400 damage events is still going to cause problems in other cases. A big part of this comes from the 'fire sticker', which applies damage every single tick. Since it lives for 30 seconds, that is 1,800 damage events. So a nice easy change posila has done, is to add a 'damage interval' to the sticker, so that damage is only applied every n ticks. For now we have set the fire sticker to do 10x the damage, but only every 10 ticks, reducing the number of total events for the sticker from 1,800 to 180, a lot more reasonable. (Note, changing this frequency can affect the damage balancing, as the resistances system in Factorio has an absolute reduction and a percentage reduction. In our case, the entities affected by the fire sticker had no absolute fire resistance, so the result is the same.)

All the changes you see here should be released soon, we are in a rhythm now of doing 1 release every week (typically on a Tuesday), and everything you see here is pretty much done (but anything can change!).

Version 0.18.7 released

Graphics


  • New visuals for poison capsule effect.
  • New dying effect and remnants for flying robots.
Sounds


  • Entity destroyed alert - Sound softened and lowered in volume.
  • Weapon sounds (WIP) - new Pistol, Submachine gun, Gun turret, Laser turret.
  • Logistic chests open sound (WIP).
  • Poison capsule cloud (WIP).
Bugfixes


  • Fixed that reordering heat buffers during the same tick a different heat buffer was built would leave the heat buffer state corrupted. more
  • Fixed that entity sounds with probabilities would loop forever once they started playing. more
  • Fixed rocket silo tooltip did not include contents of the rocket result inventory. more
  • Fixed that styles were applied to wrong slot in a filtered train view. more
  • Fixed that server authentication would fail if both the token and username and password were provided. more
  • Fixed that changing inserter pickup/dropoff through mods didn't work correctly. more
  • Fixed that combat robots had their fire resistance overwritten. more
  • Fixed that rolling stocks were not pulled correctly when train was moving through curved rails. more
  • Fixed that LuaEntityPrototype::burner_prototype didn't work for the burner-generator entity type. more
  • Fixed janky construction robot flying animation during repair work. more
Scripting


  • Added optional LuaItemStack::build_blueprint raise_built.
  • Added LuaInventory::find_empty_stack(), count_empty_stacks(), and get_insertable_count().
  • Added LuaEntityPrototype::heat_energy_source_prototype, fluid_energy_source_prototype, and void_energy_source_prototype read.
  • Added LuaGameScript::encode_string() and decode_string().
  • Added on_player_set_quick_bar_slot.
  • Added on_pre_player_toggled_map_editor.
  • Removed LuaPlayer::name write. more
  • Removed core lualib util.encode() and util.decode().


You can get experimental releases by selecting the '0.18.x' beta branch under Factorio's properties in Steam.

Friday Facts #334 - New poison cloud animation, flying robot dying effect

Read this post on our website.

Poison cloud (Ernestas, posila)

The poison cloud animation is a placeholder spritesheet (that kovarex found somewhere on the internet), we have wanted to improve it for a long time, but since it was always such a small detail other things took priority. Well now is the time to finish everything, big and small.

https://cdn.factorio.com/assets/img/blog/fff-334-old-cloud.mp4

Some of the problems we see with the old placeholder animation:
  • The edge (where damage will apply) is not clearly defined
  • The center strongly obstructs vision underneath the animation
  • It breaks the perspective/height illusion with its very circular shape


The new animation was done quickly and without the need of any large changes to the Factorio engine. This is the mindset we are in these days, use the engine features we already have to finish things quickly and without trouble, and we try to stop ourselves going crazy with more detail.

https://cdn.factorio.com/assets/img/blog/fff-334-new-cloud.mp4

The smoke capsule itself spawns a bunch of smaller dummy entities which do the smoke drawing, while the damage is kept consistent by only using the central smoke cloud to apply damage.

Flying robot die effect (Dom, Klonan)

Unlike the poison cloud, the flying robots dying was never something that we felt strongly about changing, they just exploded and poofed out of existence. With the new particle system we had an idea of using a particle to show the robot falling to the ground. The experimentation was quick and effective, and we liked the effect. Using the 16 directions of the flying robot sprites, we can create a 16 frame animation of the robot spinning for free, which is a good trick.

https://cdn.factorio.com/assets/img/blog/fff-334-robot-dying.mp4

To complete the effect we needed to pay a bit of a price by creating some remnants on the ground. Dom didn't take long to model and render 3 remnant variations for each robot. Even if you don't see the robots falling and dying actively, the corpses on the ground can really add to the battlefield.



These new effects have been merged in our master branch now, so you can expect to play with them with the next 0.18 experimental release, likely early next week.

Version 0.18.6 released

Bugfixes


  • Fixed a crash related to multiple blocks reserved for different trains but later merged by placing a rail. more
  • Fixed that construction robots were missing their working animation. more
  • Fixed circuit network debug visualization text overlap. more
  • Fixed the circuit network tooltip backgrounds didn't highlight correctly. more
  • Fixed that script.active_mods wouldn't be accurate when loading save files in some cases. more
  • Fixed that the sync-mods-with-save feature would try to download mods it didn't need to in some cases. more
  • Fixed that trains pathfinder could create non contiguous path in case of single segment cycle with a junction. more
  • Fixed possible crash when units were attacking rails with train on them. more
  • Fixed pump would consume energy and play animation when it tried to transfer very small amount of fluid but failed to do so. more
  • Fixed creating fire entity by trigger effect invoked by a particle would crash the game.
  • Fixed overriding LuaSurface::brightness_visual_weight would cause light map to appear in map view. more
Scripting


  • Building entities with from items with 0 health will set the entity to 1 health instead of 0. more
  • Added LuaGameScript::reset_time_played() which will reset the 'Time played' to 0.


You can get experimental releases by selecting the '0.18.x' beta branch under Factorio's properties in Steam.

Friday Facts #333 - Terrain scrolling

Read this post on our website.

Hello,
We released 0.18.4 this week, same old same old, more bugfixes, more bugs, more changes. At this stage of development, not many interesting things are happening, we are just polishing what we have.

Minor terrain render optimization (posila)

Just a couple days before the release of 0.18.0 I had an epiphany about a terrain rendering problem that was bugging me for a really long time. When rendering terrain, we reuse the texture from the previous frame. How this was always done, is that we would render the texture shifted to the new position, fill up the gap, and then copy the final result back into the texture for reuse in next frame. So what was bugging me about this? This simple operation would result in rasterizing 2 screens worth of pixels. While that is not a problem for at least half decent GPUs from the past decade, it's a significant work load for integrated GPUs, which in general have an order of magnitude lower memory bandwidth than dedicated GPUs. It could also be equally bad for old low-end dedicated GPUs.

One of the extreme examples is the Intel HD Graphics 3000 - an integrated GPU on the Sandy Bridge CPU architecture. When you sit still and the terrain can be reused without shifting, it would take 'just' 2 milliseconds to copy it to the game view. But when you started to move, the GPU time to render the terrain could go up to 5 milliseconds. And that is only at 1600x900 resolution. Not even 1080p. So, it was bothering me we were spending nearly 1/3rd of a frame time (16.66 ms) to render the terrain, when the engine has much more work to do to render the rest of the game (for comparison GeForce GTX 750Ti or Radeon R7 360 would do the same under 0.5 ms at 1080p).

The realization I had, was that I can 'scroll' the buffer texture. If I remember the offset of the top left corner, I can un-scroll it to the game view, and then instead of copying all the terrain back to the buffer, we can just adjust the offset and update the parts that changed. So, the number of pixels copied is proportional to how much the terrain scrolled. It is so simple I am embarrassed not to have figured this out years ago.

https://cdn.factorio.com/assets/img/blog/fff-333-tile-buffer.mp4

Most people could not have noticed this optimization, as most GPUs people have nowadays did the un-optimal thing in a fraction of a millisecond already. But it still made me very happy to be finally able to remove this inefficiency. Contemporary integrated GPUs are also significantly faster, and while it might not be as much of a challenge to render the game for them, they do share some resources with the CPU - be it the last level of cache, or CPU cooler, so the integrated GPU working hard may cause the CPU to slow down.

However, the point I wanted to illustrate by this post is how broad a range of GPUs there is. People see a 2D game and expect to be able to play it on essentially anything. If we want to live up to that expectations, we have to impose a lot of limitations on ourselves, because 'anything' also includes a couple orders of magnitude slower GPU than is found in an average gaming computer of today. CPUs got a lot faster in the last decade too, but mostly due to increasing the number of cores and adding wider vector computation units. They didn't get that much faster when executing serial code, which is unfortunately most of Factorio's game code. So if you play the game on a laptop with a Core 2 Duo and GeForce 320M, you'll run into framerate issues due to the weak GPU much sooner than a UPS slowdown due to the old CPU.

Side note: You might ask, why do we bother with caching the terrain in the first place and not just re-render it from scratch every frame. Short answer is - because Factorio's terrain rendering is insane due to its complicated tile transition rules, and re-rendering it every frame is just not fast enough.