SHARE
TWEET

Untitled

a guest Aug 12th, 2017 52 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. bool ChatHandler::HandleCreatureSpawnCommand(const char *args, WorldSession *m_session)
  2. {
  3.     uint32 entry = atol(args);
  4.     uint8 gender = 0;
  5.  
  6.     if(entry == 0)
  7.         return false;
  8.  
  9.     CreatureProto * proto = CreatureProtoStorage.LookupEntry(entry);
  10.     CreatureInfo * info = CreatureNameStorage.LookupEntry(entry);
  11.     if(proto == 0 || info == 0)
  12.     {
  13.         RedSystemMessage(m_session, "Invalid entry id.");
  14.         return true;
  15.     }
  16.  
  17.      uint32 limittime = 350000;
  18.  uint32 spawnlimit = 20;
  19.  if(m_session->CanUseCommand('b'))
  20.  {
  21.   limittime = 350000;
  22.   spawnlimit = 20;
  23.  }
  24.  
  25.  if(m_session->GetPlayer()->spawnlimittime <= time(NULL))
  26.   return true;
  27.  m_session->GetPlayer()->spawncounter++;
  28.  if(m_session->GetPlayer()->spawncounter >= spawnlimit)
  29.   m_session->GetPlayer()->spawnlimittime = time(NULL) + limittime;
  30.  
  31.   uint32 limittime = 300000;
  32.  uint32 spawnlimit = 30;
  33.  if(m_session->CanUseCommand('bc'))
  34.  {
  35.   limittime = 300000;
  36.   spawnlimit = 30;
  37.  }
  38.  
  39.  if(m_session->GetPlayer()->spawnlimittime <= time(NULL))
  40.   return true;
  41.  m_session->GetPlayer()->spawncounter++;
  42.  if(m_session->GetPlayer()->spawncounter >= spawnlimit)
  43.   m_session->GetPlayer()->spawnlimittime = time(NULL) + limittime;
  44.  
  45.   uint32 limittime = 250000;
  46.  uint32 spawnlimit = 40;
  47.  if(m_session->CanUseCommand('bcd'))
  48.  {
  49.   limittime = 150000;
  50.   spawnlimit = 40;
  51.  }
  52.  
  53.  if(m_session->GetPlayer()->spawnlimittime <= time(NULL))
  54.   return true;
  55.  m_session->GetPlayer()->spawncounter++;
  56.  if(m_session->GetPlayer()->spawncounter >= spawnlimit)
  57.   m_session->GetPlayer()->spawnlimittime = time(NULL) + limittime;
  58.  
  59.     CreatureSpawn * sp = new CreatureSpawn;
  60.     //sp->displayid = info->DisplayID;
  61.     gender = info->GenerateModelId(&sp->displayid);
  62.     sp->entry = entry;
  63.     sp->entry = entry;
  64.     sp->form = 0;
  65.     sp->id = objmgr.GenerateCreatureSpawnID();
  66.     sp->movetype = 0;
  67.     sp->x = m_session->GetPlayer()->GetPositionX();
  68.     sp->y = m_session->GetPlayer()->GetPositionY();
  69.     sp->z = m_session->GetPlayer()->GetPositionZ();
  70.     sp->o = m_session->GetPlayer()->GetOrientation();
  71.     sp->emote_state = 0;
  72.     sp->flags = 0;
  73.     sp->factionid = proto->Faction;
  74.     sp->bytes0 = sp->setbyte(0,2,gender);
  75.     sp->bytes1 = 0;
  76.     sp->bytes2 = 0;
  77.     //sp->respawnNpcLink = 0;
  78.     sp->stand_state = 0;
  79.     sp->death_state = 0;
  80.     sp->channel_target_creature = sp->channel_target_go = sp->channel_spell = 0;
  81.     sp->MountedDisplayID = 0;
  82.     sp->Item1SlotDisplay = 0;
  83.     sp->Item2SlotDisplay = 0;
  84.     sp->Item3SlotDisplay = 0;
  85.     sp->CanFly = 0;
  86.     sp->phase = m_session->GetPlayer()->GetPhase();
  87.  
  88.  
  89.     Creature * p = m_session->GetPlayer()->GetMapMgr()->CreateCreature(entry);
  90.     Arcemu::Util::ARCEMU_ASSERT(   p != NULL );
  91.     p->Load(sp, (uint32)NULL, NULL);
  92.     p->m_loadedFromDB = true;
  93.     p->PushToWorld(m_session->GetPlayer()->GetMapMgr());
  94.  
  95.     uint32 x = m_session->GetPlayer()->GetMapMgr()->GetPosX(m_session->GetPlayer()->GetPositionX());
  96.     uint32 y = m_session->GetPlayer()->GetMapMgr()->GetPosY(m_session->GetPlayer()->GetPositionY());
  97.  
  98.     // Add spawn to map
  99.     m_session->GetPlayer()->GetMapMgr()->GetBaseMap()->GetSpawnsListAndCreate(
  100.         x,
  101.         y)->CreatureSpawns.push_back(sp);
  102.  
  103.     MapCell * mCell = m_session->GetPlayer()->GetMapMgr()->GetCell( x, y );
  104.  
  105.     if( mCell != NULL )
  106.         mCell->SetLoaded();
  107.  
  108.     BlueSystemMessage(m_session, "Spawned a creature `%s` with entry %u at %f %f %f on map %u", info->Name,
  109.         entry, sp->x, sp->y, sp->z, m_session->GetPlayer()->GetMapId());
  110.  
  111.     // Save it to the database.
  112.     p->SaveToDB();
  113.  
  114.     sGMLog.writefromsession(m_session, "spawned a %s at %u %f %f %f", info->Name, m_session->GetPlayer()->GetMapId(),sp->x,sp->y,sp->z);
  115.  
  116.     return true;
  117. }
RAW Paste Data
Top