• 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++ hadCondition dont read when condition have subid

poe6man3

Member
Joined
Aug 6, 2020
Messages
52
Reaction score
9
I added new condition which is called WALKLOCK

I want to make it stop moving so i added inside game.cpp inside ReturnValue Game::internalMoveCreature

C++:
if (creature->hasCondition(CONDITION_WALKLOCK)) {
        return RETURNVALUE_NOTPOSSIBLE;
}

And its working when i dont put subid on it but right after i put subid on it its stops working i printed if i have the condition with subid in lua and its looking good but inside src the if is not going through

How i added the new condition

enums.h
C++:
CONDITION_WALKLOCK = 1 << 28,

luascript.cpp
C++:
registerEnum(CONDITION_WALKLOCK)

condition.cpp
C++:
case CONDITION_WALKLOCK:

and then the game.cpp check

Can somebody tell me what am i doing wrong ?

Edit:
ah yea its tfs 1.3 always forgeting : /
 
Last edited:

Azakelis

Advanced OT User
Joined
Feb 17, 2014
Messages
161
Solutions
15
Reaction score
225
C++:
bool Creature::hasCondition(ConditionType_t type, uint32_t subId/* = 0*/) const
{
    if (isSuppress(type)) {
        return false;
    }

    int64_t timeNow = OTSYS_TIME();
    for (Condition* condition : conditions) {
        if (condition->getType() != type || condition->getSubId() != subId) {
            continue;
        }

        if (condition->getEndTime() >= timeNow || condition->getTicks() == -1) {
            return true;
        }
    }
    return false;
}
As you can see there it checks for subId (if not privded then subId has to be 0).

You can add another method for example:
creature.cpp:
C++:
bool Creature::hasConditionOfAnySubId(ConditionType_t type) const
{
    if (isSuppress(type)) {
        return false;
    }

    int64_t timeNow = OTSYS_TIME();
    for (Condition* condition : conditions) {
        if (condition->getType() != type) {
            continue;
        }

        if (condition->getEndTime() >= timeNow || condition->getTicks() == -1) {
            return true;
        }
    }
    return false;
}

creature.h:
C++:
bool hasConditionOfAnySubId(ConditionType_t type) const;

and then:
C++:
if (creature->hasConditionOfAnySubId(CONDITION_WALKLOCK)) {
        return RETURNVALUE_NOTPOSSIBLE;
}

No idea if there is a better way to do this, because I didn't look much into it.
 
Top