• 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!
  • 2026 staff recruitment is open! Check it out and consider applying!

Block more than two creatures

Akumah

New Member
Joined
May 28, 2009
Messages
2
Reaction score
0
Hello!

I am currently trying out some stuff in the newest TFS version, and started looking for a way to change the max number of creatures that a player is allowed to block without loosing his defense (which is by default 2, at least on Tibia).

I've searched on sources (I'm not an expert, so it probably has to be somewhere there), and spent quite some time searching for it here in otland but didn't find anything about it.

So, my request is: does anybody knows if it is possible to change it (max amount of creatures blocked by a player), and if yes, how to do it?

Thanks!
 
Starting on line 820 and ending on line 877 of creature.cpp might be what your looking for.
Code:
BlockType_t Creature::blockHit(Creature* attacker, CombatType_t combatType, int32_t& damage,
  bool checkDefense /* = false */, bool checkArmor /* = false */, bool /* field  = false */)
{
   BlockType_t blockType = BLOCK_NONE;

   if (isImmune(combatType)) {
     damage = 0;
     blockType = BLOCK_IMMUNITY;
   } else if (checkDefense || checkArmor) {
     bool hasDefense = false;

     if (blockCount > 0) {
       --blockCount;
       hasDefense = true;
     }

     if (checkDefense && hasDefense) {
       int32_t defense = getDefense();
       damage -= uniform_random(defense / 2, defense);
       if (damage <= 0) {
         damage = 0;
         blockType = BLOCK_DEFENSE;
         checkArmor = false;
       }
     }

     if (checkArmor) {
       int32_t armorValue = getArmor();
       if (armorValue > 1) {
         double armorFormula = armorValue * 0.475;
         int32_t armorReduction = static_cast<int32_t>(std::ceil(armorFormula));
         damage -= uniform_random(
           armorReduction,
           armorReduction + static_cast<int32_t>(std::floor(armorFormula))
         );
       } else if (armorValue == 1) {
         --damage;
       }

       if (damage <= 0) {
         damage = 0;
         blockType = BLOCK_ARMOR;
       }
     }

     if (hasDefense && blockType != BLOCK_NONE) {
       onBlockHit();
     }
   }

   if (attacker) {
     attacker->onAttackedCreature(this);
     attacker->onAttackedCreatureBlockHit(blockType);
   }

   onAttacked();
   return blockType;
}
 
Thanks for the info, but I might need some more help;
Analyzing what you quoted, I found that blockCount could be what I was looking for, so I searched a little more for it. Then, I found this (also creature.cpp, lines 187-191):
Code:
    blockTicks += interval;
    if (blockTicks >= 1000) {
        blockCount = std::min<uint32_t>(blockCount + 1, 2);
        blockTicks = 0;
    }
Any idea if I am in the right track, if that 2 means anything related to the block limit or should I search somewhere else?
 
Back
Top