//-------------------------------------------------------------- // CBounceEffect::getTargetForBounce() //-------------------------------------------------------------- CEntityBase *CBounceEffect::getTargetForBounce(CEntityBase *actor) const { // get entities around if (!_AffectedEntity) _AffectedEntity = CEntityBaseManager::getEntityBasePtr(_TargetRowId); if (!_AffectedEntity) return NULL; // get entities in surrouding area // range of the effect in meters = _Value CRangeSelector entitiesSelector; entitiesSelector.buildDisc( CEntityBaseManager::getEntityBasePtr(getCreatorRowId()), _AffectedEntity->getX(), _AffectedEntity->getY(), (float) _Value, EntityMatrix, true ); // select valid entities const vector<CEntityBase*> &entities = entitiesSelector.getEntities(); const uint size = (uint)entities.size(); vector<CEntityBase*> selectedEntities; selectedEntities.reserve(size); for (uint i = 0; i < entities.size() ; ++i) { if ( entities[i] && ( entities[i] != (CEntityBase*)(_AffectedEntity) ) && isEntityValidTarget(entities[i], actor) ) { selectedEntities.push_back(entities[i]); } } if (selectedEntities.empty()) return NULL; uint32 num = RandomGenerator.rand((uint16)selectedEntities.size()-1); return selectedEntities[num]; } // getTargetForBounce //
//-------------------------------------------------------------- // CDamageAuraEffect::update() //-------------------------------------------------------------- bool CDamageAuraEffect::update(CTimerEvent * event, bool applyEffect) { const TGameCycle time = CTickEventHandler::getGameCycle(); if (!_AffectedEntity) _AffectedEntity = CEntityBaseManager::getEntityBasePtr(_TargetRowId); if (!_AffectedEntity) { _EndTimer.setRemaining(1, new CEndEffectTimerEvent(this)); return true; } // if main entity is being teleported, do not apply effect if (applyEffect && _AffectedEntity->getId().getType() == RYZOMID::player) { CCharacter *player = dynamic_cast<CCharacter*> (&(*_AffectedEntity)); if (player && player->teleportInProgress()) { applyEffect = false; } } if (applyEffect) { // get entities in surrouding area CRangeSelector entitiesSelector; entitiesSelector.buildDisc( CEntityBaseManager::getEntityBasePtr(getCreatorRowId()), _AffectedEntity->getX(), _AffectedEntity->getY(), _AuraRadius, EntityMatrix, true ); // create or update effect on entities returned const vector<CEntityBase*> &entities = entitiesSelector.getEntities(); const uint size = (uint)entities.size(); for (uint i = 0; i < size ; ++i) { if (entities[i] && (entities[i] != (CEntityBase*)_AffectedEntity) && isEntityValidTarget(entities[i]) ) { CEntityBase *entity = entities[i]; SM_STATIC_PARAMS_2(params, STRING_MANAGER::entity, STRING_MANAGER::integer); // send messages // to victim if (entity->getId().getType() == RYZOMID::player) { params[0].setEIdAIAlias( _AffectedEntity->getId(), CAIAliasTranslator::getInstance()->getAIAlias(_AffectedEntity->getId()) ); params[1].Int = _CycleDamage; PHRASE_UTILITIES::sendDynamicSystemMessage( entity->getEntityRowId(), "EFFECT_STENCH_LOSE_HP", params); } // to stinking entity if (_AffectedEntity->getId().getType() == RYZOMID::player) { params[0].setEIdAIAlias( entity->getId(), CAIAliasTranslator::getInstance()->getAIAlias(entity->getId()) ); params[1].Int = _CycleDamage; PHRASE_UTILITIES::sendDynamicSystemMessage( _TargetRowId, "EFFECT_STENCH_LOSE_HP_ACTOR", params); } // remove HP if (entity->changeCurrentHp( -sint32(_CycleDamage), _TargetRowId)) { // killed entity, so this effect and all other effects have been cleared send kill message and return true PHRASE_UTILITIES::sendDeathMessages( _TargetRowId, entity->getEntityRowId()); //_EndTimer.setRemaining(1, new CEndEffectTimerEvent(this)); //return true; } } } } // set timer next event _UpdateTimer.setRemaining(_CycleLength, event); return false; } // update //