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

C++ "Block Attack" system (shield) in source code

Tadelho

New Member
Joined
Aug 12, 2007
Messages
38
Solutions
1
Reaction score
2
Hi there, I would like to know where do I find the code in source (TFS 0.4.0) that determines a player/creature can block with his shield (defense attribute) only 2 attacks per turn, since I want to make some changes on that. I've looked for it in creatures.cpp and etc but I didn't find it, unfortunately. Anyone knows?

Thank you!
 
Solution
I've found it!

in creature.cpp, the following code controls it:

C++:
if(blockTicks >= 1000)
    {
        blockCount = std::min((uint32_t)blockCount + 1, (uint32_t)2);
        blockTicks = 0;
    }

And then:
C++:
bool hasDefense = false;
        if(blockCount > 0)
        {
            --blockCount;
            hasDefense = true;
        }
Hi there, I would like to know where do I find the code in source (TFS 0.4.0) that determines a player/creature can block with his shield (defense attribute) only 2 attacks per turn, since I want to make some changes on that. I've looked for it in creatures.cpp and etc but I didn't find it, unfortunately. Anyone knows?

Thank you!
It is probably a better idea to handle this in a script than to mess with the sources.
Lua:
onStatsChange(cid, attacker, type, combat, value)
 
It is probably a better idea to handle this in a script than to mess with the sources.
Lua:
onStatsChange(cid, attacker, type, combat, value)

I guess it would be simpler changing sources. I mean, I've done a lot of changes in my source code already, and it probably would make it a lot easier: instead of registering any kind of script to every creature/player, just setting it as "default".

Actually, I can't even wonder how to create a script onStatsChange based to "simulate" a new defense in that round to a "third attacker". Maybe if you got an idea... :)
 
I guess it would be simpler changing sources. I mean, I've done a lot of changes in my source code already, and it probably would make it a lot easier: instead of registering any kind of script to every creature/player, just setting it as "default".

Actually, I can't even wonder how to create a script onStatsChange based to "simulate" a new defense in that round to a "third attacker". Maybe if you got an idea... :)
Well the first thing I would do is search the forums for any script using onStatsChange and proceed from there.
 
I've been searching it in creature.cpp, player.cpp, monsters.cpp, weapon.cpp, combat.cpp but I didn't find any reference to it. :(
If anyone knows, report me, please.
 
I've found it!

in creature.cpp, the following code controls it:

C++:
if(blockTicks >= 1000)
    {
        blockCount = std::min((uint32_t)blockCount + 1, (uint32_t)2);
        blockTicks = 0;
    }

And then:
C++:
bool hasDefense = false;
        if(blockCount > 0)
        {
            --blockCount;
            hasDefense = true;
        }
 
Solution
Back
Top