As the title suggests. When a monster casts invisible, they stay invisible forever unless they take damage.
I have compared bits of code to other distributions, and everything that I've looked at so far looks the same, so I must be missing something or looking in the wrong place.
Her is what I checked so far:
The monster "defense" ability of invisible is here, in monsters.cpp:
pretty straightforward...if you don't declare a duration in the monster xml file, the default is 10 seconds, then it applies the condition.
The invisibility condition starting/stopping is here in condition.cpp, it looks the same as other distros:
Creatures get knocked out of invisibility if they take damage, this is working. The game checks using the "isInvisible" function:
The "isInvisible" function looks fine too:
I don't really know where else to look, or why the invisible condition never ends. It ends just fine for players who cast utana vid on themselves. Problem is only for monsters.
I have compared bits of code to other distributions, and everything that I've looked at so far looks the same, so I must be missing something or looking in the wrong place.
Her is what I checked so far:
The monster "defense" ability of invisible is here, in monsters.cpp:
C++:
else if (tmpName == "invisible") {
int32_t duration = 10000;
if ((attr = node.attribute("duration"))) {
duration = pugi::cast<int32_t>(attr.value());
}
Condition* condition = Condition::createCondition(CONDITIONID_COMBAT, CONDITION_INVISIBLE, duration, 0);
combat->setParam(COMBAT_PARAM_AGGRESSIVE, 0);
combat->setCondition(condition);
The invisibility condition starting/stopping is here in condition.cpp, it looks the same as other distros:
C++:
bool ConditionInvisible::startCondition(Creature* creature)
{
if (!Condition::startCondition(creature)) {
return false;
}
g_game.internalCreatureChangeVisible(creature, false);
return true;
}
void ConditionInvisible::endCondition(Creature* creature)
{
if (!creature->isInvisible()) {
g_game.internalCreatureChangeVisible(creature, true);
}
}
C++:
void Monster::drainHealth(Creature* attacker, int32_t damage)
{
Creature::drainHealth(attacker, damage);
if (isInvisible()) {
removeCondition(CONDITION_INVISIBLE);
}
}
C++:
bool Creature::isInvisible() const
{
return std::find_if(conditions.begin(), conditions.end(), [] (const Condition* condition) {
return condition->getType() == CONDITION_INVISIBLE;
}) != conditions.end();
}