Jump to content

Detect decouple event /engine start event


Recommended Posts

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 by Dagger
Link to comment
Share on other sites

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 by Dagger
Link to comment
Share on other sites

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

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 by Dagger
Link to comment
Share on other sites

This thread is quite old. Please consider starting a new thread rather than reviving this one.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...