• 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] how can i add an respawn time ?

Status
Not open for further replies.

lexir

Enthusiast
Hello . i got a question how can i add on my script (its an creature)
an respawn time when its killed ??
Code:
/*
   By aleks 
*/
#include "Stdarx.h"
#include "Setup.h"

#define Creature World Boss


class CreatureAI : public ArcscriptCreatureAI 
(
    ARSCRIPT_FACTORY_FUNCTION(CreatureAI, ArcScriptCreatureAI) ; 
    CreatureAI(Creature *pCreature) : ArcScriptCreatureAI (pCreature)
    (
	  AddEmote (Event_OnCombatStart, "You Die", Text_Yell) ;
	  AddEmote (Event_OnTargetDied, "You Fool", Text_Yell) ;
	  AddEmote (Event_OnDied, "I can't Belive pigs killed me.", Text_Yell)


void SetupCreatureAI (ScriptMgr *mgr)
(
    mgr->register_creature_script(Creature, AI::Create) ;
)
	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;
            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;
}
 

Tommy

Founder
Why are you using ArcEmu scripting system? You can't use that on TrinityCore..

Correction:

Code:
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;
            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;
}

I will tell you the problem with the rare boss spawning every 24hr is:

A player must be around the trigger for it to count down it's script, so if player's aren't around the rare boss spawner trigger, your boss won't spawn at all. I'll make the trigger for you since you want it very badly..

Here it is:

Code:
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)
            {
                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;
}
 

lexir

Enthusiast
the first code i have ._.
uhm thank you tommy .. i know thats not in support but can you give me some tipps to learn TrinityCore scripting ? i am an puuuuure beginner...
 

lexir

Enthusiast
aah an secound question. if i got 2 creature ids. can i do it that they spawn randomly i mean if i got 2 ids that onetime that creature spawns and in 24h the other ?
 

Tommy

Founder
I edited your script so it will pick a random boss to spawn:

Code:
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;
}
 
Status
Not open for further replies.
Top