HSharp wrote:QUOTE (HSharp @ Oct 17 2012, 11:30 AM) You say this but Im sure that entering alephs not at centre can put you in a non-centre exit while going centre entry you exit centre.
CODE89 Orientation alephOrientation = pwarpDest->GetOrientation();
90 const Vector& v = m_pShip->GetVelocity();
91 float speed2 = v.LengthSquared();
92 float speed = float(sqrt(speed2));
93 if (speed2 > 0)
94 {
95 float error;
96 {
97 //How close is the ship coming to the center of the warp?
98 Vector dp = pwarp->GetPosition() - m_pShip->GetPosition();
99
100 float t = (dp * v) / speed2;
101 float d = (dp - t * v).LengthSquared();
102 float r = pwarp->GetRadius();
103
104 error = (d / (r*r)) + 0.125f; //Error ranges from 0.125 to 1.125
105 // yp: to prevent 'spin of death' in massive ships.
106 // This works and is explained in that the more massive the ship the less effect going through the aleph should have
107 // on its rotational velocity. The massive amount of inertia should decrease changes in rotational velocity.
108 if(m_pShip->GetMass() > 300.0f)
109 {
110 error = error * (300.0f / m_pShip->GetMass()); // the greater the mass is above 750 the less error will be applied.
111 }
112 // yp end
113 }
114
115 alephOrientation.Pitch(random(-error, error));
116 alephOrientation.Yaw(random(-error, error));
117
118 m_pShip->SetCurrentTurnRate(c_axisRoll,
119 m_pShip->GetCurrentTurnRate(c_axisRoll) +
120 random(pi * 0.5f * error, pi * 1.5f * error)); //Must be less than 2.0 * pi
121 }
122 m_pShip->SetOrientation(alephOrientation);
Oh hey, you're right - the further from the center of the aleph you hit, the bigger the boundaries on the random direction you get sent out at.