Codesmith512 Posted December 3, 2016 Share Posted December 3, 2016 Earlier this week I posted a question regarding pathfinding so I could implement the ability to right-click on the map screen to initiate travel, making cartography and long distance travel much less tedious. I'm pleased to announce the beta release of this mod! Please note that this mod requires my pathfinding mod, Trailblazer. So please, tell me what I did right, wrong, or otherwise! Oh and right now I just shamelessly stole the flag icon, because I didn't see the "visual art" stat when I was placing my stat points at the pre-birth initial level screen. So if you've actually got a few points there, feel free to make me a quick icon (doesn't have to be anything fancy), and I'll be happy to give you credit in the description. Link to comment Share on other sites More sharing options...
Serpens Posted December 3, 2016 Share Posted December 3, 2016 (edited) instead of replacing the original mapscreen file, put this into your modmain: Spoiler AddClassPostConstruct("screens/mapscreen", function(self) local _OnControl = self.OnControl self.OnControl = function(self, control, down) if control == GLOBAL.CONTROL_SECONDARY then if self._base.OnControl(self, control, down) then return true end if not down and (control == GLOBAL.CONTROL_MAP or control == GLOBAL.CONTROL_CANCEL) then GLOBAL.TheFrontEnd:PopScreen() return true end if not (down and self.shown) then return false end local destinationMapPos = self:WidgetPosToMapPos(self:ScreenPosToWidgetPos(GLOBAL.TheInput:GetScreenPosition())) local worldX, worldY, worldZ = self.minimap:MapPosToWorldPos(destinationMapPos.x, destinationMapPos.y, destinationMapPos.z) local action = GLOBAL.BufferedAction(GLOBAL.ThePlayer.components.playercontroller.inst, nil, GLOBAL.ACTIONS.TRAILBLAZE, nil, GLOBAL.Vector3(worldX, 0, worldY)) GLOBAL.ThePlayer.components.playercontroller:DoAction(action) return true else return _OnControl(self, control, down) end end end) I already tested it and it seems to work without problems (this also fixed the incompatibility with "auto-actions" mod ! ) Edited December 3, 2016 by Serpens Link to comment Share on other sites More sharing options...
Serpens Posted December 3, 2016 Share Posted December 3, 2016 (edited) You could/should also add a check, if the position is reachable or not. If the position is unreachable or water, then the character should not move. TheWorld.Map:IsAboveGroundAtPoint(tp_pos:Get()) And if you are expert: Also use wormholes to reach position edit: The pathfinding is not perfect yet I think, see the screenshot (the goal was left from the starting point): Spoiler And with higher speed, I tested it with c_speedmult(2), it can happen that he tries to reach one specific point, but because he is too fast, he will never be able to reach that point and instead he is raipdly going back and for (happens when making curve). This happens really often with higher speed than 2, but also sometimes with 2, which is not that unlikely to achieve in normal gameplay. Can you improve that? Edited December 3, 2016 by Serpens Link to comment Share on other sites More sharing options...
Codesmith512 Posted December 3, 2016 Author Share Posted December 3, 2016 I can definitely return no path if the position is unreachable, but isn't the whole map designed to be traversible? I'll also try to duplicate the testcase, if so I should definitely be able to fix it Link to comment Share on other sites More sharing options...
Codesmith512 Posted December 3, 2016 Author Share Posted December 3, 2016 The more I think about the wormhole idea, the more I like it. I'd imagine I could use the 'FindClosestEntityWithTag' (or whatever that function is called), but does the client know where they are? Link to comment Share on other sites More sharing options...
Serpens Posted December 3, 2016 Share Posted December 3, 2016 (edited) Since island generation is broken in DST, an unreachable position should not be possible, without additional mods. But there are mods like "private island" or simular, which creates an island. Or a Shipwrecked mod is planned, where islands also will exist. So it is better to check this case, if possible. Glad you like the wormhole idea But I'm not sure, if all players want this, since it drains a bit sanity... You could add a setting for that, but this would complicate everything.... Not to mention the hassle to make this work ^^ So I would understand, if you won't add this I'm not sure if clients know where they are.. I think yes. But I fear, that clients do not know which wormholes are linked... There might be a complicated workaround to make it work... but do you think it is worth the hassle? Edited December 3, 2016 by Serpens Link to comment Share on other sites More sharing options...
Codesmith512 Posted December 3, 2016 Author Share Posted December 3, 2016 I definitely need to get this mod stable first, so I'll keep the wormhole idea in mind, but I'm not even going to go down that road until I've got this working. I also think I've found the fix for the paths being off,I just need a few hours to implement and bugtest it. Link to comment Share on other sites More sharing options...
Codesmith512 Posted December 4, 2016 Author Share Posted December 4, 2016 Alright, I just pushed an update... - The pathfinding should be improved (it still just out briefly sometimes; the smoothing algorithm just needs a little more love) - If no path could be found, a null path is returned, resulting in no movement (the island/water case) - Finally I fixed the speed mult issue, so far it goes up to 20x with no issues (if you can get above this without cheating, tell me how and I'll test it more) Link to comment Share on other sites More sharing options...
Serpens Posted December 4, 2016 Share Posted December 4, 2016 (edited) 6 hours ago, Codesmith512 said: Alright, I just pushed an update... - The pathfinding should be improved (it still just out briefly sometimes; the smoothing algorithm just needs a little more love) - If no path could be found, a null path is returned, resulting in no movement (the island/water case) - Finally I fixed the speed mult issue, so far it goes up to 20x with no issues (if you can get above this without cheating, tell me how and I'll test it more) great Were you able to test what happens at other players pc, while pathfinding is calculated? So does it only lag for 1 second at the pc who is doing pathfinding, or also at all other pcs. Edited December 4, 2016 by Serpens Link to comment Share on other sites More sharing options...
Codesmith512 Posted December 4, 2016 Author Share Posted December 4, 2016 I played a two player world from start to day 39 without issues, and the both of us were regularly using it without issues. The pc doing pathfinding froze until pathfinding is finished (completely unresponsive), but it is completely localized to that pc (even the host doing pathfinding doesn't seem to have any adverse effects). Link to comment Share on other sites More sharing options...
Serpens Posted December 4, 2016 Share Posted December 4, 2016 Great As soon as you think the mod is out of BETA, I will use this mod in any game , thank you very much (At the end don't forget to delete the mapscreen from map mod and the locomotor file from trailblazer mod. And replace it with the modmain code I gave you. This is important to 1) be compatible to other mods. 2) be compatible to game updates) Link to comment Share on other sites More sharing options...
Codesmith512 Posted December 5, 2016 Author Share Posted December 5, 2016 I completely missed your code snippet, I'll be sure to get rid of the files. I want to iron out the last wrinkle that I mentioned with the point smoothing (probably this week) and I'll deem it release-worthy. Thanks for the help! Link to comment Share on other sites More sharing options...
Codesmith512 Posted December 13, 2016 Author Share Posted December 13, 2016 I've been playing with this mod for several days now with no issues in sight, so I'm confident enough to remove the beta tag! Thanks again for all the help guys! Link to comment Share on other sites More sharing options...
Serpens Posted December 14, 2016 Share Posted December 14, 2016 (edited) Just did a small test, but it seems the "bug" I reported is still there ? my character runs zigzag. And if you have time left some feature suggestion: 1) It seems the char stops moving when he is attacked (he ran directly into a tallbird). You could make him to continue running, until the player hits any button. 2) If possible you could take roads into calculation, to always travel the fastest possible way. Edited December 14, 2016 by Serpens Link to comment Share on other sites More sharing options...
Codesmith512 Posted December 14, 2016 Author Share Posted December 14, 2016 19 hours ago, Serpens said: Just did a small test, but it seems the "bug" I reported is still there ? my character runs zigzag. That's really weird, I spend several hours smoothing this out. I'll take a look when I get the chance. 19 hours ago, Serpens said: And if you have time left some feature suggestion: 1) It seems the char stops moving when he is attacked (he ran directly into a tallbird). You could make him to continue running, until the player hits any button. 2) If possible you could take roads into calculation, to always travel the fastest possible way. I'll definitely look into those when I get a minute. Unfortunately I coded the mod as something to fill my time between projects, so I'm not sure I have the time to do anymore major development (right now). Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now