1 (edited by amir_cinderella 2016-05-27 19:00:09)

Script allow a npc to spawn random battleground npc entry,s this script usefull for all player join a battleground ...
c++ code :

/* Random Joiner BattleGround
Coded By : Ac.Dev
Comment: Script allow a npc to spawn random battleground npc entrys
*/

#include "ScriptPCH.h"

enum joiner_bg
{
    EVENT_SUMM = 1
};

int randomize = urand(0, 4); // Setting up our integer, giving it a value of random 0 - 4
struct joiner_bgAI : public Scripted_NoMovementAI
{
    joiner_bgAI(Creature *c) : Scripted_NoMovementAI(c) {}

    EventMap events;

    void Reset()
    {
        events.Reset();
        events.ScheduleEvent(EVENT_SUMM,1);
    }

    void UpdateAI(const uint32 diff)
    {
        events.Update(diff);
        while (uint32 eventId = events.ExecuteEvent())
        {
            switch (eventId)
            {
                case EVENT_SUMM:
                    events.ScheduleEvent(EVENT_SUMM, 600 * IN_MILLISECONDS); // repeat after 600 sec
                    switch (randomize) // Switching our randomizer
                    {
                    case 0: // 0
                        me->SummonCreature(20269, me->GetPositionX(), me->GetPositionY(), me->GetPositionZ(), me->GetOrientation(), TEMPSUMMON_TIMED_DESPAWN, 600 * IN_MILLISECONDS);
                        break;
                    case 1: // 1
                        me->SummonCreature(20274, me->GetPositionX(), me->GetPositionY(), me->GetPositionZ(), me->GetOrientation(), TEMPSUMMON_TIMED_DESPAWN, 600 * IN_MILLISECONDS);
                        break;
                    case 2: // 2
                        me->SummonCreature(20384, me->GetPositionX(), me->GetPositionY(), me->GetPositionZ(), me->GetOrientation(), TEMPSUMMON_TIMED_DESPAWN, 600 * IN_MILLISECONDS);
                        break;
                    case 3: // 3
                        me->SummonCreature(20276, me->GetPositionX(), me->GetPositionY(), me->GetPositionZ(), me->GetOrientation(), TEMPSUMMON_TIMED_DESPAWN, 600 * IN_MILLISECONDS);
                        break;
                    case 4: // 4
                        me->SummonCreature(20269, me->GetPositionX(), me->GetPositionY(), me->GetPositionZ(), me->GetOrientation(), TEMPSUMMON_TIMED_DESPAWN, 600 * IN_MILLISECONDS);
                        break;
                    }
                break;
            }
        }
    }
};

CreatureAI* GetAI_joiner_bg(Creature* creature)
{
    return new joiner_bgAI(creature);
}

void AddSC_joiner_bg()
{
    Script *newscript;

    newscript = new Script;
    newscript->Name="joiner_bg";
    newscript->GetAI = &GetAI_joiner_bg;
    newscript->RegisterSelf();
}

How does this work ?

Baynar wrote:

How does this work ?

you must create a npc with scriptname "joiner_bg" next
joiner_bg allow to spawn random battleground npc entrys at location joiner_bg and you can set flag_extra joiner_bg tow 130 for only gm can see this npc .

amir_cinderella wrote:
Baynar wrote:

How does this work ?

you must create a npc with scriptname "joiner_bg" next
joiner_bg allow to spawn random battleground npc entrys at location joiner_bg and you can set flag_extra joiner_bg tow 130 for only gm can see this npc .

So i can set it to spawn a random bg npc every 6 hours ?

Baynar wrote:
amir_cinderella wrote:
Baynar wrote:

How does this work ?

you must create a npc with scriptname "joiner_bg" next
joiner_bg allow to spawn random battleground npc entrys at location joiner_bg and you can set flag_extra joiner_bg tow 130 for only gm can see this npc .

So i can set it to spawn a random bg npc every 6 hours ?

yes , i added for default 600 sec you can find '600' and edit it smile