• This is a read only backup of the old Emudevs forum. If you want to have anything removed, please message me on Discord: KittyKaev

[SOLVED] I donT know what is wrong

Status
Not open for further replies.

lexir

Enthusiast
i've scripted an boss and he just dont wanna spawn the Minions .


Code:
#define Creature Azshara World Boss

enum Spells
{
	Spell_Ball_of_fire = 106532,
	Spell_Pyroblast = 96088,
	Spell_Arcane Explosion  = 63660,
	Spell_BerzerkerBlaze = 147038,
};
 enum Events
{
    EVENT_Ball_of_fire = 1,
    EVENT_Pyroblast = 2,
    EVENT_Arcane Explosion  = 3,
	EVENT_BerzerkerBlaze = 4,
	EVENT_SPAWNCREATURE = 5,
};
};
 void EnterCombat(Unit* /*who*/) OVERRIDE
{
	                events.ScheduleEvent(EVENT_Ball_of_fire, 8000);
                events.ScheduleEvent(EVENT_Pyroblast, 12000);
                events.ScheduleEvent(EVENT_Arcane Explosion , 10000);
				events.ScheduleEvent(EVENT_BerzerkerBlaze, 9000);
				events.ScheduleEvent(EVENT_SPAWNCREATURE, 2000);

}

 while (uint32 eventId = events.ExecuteEvent())
{
    switch (eventId)
    {
        case EVENT_Ball_of_fire:
            DoCastVictim(Spell_Ball_of_fire, 8000);
            events.ScheduleEvent(EVENT_Ball_of_fire, 8000);
			break;
        case EVENT_Pyroblast:
			if (Unit *target = SelectTarget(SELECT_TARGET_RANDOM, 0))
                DoCast(target, SPELL_Pyroblast);
            break;
        case EVENT_ArcaneMissiles:
			if (Unit *target = SelectTarget(SELECT_TARGET_RANDOM, 0))
                DoCast(target, SPELL_Arcane Explosion);
            break;
		case EVENT_BerzerkerBlaze:
			 DoCast(me, SPELL_BerzerkerBlaze);
            events.ScheduleEvent(EVENT_BerzerkerBlaze, 9000);
			break;
			 case EVENT_SPAWNCREATURE:
			 me->SummonCreature(21706, xf, yf, zf, of, TEMPSUMMON_TIMED_DESPAWN, 2000);
             events.ScheduleEvent(EVENT_SPAWNCREATURE, 25000);
            break;
        default:
            break;
    }
}
 public:
    npc_boss_died() : CreatureScript("npc_boss_died") { }
	
    struct npc_boss_diedAI : public ScriptedAI
    {
        npc_boss_diedAI(Creature* creature) : ScriptedAI(creature) { }
		
        void JustDied(Unit* killer)
        {
            std::ostringstream ss;
            if (killer->GetTypeId() == TYPEID_PLAYER)
            {
                ss << killer->ToPlayer()->GetName()
                   << " has killed "
                   << me->GetName()
                   << " a Rare Boss!";
                sWorld->SendGlobalText(ss.str().c_str(), NULL);
            }
        }
   };
	
    CreatureAI* GetAI(Creature* creature) const
    {
        return new npc_boss_diedAI(creature);
    }
};

void AddSC_rare_boss()
{
    new npc_boss_died;
}
class npc_rare_boss_trigger : public CreatureScript
{
public:
    npc_rare_boss_trigger() : CreatureScript("npc_rare_boss_trigger") { }
	
    struct npc_rare_boss_triggerAI : public ScriptedAI
    {
        npc_rare_boss_triggerAI(Creature* creature) : ScriptedAI(creature) { }
		
        uint32 spawnTimer;
		
        void Reset()
        {
            spawnTimer = 3600000; // 3600000 = 1hr
        }
		
        void UpdateAI(uint32 diff)
        {
            if (spawnTimer <= diff)
            {
                int random = urand(0, 2);
                if (random == 0)
                    me->SummonCreature(ENTRYID, X, Y, Z, O, TEMPSUMMON_MANUAL_DESPAWN, 0);
                else if (random == 1)
                    me->SummonCreature(ENTRYID, X, Y, Z, O, TEMPSUMMON_MANUAL_DESPAWN, 0);
                else if (random == 2)
                    me->SummonCreature(ENTRYID, X, Y, Z, O, TEMPSUMMON_MANUAL_DESPAWN, 0);
                spawnTimer = 3600000;
            }
            else
                spawnTimer -= diff;
        }
   };
	
    CreatureAI* GetAI(Creature* creature) const
    {
        return new npc_rare_boss_triggerAI(creature);
    }
};

void AddSC_boss_trigger()
{
    new npc_rare_boss_trigger;
}

- - - Updated - - -

Whooops Wrong Code ... I am sorry m8es ..

- - - Updated - - -

Now its right lal ^^
 

Tommy

Founder
Why don't you have 'EnterCombat' and at stuff at the beginning of the script (besides the enumerators) in a class? The script you pasted has tons of errors in it..

#define Creature World Boss

Why do you have this? It isn't needed so I removed it.

Code:
enum Spells
{
	Spell_Fireblast = 36920,
	Spell_Frostbolt = 43035,
	Spell_ArcaneMissiles  = 109900,
	Spell_BerzerkerBlaze = 147038,
};
 enum Events
{
    EVENT_Fireblast = 1,
    EVENT_Frostbolt = 2,
    EVENT_ArcaneMissiles = 3,
	EVENT_BerzerkerBlaze = 4,
	EVENT_SPAWNCREATURE = 5,
};
[COLOR="#FF0000"]};[/COLOR]

You have an extra '};' at the end of that which will error the entire script. It is also a lot cleaner if you capitalize your data types in the enumerators.

Code:
 void EnterCombat(Unit* /*who*/) OVERRIDE
{
	                events.ScheduleEvent(EVENT_Fireblast, 8000);
                events.ScheduleEvent(EVENT_Frostbolt, 12000);
                events.ScheduleEvent(EVENT_ArcaneMissiles , 10000);
				events.ScheduleEvent(EVENT_BerzerkerBlaze, 9000);
				events.ScheduleEvent(EVENT_SPAWNCREATURE, 2000);

}

 while (uint32 eventId = events.ExecuteEvent())
{
    switch (eventId)
    {
        case EVENT_Fireblast:
            DoCastVictim(Spell_Fireblast, 8000);
            events.ScheduleEvent(EVENT_Fireblast, 8000);
			break;
        case EVENT_Frostbolt:
			if (Unit *target = SelectTarget(SELECT_TARGET_RANDOM, 0))
                DoCast(target, SPELL_Frostbolt);
            break;
        case EVENT_ArcaneMissiles:
			if (Unit *target = SelectTarget(SELECT_TARGET_RANDOM, 0))
                DoCast(target, SPELL_ArcaneMissiles);
            break;
		case EVENT_BerzerkerBlaze:
			 DoCast(me, SPELL_BerzerkerBlaze);
            events.ScheduleEvent(EVENT_BerzerkerBlaze, 9000);
			break;
			 case EVENT_SPAWNCREATURE:
			 me->SummonCreature(NPCID HERE, xf, yf, zf, of, TEMPSUMMON_TIMED_DESPAWN, 2000);
             events.ScheduleEvent(EVENT_SPAWNCREATURE, 25000);
            break;
        default:
            break;
    }
}

I'm not entirely sure why these aren't in a class under a struct (ScriptedAI).


Code:
 public:
    npc_boss_died() : CreatureScript("npc_boss_died") { }

You're missing the class name in general here..


Code:
void AddSC_rare_boss()
{
    new npc_boss_died;
}

That isn't needed if both of your scripts are in the same source file, because you can set them up together.

You're missing the variable 'events' which is setup by 'EventMap events;'. You also need to use 'Reset()' to call 'events.Reset();' so when the boss leaves combat or dies, the events will stop and reset.


Code:
        void EnterCombat(Unit* /*who*/) OVERRIDE
        {
            events.ScheduleEvent(EVENT_FIREBLAST, 8000);
            events.ScheduleEvent(EVENT_FROSTBOLT, 12000);
            events.ScheduleEvent(EVENT_ARCANEMISSILES , 10000);
            events.ScheduleEvent(EVENT_BERZERKERBLAZE, 9000);
            events.ScheduleEvent(EVENT_SPAWNCREATURE, 2000);
        }

The event 'EVENT_SPAWNCREATURE' doesn't exist, so it won't call it. Also, some of the intervals could make more sense in terms of the boss casting.


Code:
DoCastVictim(SPELL_FIREBLAST, 8000);

You have the wrong arguments supplied. It is 'spellId, bool triggered', not 'spellId, timer'..

Code:
    case EVENT_SPAWNCREATURE:
        me->SummonCreature(NPCID HERE, xf, yf, zf, of, TEMPSUMMON_TIMED_DESPAWN, 2000);
        events.ScheduleEvent(EVENT_SPAWNCREATURE, 23000);
        break;

Even if the creature spawned, you have it despawning in 2 seconds. I'd recommend 'TEMPSUMMON_MANUAL_DESPAWN'.


Anyway, I fixed the indentation and everything I mentioned above:

Code:
enum Spells
{
    SPELL_FIREBLAST       = 36920,
    SPELL_FROSTBOLT       = 43035,
    SPELL_ARCANEMISSILES  = 109900,
    SPELL_BERZERKERBLAZE  = 147038,
};

enum Events
{
    EVENT_NONE,
    EVENT_FIREBLAST,
    EVENT_FROSTBOLT,
    EVENT_ARCANEMISSILES,
    EVENT_BERZERKERBLAZE,
    EVENT_SPAWNCREATURE
};

class npc_boss_died : public CreatureScript
{
 public:
    npc_boss_died() : CreatureScript("npc_boss_died") { }
	
    struct npc_boss_diedAI : public ScriptedAI
    {
        npc_boss_diedAI(Creature* creature) : ScriptedAI(creature) { }

        void Reset()
        {
            events.Reset();
        }
		
        void JustDied(Unit* killer)
        {
            std::ostringstream ss;
            if (killer->GetTypeId() == TYPEID_PLAYER)
            {
                ss << killer->ToPlayer()->GetName()
                   << " has killed "
                   << me->GetName()
                   << " a Rare Boss!";
                sWorld->SendGlobalText(ss.str().c_str(), NULL);
            }
        }

        void EnterCombat(Unit* /*who*/) OVERRIDE
        {
            events.ScheduleEvent(EVENT_FIREBLAST, 9000);
            events.ScheduleEvent(EVENT_FROSTBOLT, 15000);
            events.ScheduleEvent(EVENT_ARCANEMISSILES , urand(21000, 25000));
            events.ScheduleEvent(EVENT_BERZERKERBLAZE, 31000);
            events.ScheduleEvent(EVENT_SPAWNCREATURE, 2000);
        }

        void UpdateAI(uint32 diff)
        {
            while (uint32 eventId = events.ExecuteEvent())
            {
                switch (eventId)
                {
                    case EVENT_FIREBLAST:
                        DoCastVictim(SPELL_FIREBLAST);
                        events.ScheduleEvent(EVENT_FIREBLAST, 9000);
                        break;
                    case EVENT_FROSTBOLT:
                        if (Unit *target = SelectTarget(SELECT_TARGET_RANDOM, 0))
                            DoCast(target, SPELL_FROSTBOLT);
                        break;
                    case EVENT_ARCANEMISSILES:
                        if (Unit *target = SelectTarget(SELECT_TARGET_RANDOM, 0))
                            DoCast(target, SPELL_ARCANEMISSILES);
                        break;
                    case EVENT_BERZERKERBLAZE:
                        DoCast(me, SPELL_BERZERKERBLAZE);
                        events.ScheduleEvent(EVENT_BERZERKERBLAZE, 31000);
                        break;
                    case EVENT_SPAWNCREATURE:
                        me->SummonCreature(NPCID HERE, xf, yf, zf, of, TEMPSUMMON_MANUAL_DESPAWN, 0);
                        events.ScheduleEvent(EVENT_SPAWNCREATURE, 23000);
                        break;
                }
            }
        }
    private:
        EventMap events;
   };
	
    CreatureAI* GetAI(Creature* creature) const
    {
        return new npc_boss_diedAI(creature);
    }
};

class npc_rare_boss_trigger : public CreatureScript
{
public:
    npc_rare_boss_trigger() : CreatureScript("npc_rare_boss_trigger") { }
	
    struct npc_rare_boss_triggerAI : public ScriptedAI
    {
        npc_rare_boss_triggerAI(Creature* creature) : ScriptedAI(creature) { }
		
        uint32 spawnTimer;
		
        void Reset()
        {
            spawnTimer = 3600000; // 3600000 = 1hr
        }
		
        void UpdateAI(uint32 diff)
        {
            if (spawnTimer <= diff)
            {
                int random = urand(0, 2);
                if (random == 0)
                    me->SummonCreature(ENTRYID, X, Y, Z, O, TEMPSUMMON_MANUAL_DESPAWN, 0);
                else if (random == 1)
                    me->SummonCreature(ENTRYID, X, Y, Z, O, TEMPSUMMON_MANUAL_DESPAWN, 0);
                else if (random == 2)
                    me->SummonCreature(ENTRYID, X, Y, Z, O, TEMPSUMMON_MANUAL_DESPAWN, 0);
                spawnTimer = 3600000;
            }
            else
                spawnTimer -= diff;
        }
   };
	
    CreatureAI* GetAI(Creature* creature) const
    {
        return new npc_rare_boss_triggerAI(creature);
    }
};

void AddSC_boss_trigger()
{
    new npc_rare_boss_trigger;
    new npc_boss_died;
}


Wrong section. (I can't help, sorry)

REPORT IT THEN, don't post....
 

teroare

Enthusiast
Would it, in any way, overlap with the script below ?

Code:
#include "Group.h"

class npc_boss_died : public CreatureScript
{
public:
	npc_boss_died() : CreatureScript("npc_boss_died") { }

	struct npc_boss_diedAI : public ScriptedAI
	{
		npc_boss_diedAI(Creature* creature) : ScriptedAI(creature) { }

		void JustDied(Unit* killer)
		{
			std::ostringstream ss;
			Group* group = NULL;

			if (killer->GetTypeId() == TYPEID_PLAYER)
			{
				Player* playerKiller = killer->ToPlayer();
				if (!playerKiller)
					return;

				group = playerKiller->GetGroup();
				if (!group)
				{
					ss << playerKiller->GetName()
						<< " has slain "
						<< me->GetName()
						<< " a Rare World Boss!";
					 playerKiller->CastSpell(playerKiller, 42138); // Give an xp boost just for one player?
				}
				else
				{
					for (Group::MemberSlotList::const_iterator itr = group->GetMemberSlots().begin(); itr != group->GetMemberSlots().end(); ++itr)
					{
						Group::MemberSlot const& memberSlot = *itr;

						Player* groupMember = sObjectAccessor->FindPlayer((*itr).guid);
						if (groupMember && groupMember->IsInWorld())
						{
							ss << groupMember->GetName()
								<< " has slain "
								<< me->GetName()
								<< " a Rare World Boss!";
							 groupMember->CastSpell(groupMember, 42138); // XP BUFF
						}
					}
				}
				sWorld->SendGlobalText(ss.str().c_str(), NULL);
			}
		}
	};

	CreatureAI* GetAI(Creature* creature) const
	{
		return new npc_boss_diedAI(creature);
	}
};

void AddSC_rare_boss()
{
	new npc_boss_died;
}

I think it would since it's called the same. Can I just change
Code:
CreatureScript("npc_boss_died") { }
to say npc_boss_announcer for example , and have both of them working ?

LE: also here
Code:
class npc_boss_died : public CreatureScript
and here
Code:
return new npc_boss_diedAI(creature);
and last line
Code:
new npc_boss_died;
 
Last edited:

Tommy

Founder
It wouldn't load if two scripts have the same script name.

I edited it for you:

Code:
#include "Group.h"

class npc_boss_announcer : public CreatureScript
{
public:
	npc_boss_announcer() : CreatureScript("npc_boss_announcer") { }

	struct npc_boss_announcerAI : public ScriptedAI
	{
		npc_boss_announcerAI(Creature* creature) : ScriptedAI(creature) { }

		void JustDied(Unit* killer)
		{
			std::ostringstream ss;
			Group* group = NULL;

			if (killer->GetTypeId() == TYPEID_PLAYER)
			{
				Player* playerKiller = killer->ToPlayer();
				if (!playerKiller)
					return;

				group = playerKiller->GetGroup();
				if (!group)
				{
					ss << playerKiller->GetName()
						<< " has slain "
						<< me->GetName()
						<< " a Rare World Boss!";
					 playerKiller->CastSpell(playerKiller, 42138); // Give an xp boost just for one player?
				}
				else
				{
					for (Group::MemberSlotList::const_iterator itr = group->GetMemberSlots().begin(); itr != group->GetMemberSlots().end(); ++itr)
					{
						Group::MemberSlot const& memberSlot = *itr;

						Player* groupMember = sObjectAccessor->FindPlayer((*itr).guid);
						if (groupMember && groupMember->IsInWorld())
						{
							ss << groupMember->GetName()
								<< " has slain "
								<< me->GetName()
								<< " a Rare World Boss!";
							 groupMember->CastSpell(groupMember, 42138); // XP BUFF
						}
					}
				}
				sWorld->SendGlobalText(ss.str().c_str(), NULL);
			}
		}
	};

	CreatureAI* GetAI(Creature* creature) const
	{
		return new npc_boss_announcerAI(creature);
	}
};

void AddSC_rare_boss()
{
	new npc_boss_announcer;
}

How in the world did you already mess up the indentation? :/
 

teroare

Enthusiast
I didn't mess anything up :) The script I posted is a copy paste of what you wrote in another thread ;) :D

ty anyway :)
 

Tommy

Founder
I didn't mess anything up :) The script I posted is a copy paste of what you wrote in another thread ;) :D

ty anyway :)

IS NOT, look:

Code:
#include "Group.h"

class npc_boss_died : public CreatureScript
{
public:
    npc_boss_died() : CreatureScript("npc_boss_died") { }
	
    struct npc_boss_diedAI : public ScriptedAI
    {
        npc_boss_diedAI(Creature* creature) : ScriptedAI(creature) { }
		
        void JustDied(Unit* killer)
        {
            std::ostringstream ss;
            Group* group = NULL;

            if (killer->GetTypeId() == TYPEID_PLAYER)
            {
                Player* playerKiller = killer->ToPlayer();
                if (!playerKiller)
                    return;

                group = playerKiller->GetGroup();
                if (!group)
                {
                    ss << playerKiller->GetName()
                       << " has killed "
                       << me->GetName()
                       << " a Rare Boss!";
                    //playerKiller->CastSpell(playerKiller, spellId); // Give an xp boost just for one player?
                }
                else
                {
                    for (Group::MemberSlotList::const_iterator itr = group->GetMemberSlots().begin(); itr != group->GetMemberSlots().end(); ++itr)
                    {
                        Group::MemberSlot const& memberSlot = *itr;

                        Player* groupMember = sObjectAccessor->FindPlayer((*itr).guid);
                        if (groupMember && groupMember->IsInWorld())
                        {
                            ss << groupMember->GetName()
                               << " has killed "
                               << me->GetName()
                               << " a Rare Boss!";
                            //groupMember->CastSpell(groupMember, spellId); // XP BUFF
                        }
                    }
                }
                sWorld->SendGlobalText(ss.str().c_str(), NULL);
            }
        }
   };
	
    CreatureAI* GetAI(Creature* creature) const
    {
        return new npc_boss_diedAI(creature);
    }
};
 

teroare

Enthusiast
Ohh, ok. I remember now, I have added
Code:
void AddSC_rare_boss()
{
	new npc_boss_died;
}
at the end, from the first script, before you edited it, sorry :D

So, should I use it without ? It worked with those two lines also :D

LE : Tommy, could you please tell me the meaning of x , y , z and xf, yf, zf ?
Are they coordinates ? Like, how far from the boss, the minions should spawn ?

Code:
me->SummonCreature(ENTRYID, X, Y, Z, O, TEMPSUMMON_MANUAL_DESPAWN, 0);
and
Code:
 me->SummonCreature(21706, xf, yf, zf, of, TEMPSUMMON_TIMED_DESPAWN, 2000);
 
Last edited:

Tommy

Founder
Those are the coordinates, yes. However, they are only examples. They aren't existing variables. You can either replace them with numbers or:

me->GetPositionX()
me->GetPositionY()
me->GetPositionZ()
me->GetOrientation()
 
Status
Not open for further replies.
Top