diff options
author | Andrei Karas <akaras@inbox.ru> | 2011-04-26 21:56:11 +0300 |
---|---|---|
committer | Andrei Karas <akaras@inbox.ru> | 2011-04-26 21:56:11 +0300 |
commit | 8f10444e4ce4a4e25455f0a3857edc7ca74631e8 (patch) | |
tree | 7917730822f7bc090adc6af482eab843c79a389c /src | |
parent | 110134603554e06adab93a132ef8f82e55db68ad (diff) | |
download | plus-8f10444e4ce4a4e25455f0a3857edc7ca74631e8.tar.gz plus-8f10444e4ce4a4e25455f0a3857edc7ca74631e8.tar.bz2 plus-8f10444e4ce4a4e25455f0a3857edc7ca74631e8.tar.xz plus-8f10444e4ce4a4e25455f0a3857edc7ca74631e8.zip |
Impliment 3 attack lists. (priority, attack, ignore)
Diffstat (limited to 'src')
-rw-r--r-- | src/actorspritemanager.cpp | 173 | ||||
-rw-r--r-- | src/avatar.h | 1 | ||||
-rw-r--r-- | src/gui/popupmenu.cpp | 136 | ||||
-rw-r--r-- | src/gui/popupmenu.h | 2 | ||||
-rw-r--r-- | src/gui/socialwindow.cpp | 43 | ||||
-rw-r--r-- | src/gui/viewport.cpp | 4 | ||||
-rw-r--r-- | src/gui/viewport.h | 2 | ||||
-rw-r--r-- | src/gui/widgets/avatarlistbox.cpp | 65 | ||||
-rw-r--r-- | src/localplayer.cpp | 52 | ||||
-rw-r--r-- | src/localplayer.h | 31 | ||||
-rw-r--r-- | src/map.h | 6 |
11 files changed, 368 insertions, 147 deletions
diff --git a/src/actorspritemanager.cpp b/src/actorspritemanager.cpp index 2f8c28ad5..6162ba727 100644 --- a/src/actorspritemanager.cpp +++ b/src/actorspritemanager.cpp @@ -96,6 +96,22 @@ class SortBeingFunctor if (!being1 || !being2) return false; + if (priorityBeings) + { + int w1 = defaultPriorityIndex; + int w2 = defaultPriorityIndex; + std::map<std::string, int>::iterator it1 + = priorityBeings->find(being1->getName()); + std::map<std::string, int>::iterator it2 + = priorityBeings->find(being2->getName()); + if (it1 != priorityBeings->end()) + w1 = (*it1).second; + if (it2 != priorityBeings->end()) + w2 = (*it2).second; + + if (w1 != w2) + return w1 < w2; + } if (being1->getDistance() != being2->getDistance()) return being1->getDistance() < being2->getDistance(); @@ -119,17 +135,17 @@ class SortBeingFunctor if (d1 != d2) return d1 < d2; - if (beings) + if (attackBeings) { - int w1 = defaultIndex; - int w2 = defaultIndex; + int w1 = defaultAttackIndex; + int w2 = defaultAttackIndex; std::map<std::string, int>::iterator it1 - = beings->find(being1->getName()); + = attackBeings->find(being1->getName()); std::map<std::string, int>::iterator it2 - = beings->find(being2->getName()); - if (it1 != beings->end()) + = attackBeings->find(being2->getName()); + if (it1 != attackBeings->end()) w1 = (*it1).second; - if (it2 != beings->end()) + if (it2 != attackBeings->end()) w2 = (*it2).second; if (w1 != w2) @@ -139,8 +155,10 @@ class SortBeingFunctor return (being1->getName() < being2->getName()); } int x, y; - std::map<std::string, int> *beings; - int defaultIndex; + std::map<std::string, int> *attackBeings; + int defaultAttackIndex; + std::map<std::string, int> *priorityBeings; + int defaultPriorityIndex; } beingSorter; @@ -187,28 +205,6 @@ void ActorSpriteManager::setPlayer(LocalPlayer *player) Being *ActorSpriteManager::createBeing(int id, ActorSprite::Type type, Uint16 subtype) { -/* - for_actors - { - if ((*it)->getId() == id && (*it)->getType() == type) - { - if ((*it) && (*it)->getType() == Being::PLAYER) - static_cast<Being*>(*it)->addToCache(); - if (player_node) - { - if (player_node->getTarget() == *it) - player_node->setTarget(0); - if (player_node->getPickUpTarget() == *it) - player_node->unSetPickUpTarget(); - } - if (viewport) - viewport->clearHover(*it); - mActors.erase(*it); - delete *it; - break; - } - } -*/ Being *being = new Being(id, type, subtype, mMap); mActors.insert(being); @@ -621,35 +617,9 @@ Being *ActorSpriteManager::findNearestLivingBeing(int x, int y, ActorSprite::Type type, Being *excluded) const { - //Being *closestBeing = 0; - //int dist = 0; - const int maxDist = maxTileDist * 32; return findNearestLivingBeing(NULL, maxDist, type, x, y, excluded); - -/* - for_actors - { - if ((*it)->getType() == ActorSprite::FLOOR_ITEM) - continue; - - Being *being = static_cast<Being*>(*it); - const Vector &pos = being->getPosition(); - int d = abs(((int) pos.x) - x) + abs(((int) pos.y) - y); - - if ((being->getType() == type || type == ActorSprite::UNKNOWN) - && (d < dist || !closestBeing) // it is closer - && being->isAlive() // no dead beings - && being != excluded) - { - dist = d; - closestBeing = being; - } - } - - return (maxDist >= dist) ? closestBeing : 0; -*/ } Being *ActorSpriteManager::findNearestLivingBeing(Being *aroundBeing, @@ -677,9 +647,12 @@ Being *ActorSpriteManager::findNearestLivingBeing(Being *aroundBeing, Being *closestBeing = 0; std::set<std::string> attackMobs; + std::set<std::string> priorityMobs; std::set<std::string> ignoreAttackMobs; - std::map<std::string, int> mobsMap; - int defaultIndex = 10000; + std::map<std::string, int> attackMobsMap; + std::map<std::string, int> priorityMobsMap; + int defaultAttackIndex = 10000; + int defaultPriorityIndex = 10000; maxDist = maxDist * maxDist; @@ -693,14 +666,20 @@ Being *ActorSpriteManager::findNearestLivingBeing(Being *aroundBeing, if (filtered) { attackMobs = player_node->getAttackMobsSet(); + priorityMobs = player_node->getPriorityAttackMobsSet(); ignoreAttackMobs = player_node->getIgnoreAttackMobsSet(); - mobsMap = player_node->getAttackMobsMap(); - beingSorter.beings = &mobsMap; + attackMobsMap = player_node->getAttackMobsMap(); + priorityMobsMap = player_node->getPriorityAttackMobsMap(); + beingSorter.attackBeings = &attackMobsMap; + beingSorter.priorityBeings = &priorityMobsMap; if (ignoreAttackMobs.find("") != ignoreAttackMobs.end()) ignoreDefault = true; - std::map<std::string, int>::iterator itr = mobsMap.find(""); - if (itr != mobsMap.end()) - defaultIndex = (*itr).second; + std::map<std::string, int>::iterator itr = attackMobsMap.find(""); + if (itr != attackMobsMap.end()) + defaultAttackIndex = (*itr).second; + itr = priorityMobsMap.find(""); + if (itr != priorityMobsMap.end()) + defaultPriorityIndex = (*itr).second; } if (cycleSelect) @@ -727,7 +706,8 @@ Being *ActorSpriteManager::findNearestLivingBeing(Being *aroundBeing, continue; } if (ignoreDefault && attackMobs.find(being->getName()) - == attackMobs.end()) + == attackMobs.end() && priorityMobs.find(being->getName()) + == priorityMobs.end()) { continue; } @@ -747,16 +727,22 @@ Being *ActorSpriteManager::findNearestLivingBeing(Being *aroundBeing, beingSorter.y = y; if (filtered) { - beingSorter.beings = &mobsMap; - beingSorter.defaultIndex = defaultIndex; + beingSorter.attackBeings = &attackMobsMap; + beingSorter.defaultAttackIndex = defaultAttackIndex; + beingSorter.priorityBeings = &priorityMobsMap; + beingSorter.defaultPriorityIndex = defaultPriorityIndex; } else { - beingSorter.beings = 0; + beingSorter.attackBeings = 0; + beingSorter.priorityBeings = 0; } sort(sortedBeings.begin(), sortedBeings.end(), beingSorter); if (filtered) - beingSorter.beings = 0; + { + beingSorter.attackBeings = 0; + beingSorter.priorityBeings = 0; + } if (player_node->getTarget() == NULL) { @@ -800,7 +786,8 @@ Being *ActorSpriteManager::findNearestLivingBeing(Being *aroundBeing, continue; } if (ignoreDefault && attackMobs.find(being->getName()) - == attackMobs.end()) + == attackMobs.end() && priorityMobs.find(being->getName()) + == priorityMobs.end()) { continue; } @@ -810,6 +797,7 @@ Being *ActorSpriteManager::findNearestLivingBeing(Being *aroundBeing, bool valid = validateBeing(aroundBeing, being, type, excluded, 50); int d = being->getDistance(); + int index = defaultPriorityIndex; // logger->log("dist: %d", dist); // logger->log("name: %s, %d, %d", being->getName().c_str(), (int)valid, d); if (being->getType() != Being::MONSTER @@ -823,31 +811,48 @@ Being *ActorSpriteManager::findNearestLivingBeing(Being *aroundBeing, // logger->log("d:" + toString(d)); // logger->log("valid:" + toString(valid)) - if (valid && (d <= dist || closestBeing == 0)) + if (valid && !filtered && (d <= dist || closestBeing == 0)) + { + dist = d; + closestBeing = being; + } + else if (valid && filtered) { - if (closestBeing && filtered && d == dist) + int w2 = defaultPriorityIndex; + if (closestBeing) { - int w1 = defaultIndex; - int w2 = defaultIndex; - std::map<std::string, int>::iterator it1 - = mobsMap.find(closestBeing->getName()); std::map<std::string, int>::iterator it2 - = mobsMap.find(being->getName()); - if (it1 != mobsMap.end()) - w1 = (*it1).second; - if (it2 != mobsMap.end()) + = priorityMobsMap.find(being->getName()); + if (it2 != priorityMobsMap.end()) w2 = (*it2).second; - if (w2 < w1) + if (w2 < index) { dist = d; closestBeing = being; + index = w2; + continue; + } + if (w2 == index && d <= dist) + { + dist = d; + closestBeing = being; + index = w2; + continue; } - continue; } - dist = d; - closestBeing = being; + if (!closestBeing) + { + dist = d; + closestBeing = being; + std::map<std::string, int>::iterator it1 + = priorityMobsMap.find(being->getName()); + if (it1 != priorityMobsMap.end()) + index = (*it1).second; + else + index = defaultPriorityIndex; + } } } return (maxDist >= dist) ? closestBeing : 0; diff --git a/src/avatar.h b/src/avatar.h index 4ffceeb9f..83f4a586a 100644 --- a/src/avatar.h +++ b/src/avatar.h @@ -28,7 +28,6 @@ enum AvatarType { AVATAR_PLAYER = 0 -// AVATAR_PORTAL }; class Avatar diff --git a/src/gui/popupmenu.cpp b/src/gui/popupmenu.cpp index 7b0688587..ad0cb275f 100644 --- a/src/gui/popupmenu.cpp +++ b/src/gui/popupmenu.cpp @@ -254,19 +254,19 @@ void PopupMenu::showPopup(int x, int y, Being *being) if (config.getBoolValue("enableAttackFilter")) { mBrowserBox->addRow("##3---"); - if (player_node->isInAttackList(name)) + if (player_node->isInAttackList(name) + || player_node->isInIgnoreAttackList(name) + || player_node->isInPriorityAttackList(name)) { mBrowserBox->addRow( _("@@remove attack|Remove from attack list@@")); } - else if (player_node->isInIgnoreAttackList(name)) - { - mBrowserBox->addRow( - _("@@remove attack|Remove from ignore list@@")); - } else { mBrowserBox->addRow( + _("@@add attack priority|Add " + "to priority attack list@@")); + mBrowserBox->addRow( _("@@add attack|Add to attack list@@")); mBrowserBox->addRow( _("@@add attack ignore|Add to ignore list@@")); @@ -1165,6 +1165,15 @@ void PopupMenu::handleLink(const std::string &link, socialWindow->updateAttackFilter(); } } + else if (link == "add attack priority" && being) + { + if (player_node && being->getType() == Being::MONSTER) + { + player_node->addPriorityAttackMob(being->getName()); + if (socialWindow) + socialWindow->updateAttackFilter(); + } + } else if (link == "add attack ignore" && being) { if (player_node && being->getType() == Being::MONSTER) @@ -1203,6 +1212,36 @@ void PopupMenu::handleLink(const std::string &link, } } } + else if (link == "priority moveup") + { + if (player_node) + { + int idx = player_node->getPriorityAttackMobIndex(mNick); + if (idx > 0) + { + std::list<std::string> mobs + = player_node->getPriorityAttackMobs(); + std::list<std::string>::iterator it = mobs.begin(); + std::list<std::string>::iterator it2 = mobs.begin(); + while (it != mobs.end()) + { + if (*it == mNick) + { + -- it2; + mobs.splice(it2, mobs, it); + player_node->setPriorityAttackMobs(mobs); + player_node->rebuildPriorityAttackMobs(); + break; + } + ++ it; + ++ it2; + } + + if (socialWindow) + socialWindow->updateAttackFilter(); + } + } + } else if (link == "attack movedown") { if (player_node) @@ -1236,6 +1275,40 @@ void PopupMenu::handleLink(const std::string &link, } } } + else if (link == "priority movedown") + { + if (player_node) + { + int idx = player_node->getPriorityAttackMobIndex(mNick); + int size = player_node->getPriorityAttackMobsSize(); + if (idx + 1 < size) + { + std::list<std::string> mobs + = player_node->getPriorityAttackMobs(); + std::list<std::string>::iterator it = mobs.begin(); + std::list<std::string>::iterator it2 = mobs.begin(); + while (it != mobs.end()) + { + if (*it == mNick) + { + ++ it2; + if (it2 == mobs.end()) + break; + + mobs.splice(it, mobs, it2); + player_node->setPriorityAttackMobs(mobs); + player_node->rebuildPriorityAttackMobs(); + break; + } + ++ it; + ++ it2; + } + + if (socialWindow) + socialWindow->updateAttackFilter(); + } + } + } else if (link == "attack remove") { if (player_node) @@ -1606,7 +1679,7 @@ void PopupMenu::showPopup(int x, int y, ProgressBar *b) } void PopupMenu::showAttackMonsterPopup(int x, int y, std::string name, - bool isAttack) + int type) { if (!player_node) return; @@ -1619,27 +1692,48 @@ void PopupMenu::showAttackMonsterPopup(int x, int y, std::string name, mBrowserBox->addRow(_("(default)")); else mBrowserBox->addRow(name); - if (isAttack) + switch (type) { - int idx = player_node->getAttackMobIndex(name); - int size = player_node->getAttackMobsSize(); - if (idx > 0) + case MapItem::ATTACK: { + int idx = player_node->getAttackMobIndex(name); + int size = player_node->getAttackMobsSize(); + if (idx > 0) + { + mBrowserBox->addRow(strprintf( + "@@attack moveup|%s@@", _("Move up"))); + } + if (idx + 1 < size) + { + mBrowserBox->addRow(strprintf( + "@@attack movedown|%s@@", _("Move down"))); + } mBrowserBox->addRow(strprintf( - "@@attack moveup|%s@@", _("Move up"))); + "@@attack remove|%s@@", _("Remove"))); + break; } - if (idx + 1 < size) + case MapItem::PRIORITY: { + int idx = player_node->getPriorityAttackMobIndex(name); + int size = player_node->getPriorityAttackMobsSize(); + if (idx > 0) + { + mBrowserBox->addRow(strprintf( + "@@priority moveup|%s@@", _("Move up"))); + } + if (idx + 1 < size) + { + mBrowserBox->addRow(strprintf( + "@@priority movedown|%s@@", _("Move down"))); + } mBrowserBox->addRow(strprintf( - "@@attack movedown|%s@@", _("Move down"))); + "@@attack remove|%s@@", _("Remove"))); + break; } - mBrowserBox->addRow(strprintf( - "@@attack remove|%s@@", _("Remove"))); - } - else - { - mBrowserBox->addRow(strprintf( - "@@attack remove|%s@@", _("Remove"))); + case MapItem::IGNORE: + mBrowserBox->addRow(strprintf( + "@@attack remove|%s@@", _("Remove"))); + break; } mBrowserBox->addRow("##3---"); diff --git a/src/gui/popupmenu.h b/src/gui/popupmenu.h index 61720d417..208652083 100644 --- a/src/gui/popupmenu.h +++ b/src/gui/popupmenu.h @@ -118,7 +118,7 @@ class PopupMenu : public Popup, public LinkHandler void showSpellPopup(int x, int y, TextCommand *cmd); void showAttackMonsterPopup(int x, int y, std::string name, - bool isAttack); + int type); /** * Shows the related popup menu when right click on the chat diff --git a/src/gui/socialwindow.cpp b/src/gui/socialwindow.cpp index c6ec12cd8..d25ca209d 100644 --- a/src/gui/socialwindow.cpp +++ b/src/gui/socialwindow.cpp @@ -808,7 +808,7 @@ public: std::vector<Avatar*> *avatars = mBeings->getMembers(); - std::list<std::string> mobs = player_node->getAttackMobs(); + std::list<std::string> mobs = player_node->getPriorityAttackMobs(); std::list<std::string>::iterator i = mobs.begin(); std::vector<Avatar*>::iterator ia = avatars->begin(); @@ -820,7 +820,7 @@ public: } avatars->clear(); - Avatar *ava = new Avatar(_("Selected mobs")); + Avatar *ava = new Avatar(_("Priority mobs")); ava->setOnline(false); ava->setLevel(-1); ava->setType(MapItem::SEPARATOR); @@ -844,7 +844,42 @@ public: Avatar *ava = new Avatar(name); ava->setOnline(true); ava->setLevel(level); - ava->setType(MapItem::MONSTER); + ava->setType(MapItem::PRIORITY); + ava->setX(0); + ava->setY(0); + avatars->push_back(ava); + + ++ i; + } + + ava = new Avatar(_("Attack mobs")); + ava->setOnline(false); + ava->setLevel(-1); + ava->setType(MapItem::SEPARATOR); + ava->setX(0); + ava->setY(0); + avatars->push_back(ava); + + mobs = player_node->getAttackMobs(); + i = mobs.begin(); + + while (i != mobs.end()) + { + std::string name; + int level = -1; + if (*i == "") + { + name = _("(default)"); + level = 0; + } + else + { + name = *i; + } + Avatar *ava = new Avatar(name); + ava->setOnline(true); + ava->setLevel(level); + ava->setType(MapItem::ATTACK); ava->setX(0); ava->setY(0); avatars->push_back(ava); @@ -879,7 +914,7 @@ public: Avatar *ava = new Avatar(name); ava->setOnline(false); ava->setLevel(level); - ava->setType(MapItem::MONSTER); + ava->setType(MapItem::IGNORE); ava->setX(0); ava->setY(0); avatars->push_back(ava); diff --git a/src/gui/viewport.cpp b/src/gui/viewport.cpp index 9688c818a..478059f53 100644 --- a/src/gui/viewport.cpp +++ b/src/gui/viewport.cpp @@ -625,10 +625,10 @@ void Viewport::showPopup(int x, int y, ProgressBar *bar) mPopupMenu->showPopup(x, y, bar); } -void Viewport::showAttackMonsterPopup(std::string name, bool isAttack) +void Viewport::showAttackMonsterPopup(std::string name, int type) { mPopupMenu->showAttackMonsterPopup(getMouseX(), getMouseY(), - name, isAttack); + name, type); } void Viewport::closePopupMenu() diff --git a/src/gui/viewport.h b/src/gui/viewport.h index 59db38e4c..d3a3bfe4b 100644 --- a/src/gui/viewport.h +++ b/src/gui/viewport.h @@ -160,7 +160,7 @@ class Viewport : public WindowContainer, public gcn::MouseListener, void showSpellPopup(TextCommand *cmd); - void showAttackMonsterPopup(std::string name, bool isAttack); + void showAttackMonsterPopup(std::string name, int type); /** * Shows the related popup menu when right click on the chat diff --git a/src/gui/widgets/avatarlistbox.cpp b/src/gui/widgets/avatarlistbox.cpp index f3bdb6a45..d16388837 100644 --- a/src/gui/widgets/avatarlistbox.cpp +++ b/src/gui/widgets/avatarlistbox.cpp @@ -308,42 +308,47 @@ void AvatarListBox::mousePressed(gcn::MouseEvent &event) } else if (event.getButton() == gcn::MouseEvent::RIGHT) { - if (ava->getType() == AVATAR_PLAYER) + switch (ava->getType()) { - Being* being = actorSpriteManager->findBeingByName( - model->getAvatarAt(selected)->getName(), Being::PLAYER); - if (being) - { - viewport->showPopup(event.getX(), event.getY(), being); - } - else + case AVATAR_PLAYER: { - viewport->showPlayerPopup( - model->getAvatarAt(selected)->getName()); - } - } - else if (ava->getType() == MapItem::MONSTER) - { - if (model->getAvatarAt(selected)->getLevel() == 0) - { - viewport->showAttackMonsterPopup("", - model->getAvatarAt(selected)->getOnline()); + Being* being = actorSpriteManager->findBeingByName( + model->getAvatarAt(selected)->getName(), Being::PLAYER); + if (being) + { + viewport->showPopup(event.getX(), event.getY(), being); + } + else + { + viewport->showPlayerPopup( + model->getAvatarAt(selected)->getName()); + } + break; } - else + case MapItem::ATTACK: + case MapItem::PRIORITY: + case MapItem::IGNORE: { - viewport->showAttackMonsterPopup( - model->getAvatarAt(selected)->getName(), - model->getAvatarAt(selected)->getOnline()); + std::string name; + if (model->getAvatarAt(selected)->getLevel() == 0) + name = ""; + else + name = model->getAvatarAt(selected)->getName(); + + viewport->showAttackMonsterPopup(name, + model->getAvatarAt(selected)->getType()); + break; } - } - else - { - Map *map = viewport->getMap(); - Avatar *ava = model->getAvatarAt(selected); - if (map && ava) + default: { - MapItem *mapItem = map->findPortalXY(ava->getX(), ava->getY()); - viewport->showPopup(mapItem); + Map *map = viewport->getMap(); + Avatar *ava = model->getAvatarAt(selected); + if (map && ava) + { + MapItem *mapItem = map->findPortalXY(ava->getX(), ava->getY()); + viewport->showPopup(mapItem); + } + break; } } } diff --git a/src/localplayer.cpp b/src/localplayer.cpp index de6eef334..860b1cbe4 100644 --- a/src/localplayer.cpp +++ b/src/localplayer.cpp @@ -3806,11 +3806,14 @@ void LocalPlayer::checkNewName(Being *being) void LocalPlayer::removeAttackMob(const std::string &name) { + mPriorityAttackMobs.remove(name); mAttackMobs.remove(name); mIgnoreAttackMobs.remove(name); + mPriorityAttackMobsSet.erase(name); mAttackMobsSet.erase(name); mIgnoreAttackMobsSet.erase(name); rebuildAttackMobs(); + rebuildPriorityAttackMobs(); } void LocalPlayer::addAttackMob(std::string name) @@ -3836,6 +3839,32 @@ void LocalPlayer::addAttackMob(std::string name) } mAttackMobsSet.insert(name); rebuildAttackMobs(); + rebuildPriorityAttackMobs(); +} + +void LocalPlayer::addPriorityAttackMob(std::string name) +{ + int size = getPriorityAttackMobsSize(); + if (size > 0) + { + int idx = getPriorityAttackMobIndex(""); + if (idx + 1 == size) + { + std::list<std::string>::iterator itr = mPriorityAttackMobs.end(); + -- itr; + mPriorityAttackMobs.insert(itr, name); + } + else + { + mPriorityAttackMobs.push_back(name); + } + } + else + { + mPriorityAttackMobs.push_back(name); + } + mPriorityAttackMobsSet.insert(name); + rebuildPriorityAttackMobs(); } void LocalPlayer::addIgnoreAttackMob(std::string name) @@ -3843,6 +3872,20 @@ void LocalPlayer::addIgnoreAttackMob(std::string name) mIgnoreAttackMobs.push_back(name); mIgnoreAttackMobsSet.insert(name); rebuildAttackMobs(); + rebuildPriorityAttackMobs(); +} + +void LocalPlayer::rebuildPriorityAttackMobs() +{ + mPriorityAttackMobsMap.clear(); + std::list<std::string>::iterator i = mPriorityAttackMobs.begin(); + int cnt = 0; + while (i != mPriorityAttackMobs.end()) + { + mPriorityAttackMobsMap[*i] = cnt; + ++ i; + ++ cnt; + } } void LocalPlayer::rebuildAttackMobs() @@ -3858,6 +3901,15 @@ void LocalPlayer::rebuildAttackMobs() } } +int LocalPlayer::getPriorityAttackMobIndex(std::string name) +{ + std::map<std::string, int>::iterator i = mPriorityAttackMobsMap.find(name); + if (i == mPriorityAttackMobsMap.end()) + return -1; + + return (*i).second; +} + int LocalPlayer::getAttackMobIndex(std::string name) { std::map<std::string, int>::iterator i = mAttackMobsMap.find(name); diff --git a/src/localplayer.h b/src/localplayer.h index f42258a82..b20a89786 100644 --- a/src/localplayer.h +++ b/src/localplayer.h @@ -64,7 +64,6 @@ enum PICKUP_DROP_STEAL }; - /** * The local player character. */ @@ -453,26 +452,43 @@ class LocalPlayer : public Being, public ActorSpriteListener, bool isInAttackList(const std::string &name) { return mAttackMobsSet.find(name) != mAttackMobsSet.end(); } + bool isInPriorityAttackList(const std::string &name) + { return mPriorityAttackMobsSet.find(name) + != mPriorityAttackMobsSet.end(); } + bool isInIgnoreAttackList(const std::string &name) { return mIgnoreAttackMobsSet.find(name) != mIgnoreAttackMobsSet.end(); } +/* bool isInAttackOrIgnoreList(const std::string &name) { return mAttackMobsSet.find(name) != mAttackMobsSet.end() || mIgnoreAttackMobsSet.find(name) != mIgnoreAttackMobsSet.end(); } +*/ void removeAttackMob(const std::string &name); + void addPriorityAttackMob(std::string name); + void addAttackMob(std::string name); void addIgnoreAttackMob(std::string name); + std::list<std::string> getPriorityAttackMobs() + { return mPriorityAttackMobs; } + std::list<std::string> getAttackMobs() { return mAttackMobs; } + void setPriorityAttackMobs(std::list<std::string> mobs) + { mPriorityAttackMobs = mobs; } + void setAttackMobs(std::list<std::string> mobs) { mAttackMobs = mobs; } + int getPriorityAttackMobsSize() + { return mPriorityAttackMobs.size(); } + int getAttackMobsSize() { return mAttackMobs.size(); } @@ -482,16 +498,26 @@ class LocalPlayer : public Being, public ActorSpriteListener, std::set<std::string> getAttackMobsSet() { return mAttackMobsSet; } + std::set<std::string> getPriorityAttackMobsSet() + { return mPriorityAttackMobsSet; } + std::set<std::string> getIgnoreAttackMobsSet() { return mIgnoreAttackMobsSet; } + void rebuildPriorityAttackMobs(); + void rebuildAttackMobs(); std::map<std::string, int> getAttackMobsMap() { return mAttackMobsMap; } + std::map<std::string, int> getPriorityAttackMobsMap() + { return mPriorityAttackMobsMap; } + int getAttackMobIndex(std::string name); + int getPriorityAttackMobIndex(std::string name); + void resetYellowBar(); protected: @@ -620,10 +646,13 @@ class LocalPlayer : public Being, public ActorSpriteListener, bool mServerAttack; std::string mLastHitFrom; std::string mWaitFor; + std::list<std::string> mPriorityAttackMobs; std::list<std::string> mAttackMobs; std::list<std::string> mIgnoreAttackMobs; + std::set<std::string> mPriorityAttackMobsSet; std::set<std::string> mAttackMobsSet; std::set<std::string> mIgnoreAttackMobsSet; + std::map<std::string, int> mPriorityAttackMobsMap; std::map<std::string, int> mAttackMobsMap; }; @@ -585,8 +585,10 @@ class MapItem ARROW_RIGHT = 7, PORTAL = 8, MUSIC = 9, - MONSTER = 10, - SEPARATOR = 11 + ATTACK = 10, + PRIORITY = 11, + IGNORE = 12, + SEPARATOR = 13 }; MapItem(); |