Advertisement
Guest User

Untitled

a guest
Mar 25th, 2017
73
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.32 KB | None | 0 0
  1. bool Player::hasAttacked(const Player* attacked) const
  2. {
  3. if (hasFlag(PlayerFlag_NotGainInFight) || !attacked)
  4. return false;
  5.  
  6. AttackedSet::const_iterator it;
  7. uint32_t attackedId = attacked->getID();
  8. it = attackedSet.find(attackedId);
  9. if (it != attackedSet.end())
  10. return true;
  11.  
  12. return false;
  13. }
  14.  
  15. void Player::addAttacked(const Player* attacked)
  16. {
  17. if (hasFlag(PlayerFlag_NotGainInFight) || !attacked || attacked == this)
  18. return;
  19.  
  20. AttackedSet::iterator it;
  21. uint32_t attackedId = attacked->getID();
  22. it = attackedSet.find(attackedId);
  23. if (it == attackedSet.end())
  24. attackedSet.insert(attackedId);
  25. }
  26.  
  27. void Player::setSkullEnd(time_t _time, bool login, Skulls_t _skull)
  28. {
  29. if (g_game.getWorldType() != WORLDTYPE_OPEN
  30. || hasFlag(PlayerFlag_NotGainInFight) ||
  31. hasCustomFlag(PlayerCustomFlag_NotGainSkull))
  32. return;
  33.  
  34. bool requireUpdate = false;
  35. if (_time > time(NULL))
  36. {
  37. requireUpdate = true;
  38. setSkull(_skull);
  39. }
  40. else if (skull == _skull)
  41. {
  42. requireUpdate = true;
  43. setSkull(SKULL_NONE);
  44. _time = 0;
  45. }
  46.  
  47. if (requireUpdate)
  48. {
  49. skullEnd = _time;
  50. if (!login)
  51. g_game.updateCreatureSkull(this);
  52. }
  53. }
  54.  
  55. bool Player::addUnjustifiedKill(const Player* attacked, bool countNow)
  56. {
  57. if (!g_config.getBool(ConfigManager::USE_FRAG_HANDLER) || hasFlag(
  58. PlayerFlag_NotGainInFight) || g_game.getWorldType() != WORLDTYPE_OPEN
  59. || hasCustomFlag(PlayerCustomFlag_NotGainUnjustified) || hasCustomFlag(
  60. PlayerCustomFlag_NotGainSkull) || attacked == this)
  61. return false;
  62.  
  63. if (countNow)
  64. {
  65. char buffer[90];
  66. sprintf(buffer, "Warning! The murder of %s was not justified.", attacked->getName().c_str());
  67. sendTextMessage(MSG_STATUS_WARNING, buffer);
  68. }
  69.  
  70. time_t now = time(NULL), first = (now - g_config.getNumber(ConfigManager::FRAG_LIMIT)),
  71. second = (now - g_config.getNumber(ConfigManager::FRAG_SECOND_LIMIT));
  72. std::vector<time_t> dateList;
  73.  
  74. IOLoginData::getInstance()->getUnjustifiedDates(guid, dateList, now);
  75. if (countNow)
  76. dateList.push_back(now);
  77.  
  78. uint32_t fc = 0, sc = 0, tc = dateList.size();
  79. for (std::vector<time_t>::iterator it = dateList.begin(); it != dateList.end(); ++it)
  80. {
  81. if (second > 0 && (*it) > second)
  82. sc++;
  83.  
  84. if (first > 0 && (*it) > first)
  85. fc++;
  86. }
  87.  
  88. uint32_t f = g_config.getNumber(ConfigManager::RED_LIMIT), s = g_config.getNumber(
  89. ConfigManager::RED_SECOND_LIMIT), t = g_config.getNumber(ConfigManager::RED_THIRD_LIMIT);
  90. if (skull < SKULL_RED && ((f > 0 && fc >= f) || (s > 0 && sc >= s) || (t > 0 && tc >= t)))
  91. setSkullEnd(now + g_config.getNumber(ConfigManager::RED_SKULL_LENGTH), false, SKULL_RED);
  92.  
  93. f += g_config.getNumber(ConfigManager::BAN_LIMIT);
  94. s += g_config.getNumber(ConfigManager::BAN_SECOND_LIMIT);
  95. t += g_config.getNumber(ConfigManager::BAN_THIRD_LIMIT);
  96. if ((f <= 0 || fc < f) && (s <= 0 || sc < s) && (t <= 0 || tc < t))
  97. return true;
  98.  
  99. if (!IOBan::getInstance()->addAccountBanishment(accountId, (now + g_config.getNumber(
  100. ConfigManager::KILLS_BAN_LENGTH)), 28, ACTION_BANISHMENT, "Player Killing (automatic)", 0, guid))
  101. return true;
  102.  
  103. sendTextMessage(MSG_INFO_DESCR, "You have been banished.");
  104. g_game.addMagicEffect(getPosition(), MAGIC_EFFECT_WRAPS_GREEN);
  105. Scheduler::getInstance().addEvent(createSchedulerTask(1000, boost::bind(
  106. &Game::kickPlayer, &g_game, getID(), false)));
  107. return true;
  108. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement