• 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!

infinite condition

czouski

Banned User
Joined
Nov 2, 2024
Messages
166
Solutions
1
Reaction score
64
how can i make an infinite condition where player gets hp and mana every x seconds but it doest not affect food /hunger conditions etc ?
tfs 1.4.2
 
LUA:
local regenCondition = Condition(CONDITION_REGENERATION, CONDITIONID_DEFAULT)
regenCondition:setParameter(CONDITION_PARAM_HEALTHGAIN, 50) -- amount
regenCondition:setParameter(CONDITION_PARAM_HEALTHTICKS, 1000) -- ms
regenCondition:setParameter(CONDITION_PARAM_MANAGAIN, 50)
regenCondition:setParameter(CONDITION_PARAM_MANATICKS, 1000)
regenCondition:setTicks(-1) -- -1 means infinite time
LUA:
player:addCondition(regenCondition) -- put wherever you wanna trigger it
 
LUA:
local regenCondition = Condition(CONDITION_REGENERATION, CONDITIONID_DEFAULT)
regenCondition:setParameter(CONDITION_PARAM_HEALTHGAIN, 50) -- amount
regenCondition:setParameter(CONDITION_PARAM_HEALTHTICKS, 1000) -- ms
regenCondition:setParameter(CONDITION_PARAM_MANAGAIN, 50)
regenCondition:setParameter(CONDITION_PARAM_MANATICKS, 1000)
regenCondition:setTicks(-1) -- -1 means infinite time
LUA:
player:addCondition(regenCondition) -- put wherever you wanna trigger it
if youre hungry it does not work because its condition regeneration.

neverming it works oddly when i tried that before it did not
 
Last edited:
it resets regeneration time (e.g food to -1) aka 0 so its invalid solution sorry :(
I cant believe how useless this game engine is and how limited the developers were inside of their head never thinking this or that could potentially be used in different way. they really went by the book.
 
LUA:
local regenCondition = Condition(CONDITION_REGENERATION)
regenCondition:setParameter(CONDITION_PARAM_HEALTHGAIN, 50) -- amount
regenCondition:setParameter(CONDITION_PARAM_HEALTHTICKS, 1000) -- ms
regenCondition:setParameter(CONDITION_PARAM_MANAGAIN, 50)
regenCondition:setParameter(CONDITION_PARAM_MANATICKS, 1000)
regenCondition:setParameter(CONDITION_PARAM_SUBID, 789)
regenCondition:setParameter(CONDITION_PARAM_TICKS, -1)
 
regenCondition:setParameter(CONDITION_PARAM_SUBID, 789)
Adding subId should make it not overwrite normal regeneration condition.
I cant believe how useless this game engine is and how limited the developers were inside of their head
Your problem should be solved with code above.

They were not limited, they limited features to make engine that replicates RL Tibia and allows you to run 1000+ online server by removing any 'feature' that is not required and increase CPU usage.
TFS 0.3.x and TFS 0.4 were focused on 'evo' OTSes and making any crazy idea 'works', but it made them lag with 500+ online (CPU 80%+). TFS 1.x is/was focused on RL Tibia servers.
 
it resets regeneration time (e.g food to -1) aka 0 so its invalid solution sorry :(
I cant believe how useless this game engine is and how limited the developers were inside of their head never thinking this or that could potentially be used in different way. they really went by the book.
It's not the solution that is invalid, the solution you have in this thread is correct, just seems that you don't know how to use it, which is perfectly fine, nobody started with all the knowledge, just learned it over time. But being that rude won't help you...

login.lua

LUA:
    local regenCondition = Condition(CONDITION_REGENERATION)
    regenCondition:setParameter(CONDITION_PARAM_SUBID, 2789)
    regenCondition:setParameter(CONDITION_PARAM_TICKS, -1)
    regenCondition:setParameter(CONDITION_PARAM_HEALTHGAIN, 1)
    regenCondition:setParameter(CONDITION_PARAM_HEALTHTICKS, 1000)
    regenCondition:setParameter(CONDITION_PARAM_MANAGAIN, 1)
    regenCondition:setParameter(CONDITION_PARAM_MANATICKS, 1000)

    if not player:getCondition(CONDITION_REGENERATION, CONDITIONID_DEFAULT, 2789) then
        player:addCondition(regenCondition)
    end
 
for real though why is there no solid documentations but we refer for any request to this forum it be much easier if everything was explained on the wiki yet nobody is putting in the work. especially half the stuff could be just links instead of actual wiki on the wiki to otland so it be easier to find the tutorials and have peoples feedback comments etc.
maybe even a board on the forum called Documentation and would fill as we go?
the basics are not explained and if they are you get "lua tutorial" nobody needs that anymore we just need solid basics explained and how stuff works to give an edge to the new guys comming in and doing the work ^.^ there is too big of skill gap with it all between newbs and pros and the pros are too busy irl to play with it while the new guys cant work it out.]



ps. it works now but when I added subid 2 days ago It did not.
 
for real though why is there no solid documentations but we refer for any request to this forum it be much easier if everything was explained on the wiki yet nobody is putting in the work. especially half the stuff could be just links instead of actual wiki on the wiki to otland so it be easier to find the tutorials and have peoples feedback comments etc.
maybe even a board on the forum called Documentation and would fill as we go?
the basics are not explained and if they are you get "lua tutorial" nobody needs that anymore we just need solid basics explained and how stuff works to give an edge to the new guys comming in and doing the work ^.^ there is too big of skill gap with it all between newbs and pros and the pros are too busy irl to play with it while the new guys cant work it out.]



ps. it works now but when I added subid 2 days ago It did not.
1730881988284.webp
That button on the right, its the guide. It has all kinds of information and I was working on filling it out more, but apparently people didn't even know it existed while I was working on it. I created a thread about it and everything to try to raise awareness.. I was attempting to build documentation but no one used it, every single day the forum would still have people asking questions that showed the lack of the most basic understanding.
I do agree though, the engine was created with a very limited purpose that has held it back for a long time now.
 
I ment for lua / revscripts and all type stuff not to how to run a linux machine for dumbs this "OTS Guide" barely even explains 10% of the functions inside lua.
1730882152327.webp

1730882181023.webp


also reference to itemEx while we are using target nowadays DEPRACATED
proves my point this game engine could actually bring a lot more people if we invested into teaching people tutorials and generalizing 2d rpg game tag on youtube.
maybe a lot of people would decide to use this instead of rpg maker :) and maybe we would get a lot more games innit
Laugh Smile GIF
 
yeah I was working on the revscript version, but like I said... no one even used it anyways
maybe because its so hard to find. I did not ever seen the top bar of the site other than my account and notifications because it does not stand out in any way its same color as footer and the center div has everything for browsing /searching maybe adding Emojis like ⚙️ beside ot guide would get some magic going remember people are visual monkeys :)
Id do
Whats New Newspaper emoji
Resources A Letter or Paper blank
Members of course human emoji
Github emm Github emoji? custom ico?
Tools Wrench
Ots Guide Gear wheel
Lua guide magnifying glass? (since we do c++ functions via lua so its kind of like magnifying functions :D)
Rules !

it would definately start catching an eye for a user.
 
Well like I said, I started a thread, I told people about it in discord, I did what I could to raise awareness and yet, still didn't matter, no one used it, so I stopped working on it.

I have all my old files for it though, and I plan to update them to create documentation for my server Black Tek. At such time, I could surely remove the extra stuff that Black Tek has that TFS doesn't from some copies, and update the gitbook so you guy could have at least a lot more information, even if its still not 100 percent complete... but its not a high priority of mine at this moment. It's about to be really really soon though, I'm getting ready for my first official release and I would like to have some documentation ready for that
 
maybe because its so hard to find. I did not ever seen the top bar of the site other than my account and notifications because it does not stand out in any way its same color as footer and the center div has everything for browsing /searching maybe adding Emojis like ⚙️ beside ot guide would get some magic going remember people are visual monkeys :)
Id do
Whats New Newspaper emoji
Resources A Letter or Paper blank
Members of course human emoji
Github emm Github emoji? custom ico?
Tools Wrench
Ots Guide Gear wheel
Lua guide magnifying glass? (since we do c++ functions via lua so its kind of like magnifying functions :D)
Rules !

it would definately start catching an eye for a user.
I doubt that the problem is the lack of docu or difficult to find tutorial. Nowadays reading and slowly chasing the goal is just not comfortable, not as much as getting the answer quickly, just like that. People prefer to get their answet quickly, without an effort of reading and understanding and putting more effort into it. Obviously, I'm generalising, does not apply to everyone, but I can suppose it is true with huge part of many communities, not only here.
 
also reference to itemEx while we are using target nowadays DEPRACATED
proves my point this game engine could actually bring a lot more people if we invested into teaching people tutorials and generalizing 2d rpg game tag on youtube.
maybe a lot of people would decide to use this instead of rpg maker :) and maybe we would get a lot more games innit
Laugh Smile GIF
If you bothered to read the comment in the example code, I explicitly explained how there was a change in the variable name to demonstrate that you can name them whatever you like... its not "DEPRACATED".

I also felt the desire to turn an OT engine into something more than an OT engine. I have already started a thread or two on the subject, and have very clearly stated that to be my intent with Black Tek. After first official release, the next version, I will be removing the restrictive tibia specific logic.
 
so question what subId will default conditions be ? I have added some custom code in c++ i am gonna probably already circumverent it via

C++:
if (Player* player = creature->getPlayer()) {


    if (getSubId() <= 200) {
but is there any range ? (i dont want the bonuses to apply to other things like rings etc)
nevermind i should have done my code in player updatecondition instead of inside of conditions! :D

ill leave this here:
C++:
        int32_t getTotalHealthGain() const {
            int32_t totalHealthGain = vocation ? vocation->getHealthGainAmount() : 0;

            // Add charm bonus
            int32_t charmValue = 0;
 //storage representing charm or some skill
            if (getStorageValue(656006, charmValue) && charmValue > 0) {
                totalHealthGain += charmValue;
            }

            // Add fish event bonus
            int32_t fishevent_status = 0;
          //storage set to player on login if the world event i son
            if (getStorageValue(8100026, fishevent_status) && fishevent_status > 0) {
                totalHealthGain += fishevent_status;
            }

            return totalHealthGain;
        }

        int32_t getTotalHealthTicks() const {
            return vocation ? vocation->getHealthGainTicks() * 1000 : 12000;
        }

        int32_t getTotalManaGain() const {
            return vocation ? vocation->getManaGainAmount() : 1;
        }

        int32_t getTotalManaTicks() const {
            return vocation ? vocation->getManaGainTicks() * 1000 : 12000;
        }


C++:
void Player::updateRegeneration() {
    if (!vocation) {
        return;
    }

    Condition* condition = getCondition(CONDITION_REGENERATION, CONDITIONID_DEFAULT);
    if (condition) {
        condition->setParam(CONDITION_PARAM_HEALTHGAIN, getTotalHealthGain());
        condition->setParam(CONDITION_PARAM_HEALTHTICKS, getTotalHealthTicks());
        condition->setParam(CONDITION_PARAM_MANAGAIN, getTotalManaGain());
        condition->setParam(CONDITION_PARAM_MANATICKS, getTotalManaTicks());
    }
}
 
Last edited:
Back
Top