• There is NO official Otland's Discord server and NO official Otland's server list. The Otland's Staff does not manage any Discord server or server list. Moderators or administrator of any Discord server or server lists have NO connection to the Otland's Staff. Do not get scammed!

Feature Rook System Working on 8.6

Bill3000

New Member
Joined
Jul 26, 2010
Messages
106
Reaction score
1
This is a Source Edit for Rook System that works on 8.6 (tested and no errors found)

How it works: as same as Rl-Tibia does: If you have a vocation and live on Main, when you downgrade from Level 6 to Level 5, you will be send to Rookgaard again, with level 1, start items, no items from main, no Addons, and no skills (all skills come back to 10 - Magic level to 0).

Ps: If you want it to remove Mounts (in case of 8.7+) I can post here, but it's show at the code if you want to add by yourself ;)

Let's Start:

Configmanager.cpp add:

Lua:
	m_confBool[ROOK_SYSTEM] = getGlobalBool("useRookSystem", false);
	m_confNumber[ROOK_TOWN] = getGlobalNumber("rookTownId", 1);
	m_confNumber[ROOK_LEVELTO] = getGlobalNumber("rookLevelToGetRooked", 5);
	m_confNumber[ROOK_TOLEVEL] = getGlobalNumber("rookLevelToLeaveRook", 8);

configmanager.h add:

Lua:
	ROOK_SYSTEM,
	ROOK_TOWN,
	ROOK_LEVELTO,
	ROOK_TOLEVEL,

iologindata.cpp add: (I don't remember where exactly)
Lua:
	Vocation* vocation = Vocations::getInstance()->getVocation(vocationId);
	Vocation* rookVoc = Vocations::getInstance()->getVocation(0);

	uint16_t healthMax = 150, manaMax = 0, capMax = 400, lookType = 136;
	if(sex % 2)
		lookType = 128;

	uint32_t level = g_config.getNumber(ConfigManager::START_LEVEL), tmpLevel = std::min((uint32_t)7, (level - 1));
	uint64_t exp = 0;
	if(level > 1)
		exp = Player::getExpForLevel(level);

	if(tmpLevel > 0)
	{
		healthMax += rookVoc->getGain(GAIN_HEALTH) * tmpLevel;
		manaMax += rookVoc->getGain(GAIN_MANA) * tmpLevel;
		capMax += rookVoc->getGainCap() * tmpLevel;
		if(level > 8)
		{
			tmpLevel = level - 8;
			healthMax += vocation->getGain(GAIN_HEALTH) * tmpLevel;
			manaMax += vocation->getGain(GAIN_MANA) * tmpLevel;
			capMax += vocation->getGainCap() * tmpLevel;
		}
	}

Player.cpp add (3 Parts):

First Part, look for
Code:
//player has reached max level

then add just under it:

Lua:
		levelPercent = 0;
		sendStats();
		return;
	}

	experience += exp;
	while(experience >= nextLevelExp)
	{
		++level;
		Vocation* voc = vocation;
		if(voc->getId() > 0 && g_config.getBool(ConfigManager::ROOK_SYSTEM) &&
			level <= (uint32_t)g_config.getNumber(ConfigManager::ROOK_TOLEVEL))
		{
			if(Vocation* tmp = Vocations::getInstance()->getVocation(0))
				voc = tmp;
		}

		healthMax += voc->getGain(GAIN_HEALTH);
		health += voc->getGain(GAIN_HEALTH);
		manaMax += voc->getGain(GAIN_MANA);
		mana += voc->getGain(GAIN_MANA);
		capacity += voc->getGainCap();

		nextLevelExp = Player::getExpForLevel(level + 1);
		if(Player::getExpForLevel(level) > nextLevelExp) //player has reached max level

Second part: look for
Code:
void Player::removeExperience(uint64_t exp, bool updateStats/* = true*/)

Then add just under it:
Lua:
{
	uint32_t prevLevel = level;
	bool attackable = isProtected();

	experience -= std::min(exp, experience);
	while(level > 1 && experience < Player::getExpForLevel(level))
	{
		--level;
		Vocation* voc = vocation;
		if(voc->getId() > 0 && g_config.getBool(ConfigManager::ROOK_SYSTEM) &&
			level < (uint32_t)g_config.getNumber(ConfigManager::ROOK_TOLEVEL))
		{
			if(Vocation* tmp = Vocations::getInstance()->getVocation(0))
				voc = tmp;
		}

		healthMax = std::max((int32_t)0, (healthMax - (int32_t)voc->getGain(GAIN_HEALTH)));
		manaMax = std::max((int32_t)0, (manaMax - (int32_t)voc->getGain(GAIN_MANA)));
		capacity = std::max((double)0, (capacity - (double)voc->getGainCap()));
	}

Third and Last part at player.cpp

Look for
Code:
if(!inventory[SLOT_BACKPACK])

Remove and add this:

Lua:
if(vocationId > 0 && g_config.getBool(ConfigManager::ROOK_SYSTEM) &&
			level <= (uint32_t)g_config.getNumber(ConfigManager::ROOK_LEVELTO))
		{
			if(Town* rook = Towns::getInstance()->getTown(g_config.getNumber(ConfigManager::ROOK_TOWN)))
			{
				level = 1;
				soulMax = soul = 100;
				capacity = 400;
				stamina = STAMINA_MAX;
				health = healthMax = 150;
				loginPosition = masterPosition = rook->getPosition();
				experience = magLevel = manaSpent = mana = manaMax = balance = marriage = 0;
				promotionLevel = defaultOutfit.lookAddons = 0; //add mount remove here if you need

				setTown(rook->getID());
				setVocation(0);
				leaveGuild();

				storageMap.clear();
				for(uint32_t i = SKILL_FIRST; i <= SKILL_LAST; ++i)
				{
					skills[i][SKILL_LEVEL] = 10;
					skills[i][SKILL_TRIES] = 0;
				}

				for(uint32_t i = SLOT_FIRST; i < SLOT_LAST; ++i)
				{
					if(inventory[i])
						g_game.internalRemoveItem(NULL, inventory[i]);
				}
			}
		}
		else if(!inventory[SLOT_BACKPACK])

Then, at config.lua add (anywhere):
Lua:
-- Rook System
rookLevelTo = 5	-- level to teleport to rook
rookTownId = 1	-- rook town id	
RookSystem = true -- enable or desable rook system

REP+ if you liked or think it's usefull =]
Tested in TFS 0.4 (just for explanation: I was premium a long time ago)
 
Very good and usefull! But..
bool attackable = isProtected(); -It gave me error..
So I took off and continued, but when the player dies he don't returns to Rookgaard (level 5)...
If I'm not mistaken this: ConfigManager :: ROOK_SYSTEM, which showed error

anyway, it isnt TFS 0.4! But if you can help ;p
 
I tried and it works perfectly! No errors for me. And tt is working on TFS 0.4 for 8.6. I'm using this (I downloaded when I was premium user).

***On the first time I built the code, I had some erros, in the configmanager.h, but I fixed it, and the errors vanished. And yes, it was something about the ROOK_SYTEM.

But any problems post here.
 

Similar threads

Back
Top