First you need to be full to go to sleep. and it takes a long time for the mana to rise!
In bed.cpp ur edit time here!
C++:
void BedItem::regeneratePlayer(Player* player) const
{
const uint32_t sleptTime = time(nullptr) - sleepStart;
Condition* condition = player->getCondition(CONDITION_REGENERATION, CONDITIONID_DEFAULT);
if (condition) {
uint32_t regen;
if (condition->getTicks() != -1) {
regen = std::min<int32_t>((condition->getTicks() / 1000), sleptTime) / 30;
const int32_t newRegenTicks = condition->getTicks() - (regen * 30000);
if (newRegenTicks <= 0) {
player->removeCondition(condition);
} else {
condition->setTicks(newRegenTicks);
}
} else {
regen = sleptTime / 30;
}
player->changeHealth(regen, false);
player->changeMana(regen);
}
const int32_t soulRegen = sleptTime / (60 * 15);
player->changeSoul(soulRegen);
}
I have tested it multiple times. Last with two characters over night. One 8 knight and one 20 MS. Both was full and had premium account.
No mana gain occurs but they lose their "food ticks". I can eat again when I log in but no mana is gained. I do not know how to debug this..
This is my bed.cpp. Not exactly the same as yours? Mine is "/
Condition condition " and yours is "Condition* condition".
Also no "}[/CODE]" after changesoul or in the end. The whole file is 6.46kB.
void BedItem::regeneratePlayer(Player* player) const
{
const uint32_t sleptTime = time(nullptr) - sleepStart;
/
Condition condition = player->getCondition(CONDITION_REGENERATION, CONDITIONID_DEFAULT);
if (condition) {
uint32_t regen;
if (condition->getTicks() != -1) {
regen = std::min<int32_t>((condition->getTicks() / 1000), sleptTime) / 30;
const int32_t newRegenTicks = condition->getTicks() - (regen * 30000);
if (newRegenTicks <= 0) {
player->removeCondition(condition);
} else {
condition->setTicks(newRegenTicks);
}
} else {
regen = sleptTime / 30;
}
player->changeHealth(regen, false);
player->changeMana(regen);
}*/
const int32_t soulRegen = sleptTime / (60 * 15);
player->changeSoul(soulRegen);
}
void BedItem::updateAppearance(const Player* player)
{
const ItemType& it = Item::items[id];
if (it.type == ITEM_TYPE_BED) {
if (player && it.transformToOnUse != 0) {
const ItemType& newType = Item::items[it.transformToOnUse];
if (newType.type == ITEM_TYPE_BED) {
g_game.transformItem(this, it.transformToOnUse);
}
} else if (it.transformToFree != 0) {
const ItemType& newType = Item::items[it.transformToFree];
if (newType.type == ITEM_TYPE_BED) {
g_game.transformItem(this, it.transformToFree);
}
}
}
edit: I do not know how to post code the way you did..