• 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+ Tfs 1.2 help logic map multfloor respawn

jackl90

Member
Joined
Jul 25, 2017
Messages
249
Reaction score
12
Can someone with experience in c++ help me with this logic?
I'm configuring the block respawn system, basically what i need,

player will block respawns 2 floors above and 2 below when they are underground and all levels above if on surface, if the player is on floor 7, he will not block respawn on floor 8.

How do I configure this in this code?

C++:
        if (multifloor) {
            if (centerPos.z > 7) {
                minRangeZ = std::max<int32_t>(centerPos.getZ() - 2, 0);
                maxRangeZ = std::min<int32_t>(centerPos.getZ() + 2, MAP_MAX_LAYERS - 1);
            } else if (centerPos.z == 6) {
                minRangeZ = 0;
                maxRangeZ = 8;
            } else if (centerPos.z == 7) {
                minRangeZ = 0;
                maxRangeZ = 9;
            } else {
                minRangeZ = 0;
                maxRangeZ = 7;
            }
        } else {
            minRangeZ = centerPos.z;
            maxRangeZ = centerPos.z;
        }
 
Code:
if (centerPos.z > 7) {
   //underground
   minRangeZ = centerPos.z - 2;
   maxRangeZ = (centerPos.z + 2 > 15) ? 15 : (centerPos.z + 2);
} else {
  //surface
  minRangeZ = 0;
  maxRangeZ = 7;
}
 
Code:
if (centerPos.z > 7) {
   //underground
   minRangeZ = centerPos.z - 2;
   maxRangeZ = (centerPos.z + 2 > 15) ? 15 : (centerPos.z + 2);
} else {
  //surface
  minRangeZ = 0;
  maxRangeZ = 7;
}
Thanks!! but I tested this code, im surface (floor 7) and im blocking respawn of the (floor 8) lower
 
Thanks!! but I tested this code, im surface (floor 7) and im blocking respawn of the (floor 8) lower
What is that "centerPos.z", is it the player's floor or the monster's? I'm not familiar with the sources and I initially thought it was the player, but in case that's the monster you should use this instead:
Code:
if (centerPos.z > 7) {
   //underground
   minRangeZ = (centerPos.z - 2 < 8) ? 8 : (centerPos.z - 2); //always two floors above, but the highest being 8
   maxRangeZ = (centerPos.z + 2 > 15) ? 15 : (centerPos.z + 2); //always two floors below, but the lowest being 15
} else {
  //surface
  minRangeZ = 0; //always all the surface floors up to the top
  maxRangeZ = (centerPos.z + 2 < 7) ? 7 : (centerPos.z + 2 < 7); //always all the surface floors down to 7, but may also be two more below
}
Standing on the floor 7 you won't block the respawn on 8, but standing on 8 you will block the respawn on 7.

Your original code was also correct, except for this line:
minRangeZ = std::max<int32_t>(centerPos.getZ() - 2, 0 8);
Change 0 to 8, because you don't want to check the floors above 8 (0-7) when the spawn is underground.
 
Last edited:
Back
Top