//-------------------------------------------------------------- // CBounceEffect::isEntityValidTarget() //-------------------------------------------------------------- bool CBounceEffect::isEntityValidTarget(CEntityBase *entity, CEntityBase *actor) const { #ifdef NL_DEBUG nlassert(entity); #endif if (entity->isDead()) return false; if (entity->getId().getType() == RYZOMID::player) return true; if ( entity->getContextualProperty().getValue().attackable() ) return true; CCreature * creature = CreatureManager.getCreature( entity->getId() ); if (creature && actor) { if (creature->checkFactionAttackable( actor->getId() )) { return true; } } return false; } // checkTargetValidity //
bool CMagicActionBasicDamage::initFromAiAction(CStaticAiAction const* aiAction, CMagicPhrase* phrase) { #ifdef NL_DEBUG nlassert(phrase); nlassert(aiAction); #endif if (aiAction->getType() != AI_ACTION::DamageSpell ) return false; sint32 damageBonus = 0; CCreature *creature = CreatureManager.getCreature( phrase->getActor() ); if (creature && creature->getForm()) damageBonus = sint32(aiAction->getData().Spell.SpellPowerFactor * creature->getForm()->getAttackLevel()); switch(aiAction->getData().Spell.AffectedScore) { case SCORES::sap: _DmgSap = sint32(aiAction->getData().Spell.SpellParamValue + damageBonus); break; case SCORES::stamina: _DmgSta = sint32(aiAction->getData().Spell.SpellParamValue + damageBonus); break; case SCORES::hit_points: _DmgHp = sint32(aiAction->getData().Spell.SpellParamValue + damageBonus); break; default: return false; }; _VampirismValue = (sint32)aiAction->getData().Spell.SpellParamValue2; _DmgType = aiAction->getData().Spell.DamageType; phrase->setMagicFxType(MAGICFX::toMagicFx( _DmgType, false), 1); return true; }
//-------------------------------------------------------------- // initFromAiAction //-------------------------------------------------------------- bool CMagicAiActionDoT::initFromAiAction( const CStaticAiAction *aiAction, CMagicPhrase *phrase ) { #ifdef NL_DEBUG nlassert(phrase); nlassert(aiAction); #endif if (aiAction->getType() != AI_ACTION::DoTSpell ) return false; // read parameters const COTSpellParams &data = aiAction->getData().OTSpell; CCreature *creature = CreatureManager.getCreature( phrase->getActor() ); if (creature && creature->getForm()) _TotalDamageValue = (uint16)(data.SpellParamValue + data.SpellPowerFactor * creature->getForm()->getAttackLevel()); else _TotalDamageValue = (uint16)data.SpellParamValue; _EffectDuration = data.Duration; _UpdateFrequency = data.UpdateFrequency; _AffectedScore = data.AffectedScore; _DamageType = data.DamageType; _Stackable = data.Stackable; _DurationType = data.EffectDurationType; phrase->setMagicFxType(MAGICFX::toMagicFx( _DamageType, true), 3); return true; } // initFromAiAction //
//-------------------------------------------------------------- // initFromAiAction //-------------------------------------------------------------- bool CMagicAiActionDamageAura::initFromAiAction( const CStaticAiAction *aiAction, CMagicPhrase *phrase ) { #ifdef NL_DEBUG nlassert(phrase); nlassert(aiAction); #endif if (aiAction->getType() != AI_ACTION::EoTSpell ) return false; // read parameters const COTEffectSpellParams &data = aiAction->getData().OTEffectSpell; CCreature *creature = CreatureManager.getCreature( phrase->getActor() ); if (creature && creature->getForm()) _DamagePerUpdate = (uint16)(data.SpellParamValue2 + data.SpellPowerFactor * creature->getForm()->getAttackLevel()); else _DamagePerUpdate = (uint16)data.SpellParamValue2; _EffectFamily = AI_ACTION::toEffectFamily(data.EffectFamily, aiAction->getType()); _EffectDuration = data.Duration; _Range = data.SpellParamValue; _CycleLength = data.UpdateFrequency; phrase->setMagicFxType(MAGICFX::toMagicFx( _EffectFamily), 3); return true; } // initFromAiAction //
//----------------------------------------------- // CHarvestPhrase harvestCorpseResult //----------------------------------------------- void CHarvestPhrase::harvestCorpseResult() { H_AUTO(CHarvestPhrase_harvestCorpseResult); // get harvester character CCharacter *character = PlayerManager.getChar( _ActorRowId ); if (character == NULL) { //nlwarning("<cbHarvestResult> Invalid player Id %s", playerId.toString().c_str() ); return; } // get harvested corpse const CEntityId &harvestedEntity = character->harvestedEntity(); CCreature *creature = CreatureManager.getCreature( harvestedEntity ); if (creature == NULL) { nlwarning("<cbHarvestResult> Invalid creature Id %s", harvestedEntity.toString().c_str() ); // reset harvest info character->resetHarvestInfos(); character->endHarvest(); return; } const vector< CCreatureRawMaterial> &mps = creature->getMps(); if ( character->harvestedMpIndex() >= mps.size() || character->harvestedMpQuantity() > mps[character->harvestedMpIndex()].Quantity ) { // reset harvest info character->resetHarvestInfos(); return; } uint16 quality = _MaxQuality; // create the mp items if any if (quality > 0) { if ( !character->createItemInInventory(INVENTORIES::bag, quality, character->harvestedMpQuantity(), _RawMaterialId, character->getId()) ) { // CMissionEventItem event(CMissionEvent::Harvest,playerId,harvestedEntity,_RawMaterialId,quality,character->harvestedMpQuantity()); // character->processMissionEvent(event); // error creating the object, hand probably not empty // character->resetHarvestInfos(); // return; } else { const CStaticItem *item = CSheets::getForm(_RawMaterialId); if (item) { ///\todo nico: check if this event exists // CMissionEventHarvest event(_RawMaterialId ,character->harvestedMpQuantity(),quality); // character->processMissionEvent( event ); SM_STATIC_PARAMS_3(params, STRING_MANAGER::integer, STRING_MANAGER::item, STRING_MANAGER::integer); params[0].Int = (sint32)character->harvestedMpQuantity(); params[1].SheetId = _RawMaterialId; params[2].Int = (sint32)quality; STRING_MANAGER::sendStringToClient( character->getEntityRowId(), "HARVEST_SUCCESS", params ); } } } // the mp have been destroyed -> do nothing else { } // remove the quantity of mp harvested from the ressource creature->removeMp( character->harvestedMpIndex(), character->harvestedMpQuantity() ); // reset harvest info character->resetHarvestInfos(); } // harvestCorpseResult //