Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- bool Player::hasAttacked(const Player* attacked) const
- {
- if (hasFlag(PlayerFlag_NotGainInFight) || !attacked)
- return false;
- AttackedSet::const_iterator it;
- uint32_t attackedId = attacked->getID();
- it = attackedSet.find(attackedId);
- if (it != attackedSet.end())
- return true;
- return false;
- }
- void Player::addAttacked(const Player* attacked)
- {
- if (hasFlag(PlayerFlag_NotGainInFight) || !attacked || attacked == this)
- return;
- AttackedSet::iterator it;
- uint32_t attackedId = attacked->getID();
- it = attackedSet.find(attackedId);
- if (it == attackedSet.end())
- attackedSet.insert(attackedId);
- }
- void Player::setSkullEnd(time_t _time, bool login, Skulls_t _skull)
- {
- if (g_game.getWorldType() != WORLDTYPE_OPEN
- || hasFlag(PlayerFlag_NotGainInFight) ||
- hasCustomFlag(PlayerCustomFlag_NotGainSkull))
- return;
- bool requireUpdate = false;
- if (_time > time(NULL))
- {
- requireUpdate = true;
- setSkull(_skull);
- }
- else if (skull == _skull)
- {
- requireUpdate = true;
- setSkull(SKULL_NONE);
- _time = 0;
- }
- if (requireUpdate)
- {
- skullEnd = _time;
- if (!login)
- g_game.updateCreatureSkull(this);
- }
- }
- bool Player::addUnjustifiedKill(const Player* attacked, bool countNow)
- {
- if (!g_config.getBool(ConfigManager::USE_FRAG_HANDLER) || hasFlag(
- PlayerFlag_NotGainInFight) || g_game.getWorldType() != WORLDTYPE_OPEN
- || hasCustomFlag(PlayerCustomFlag_NotGainUnjustified) || hasCustomFlag(
- PlayerCustomFlag_NotGainSkull) || attacked == this)
- return false;
- if (countNow)
- {
- char buffer[90];
- sprintf(buffer, "Warning! The murder of %s was not justified.", attacked->getName().c_str());
- sendTextMessage(MSG_STATUS_WARNING, buffer);
- }
- time_t now = time(NULL), first = (now - g_config.getNumber(ConfigManager::FRAG_LIMIT)),
- second = (now - g_config.getNumber(ConfigManager::FRAG_SECOND_LIMIT));
- std::vector<time_t> dateList;
- IOLoginData::getInstance()->getUnjustifiedDates(guid, dateList, now);
- if (countNow)
- dateList.push_back(now);
- uint32_t fc = 0, sc = 0, tc = dateList.size();
- for (std::vector<time_t>::iterator it = dateList.begin(); it != dateList.end(); ++it)
- {
- if (second > 0 && (*it) > second)
- sc++;
- if (first > 0 && (*it) > first)
- fc++;
- }
- uint32_t f = g_config.getNumber(ConfigManager::RED_LIMIT), s = g_config.getNumber(
- ConfigManager::RED_SECOND_LIMIT), t = g_config.getNumber(ConfigManager::RED_THIRD_LIMIT);
- if (skull < SKULL_RED && ((f > 0 && fc >= f) || (s > 0 && sc >= s) || (t > 0 && tc >= t)))
- setSkullEnd(now + g_config.getNumber(ConfigManager::RED_SKULL_LENGTH), false, SKULL_RED);
- f += g_config.getNumber(ConfigManager::BAN_LIMIT);
- s += g_config.getNumber(ConfigManager::BAN_SECOND_LIMIT);
- t += g_config.getNumber(ConfigManager::BAN_THIRD_LIMIT);
- if ((f <= 0 || fc < f) && (s <= 0 || sc < s) && (t <= 0 || tc < t))
- return true;
- if (!IOBan::getInstance()->addAccountBanishment(accountId, (now + g_config.getNumber(
- ConfigManager::KILLS_BAN_LENGTH)), 28, ACTION_BANISHMENT, "Player Killing (automatic)", 0, guid))
- return true;
- sendTextMessage(MSG_INFO_DESCR, "You have been banished.");
- g_game.addMagicEffect(getPosition(), MAGIC_EFFECT_WRAPS_GREEN);
- Scheduler::getInstance().addEvent(createSchedulerTask(1000, boost::bind(
- &Game::kickPlayer, &g_game, getID(), false)));
- return true;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement