diff options
Diffstat (limited to 'src/game-server/being.cpp')
-rw-r--r-- | src/game-server/being.cpp | 44 |
1 files changed, 14 insertions, 30 deletions
diff --git a/src/game-server/being.cpp b/src/game-server/being.cpp index c9bec84c..2c549c9f 100644 --- a/src/game-server/being.cpp +++ b/src/game-server/being.cpp @@ -117,41 +117,26 @@ void Being::move() MovingObject::move(); if (mAction == WALK || mAction == STAND) { - if (mActionTime) - { - mAction = WALK; - } - else - { - mAction = STAND; - } + mAction = (mActionTime) ? WALK : STAND; } } -void Being::performAttack(Damage const &damage, AttackZone const *attackZone) +int Being::directionToAngle(int direction) { - Point ppos = getPosition(); - int dir = getDirection(); - - int attackAngle = 0; - - switch (dir) + switch (direction) { - case DIRECTION_UP: - attackAngle = 90; - break; - case DIRECTION_DOWN: - attackAngle = 270; - break; + case DIRECTION_UP: return 90; + case DIRECTION_DOWN: return 270; + case DIRECTION_RIGHT: return 180; case DIRECTION_LEFT: - attackAngle = 0; - break; - case DIRECTION_RIGHT: - attackAngle = 180; - break; - default: - break; + default: return 0; } +} + +void Being::performAttack(Damage const &damage, AttackZone const *attackZone) +{ + Point ppos = getPosition(); + const int attackAngle = directionToAngle(getDirection()); std::list<Being *> victims; @@ -160,7 +145,7 @@ void Being::performAttack(Damage const &damage, AttackZone const *attackZone) { MovingObject *o = *i; Point opos = o->getPosition(); - + if (o == this) continue; int type = o->getType(); @@ -168,7 +153,6 @@ void Being::performAttack(Damage const &damage, AttackZone const *attackZone) if (type != OBJECT_CHARACTER && type != OBJECT_MONSTER) continue; - switch (attackZone->shape) { case ATTZONESHAPE_CONE: |