Small changes
This commit is contained in:
parent
ae731ddefc
commit
2a2214991c
|
@ -576,36 +576,23 @@ void Creature::setName(const std::string& name)
|
||||||
|
|
||||||
void Creature::setHealthPercent(uint8 healthPercent)
|
void Creature::setHealthPercent(uint8 healthPercent)
|
||||||
{
|
{
|
||||||
m_informationColor = Color::black;
|
if(healthPercent > 92)
|
||||||
|
m_informationColor = Color(0, 188, 0);
|
||||||
if(healthPercent > 92) {
|
else if(healthPercent > 60)
|
||||||
m_informationColor.setGreen(188);
|
m_informationColor = Color(80, 161, 80);
|
||||||
}
|
else if(healthPercent > 30)
|
||||||
else if(healthPercent > 60) {
|
m_informationColor = Color(80, 161, 0);
|
||||||
m_informationColor.setRed(80);
|
else if(healthPercent > 8)
|
||||||
m_informationColor.setGreen(161);
|
m_informationColor = Color(160, 39, 39);
|
||||||
m_informationColor.setBlue(80);
|
else if(healthPercent > 3)
|
||||||
}
|
m_informationColor = Color(160, 0, 0);
|
||||||
else if(healthPercent > 30) {
|
else
|
||||||
m_informationColor.setRed(161);
|
m_informationColor = Color(79, 0, 0);
|
||||||
m_informationColor.setGreen(161);
|
|
||||||
}
|
|
||||||
else if(healthPercent > 8) {
|
|
||||||
m_informationColor.setRed(160);
|
|
||||||
m_informationColor.setGreen(39);
|
|
||||||
m_informationColor.setBlue(39);
|
|
||||||
}
|
|
||||||
else if(healthPercent > 3) {
|
|
||||||
m_informationColor.setRed(160);
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
m_informationColor.setRed(79);
|
|
||||||
}
|
|
||||||
|
|
||||||
m_healthPercent = healthPercent;
|
m_healthPercent = healthPercent;
|
||||||
callLuaField("onHealthPercentChange", healthPercent);
|
callLuaField("onHealthPercentChange", healthPercent);
|
||||||
|
|
||||||
if(healthPercent < 1)
|
if(healthPercent <= 0)
|
||||||
onDeath();
|
onDeath();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -826,11 +813,7 @@ int Creature::getStepDuration(bool ignoreDiagonal)
|
||||||
|
|
||||||
Point Creature::getDisplacement()
|
Point Creature::getDisplacement()
|
||||||
{
|
{
|
||||||
if(m_outfit.getCategory() == ThingCategoryEffect)
|
return Point(getDisplacementX(), getDisplacementY());
|
||||||
return Point(8, 8);
|
|
||||||
else if(m_outfit.getCategory() == ThingCategoryItem)
|
|
||||||
return Point(0, 0);
|
|
||||||
return Thing::getDisplacement();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
int Creature::getDisplacementX()
|
int Creature::getDisplacementX()
|
||||||
|
|
|
@ -57,21 +57,6 @@ LocalPlayer::LocalPlayer()
|
||||||
m_totalCapacity = -1;
|
m_totalCapacity = -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
void LocalPlayer::draw(const Point& dest, float scaleFactor, bool animate, LightView *lightView)
|
|
||||||
{
|
|
||||||
Creature::draw(dest, scaleFactor, animate, lightView);
|
|
||||||
|
|
||||||
/*
|
|
||||||
// This is a test to rotation, translate and scale transformations.
|
|
||||||
Point rotateOffset = dest;
|
|
||||||
rotateOffset += ((animate ? m_walkOffset : Point(0,0)) + Point(16,16)) * scaleFactor;
|
|
||||||
g_painter->pushTransformMatrix();
|
|
||||||
g_painter->rotate(rotateOffset, Fw::pi * std::sin(g_clock.millis()/1000.0f));
|
|
||||||
Creature::draw(dest, scaleFactor, animate, lightView);
|
|
||||||
g_painter->popTransformMatrix();
|
|
||||||
*/
|
|
||||||
}
|
|
||||||
|
|
||||||
void LocalPlayer::lockWalk(int millis)
|
void LocalPlayer::lockWalk(int millis)
|
||||||
{
|
{
|
||||||
m_walkLockExpiration = std::max(m_walkLockExpiration, (ticks_t) g_clock.millis() + millis);
|
m_walkLockExpiration = std::max(m_walkLockExpiration, (ticks_t) g_clock.millis() + millis);
|
||||||
|
|
|
@ -35,8 +35,6 @@ class LocalPlayer : public Player
|
||||||
public:
|
public:
|
||||||
LocalPlayer();
|
LocalPlayer();
|
||||||
|
|
||||||
virtual void draw(const Point& dest, float scaleFactor, bool animate, LightView *lightView = nullptr);
|
|
||||||
|
|
||||||
void unlockWalk() { m_walkLockExpiration = 0; }
|
void unlockWalk() { m_walkLockExpiration = 0; }
|
||||||
void lockWalk(int millis = 250);
|
void lockWalk(int millis = 250);
|
||||||
void stopAutoWalkUpdate();
|
void stopAutoWalkUpdate();
|
||||||
|
|
|
@ -141,46 +141,26 @@ public:
|
||||||
}
|
}
|
||||||
|
|
||||||
Otc::Direction getDirectionFromPosition(const Position& position) const {
|
Otc::Direction getDirectionFromPosition(const Position& position) const {
|
||||||
int dx = position.x - x;
|
float angle = getAngleFromPosition(position) * RAD_TO_DEC;
|
||||||
int dy = position.y - y;
|
|
||||||
|
|
||||||
if(dx == 0 && dy == 0)
|
if(angle >= 360 - 22.5 || angle < 0 + 22.5)
|
||||||
|
return Otc::East;
|
||||||
|
else if(angle >= 45 - 22.5 && angle < 45 + 22.5)
|
||||||
|
return Otc::NorthEast;
|
||||||
|
else if(angle >= 90 - 22.5 && angle < 90 + 22.5)
|
||||||
|
return Otc::North;
|
||||||
|
else if(angle >= 135 - 22.5 && angle < 135 + 22.5)
|
||||||
|
return Otc::NorthWest;
|
||||||
|
else if(angle >= 180 - 22.5 && angle < 180 + 22.5)
|
||||||
|
return Otc::West;
|
||||||
|
else if(angle >= 225 - 22.5 && angle < 225 + 22.5)
|
||||||
|
return Otc::SouthWest;
|
||||||
|
else if(angle >= 270 - 22.5 && angle < 270 + 22.5)
|
||||||
|
return Otc::South;
|
||||||
|
else if(angle >= 315 - 22.5 && angle < 315 + 22.5)
|
||||||
|
return Otc::SouthEast;
|
||||||
|
else
|
||||||
return Otc::InvalidDirection;
|
return Otc::InvalidDirection;
|
||||||
else if(dx == 0) {
|
|
||||||
if(dy < 0)
|
|
||||||
return Otc::North;
|
|
||||||
else if(dy > 0)
|
|
||||||
return Otc::South;
|
|
||||||
}
|
|
||||||
else if(dy == 0) {
|
|
||||||
if(dx < 0)
|
|
||||||
return Otc::West;
|
|
||||||
else if(dx > 0)
|
|
||||||
return Otc::East;
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
float angle = std::atan2(dy * -1, dx) * RAD_TO_DEC;
|
|
||||||
if(angle < 0)
|
|
||||||
angle += 360;
|
|
||||||
|
|
||||||
if(angle >= 360 - 22.5 || angle < 0 + 22.5)
|
|
||||||
return Otc::East;
|
|
||||||
else if(angle >= 45 - 22.5 && angle < 45 + 22.5)
|
|
||||||
return Otc::NorthEast;
|
|
||||||
else if(angle >= 90 - 22.5 && angle < 90 + 22.5)
|
|
||||||
return Otc::North;
|
|
||||||
else if(angle >= 135 - 22.5 && angle < 135 + 22.5)
|
|
||||||
return Otc::NorthWest;
|
|
||||||
else if(angle >= 180 - 22.5 && angle < 180 + 22.5)
|
|
||||||
return Otc::West;
|
|
||||||
else if(angle >= 225 - 22.5 && angle < 225 + 22.5)
|
|
||||||
return Otc::SouthWest;
|
|
||||||
else if(angle >= 270 - 22.5 && angle < 270 + 22.5)
|
|
||||||
return Otc::South;
|
|
||||||
else if(angle >= 315 - 22.5 && angle < 315 + 22.5)
|
|
||||||
return Otc::SouthEast;
|
|
||||||
}
|
|
||||||
return Otc::InvalidDirection;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
bool isMapPosition() const { return (x < 65535 && y < 65535 && z <= Otc::MAX_Z); }
|
bool isMapPosition() const { return (x < 65535 && y < 65535 && z <= Otc::MAX_Z); }
|
||||||
|
|
Loading…
Reference in New Issue