Erikas Kontenis
Excellent OT User
I wanna to ask about how to make own function similar to created, i realy tried much different ways i expermented a lot. 
I wanna to add for mounts new abbilities such as Attackspeed increase and Maxhealth increase when you use it and on demount it expires. Theres Already excists one abbility. If is mounted you get extra StepSpeed i tried to do something familar as it, but i dont know, i made some changes in mounts.cpp/.h self but its not enough, i know where to edit, but it requires something as g_game.changeAttackSpeed -- G_game new function (however is to change stepSpeed g_game.changeSpeed), i tried to check something in vocations.cpp/.h becouse in vocations.xml is vocation attack speed attribute, however still didint get how to use it for own...
This is a things wich i changed and things where i think need to edit. Mark "//" this is what i added.
I added to mounts.cpp thoose lines.
24-32~ line
89-115 ~ lines
Mounts.h
i compiled it fine without any errors and i gues its ok only might be needed changes in mounts.h becouse for new function or im wrong.
And this is parts where i think needs to be changed in players.cpp and game.cpp propapbly in /.h too i not vert good understand what the point of .h gives its something as registering propapbly...
So this is where needs to be changed somehow
and
Game.cpp
if you have time only, then i please. However give me idea/reply i would be very thankfull for it.
I wanna to add for mounts new abbilities such as Attackspeed increase and Maxhealth increase when you use it and on demount it expires. Theres Already excists one abbility. If is mounted you get extra StepSpeed i tried to do something familar as it, but i dont know, i made some changes in mounts.cpp/.h self but its not enough, i know where to edit, but it requires something as g_game.changeAttackSpeed -- G_game new function (however is to change stepSpeed g_game.changeSpeed), i tried to check something in vocations.cpp/.h becouse in vocations.xml is vocation attack speed attribute, however still didint get how to use it for own...
This is a things wich i changed and things where i think need to edit. Mark "//" this is what i added.
I added to mounts.cpp thoose lines.
24-32~ line
Code:
Mount::Mount(uint8_t _id, uint16_t _clientId, std::string _name, int32_t _speed//, uint32_t _attackSpeed//, int32_t _health_max)
{
id = _id;
clientId = _clientId;
name = _name;
speed = _speed;
//attackSpeed = _attackSpeed;
//health_max = _health_max;
}
Code:
if(xmlStrcmp(p->name, (const xmlChar*)"mount") == 0)
{
int8_t id = 0;
int16_t clientid = 0;
std::string name = "";
int32_t speed = 0;
//uint32_t attackSpeed = 0;
//int32_t health_max = 0;
if(readXMLInteger(p, "id", intValue))
id = intValue;
if(readXMLInteger(p, "clientid", intValue))
clientid = intValue;
if(readXMLString(p, "name", strValue))
name = strValue;
if(readXMLInteger(p, "speed", intValue))
speed = intValue;
//if(readXMLInteger(p, "attackspeed", intValue))
//attackSpeed = intValue;
//if(readXMLInteger(p, "health_max", intValue))
//health_max = intValue;
mounts.push_back(new Mount(id, clientid, name, speed//, attackSpeed, health_max));
Mounts.h
Code:
class Mount
{
public:
Mount(uint8_t _id, uint16_t _clientId, std::string _name, int32_t _speed//, uint32_t _attackSpeed, int32_t _health_max);
~Mount() {}
bool isTamed(Player* player) const;
uint8_t getID() const { return id; }
uint16_t getClientID() const { return clientId; }
std::string getName() const { return name; }
int32_t getSpeed() const { return speed; }
//uint32_t getAttackSpeed() const {return attackSpeed;}
//int32_t getMaxHealth() const { return health_max; }
private:
uint8_t id;
uint16_t clientId;
std::string name;
int32_t speed;
//uint32_t attackSpeed;
//int32_t health_max;
};
And this is parts where i think needs to be changed in players.cpp and game.cpp propapbly in /.h too i not vert good understand what the point of .h gives its something as registering propapbly...
So this is where needs to be changed somehow
Code:
bool Player::toggleMount(bool mount)
{
if(mount)
{
if(isMounted())
return false;
if(_tile->hasFlag(TILESTATE_PROTECTIONZONE))
{
sendCancelMessage(RET_ACTIONNOTPERMITTEDINPROTECTIONZONE);
return false;
}
if(!isPremium())
{
sendCancelMessage(RET_YOUNEEDPREMIUMACCOUNT);
return false;
}
uint8_t currentMountId = getCurrentMount();
if(currentMountId == 0)
{
sendOutfitWindow();
return false;
}
Mount* currentMount = Mounts::getInstance()->getMountByID(currentMountId);
if(!currentMount)
return false;
defaultOutfit.lookMount = currentMount->getClientID();
if(currentMount->getSpeed() != 0)
g_game.changeSpeed(this, currentMount->getSpeed());
//if(currentMount->getAttackSpeed() != 0)
//mount->getAttackSpeed(this, currentMount->getAttackSpeed()); -- i tried to use as this "g_game.changeSpeed(this, currentMount->getAttackSpeed());" it compiled fine but no effect mayby is good idea to add something inside game::changeSpeed
//if(currentMount->getMaxHealth() != 0)
//changeHealth(this, currentMount->getMaxHealth());
g_game.internalCreatureChangeOutfit(this, defaultOutfit);
}
else
{
if(!isMounted())
return false;
dismount();
}
return true;
}
Code:
void Player::dismount()
{
Mount* mount = Mounts::getInstance()->getMountByID(getCurrentMount());
if(mount && mount->getSpeed() > 0)
g_game.changeSpeed(this, -mount->getSpeed());
//if(mount && mount->getAttackSpeed() > 0) -- this is about what i thinked but it fails.
//mount->getAttackSpeed(this, -mount->getAttackSpeed());
//if(mount && mount->getMaxHealth() > 0)
//g_game.addCreatureHealth(this, -mount->getMaxHealth());
defaultOutfit.lookMount = 0;
g_game.internalCreatureChangeOutfit(this, defaultOutfit);
}
Code:
bool Game::playerChangeOutfit(uint32_t playerId, Outfit_t outfit)
{
Player* player = getPlayerByID(playerId);
if(!player || player->isRemoved())
return false;
if(outfit.lookMount != 0)
{
Mount* mount = Mounts::getInstance()->getMountByClientID(outfit.lookMount);
if(!mount || !mount->isTamed(player))
return false;
if(player->isMounted())
{
Mount* prevMount = Mounts::getInstance()->getMountByID(player->getCurrentMount());
if(prevMount)
changeSpeed(player, mount->getSpeed() - prevMount->getSpeed());
//if(prevMount)
//changeSpeed(player, mount->getSpeed() - prevMount->getSpeed());
player->setCurrentMount(mount->getID());
}
else
{
player->setCurrentMount(mount->getID());
outfit.lookMount = 0;
}
}
else if(player->isMounted())
player->dismount();
if(player->canWear(outfit.lookType, outfit.lookAddons) && player->hasRequestedOutfit())
{
player->hasRequestedOutfit(false);
player->defaultOutfit = outfit;
if(player->hasCondition(CONDITION_OUTFIT))
return false;
internalCreatureChangeOutfit(player, outfit);
}
return true;
}