Dagger Posted October 21, 2016 Share Posted October 21, 2016 (edited) Hi, I'm forking DMP (dark multiplayer mod) and I'm very happy with the result so far, the vessels are loaded correctly, their positions are updated smoothly etc. Still there's one issue that is giving me headaches as I can't find a solution in the API. Say for example that a client stages his rocket so now the vessel is divided in 2 (the active vessel of the client and a debris part) How can I reproduce that behaviour in the other client machine? I know I can detect the moment that the vessel is modified in the GameEvents.onVesselPartCountChanged or in the GameEvents.onVesselWasModified but what I want to achieve is to get the part ID that triggered the decoupling, send a message to the other clients and then reproduce that decoupling by calling the Part.Decouple() Method on the other clients vessels -- Right now I'm sending the started engines, stopped engines, launch clamps and decouplers that a vessel has in periodic updates and once another client detects that the represented vessel has more decouplers than it should then it triggers the needed one by using vessel.FindPartModulesImplementing<ModuleDecouple>()....Decouple() This logic works but it's not a good solution as I have to check the vessel all the time and I waste resources. Also, the OnStageSeparation event is not a good option as is triggered when any vessel stages and not only the active vessel and even if I want to use it, I will still have the same problems when clamps are released or turbofan engines are started... It would be nice to be able to detect events such as when an engine starts, clamp is released, decoupler is activated, etc... Edited October 21, 2016 by Dagger Link to comment Share on other sites More sharing options...
sarbian Posted October 21, 2016 Share Posted October 21, 2016 onStageSeparation, onPartJointBreak and onPartUndock all carry info on the origin part. Link to comment Share on other sites More sharing options...
Dagger Posted October 21, 2016 Author Share Posted October 21, 2016 (edited) Thanks @sarbian, I already tried the onPartJointBreak but it's called many times and the onStageSeparation is called after the part is separated so the part.Vessel property corresponds to the new vessel and not the old vessel that triggered it. I didn't tried with onPartUndock but it seems that in only works when undocking and not on decoupling. It would be best to have a similar event fired just before the decoupling Regarding my second question, is there any event to detect when an engine is started? Right now the client plane moves but their engines appears as they're turned off. Edited October 21, 2016 by Dagger Link to comment Share on other sites More sharing options...
Diazo Posted October 21, 2016 Share Posted October 21, 2016 I can't help with the code issue, but I'm not sure detecting an engine can be done. What happens when an engine is activated, burns for a bit and then is throttle down to zero? It's still "activated" but you'd also need some way to turn the engine plume off. For current status of things like engines you may be stuck with the periodic updates route. D. Link to comment Share on other sites More sharing options...
Dagger Posted October 21, 2016 Author Share Posted October 21, 2016 (edited) 1 hour ago, Diazo said: I can't help with the code issue, but I'm not sure detecting an engine can be done. What happens when an engine is activated, burns for a bit and then is throttle down to zero? It's still "activated" but you'd also need some way to turn the engine plume off. For current status of things like engines you may be stuck with the periodic updates route. D. Well if I do with the periodic update it works but right now I'm sending a packet every 50ms so every 50ms I must go to the vessel and check all the engine, clamps, decouplers etc and send if they are on or off. Then on another client, every time I receive a update I must go to that vessel and compare the status against the status that I received. That's really bad in terms of performance but anyway, KSP was not programmed with multiplayer in mind. It would be much better if I can just send a message when engines are on, off, clamps have been released (via the right click menu) or decouplers activated. Edited October 21, 2016 by Dagger 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