• 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 Mounts with attackSpeed

manerinhu

I'm very very MaNeRiNhU
Joined
Jan 14, 2008
Messages
79
Reaction score
1
Location
Behind you!
Hello guys,

I saw a code like this some time ago in this section, but it didn't worked here, so I get his idea and developed my own code.
It adds a new field in "mounts.xml" that's called "attackspeed" which one reduces the delay of attacks.
How it works: If I set attackspeed="1000" to Racing Bird mount, when mounted I will give a hit on monsters each 2000-1000 ms, so it'll be 2x faster, but when not using mounts, it will attack with a 2000 ms delay.

Now, the code:

In mounts.cpp, find:
Code:
int32_t speed = 0;
	if(readXMLInteger(p, "speed", intValue))
		speed = intValue;

Add 2 lines below:
Code:
	int32_t attackSpeed = 0;
	if(readXMLInteger(p, "attackspeed", intValue))
		attackSpeed = intValue;

find:
Code:
Mount* mount = new Mount(name, mountId, clientId,
	speed, premium, storageId, storageValue);

change for:
Code:
Mount* mount = new Mount(name, mountId, clientId,
	speed, attackSpeed, premium, storageId, storageValue);

Now in mounts.h, find:
Code:
Mount(std::string _name, uint16_t _id, uint16_t _clientId, int32_t _speed,
			bool _premium, std::string _storageId, std::string _storageValue)

change for:
Code:
Mount(std::string _name, uint16_t _id, uint16_t _clientId, int32_t _speed, int32_t _attackSpeed,
			bool _premium, std::string _storageId, std::string _storageValue)

find:
Code:
id = _id;

add below:
Code:
attackSpeed = _attackSpeed;

find:
Code:
uint32_t getSpeed() const {return speed;}

add below:
Code:
uint32_t getAttackSpeed() const {return attackSpeed;}

find:
Code:
int32_t speed;

change for:
Code:
int32_t speed, attackSpeed;

Now in player.cpp, find:
Code:
uint32_t Player::getAttackSpeed()

change the whole function for this one:
Code:
uint32_t Player::getAttackSpeed() const
{
	Mount* mount = Mounts::getInstance()->getMountByCid(currentOutfit.lookMount);
	if(!mounted){
	return ((weapon && weapon->getAttackSpeed() != 0) ? weapon->getAttackSpeed() : (vocation->getAttackSpeed() / std::max((size_t)1, getWeapons().size())));
} else if(mount->getAttackSpeed() > 0){
	return ((weapon && weapon->getAttackSpeed() != 0) ? weapon->getAttackSpeed() : (vocation->getAttackSpeed() - mount->getAttackSpeed() / std::max((size_t)1, getWeapons().size())));
	}
else {
	return ((weapon && weapon->getAttackSpeed() != 0) ? weapon->getAttackSpeed() : (vocation->getAttackSpeed() / std::max((size_t)1, getWeapons().size())));
}
}

Now you are done, I guess.

This also can be used for making other attributes for mounts, like add critical chance or something like.
 
instead of just asking if it works and waiting for a reply, why don't you try it to see if it works and answer your own question within the time frame someone might answer?
 
instead of just asking if it works and waiting for a reply, why don't you try it to see if it works and answer your own question within the time frame someone might answer?
It would not work, because it's completely different mounts.cpp on tfs 1.2+ and mounts.cpp posted here.
I was referring to if one day you could update your code for new versions.
 
Back
Top