void AssistanceMovementGenerator::Finalize(Unit &unit)
{
    unit.ToCreature()->SetNoCallAssistance(false);
    unit.ToCreature()->CallAssistance();
    if (unit.isAlive())
        unit.GetMotionMaster()->MoveSeekAssistanceDistract(sWorld->getConfig(CONFIG_CREATURE_FAMILY_ASSISTANCE_DELAY));
}
void TempSummon::UnSummon(uint32 msTime)
{ 
    if (msTime)
    {
        ForcedUnsummonDelayEvent* pEvent = new ForcedUnsummonDelayEvent(*this);

        m_Events.AddEvent(pEvent, m_Events.CalculateTime(msTime));
        return;
    }

	// Dont allow to call this function twice (possible)
	if (m_type == TEMPSUMMON_DESPAWNED)
		return;
	SetTempSummonType(TEMPSUMMON_DESPAWNED);

    //ASSERT(!IsPet());
    if (IsPet())
    {
        ((Pet*)this)->Remove(PET_SAVE_NOT_IN_SLOT);
        ASSERT(!IsInWorld());
        return;
    }

    Unit* owner = GetSummoner();
    if (owner && owner->GetTypeId() == TYPEID_UNIT && owner->ToCreature()->IsAIEnabled)
        owner->ToCreature()->AI()->SummonedCreatureDespawn(this);

    AddObjectToRemoveList();
}
Example #3
0
void TempSummon::UnSummon(uint32 msTime)
{
    if (msTime)
    {
        ForcedUnsummonDelayEvent* pEvent = new ForcedUnsummonDelayEvent(*this);

        m_Events.AddEvent(pEvent, m_Events.CalculateTime(msTime));
        return;
    }

    //ASSERT(!IsPet());
    if (IsPet())
    {
        ((Pet*)this)->Remove(PET_SAVE_NOT_IN_SLOT);
        ASSERT(!IsInWorld());
        return;
    }

    Unit* owner = GetSummoner();
    if (owner && owner->GetTypeId() == TYPEID_UNIT && owner->ToCreature()->IsAIEnabled)
        owner->ToCreature()->AI()->SummonedCreatureDespawn(this);

    //npcbot
    if (GetIAmABot() || GetIAmABotsPet())
    {
        //TC_LOG_ERROR("entities.player", "TempSummon::UnSummon(): Trying to unsummon Bot %s (guidLow: %u owner: %s)", GetName().c_str(), GetGUIDLow(), GetBotOwner()->GetName().c_str());
        if (IsTempBot())
            AI()->JustDied(NULL);
        return;
    }
    //end npcbots

    AddObjectToRemoveList();
}
            void SpellHitTarget(Unit* target, const SpellInfo* spellInfo)
            {
                Unit* charm = target->GetCharm();
                if (!charm || !charm->ToCreature())
                    return;

                charm->ToCreature()->AI()->DoAction(spellInfo->Id);
            }
Example #5
0
void TempSummon::InitSummon() {
	Unit* owner = GetSummoner();
	if (owner) {
		if (owner->GetTypeId() == TYPEID_UNIT
				&& owner->ToCreature()->IsAIEnabled)
			owner->ToCreature()->AI()->JustSummoned(this);
		if (IsAIEnabled)
			AI()->IsSummonedBy(owner);
	}
}
Example #6
0
 void EnterCombat(Unit* /*who*/)
 {
     DoCast(me, SPELL_STRENGHT_OF_THE_PACK, true);
     if (me->ToTempSummon())
     {
         Unit* auriaya = me->ToTempSummon()->GetSummoner();
         if (auriaya && auriaya->ToCreature() && !auriaya->isInCombat())
             auriaya->ToCreature()->SetInCombatWithZone();
     }
 }
void TempSummon::InitSummon()
{ 
    Unit* owner = GetSummoner();
    if (owner)
    {
        if (owner->GetTypeId() == TYPEID_UNIT && owner->ToCreature()->IsAIEnabled)
            owner->ToCreature()->AI()->JustSummoned(this);
    }

	// Xinef: Allow to call this hook when npc is summoned by gameobject, in this case pass this as summoner to avoid possible null checks
	if (IsAIEnabled)
		AI()->IsSummonedBy(owner);
}
Example #8
0
            void HandleDummy(SpellEffIndex /*effIndex*/)
            {
                Unit* caster = GetCaster();

                if (!caster)
                    return;

                if (!caster->ToCreature())
                    return;

                if (Unit* target = caster->ToCreature()->AI()->SelectTarget(SELECT_TARGET_RANDOM, 0, 80.0f, true))
                    caster->SummonCreature(NPC_ROCKFALL_TORTOS, target->GetPositionX(), target->GetPositionY(), target->GetPositionZ(), 0, TEMPSUMMON_MANUAL_DESPAWN);
            }
        void JustDied(Unit* Killer)
        {
            if (!ghost && instance)
            {
                Unit* skarvald = Unit::GetUnit((*me), instance->GetData64(DATA_SKARVALD));
                if (skarvald)
                {
                    if (skarvald->isDead())
                    {
                        DoScriptText(YELL_DALRONN_SKA_DIED,me);

                        if (instance)
                            instance->SetData(DATA_SKARVALD_DALRONN_EVENT, DONE);
                    }
                    else
                    {
                        DoScriptText(YELL_DALRONN_DAL_DIEDFIRST,me);

                        skarvald->ToCreature()->AddLootMode(1);
                        //me->RemoveFlag(UNIT_DYNAMIC_FLAGS, UNIT_DYNFLAG_LOOTABLE);
                        //DoCast(me, SPELL_SUMMON_DALRONN_GHOST, true);
                        Creature* temp = me->SummonCreature(MOB_DALRONN_GHOST,me->GetPositionX(),me->GetPositionY(),me->GetPositionZ(),0,TEMPSUMMON_CORPSE_DESPAWN,5000);
                        if (temp)
                        {
                            temp->SetFlag(UNIT_FIELD_FLAGS,UNIT_FLAG_NON_ATTACKABLE);
                            temp->AI()->AttackStart(Killer);
                        }
                    }
                }
            }
        }
Example #10
0
    static bool HandleNpcBotAddCommand(ChatHandler* handler, const char* /*args*/)
    {
        Player* owner = handler->GetSession()->GetPlayer();
        Unit* cre = owner->GetSelectedUnit();

        if (!cre || cre->GetTypeId() != TYPEID_UNIT)
        {
            handler->SendSysMessage(".npcbot add");
            handler->SendSysMessage("Allows to hire selected uncontrolled bot, bypassing price condition");
            handler->SetSentErrorMessage(true);
            return false;
        }

        Creature* bot = cre->ToCreature();
        if (!bot || !bot->GetIAmABot() || bot->GetBotAI()->GetBotOwnerGuid())
        {
            handler->SendSysMessage("You must select uncontrolled npcbot");
            handler->SetSentErrorMessage(true);
            return false;
        }

        BotMgr* mgr = owner->GetBotMgr();
        if (!mgr)
            mgr = new BotMgr(owner);

        if (mgr->AddBot(bot) == BOT_ADD_SUCCESS)
        {
            handler->PSendSysMessage("%s is now your npcbot", bot->GetName().c_str());
            return true;
        }

        handler->PSendSysMessage("NpcBot is NOT created for some reason!");
        handler->SetSentErrorMessage(true);
        return false;
    }
 void OnApply(AuraEffect const* /*aurEff*/, AuraEffectHandleModes /*mode*/)
 {
     Unit* caster = GetCaster();
     if (caster && caster->GetEntry() == NPC_ACIDMAW)
         if (Creature* acidmaw = caster->ToCreature())
             acidmaw->AI()->Talk(SAY_SPECIAL, GetTarget());
 }
 void Counter()
 {
     Unit* u = me->GetVictim();
     bool cSpell = COUNTERSPELL && CounterSpell_cd <= 5000;
     bool blast = FIREBLAST && FireBlast_cd <= 3000 && !(u && u->ToCreature() && (u->ToCreature()->isWorldBoss() || u->ToCreature()->IsDungeonBoss())) && me->HasAura(IMPACT_BUFF);
     if (!cSpell && !blast) return;
     if (u && u->IsNonMeleeSpellCast(false) &&
         ((cSpell && me->GetDistance(u) < 40) || (blast && me->GetDistance(u) < 30)))
     {
         temptimer = GC_Timer;
         if (me->IsNonMeleeSpellCast(false))
             me->InterruptNonMeleeSpells(false);
         if (cSpell && doCast(u, COUNTERSPELL))
             CounterSpell_cd = 15000;
         else if (blast && doCast(u, FIREBLAST))
             FireBlast_cd = 6000;
         GC_Timer = temptimer;
     }
     else if (cSpell)
     {
         if (Unit* target = FindCastingTarget(40))
         {
             temptimer = GC_Timer;
             if (me->IsNonMeleeSpellCast(false))
                 me->InterruptNonMeleeSpells(false);
             if (doCast(target, COUNTERSPELL))
             {
                 CounterSpell_cd = 15000;
                 GC_Timer = temptimer;
             }
         }
     }
 }
Example #13
0
void TempSummon::UnSummon()
{
    //assert(!isPet());
    if (isPet())
    {
        ((Pet*)this)->Remove(PET_SAVE_NOT_IN_SLOT);
        assert(!IsInWorld());
        return;
    }

    Unit* owner = GetSummoner();
    if (owner && owner->GetTypeId() == TYPEID_UNIT && owner->ToCreature()->IsAIEnabled)
        owner->ToCreature()->AI()->SummonedCreatureDespawn(this);

    AddObjectToRemoveList();
}
Example #14
0
        void UpdateAI(uint32 diff) override
        {
            m_events.Update(diff);

            while (uint32 eventId = m_events.ExecuteEvent())
            {
                switch (eventId)
                {
                    case EVENT_CHECK_PLAYER:
                    {
                        Vehicle* catapult = me->GetVehicleKit();
                        Unit* unit = catapult->GetPassenger(0);
                        if (catapult)
                            if (unit)
                            {
                                if (Creature* forsaken = unit->ToCreature())
                                {
                                    if (forsaken->IsInCombat())
                                    {
                                        forsaken->ExitVehicle();
                                        forsaken->SetUInt32Value(UNIT_FIELD_BYTES_1, 0);
                                        m_events.ScheduleEvent(EVENT_MASTER_RESET, 10000);
                                    }
                                }
                            }
                            else
                            {
                                if (me->getFaction() != 35)
                                {
                                    m_events.CancelEvent(EVENT_CAST_BOULDER_PREPARE);
                                    me->setFaction(35);
                                    me->RemoveFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_DISABLE_MOVE | UNIT_FLAG_NOT_SELECTABLE);
                                    me->RemoveFlag(UNIT_FIELD_FLAGS_2, UNIT_FLAG2_DISABLE_TURN);
                                }
                                break;
                            }

                        m_events.ScheduleEvent(EVENT_CHECK_PLAYER, 1000);
                        break;
                    }
                    case EVENT_CAST_BOULDER_PREPARE:
                    {
                        me->CastSpell(me, SPELL_FIERY_BOULDER, true);
                        m_events.ScheduleEvent(EVENT_CAST_BOULDER_PREPARE, urand(8000,15000));
                        break;
                    }
                    case EVENT_MASTER_RESET:
                    {
                        me->DespawnOrUnsummon(1);
                        break;
                    }
                }
            }

            if (!UpdateVictim())
                return;
            else
                DoMeleeAttackIfReady();
        }
void EffectMovementGenerator::Finalize(Unit& unit)
{
    if (unit.GetTypeId() != TYPEID_UNIT)
        return;

    // Need restore previous movement since we have no proper states system
    if (unit.IsAlive() && !unit.HasUnitState(UNIT_STATE_CONFUSED | UNIT_STATE_FLEEING | UNIT_STATE_DISTRACTED))
    {
        if (Unit* victim = unit.getVictim())
            unit.GetMotionMaster()->MoveChase(victim);
        else
            unit.GetMotionMaster()->Initialize();
    }

    if (unit.ToCreature()->AI())
        unit.ToCreature()->AI()->MovementInform(EFFECT_MOTION_TYPE, m_Id);
}
            void FilterTargets(std::list<WorldObject*>& targets)
            {
                Unit* caster = GetCaster();
                if (!caster || !caster->ToCreature())
                    return;

                std::list<WorldObject*> tmplist;
                for (std::list<WorldObject*>::iterator itr = targets.begin(); itr != targets.end(); ++itr)
                {
                    if (CAST_AI(boss_sapphiron::boss_sapphironAI, caster->ToCreature()->AI())->IsValidExplosionTarget(*itr))
                        tmplist.push_back(*itr);
                }

                 targets.clear();
                 for (std::list<WorldObject*>::iterator itr = tmplist.begin(); itr != tmplist.end(); ++itr)
                     targets.push_back(*itr);
            }
Example #17
0
void WorldSession::HandleTextEmoteOpcode(WorldPackets::Chat::CTextEmote& packet)
{
    if (!_player->IsAlive())
        return;

    if (!_player->CanSpeak())
    {
        std::string timeStr = secsToTimeString(m_muteTime - time(NULL));
        SendNotification(GetTrinityString(LANG_WAIT_BEFORE_SPEAKING), timeStr.c_str());
        return;
    }

    sScriptMgr->OnPlayerTextEmote(_player, packet.SoundIndex, packet.EmoteID, packet.Target);

    EmotesTextEntry const* em = sEmotesTextStore.LookupEntry(packet.EmoteID);
    if (!em)
        return;

    uint32 emoteAnim = em->EmoteID;

    switch (emoteAnim)
    {
        case EMOTE_STATE_SLEEP:
        case EMOTE_STATE_SIT:
        case EMOTE_STATE_KNEEL:
        case EMOTE_ONESHOT_NONE:
            break;
        case EMOTE_STATE_DANCE:
        case EMOTE_STATE_READ:
            _player->SetUInt32Value(UNIT_NPC_EMOTESTATE, emoteAnim);
            break;
        default:
            // Only allow text-emotes for "dead" entities (feign death included)
            if (_player->HasUnitState(UNIT_STATE_DIED))
                break;
            _player->HandleEmoteCommand(emoteAnim);
            break;
    }

    WorldPackets::Chat::STextEmote textEmote;
    textEmote.SourceGUID = _player->GetGUID();
    textEmote.SourceAccountGUID = GetAccountGUID();
    textEmote.TargetGUID = packet.Target;
    textEmote.EmoteID = packet.EmoteID;
    textEmote.SoundIndex = packet.SoundIndex;
    _player->SendMessageToSetInRange(textEmote.Write(), sWorld->getFloatConfig(CONFIG_LISTEN_RANGE_TEXTEMOTE), true);

    Unit* unit = ObjectAccessor::GetUnit(*_player, packet.Target);

    _player->UpdateCriteria(CRITERIA_TYPE_DO_EMOTE, packet.SoundIndex, 0, 0, unit);

    // Send scripted event call
    if (unit)
        if (Creature* creature = unit->ToCreature())
            creature->AI()->ReceiveEmote(_player, packet.EmoteID);
}
Example #18
0
    static bool HandleNpcBotDeleteCommand(ChatHandler* handler, const char* /*args*/)
    {
        Player* chr = handler->GetSession()->GetPlayer();
        Unit* ubot = chr->GetSelectedUnit();
        if (!ubot)
        {
            handler->SendSysMessage(".npcbot delete");
            handler->SendSysMessage("Deletes selected npcbot spawn from world and DB");
            handler->SetSentErrorMessage(true);
            return false;
        }

        Creature* bot = ubot->ToCreature();
        if (!bot || !bot->IsNPCBot())
        {
            handler->SendSysMessage("No npcbot selected");
            handler->SetSentErrorMessage(true);
            return false;
        }

        if (Player* botowner = bot->GetBotOwner()->ToPlayer())
            botowner->GetBotMgr()->RemoveBot(bot->GetGUID(), BOT_REMOVE_DISMISS);

        uint32 id = bot->GetEntry();

        PreparedStatement* stmt = CharacterDatabase.GetPreparedStatement(CHAR_SEL_NPCBOT_EQUIP);
        //"SELECT equipMhEx, equipOhEx, equipRhEx, equipHead, equipShoulders, equipChest, equipWaist, equipLegs, equipFeet, equipWrist, equipHands, equipBack, equipBody, equipFinger1, equipFinger2, equipTrinket1, equipTrinket2, equipNeck
        //FROM characters_npcbot WHERE entry = ?", CONNECTION_SYNCH
        stmt->setUInt32(0, id);
        PreparedQueryResult res = CharacterDatabase.Query(stmt);
        ASSERT(res);

        Field* fields = res->Fetch();
        for (uint8 i = 0; i != BOT_INVENTORY_SIZE; ++i)
        {
            if (fields[i].GetUInt32())
            {
                handler->PSendSysMessage("%s still has eqipment assigned. Please remove equips before deleting bot!", bot->GetName().c_str());
                handler->SetSentErrorMessage(true);
                return false;
            }
        }

        bot->CombatStop();
        bot->DeleteFromDB();
        bot->AddObjectToRemoveList();

        stmt = CharacterDatabase.GetPreparedStatement(CHAR_DEL_NPCBOT);
        //"DELETE FROM characters_npcbot WHERE entry = ?", CONNECTION_ASYNC
        stmt->setUInt32(0, id);
        CharacterDatabase.Execute(stmt);

        handler->SendSysMessage("Npcbot successfully deleted.");
        return true;
    }
Example #19
0
            void HandlePeriodicDummy(AuraEffect const* aurEff)
            {
                Unit* target = GetTarget();
				if (target->GetTypeId() == TYPEID_UNIT && GetAura()->GetStackAmount() >= 10)
				{
					target->CastSpell(target, SPELL_OVERCHARGED_BLAST, true);
					target->ToCreature()->DespawnOrUnsummon(500);
				}

				PreventDefaultAction();
            }
Example #20
0
    static bool HandleNpcSetFactionCommand(ChatHandler* handler, const char* args)
    {
        Player* chr = handler->GetSession()->GetPlayer();
        Unit* ubot = chr->GetSelectedUnit();
        if (!ubot || !*args)
        {
            handler->SendSysMessage(".npcbot set faction #faction");
            handler->SendSysMessage("Sets faction for selected npcbot (saved in DB). Use 'a', 'h' or 'm' as argument to set faction to alliance, horde or monsters (hostile to all)");
            handler->SetSentErrorMessage(true);
            return false;
        }

        Creature* bot = ubot->ToCreature();
        if (!bot || !bot->GetIAmABot() || !bot->IsFreeBot())
        {
            handler->SendSysMessage("You must select uncontrolled npcbot.");
            handler->SetSentErrorMessage(true);
            return false;
        }

        uint32 factionId = 0;
        const std::string facStr = args;
        char const* factionChar = facStr.c_str();

        if (factionChar[0] == 'a')
            factionId = 1802; //Alliance
        else if (factionChar[0] == 'h')
            factionId = 1801; //Horde
        else if (factionChar[0] == 'm')
            factionId = 14; //Monsters

        if (!factionId)
        {
            char* pfactionid = handler->extractKeyFromLink((char*)args, "Hfaction");
            factionId = atoi(pfactionid);
        }

        if (!sFactionTemplateStore.LookupEntry(factionId))
        {
            handler->PSendSysMessage(LANG_WRONG_FACTION, factionId);
            handler->SetSentErrorMessage(true);
            return false;
        }

        PreparedStatement* stmt = CharacterDatabase.GetPreparedStatement(CHAR_UPD_NPCBOT_FACTION);
        //"UPDATE characters_npcbot SET faction = ? WHERE entry = ?", CONNECTION_SYNCH
        stmt->setUInt32(0, factionId);
        stmt->setUInt32(1, bot->GetEntry());
        CharacterDatabase.DirectExecute(stmt);

        handler->PSendSysMessage("%s's faction set to %u", bot->GetName().c_str(), factionId);
        bot->GetBotAI()->InitFaction();
        return true;
    }
Example #21
0
    static bool HandleNpcBotRemoveCommand(ChatHandler* handler, const char* /*args*/)
    {
        Player* owner = handler->GetSession()->GetPlayer();
        Unit* u = owner->GetSelectedUnit();
        if (!u)
        {
            handler->PSendSysMessage(".npcbot remove");
            handler->PSendSysMessage("Frees selected npcbot from it's owner. Select player to remove all npcbots");
            handler->SetSentErrorMessage(true);
            return false;
        }

        Player* master = u->ToPlayer();
        if (master)
        {
            if (master->HaveBot())
            {
                master->RemoveAllBots(BOT_REMOVE_DISMISS);

                if (!master->HaveBot())
                {
                    handler->PSendSysMessage("Npcbots were successfully removed");
                    handler->SetSentErrorMessage(true);
                    return true;
                }
                handler->PSendSysMessage("Some npcbots were not removed!");
                handler->SetSentErrorMessage(true);
                return false;
            }
            handler->PSendSysMessage("Npcbots are not found!");
            handler->SetSentErrorMessage(true);
            return false;
        }

        Creature* cre = u->ToCreature();
        if (cre && cre->GetIAmABot() && !cre->IsFreeBot())
        {
            master = cre->GetBotOwner();
            master->GetBotMgr()->RemoveBot(cre->GetGUID(), BOT_REMOVE_DISMISS);
            if (master->GetBotMgr()->GetBot(cre->GetGUID()) == NULL)
            {
                handler->PSendSysMessage("NpcBot successfully removed");
                handler->SetSentErrorMessage(true);
                return true;
            }
            handler->PSendSysMessage("NpcBot was NOT removed for some stupid reason!");
            handler->SetSentErrorMessage(true);
            return false;
        }

        handler->PSendSysMessage("You must select player or controlled npcbot");
        handler->SetSentErrorMessage(true);
        return false;
    }
Example #22
0
        void DespawnSelf(AuraEffect const* /*aurEff*/)
        {
            PreventDefaultAction();
            Unit* target = GetTarget();
            if (target->GetTypeId() != TYPEID_UNIT)
                return;

            target->RemoveAllAuras();
            target->SetVisible(false);
            target->ToCreature()->DespawnOrUnsummon(60000);
        }
void TimedFleeingMovementGenerator::Finalize(Unit &owner)
{
    owner.RemoveFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_FLEEING);
    owner.ClearUnitState(UNIT_STAT_FLEEING | UNIT_STAT_ROAMING);
    if (Unit* victim = owner.getVictim())
    {
        if (owner.isAlive())
        {
            owner.AttackStop();
            owner.ToCreature()->AI()->AttackStart(victim);
        }
    }
}
Example #24
0
void TempSummon::UnSummon(uint32 msTime) {
	if (msTime) {
		ForcedUnsummonDelayEvent *pEvent = new ForcedUnsummonDelayEvent(*this);

		m_Events.AddEvent(pEvent, m_Events.CalculateTime(msTime));
		return;
	}

	//ASSERT(!isPet());
	if (isPet()) {
		((Pet*) this)->Remove(PET_SLOT_OTHER_PET);
		ASSERT(!IsInWorld());
		return;
	}

	Unit* owner = GetSummoner();
	if (owner && owner->GetTypeId() == TYPEID_UNIT
			&& owner->ToCreature()->IsAIEnabled)
		owner->ToCreature()->AI()->SummonedCreatureDespawn(this);

	AddObjectToRemoveList();
}
 void OnStackChange(AuraEffect const* /*aurEff*/, AuraEffectHandleModes /*mode*/)
 {
     if (GetStackAmount() == 15)
     {
         Unit* target = GetTarget(); // store target because aura gets removed
         target->CastSpell(target, SPELL_EXPLOSIVE_BARRAGE_DAMAGE, false);
         target->RemoveAurasDueToSpell(SPELL_HASTY_GROW);
         target->RemoveAurasDueToSpell(SPELL_AUTO_GROW);
         target->RemoveAurasDueToSpell(SPELL_EXPLODING_ORB);
         if (Creature* creature = target->ToCreature())
             creature->DespawnOrUnsummon();
     }
 }
Example #26
0
    static bool HandleNpcSetOwnerCommand(ChatHandler* handler, const char* args)
    {
        Player* chr = handler->GetSession()->GetPlayer();
        Unit* ubot = chr->GetSelectedUnit();
        if (!ubot || !*args)
        {
            handler->SendSysMessage(".npcbot set owner #guid | #name");
            handler->SendSysMessage("Binds selected npcbot to new player owner using guid or name and updates owner in DB");
            handler->SetSentErrorMessage(true);
            return false;
        }

        Creature* bot = ubot->ToCreature();
        if (!bot || !bot->GetIAmABot() || bot->GetBotAI()->GetBotOwnerGuid())
        {
            handler->SendSysMessage("This npcbot already has owner");
            handler->SetSentErrorMessage(true);
            return false;
        }

        char* characterName_str = strtok((char*)args, " ");
        if (!characterName_str)
            return false;

        std::string characterName = characterName_str;
        uint32 guidlow = (uint32)atoi(characterName_str);

        if (guidlow)
            sObjectMgr->GetPlayerNameByGUID(MAKE_NEW_GUID(guidlow, 0, HIGHGUID_PLAYER), characterName);
        else
            guidlow = sObjectMgr->GetPlayerGUIDByName(characterName);

        if (!guidlow || !normalizePlayerName(characterName))
        {
            handler->PSendSysMessage("Player %s not found", characterName.c_str());
            handler->SetSentErrorMessage(true);
            return false;
        }

        bot->GetBotAI()->SetBotOwnerGUID(guidlow);

        PreparedStatement* stmt = CharacterDatabase.GetPreparedStatement(CHAR_UPD_NPCBOT_OWNER);
        //"UPDATE characters_npcbot SET owner = ? WHERE entry = ?", CONNECTION_ASYNC
        stmt->setUInt32(0, guidlow);
        stmt->setUInt32(1, bot->GetEntry());
        CharacterDatabase.Execute(stmt);

        handler->PSendSysMessage("%s's new owner is %s (guidlow: %u)", bot->GetName().c_str(), characterName.c_str(), guidlow);
        return true;
    }
Example #27
0
        void HandleScriptEffect(SpellEffIndex /*effIndex*/)
        {
            if (GetCaster()->GetTypeId() != TYPEID_UNIT)
                return;

            Unit* caster = GetCaster();
            CreatureAI* ickAI = caster->ToCreature()->AI();
            if (Unit* target = ickAI->SelectTarget(SELECT_TARGET_RANDOM, 0, 200.0f, true))
            {
                DoScriptText(SAY_ICK_CHASE_1, caster, target);
                caster->AddAura(GetSpellInfo()->Id, target);
                CAST_AI(boss_ick::boss_ickAI, ickAI)->SetTempThreat(caster->getThreatManager().getThreat(target));
                caster->AddThreat(target, float(GetEffectValue()));
                target->AddThreat(caster, float(GetEffectValue()));
            }
        }
Example #28
0
            void HandleDamage(SpellEffIndex /*effIndex*/)
            {
                if (!GetTriggeringSpell())
                    return;

                Unit* target = GetHitUnit();
                Unit* caster = GetCaster();

                if (target->HasAura(GetTriggeringSpell()->Id))
                    SetHitDamage(0);
                else
                {
                    if (target->GetTypeId() == TYPEID_PLAYER && caster->IsAIEnabled)
                        caster->ToCreature()->AI()->SetData(DATA_POLARITY_SWITCH, 1);
                }
            }
Example #29
0
    //Edit Player TP
    static bool HandleModifyTalentCommand (ChatHandler* handler, const char* args)
    {
        if (!*args)
            return false;

        int tp = atoi((char*)args);
        if (tp < 0)
            return false;

        Unit* target = handler->getSelectedUnit();
        if (!target)
        {
            handler->SendSysMessage(LANG_NO_CHAR_SELECTED);
            handler->SetSentErrorMessage(true);
            return false;
        }

        if (target->GetTypeId() == TYPEID_PLAYER)
        {
            // check online security
            if (handler->HasLowerSecurity(target->ToPlayer(), 0))
                return false;
            target->ToPlayer()->SetFreeTalentPoints(tp);
            target->ToPlayer()->SendTalentsInfoData(false);
            return true;
        }
        else if (target->ToCreature()->IsPet())
        {
            Unit* owner = target->GetOwner();
            if (owner && owner->GetTypeId() == TYPEID_PLAYER && ((Pet*)target)->IsPermanentPetFor(owner->ToPlayer()))
            {
                // check online security
                if (handler->HasLowerSecurity(owner->ToPlayer(), 0))
                    return false;
                ((Pet*)target)->SetFreeTalentPoints(tp);
                owner->ToPlayer()->SendTalentsInfoData(true);
                return true;
            }
        }

        handler->SendSysMessage(LANG_NO_CHAR_SELECTED);
        handler->SetSentErrorMessage(true);
        return false;
    }
    void PeriodicTick(AuraEffect const* /*aurEff*/)
    {
        PreventDefaultAction();

        Unit* permafrostCaster = nullptr;
        if (Aura* permafrostAura = GetTarget()->GetAura(sSpellMgr->GetSpellIdForDifficulty(SPELL_PERMAFROST, GetTarget())))
            permafrostCaster = permafrostAura->GetCaster();

        if (permafrostCaster)
        {
            if (Creature* permafrostCasterCreature = permafrostCaster->ToCreature())
                permafrostCasterCreature->DespawnOrUnsummon(3000);

            GetTarget()->CastSpell(nullptr, SPELL_SPIKE_FAIL, false);
            GetTarget()->RemoveAllAuras();
            if (Creature* targetCreature = GetTarget()->ToCreature())
                targetCreature->DisappearAndDie();
        }
    }