Skip to content

Commit

Permalink
System to allow specific chars login with clones (inside pvp arena)
Browse files Browse the repository at this point in the history
  • Loading branch information
GustavoContreiras committed Nov 7, 2019
1 parent d3622b7 commit b19b901
Show file tree
Hide file tree
Showing 4 changed files with 34 additions and 9 deletions.
23 changes: 17 additions & 6 deletions Server/data/movements/scripts/arena.lua
Expand Up @@ -11,12 +11,23 @@ function onStepIn(creature, item, position, fromPosition)
creature:registerEvent("Arena-Death")

elseif item.actionid == 2036 then
creature:setStorageValue(storage, 0)
creature:sendTextMessage(MESSAGE_INFO_DESCR, "You have left the arena.")
creature:removeCondition(CONDITION_INFIGHT)
creature:addHealth(creature:getMaxHealth())
creature:addMana(creature:getMaxMana())
creature:unregisterEvent("Arena-Death")
if creature:getName() == "Knight Level 120" then
local pos = Position(33059, 31334, 10)
creature:sendTextMessage(MESSAGE_INFO_DESCR, "You can not leave the arena!")
creature:teleportTo(pos)
pos:sendMagicEffect(CONST_ME_TELEPORT)
return false
else
local pos = Position(33059, 31328, 10)
creature:setStorageValue(storage, 0)
creature:sendTextMessage(MESSAGE_INFO_DESCR, "You have left the arena.")
creature:removeCondition(CONDITION_INFIGHT)
creature:addHealth(creature:getMaxHealth())
creature:addMana(creature:getMaxMana())
creature:teleportTo(pos)
pos:sendMagicEffect(CONST_ME_TELEPORT)
creature:unregisterEvent("Arena-Death")
end
end

return true
Expand Down
6 changes: 5 additions & 1 deletion Server/src/iologindata.cpp
Expand Up @@ -25,6 +25,7 @@

extern ConfigManager g_config;
extern Game g_game;
extern std::vector<std::string> g_allowedClones;

Account IOLoginData::loadAccount(uint32_t accno)
{
Expand Down Expand Up @@ -180,7 +181,10 @@ void IOLoginData::setAccountType(uint32_t accountId, AccountType_t accountType)

void IOLoginData::updateOnlineStatus(uint32_t guid, bool login)
{
if (g_config.getBoolean(ConfigManager::ALLOW_CLONES)) {
Player* player = g_game.getPlayerByGUID(guid);

if (g_config.getBoolean(ConfigManager::ALLOW_CLONES) ||
std::find(g_allowedClones.begin(), g_allowedClones.end(), player->getName()) != g_allowedClones.end()) {
return;
}

Expand Down
5 changes: 5 additions & 0 deletions Server/src/otserv.cpp
Expand Up @@ -45,6 +45,11 @@ ConfigManager g_config;
Monsters g_monsters;
Vocations g_vocations;
RSA g_RSA;
std::vector<std::string> g_allowedClones = {
"Knight Level 60", "Knight Level 120",
"Mage Level 60", "Mage Level 120",
"Ranger Level 60", "Ranger Level 120",
"Empty Level 60", "Empty Level 120" };

std::mutex g_loaderLock;
std::condition_variable g_loaderSignal;
Expand Down
9 changes: 7 additions & 2 deletions Server/src/protocolgame.cpp
Expand Up @@ -40,6 +40,7 @@ extern ConfigManager g_config;
extern Actions actions;
extern CreatureEvents* g_creatureEvents;
extern Chat* g_chat;
extern std::vector<std::string> g_allowedClones;

void ProtocolGame::release()
{
Expand All @@ -58,7 +59,10 @@ void ProtocolGame::login(const std::string& name, uint32_t accountId, OperatingS
{
//dispatcher thread
Player* foundPlayer = g_game.getPlayerByName(name);
if (!foundPlayer || g_config.getBoolean(ConfigManager::ALLOW_CLONES)) {

if (!foundPlayer || g_config.getBoolean(ConfigManager::ALLOW_CLONES) ||
std::find(g_allowedClones.begin(), g_allowedClones.end(), name) != g_allowedClones.end()) {

player = new Player(getThis());
player->setName(name);

Expand All @@ -85,7 +89,8 @@ void ProtocolGame::login(const std::string& name, uint32_t accountId, OperatingS
return;
}

if (g_config.getBoolean(ConfigManager::ONE_PLAYER_ON_ACCOUNT) && player->getAccountType() < ACCOUNT_TYPE_GAMEMASTER && g_game.getPlayerByAccount(player->getAccount())) {
if ((g_config.getBoolean(ConfigManager::ONE_PLAYER_ON_ACCOUNT) && player->getAccountType() < ACCOUNT_TYPE_GAMEMASTER &&
g_game.getPlayerByAccount(player->getAccount())) && std::find(g_allowedClones.begin(), g_allowedClones.end(), name) == g_allowedClones.end()) {
disconnectClient("You may only login with one character\nof your account at the same time.");
return;
}
Expand Down

0 comments on commit b19b901

Please sign in to comment.