Lost my source files so I had to re-download and old revision I chucked on github and re-add the onSpawn and Loot customizations.
But I did it.
Re-compiled, tested.
So...
C++:
if (hasCondition(CONDITION_EXHAUST)) {
return false;
}
Is not a valid CONST.
CONDITION_EXHAUST_COMBAT
CONDITION_EXHAUST_HEALING is.
C++:
if (hasCondition(CONDITION_EXHAUST_HEALING)) {
return false;
}
Either way, those conditions don't seem to apply on monsters properly(?)
So I've settled for CONDITION_PACIFIED instead, its probably more appropriate anyway.
I've added the check to the following monster functions:
Stop monster from changing look direction (because its stunned)
C++:
void Monster::doAttacking(uint32_t interval)
{
if (!attackedCreature || (isSummon() && attackedCreature == this)) {
return;
}
bool updateLook = true;
bool resetTicks = interval != 0;
attackTicks += interval;
if (hasCondition(CONDITION_PACIFIED)) {
updateLook = false;
}
...
...
Stop monster from attacking
C++:
bool Monster::canUseAttack(const Position& pos, const Creature* target) const
{
if (isHostile()) {
const Position& targetPos = target->getPosition();
uint32_t distance = std::max<uint32_t>(Position::getDistanceX(pos, targetPos), Position::getDistanceY(pos, targetPos));
for (const spellBlock_t& spellBlock : mType->attackSpells) {
if (spellBlock.range != 0 && distance <= spellBlock.range) {
return g_game.isSightClear(pos, targetPos, true);
}
}
return false;
}
if (hasCondition(CONDITION_PACIFIED)) {
return false;
}
...
...
Stop monster from using offensive spells (possibly redundant due to check above, no harm either way)
C++:
bool Monster::canUseSpell(const Position& pos, const Position& targetPos,
const spellBlock_t& sb, uint32_t interval, bool& inRange, bool& resetTicks)
{
inRange = true;
if (hasCondition(CONDITION_PACIFIED)) {
return false;
}
...
...
Stop monster from healing/hasting etc
Going to test this one a bit more as its also probably redundant, and reseting the interval ticks will add an unecessary delay between the stun wearing off and them casting their next spell.
But maybe thats thematically a good thing, we'll see.
C++:
void Monster::onThinkDefense(uint32_t interval)
{
bool resetTicks = true;
defenseTicks += interval;
if (hasCondition(CONDITION_PACIFIED)) {
defenseTicks = 0;
}
...
...
Stop monster from trying to move
C++:
bool Monster::getNextStep(Direction& dir, uint32_t& flags)
{
if (isIdle || getHealth() <= 0) {
//we dont have anyone watching might aswell stop walking
eventWalk = 0;
return false;
}
if (hasCondition(CONDITION_PACIFIED)) {
return false;
}
...
...
Stop monster from trying to flee (also probably redundant, oh well)
C++:
bool Monster::getDistanceStep(const Position& targetPos, Direction& dir, bool flee /* = false */)
{
const Position& creaturePos = getPosition();
if (hasCondition(CONDITION_PACIFIED)) {
return false;
}
...
...
Works perfectly, monster literally stops in-place and it functions as a stun.
addCondition + addEvent with repeating CONST_ME_STUN for the duration and you have a stun system.