These boss scripts are not easy at all, they usually contain tones on code, just look at illidan or onyxia. Ok, i'm going to be using Rhakzor a deadmines boss, he's simple and hes a pretty awesome boss I must say. (found on ascent, no GNU code on it) Now as again read through the script.
Code:
#include "StdAfx.h"
#include "Setup.h"

// Rhakzor - Sends sound and talk message on enter combat, opens door on death.

class RhahkZorAI : public CreatureAIScript
{
public:
    RhahkZorAI(Creature* pCreature) : CreatureAIScript(pCreature) {}

    void OnDied(Unit * mKiller)
    {
        // Find "Factory Door"
        // GetGameObjectNearestCoords works here too.

        GameObject *pDoor = _unit->GetMapMgr()->GetInterface()->GetObjectNearestCoords<GameObject, TYPEID_GAMEOBJECT>(
            13965, -190.860092f, -456.332184f, 54.496822f);
        if(pDoor == 0)
            return;

        // Open the door
        pDoor->SetUInt32Value(GAMEOBJECT_FLAGS, 33);
        pDoor->SetUInt32Value(GAMEOBJECT_STATE, 0);
    }

    void OnCombatStart(Unit* mTarget)
    {
        _unit->SendChatMessage(CHAT_MSG_MONSTER_YELL, LANG_UNIVERSAL, "Van Cleef pay big for your heads!");
        _unit->PlaySoundToSet(5774);
    }

    void Destroy()
    {
        delete (RhahkZorAI*)this;
    }

    static CreatureAIScript *Create(Creature * c) { return new RhahkZorAI(c); }
};

CreatureAIScript * create_rhakzor(Creature * c) { return new RhahkZorAI(c); }

See? told ya it was simple! By now you should know what this part means, not even going to explain this bit.
#include "StdAfx.h"
#include "Setup.h"

// Rhakzor - Sends sound and talk message on enter combat, opens door on death.


But if you don't understand what the ".h" means it simply means "using namespace std;"
class RhahkZorAI : public CreatureAIScript
{
public:
RhahkZorAI(Creature* pCreature) : CreatureAIScript(pCreature) {}

Wow.. Now were getting to some hard stuff.. The "RhahkZorAI" is the name of the creature, the AI is always left intact. Now the public is always keep't the same in boss scripts. But in other scripts you may want to put private, Protected (Don't need to know about this stuff atm) Now we have to start the body of the script.

void OnDied(Unit * mKiller)
{
// Find "Factory Door"
// GetGameObjectNearestCoords works here too.

GameObject *pDoor = _unit->GetMapMgr()->GetInterface()->GetObjectNearestCoords<GameObject, TYPEID_GAMEOBJECT>(
13965, -190.860092f, -456.332184f, 54.496822f);
if(pDoor == 0)
return;

Now, the void OnDied is what happens when the creature dies, Ok, now we have to find where the damn door is! Burlex here is working in f I prefer working in coords.

// Open the door
pDoor->SetUInt32Value(GAMEOBJECT_FLAGS, 33);
pDoor->SetUInt32Value(GAMEOBJECT_STATE, 0);
}


Now, this part is what happens when Rhaz dies, usually if we wanted to open a door we'd be using
Code:
GameObject *gate = SpawnGameObject(179921, 489, 1471.554688f, 1458.778076f, 362.633240f, 0, 33, 114, 2.33271f);
    gate->PushToWorld(m_mapMgr);
    m_gates.push_back(gate);
But since we want him to open the door on death we need another code. Now if you wish you can skip this part about doors on death, it's not that easy. Staying? Ok, now when you kill a creature and the creature opens the door for you, you must always have this code,
Code:
pDoor->SetUInt32Value(GAMEOBJECT_FLAGS, 33);
        pDoor->SetUInt32Value(GAMEOBJECT_STATE, 0);

Although for opening doors like in a battleground some use pDoor->SetUInt32Value(GAMEOBJECTS_FLAGS, 64);
pDoor->SetUInt32Value(GAMEOBJECTS_FLAGS, 0);
You dont need to worry about that part either, Kinda advanced, we need to keep it simple.

void OnCombatStart(Unit* mTarget)
{
_unit->SendChatMessage(CHAT_MSG_MONSTER_YELL, LANG_UNIVERSAL, "Van Cleef pay big for your heads!");
_unit->PlaySoundToSet(5774);
}

Ok, now we need to start Combat
_unit->SendChatMessage(CHAT_MSG_MONSTER_YELL, LANG_UNIVERSAL, "");
Is the best way to send a chat message, there are alot more ways to send a message but this is the most effective.
Now you send the PlaySoundToSet(5774);? the 5774 means that it will play that specific sound saying "Van Cleef pay big for your heads!"

void Destroy()
{
delete (RhahkZorAI*)this;
}



static CreatureAIScript *Create(Creature * c) { return new RhahkZorAI(c); }
};

CreatureAIScript * create_rhakzor(Creature * c) { return new RhahkZorAI(c); }

Now, this is just finishing off the script Every part it has Rhahzor in it thats just the name of the boss.

void SetupDeadmines(ScriptMgr * mgr)
{
mgr->register_creature_script(644, &RhahkZorAI::Create);

The SetupDeadmines is just what the script is going to be called, the Rhahzor is the boss name.
Now registing this creature is simple, register_creature_script varies not the same register all the time so this is the structure. (NPCID, &NPCNAMEAI::Create);

And now we're done! Now you have knowledge on how to create your own boss.
Please post any questions/Suggestions/Comments in this post.

You may post this on any forum with the correct credits.









› See More: Understanding Boss Scripts