Jump to content
  • 0

Spawning Creature Problem



Hey all,

I'm having a quiet simple problem.

I tried to create a own "spawning" commando.

Just to spawn a creature directly in front of me, lets say with the creature_template ID 68.

But always I spawn it (using the SummonCreature method from the class Creature),

my server immediately crushes, with no useful information in my logfiles.

Could anybody provide me a view lines of source in which function/file I could find the definition

for the creature spawning?

Thanks in advice.

Link to comment
Share on other sites

5 answers to this question

Recommended Posts

Obviously you have already some code.

And you have a question related to this code.

Unless somebody has a very powerfull crystal ball here, I think the most reasonable would be if you posted your patch here, so that it can be examined ;)

And i strongly suggest a patch format, because this would the easiest show all your changes of this - and give ppl the possiblity to reproduce (the error!) if wanted.

Link to comment
Share on other sites

@ LilleCarl:

The Spawn should be a summon which should stay multiple hours.

My Idea, for the spawn, is to create a new creature_template in the DB and spawn it.


Of course you will need it :(

Sorry, was late i totally forgot about it!

This is the code I'm using:


<         bool HandleArmyCommand(char* args);


<         { "army",            SEC_PLAYER,            false, &ChatHandler::HandleArmyCommand,               "", NULL },


< bool ChatHandler::HandleArmyCommand(char* args)
< {
<     if (!*args)
<     {
<         PSendSysMessage("|cffff0000usage: .army add");
<         SetSentErrorMessage(true);
<         return false;
<     }
<     char *cmd = strtok ((char *) args, " ");
<     std::string cmdStr = cmd;
<     if (cmdStr == "add")
<     {
<         PSendSysMessage("Adding");
<         Unit *target = NULL;
<         char *orderChar = strtok(NULL, " ");
<         PSendSysMessage("Added Infantry squadron");
<         uint32 id;
<         id = 68;//ID 68 = Stormwind City Guard
<         Player *chr = m_session->GetPlayer();
<         Creature* m_creature;
<         m_creature->SummonCreature( id, chr->GetPositionX() , chr->GetPositionY(), chr->GetPositionZ (), chr->GetOrientation() ,TEMPSUMMON_MANUAL_DESPAWN ,0);
<     }    
<     return true;
< }

(The codeboxes are actually pretty nice!)

Link to comment
Share on other sites

Silly me :(

Thanks for the hint with HandleNpcAddCommand, that helped indeed a lot!

Now the summon works and I can continue with my work.


And there is the next big questionmark on my road..

Adding the creature with "map ->Add (id)" makes it possible to add waypoints, but it does not get aggro by itself.

Adding the creature with "creature->SummonCreature() " it will be able to attack but not to add any waypoints :/

There must be a way to summon a creature, edit waypoints and getting aggro. But i couldn't find it :(

Creature Template ID 100.000 is a custom creature from me.

       uint32 id;
       id = 100000; //ID 68 = Stormwind City Guard
       CreatureInfo const *cinfo = ObjectMgr::GetCreatureTemplate(id);
       if (!cinfo)
           return false;

       Player *chr = m_session->GetPlayer();

       Map *map = chr->GetMap();

       Creature* m_creature = new Creature;

       CreatureCreatePos pos(chr, chr->GetOrientation());

       // used guids from specially reserved range (can be 0 if no free values)
       uint32 lowguid = sObjectMgr.GenerateStaticCreatureLowGuid();
       if (!lowguid)
           return false;

       if (!m_creature->Create(lowguid, pos,cinfo))
           delete m_creature;
           PSendSysMessage("|cffff0000 nicht so gut");
           return false;

       m_creature->LoadFromDB(lowguid, map);
       //! Has to be changed to an correct never respawn code.
       uint32  highrespawn = 9999999;

       m_creature->SummonCreature( id, chr->GetPositionX() , chr->GetPositionY(), chr->GetPositionZ (), chr->GetOrientation() ,TEMPSUMMON_DEAD_DESPAWN ,1);
       uint32 db_guid = m_creature->GetGUIDLow();

       // Move it
       sWaypointMgr.AddLastNode(lowguid, chr->GetPositionX(), chr->GetPositionY() + 2.0, chr->GetPositionZ(), chr->GetOrientation(), 0, 0);

Oh my.. It seems. I need to learn a view more thinks on mangos

Link to comment
Share on other sites


This topic is now archived and is closed to further replies.

  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue. Privacy Policy Terms of Use