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

Lua Block more hits with a shield

Joined
Feb 16, 2017
Messages
53
Solutions
2
Reaction score
9
Hey, I was wondering how to change that player can block more than 2 hits with a shield. ( TFS 1.3 )
In creature.cpp i found:
Lua:
    blockTicks += interval;
    if (blockTicks >= 1000) {
        blockCount = std::min<uint32_t>(blockCount + 1, 2);
        blockTicks = 0;
    }
Is "(blockCount + 1, 2)" equal to numbers that player can block? I changed that to "(blockCount + 1, 2, 3, 4);" and after that I received many errors on compiling.

Help please <3
 
Solution
Hey, I was wondering how to change that player can block more than 2 hits with a shield. ( TFS 1.3 )
In creature.cpp i found:
Lua:
    blockTicks += interval;
    if (blockTicks >= 1000) {
        blockCount = std::min<uint32_t>(blockCount + 1, 2);
        blockTicks = 0;
    }
Is "(blockCount + 1, 2)" equal to numbers that player can block? I changed that to "(blockCount + 1, 2, 3, 4);" and after that I received many errors on compiling.

Help please <3

The role of 2 here is to set a maximum value limit.
std::min picks the minimum value.
C++:
std::min<uint32_t>(blockCount + 1, 2);

There are 2 parameters passed into std::min function.
First one is blockCount + 1
Second one is 2

When the...
Hey, I was wondering how to change that player can block more than 2 hits with a shield. ( TFS 1.3 )
In creature.cpp i found:
Lua:
    blockTicks += interval;
    if (blockTicks >= 1000) {
        blockCount = std::min<uint32_t>(blockCount + 1, 2);
        blockTicks = 0;
    }
Is "(blockCount + 1, 2)" equal to numbers that player can block? I changed that to "(blockCount + 1, 2, 3, 4);" and after that I received many errors on compiling.

Help please <3

The role of 2 here is to set a maximum value limit.
std::min picks the minimum value.
C++:
std::min<uint32_t>(blockCount + 1, 2);

There are 2 parameters passed into std::min function.
First one is blockCount + 1
Second one is 2

When the first one is greater than the second value, for example, blockCount + 1 = 4 then the larger value will be ignored and 2 used instead.

If you wish to increase the blockCount limit, simply increase nr 2 to a greater limit.
for example if you want to set the max blockCount limit to 5, change 2 to 5

C++:
blockCount = std::min<uint32_t>(blockCount + 1, 5);
 
Solution
About formula
blockCount + 1, 2

1 - is number of 'available new blocks' per second
2 - is limit

Increasing 1 increases number of shield blocks player can do every second.
Increasing 2 let players 'collect more blocks', when they are out of fight.

Warning:
Changing number 1000 in:
Code:
if (blockTicks >= 1000) {
to 500 will not work. You may expect, it will give '+1 block' every 0.5 sec, but this function (onThink) is executed once a second, so algorithm will not notice it.
 
Back
Top