当前位置: 首页>>代码示例>>C++>>正文


C++ CastSpell函数代码示例

本文整理汇总了C++中CastSpell函数的典型用法代码示例。如果您正苦于以下问题:C++ CastSpell函数的具体用法?C++ CastSpell怎么用?C++ CastSpell使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。


在下文中一共展示了CastSpell函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: AIUpdate

	void AIUpdate()
	{
		if((GetHealthPercent() <= 85  && mSummon == 0) || 
			( GetHealthPercent() <= 70 && mSummon == 1 ) ||
			( GetHealthPercent() <= 55 && mSummon == 2 ) ||
			( GetHealthPercent() <= 40 && mSummon == 3 ) || 
		( GetHealthPercent() <= 25 && mSummon == 4 ))
		{
			CastSpell(mPureEnergy);
			++mSummon;
			//SpawnCreature(CN_PURE_ENERGY, 231, -207, 6, 0, true);
		}

		if( GetHealthPercent() <= 10 && GetPhase() == 1 )
			SetPhase(2);
	
		
		ParentClass::AIUpdate();
	} 
开发者ID:AscNHalf,项目名称:AscNHalf,代码行数:19,代码来源:Instance_MagistersTerrace.cpp

示例2: GetPlayerBot

bool PlayerbotPaladinAI::ChangeAura(uint32 aura)
{
    Player *m_bot = GetPlayerBot();
    if(!aura) return false;

    if(!CanCast(aura,m_bot)) return false;

    if(m_bot->HasAura(aura))
    {
        if (aura == DEVOTION_AURA)
        {
            if (ChangeAura(FIRE_AURA)) return true;
            if (ChangeAura(FROST_AURA)) return true;
            if (ChangeAura(SHADOW_AURA)) return true;
            return true;
        }
        else return ChangeAura(DEVOTION_AURA);
    }
    return CastSpell(aura,m_bot,false);
}
开发者ID:Crash911,项目名称:RaptoredSkyFire,代码行数:20,代码来源:PlayerbotPaladinAI.cpp

示例3: _DoNextPVECombatManeuverHeal

CombatManeuverReturns PlayerbotDruidAI::_DoNextPVECombatManeuverHeal()
{
    if (!m_ai)  return RETURN_NO_ACTION_ERROR;
    if (!m_bot) return RETURN_NO_ACTION_ERROR;

    // (un)Shapeshifting is considered one step closer so will return true (and have the bot wait a bit for the GCD)
    if (TREE_OF_LIFE > 0 && !m_bot->HasAura(TREE_OF_LIFE, EFFECT_INDEX_0))
        if (CastSpell(TREE_OF_LIFE, m_bot))
            return RETURN_CONTINUE;

    if (m_bot->HasAura(CAT_FORM, EFFECT_INDEX_0))
    {
        m_bot->RemoveAurasDueToSpell(CAT_FORM_1);
        //m_ai->TellMaster("FormClearCat");
        return RETURN_CONTINUE;
    }
    if (m_bot->HasAura(BEAR_FORM, EFFECT_INDEX_0))
    {
        m_bot->RemoveAurasDueToSpell(BEAR_FORM_1);
        //m_ai->TellMaster("FormClearBear");
        return RETURN_CONTINUE;
    }
    if (m_bot->HasAura(DIRE_BEAR_FORM, EFFECT_INDEX_0))
    {
        m_bot->RemoveAurasDueToSpell(DIRE_BEAR_FORM_1);
        //m_ai->TellMaster("FormClearDireBear");
        return RETURN_CONTINUE;
    }
    // spellcasting form, but disables healing spells so it's got to go
    if (m_bot->HasAura(MOONKIN_FORM, EFFECT_INDEX_0))
    {
        m_bot->RemoveAurasDueToSpell(MOONKIN_FORM_1);
        //m_ai->TellMaster("FormClearMoonkin");
        return RETURN_CONTINUE;
    }

    if (HealPlayer(GetHealTarget()) & (RETURN_NO_ACTION_OK | RETURN_CONTINUE))
        return RETURN_CONTINUE;

    return RETURN_NO_ACTION_UNKNOWN;
}
开发者ID:jpiolho,项目名称:portalclassic,代码行数:41,代码来源:PlayerbotDruidAI.cpp

示例4: GetPlayerBot

bool PlayerbotShamanAI::HealTarget(Unit *target, uint8 hp)
{
    if(!target || target->isDead()) return false;
    Player *m_bot = GetPlayerBot();

    if(hp < 30 && m_bot->isInCombat() && CastSpell(NATURES_SWIFTNESS, m_bot)) {} // NO gcd
    if(hp < 60 && CanCast(HEAL,target,true) && m_bot->HasAura(NATURES_SWIFTNESS) && CastSpell(HEAL, target, false)) { return true; }
    if(hp < 30 && CastSpell(LESSER_HEAL,target,true,true)) { return true; }
    if(hp < 40 && m_bot->getRace() == (uint8) RACE_DRAENEI && CastSpell(R_GIFT_OF_NAARU,target)) {} // no GCD
    if(hp < 65 && CanCast(EARTH_SHIELD,target) && !m_bot->HasAura(EARTH_SHIELD,m_bot->GetGUID()) && CastSpell(EARTH_SHIELD,target,false)) { return true; }
    if(hp < 65 && CastSpell(HEAL,target,true,true)) { return true; }
    if(hp < 85 && CastSpell(LESSER_HEAL,target,true,true)) { return true; }

    return false;
} //end HealTarget
开发者ID:Anonymus111,项目名称:chaoscore,代码行数:15,代码来源:PlayerbotShamanAI.cpp

示例5: GetSpellStore

bool PlayerbotClassAI::castDispel (uint32 dispelSpell, Unit *dTarget, bool checkFirst, bool castExistingAura, bool skipFriendlyCheck, bool skipEquipStanceCheck)
{
    if (dispelSpell == 0 || !dTarget ) return false;
    //if (!canCast(dispelSpell, dTarget, true)) return false; //Needless cpu cycles wasted, usually a playerbot can cast a dispell
    const SpellEntry *dSpell = GetSpellStore()->LookupEntry(dispelSpell);
    if (!dSpell) return false;

    for (uint8 i = 0 ; i < MAX_SPELL_EFFECTS ; ++i)
    {
        if (dSpell->Effect[i] != (uint32)SPELL_EFFECT_DISPEL) continue;
        uint32 dispel_type = dSpell->EffectMiscValue[i];
        uint32 dispelMask  = GetDispellMask(DispelType(dispel_type));
        Unit::AuraMap const& auras = dTarget->GetOwnedAuras();
        for (Unit::AuraMap::const_iterator itr = auras.begin(); itr != auras.end(); itr++)
        {
            Aura * aura = itr->second;
            AuraApplication * aurApp = aura->GetApplicationOfTarget(dTarget->GetGUID());
            if (!aurApp)
                continue;

            if ((1<<aura->GetSpellProto()->Dispel) & dispelMask)
            {
                if(aura->GetSpellProto()->Dispel == DISPEL_MAGIC)
                {
                    bool positive = aurApp->IsPositive() ? (!(aura->GetSpellProto()->AttributesEx & SPELL_ATTR0_UNK7)) : false;

                    // do not remove positive auras if friendly target
                    //               negative auras if non-friendly target
                    if(positive == dTarget->IsFriendlyTo(GetPlayerBot()))
                        continue;
                }
                // If there is a successfull match return, else continue searching.
                if (CastSpell(dSpell, dTarget, checkFirst, castExistingAura, skipFriendlyCheck, skipEquipStanceCheck)) {
                    return true;
                }
            }
        }
    }
    return false;
}
开发者ID:Sharki,项目名称:TC,代码行数:40,代码来源:PlayerbotClassAI.cpp

示例6: _DoNextPVECombatManeuverBear

CombatManeuverReturns PlayerbotDruidAI::_DoNextPVECombatManeuverBear(Unit* pTarget)
{
    if (!m_ai)  return RETURN_NO_ACTION_ERROR;
    if (!m_bot) return RETURN_NO_ACTION_ERROR;

    if (!m_bot->HasAura( (DIRE_BEAR_FORM > 0 ? DIRE_BEAR_FORM : BEAR_FORM) )) return RETURN_NO_ACTION_ERROR;

    // Used to determine if this bot is highest on threat
    Unit* newTarget = m_ai->FindAttacker((PlayerbotAI::ATTACKERINFOTYPE) (PlayerbotAI::AIT_VICTIMSELF | PlayerbotAI::AIT_HIGHESTTHREAT), m_bot);
    Unit* pVictim = pTarget->getVictim();

    // Face enemy, make sure you're attacking
    if (!m_bot->HasInArc(M_PI_F, pTarget))
    {
        m_bot->SetFacingTo(m_bot->GetAngle(pTarget));
        if (pVictim)
            pVictim->Attack(pTarget, true);
    }

    if (PlayerbotAI::ORDERS_TANK & m_ai->GetCombatOrder() && !newTarget && GROWL > 0 && !m_bot->HasSpellCooldown(GROWL))
        if (CastSpell(GROWL, pTarget))
            return RETURN_CONTINUE;

    if (FAERIE_FIRE_FERAL > 0 && m_ai->In_Reach(pTarget,FAERIE_FIRE_FERAL) && !pTarget->HasAura(FAERIE_FIRE_FERAL, EFFECT_INDEX_0))
        if (CastSpell(FAERIE_FIRE_FERAL, pTarget))
            return RETURN_CONTINUE;

    if (SWIPE > 0 && m_ai->In_Reach(pTarget,SWIPE) && m_ai->GetAttackerCount() >= 2 && CastSpell(SWIPE, pTarget))
        return RETURN_CONTINUE;

    if (ENRAGE > 0 && !m_bot->HasSpellCooldown(ENRAGE) && CastSpell(ENRAGE, m_bot))
        return RETURN_CONTINUE;

    if (DEMORALIZING_ROAR > 0 && !pTarget->HasAura(DEMORALIZING_ROAR, EFFECT_INDEX_0) && CastSpell(DEMORALIZING_ROAR, pTarget))
        return RETURN_CONTINUE;

    if (MANGLE_BEAR > 0 && !pTarget->HasAura(MANGLE_BEAR) && CastSpell(MANGLE_BEAR, pTarget))
        return RETURN_CONTINUE;

    if (LACERATE > 0 && !pTarget->HasAura(LACERATE, EFFECT_INDEX_0) && CastSpell(LACERATE, pTarget))
        return RETURN_CONTINUE;

    if (MAUL > 0 && CastSpell(MAUL, pTarget))
        return RETURN_CONTINUE;

    return RETURN_NO_ACTION_UNKNOWN;
}
开发者ID:jpiolho,项目名称:portalclassic,代码行数:47,代码来源:PlayerbotDruidAI.cpp

示例7: GetAI

void PlayerbotPaladinAI::DoNonCombatActions()
{
    PlayerbotAI *ai = GetAI();
    Player *m_bot = GetPlayerBot();
    if (!m_bot || !ai || m_bot->isDead()) { return; }

    //If Casting or Eating/Drinking return
    if (m_bot->HasUnitState(UNIT_STATE_CASTING)) { return; }
    if (m_bot->getStandState() == UNIT_STAND_STATE_SIT) { return; }

    //buff and heal raid
    if (DoSupportRaid(m_bot)) { return; }

    //heal pets and bots
    Unit *target = DoSelectLowestHpFriendly(40, 1000);
    if (target && target->isAlive() && HealTarget(target, target->GetHealth()*100 / target->GetMaxHealth())) { return; }

    //mana/hp check
    //Don't bother with eating, if low on hp, just let it heal themself
    if (m_bot->getRace() == (uint8) RACE_UNDEAD_PLAYER && ai->GetHealthPercent() < 75 && CastSpell(R_CANNIBALIZE,m_bot)) { return; }
    if (m_bot->GetHealth() < m_bot->GetMaxHealth() && CastSpell(FLASH_OF_LIGHT,m_bot)) { return; }
    if (ai->GetManaPercent() < 70) { ai->Feast(); }
} //end DoNonCombatActions
开发者ID:Crash911,项目名称:RaptoredSkyFire,代码行数:23,代码来源:PlayerbotPaladinAI.cpp

示例8: data

void Totem::InitStats(uint32 duration)
{
    // client requires SMSG_TOTEM_CREATED to be sent before adding to world and before removing old totem
    if (m_owner->GetTypeId() == TYPEID_PLAYER
        && m_Properties->Slot >= SUMMON_SLOT_TOTEM
        && m_Properties->Slot < MAX_TOTEM_SLOT)
    {
        WorldPacket data(SMSG_TOTEM_CREATED, 1 + 8 + 4 + 4);
        data << uint8(m_Properties->Slot - 1);
        data << uint64(GetGUID());
        data << uint32(duration);
        data << uint32(GetUInt32Value(UNIT_CREATED_BY_SPELL));
        m_owner->ToPlayer()->SendDirectMessage(&data);

        // set display id depending on caster's race
        SetDisplayId(m_owner->GetModelForTotem(PlayerTotemType(m_Properties->Id)));
    }

    if (m_owner->GetDummyAuraEffect(SPELLFAMILY_GENERIC, 2019, EFFECT_0))
        if (m_Properties->Slot == SUMMON_SLOT_TOTEM)
            CastSpell(this, 77747, true);

    Minion::InitStats(duration);

    // Get spell cast by totem
    if (SpellInfo const* totemSpell = sSpellMgr->GetSpellInfo(GetSpell()))
        if (totemSpell->CalcCastTime())   // If spell has cast time -> its an active totem
            m_type = TOTEM_ACTIVE;

    if (GetEntry() == SENTRY_TOTEM_ENTRY)
        SetReactState(REACT_AGGRESSIVE);

    m_duration = duration;

    SetLevel(m_owner->getLevel());
}
开发者ID:beyourself,项目名称:Wow-4.3.4,代码行数:36,代码来源:Totem.cpp

示例9: GetHealTarget

CombatManeuverReturns PlayerbotPriestAI::HealPlayer(Player* target)
{
    CombatManeuverReturns r = PlayerbotClassAI::HealPlayer(target);
    if (r != RETURN_NO_ACTION_OK)
        return r;

    if (!target->isAlive())
    {
        if (RESURRECTION && m_ai->In_Reach(target,RESURRECTION) && m_ai->CastSpell(RESURRECTION, *target))
        {
            std::string msg = "Resurrecting ";
            msg += target->GetName();
            m_bot->Say(msg, LANG_UNIVERSAL);
            return RETURN_CONTINUE;
        }
        return RETURN_NO_ACTION_ERROR; // not error per se - possibly just OOM
    }

    // Remove negative magic on group members if orders allow bot to do so
    if (Player* pCursedTarget = GetDispelTarget(DISPEL_MAGIC))
    {
        if (PRIEST_DISPEL_MAGIC > 0 && (m_ai->GetCombatOrder() & PlayerbotAI::ORDERS_NODISPEL) == 0 && CastSpell(PRIEST_DISPEL_MAGIC, pCursedTarget))
            return RETURN_CONTINUE;
    }

    // Remove disease on group members if orders allow bot to do so
    if (Player* pDiseasedTarget = GetDispelTarget(DISPEL_DISEASE))
    {
        uint32 cure = ABOLISH_DISEASE > 0 ? ABOLISH_DISEASE : CURE_DISEASE;
        // uint32 poison = ABOLISH_POISON ? ABOLISH_POISON : CURE_POISON;
        if (cure > 0 && (m_ai->GetCombatOrder() & PlayerbotAI::ORDERS_NODISPEL) == 0 && CastSpell(cure, pDiseasedTarget))
            return RETURN_CONTINUE;
    }

    uint8 hp = target->GetHealthPercent();
    uint8 hpSelf = m_ai->GetHealthPercent();

    // Define a tank bot will look at
    Unit* pMainTank = GetHealTarget(JOB_TANK);

    if (hp >= 90)
        return RETURN_NO_ACTION_OK;

    // If target is out of range (40 yards) and is a tank: move towards it
    // Other classes have to adjust their position to the healers
    // TODO: This code should be common to all healers and will probably
    // move to a more suitable place
    if (pMainTank && !m_ai->In_Reach(pMainTank, FLASH_HEAL))
    {
        m_bot->GetMotionMaster()->MoveFollow(target, 39.0f, m_bot->GetOrientation());
        return RETURN_CONTINUE;
    }

    // Get a free and more efficient heal if needed: low mana for bot or average health for target
    if (m_ai->IsInCombat() && (hp < 50 || m_ai->GetManaPercent() < 40))
        if (INNER_FOCUS > 0 && m_bot->IsSpellReady(INNER_FOCUS) && !m_bot->HasAura(INNER_FOCUS, EFFECT_INDEX_0) && CastSpell(INNER_FOCUS, m_bot))
            return RETURN_CONTINUE;

    if (hp < 25 && POWER_WORD_SHIELD > 0 && m_ai->In_Reach(target,POWER_WORD_SHIELD) && !m_bot->HasAura(POWER_WORD_SHIELD, EFFECT_INDEX_0) && !target->HasAura(WEAKNED_SOUL,EFFECT_INDEX_0) && m_ai->CastSpell(POWER_WORD_SHIELD, *target))
        return RETURN_CONTINUE;
    if (hp < 35 && FLASH_HEAL > 0 && m_ai->In_Reach(target,FLASH_HEAL) && m_ai->CastSpell(FLASH_HEAL, *target))
        return RETURN_CONTINUE;
    if (hp < 50 && GREATER_HEAL > 0 && m_ai->In_Reach(target,GREATER_HEAL) && m_ai->CastSpell(GREATER_HEAL, *target))
        return RETURN_CONTINUE;
    // Heals target AND self for equal amount
    if (hp < 60 && hpSelf < 80 && BINDING_HEAL > 0 && m_ai->In_Reach(target,BINDING_HEAL) && m_ai->CastSpell(BINDING_HEAL, *target))
        return RETURN_CONTINUE;
    if (hp < 60 && PRAYER_OF_MENDING > 0 && m_ai->In_Reach(target,PRAYER_OF_MENDING) && !target->HasAura(PRAYER_OF_MENDING, EFFECT_INDEX_0) && CastSpell(PRAYER_OF_MENDING, target))
        return RETURN_FINISHED_FIRST_MOVES;
    if (hp < 70 && HEAL > 0 && m_ai->In_Reach(target,HEAL) && m_ai->CastSpell(HEAL, *target))
        return RETURN_CONTINUE;
    if (hp < 90 && RENEW > 0 && m_ai->In_Reach(target,RENEW) && !target->HasAura(RENEW) && m_ai->CastSpell(RENEW, *target))
        return RETURN_CONTINUE;

    // Group heal. Not really useful until a group check is available?
    //if (hp < 40 && PRAYER_OF_HEALING > 0 && m_ai->CastSpell(PRAYER_OF_HEALING, *target) & RETURN_CONTINUE)
    //    return RETURN_CONTINUE;
    // Group heal. Not really useful until a group check is available?
    //if (hp < 50 && CIRCLE_OF_HEALING > 0 && m_ai->CastSpell(CIRCLE_OF_HEALING, *target) & RETURN_CONTINUE)
    //    return RETURN_CONTINUE;

    return RETURN_NO_ACTION_OK;
} // end HealTarget
开发者ID:krullgor,项目名称:mangos-tbc,代码行数:83,代码来源:PlayerbotPriestAI.cpp

示例10: return

bool Client::UseDiscipline(uint32 spell_id, uint32 target) {
    // Dont let client waste a reuse timer if they can't use the disc
    if (IsStunned() || IsFeared() || IsMezzed() || IsAmnesiad() || IsPet())
    {
        return(false);
    }

    //make sure we have the spell...
    int r;
    for(r = 0; r < MAX_PP_DISCIPLINES; r++) {
        if(m_pp.disciplines.values[r] == spell_id)
            break;
    }
    if(r == MAX_PP_DISCIPLINES)
        return(false);	//not found.

    //Check the disc timer
    pTimerType DiscTimer = pTimerDisciplineReuseStart + spells[spell_id].EndurTimerIndex;
    if(!p_timers.Expired(&database, DiscTimer)) {
        /*char val1[20]={0};*/	//unused
        /*char val2[20]={0};*/	//unused
        uint32 remain = p_timers.GetRemainingTime(DiscTimer);
        //Message_StringID(0, DISCIPLINE_CANUSEIN, ConvertArray((remain)/60,val1), ConvertArray(remain%60,val2));
        Message(0, "You can use this discipline in %d minutes %d seconds.", ((remain)/60), (remain%60));
        return(false);
    }

    //make sure we can use it..
    if(!IsValidSpell(spell_id)) {
        Message(13, "This tome contains invalid knowledge.");
        return(false);
    }

    //can we use the spell?
    const SPDat_Spell_Struct &spell = spells[spell_id];
    uint8 level_to_use = spell.classes[GetClass() - 1];
    if(level_to_use == 255) {
        Message(13, "Your class cannot learn from this tome.");
        //should summon them a new one...
        return(false);
    }

    if(level_to_use > GetLevel()) {
        Message_StringID(13, DISC_LEVEL_USE_ERROR);
        //should summon them a new one...
        return(false);
    }

    if(GetEndurance() > spell.EndurCost) {
        SetEndurance(GetEndurance() - spell.EndurCost);
    } else {
        Message(11, "You are too fatigued to use this skill right now.");
        return(false);
    }

    if(spell.recast_time > 0)
    {
        uint32 reduced_recast = spell.recast_time / 1000;
        reduced_recast -= CastToClient()->GetFocusEffect(focusReduceRecastTime, spell_id);
        if(reduced_recast < 0)
            reduced_recast = 0;

        CastSpell(spell_id, target, DISCIPLINE_SPELL_SLOT, -1, -1, 0, -1, (uint32)DiscTimer, reduced_recast);
        if(spells[spell_id].EndurTimerIndex < MAX_DISCIPLINE_TIMERS)
        {
            EQApplicationPacket *outapp = new EQApplicationPacket(OP_DisciplineTimer, sizeof(DisciplineTimer_Struct));
            DisciplineTimer_Struct *dts = (DisciplineTimer_Struct *)outapp->pBuffer;
            dts->TimerID = spells[spell_id].EndurTimerIndex;
            dts->Duration = reduced_recast;
            QueuePacket(outapp);
            safe_delete(outapp);
        }
    }
    else
    {
        CastSpell(spell_id, target, DISCIPLINE_SPELL_SLOT);
    }
    return(true);
}
开发者ID:regneq,项目名称:projecteqemu,代码行数:79,代码来源:effects.cpp

示例11: AIUpdate

	void AIUpdate()
	{
		float OggCast = (float)RandomFloat(100.0f);
		CastSpell(OggCast);
	}
开发者ID:xiaofeng,项目名称:Arcemu,代码行数:5,代码来源:Instance_RagefireChasm.cpp

示例12: GetAI

bool PlayerbotShamanAI::ChangeTotems(uint32 mode)
{
    uint32 earth=0, fire=0, water=0, air=0;

    PlayerbotAI *ai = GetAI();
    if(!ai) return false;
    Player *m_bot = GetPlayerBot();
    if(!m_bot || m_bot->isDead()) return false;

    Unit *pTarget = m_bot->GetSelectedUnit();
    Unit *pVictim = NULL;
    if (m_bot->GetSelectedUnit()->IsFriendlyTo(m_bot)) pTarget = NULL;
    if (pTarget) pVictim = pTarget->getVictim();

    //Defaults
    if (!HasAuraName(m_bot,"Horn of Winter") )earth = STRENGTH_OF_EARTH_TOTEM;
    if (!earth) earth = STONESKIN_TOTEM;
    if (!earth) earth = EARTHBIND_TOTEM;
    fire = TOTEM_OF_WRATH;
    if (!fire) fire = FLAMETONGUE_TOTEM;
    if (!fire) fire = SEARING_TOTEM;
    water = MANA_SPRING_TOTEM;
    if (!water) water = HEALING_STREAM_TOTEM;
    if (TALENT_ELEMENTAL || TALENT_RESTO) air = WRATH_OF_AIR_TOTEM;
    else air = WINDFURY_TOTEM;

    //Target reactive stuff
    if (pTarget)
    {
        if (GROUNDING_TOTEM && pTarget->IsNonMeleeSpellCasted(true)) air = GROUNDING_TOTEM;
    }

    if (STONESKIN_TOTEM && isUnderAttack()) earth = STONESKIN_TOTEM;

    uint32 totz[4] = {earth, fire, water, air};

    for (int i = 0; i < 4; i++)
    {
        if (!totz[i]) continue;
        SpellEntry const *tSpell = GetSpellStore()->LookupEntry(totz[i]);
        if (!tSpell) continue;
        uint32 tEntry = (uint32) tSpell->EffectMiscValue[0];
        if (!tEntry) continue;
        CreatureTemplate const *totemEntry = sObjectMgr->GetCreatureTemplate(tEntry);
        if (!tEntry) continue;

        if (CanCast(totz[i], m_bot) && !m_bot->FindNearestCreature(tEntry,30)) { return CastSpell(totz[i],m_bot,false); }
    }
    return false;
}
开发者ID:Anonymus111,项目名称:chaoscore,代码行数:50,代码来源:PlayerbotShamanAI.cpp

示例13: CastSpell

// Decision tree for putting a curse on the current target
bool PlayerbotWarlockAI::CheckCurse(Unit* pTarget)
{
    Creature * pCreature = (Creature*) pTarget;
    uint32 CurseToCast = 0;

    // Prevent low health humanoid from fleeing or fleeing too fast
    // Curse of Exhaustion first to avoid increasing damage output on tank
    if (pCreature && pCreature->GetCreatureInfo()->CreatureType == CREATURE_TYPE_HUMANOID && pTarget->GetHealthPercent() < 20 && !pCreature->IsWorldBoss())
    {
        if (CURSE_OF_EXHAUSTION && m_ai->In_Reach(pTarget,CURSE_OF_EXHAUSTION) && !pTarget->HasAura(CURSE_OF_EXHAUSTION))
        {
            if (AMPLIFY_CURSE && m_bot->IsSpellReady(AMPLIFY_CURSE))
                CastSpell(AMPLIFY_CURSE, m_bot);

            if (CastSpell(CURSE_OF_EXHAUSTION, pTarget))
            {
                m_CurrentCurse = CURSE_OF_EXHAUSTION;
                return true;
            }
        }
        else if (CURSE_OF_RECKLESSNESS && m_ai->In_Reach(pTarget,CURSE_OF_RECKLESSNESS) && !pTarget->HasAura(CURSE_OF_RECKLESSNESS) && !pTarget->HasAura(CURSE_OF_EXHAUSTION) && CastSpell(CURSE_OF_RECKLESSNESS, pTarget))
        {
            m_CurrentCurse = CURSE_OF_RECKLESSNESS;
            return true;
        }
    }

    // If bot already put a curse and curse is still active on target: no need to go further
    if (m_CurrentCurse > 0 && pTarget->HasAura(m_CurrentCurse))
        return false;

    // No curse or effect worn off: choose again which curse to use

    // Target is a boss
    if (pCreature && pCreature->IsWorldBoss())
    {
        if (m_bot->GetGroup())
        {
            uint8 mages = 0;
            uint8 warlocks = 1;
            Group::MemberSlotList const& groupSlot = m_bot->GetGroup()->GetMemberSlots();
            for (Group::member_citerator itr = groupSlot.begin(); itr != groupSlot.end(); itr++)
            {
                Player *groupMember = sObjectMgr.GetPlayer(itr->guid);
                if (!groupMember || !groupMember->isAlive())
                    continue;
                switch (groupMember->getClass())
                {
                    case CLASS_WARLOCK:
                        warlocks++;
                        continue;
                    case CLASS_MAGE:
                        mages++;
                        continue;
                }
            }
            if (warlocks > 1 && warlocks > mages)
                CurseToCast = CURSE_OF_SHADOW;
            else if (mages > warlocks)
                CurseToCast = CURSE_OF_THE_ELEMENTS;
            else
                CurseToCast = CURSE_OF_AGONY;
        }
    // If target is not elite, no need to put a curse useful
    // in the long run: go for direct damage
    } else if (!m_ai->IsElite(pTarget))
        CurseToCast = CURSE_OF_AGONY;
    // Enemy elite mages have low health but can cast dangerous spells: group safety before bot DPS
    else if (pCreature && pCreature->GetCreatureInfo()->UnitClass == 8)
        CurseToCast = CURSE_OF_TONGUES;
    // Default case: Curse of Agony
    else
        CurseToCast = CURSE_OF_AGONY;

    // Try to curse the target with the selected curse
    if (CurseToCast && m_ai->In_Reach(pTarget,CurseToCast) && !pTarget->HasAura(CurseToCast))
    {
        if (CurseToCast == CURSE_OF_AGONY)
            if (AMPLIFY_CURSE && m_bot->IsSpellReady(AMPLIFY_CURSE))
                CastSpell(AMPLIFY_CURSE, m_bot);

        if (CastSpell(CurseToCast, pTarget))
        {
            m_CurrentCurse = CurseToCast;
            return true;
        }
    }
    // else: go for Curse of Agony
    else if (CURSE_OF_AGONY && m_ai->In_Reach(pTarget,CURSE_OF_AGONY) && !pTarget->HasAura(CURSE_OF_AGONY))
    {
        if (AMPLIFY_CURSE && m_bot->IsSpellReady(AMPLIFY_CURSE))
            CastSpell(AMPLIFY_CURSE, m_bot);

        if (CastSpell(CURSE_OF_AGONY, pTarget))
        {
            m_CurrentCurse = CURSE_OF_AGONY;
            return true;
        }
    }
//.........这里部分代码省略.........
开发者ID:zwisus,项目名称:mangos-classic,代码行数:101,代码来源:PlayerbotWarlockAI.cpp

示例14: if

CombatManeuverReturns PlayerbotWarlockAI::DoNextCombatManeuverPVE(Unit *pTarget)
{
    if (!m_ai)  return RETURN_NO_ACTION_ERROR;
    if (!m_bot) return RETURN_NO_ACTION_ERROR;

    //Unit* pVictim = pTarget->getVictim();
    bool meleeReach = m_bot->CanReachWithMeleeAttack(pTarget);
    Pet *pet = m_bot->GetPet();
    uint32 spec = m_bot->GetSpec();
    uint8 shardCount = m_bot->GetItemCount(SOUL_SHARD, false, nullptr);

    // Voidwalker is near death - sacrifice it for a shield
    if (pet && pet->GetEntry() == DEMON_VOIDWALKER && SACRIFICE && !m_bot->HasAura(SACRIFICE) && pet->GetHealthPercent() < 10)
        m_ai->CastPetSpell(SACRIFICE);

    // Use healthstone
    if (m_ai->GetHealthPercent() < 30)
    {
        Item* healthStone = m_ai->FindConsumable(HEALTHSTONE_DISPLAYID);
        if (healthStone)
            m_ai->UseItem(healthStone);
    }

    // Voidwalker sacrifice gives shield - but you lose the pet (and it's DPS/tank) - use only as last resort for your own health!
    if (m_ai->GetHealthPercent() < 20 && pet && pet->GetEntry() == DEMON_VOIDWALKER && SACRIFICE && !m_bot->HasAura(SACRIFICE))
        m_ai->CastPetSpell(SACRIFICE);

    if (m_ai->GetCombatStyle() != PlayerbotAI::COMBAT_RANGED && !meleeReach)
        m_ai->SetCombatStyle(PlayerbotAI::COMBAT_RANGED);
    // switch to melee if in melee range AND can't shoot OR have no ranged (wand) equipped
    else if(m_ai->GetCombatStyle() != PlayerbotAI::COMBAT_MELEE
            && meleeReach
            && (SHOOT == 0 || !m_bot->GetWeaponForAttack(RANGED_ATTACK, true, true)))
        m_ai->SetCombatStyle(PlayerbotAI::COMBAT_MELEE);

    //Used to determine if this bot is highest on threat
    Unit *newTarget = m_ai->FindAttacker((PlayerbotAI::ATTACKERINFOTYPE) (PlayerbotAI::AIT_VICTIMSELF | PlayerbotAI::AIT_HIGHESTTHREAT), m_bot);
    if (newTarget && !m_ai->IsNeutralized(newTarget)) // TODO: && party has a tank
    {
        // Have threat, can't quickly lower it. 3 options remain: Stop attacking, lowlevel damage (wand), keep on keeping on.
        if (newTarget->GetHealthPercent() > 25)
        {
            // If elite
            if (m_ai->IsElite(newTarget))
            {
                // let warlock pet handle it to win some time
                Creature * pCreature = (Creature*) newTarget;
                if (pet)
                {
                    switch (pet->GetEntry())
                    {
                        // taunt the elite and tank it
                        case DEMON_VOIDWALKER:
                            if (TORMENT && m_ai->CastPetSpell(TORMENT, newTarget))
                                return RETURN_NO_ACTION_OK;
                        // maybe give it some love?
                        case DEMON_SUCCUBUS:
                            if (pCreature && pCreature->GetCreatureInfo()->CreatureType == CREATURE_TYPE_HUMANOID)
                                if (SEDUCTION && !newTarget->HasAura(SEDUCTION) && m_ai->CastPetSpell(SEDUCTION, newTarget))
                                    return RETURN_NO_ACTION_OK;
                    }

                }
                // if aggroed mob is a demon or an elemental: banish it
                if (pCreature && (pCreature->GetCreatureInfo()->CreatureType == CREATURE_TYPE_DEMON || pCreature->GetCreatureInfo()->CreatureType == CREATURE_TYPE_ELEMENTAL))
                {
                    if (BANISH && !newTarget->HasAura(BANISH) && CastSpell(BANISH, newTarget))
                        return RETURN_CONTINUE;
                }

                return RETURN_NO_ACTION_OK; // do nothing and pray tank gets aggro off you
            }

            // Not an elite. You could insert FEAR here but in any PvE situation that's 90-95% likely
            // to worsen the situation for the group. ... So please don't.
            return CastSpell(SHOOT, pTarget);
        }
    }

    // Create soul shard (only on non-worldboss)
    uint8 freeSpace = m_ai->GetFreeBagSpace();
    uint8 HPThreshold = (m_ai->IsElite(pTarget) ? 10 : 25);
    if (!m_ai->IsElite(pTarget, true) && pTarget->GetHealthPercent() < HPThreshold && (shardCount < MAX_SHARD_COUNT && freeSpace > 0))
    {
        if (SHADOWBURN && m_ai->In_Reach(pTarget, SHADOWBURN) && !pTarget->HasAura(SHADOWBURN) && m_bot->IsSpellReady(SHADOWBURN) && CastSpell(SHADOWBURN, pTarget))
            return RETURN_CONTINUE;

        // Do not cast Drain Soul if Shadowburn is active on target
        if (DRAIN_SOUL && m_ai->In_Reach(pTarget, DRAIN_SOUL) && !pTarget->HasAura(DRAIN_SOUL) && !pTarget->HasAura(SHADOWBURN) && CastSpell(DRAIN_SOUL, pTarget))
        {
            m_ai->SetIgnoreUpdateTime(15);
            return RETURN_CONTINUE;
        }
    }

    if (pet && DARK_PACT && (100 * pet->GetPower(POWER_MANA) / pet->GetMaxPower(POWER_MANA)) > 10 && m_ai->GetManaPercent() <= 20)
        if (m_ai->CastSpell(DARK_PACT, *m_bot))
            return RETURN_CONTINUE;

    // Mana check and replenishment
//.........这里部分代码省略.........
开发者ID:zwisus,项目名称:mangos-classic,代码行数:101,代码来源:PlayerbotWarlockAI.cpp

示例15: switch


//.........这里部分代码省略.........
                    CellLock<GridReadGuard> cell_lock(cell, p);

                    TypeContainerVisitor<Trinity::UnitSearcher<Trinity::AnyUnfriendlyNoTotemUnitInObjectRangeCheck>, GridTypeMapContainer > grid_object_checker(checker);
                    cell_lock->Visit(cell_lock, grid_object_checker, *MapManager::Instance().GetMap(GetMapId(), this));

                    // or unfriendly player/pet
                    if(!ok)
                    {
                        TypeContainerVisitor<Trinity::UnitSearcher<Trinity::AnyUnfriendlyNoTotemUnitInObjectRangeCheck>, WorldTypeMapContainer > world_object_checker(checker);
                        cell_lock->Visit(cell_lock, world_object_checker, *MapManager::Instance().GetMap(GetMapId(), this));
                    }
                }
                else                                        // environmental trap
                {
                    // environmental damage spells already have around enemies targeting but this not help in case not existed GO casting support

                    // affect only players
                    Player* p_ok = NULL;
                    Trinity::AnyPlayerInObjectRangeCheck p_check(this, radius);
                    Trinity::PlayerSearcher<Trinity::AnyPlayerInObjectRangeCheck>  checker(p_ok, p_check);

                    CellLock<GridReadGuard> cell_lock(cell, p);

                    TypeContainerVisitor<Trinity::PlayerSearcher<Trinity::AnyPlayerInObjectRangeCheck>, WorldTypeMapContainer > world_object_checker(checker);
                    cell_lock->Visit(cell_lock, world_object_checker, *MapManager::Instance().GetMap(GetMapId(), this));
                    ok = p_ok;
                }

                if (ok)
                {
                    //Unit *caster =  owner ? owner : ok;

                    //caster->CastSpell(ok, goInfo->trap.spellId, true);
                    CastSpell(ok, goInfo->trap.spellId);
                    m_cooldownTime = time(NULL) + 4;        // 4 seconds

                    if(NeedDespawn)
                        SetLootState(GO_JUST_DEACTIVATED);  // can be despawned or destroyed

                    if(IsBattleGroundTrap && ok->GetTypeId() == TYPEID_PLAYER)
                    {
                        //BattleGround gameobjects case
                        if(((Player*)ok)->InBattleGround())
                            if(BattleGround *bg = ((Player*)ok)->GetBattleGround())
                                bg->HandleTriggerBuff(GetGUID());
                    }
                }
            }

            if (m_charges && m_usetimes >= m_charges)
                SetLootState(GO_JUST_DEACTIVATED);          // can be despawned or destroyed

            break;
        }
        case GO_ACTIVATED:
        {
            switch(GetGoType())
            {
                case GAMEOBJECT_TYPE_DOOR:
                case GAMEOBJECT_TYPE_BUTTON:
                    if(GetAutoCloseTime() && (m_cooldownTime < time(NULL)))
                    {
                        SwitchDoorOrButton(false);
                        SetLootState(GO_JUST_DEACTIVATED);
                    }
                    break;
开发者ID:de-dima,项目名称:243,代码行数:67,代码来源:GameObject.cpp


注:本文中的CastSpell函数示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。