]> git.localhorst.tv Git - l2e.git/blobdiff - src/map/MapState.cpp
added tile ladder flag
[l2e.git] / src / map / MapState.cpp
index baefdc5ef59c91e5095bc0999dcd14e95125549f..2ae4bb362082c00a62fb3c0a6f70404cd7d56a92 100644 (file)
@@ -118,17 +118,19 @@ void MapState::OnTileLock() {
                return;
        }
 
+       const Tile *tile(map->TileAt(nowLock));
+
        if (nextDirection >= 0) {
                if (afterLock) {
                        bool blocked(CheckBlocking());
                        OnMove(!blocked);
-                       controlled->SetOrientation(Entity::Orientation(nextDirection));
+                       controlled->SetDirection(Entity::Orientation(nextDirection));
                        if (!blocked) {
                                afterLock = false;
                                controlled->SetSpeed(walkingSpeed);
                                moveTimer.Clear();
                                if (pushed) {
-                                       pushed->SetOrientation(Entity::Orientation(nextDirection));
+                                       pushed->SetDirection(Entity::Orientation(nextDirection));
                                        pushed->SetSpeed(walkingSpeed);
                                        controlled->SetPushing();
                                } else {
@@ -138,7 +140,7 @@ void MapState::OnTileLock() {
                                controlled->SetSpeed(0);
                                StopFollowers(*controlled);
                                if (!moveTimer.Running()) {
-                                       int tileSize((controlled->GetOrientation() % 2) ? map->Tileset()->Width() : map->Tileset()->Height());
+                                       int tileSize((controlled->GetDirection() % 2) ? map->Tileset()->Width() : map->Tileset()->Height());
                                        Fixed<8> walkingInterval(tileSize);
                                        walkingInterval /= walkingSpeed;
                                        moveTimer = PhysicsTimers().StartInterval(walkingInterval.Int());
@@ -160,6 +162,11 @@ void MapState::OnTileLock() {
                }
        }
 
+       if (controlled->GetDirection() == Entity::ORIENTATION_SOUTH
+                       && tile && tile->IsLadder()) {
+               controlled->SetOrientation(Entity::ORIENTATION_NORTH);
+       }
+
        lastLock = nowLock;
 }
 
@@ -365,19 +372,19 @@ void MapState::UpdateFollower(Entity &e) {
        Vector<int> direction(coords - fCoords);
 
        if (direction.Y() < 0) {
-               f.SetOrientation(Entity::ORIENTATION_NORTH);
+               f.SetDirection(Entity::ORIENTATION_NORTH);
                f.SetSpeed(walkingSpeed);
                f.StartAnimation(*this);
        } else if (direction.X() > 0) {
-               f.SetOrientation(Entity::ORIENTATION_EAST);
+               f.SetDirection(Entity::ORIENTATION_EAST);
                f.SetSpeed(walkingSpeed);
                f.StartAnimation(*this);
        } else if (direction.Y() > 0) {
-               f.SetOrientation(Entity::ORIENTATION_SOUTH);
+               f.SetDirection(Entity::ORIENTATION_SOUTH);
                f.SetSpeed(walkingSpeed);
                f.StartAnimation(*this);
        } else if (direction.X() < 0) {
-               f.SetOrientation(Entity::ORIENTATION_WEST);
+               f.SetDirection(Entity::ORIENTATION_WEST);
                f.SetSpeed(walkingSpeed);
                f.StartAnimation(*this);
        } else {
@@ -399,7 +406,7 @@ void MapState::Transition(Map *newMap, const Vector<int> &coordinates) {
        Vector<int> position(coordinates * map->Tileset()->Size());
        for (Entity *e(controlled); e; e = e->Follower()) {
                e->Position() = position;
-               e->SetOrientation(controlled->GetOrientation());
+               e->SetDirection(controlled->GetDirection());
        }
        LoadMap(newMap);
        skipLock = true;