zezin009
Active Member
- Joined
- May 30, 2019
- Messages
- 52
- Reaction score
- 25
Well, since I didn't saw anything like this, I'll register this idea then.
Hello everyone, this one is to able any player sleep in any bed, anywhere (for TSF 0.3.6). You'll need change your source files in beds.cpp.
The commentary part is the original sentence. The first change is for 'canUse':
Then, the second change is for 'sleep', (you may notice that I only commented the first two lines):
Third part is for 'wake up' (commented only, again):
And finally, if you want to speed up the regeneration time, it is possible to do it in 'regeneratePlayer':
But this part you can change however you want it, notice that I left the soul regeneration untouched, but is possible to change it! That's it, I hope you like it!
Please, rep+
Hello everyone, this one is to able any player sleep in any bed, anywhere (for TSF 0.3.6). You'll need change your source files in beds.cpp.
The commentary part is the original sentence. The first change is for 'canUse':
C++:
bool BedItem::canUse(Player* player)
{
if(!house || !player || player->isRemoved() || (!player->isPremium() && g_config.getBool(
ConfigManager::BED_REQUIRE_PREMIUM)) || player->hasCondition(CONDITION_INFIGHT))
return isBed(); //return false
Then, the second change is for 'sleep', (you may notice that I only commented the first two lines):
C++:
void BedItem::sleep(Player* player)
{
//if(!house || !player || player->isRemoved())
// return;
Third part is for 'wake up' (commented only, again):
C++:
void BedItem::wakeUp()
{
//if(!house)
// return;
And finally, if you want to speed up the regeneration time, it is possible to do it in 'regeneratePlayer':
C++:
void BedItem::regeneratePlayer(Player* player) const
{
const int32_t* sleepStart = getIntegerAttribute("sleepstart");
int32_t sleptTime = (int32_t)time(NULL) - (sleepStart ? *sleepStart : 0);
if(Condition* condition = player->getCondition(CONDITION_REGENERATION, CONDITIONID_DEFAULT))
{
int32_t amount = sleptTime; // / 30;
if(condition->getTicks() != -1)
{
amount = std::min((condition->getTicks() / 1000), sleptTime); // / 30;
int32_t tmp = condition->getTicks() - (amount * 30000);
if(tmp <= 0)
player->removeCondition(condition);
else
condition->setTicks(tmp);
}
player->changeHealth(amount);
player->changeMana(amount);
}
player->changeSoul((int32_t)std::max((float)0, (float)sleptTime / (60 * 15)));
}
But this part you can change however you want it, notice that I left the soul regeneration untouched, but is possible to change it! That's it, I hope you like it!
Please, rep+