Refactorio / RedMew

The RedMew scenario code for Factorio.
https://redmew.com
GNU General Public License v3.0
177 stars 80 forks source link

Diggy : Compatibility with Klonan's mining drones #1036

Open anisghaoui opened 4 years ago

anisghaoui commented 4 years ago

Hello, Klonan has this fantastic mod that makes the map exceptionally fun ! 2 problems : 1st : the drones destroy the rocks and don't generate the new terrain. I asked him and he kindly implemented a config to ignore the big rocks.

2nd : he suggested that you would make the rocks destroyable by the drones. I don't really understand his point tbh. Here is a link for it :

https://mods.factorio.com/mod/Mining_Drones/discussion/5e2d8b7c0cf772000bfba8f2

Is there any way to have compatibility between your scenarios and the mod ?

BlueRock2 commented 4 years ago

Try re-downloading the RedMew scenario as there was a 0.18 diggy patch for it today. I tried the newest version of Diggy and the Mining drones seemed to work. But I didn't test it a long time. With the option selected to not destroy rocks, they only seemed to destroy rocks if they were in their way (like in a congested pathway if other drones and rocks were nearby). In the places rocks did get destroyed I verified new terrain was generated. I witnessed one of them cause a cave collapse and get killed which was a bit humorous.

anisghaoui commented 4 years ago

They indeed will destroy rocks blocking their paths and rocks that have resources beneath them. I will give you a feedback later today. Thank you.

anisghaoui commented 4 years ago

I have cloned the most up-to-date git repo. I tested with Klonan's mining drones and having them mining rocks (without ignore them) will not propagate the normal Diggy cave's behaviour.

Robots and explosions on the other hands do work correctly.

BlueRock2 commented 4 years ago

When you say

"will not propagate the normal Diggy cave's behaviour",

can you be a little more specific? Are you seeing the drones not fully destroy rocks? If they do fully destroy a rock, do you see new tiles get placed with additional rocks put on them? Or do you end up with a gap in the rocks where the tiles meet up directly against the void with no new tiles/rocks placed?

anisghaoui commented 4 years ago

I made this for Klonan : https://imgur.com/CX11sPF

he fixed his mod now to ignore rocks correctly ( I am against his drones destroying the rocks in diggy because it is too dangerous x) ). The behaviour is still incorrect in my opinion. It might not be even necessary to solve it.

linaori commented 4 years ago

The cave opening event doesn't get triggered when an object is destroyed (entity.destroy()), that's usually what's being called in mods to remove a rock after "mining" it. Unless we can start listening to a pre-destroy hook, I don't know how to properly deal with this.

Maybe mods should start triggering a mined or death event of sorts?

anisghaoui commented 4 years ago

Wait, this is (maybe?) incoherent. If I used grenades, atomic bombs or even my gun to destroy rocks the cave expends. if it is the same event that you subscribed to then it should be the same behaviour.

I agree the solution will not be trivial. I also doubt that the mod has to add anything new.

BlueRock2 commented 4 years ago

Hello Linaori! Haven't seen you active for a while. I just wanted to add an observation that in the video above I didn't see any stone particles being generated during stone damage or destruction either by the drones OR player at the end, so I am doubtful the 0.18 particle fixes were applied when you recorded that.

linaori commented 4 years ago

Wait, this is (maybe?) incoherent. If I used a grenades, atomic bombs or even my gun to destroy rocks the cave expends. if it is the same event that you subscribed to then it should be the same behaviour.

The destroy() function on an entity just removes it. grenades and atomic bombs trigger the on_entity_died event. The destroy was not something we could use in 0.16, which was the last time I did anything with the lua api in factorio.

I agree the solution will not be trivial. I also doubt that the mod has to add anything new.

If a mod does not provide a hook we can listen to, there's no way of knowing that something happened to that rock.

Hello Linaori! Haven't seen you active for a while

Just stalking around, haven't touched factorio in a while.

BlueRock2 commented 4 years ago

Interesting observation # 2: I did the same test as in the video. If I tell them to mine for stone they just destroy the rock and there is no replacement stone placed. If I expose some iron ore and the iron ore is under the rock or the rock is in their way, and they do actual damage to the rock everything works properly.

BlueRock2 commented 4 years ago

Ok, so I did one last(I think) test with the mod option to ignore rocks. In this mode, if you choose to mine stone, they will only mine stone off the ground not the large rocks. They could still damage rocks that are in their way or covering stone on the ground, but the damage they do in this mode when they kill a rock works properly in Diggy. If you want to further expand the mine, can still use the construction bots which is probably best anyway because if the drones were to dig too much rock unsupervised they would cause collapses and die. So would this address any remaining concerns you have? The only other issue I found, which would need to be addressed by the mod author is if you wanted the drones to re-scan for new ore every now and then. Currently, once they start mining, they don't appear to be aware of any new ore that might later get uncovered.

anisghaoui commented 4 years ago

Some explanations :

SimonFlapse commented 4 years ago

It'd say that the LuaEntity.destroy method is an artificial way of removing an entity from the game. Thus it is not really something that occurs naturally in the game. Using it has its advantages, because it prevents spilling of items like stone, coal and wood.

However it can be seen as a godlike way of manipulating the game environment in the sense that it can overwrite almost all logic, and simply just remove the entity and any traces of existence.

What mod creators who uses LuaEntity.destroy IMHO should do is to set the raise_destroy parameter to true, so that the mod tries to act compatible with any other unknown third part modification. Maybe, and just maybe, this would allow us to make changes to accommodate mods.