in

C++ Sistema de orientación para Trinity, Mangos y Ascent

Estos codigos ayudara a cualquier persona interesada en los objetivos de hechizo.

SCRIPT PARA DIFENTES EMLADORES WOW

Ascent:

void Spell::FillTargetMap(uint32 i)
{
	uint32 cur;
	
	uint32 TypeA = m_spellInfo->EffectImplicitTargetA[i];
	uint32 TypeB = m_spellInfo->EffectImplicitTargetB[i];

	// if all secondary targets are 0 then use only primary targets
	if(!TypeB)
	{
		if(TypeA < TOTAL_SPELL_TARGET) (this->*SpellTargetHandler[TypeA])(i, 0);		//0=A

		return;
	}

	// if all primary targets are 0 then use only secondary targets
	if(!TypeA)
	{
		if(TypeB < TOTAL_SPELL_TARGET) (this->*SpellTargetHandler[TypeB])(i, 1);		//1=B

		return;
	}

	// j = 0
	cur = m_spellInfo->EffectImplicitTargetA[i];
	if (cur < TOTAL_SPELL_TARGET) { (this->*SpellTargetHandler[cur])(i,0);	//0=A
	}

	// j = 1
	cur = m_spellInfo->EffectImplicitTargetB[i];
	if (cur < TOTAL_SPELL_TARGET) { (this->*SpellTargetHandler[cur])(i,1);	//1=B
	}
}
Fucking faerie wouldn't listen...

	
Eskiv

Mangos parte 1:

void Spell::SelectEffectTargets(uint32 i, uint32 cur)
{
    SpellNotifyPushType pushType = PUSH_NONE;
    Player *modOwner = NULL;
    if(m_originalCaster)
        modOwner = m_originalCaster->GetSpellModOwner();

    switch(SpellTargetType[cur])
    {
        case TARGET_TYPE_UNIT_CASTER:
        {
            switch(cur)
            {
                case TARGET_UNIT_CASTER:
                    AddUnitTarget(m_caster, i);
                    break;
                case TARGET_UNIT_CASTER_FISHING:
                {
                    //AddUnitTarget(m_caster, i);
                    float min_dis = GetSpellMinRange(m_spellInfo, true);
                    float max_dis = GetSpellMaxRange(m_spellInfo, true);
                    float dis = rand_norm() * (max_dis - min_dis) + min_dis;
                    float x, y, z;
                    m_caster->GetClosePoint(x, y, z, DEFAULT_WORLD_OBJECT_SIZE, dis);
                    m_targets.setDst(x, y, z);
                    break;
                }
                case TARGET_UNIT_MASTER:
                    if(Unit* owner = m_caster->GetCharmerOrOwner())
                        AddUnitTarget(owner, i);
                    break;
                case TARGET_UNIT_PET:
                    if(Guardian* pet = m_caster->GetGuardianPet())
                        AddUnitTarget(pet, i);
                    break;
                case TARGET_UNIT_PARTY_CASTER:
                case TARGET_UNIT_RAID_CASTER:
                    pushType = PUSH_CASTER_CENTER;
                    break;
                case TARGET_UNIT_VEHICLE:
                    if(Unit *vehicle = m_caster->GetVehicleBase())
                        AddUnitTarget(vehicle, i);
                    break;
                case TARGET_UNIT_PASSENGER:
                    if(m_caster->GetTypeId() == TYPEID_UNIT && ((Creature*)m_caster)->IsVehicle())
                        if(Unit *unit = m_caster->GetVehicleKit()->GetPassenger(1)) // maybe not right
                            AddUnitTarget(unit, i);
                    break;
            }
            break;
        }

        case TARGET_TYPE_UNIT_TARGET:
        {
            Unit *target = m_targets.getUnitTarget();
            if(!target)
            {
                sLog.outError("SPELL: no unit target for spell ID %u", m_spellInfo->Id);
                break;
            }

            switch(cur)
            {
                case TARGET_UNIT_TARGET_ENEMY:
                    if(Unit *magnet = m_caster->SelectMagnetTarget(target, m_spellInfo))
                        if(magnet != target)
                            m_targets.setUnitTarget(magnet);
                    pushType = PUSH_CHAIN;
                    break;
                case TARGET_UNIT_TARGET_ANY:
                    if(!IsPositiveSpell(m_spellInfo->Id))
                        if(Unit *magnet = m_caster->SelectMagnetTarget(target, m_spellInfo))
                            if(magnet != target)
                                m_targets.setUnitTarget(magnet);
                    pushType = PUSH_CHAIN;
                    break;
                case TARGET_UNIT_CHAINHEAL:
                    pushType = PUSH_CHAIN;
                    break;
                case TARGET_UNIT_TARGET_ALLY:
                case TARGET_UNIT_TARGET_RAID:
                case TARGET_UNIT_TARGET_PARTY:
                case TARGET_UNIT_MINIPET:
                    AddUnitTarget(target, i);
                    break;
                case TARGET_UNIT_PARTY_TARGET:
                case TARGET_UNIT_CLASS_TARGET:
                    pushType = PUSH_CASTER_CENTER; // not real
                    break;
            }
            break;
        }

        case TARGET_TYPE_UNIT_NEARBY:
        {
            WorldObject *target = NULL;
            float range;

            switch(cur)
            {
                case TARGET_UNIT_NEARBY_ENEMY:
                    range = GetSpellMaxRange(m_spellInfo, false);
                    if(modOwner) modOwner->ApplySpellMod(m_spellInfo->Id, SPELLMOD_RANGE, range, this);
                    target = SearchNearbyTarget(range, SPELL_TARGETS_ENEMY);
                    break;
                case TARGET_UNIT_NEARBY_ALLY:
                case TARGET_UNIT_NEARBY_ALLY_UNK:
                case TARGET_UNIT_NEARBY_RAID:
                    range = GetSpellMaxRange(m_spellInfo, true);
                    if(modOwner) modOwner->ApplySpellMod(m_spellInfo->Id, SPELLMOD_RANGE, range, this);
                    target = SearchNearbyTarget(range, SPELL_TARGETS_ALLY);
                    break;
                case TARGET_UNIT_NEARBY_ENTRY:
                    range = GetSpellMaxRange(m_spellInfo, IsPositiveSpell(m_spellInfo->Id));
                    if(modOwner) modOwner->ApplySpellMod(m_spellInfo->Id, SPELLMOD_RANGE, range, this);
                    target = SearchNearbyTarget(range, SPELL_TARGETS_ENTRY);
                    break;
            }

            if(!target)
                return;
            else if(target->GetTypeId() == TYPEID_GAMEOBJECT)
                AddGOTarget((GameObject*)target, i);
            else
            {
                pushType = PUSH_CHAIN;

                if(m_targets.getUnitTarget() != target)
                    m_targets.setUnitTarget((Unit*)target);
            }

            break;
        }

        case TARGET_TYPE_AREA_SRC:
            pushType = PUSH_SRC_CENTER;
            break;

        case TARGET_TYPE_AREA_DST:
            pushType = PUSH_DST_CENTER;
            break;

        case TARGET_TYPE_AREA_CONE:
            if(m_customAttr & SPELL_ATTR_CU_CONE_BACK)
                pushType = PUSH_IN_BACK;
            else if(m_customAttr & SPELL_ATTR_CU_CONE_LINE)
                pushType = PUSH_IN_LINE;
            else
                pushType = PUSH_IN_FRONT;
            break;
           
        case TARGET_TYPE_DEST_CASTER: //4+8+2
        {
            if(cur == TARGET_SRC_CASTER)
            {
                m_targets.setSrc(m_caster);
                break;
            }
            else if(cur == TARGET_DST_CASTER)
            {
                m_targets.setDst(m_caster);
                break;
            }

            float angle, dist;

            float objSize = m_caster->GetObjectSize();
            dist = GetSpellRadiusForFriend(sSpellRadiusStore.LookupEntry(m_spellInfo->EffectRadiusIndex[i]));
            if(dist < objSize) dist = objSize; else if(cur == TARGET_DEST_CASTER_RANDOM) dist = objSize + (dist - objSize) * rand_norm(); switch(cur) { case TARGET_DEST_CASTER_FRONT_LEFT: angle = -M_PI/4; break; case TARGET_DEST_CASTER_BACK_LEFT: angle = -3*M_PI/4; break; case TARGET_DEST_CASTER_BACK_RIGHT: angle = 3*M_PI/4; break; case TARGET_DEST_CASTER_FRONT_RIGHT:angle = M_PI/4; break; case TARGET_MINION: case TARGET_DEST_CASTER_FRONT_LEAP: case TARGET_DEST_CASTER_FRONT: angle = 0.0f; break; case TARGET_DEST_CASTER_BACK: angle = M_PI; break; case TARGET_DEST_CASTER_RIGHT: angle = M_PI/2; break; case TARGET_DEST_CASTER_LEFT: angle = -M_PI/2; break; default: angle = rand_norm()*2*M_PI; break; } Position pos; m_caster->GetNearPosition(pos, dist, angle);
            m_targets.setDst(&pos); // also flag
            break;
        }

        case TARGET_TYPE_DEST_TARGET: //2+8+2
        {
            Unit *target = m_targets.getUnitTarget();
            if(!target)
            {
                sLog.outError("SPELL: no unit target for spell ID %u\n", m_spellInfo->Id);
                break;
            }

            if(cur == TARGET_DST_TARGET_ENEMY || cur == TARGET_DEST_TARGET_ANY)
            {
                m_targets.setDst(target);
                break;
            }

            float angle, dist;

            float objSize = target->GetObjectSize();
            dist = target->GetSpellRadiusForTarget(target, sSpellRadiusStore.LookupEntry(m_spellInfo->EffectRadiusIndex[i]));
            if(dist < objSize) dist = objSize; else if(cur == TARGET_DEST_CASTER_RANDOM) dist = objSize + (dist - objSize) * rand_norm(); switch(cur) { case TARGET_DEST_TARGET_FRONT: angle = 0.0f; break; case TARGET_DEST_TARGET_BACK: angle = M_PI; break; case TARGET_DEST_TARGET_RIGHT: angle = M_PI/2; break; case TARGET_DEST_TARGET_LEFT: angle = -M_PI/2; break; case TARGET_DEST_TARGET_FRONT_LEFT: angle = -M_PI/4; break; case TARGET_DEST_TARGET_BACK_LEFT: angle = -3*M_PI/4; break; case TARGET_DEST_TARGET_BACK_RIGHT: angle = 3*M_PI/4; break; case TARGET_DEST_TARGET_FRONT_RIGHT:angle = M_PI/4; break; default: angle = rand_norm()*2*M_PI; break; } Position pos; target->GetNearPosition(pos, dist, angle);
            m_targets.setDst(&pos);
            break;
        }

        case TARGET_TYPE_DEST_DEST: //5+8+1
        {
            if(!m_targets.HasDst())
            {
                sLog.outError("SPELL: no destination for spell ID %u\n", m_spellInfo->Id);
                break;
            }

            float angle;
            switch(cur)
            {
                case TARGET_DEST_DYNOBJ_ENEMY:
                case TARGET_DEST_DYNOBJ_ALLY:
                case TARGET_DEST_DYNOBJ_NONE:
                case TARGET_DEST_DEST:
                    return;
                case TARGET_DEST_TRAJ:
                    SelectTrajTargets();
                    return;
                case TARGET_DEST_DEST_FRONT:      angle = 0.0f;       break;
                case TARGET_DEST_DEST_BACK:       angle = M_PI;       break;
                case TARGET_DEST_DEST_RIGHT:      angle = M_PI/2;     break;
                case TARGET_DEST_DEST_LEFT:       angle = -M_PI/2;    break;
                case TARGET_DEST_DEST_FRONT_LEFT: angle = -M_PI/4;    break;
                case TARGET_DEST_DEST_BACK_LEFT:  angle = -3*M_PI/4;  break;
                case TARGET_DEST_DEST_BACK_RIGHT: angle = 3*M_PI/4;   break;
                case TARGET_DEST_DEST_FRONT_RIGHT:angle = M_PI/4;     break;
                default:                          angle = rand_norm()*2*M_PI; break;
            }

            float dist;
            dist = GetSpellRadiusForFriend(sSpellRadiusStore.LookupEntry(m_spellInfo->EffectRadiusIndex[i]));
            if (cur == TARGET_DEST_DEST_RANDOM)
                dist *= rand_norm();

            // must has dst, no need to set flag
            m_caster->MovePosition(m_targets.m_dstPos, dist, angle);
            break;
        }

        case TARGET_TYPE_DEST_SPECIAL:
        {
            switch(cur)
            {
                case TARGET_DST_DB:
                    if(SpellTargetPosition const* st = spellmgr.GetSpellTargetPosition(m_spellInfo->Id))
                    {
                        //TODO: fix this check
                        if(m_spellInfo->Effect[0] == SPELL_EFFECT_TELEPORT_UNITS
                            || m_spellInfo->Effect[1] == SPELL_EFFECT_TELEPORT_UNITS
                            || m_spellInfo->Effect[2] == SPELL_EFFECT_TELEPORT_UNITS)
                            m_targets.setDst(st->target_X, st->target_Y, st->target_Z, (int32)st->target_mapId);
                        else if(st->target_mapId == m_caster->GetMapId())
                            m_targets.setDst(st->target_X, st->target_Y, st->target_Z);
                    }
                    else
                    {
                        sLog.outDebug( "SPELL: unknown target coordinates for spell ID %u", m_spellInfo->Id );
                        Unit *target = NULL;
                        if(uint64 guid = m_caster->GetUInt64Value(UNIT_FIELD_TARGET))
                            target = ObjectAccessor::GetUnit(*m_caster, guid);
                        m_targets.setDst(target ? target : m_caster);
                    }
                    break;
                case TARGET_DST_HOME:
                    if(m_caster->GetTypeId() == TYPEID_PLAYER)
                        m_targets.setDst(((Player*)m_caster)->m_homebindX,((Player*)m_caster)->m_homebindY,((Player*)m_caster)->m_homebindZ, ((Player*)m_caster)->m_homebindMapId);
                    break;
                case TARGET_DST_NEARBY_ENTRY:
                {
                    float range = GetSpellMaxRange(m_spellInfo, IsPositiveSpell(m_spellInfo->Id));
                    if(modOwner) modOwner->ApplySpellMod(m_spellInfo->Id, SPELLMOD_RANGE, range, this);

                    if(WorldObject *target = SearchNearbyTarget(range, SPELL_TARGETS_ENTRY))
                        m_targets.setDst(target);
                    break;
                }
            }
            break;
        }

        case TARGET_TYPE_CHANNEL:
        {
            if(!m_originalCaster || !m_originalCaster->GetCurrentSpell(CURRENT_CHANNELED_SPELL))
            {
                sLog.outError( "SPELL: no current channeled spell for spell ID %u", m_spellInfo->Id );
                break;
            }

            switch(cur)
            {
                case TARGET_UNIT_CHANNEL:
                    // in some cases unittarget is invalid and crash. do not know why it happens.
                    if(Unit* target = Unit::GetUnit(*m_caster, m_originalCaster->GetCurrentSpell(CURRENT_CHANNELED_SPELL)->m_targets.getUnitTargetGUID()))
                        AddUnitTarget(target, i);
                    else
                        sLog.outError( "SPELL: cannot find channel spell target for spell ID %u", m_spellInfo->Id );
                    break;
                case TARGET_DEST_CHANNEL:
                    if(m_originalCaster->GetCurrentSpell(CURRENT_CHANNELED_SPELL)->m_targets.HasDst())
                        m_targets = m_originalCaster->GetCurrentSpell(CURRENT_CHANNELED_SPELL)->m_targets;
                    else if(Unit* target = Unit::GetUnit(*m_caster, m_originalCaster->GetCurrentSpell(CURRENT_CHANNELED_SPELL)->m_targets.getUnitTargetGUID()))
                        m_targets.setDst(target);
                    else
                        sLog.outError( "SPELL: cannot find channel spell destination for spell ID %u", m_spellInfo->Id );
                    break;
            }
            break;
        }

        default:
        {
            switch(cur)
            {
                case TARGET_GAMEOBJECT:
                case TARGET_OBJECT_USE:
                    if(m_targets.getGOTarget())
                        AddGOTarget(m_targets.getGOTarget(), i);
                    break;
                case TARGET_GAMEOBJECT_ITEM:
                    if(m_targets.getGOTargetGUID())
                        AddGOTarget(m_targets.getGOTarget(), i);
                    else if(m_targets.getItemTarget())
                        AddItemTarget(m_targets.getItemTarget(), i);
                    break;
                default:
                    sLog.outError("Unhandled spell target %u", cur);
                    break;
            }
            break;
        }
    }

Mangos parte 2:

if(pushType == PUSH_CHAIN) // Chain
    {
        Unit *target = m_targets.getUnitTarget();
        if(!target)
        {
            sLog.outError("SPELL: no chain unit target for spell ID %u", m_spellInfo->Id);
            return;
        }

        //Chain: 2, 6, 22, 25, 45, 77
        uint32 maxTargets = m_spellInfo->EffectChainTarget[i];
        if(modOwner)
            modOwner->ApplySpellMod(m_spellInfo->Id, SPELLMOD_JUMP_TARGETS, maxTargets, this);

        if(maxTargets > 1)
        {
            //otherwise, this multiplier is used for something else
            m_damageMultipliers[i] = 1.0f;
            m_applyMultiplierMask |= 1 << i;

            float range;
            std::list<Unit*> unitList;

            switch(cur)
            {
                case TARGET_UNIT_NEARBY_ENEMY:
                case TARGET_UNIT_TARGET_ENEMY:
                case TARGET_UNIT_NEARBY_ENTRY: // fix me
                    range = GetSpellMaxRange(m_spellInfo, false);
                    if(modOwner) modOwner->ApplySpellMod(m_spellInfo->Id, SPELLMOD_RANGE, range, this);
                    SearchChainTarget(unitList, range, maxTargets, SPELL_TARGETS_ENEMY);
                    break;
                case TARGET_UNIT_CHAINHEAL:
                case TARGET_UNIT_NEARBY_ALLY:  // fix me
                case TARGET_UNIT_NEARBY_ALLY_UNK:
                case TARGET_UNIT_NEARBY_RAID:
                    range = GetSpellMaxRange(m_spellInfo, true);
                    if(modOwner) modOwner->ApplySpellMod(m_spellInfo->Id, SPELLMOD_RANGE, range, this);
                    SearchChainTarget(unitList, range, maxTargets, SPELL_TARGETS_CHAINHEAL);
                    break;
            }
            
            for(std::list<Unit*>::iterator itr = unitList.begin(); itr != unitList.end(); ++itr)
                AddUnitTarget(*itr, i);
        }
        else
            AddUnitTarget(target, i);
    }
    else if(pushType)
    {
        // Dummy, just for client
        if(EffectTargetType[m_spellInfo->Effect[i]] != SPELL_REQUIRE_UNIT)
            return;

        float radius;
        SpellTargets targetType;
        switch(cur)
        {
            case TARGET_UNIT_AREA_ENEMY_SRC:
            case TARGET_UNIT_AREA_ENEMY_DST:
            case TARGET_UNIT_CONE_ENEMY:
            case TARGET_UNIT_CONE_ENEMY_UNKNOWN:
            case TARGET_UNIT_AREA_PATH:
                radius = GetSpellRadius(m_spellInfo, i, false);
                targetType = SPELL_TARGETS_ENEMY;
                break;
            case TARGET_UNIT_AREA_ALLY_SRC:
            case TARGET_UNIT_AREA_ALLY_DST:
            case TARGET_UNIT_CONE_ALLY:
                radius = GetSpellRadius(m_spellInfo, i, true);
                targetType = SPELL_TARGETS_ALLY;
                break;
            case TARGET_UNIT_AREA_ENTRY_DST:
            case TARGET_UNIT_AREA_ENTRY_SRC:
            case TARGET_UNIT_CONE_ENTRY: // fix me
                radius = GetSpellRadius(m_spellInfo, i, IsPositiveSpell(m_spellInfo->Id));
                targetType = SPELL_TARGETS_ENTRY;
                break;
            default:
                radius = GetSpellRadius(m_spellInfo, i, true);
                targetType = SPELL_TARGETS_NONE;
                break;
        }

        if(modOwner)
            modOwner->ApplySpellMod(m_spellInfo->Id, SPELLMOD_RADIUS, radius, this);
        radius *= m_spellValue->RadiusMod;

        std::list<Unit*> unitList;
        if(targetType == SPELL_TARGETS_ENTRY)
        {
            SpellScriptTargetBounds bounds = spellmgr.GetSpellScriptTargetBounds(m_spellInfo->Id);
            if(bounds.first==bounds.second)
            {
                // Custom entries
                // TODO: move these to sql
                switch (m_spellInfo->Id)
                {
                    case 46584: // Raise Dead
                    {
                        m_targets.m_targetMask &= ~TARGET_FLAG_DEST_LOCATION;
                        WorldObject* result = FindCorpseUsing ();
                        if(result)
                        {
                            switch(result->GetTypeId())
                            {
                                case TYPEID_UNIT:
                                    m_targets.setDst(result);
                            }
                        }
                        break;
                    }
                    // Corpse Explosion
                    case 49158:
                    case 51325:
                    case 51326:
                    case 51327:
                    case 51328:
                        // Search for ghoul if our ghoul or dead body not valid unit target
                        if (!(m_targets.getUnitTarget() && (m_targets.getUnitTarget()->GetEntry() == 26125 && m_targets.getUnitTarget()->GetOwnerGUID() == m_caster->GetGUID()
                            || (m_targets.getUnitTarget()->getDeathState() == CORPSE
                                && m_targets.getUnitTarget()->GetDisplayId() == m_targets.getUnitTarget()->GetNativeDisplayId() 
                                && m_targets.getUnitTarget()->GetTypeId()== TYPEID_UNIT
                                && !((Creature*)m_targets.getUnitTarget())->isDeadByDefault()
                                && !(m_targets.getUnitTarget()->GetCreatureTypeMask() & CREATURE_TYPEMASK_MECHANICAL_OR_ELEMENTAL))
                                && m_targets.getUnitTarget()->GetDisplayId() == m_targets.getUnitTarget()->GetNativeDisplayId())))
                        {
                            CleanupTargetList();

                            WorldObject* result = FindCorpseUsing  ();

                            if(result)
                            {
                                switch(result->GetTypeId())
                                {
                                case TYPEID_UNIT:
                                case TYPEID_PLAYER:
                                    m_targets.setUnitTarget((Unit*)result);
                                    break;
                                }
                            }
                            else
                            {
                                if (m_caster->GetTypeId()==TYPEID_PLAYER)
                                    ((Player*)m_caster)->RemoveSpellCooldown(m_spellInfo->Id,true);
                                SendCastResult(SPELL_FAILED_CANT_DO_THAT_RIGHT_NOW);
                                finish(false);
                            }
                        }
                        break;

                    default:
                        sLog.outDebug("Spell (ID: %u) (caster Entry: %u) does not have record in `spell_script_target`", m_spellInfo->Id, m_caster->GetEntry());

                        if(m_spellInfo->Effect[i] == SPELL_EFFECT_TELEPORT_UNITS)
                            SearchAreaTarget(unitList, radius, pushType, SPELL_TARGETS_ENTRY, 0);
                        else if(IsPositiveEffect(m_spellInfo->Id, i))
                            SearchAreaTarget(unitList, radius, pushType, SPELL_TARGETS_ALLY);
                        else
                            SearchAreaTarget(unitList, radius, pushType, SPELL_TARGETS_ENEMY);
                }
            }
            // let it be done in one check?
            else
            {
                for(SpellScriptTarget::const_iterator i_spellST = bounds.first; i_spellST != bounds.second; ++i_spellST)
                {
                    if(i_spellST->second.type == SPELL_TARGET_TYPE_CREATURE)
                        SearchAreaTarget(unitList, radius, pushType, SPELL_TARGETS_ENTRY, i_spellST->second.targetEntry);
                    else if (i_spellST->second.type == SPELL_TARGET_TYPE_CONTROLLED)
                    {
                        for(Unit::ControlList::iterator itr = m_caster->m_Controlled.begin(); itr != m_caster->m_Controlled.end(); ++itr)
                            if ((*itr)->GetEntry() == i_spellST->second.targetEntry && 
                                /*(*itr)->IsWithinDistInMap(m_caster, radius)*/ (*itr)->IsInMap(m_caster)) // For 60243 and 52173 need skip radius check or use range (no radius entry for effect)
                                unitList.push_back(*itr);
                    }
                }
            }
        }
        else if(targetType)
            SearchAreaTarget(unitList, radius, pushType, targetType);
        else
        {
            switch(cur)
            {
                case TARGET_UNIT_AREA_PARTY_SRC:
                case TARGET_UNIT_AREA_PARTY_DST:
                    m_caster->GetPartyMemberInDist(unitList, radius); //fix me
                    break;
                case TARGET_OBJECT_AREA_SRC: // fix me
                case TARGET_OBJECT_AREA_DST:
                {
                    float x, y, z;
                    if(cur == TARGET_OBJECT_AREA_SRC)
                    {
                        if(m_targets.HasSrc())
                            m_targets.m_srcPos.GetPosition(x, y, z);
                        else
                            break;
                    }
                    else
                    {
                        if(m_targets.HasDst())
                            m_targets.m_dstPos.GetPosition(x, y, z);
                        else
                            break;
                    }

                    CW::GameObjectInRangeCheck check(x, y, z, radius + 50);
                    std::list<GameObject*> goList;
                    CW::GameObjectListSearcher searcher(m_caster, goList, check);
                    m_caster->GetMap()->VisitGrid(x, y, radius, searcher);
                    for(std::list<GameObject*>::iterator itr = goList.begin(); itr != goList.end(); ++itr)
                        AddGOTarget(*itr, i);
                    break;
                }
                case TARGET_UNIT_PARTY_TARGET:
                    m_targets.getUnitTarget()->GetPartyMemberInDist(unitList, radius);
                    break;
                case TARGET_UNIT_PARTY_CASTER:
                    m_caster->GetPartyMemberInDist(unitList, radius);
                    break;
                case TARGET_UNIT_RAID_CASTER:
                    m_caster->GetRaidMember(unitList, radius);
                    break;
                case TARGET_UNIT_CLASS_TARGET:
                {
                    Player* targetPlayer = m_targets.getUnitTarget() && m_targets.getUnitTarget()->GetTypeId() == TYPEID_PLAYER
                        ? (Player*)m_targets.getUnitTarget() : NULL;

                    Group* pGroup = targetPlayer ? targetPlayer->GetGroup() : NULL;
                    if(pGroup)
                    {
                        for(GroupReference *itr = pGroup->GetFirstMember(); itr != NULL; itr = itr->next())
                        {
                            Player* Target = itr->getSource();

                            // IsHostileTo check duel and controlled by enemy
                            if( Target && targetPlayer->IsWithinDistInMap(Target, radius) &&
                                targetPlayer->getClass() == Target->getClass() &&
                                !m_caster->IsHostileTo(Target) )
                            {
                                AddUnitTarget(Target, i);
                            }
                        }
                    }
                    else if(m_targets.getUnitTarget())
                        AddUnitTarget(m_targets.getUnitTarget(), i);
                    break;
                }
            }
        }

        if(!unitList.empty())
        {
            if(uint32 maxTargets = m_spellValue->MaxAffectedTargets)
            {
                Unit::AuraEffectList const& Auras = m_caster->GetAurasByType(SPELL_AURA_MOD_MAX_AFFECTED_TARGETS);
                for(Unit::AuraEffectList::const_iterator j = Auras.begin();j != Auras.end(); ++j)
                    if((*j)->isAffectedOnSpell(m_spellInfo))
                        maxTargets += (*j)->GetAmount();

                if(m_spellInfo->Id == 5246) //Intimidating Shout
                    unitList.remove(m_targets.getUnitTarget());
                CW::RandomResizeList(unitList, m_spellValue->MaxAffectedTargets);
            }
            else
            {
                switch (m_spellInfo->Id)
                {
                    case 27285: // Seed of Corruption proc spell
                        unitList.remove(m_targets.getUnitTarget());
                        break;
                    case 55789: // Improved Icy Talons
                    case 59725: // Improved Spell Reflection - aoe aura
                        unitList.remove(m_caster);
                        break;
                    case 57669: //Replenishment (special target selection) 10 targets with lowest mana
                    {
                        typedef std::priority_queue<PrioritizeManaUnitWraper, std::vector, PrioritizeMana> TopMana;
                        TopMana manaUsers;
                        for (std::list<Unit*>::iterator itr = unitList.begin() ; itr != unitList.end();++itr)
                        {
                            if ((*itr)->getPowerType() == POWER_MANA)
                            {
                                PrioritizeManaUnitWraper  WTarget(*itr);
                                manaUsers.push(WTarget);
                            }
                        }

                        unitList.clear();
                        while(!manaUsers.empty() && unitList.size()<10)
                        {
                            unitList.push_back(manaUsers.top().getUnit());
                            manaUsers.pop();
                        }
                        break;
                    }
                    case 52759: // Ancestral Awakening
                    {
                        typedef std::priority_queue<PrioritizeHealthUnitWraper, std::vector, PrioritizeHealth> TopHealth;
                        TopHealth healedMembers;
                        for (std::list<Unit*>::iterator itr = unitList.begin() ; itr != unitList.end();++itr)
                        {
                            PrioritizeHealthUnitWraper  WTarget(*itr);
                            healedMembers.push(WTarget);
                        }

                        unitList.clear();
                        while(!healedMembers.empty() && unitList.size()<1) { unitList.push_back(healedMembers.top().getUnit()); healedMembers.pop(); } break; } } if (m_spellInfo->EffectImplicitTargetA[i] == TARGET_DEST_TARGET_ANY
                    && m_spellInfo->EffectImplicitTargetB[i] == TARGET_UNIT_AREA_ALLY_DST)// Wild Growth, Circle of Healing, Glyph of holy light target special selection
                {
                    typedef std::priority_queue<PrioritizeHealthUnitWraper, std::vector, PrioritizeHealth> TopHealth;
                    TopHealth healedMembers;
                    for (std::list<Unit*>::iterator itr = unitList.begin() ; itr != unitList.end();++itr)
                    {
                        if ((*itr)->IsInRaidWith(m_targets.getUnitTarget()))
                        {
                            PrioritizeHealthUnitWraper  WTarget(*itr);
                            healedMembers.push(WTarget);
                        }
                    }

                    unitList.clear();
                    uint32 maxsize = 5;

                    if (m_spellInfo->SpellFamilyName == SPELLFAMILY_DRUID && m_spellInfo->SpellFamilyFlags[1] & 0x04000000)
                        maxsize += m_caster->HasAura(62970) ? 1 : 0;

                    while(!healedMembers.empty() && unitList.size()<maxsize) { unitList.push_back(healedMembers.top().getUnit()); healedMembers.pop(); } } // Death Pact if (m_spellInfo->SpellFamilyName == SPELLFAMILY_DEATHKNIGHT && m_spellInfo->SpellFamilyFlags[0] & 0x00080000)
                {
                    Unit * unit_to_add = NULL;
                    for (std::list<Unit*>::iterator itr = unitList.begin() ; itr != unitList.end();++itr)
                    {
                        if ((*itr)->GetTypeId() == TYPEID_UNIT
                            && (*itr)->GetOwnerGUID() == m_caster->GetGUID()
                            && ((Creature*)(*itr))->GetCreatureInfo()->type == CREATURE_TYPE_UNDEAD)
                        {
                            unit_to_add = (*itr);
                            break;
                        }
                    }
                    if (unit_to_add)
                    {
                        unitList.clear();
                        unitList.push_back(unit_to_add);
                    }
                    // Pet not found - remove cooldown
                    else
                    {
                        if (modOwner->GetTypeId()==TYPEID_PLAYER)
                            modOwner->RemoveSpellCooldown(m_spellInfo->Id,true);
                        SendCastResult(SPELL_FAILED_NO_PET);
                        finish(false);
                    }
                }
            }
            for(std::list<Unit*>::iterator itr = unitList.begin(); itr != unitList.end(); ++itr)
                AddUnitTarget(*itr, i);
        }
    }
}

Ascent:

/// Function pointer holder
pSpellTarget SpellTargetHandler[TOTAL_SPELL_TARGET] = 
{
	&Spell::SpellTargetDefault,						// 0
	&Spell::SpellTargetSelf,						// 1
	&Spell::SpellTargetNULL,						// 2 Not handled (Test spells)
	&Spell::SpellTargetInvisibleAOE,				// 3
	&Spell::SpellTargetFriendly,					// 4
	&Spell::SpellTargetPet,							// 5
	&Spell::SpellTargetSingleTargetEnemy,			// 6
	&Spell::SpellTargetNULL,						// 7
	&Spell::SpellTargetCustomAreaOfEffect,			// 8
	&Spell::SpellTargetNULL,						// 9 Not handled (no spells)
	&Spell::SpellTargetNULL,						// 10 Not handled (no spells)
	&Spell::SpellTargetNULL,						// 11 Not handled (Test spells)
	&Spell::SpellTargetNULL,						// 12 Not handled (no spells)
	&Spell::SpellTargetNULL,						// 13 Not handled (no spells)
	&Spell::SpellTargetNULL,						// 14 Not handled (no spells)
	&Spell::SpellTargetAreaOfEffect,				// 15
	&Spell::SpellTargetAreaOfEffect,				// 16
	&Spell::SpellTargetNULL,						// 17 Target is a location
	&Spell::SpellTargetLandUnderCaster,				// 18
	&Spell::SpellTargetNULL,						// 19 Not handled (Test spells)
	&Spell::SpellTargetAllPartyMembersRangeNR,		// 20
	&Spell::SpellTargetSingleTargetFriend,			// 21
	&Spell::SpellTargetAoE,							// 22
	&Spell::SpellTargetSingleGameobjectTarget,		// 23
	&Spell::SpellTargetInFrontOfCaster,				// 24
	&Spell::SpellTargetSingleFriend,				// 25
	&Spell::SpellTargetGameobject_itemTarget,		// 26
	&Spell::SpellTargetPetOwner,					// 27
	&Spell::SpellTargetEnemysAreaOfEffect,			// 28 channeled
	&Spell::SpellTargetTypeTAOE,					// 29
	&Spell::SpellTargetAllyBasedAreaEffect,			// 30
	&Spell::SpellTargetScriptedEffects,				// 31
	&Spell::SpellTargetSummon,						// 32
	&Spell::SpellTargetNearbyPartyMembers,			// 33
	&Spell::SpellTargetNULL,						// 34 Not handled (No spells)
	&Spell::SpellTargetSingleTargetPartyMember,		// 35
	&Spell::SpellTargetScriptedEffects2,			// 36
	&Spell::SpellTargetPartyMember,					// 37
	&Spell::SpellTargetDummyTarget,					// 38
	&Spell::SpellTargetFishing,						// 39
	&Spell::SpellTargetType40,						// 40
	&Spell::SpellTargetTotem,						// 41
	&Spell::SpellTargetTotem,						// 42
	&Spell::SpellTargetTotem,						// 43
	&Spell::SpellTargetTotem,						// 44
	&Spell::SpellTargetChainTargeting,				// 45
	&Spell::SpellTargetSimpleTargetAdd,				// 46
	&Spell::SpellTargetSimpleTargetAdd,				// 47
	&Spell::SpellTargetSimpleTargetAdd,				// 48
	&Spell::SpellTargetSimpleTargetAdd,				// 49
	&Spell::SpellTargetSimpleTargetAdd,				// 50
	&Spell::SpellTargetNULL,						// 51
	&Spell::SpellTargetSimpleTargetAdd,				// 52
	&Spell::SpellTargetTargetAreaSelectedUnit,		// 53
	&Spell::SpellTargetInFrontOfCaster2,			// 54
	&Spell::SpellTargetNULL,						// 55 Not handled (Not realy handled by the current spell system)
	&Spell::SpellTarget56,							// 56
	&Spell::SpellTargetTargetPartyMember,			// 57
	&Spell::SpellTargetNULL,						// 58
	&Spell::SpellTargetNULL,						// 59
	&Spell::SpellTargetNULL,						// 60 // scripted target fill..
	&Spell::SpellTargetSameGroupSameClass,			// 61
	&Spell::SpellTargetNULL,						// 62 // targets the priest champion, big range..
	&Spell::SpellTargetScriptedEffects,				// 63 // summon [] creature
	&Spell::SpellTargetSimpleTargetAdd,				// 64 // summon [] creature
	&Spell::SpellTargetSimpleTargetAdd,				// 65 // summon [] creature
	&Spell::SpellTargetSimpleTargetAdd,				// 66 // summon [] creature
	&Spell::SpellTargetSimpleTargetAdd,				// 67 // summon [] creature
	&Spell::SpellTargetNULL,						// 68 Not handled (No spells)
	&Spell::SpellTargetTotem,						// 69 // Spitfire totem
	&Spell::SpellTargetNULL,						// 70 Not handled (No spells)
	&Spell::SpellTargetNULL,						// 71 Not handled (No spells)
	&Spell::SpellTargetSimpleTargetAdd,				// 72 // summon [] creature + trow items
	&Spell::SpellTargetSummon,						// 73
	&Spell::SpellTargetNULL,						// 74
	&Spell::SpellTargetNULL,						// 75
	&Spell::SpellTargetAllTargetsInArea,			// 76
	&Spell::SpellTargetSingleTargetEnemy,			// 77
	&Spell::SpellTargetNULL,						// 78
	&Spell::SpellTargetNULL,						// 79
	&Spell::SpellTargetNULL,						// 80
	&Spell::SpellTargetNULL,						// 81
	&Spell::SpellTargetNULL,						// 82
	&Spell::SpellTargetNULL,						// 83
	&Spell::SpellTargetNULL,						// 84
	&Spell::SpellTargetNULL,						// 85
	&Spell::SpellTargetNULL,						// 86
	&Spell::SpellTargetAreaOfEffect87,				// 87
	&Spell::SpellTargetNULL,						// 88
	&Spell::SpellTargetNULL,						// 89
	&Spell::SpellTargetNULL,						// 90
	&Spell::SpellTargetNULL,						// 91
	&Spell::SpellTargetNULL,						// 92
	&Spell::SpellTargetNULL,						// 93
	&Spell::SpellTargetVehicle,						// 94
	&Spell::SpellTargetNULL,						// 95
	&Spell::SpellTargetNULL,						// 96
	&Spell::SpellTargetNULL,						// 97
	&Spell::SpellTargetNULL,						// 98
	&Spell::SpellTargetNULL,						// 99
	&Spell::SpellTargetNULL,						// 100
	// all 100 > n spelltargettype's are from test spells
};

/* LEFTOVER RESEARCH, this contains note's comments from Captnoord
// these are left here because of the importance's of the info.
// comments and additional information related to this send to Captnoord

// Type 4:
// 4 is related to Diseases fun to give it a try..
// dono related to "Wandering Plague", "Spirit Steal", "Contagion of Rot", "Retching Plague" and "Copy of Wandering Plague"

// Type 7:
// Point Blank Area of Effect
// think its wrong, related to 2 spells, "Firegut Fear Storm" and "Mind Probe"
// FillAllTargetsInArea(tmpMap,m_targets.m_destX,m_targets.m_destY,m_targets.m_destZ,GetRadius(i));

//fear storm is nice
//Score 5.7	 Vote: [-] [+] by plle, 1.5 years ago
//when you set that ogre head on the top of the rock and all orges see it they /yell: FLEE (and) RUN!!
//and then all ogres get fear storm =D 

//this quest
//Score 6.9	 Vote: [-] [+] by ewendim, 1.1 years ago
//happens while doing this quest http://www.thottbot.com/?qu=3825

// Type 11
// this is related to spellID: 4, as I think is a gm spell

// 11 select id,name, EffectImplicitTargetA1 from spell where EffectImplicitTargetA1 = 11;
// +----+----------------------+------------------------+
// | id | name				 | EffectImplicitTargetA1 |
// +----+----------------------+------------------------+
// |  4 | Word of Recall Other |					 11 |
// +----+----------------------+------------------------+

// type 17:
// spells like 17278:Cannon Fire and 21117:Summon Son of Flame A
// A single target at a xyz location or the target is a possition xyz

// select id,name, EffectImplicitTargetA1 from spell where EffectImplicitTargetB1 = 9;
// +-------+----------------------------+------------------------+
// | id	| name					   | EffectImplicitTargetA1 |
// +-------+----------------------------+------------------------+
// |	 1 | Word of Recall (OLD)	   |					  1 |
// |	 3 | Word of Mass Recall (OLD)  |					 20 |
// |   556 | Astral Recall			  |					  1 |
// |  8690 | Hearthstone				|					  1 |
// | 39937 | There's No Place Like Home |					  1 |
// +-------+----------------------------+------------------------+

// type 10: is not used
// type 12: is not used
// type 13: is not used
// type 14: is not used

// type 19: is target zone I think (test spells)

// type 48: is summon wild unit
// type 49: is summon friend unit
// type 50: something related to the pref 2
// type 51: is targeting objects / egg's / possible to use those while flying


// type 55 related to blink and Netherstep... I think this one sets the xyz where you should end...
// type 56 is related to aura holder... Player 1 give's me a aura and that aura has as target me. I wear then the aura / spell and it targeting me

// type 58 proc triggeret target... 
// Apply Aura: Proc Trigger Spell
// Retching Plague
// 10% chance.

// type 59 related to 2 visual spells
// type 60 1 target related. rest is unknown or not clear

// type 62 targets the best player of [class]
// type 63 targets chess player... something like that
// type 64 something related to wharp storm... and the wharpstorm creature..
// type 65 target enemy's weapon... Item target..... "A" target type, "B" target type is target enemy unit...
// type 66 related to summon some unit...
// type 67 related to summon some unit...
// type 68 is not used
// type 69 is totem stuff level 70 totem stuff
// type 70 is not used
// type 71 is not used
// type 72 target enemy unit... (I think it does not matter if its a friendly unit)
// type 73 is serverside scripted.... Mostly summons
// type 74 Target Random Enemy
// type 75 Target location in front of the caster
// type 76 target a area... of target...
// type 77 target single enemy
// type 78 units in front of caster ( test spell )
// type 79 is not used
// type 80 related to summon some unit
// type 81 > N are not handled because they are test spells 

*/

¿Te fue útil este post?

0 puntos
Nuevo

Escrito por Inamsay

El objetivo de Inamsay.com es ayudar a educar y mejorar las habilidades de cualquier persona interesada en la tecnología.

3 Comments

Leave a Reply

Deja un comentario

Atajos de teclado para Adobe Photoshop

Guia de como escribir un Scripts en LUA