beeki

Walk pvp

Jun 4th, 2012
58
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 1.57 KB | None | 0 0
  1. bool Player::canWalkthrough(const Creature* creature) const
  2. {
  3.     if(creature == this || hasFlag(PlayerFlag_CanPassThroughAllCreatures) || creature->isWalkable() ||
  4.         std::find(forceWalkthrough.begin(), forceWalkthrough.end(), creature->getID()) != forceWalkthrough.end()
  5.         || (creature->getMaster() && creature->getMaster() != this && canWalkthrough(creature->getMaster())))
  6.         return true;
  7.  
  8.     const Player* player = creature->getPlayer();
  9.     if(!player)
  10.         return false;
  11.  
  12.     if(((g_game.getWorldType() == WORLDTYPE_OPTIONAL && !player->isEnemy(this, true) &&
  13.         !player->isProtected()) || player->getTile()->hasFlag(TILESTATE_PROTECTIONZONE) || player->isProtected()) && player->getTile()->ground
  14.         && Item::items[player->getTile()->ground->getID()].walkStack && (!player->hasCustomFlag(PlayerCustomFlag_GamemasterPrivileges)
  15.         || player->getAccess() <= getAccess()))
  16.         return true;
  17.  
  18.     return (player->isGhost() && getGhostAccess() < player->getGhostAccess())
  19.         || (isGhost() && getGhostAccess() > player->getGhostAccess());
  20. }
  21.  
  22. void Player::setWalkthrough(const Creature* creature, bool walkthrough)
  23. {
  24.     std::vector<uint32_t>::iterator it = std::find(forceWalkthrough.begin(),
  25.         forceWalkthrough.end(), creature->getID());
  26.     bool update = false;
  27.     if(walkthrough && it == forceWalkthrough.end())
  28.     {
  29.         forceWalkthrough.push_back(creature->getID());
  30.         update = true;
  31.     }
  32.     else if(!walkthrough && it != forceWalkthrough.end())
  33.     {
  34.         forceWalkthrough.erase(it);
  35.         update = true;
  36.     }
  37.  
  38.     if(update)
  39.         sendCreatureWalkthrough(creature, !walkthrough ? canWalkthrough(creature) : walkthrough);
  40. }
Advertisement
Add Comment
Please, Sign In to add comment