mirror of
https://github.com/edubart/otclient.git
synced 2025-10-15 12:04:55 +02:00
affectors attract
This commit is contained in:
@@ -56,6 +56,8 @@ bool AttractionAffector::load(const OTMLNodePtr& node)
|
||||
m_destination = childNode->value<Point>();
|
||||
else if(childNode->tag() == "acceleration")
|
||||
m_acceleration = childNode->value<float>();
|
||||
else if(childNode->tag() == "velocity-reduction-percent")
|
||||
m_reduction = childNode->value<float>();
|
||||
}
|
||||
return true;
|
||||
}
|
||||
@@ -70,6 +72,7 @@ void AttractionAffector::update(const ParticlePtr& particle, double elapsedTime)
|
||||
if(d.length() == 0)
|
||||
return;
|
||||
|
||||
PointF pVelocity = particle->getVelocity();
|
||||
particle->setVelocity(pVelocity + (d / d.length()) * m_acceleration * elapsedTime);
|
||||
PointF pVelocity = particle->getVelocity() + (d / d.length() * m_acceleration * elapsedTime);
|
||||
|
||||
particle->setVelocity(pVelocity - pVelocity * m_reduction/100.0 * elapsedTime);
|
||||
}
|
||||
|
@@ -48,7 +48,7 @@ public:
|
||||
|
||||
private:
|
||||
Point m_destination;
|
||||
float m_acceleration;
|
||||
float m_acceleration, m_reduction;
|
||||
};
|
||||
|
||||
#endif
|
||||
|
Reference in New Issue
Block a user