• 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!
  • 2026 staff recruitment is open! Check it out and consider applying!

TFS 1.2 persist conditions doesnt work

Lopaskurwa

Well-Known Member
Joined
Oct 6, 2017
Messages
936
Solutions
2
Reaction score
57
Hello using scrolls that increaes max health by 20% for x period of hours but after death the boost disappears the issue is that for some reason in my server, persist conditions do not remain after death and disappears. Is it known problem in tfs 1.2?
 
Solution
And where do you add that
Your Lua script uses 10k and 20k IDs + boost ID as subId, so I adjusted code to make conditions with subId 10k - 25k not removed on death.
You don't have to edit anything in Lua script.

You have to edit C++ files and recompile server:
1. At end of condition.cpp add:
C++:
bool Condition::isRemovableOnDeath() const
{
    return getSubId() >= 10000 && getSubId() <= 25000;
}
2. In conditon.h under:
C++:
bool isPersistent() const;
add:
C++:
bool isRemovableOnDeath() const;
3. In player.cpp replace in 2 places - it's only in 2 places in that file, so you can "replace all":
C++:
if (condition->isPersistent()) {
with:
C++:
if (condition->isPersistent() &&...
Is it known problem in tfs 1.2
isPersistent makes server save condition in database, when player logouts.
There are codes that remove condition on death on TFS 1.2:

You must add function to conditions that will decide, if given condition should be removed on death. Ex. I added on some OTS, that conditions with subId over 1kk are not removed on death:
C++:
bool Condition::isRemovableOnDeath() const
{
return getSubId() < 1000000;
}
and in 2 parts of code I posted above, replace:
C++:
if (condition->isPersistent()) {
with:
C++:
if (condition->isPersistent() && condition->isRemovableOnDeath()) {
 
isPersistent makes server save condition in database, when player logouts.
There are codes that remove condition on death on TFS 1.2:

You must add function to conditions that will decide, if given condition should be removed on death. Ex. I added on some OTS, that conditions with subId over 1kk are not removed on death:
C++:
bool Condition::isRemovableOnDeath() const
{
return getSubId() < 1000000;
}
and in 2 parts of code I posted above, replace:
C++:
if (condition->isPersistent()) {
with:
C++:
if (condition->isPersistent() && condition->isRemovableOnDeath()) {
And where do you add that
C++:
bool Condition::isRemovableOnDeath() const
{
return getSubId() < 1000000;
}
because right now its like this
LUA:
local healthPercentSubId = 10000
local manaPercentSubId = 20000
for itemId, scroll in pairs(BoostScrolls) do
    if scroll.healthPercent then
        if not scroll.conditions then
            scroll.conditions = {}
        end

        local condition = Condition(CONDITION_ATTRIBUTES)
        condition:setParameter(CONDITION_PARAM_SUBID, healthPercentSubId + itemId)
        condition:setParameter(CONDITION_PARAM_TICKS, scroll.minutes * 60 * 1000)
        condition:setParameter(CONDITION_PARAM_STAT_MAXHITPOINTSPERCENT, 100 + scroll.healthPercent)

        table.insert(scroll.conditions, condition)
    end

    if scroll.manaPercent then
        if not scroll.conditions then
            scroll.conditions = {}
        end

        local condition = Condition(CONDITION_ATTRIBUTES)
        condition:setParameter(CONDITION_PARAM_SUBID, manaPercentSubId + itemId)
        condition:setParameter(CONDITION_PARAM_TICKS, scroll.minutes * 60 * 1000)
        condition:setParameter(CONDITION_PARAM_STAT_MAXMANAPOINTSPERCENT, 100 + scroll.manaPercent)

        table.insert(scroll.conditions, condition)
    end
end
 
And where do you add that
Your Lua script uses 10k and 20k IDs + boost ID as subId, so I adjusted code to make conditions with subId 10k - 25k not removed on death.
You don't have to edit anything in Lua script.

You have to edit C++ files and recompile server:
1. At end of condition.cpp add:
C++:
bool Condition::isRemovableOnDeath() const
{
    return getSubId() >= 10000 && getSubId() <= 25000;
}
2. In conditon.h under:
C++:
bool isPersistent() const;
add:
C++:
bool isRemovableOnDeath() const;
3. In player.cpp replace in 2 places - it's only in 2 places in that file, so you can "replace all":
C++:
if (condition->isPersistent()) {
with:
C++:
if (condition->isPersistent() && condition->isRemovableOnDeath()) {

EDIT:
Of course, it would be better, to add it as condition parameter. Then you could set in Lua, if given condition can be removed on death, but it would require much more changes in C++ files.
If I were you, I would use some AI IDE (Cursor, Warp, CLion - work well, but cost 15-20$; or Github Copilot which is free in Visual Studio) and tell it to add new condition parameter. AI is pretty good as simple code edits.
 
Last edited:
Solution
Your Lua script uses 10k and 20k IDs + boost ID as subId, so I adjusted code to make conditions with subId 10k - 25k not removed on death.
You don't have to edit anything in Lua script.

You have to edit C++ files and recompile server:
1. At end of condition.cpp add:
C++:
bool Condition::isRemovableOnDeath() const
{
    return getSubId() >= 10000 && getSubId() <= 25000;
}
2. In conditon.h under:
C++:
bool isPersistent() const;
add:
C++:
bool isRemovableOnDeath() const;
3. In player.cpp replace in 2 places - it's only in 2 places in that file, so you can "replace all":
C++:
if (condition->isPersistent()) {
with:
C++:
if (condition->isPersistent() && condition->isRemovableOnDeath()) {

EDIT:
Of course, it would be better, to add it as condition parameter. Then you could set in Lua, if given condition can be removed on death, but it would require much more changes in C++ files.
If I were you, I would use some AI IDE (Cursor, Warp, CLion - work well, but cost 15-20$; or Github Copilot which is free in Visual Studio) and tell it to add new condition parameter. AI is pretty good as simple code edits.
Sadly its still removing the condition after death
 
Sadly its still removing the condition after death
It removes because isRemovableOnDeath function returns true when the subId is between 10000-25000, which means those conditions will be removed on death. This is backwards from what you want. So just replace current function with this and should work
C++:
bool Condition::isRemovableOnDeath() const
{
    return !(getSubId() >= 10000 && getSubId() <= 25000);
}
 
It removes because isRemovableOnDeath function returns true when the subId is between 10000-25000, which means those conditions will be removed on death. This is backwards from what you want. So just replace current function with this and should work
C++:
bool Condition::isRemovableOnDeath() const
{
    return !(getSubId() >= 10000 && getSubId() <= 25000);
}
Thanks works finally
 
Uch sorry for bumping back, but this c hange now made my conditions not dissapear after 2 hours passes for example for that buff now they are permanent they are not removed after ticks end.

Edit nevermind it seems like a strange behaviour instead it removes condition but not after 2 hours if you died few times somehow endTime function works strangely it sums up the death time so thats why it doesnt remove condition at exact time it was said to remove, but it removes perfectly after 2 hours if you dont reconnect at all
 
Last edited:
Back
Top