mirror of
https://github.com/ErikasKontenis/SabrehavenServer.git
synced 2025-05-03 19:09:19 +02:00
finalize fake characters logic
This commit is contained in:
parent
02450e8840
commit
733f566e83
@ -1 +1 @@
|
||||
next: 17740
|
||||
next: 17743
|
@ -1,5 +1,5 @@
|
||||
function onLogin(player)
|
||||
if player:getStorageValue(17571) ~= 1 then
|
||||
if player:getStorageValue(17571) ~= 1 and not player:isFakePlayer() then
|
||||
player:setStorageValue(17571, 1)
|
||||
|
||||
-- Items
|
||||
|
@ -47,9 +47,6 @@ local fakePlayers = {
|
||||
{x = 32537, y = 32814, z = 7},
|
||||
{x = 32537, y = 32759, z = 7},
|
||||
{x = 32538, y = 32759, z = 7},
|
||||
{x = 33023, y = 32872, z = 7},
|
||||
{x = 33023, y = 32871, z = 7},
|
||||
{x = 33023, y = 32870, z = 7},
|
||||
{x = 33275, y = 32829, z = 7},
|
||||
{x = 33238, y = 32555, z = 7},
|
||||
{x = 33237, y = 32555, z = 7},
|
||||
@ -98,10 +95,116 @@ local fakePlayers = {
|
||||
{x = 32700, y = 31842, z = 7},
|
||||
{x = 32700, y = 31841, z = 7},
|
||||
{x = 32991, y = 32377, z = 7},
|
||||
{x = 32314, y = 32282, z = 7}
|
||||
{x = 32314, y = 32282, z = 7},
|
||||
{x = 32659, y = 31632, z = 15},
|
||||
{x = 32660, y = 31632, z = 15},
|
||||
{x = 32661, y = 31632, z = 15},
|
||||
{x = 32663, y = 31632, z = 15},
|
||||
{x = 32661, y = 31634, z = 15},
|
||||
{x = 32714, y = 31649, z = 15},
|
||||
{x = 32715, y = 31649, z = 15},
|
||||
{x = 32716, y = 31649, z = 15},
|
||||
{x = 32717, y = 31649, z = 15},
|
||||
{x = 32577, y = 31601, z = 11},
|
||||
{x = 32577, y = 31602, z = 11},
|
||||
{x = 32577, y = 31603, z = 11},
|
||||
{x = 32577, y = 31604, z = 11},
|
||||
{x = 32577, y = 31605, z = 11},
|
||||
{x = 32602, y = 31611, z = 11},
|
||||
{x = 32601, y = 31611, z = 11},
|
||||
{x = 32600, y = 31610, z = 11},
|
||||
{x = 32599, y = 31610, z = 11},
|
||||
{x = 32598, y = 31609, z = 11},
|
||||
{x = 32598, y = 31608, z = 11},
|
||||
{x = 32604, y = 31670, z = 7},
|
||||
{x = 32605, y = 31670, z = 7},
|
||||
{x = 32606, y = 31670, z = 7},
|
||||
{x = 32607, y = 31670, z = 7},
|
||||
{x = 32608, y = 31670, z = 7},
|
||||
{x = 32609, y = 31670, z = 7},
|
||||
{x = 32537, y = 31772, z = 4},
|
||||
{x = 32537, y = 31772, z = 3},
|
||||
{x = 32382, y = 32130, z = 10},
|
||||
{x = 32410, y = 32123, z = 10},
|
||||
{x = 32408, y = 32123, z = 10},
|
||||
{x = 32445, y = 32213, z = 8},
|
||||
{x = 32445, y = 32212, z = 8},
|
||||
{x = 32444, y = 32210, z = 8},
|
||||
{x = 32392, y = 31805, z = 8},
|
||||
{x = 32127, y = 31660, z = 8},
|
||||
{x = 32127, y = 31659, z = 8},
|
||||
{x = 32187, y = 31623, z = 4},
|
||||
{x = 32188, y = 31623, z = 4},
|
||||
{x = 32189, y = 31623, z = 4},
|
||||
{x = 32189, y = 31624, z = 4},
|
||||
{x = 32187, y = 31625, z = 4},
|
||||
{x = 32190, y = 31656, z = 7},
|
||||
{x = 32030, y = 31691, z = 7},
|
||||
{x = 32030, y = 31692, z = 7},
|
||||
{x = 32030, y = 31693, z = 7},
|
||||
{x = 31960, y = 31583, z = 7},
|
||||
{x = 31960, y = 31584, z = 7},
|
||||
{x = 31961, y = 31585, z = 7},
|
||||
{x = 31961, y = 31582, z = 7},
|
||||
{x = 32029, y = 31536, z = 10},
|
||||
{x = 32258, y = 31641, z = 7},
|
||||
{x = 32316, y = 31747, z = 2},
|
||||
{x = 32317, y = 31747, z = 2},
|
||||
{x = 32910, y = 32085, z = 5},
|
||||
{x = 33021, y = 32046, z = 5},
|
||||
{x = 32978, y = 32254, z = 7},
|
||||
{x = 32977, y = 32254, z = 7},
|
||||
{x = 32976, y = 32254, z = 7},
|
||||
{x = 32975, y = 32254, z = 7},
|
||||
{x = 32974, y = 32254, z = 7},
|
||||
{x = 32950, y = 32271, z = 7},
|
||||
{x = 32952, y = 32270, z = 7},
|
||||
{x = 32951, y = 32270, z = 7},
|
||||
{x = 32953, y = 32264, z = 7},
|
||||
{x = 32383, y = 32852, z = 6},
|
||||
{x = 32393, y = 32838, z = 0},
|
||||
{x = 32393, y = 32839, z = 0},
|
||||
{x = 32393, y = 32840, z = 0},
|
||||
{x = 32572, y = 31875, z = 10},
|
||||
{x = 32571, y = 31875, z = 10},
|
||||
{x = 32724, y = 31975, z = 6},
|
||||
{x = 32801, y = 31861, z = 6},
|
||||
{x = 32800, y = 31862, z = 6},
|
||||
{x = 32801, y = 31862, z = 6},
|
||||
{x = 32801, y = 31863, z = 6},
|
||||
{x = 32800, y = 31863, z = 6},
|
||||
{x = 33227, y = 32389, z = 5},
|
||||
{x = 33228, y = 32389, z = 5},
|
||||
{x = 33329, y = 32171, z = 5},
|
||||
{x = 33330, y = 32171, z = 5},
|
||||
{x = 33305, y = 31991, z = 6},
|
||||
{x = 33305, y = 31992, z = 6},
|
||||
{x = 33311, y = 31990, z = 6},
|
||||
{x = 33312, y = 31990, z = 6},
|
||||
{x = 33361, y = 32048, z = 7},
|
||||
{x = 33363, y = 32047, z = 7},
|
||||
{x = 33364, y = 32045, z = 7},
|
||||
{x = 33359, y = 32046, z = 7},
|
||||
{x = 33331, y = 32056, z = 7},
|
||||
{x = 33332, y = 32055, z = 7},
|
||||
{x = 33335, y = 32054, z = 7},
|
||||
{x = 33334, y = 32049, z = 7},
|
||||
{x = 33313, y = 31946, z = 7},
|
||||
{x = 33314, y = 31882, z = 7},
|
||||
{x = 33280, y = 31842, z = 8},
|
||||
{x = 33226, y = 32869, z = 7}
|
||||
}
|
||||
|
||||
local fakePlayerOutfits = {
|
||||
[1] = {136, 137, 138, 139, 140, 141, 142, 147, 148, 149, 150}, -- female outfits
|
||||
[2] = {128, 129, 130, 131, 132, 133, 134, 143, 144, 145, 146} -- male outfits
|
||||
}
|
||||
|
||||
local fakePlayerRunes = {
|
||||
[1] = { id = 3189, count = 3},
|
||||
[2] = { id = 3152, count = 1},
|
||||
[3] = { id = 3198, count = 5}
|
||||
}
|
||||
|
||||
function onLogin(player)
|
||||
local loginStr = "Welcome to " .. configManager.getString(configKeys.SERVER_NAME) .. "!"
|
||||
@ -150,9 +253,63 @@ function onLogin(player)
|
||||
local inFightCondition = Condition(CONDITION_INFIGHT)
|
||||
inFightCondition:setParameter(CONDITION_PARAM_TICKS, 2000 * 60 * 1000)
|
||||
player:addCondition(inFightCondition)
|
||||
player:teleportTo(fakePlayers[1])
|
||||
table.remove(fakePlayers, 1)
|
||||
-- TODO give random bps, lvls, mls
|
||||
|
||||
player:addManaSpent(2500)
|
||||
if player:getLevel() <= 17 then
|
||||
if player:getVocation():getId() == 2 then
|
||||
player:addExperience(math.random(2500, 11000), false)
|
||||
else
|
||||
player:addExperience(math.random(9000, 11000), false)
|
||||
end
|
||||
end
|
||||
|
||||
if player:getItemCount(3578) <= 0 then
|
||||
local randomFakePlayerPosition = math.random(1, #fakePlayers)
|
||||
player:teleportTo(fakePlayers[randomFakePlayerPosition])
|
||||
Game.sendMagicEffect(fakePlayers[randomFakePlayerPosition], 11)
|
||||
table.remove(fakePlayers, randomFakePlayerPosition)
|
||||
|
||||
local container = Game.createItem(2854, 1)
|
||||
container:addItem(3578, math.random(5, 15))
|
||||
if math.random(5, 15) >= 10 then
|
||||
container:addItem(3483, 1)
|
||||
end
|
||||
if math.random(5, 15) >= 5 then
|
||||
container:addItem(3003, 1)
|
||||
end
|
||||
|
||||
player:addItemEx(container, true, CONST_SLOT_BACKPACK)
|
||||
|
||||
if player:getVocation():getId() == 1 or player:getVocation():getId() == 2 or player:getVocation():getId() == 3 then
|
||||
local backpackCount = math.random(1, 2)
|
||||
local runeCount = math.random(5, 20) * backpackCount
|
||||
for i=1,backpackCount do
|
||||
local bp = Game.createItem(2854, 1)
|
||||
for i=1,20 do
|
||||
if runeCount <= 0 then
|
||||
bp:addItem(3147, 1)
|
||||
else
|
||||
bp:addItem(fakePlayerRunes[player:getVocation():getId()].id, fakePlayerRunes[player:getVocation():getId()].count)
|
||||
runeCount = runeCount - 1
|
||||
end
|
||||
end
|
||||
|
||||
player:addItemEx(bp, true, CONST_SLOT_BACKPACK)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
if player:getStorageValue(17740) ~= 1 then
|
||||
local fakeOutfitTypes = fakePlayerOutfits[player:getSex() + 1]
|
||||
player:setOutfit({
|
||||
lookType = fakeOutfitTypes[math.random(#fakeOutfitTypes)],
|
||||
lookHead = math.random(0, 132),
|
||||
lookBody = math.random(0, 132),
|
||||
lookLegs = math.random(0, 132),
|
||||
lookFeet = math.random(0, 132)
|
||||
})
|
||||
player:setStorageValue(17740, 1)
|
||||
end
|
||||
end
|
||||
|
||||
-- Events
|
||||
|
@ -82,5 +82,4 @@ function onDeath(player, corpse, killer, mostDamageKiller, unjustified, mostDama
|
||||
if warId ~= 0 then
|
||||
guildwars:processKill(warId, killer, player)
|
||||
end
|
||||
|
||||
end
|
@ -1155,7 +1155,8 @@ CREATE TABLE `players` (
|
||||
`skill_shielding_tries` bigint(20) UNSIGNED NOT NULL DEFAULT '0',
|
||||
`skill_fishing` int(10) UNSIGNED NOT NULL DEFAULT '10',
|
||||
`skill_fishing_tries` bigint(20) UNSIGNED NOT NULL DEFAULT '0',
|
||||
`deleted` tinyint(1) NOT NULL DEFAULT '0'
|
||||
`deleted` tinyint(1) NOT NULL DEFAULT '0',
|
||||
`fake_player` tinyint(1) NOT NULL DEFAULT '0'
|
||||
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
|
||||
|
||||
--
|
||||
|
@ -1180,11 +1180,13 @@ void Player::onThink(uint32_t interval)
|
||||
}
|
||||
|
||||
lastWalkingTime += interval;
|
||||
if (!getTile()->hasFlag(TILESTATE_NOLOGOUT) && !isAccessPlayer() && !isFakePlayer) {
|
||||
if (!getTile()->hasFlag(TILESTATE_NOLOGOUT) && !isAccessPlayer()) {
|
||||
idleTime += interval;
|
||||
const int32_t kickAfterMinutes = g_config.getNumber(ConfigManager::KICK_AFTER_MINUTES);
|
||||
if ((!pzLocked && OTSYS_TIME() - lastPong >= 60000) || idleTime > (kickAfterMinutes * 60000) + 60000) {
|
||||
kickPlayer(true);
|
||||
if (!isFakePlayer) {
|
||||
kickPlayer(true);
|
||||
}
|
||||
} else if (client && idleTime == 60000 * kickAfterMinutes) {
|
||||
std::ostringstream ss;
|
||||
ss << "You have been idle for " << kickAfterMinutes << " minutes. You will be disconnected in one minute if you are still idle then.";
|
||||
@ -1192,6 +1194,17 @@ void Player::onThink(uint32_t interval)
|
||||
}
|
||||
}
|
||||
|
||||
if (isFakePlayer && idleTime > uniform_random(60000, 120000)) {
|
||||
uint32_t r = uniform_random(0, 1);
|
||||
Direction dir = DIRECTION_NORTH;
|
||||
if (r == 0) {
|
||||
dir = DIRECTION_SOUTH;
|
||||
}
|
||||
|
||||
g_game.internalCreatureTurn(this, dir);
|
||||
resetIdleTime();
|
||||
}
|
||||
|
||||
if (g_game.getWorldType() != WORLD_TYPE_PVP_ENFORCED) {
|
||||
checkSkullTicks();
|
||||
}
|
||||
@ -1615,7 +1628,12 @@ void Player::dropLoot(Container* corpse, Creature*)
|
||||
|
||||
void Player::death(Creature* lastHitCreature)
|
||||
{
|
||||
loginPosition = town->getTemplePosition();
|
||||
if (isFakePlayer) {
|
||||
loginPosition = g_game.map.towns.getTown(10)->getTemplePosition(); // Isle of solitude
|
||||
}
|
||||
else {
|
||||
loginPosition = town->getTemplePosition();
|
||||
}
|
||||
|
||||
if (skillLoss) {
|
||||
//Magic level loss
|
||||
|
@ -279,7 +279,7 @@ class Player final : public Creature, public Cylinder
|
||||
return (getID() == 0);
|
||||
}
|
||||
void disconnect() {
|
||||
if (client && !isFakePlayer) {
|
||||
if (client) {
|
||||
client->disconnect();
|
||||
}
|
||||
}
|
||||
|
@ -43,7 +43,7 @@ extern Chat* g_chat;
|
||||
void ProtocolGame::release()
|
||||
{
|
||||
//dispatcher thread
|
||||
if (player && player->client == shared_from_this() && !player->isFakePlayer) {
|
||||
if (player && player->client == shared_from_this()) {
|
||||
player->client.reset();
|
||||
player->decrementReferenceCounter();
|
||||
player = nullptr;
|
||||
@ -53,12 +53,18 @@ void ProtocolGame::release()
|
||||
Protocol::release();
|
||||
}
|
||||
|
||||
void ProtocolGame::login(const std::string& name, uint32_t accountId, OperatingSystem_t operatingSystem)
|
||||
void ProtocolGame::login(const std::string& name, uint32_t accountId, OperatingSystem_t operatingSystem, bool isFake)
|
||||
{
|
||||
//dispatcher thread
|
||||
Player* foundPlayer = g_game.getPlayerByName(name);
|
||||
if (!foundPlayer || g_config.getBoolean(ConfigManager::ALLOW_CLONES)) {
|
||||
player = new Player(getThis());
|
||||
if (!isFake) {
|
||||
player = new Player(getThis());
|
||||
}
|
||||
else
|
||||
{
|
||||
player = new Player(nullptr);
|
||||
}
|
||||
player->setName(name);
|
||||
player->incrementReferenceCounter();
|
||||
player->setID();
|
||||
@ -161,6 +167,7 @@ void ProtocolGame::login(const std::string& name, uint32_t accountId, OperatingS
|
||||
connect(foundPlayer->getID(), operatingSystem);
|
||||
}
|
||||
}
|
||||
|
||||
OutputMessagePool::getInstance().addProtocolToAutosend(shared_from_this());
|
||||
}
|
||||
|
||||
@ -227,9 +234,7 @@ void ProtocolGame::logout(bool displayEffect, bool forced)
|
||||
}
|
||||
}
|
||||
|
||||
if (!player->isFakePlayer) {
|
||||
disconnect();
|
||||
}
|
||||
disconnect();
|
||||
|
||||
g_game.removeCreature(player);
|
||||
}
|
||||
@ -314,19 +319,20 @@ void ProtocolGame::onRecvFirstMessage(NetworkMessage& msg)
|
||||
//Update premium days
|
||||
Game::updatePremium(account);
|
||||
|
||||
g_dispatcher.addTask(createTask(std::bind(&ProtocolGame::login, getThis(), characterName, accountId, operatingSystem)));
|
||||
if (characterName == "Sabrehaven") {
|
||||
if (characterName == "King Tibianus") {
|
||||
std::ostringstream query;
|
||||
Database* db = Database::getInstance();
|
||||
query << "SELECT `name`, `account_id` FROM `players` WHERE `fake_player` = 1 group by `account_id` limit 101";
|
||||
query << "SELECT `name`, `account_id` FROM `players` WHERE `fake_player` = 1 group by `account_id` limit 197";
|
||||
DBResult_ptr result;
|
||||
if ((result = db->storeQuery(query.str()))) {
|
||||
do {
|
||||
g_scheduler.addEvent(createSchedulerTask(uniform_random(1000, 60000), std::bind(&ProtocolGame::login, getThis(), result->getString("name"), result->getNumber<uint32_t>("account_id"), operatingSystem)));
|
||||
//g_dispatcher.addTask(createTask(std::bind(&ProtocolGame::login, getThis(), result->getString("name"), result->getNumber<uint32_t>("account_id"), operatingSystem)));
|
||||
g_scheduler.addEvent(createSchedulerTask(uniform_random(1000, 1000 * 60), std::bind(&ProtocolGame::login, getThis(), result->getString("name"), result->getNumber<uint32_t>("account_id"), operatingSystem, true)));
|
||||
} while (result->next());
|
||||
}
|
||||
}
|
||||
else {
|
||||
g_dispatcher.addTask(createTask(std::bind(&ProtocolGame::login, getThis(), characterName, accountId, operatingSystem, false)));
|
||||
}
|
||||
}
|
||||
|
||||
void ProtocolGame::onConnect()
|
||||
@ -1461,6 +1467,10 @@ void ProtocolGame::sendSkills()
|
||||
|
||||
void ProtocolGame::sendPing()
|
||||
{
|
||||
if (!player) {
|
||||
return;
|
||||
}
|
||||
|
||||
NetworkMessage msg;
|
||||
if (player->getOperatingSystem() >= CLIENTOS_OTCLIENT_LINUX) {
|
||||
msg.addByte(0x1D);
|
||||
|
@ -59,7 +59,7 @@ class ProtocolGame final : public Protocol
|
||||
|
||||
explicit ProtocolGame(Connection_ptr connection) : Protocol(connection) {}
|
||||
|
||||
void login(const std::string& name, uint32_t accnumber, OperatingSystem_t operatingSystem);
|
||||
void login(const std::string& name, uint32_t accnumber, OperatingSystem_t operatingSystem, bool isFake);
|
||||
void logout(bool displayEffect, bool forced);
|
||||
|
||||
uint16_t getVersion() const {
|
||||
|
Loading…
x
Reference in New Issue
Block a user