Atrik Posted October 10 Report Share Posted October 10 (edited) This mod allow snapping walls to any buildings (or entities like mineral deposits), increasing drastically their potential utility by making sure to leave no gaps, and/or speed at which you can place them. Walls.. That snaps... I did my best for the behavior to be simple and intuitive, but there are still a couple compromises that were done. Also there are vanilla flaws with wall placements that I couldn't address. Mod compatibility: Compatible mod (can be enabled in MP) Works with other mods I tested that modify inputs (autociv, customtrainer, moderngui) Features : Starting wall tower can be snapped to any edge just like regular building End wall tower can be snapped to any edge but might only really works on building corners Towers can be used as start or end point for wall segments Can continue wall building even in fog of war Can restore wall segment and continue building from captured foreign civilization Can continue palisade from stone wall tower Performance improvements for most situations* when placing walls *Known exception : after placing a wall tower snapped to a building edge, performance is actually worse for a couple frames. SnappingWalls.zip Edited 4 hours ago by Atrik 7 1 1 Quote Link to comment Share on other sites More sharing options...
Player of 0AD Posted October 10 Report Share Posted October 10 Snapping walls are nothing new. These things are called gates. 3 Quote Link to comment Share on other sites More sharing options...
AlexHerbert Posted October 10 Report Share Posted October 10 (edited) I have installed to try. Edited October 11 by AlexHerbert Quote Link to comment Share on other sites More sharing options...
Atrik Posted October 16 Author Report Share Posted October 16 Updated : Significant performance improvement (First version was bad, this one fix it but also improve wall placement performance impacts in general) Now other towers can be used as a starting or end point for wall placement instead of wall towers. This doesn't prevent you from walling easily around them : you can also snap walls and palisades to their edges! (The threshold distance makes it so easy to choose between the two you won't even be bothered). 2 Quote Link to comment Share on other sites More sharing options...
Perzival12 Posted October 16 Report Share Posted October 16 What if you add the ability to snap walls to a fortress' towers? Then fortresses would be more realistic, more useful to build, and take up less space. 3 Quote Link to comment Share on other sites More sharing options...
Atrik Posted October 16 Author Report Share Posted October 16 4 minutes ago, Perzival12 said: What if you add the ability to snap walls to a fortress' towers? Then fortresses would be more realistic, more useful to build, and take up less space. Wish I could, however this would either be very complicated, or needs to be as a incompatible mod setting some references point in fort templates or something. I wanted this mod to be compatible. Quote Link to comment Share on other sites More sharing options...
Perzival12 Posted October 16 Report Share Posted October 16 Kay, just a thought. 1 Quote Link to comment Share on other sites More sharing options...
Perzival12 Posted October 16 Report Share Posted October 16 By the way, your download isn't recording how many people have downloaded it. Quote Link to comment Share on other sites More sharing options...
Grautvornix Posted October 16 Report Share Posted October 16 It must be hundreds if not thousands! This feature is definitely long awaited! 1 Quote Link to comment Share on other sites More sharing options...
wowgetoffyourcellphone Posted Saturday at 21:15 Report Share Posted Saturday at 21:15 On 16/10/2025 at 6:52 AM, Atrik said: Updated : Significant performance improvement (First version was bad, this one fix it but also improve wall placement performance impacts in general) Now other towers can be used as a starting or end point for wall placement instead of wall towers. This doesn't prevent you from walling easily around them : you can also snap walls and palisades to their edges! (The threshold distance makes it so easy to choose between the two you won't even be bothered). Why aren't you making this a pull request? 3 Quote Link to comment Share on other sites More sharing options...
Atrik Posted Saturday at 22:28 Author Report Share Posted Saturday at 22:28 1 hour ago, wowgetoffyourcellphone said: Why aren't you making this a pull request? Unlikely to be accepted as a PR. It lengthen the code by a bit; and is probably not how one would go about to implement all of the different features I've added, without the constraint of trying to make it into a compatible mod.. Quote Link to comment Share on other sites More sharing options...
Vantha Posted Sunday at 18:04 Report Share Posted Sunday at 18:04 19 hours ago, Atrik said: Unlikely to be accepted as a PR. It lengthen the code by a bit; and is probably not how one would go about to implement all of the different features I've added, without the constraint of trying to make it into a compatible mod.. I took a quick look at the code, correct me if I'm wrong, but for a PR it looks like you could directly move most of the logic to the GuiInterface.prototype.SetWallPlacementPreview method. I don't think length would be an issue since you largely rewrote the logic of that method anyway, which is itself already quite long. And I don't think anyone would mind having a bit more code for more desired behaviour. Also, that would make it even more performant because you wouldn't have to compute the entire entity state for each snap candidate and could pull values like the position from the simulation directly, which is a lot quicker. What do you think? I believe a lot of people (including me) would love to see this added to the main game. 5 Quote Link to comment Share on other sites More sharing options...
Atrik Posted Sunday at 21:36 Author Report Share Posted Sunday at 21:36 3 hours ago, Vantha said: I took a quick look at the code, correct me if I'm wrong, but for a PR it looks like you could directly move most of the logic to the GuiInterface.prototype.SetWallPlacementPreview method. I don't think length would be an issue since you largely rewrote the logic of that method anyway, which is itself already quite long. And I don't think anyone would mind having a bit more code for more desired behaviour. Also, that would make it even more performant because you wouldn't have to compute the entire entity state for each snap candidate and could pull values like the position from the simulation directly, which is a lot quicker. What do you think? I believe a lot of people (including me) would love to see this added to the main game. Thanks, I've just realized I've slept an stupid, potentially error-generating mistake so I've just re-uploaded again with tiny fix... There are also small compromises I made as said in the opening comment... And the buildings templates that can be used as end wall sections (towers) are defined arbitrarily in a constant etc... So there are a few things that needs extra work. 2 1 Quote Link to comment Share on other sites More sharing options...
Perzival12 Posted Monday at 17:08 Report Share Posted Monday at 17:08 On 16/10/2025 at 10:00 AM, Perzival12 said: By the way, your download isn't recording how many people have downloaded it. It seems to have been fixed, the newest upload says 5 downloads. Wonder what the bug was. Quote Link to comment Share on other sites More sharing options...
Atrik Posted Monday at 19:24 Author Report Share Posted Monday at 19:24 1 hour ago, Perzival12 said: On 16/10/2025 at 7:00 PM, Perzival12 said: By the way, your download isn't recording how many people have downloaded it. It seems to have been fixed, the newest upload says 5 downloads. Wonder what the bug was. You probably got confused by the counter resetting because I'm reuploading shamefully the mod every time I find some bugs coming from the mod.. 4rd reupload due to poorly handled exceptions ... Also on @Vantha's tip I've tried to see if I could get some of the logic in guiinterface. I couldn't import much logic there but in SetWallPlacementPreview we could control additional visual effects of the previews. I also rewrote some of it to be able to reason from it... Anyways... If the mod/code is working as I think it is now (finely), my guess is that it is still not possible to PR it as long as it is a constant storing tower-like structures, usable as start/end points for wall segments. Quote Link to comment Share on other sites More sharing options...
Vantha Posted 23 hours ago Report Share Posted 23 hours ago 23 hours ago, Atrik said: Anyways... If the mod/code is working as I think it is now (finely), my guess is that it is still not possible to PR it as long as it is a constant storing tower-like structures, usable as start/end points for wall segments. You could either define it in the GUI globally somewhere and then pass it to every GuiInterface call, or just make it a member of the GuiInterface directly. The Engine.PickSimilarPlayerEntities method does not exist in the simulation scripting context, but the same thing can be achieved through the GetEntitiesByPlayer method combined some additional manual checks. That would also allow filtering entities by the "Tower" class instead of their template names (as you mentioned in the comment), if wanted. By the way, the GUI already caches entity states (in g_EntityStates). 1 Quote Link to comment Share on other sites More sharing options...
Atrik Posted 4 hours ago Author Report Share Posted 4 hours ago 19 hours ago, Vantha said: You could either define it in the GUI globally somewhere and then pass it to every GuiInterface call, or just make it a member of the GuiInterface directly. The Engine.PickSimilarPlayerEntities method does not exist in the simulation scripting context, but the same thing can be achieved through the GetEntitiesByPlayer method combined some additional manual checks. That would also allow filtering entities by the "Tower" class instead of their template names (as you mentioned in the comment), if wanted. By the way, the GUI already caches entity states (in g_EntityStates). Good catch for the cached entities. Alright I think I've finished this up so we might have it now. Cool enough by replacing the method to retrieve snappable entites, a couple vanilla bugs for fixed just like that; notably the inability to continue wall placement in fog of war, but also inability to build from captured walls. I've listed all features achieved in opening comment. I've tested everything I could thing of to see if any exceptions are left unhandled but I think everything seems so much better now then it ever was. Quote Link to comment Share on other sites More sharing options...
Vantha Posted 3 hours ago Report Share Posted 3 hours ago 45 minutes ago, Atrik said: Alright I think I've finished this up so we might have it now. Cool enough by replacing the method to retrieve snappable entites, a couple vanilla bugs for fixed just like that; notably the inability to continue wall placement in fog of war, but also inability to build from captured walls. I've listed all features achieved in opening comment. I've tested everything I could thing of to see if any exceptions are left unhandled but I think everything seems so much better now then it ever was. Very nice. It also adds the missing tooltip when the starting turret can't be placed. Do you want to open a PR? I can help with testing and reviewing. 1 Quote Link to comment Share on other sites More sharing options...
Atrik Posted 1 hour ago Author Report Share Posted 1 hour ago I've tested all cases I could think of but we can always give it a couple days to see if something broken is discovered. If not, I don't have a gitea account or repo set up, and I might be lazy to set one up (a bit of other reasons too that makes me not want to do it maybe...). I've made a version SnappingWalls.zip of the code that use function overwrites and comments cleanup to make it easier if someone want create a PR for main game. Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.