void MonsterComponent::receivedDamage(Entity *source, const Damage &damage, int hpLoss) { if (source) changeAnger(source, hpLoss); if (hpLoss && source && source->getType() == OBJECT_CHARACTER) { mExpReceivers[source].insert(damage.skill); if (mKillStealProtectedTimeout.expired() || mOwner == source || mOwner->getComponent<CharacterComponent>()->getParty() == source->getComponent<CharacterComponent>()->getParty()) { mOwner = source; mLegalExpReceivers.insert(source); mKillStealProtectedTimeout.set(KILLSTEAL_PROTECTION_TIME); } } }
int Monster::damage(Actor *source, const Damage &damage) { int HPLoss = Being::damage(source, damage); if (source) { changeAnger(source, HPLoss); } if (HPLoss && source && source->getType() == OBJECT_CHARACTER) { Character *s = static_cast< Character * >(source); mExpReceivers[s].insert(damage.skill); if (mKillStealProtectedTimeout.expired() || mOwner == s || mOwner->getParty() == s->getParty()) { mOwner = s; mLegalExpReceivers.insert(s); mKillStealProtectedTimeout.set(KILLSTEAL_PROTECTION_TIME); } } if (mSpecy->getDamageCallback().isValid()) { Script *script = ScriptManager::currentState(); script->setMap(getMap()); script->prepare(mSpecy->getDamageCallback()); script->push(this); script->push(source); script->push(HPLoss); // TODO: add exact damage parameters as well script->execute(); } return HPLoss; }