• 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!

[TFS] 2008-02-01 baseSpeed in vocations.cpp for SQL users too

Lejjo

New Member
Joined
Sep 21, 2007
Messages
78
Reaction score
1
First of all I want to say I have seen this codes in some places but not on this forum (OTServ Codes), so thats why I add it here. I didn't search for this on the forums and adding it here just to get credits, I don't care of it. I'm just here to help perople.

What is this code?
I think you already know what this code does but I will tell for those who doesn't.
You can choose the base speed insice vocations.xml, and this will enable you to have different base speed on different vocations.
Note that you have to change in your database too, so I hope you know a bit of SQL before adding this.

Start of the code:
iologindata.cpp

Add...
Code:
	player->updateBaseSpeed();

...above
Code:
	player->updateInventoryWeigth();



Add...
Code:
	query << "`speed` = " << player->getBaseSpeed() << ", ";

...above
Code:
	query << "`cap` = " << player->getCapacity() << ", ";


player.h

Change...
Code:
baseSpeed = 220 + (2* (level - 1));

...to
Code:
baseSpeed = vocation->getBaseSpeed() + (2* (level - 1));


vocation.cpp

Add...
Code:
					if(readXMLInteger(p, "basespeed", intVal)){
						voc->baseSpeed = intVal;
					}

...under
Code:
					if(readXMLInteger(p, "fromvoc", intVal)){
						voc->fromVocation = intVal;
					}



Add...
Code:
	baseSpeed = 220;

...under
Code:
	fromVocation = 0;


vocation.h

Add...
Code:
		uint32_t getBaseSpeed() const {return baseSpeed;};

...under
Code:
		uint32_t getFromVocation() const {return fromVocation;}



Add...
Code:
		uint32_t baseSpeed;

...under
Code:
		uint32_t attackSpeed;
End of the code:

Rebuild all and now you can add:
Don't mind my vocation, its my custom vocation, concentrate on the red parts.
Code:
	<vocation id="125" name="Lycanthropy (Braindeath)" description="a lycanthropy transformed into a braindeath" gaincap="10" gainhp="5" gainmana="30" gainhpticks="5" gainhpamount="15" gainmanaticks="2" gainmanaamount="15" manamultiplier="2.1" attackspeed="1800" soulmax="200" gainsoulticks="6000" fromvoc="12" [COLOR="Red"]basespeed="220"[/COLOR] physicalDamage="130" energyDamage="80" fireDamage="90" poisonDamage="90" drownDamage="110">

Explanation
220 is the normal speed in real tibia. You can change this to whatever, but as soon as you put something over 900 it will be 900.

Please leave a comment :)
And if there is a better way to do this, please tell me then. Still learning :)

Yours,
Kadj
 
Last edited:
query << "`speed` = " << player->getBaseSpeed() << ", ";

What's the point of saving the speed if you're not loading it? It's calculated at login. Other than that it looks alright.
 
query << "`speed` = " << player->getBaseSpeed() << ", ";

What's the point of saving the speed if you're not loading it? It's calculated at login. Other than that it looks alright.

Oh okey. I don't know. I guess I just looked up how cap is being done and just made another line. I also added a new row in the SQL database. Guess if its not needed then nvm :)

I will remove it.
 
Hey guys. This is really great script I have added it to my server. But... could you guys post sql table for that? I tried but I can't make it :(

@Edit
Nvm. I needed that becaouse I had an error while using "/save", i have added new atribute to table "players" and it works now ^^

@Gesior.pl
Nvm, when i added new atribute it works and now i can define players' speed by mysql database :)
 
Last edited:
Hey guys. This is really great script I have added it to my server. But... could you guys post sql table for that? I tried but I can't make it :(

@Edit
Nvm. I needed that becaouse I had an error while using "/save", i have added new atribute to table "players" and it works now ^^

Just don't add:
Code:
query << "`speed` = " << player->getBaseSpeed() << ", ";
to your "iologindata.cpp" :>
 
Back
Top