• 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++ help monster level

jel

Member
Joined
Mar 22, 2014
Messages
302
Reaction score
12
Does not have this table in otx / tfs 1.3.
Does anyone help where to put it?

no have table void ProtocolGame::AddCreature(NetworkMessage& msg, const Creature* creature, bool known, uint32_t remove) on otx 1.3

capture-20190123-092107.pngcapture-20190123-092147.png
 
Replace the function with this for TFS 1.3
C++:
////////////// Add common messages
void ProtocolGame::AddCreature(NetworkMessage& msg, const Creature* creature, bool known, uint32_t remove)
{
    CreatureType_t creatureType = creature->getType();

    const Player* otherPlayer = creature->getPlayer();

    if (known) {
        msg.add<uint16_t>(0x62);
        msg.add<uint32_t>(creature->getID());
    } else {
        msg.add<uint16_t>(0x61);
        msg.add<uint32_t>(remove);
        msg.add<uint32_t>(creature->getID());
        msg.addByte(creatureType);

        const Monster* monster = creature->getMonster();
        if (monster && monster->getLevel() > 0) {
            uint32_t sLevel = monster->getLevel();
            if (monster->isSummon()) {
                sLevel = monster->getMaster()->getLevel();
            }
            msg.addString(monster->getName() + " [" + g_config.getString(ConfigManager::MONSTERLEVEL_PREFIX) + " " + std::to_string(sLevel) + "]");
        } else {
            msg.addString(creature->getName());
        }
    }

    if (creature->isHealthHidden()) {
        msg.addByte(0x00);
    } else {
        msg.addByte(std::ceil((static_cast<double>(creature->getHealth()) / std::max<int32_t>(creature->getMaxHealth(), 1)) * 100));
    }

    msg.addByte(creature->getDirection());

    if (!creature->isInGhostMode() && !creature->isInvisible()) {
        AddOutfit(msg, creature->getCurrentOutfit());
    } else {
        static Outfit_t outfit;
        AddOutfit(msg, outfit);
    }

    LightInfo lightInfo = creature->getCreatureLight();
    msg.addByte(player->isAccessPlayer() ? 0xFF : lightInfo.level);
    msg.addByte(lightInfo.color);

    msg.add<uint16_t>(creature->getStepSpeed() / 2);

    msg.addByte(player->getSkullClient(creature));
    msg.addByte(player->getPartyShield(otherPlayer));

    if (!known) {
        msg.addByte(player->getGuildEmblem(otherPlayer));
    }

    if (creatureType == CREATURETYPE_MONSTER) {
        const Creature* master = creature->getMaster();
        if (master) {
            const Player* masterPlayer = master->getPlayer();
            if (masterPlayer) {
                if (masterPlayer == player) {
                    creatureType = CREATURETYPE_SUMMON_OWN;
                } else {
                    creatureType = CREATURETYPE_SUMMON_OTHERS;
                }
            }
        }
    }

    msg.addByte(creatureType); // Type (for summons)
    msg.addByte(creature->getSpeechBubble());
    msg.addByte(0xFF); // MARK_UNMARKED

    if (otherPlayer) {
        msg.add<uint16_t>(otherPlayer->getHelpers());
    } else {
        msg.add<uint16_t>(0x00);
    }

    msg.addByte(player->canWalkthroughEx(creature) ? 0x00 : 0x01);
}

For the latest otx replace that function with this
C++:
void ProtocolGameBase::AddCreature(NetworkMessage& msg, const Creature* creature, bool known, uint32_t remove)
{
    CreatureType_t creatureType = creature->getType();

    const Player* otherPlayer = creature->getPlayer();

    if (known) {
        msg.add<uint16_t>(0x62);
        msg.add<uint32_t>(creature->getID());
    } else {
        msg.add<uint16_t>(0x61);
        msg.add<uint32_t>(remove);
        msg.add<uint32_t>(creature->getID());
        msg.addByte(creatureType);

        if (player->getProtocolVersion() >= 1120) {
            if (creatureType == CREATURETYPE_SUMMONPLAYER) {
                const Creature* master = creature->getMaster();
                if (master) {
                    msg.add<uint32_t>(master->getID());
                }
            }
        }

        const Monster* monster = creature->getMonster();
        if (monster && monster->getLevel() > 0) {
            uint32_t sLevel = monster->getLevel();
            if (monster->isSummon()) {
                sLevel = monster->getMaster()->getLevel();
            }
            msg.addString(monster->getName() + " [" + g_config.getString(ConfigManager::MONSTERLEVEL_PREFIX) + " " + std::to_string(sLevel) + "]");
        } else {
            msg.addString(creature->getName());
        }
    }

    if (creature->isHealthHidden()) {
        msg.addByte(0x00);
    } else {
        msg.addByte(std::ceil((static_cast<double>(creature->getHealth()) / std::max<int32_t>(creature->getMaxHealth(), 1)) * 100));
    }

    msg.addByte(creature->getDirection());

    if (!creature->isInGhostMode() && !creature->isInvisible()) {
        AddOutfit(msg, creature->getCurrentOutfit());
    } else {
        static Outfit_t outfit;
        AddOutfit(msg, outfit);
    }

    LightInfo lightInfo = creature->getCreatureLight();
    msg.addByte(player->isAccessPlayer() ? 0xFF : lightInfo.level);
    msg.addByte(lightInfo.color);

    msg.add<uint16_t>(creature->getStepSpeed() / 2);

    msg.addByte(player->getSkullClient(creature));
    msg.addByte(player->getPartyShield(otherPlayer));

    if (!known) {
        msg.addByte(player->getGuildEmblem(otherPlayer));
    }

    if (player->getProtocolVersion() >= 1120) {
        if (creatureType == CREATURETYPE_MONSTER) {
            const Creature* master = creature->getMaster();
            if (master) {
                const Player* masterPlayer = master->getPlayer();
                if (masterPlayer) {
                    creatureType = CREATURETYPE_SUMMONPLAYER;
                }
            }
        }
    }

    msg.addByte(creatureType); // Type (for summons)

    if (player->getProtocolVersion() >= 1120) {
        if (creatureType == CREATURETYPE_SUMMONPLAYER) {
            const Creature* master = creature->getMaster();
            if (master) {
                msg.add<uint32_t>(master->getID());
            }
        }
    }

    msg.addByte(creature->getSpeechBubble());
    msg.addByte(0xFF); // MARK_UNMARKED
    if (version >= 1110) {
        msg.addByte(0x00); // ??
    }

    if (otherPlayer) {
        msg.add<uint16_t>(otherPlayer->getHelpers());
    } else {
        msg.add<uint16_t>(0x00);
    }

    msg.addByte(player->canWalkthroughEx(creature) ? 0x00 : 0x01);
}
 
Replace the function with this for TFS 1.3
C++:
////////////// Add common messages
void ProtocolGame::AddCreature(NetworkMessage& msg, const Creature* creature, bool known, uint32_t remove)
{
    CreatureType_t creatureType = creature->getType();

    const Player* otherPlayer = creature->getPlayer();

    if (known) {
        msg.add<uint16_t>(0x62);
        msg.add<uint32_t>(creature->getID());
    } else {
        msg.add<uint16_t>(0x61);
        msg.add<uint32_t>(remove);
        msg.add<uint32_t>(creature->getID());
        msg.addByte(creatureType);

        const Monster* monster = creature->getMonster();
        if (monster && monster->getLevel() > 0) {
            uint32_t sLevel = monster->getLevel();
            if (monster->isSummon()) {
                sLevel = monster->getMaster()->getLevel();
            }
            msg.addString(monster->getName() + " [" + g_config.getString(ConfigManager::MONSTERLEVEL_PREFIX) + " " + std::to_string(sLevel) + "]");
        } else {
            msg.addString(creature->getName());
        }
    }

    if (creature->isHealthHidden()) {
        msg.addByte(0x00);
    } else {
        msg.addByte(std::ceil((static_cast<double>(creature->getHealth()) / std::max<int32_t>(creature->getMaxHealth(), 1)) * 100));
    }

    msg.addByte(creature->getDirection());

    if (!creature->isInGhostMode() && !creature->isInvisible()) {
        AddOutfit(msg, creature->getCurrentOutfit());
    } else {
        static Outfit_t outfit;
        AddOutfit(msg, outfit);
    }

    LightInfo lightInfo = creature->getCreatureLight();
    msg.addByte(player->isAccessPlayer() ? 0xFF : lightInfo.level);
    msg.addByte(lightInfo.color);

    msg.add<uint16_t>(creature->getStepSpeed() / 2);

    msg.addByte(player->getSkullClient(creature));
    msg.addByte(player->getPartyShield(otherPlayer));

    if (!known) {
        msg.addByte(player->getGuildEmblem(otherPlayer));
    }

    if (creatureType == CREATURETYPE_MONSTER) {
        const Creature* master = creature->getMaster();
        if (master) {
            const Player* masterPlayer = master->getPlayer();
            if (masterPlayer) {
                if (masterPlayer == player) {
                    creatureType = CREATURETYPE_SUMMON_OWN;
                } else {
                    creatureType = CREATURETYPE_SUMMON_OTHERS;
                }
            }
        }
    }

    msg.addByte(creatureType); // Type (for summons)
    msg.addByte(creature->getSpeechBubble());
    msg.addByte(0xFF); // MARK_UNMARKED

    if (otherPlayer) {
        msg.add<uint16_t>(otherPlayer->getHelpers());
    } else {
        msg.add<uint16_t>(0x00);
    }

    msg.addByte(player->canWalkthroughEx(creature) ? 0x00 : 0x01);
}

For the latest otx replace that function with this
C++:
void ProtocolGameBase::AddCreature(NetworkMessage& msg, const Creature* creature, bool known, uint32_t remove)
{
    CreatureType_t creatureType = creature->getType();

    const Player* otherPlayer = creature->getPlayer();

    if (known) {
        msg.add<uint16_t>(0x62);
        msg.add<uint32_t>(creature->getID());
    } else {
        msg.add<uint16_t>(0x61);
        msg.add<uint32_t>(remove);
        msg.add<uint32_t>(creature->getID());
        msg.addByte(creatureType);

        if (player->getProtocolVersion() >= 1120) {
            if (creatureType == CREATURETYPE_SUMMONPLAYER) {
                const Creature* master = creature->getMaster();
                if (master) {
                    msg.add<uint32_t>(master->getID());
                }
            }
        }

        const Monster* monster = creature->getMonster();
        if (monster && monster->getLevel() > 0) {
            uint32_t sLevel = monster->getLevel();
            if (monster->isSummon()) {
                sLevel = monster->getMaster()->getLevel();
            }
            msg.addString(monster->getName() + " [" + g_config.getString(ConfigManager::MONSTERLEVEL_PREFIX) + " " + std::to_string(sLevel) + "]");
        } else {
            msg.addString(creature->getName());
        }
    }

    if (creature->isHealthHidden()) {
        msg.addByte(0x00);
    } else {
        msg.addByte(std::ceil((static_cast<double>(creature->getHealth()) / std::max<int32_t>(creature->getMaxHealth(), 1)) * 100));
    }

    msg.addByte(creature->getDirection());

    if (!creature->isInGhostMode() && !creature->isInvisible()) {
        AddOutfit(msg, creature->getCurrentOutfit());
    } else {
        static Outfit_t outfit;
        AddOutfit(msg, outfit);
    }

    LightInfo lightInfo = creature->getCreatureLight();
    msg.addByte(player->isAccessPlayer() ? 0xFF : lightInfo.level);
    msg.addByte(lightInfo.color);

    msg.add<uint16_t>(creature->getStepSpeed() / 2);

    msg.addByte(player->getSkullClient(creature));
    msg.addByte(player->getPartyShield(otherPlayer));

    if (!known) {
        msg.addByte(player->getGuildEmblem(otherPlayer));
    }

    if (player->getProtocolVersion() >= 1120) {
        if (creatureType == CREATURETYPE_MONSTER) {
            const Creature* master = creature->getMaster();
            if (master) {
                const Player* masterPlayer = master->getPlayer();
                if (masterPlayer) {
                    creatureType = CREATURETYPE_SUMMONPLAYER;
                }
            }
        }
    }

    msg.addByte(creatureType); // Type (for summons)

    if (player->getProtocolVersion() >= 1120) {
        if (creatureType == CREATURETYPE_SUMMONPLAYER) {
            const Creature* master = creature->getMaster();
            if (master) {
                msg.add<uint32_t>(master->getID());
            }
        }
    }

    msg.addByte(creature->getSpeechBubble());
    msg.addByte(0xFF); // MARK_UNMARKED
    if (version >= 1110) {
        msg.addByte(0x00); // ??
    }

    if (otherPlayer) {
        msg.add<uint16_t>(otherPlayer->getHelpers());
    } else {
        msg.add<uint16_t>(0x00);
    }

    msg.addByte(player->canWalkthroughEx(creature) ? 0x00 : 0x01);
}
do the editing for me?
 

Attachments

Back
Top