Spin Protection - Request…
-
Ahoy m8tys i had a look at the Spin Protection (from Kossacs Plugin and am thinking about the implementation).
Here is the snippet of code that will do the spin protection and i cant seem to grasp what it is used for…
uint iShip; uint iClientIDTarget = HkGetClientIDByShip(ci.dwTargetShip); pub::Player::GetShip(iClientID, iShip); uint iType; pub::SpaceObj::GetType(ci.dwTargetShip, iType); if(iType == 65536) { float fMass; pub::SpaceObj::GetMass(iShip, fMass); if(set_fSpinProtectMass!=-1.0f && !iClientIDTarget && fMass>=set_fSpinProtectMass) { Vector V1, V2; pub::SpaceObj::GetMotion(ci.dwTargetShip, V1, V2); pub::SpaceObj::GetMass(ci.dwTargetShip, fMass); V1.x *= set_fSpinImpulseMultiplier * fMass; V1.y *= set_fSpinImpulseMultiplier * fMass; V1.z *= set_fSpinImpulseMultiplier * fMass; V2.x *= set_fSpinImpulseMultiplier * fMass; V2.y *= set_fSpinImpulseMultiplier * fMass; V2.z *= set_fSpinImpulseMultiplier * fMass; pub::SpaceObj::AddImpulse(ci.dwTargetShip, V1, V2); } }
At first we try to retrieve if the target that was hit is a player (iClientIDTarget) or anything else.
Then the ship of the current player is retrieved. And the type of object that was hit.
Only if the object that was hit was a fighter (65536) then a spin correction will be considered. Additionally to this it is checked whether it was activated (set_fSpinProtectMass!=-1.0f) and its not a player (!iClientIDTarget) and the mass of the own ship is bigger than the defined spin mass correction.
So now the question. Why is it limited to npcs only and fighters actually? That means if a non fighter will hit my ship it is still start to spin. And if another player hits the ship it will still start spinning because another player should have a iClientIDTarget that is valid and bigger than 0.
Wouldnt it be better to say the spin is adjusted if the own ship is a BS, freighter, gunboat (or whatever criteria should be met) and correct the impulse if the mass exceeds a defined value?
Or is there anything i dont see. From what i understand by the code the spin protection does not work if two players hit each other and only if the own ship will hit a fighter…
Any hints appreciated. Thanks in advance! -
Originaly it is M0tah’s code just ported into plugin, so need to ask M0tah. A saw him at Flak forums not long time ago…
-
Ok, but every coder can have a look at this. And as far as i could figure out from the code the spin protection will only work if you hit with your ship a feighter and your ships mass is bigger than a defined value.
This would result that big ships (BS) would still start to spin when they are hit by anything else than fighters
And the question that comes up for me is: Is that supposed to be exactly this way - or is there anything i dont get properly from this code? -
-
Only NPC ;(
Other part is modded - did not checked, but there was option antispin with Flak mod activation…
Dig also http://forge.the-starport.net/attachments/download/346/flhook_plugin_1.6.1_discovery_release_8July2011.7z by comment “// Only take collision damage if we’re colliding with a big ship.” -
look into values like “mass”, “thrust_force”, and “nudge_force”. just imagine the units to be not custom but taken from the real world like meters are; and a solution may become apparent.
of course, this thought maybe futile if freelancer physics are designed to have flaws like these. for my part i find it more appropriate to test first if and how far freelancer is designed bad enough before asking for magical additional codework solutions which would only affect players in MP.