• 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!
  • New resources must be posted under Resources tab. A discussion thread will be created automatically, you can't open threads manually anymore.

Feature Rook system.

slaw

Software Developer
Joined
Aug 27, 2007
Messages
3,667
Solutions
125
Reaction score
1,114
Location
Germany
GitHub
slawkens
Update: (Last changelog)
* More readable code (format : o!)
* Players from mainland wont be able to send parcels to rookgaard
* Skull is removed before sending player to rookgaard

If you want this new system, you need to remove this old, posted which was there before updating.

player.cpp
After: (Its really not important where)
PHP:
uint32_t Player::getIP() const
{
	if(client)
		return client->getIP();
	return 0;
}
Add:
PHP:
void Player::sendToRook()
{
	vocation_id = 0;

	//Edit stats (level, exp, mana...)
	level = 1;
	health = 150;
	healthMax = 150;
	mana = 0;
	manaMax = 0;
	manaSpent = 0;
	magLevel= 0;
	soul = 0;
	soulMax = 100;
	capacity = 400;
	experience = 0;
	setSkull(SKULL_NONE);
	g_game.updateCreatureSkull(this);

	for(int32_t i = SKILL_FIRST; i <= SKILL_LAST; ++i)
	{
		skills[i][SKILL_LEVEL]= 10;
		skills[i][SKILL_TRIES]= 0;
	}

	//Remove items
	for(int32_t i = SLOT_FIRST; i < SLOT_LAST; ++i)
	{
		if(inventory[i])
			g_game.internalRemoveItem(inventory[i]);
	}

	__internalAddThing(SLOT_HEAD, Item::CreateItem(2461));
	__internalAddThing(SLOT_ARMOR, Item::CreateItem(2467));
	__internalAddThing(SLOT_RIGHT, Item::CreateItem(2382));

	Town* town = Towns::getInstance().getTown(g_config.getNumber(ConfigManager::ROOK_TEMPLE_ID));
	if(town)
	{
		std::cout << "TownId: " << town->getTownID() << "." << std::endl;
		setTown(town->getTownID());
		loginPosition = town->getTemplePosition();
	}
}

After:
PHP:
uint32_t newLevel = level;
Add:
PHP:
uint32_t oldLevel = level;

After:
PHP:
		if(newLevel != level)
		{
Add:
PHP:
			uint32_t levelToRook = g_config.getNumber(ConfigManager::LEVEL_TO_ROOK);
			if((newLevel <= levelToRook) && getVocationId() != 0)
				sendToRook();

Change:
PHP:
sprintf(lvMsg, "You were downgraded from Level %d to Level %d.", level, newLevel);
To:
PHP:
sprintf(lvMsg, "You were downgraded from Level %d to Level %d.", oldLevel, newLevel);

player.h
After:
PHP:
void death();
Add:
PHP:
void sendToRook();

mailbox.cpp
After
PHP:
#include "mailbox.h"
Add:
PHP:
#include "configmanager.h"

After:
PHP:
extern Game g_game;
Add:
PHP:
extern ConfigManager g_config;

Change:
PHP:
if(town)
To:
PHP:
if(town && town->getTownID() != g_config.getNumber(ConfigManager::ROOK_TEMPLE_ID))



configmanager.cpp
Before:
PHP:
	m_isLoaded = true;
Add:
PHP:
	m_confNumber[LEVEL_TO_ROOK] = getGlobalNumber(L, "levelToRook", 5);
	m_confNumber[ROOK_TEMPLE_ID] = getGlobalNumber(L, "rookTempleId", 10);

configmanager.h
PHP:
IPBANISHMENT_LENGTH,
Add:
PHP:
LEVEL_TO_ROOK,
ROOK_TEMPLE_ID,

Now to config.lua:
levelToRook = X
rookTempleId = X

Where, X = your number ;o


If player will die on mainland and he'll have 5 level after dead then he'll be rooked!

Also, player wont be able send parcels to rookgaard.
 
Last edited:
Good code, but "levelToRook" at config.lua won't work.

Change:

Code:
if(newLevel == 5)

to:

Code:
if(newLevel <= levelToRook)

And if the server uses an HIGH-LOOSE exp when dieing and it gets from level 6 to 4, won't the player be rooked? You should improve your code changing his level to 1, exp to 0 and vocation to 0 too.

You could add after newLevel <= levelToRook:

Code:
      	    //Set temple position
            Position logPos = town->getTemplePosition();
	    
            
            //Set NO VOCATION
            vocation_id = 0;
            
            
            //Edit stats (level, exp, mana...)
            level = 1;
            health = 150;
            healthMax = 150;
	    mana = 0;
            manaMax = 0;		
            manaSpent = 0;
	    magLevel= 0;		
    	    soul = 0;
    	    soulMax = 100;		
            capacity = 400;
	    experience = 0;

	    //Put all skills 10
        	for(i = SKILL_FIRST; i <= SKILL_LAST; ++i)
	        {
		    skills[i][SKILL_LEVEL]= 10;
		    skills[i][SKILL_TRIES]= 0;
            }

            //Remove all items from the body
	    	int32_t i;
         	for(i = SLOT_FIRST; i < SLOT_LAST; ++i)
	        {
	      	if(inventory[i])
	       	{
			g_game.internalRemoveItem(inventory[i]);
		    }
	        }

	    //Change masterpos e loginposition
	    if(town){
                loginPosition = logPos;
                masterPos = logPos;
            }

Using that, your code will really ROOK the player.

Yours,
Rafael Hamdan;
 
Last edited:
Well, where is the check if the player has other vocation than 0?
I suppose it will set level of players who are on rook tho when they die form 6 to 5.
 
You must put something to add newbie equipments, or to RESET storageID 30001 (the first login ST)

Thanks
 
Last edited:
u must make it for voc diffrent than 0 because when player with level 6 die on rook and he will be downgraded to 5 system will make him lvl 1 :D
 
Ok, fixed. Added also 3 items on start (leather: helmet, armor + club).
 
Code:
12:02 You were downgraded from Level 1 to Level 5.
12:02 You are dead.

Besides this, everything is ok :)

Edit:

Change:
Code:
&& getVocation() != 0)
for:
Code:
&& vocation_id != 0)

Hey... I'm not getting the message of "You were downgraded..." anymore since I put this thing of get vocation. Here is the part of the code:

Code:
			uint32_t levelToRook = g_config.getNumber(ConfigManager::LEVEL_TO_ROOK);
			if((newLevel <= levelToRook) && vocation_id != 0)
			{
				//Welcome rook ;)
				vocation_id = 0;

				//Edit stats (level, exp, mana...)
				level = 1;
				health = 150;
				healthMax = 150;
				mana = 0;
				manaMax = 0;
				manaSpent = 0;
				magLevel= 0;
				soul = 100;
				soulMax = 100;
				capacity = 420;
				experience = 0;

				for(int32_t i = SKILL_FIRST; i <= SKILL_LAST; ++i)
				{
					skills[i][SKILL_LEVEL]= 10;
					skills[i][SKILL_TRIES]= 0;
				}

				//Remove items
				for(int32_t i = SLOT_FIRST; i < SLOT_LAST; ++i)
				{
					if(inventory[i])
						g_game.internalRemoveItem(inventory[i]);
				}
					__internalAddThing(SLOT_ARMOR, Item::CreateItem(2467));
					__internalAddThing(SLOT_LEFT, Item::CreateItem(2448));
					__internalAddThing(SLOT_RIGHT, Item::CreateItem(2512));
					__internalAddThing(SLOT_BACKPACK, Item::CreateItem(1987));
					__internalAddThing(SLOT_AMMO, Item::CreateItem(2050));

				Town* town = Towns::getInstance().getTown(g_config.getNumber(ConfigManager::ROOK_TEMPLE_ID));
				if(town)
				{
					setTown(town->getTownID());
					loginPosition = town->getTemplePosition();
				}
			char lvMsg[75];
			sprintf(lvMsg, "You were downgraded from Level %d to Level %d.", level, newLevel);
			sendTextMessage(MSG_EVENT_ADVANCE, lvMsg);
		}
 
Last edited:
Ok, now it's working, but the "Vocation != 0" doesn't. As I said, you must change:
This:
Code:
&& getVocation() != 0)
for this:
Code:
&& vocation_id != 0)
=P
 
Noo : D

vocation_id == getVocationId()

Fixed. :)
 
Last edited:
Hi,
I have lastest TFS Trunk is there allready an Rooksystem?
Or can I add this System to the Server?

Greets
 
You can add this system to the server.
TFS doesn't have it.
 
Last edited:
I think you should enable this in config.lua also:
Code:
				level = 1;
				health = 150;
				healthMax = 150;
				mana = 0;
				manaMax = 0;
				manaSpent = 0;
				magLevel= 0;
				soul = 100;
				soulMax = 100;
				capacity = 420;
				experience = 0;

but nice and usefull code :)
 
doesnt looks good.... maybe a event "onDie" would be better for this

Code:
local LEVELTOBEROOKED = 5
local rook = {x = 100, y = 100, z = 7, stackpos=253}

function onDie(cid, corpse)
	if(isPlayer(cid) == TRUE) then
		if(getPlayerLevel(cid) <= LEVELTOBEROOKED) then
			doPlayerSetMasterPos(cid, rook)
		end
	end
end
 
Last edited:
Ponei, as I said before, your script is not complete, actually it just changes the temple of the player, and everybody knows that when we are rooked, we get back to level 1, exp 0, all skills 10, ml 0 and all of our items in corpse are lost.

And I think it's not possible to change ALL OF THIS using scripts (unless you create some LuaFunctions).

@master-m
Yep.. it would be great, and this is not that hard to do.

Yours,
Rafael Hamdan;
 
Last edited:
Ponei, as I said before, your script is not complete, actually it just changes the temple of the player, and everybody knows that when we are rooked, we get back to level 1, exp 0, all skills 10, ml 0 and all of our items in corpse are lost.

And I think it's not possible to change ALL OF THIS using scripts (unless you create some LuaFunctions).

@master-m
Yep.. it would be great, and this is not that hard to do.

Yours,
Rafael Hamdan;

The script is not complete this is true but its a example to show possibilities to do this system with scripts. There are alot of ways to complete this script but i wont do all the work. Now just do a command lua "resetPlayer(cid)" to complete.
 
Back
Top