From 3c0af406c2b8d74558e236f9f99862ea0e33bf4a Mon Sep 17 00:00:00 2001 From: Guillaume Melquiond Date: Sat, 30 Dec 2006 17:19:33 +0000 Subject: Just for fun: a trigger to change map. --- src/game-server/mapcomposite.hpp | 6 ++++++ src/game-server/state.cpp | 29 +++++++++++++++++++++++++++++ 2 files changed, 35 insertions(+) diff --git a/src/game-server/mapcomposite.hpp b/src/game-server/mapcomposite.hpp index 84fbb2d0..84599d39 100644 --- a/src/game-server/mapcomposite.hpp +++ b/src/game-server/mapcomposite.hpp @@ -188,6 +188,12 @@ class MapComposite { */ ZoneIterator getAroundPlayerIterator(Player *, int radius) const; + /** + * Gets all the objects on the map. + */ + Objects const &getObjects() const + { return objects; } + private: MapComposite(MapComposite const &); diff --git a/src/game-server/state.cpp b/src/game-server/state.cpp index f4eb75d5..5fade89a 100644 --- a/src/game-server/state.cpp +++ b/src/game-server/state.cpp @@ -242,6 +242,35 @@ void State::update() static_cast< Being * >(o)->clearHitsTaken(); } } + + // Just for fun. Should be replaced by a real trigger system. + for (size_t i = map->getObjects().size(); i-- > 0;) + { + Object *o = map->getObjects()[i]; + if (o->getType() != OBJECT_PLAYER) continue; + Point pos = o->getPosition(); + int x = pos.x / 32, y = pos.y / 32; + int m = 0; + switch (o->getMapId()) + { + case 1: + if (x >= 56 && x <= 60 && y == 12) + { m = 3; x = 44; y = 80; } + break; + case 3: + if (x >= 42 && x <= 46 && y == 88) + { m = 1; x = 58; y = 17; } + break; + } + if (m != 0) + { + removeObject(o); + o->setMapId(m); + pos.x = x * 32; pos.y = y * 32; + o->setPosition(pos); + addObject(o); + } + } } } -- cgit v1.2.3-60-g2f50