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

C++ What is this code source tfs

gubbo123

New Member
Joined
Aug 15, 2017
Messages
151
Solutions
1
Reaction score
3
Tfs 1.2
I found this on combat.cpp

Inside function

C++:
void MagicField::onStepInField(Creature* creature)



C++:
const ItemType& it = items[getID()];
    if (it.conditionDamage) {
        Condition* conditionCopy = it.conditionDamage->clone();
        uint32_t ownerId = getOwner();
        if (ownerId) {
            bool harmfulField = true;

            if (g_game.getWorldType() == WORLD_TYPE_NO_PVP || getTile()->hasFlag(TILESTATE_NOPVPZONE)) {
                Creature* owner = g_game.getCreatureByID(ownerId);
                if (owner) {
                    if (owner->getPlayer() || (owner->isSummon() && owner->getMaster()->getPlayer())) {
                        harmfulField = false;
                    }
                }
            }

            Player* targetPlayer = creature->getPlayer();
            if (targetPlayer) {
                Player* attackerPlayer = g_game.getPlayerByID(ownerId);
                if (attackerPlayer) {
                    if (Combat::isProtected(attackerPlayer, targetPlayer)) {
                        harmfulField = false;
                    }
                }
            }

            if (!harmfulField || (OTSYS_TIME() - createTime <= 5000) || creature->hasBeenAttacked(ownerId)) {
                conditionCopy->setParam(CONDITION_PARAM_OWNER, ownerId);
            }
        }

        creature->addCondition(conditionCopy);
    }
}

Someone can tell me how harmfulField work?
 
Checks if creature that steps on it is:
  • the one that made that field
  • one of the summons of a creature that made that field
  • player is attacking another player (in PvP mode or such)

If false, field can do damage.
 
In this part for example,


C++:
            if (!harmfulField || (OTSYS_TIME() - createTime <= 5000) || creature->hasBeenAttacked(ownerId)) {
                conditionCopy->setParam(CONDITION_PARAM_OWNER, ownerId);

If the field damage is more than 5 seconds, no have morr owner yes?

For example, how can i put replace this
createTime <= 5000 to all day? Is possible without put there number 999999?
 
If the field damage is more than 5 seconds
This actually made my day.

You can actually remove that statement so the ownership won't be based on time at all
C++:
if (!harmfulField || creature->hasBeenAttacked(ownerId)) {
    conditionCopy->setParam(CONDITION_PARAM_OWNER, ownerId);
 
Back
Top