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

TFS 1.X+ Changing permanently character speed

Togu

Advanced OT User
Joined
Jun 22, 2018
Messages
308
Solutions
1
Reaction score
178
Location
Brazil
How can I change player speed permanently? I'm using a skill system by points, the "Endurance" (that raises the capacity) is working, but I don't know how to make the "Dexterity" (that changes player speed) works. I think I'm not using the correct function or don't know how to use it.

Code:
[4] = {'Dexterity', -- + Speed

           function(player)
               return player:getSkillLevel(SKILL_SWORD) end,

           function(player)
               local gain = gainVoc[player:getBaseVocId()].speed player:sendChangeSpeed(self, player:getStepSpeed() + gain)
               return gain end,
           1},

[5] = {'Endurance', -- + Capacity

           function(player)
               return player:getSkillLevel(SKILL_AXE) end,

           function(player)
               local gain = gainVoc[player:getBaseVocId()].cap player:setCapacity(player:getCapacity() + (gain * 100))
               return gain end,
           1}
 
I think the method is called player:changeSpeed and it does not permanently apply this change to the player's speed.
Consequently, you have to remember how much "dexterity" the player has (or the amount of extra speed) and apply the speed change again in an onLogin creature script.
 
Thanks for the fast feedback, ill try it here.

Edit: no matter what I do, I always receive this error:
Code:
Lua Script Error: [CreatureScript Interface]
data/creaturescripts/scripts/skillpoints.lua:onModalWindow
data/lib/skillpoints.lua:58: attempt to call method 'getStepSpeed' (a nil value)
stack traceback:
        [C]: in function 'getStepSpeed'
        data/lib/skillpoints.lua:58: in function <data/lib/skillpoints.lua:57>
        data/lib/skillpoints.lua:248: in function 'skillWindowChoice'
        data/creaturescripts/scripts/skillpoints.lua:2: in function <data/creaturescripts/scripts/skillpoints.lua:1>

In player.h there is:
Code:
int32_t getStepSpeed() const override {
           return std::max<int32_t>(PLAYER_MIN_SPEED, std::min<int32_t>(PLAYER_MAX_SPEED, getSpeed()));
}

void updateBaseSpeed() {
           if (!hasFlag(PlayerFlag_SetMaxSpeed)) {
               baseSpeed = vocation->getBaseSpeed() + (2 * (level - 1));
           } else {
               baseSpeed = PLAYER_MAX_SPEED;
           }
}

void sendChangeSpeed(const Creature* creature, uint32_t newSpeed) const {
           if (client) {
               client->sendChangeSpeed(creature, newSpeed);
           }
}
 
Back
Top