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

Solved How to set minimum speed for creatures? in sourceCode

whitevo

Feeling good, thats what I do.
Joined
Jan 2, 2015
Messages
3,452
Solutions
1
Reaction score
625
Location
Estonia
I have no clue how to work around this issue, so I believe source edit is required.

Currently I have made it so (in LUA) that if player current speed (conditions from: items, food, spells, etc) makes it go below 50 then the speed will settle on 50.

But in some rare occasions (propably because all these hundreds addEvents what constantly activate on player)
The speed DOES go under 50.. causing the player move from 1 tile to another for a freaking ~3 minutes.

I have practically no knowledge of SourceCode. Therefor I ask here, where and what should be written in sourcecode to make sure CREATURE SPEED CAN NOT BE REDUCED BELOW 50 with conditions (unless the original value of monster or npc is already below 50)

I'm using TFS 1.1.x
If someone knows how to do it and willing to help out, latest TFS release will be edited and used.
 
You can do it via Lua or the database? Not sure.
If you can do it via the database, re-check it each time the players dies.

A simple if statment could aswell also work in an onLogin script, but would in sence require more code.
This also means you need to re-work your "first item" if statment / script to set the first base speed.

Can aswell also be done via the function Evul posted, just add an if statment to check if the value is below 50 if it is then set it to 50.
Code:
if (newBaseSpeed < 50) {
     return;
}
baseSpeed = newBaseSpeed;

Something like that should also work fine.
But seeing as you prefer Lua coding over C++ coding id go with what I wrote first.
 
@WibbenZ

Both of your solutions are wrong.
Speed is not stored in database.
onLogin script to fix speed of a player that is already in game? And what about monsters? Great idea.
 
Last edited:
Well with LUA it doesn't seem to work correctly.
I like the sourceCode edit though. Just wondering is this the only place where this code has to be changed?
Because most of the times there are like 3 different files where you gotta change stuff xD

function where the problem comes up 1 out of few hundred times
Code:
function executeUltimateCondition(targetID, conditionTable)
local target = Creature(targetID)
if not target then return false end
local stack = conditionTable.stack
local condition = conditionTable.condit
local amount = conditionTable.amount
local duration = conditionTable.duration

    if condition == HASTE then
        subID = SUB.haste.s_spell
        param = SPEED
        effect = hasteCondition
    elseif condition == SLOW then
        subID = SUB.slow.s_spell
        param = SPEED
        effect = slowCondition
    else print("missing more conditions IN executeUltimateCondition()") return false
    end

    if stack then
        local stack = 1
    
        for x=1, 20 do
            if target:getCondition(condition, x-1+subID) then
                amount = x*amount
                stack = x+1
            
                target:removeCondition(condition, x+subID)
                break
            end
        end
    
        if condition == HASTE then effect = speedStack[stack]
        elseif condition == SLOW then effect = slowStack[stack]
        end
    end
    if target:getBaseSpeed()+amount < 50 then amount = -target:getBaseSpeed()+50 end

    effect:setParameter(param, amount)
    effect:setParameter(TICKS, duration)
    target:addCondition(effect)
end
 
Last edited:
@WibbenZ

Both of your solutions are wrong.
Speed is not stored in database.
onLogin script to fix speed of a player that is already in game? And what about monsters? Great idea.

Note the question mark I added.
It is posible to change the speed after a player has logged in so im correct there.
Notr that he prefers to do things in Lua atlesst has, thats the reason I responded.


In this case it should only be the creature.cpp file, not at the computet so can't check.
In somr cases (where you add or remove variables) you might have to change these, luascript.cpp, creature/pkayer.cpp and the header files .h.

But in this case just find the last call, add the if statment I posted and you should be fine.
Since we don't change the variables there is no need to modify the header file.
 
You, sir, are a complete retard. Please stop commenting here and on github, you are just wasting space.
 
This is not the solution you're after, but why don't you check the speed on the addEvent o_O?
this function is created with addEvent.

That's why I'm looking other ways to fix it.
Looks like i got some answers.

When I have figured few more things I want to change in sourcecode and its compiled I will let you know how my test goes.
 
What was suggested should work just fine, but maybe try to debug the error instead, try to make your code more reliable!
Good luck.
 
What was suggested should work just fine, but maybe try to debug the error instead, try to make your code more reliable!
Good luck.
What error and in matter of fact I don't know how to debug TFS if it crashes.
That could be super helpful though.
 
You, sir, are a complete retard. Please stop commenting here and on github, you are just wasting space.

Atleast some of us do something?
Luckily you are not wasting that much space since you seem to rarely do anything, but if you wish to continue you can just send me a pm ;)
 
Back
Top