Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- bool ChatHandler::HandleCreatureSpawnCommand(const char *args, WorldSession *m_session)
- {
- uint32 entry = atol(args);
- uint8 gender = 0;
- if(entry == 0)
- return false;
- CreatureProto * proto = CreatureProtoStorage.LookupEntry(entry);
- CreatureInfo * info = CreatureNameStorage.LookupEntry(entry);
- if(proto == 0 || info == 0)
- {
- RedSystemMessage(m_session, "Invalid entry id.");
- return true;
- }
- uint32 limittime = 350000;
- uint32 spawnlimit = 20;
- if(m_session->CanUseCommand('b'))
- {
- limittime = 350000;
- spawnlimit = 20;
- }
- if(m_session->GetPlayer()->spawnlimittime <= time(NULL))
- return true;
- m_session->GetPlayer()->spawncounter++;
- if(m_session->GetPlayer()->spawncounter >= spawnlimit)
- m_session->GetPlayer()->spawnlimittime = time(NULL) + limittime;
- uint32 limittime = 300000;
- uint32 spawnlimit = 30;
- if(m_session->CanUseCommand('bc'))
- {
- limittime = 300000;
- spawnlimit = 30;
- }
- if(m_session->GetPlayer()->spawnlimittime <= time(NULL))
- return true;
- m_session->GetPlayer()->spawncounter++;
- if(m_session->GetPlayer()->spawncounter >= spawnlimit)
- m_session->GetPlayer()->spawnlimittime = time(NULL) + limittime;
- uint32 limittime = 250000;
- uint32 spawnlimit = 40;
- if(m_session->CanUseCommand('bcd'))
- {
- limittime = 150000;
- spawnlimit = 40;
- }
- if(m_session->GetPlayer()->spawnlimittime <= time(NULL))
- return true;
- m_session->GetPlayer()->spawncounter++;
- if(m_session->GetPlayer()->spawncounter >= spawnlimit)
- m_session->GetPlayer()->spawnlimittime = time(NULL) + limittime;
- CreatureSpawn * sp = new CreatureSpawn;
- //sp->displayid = info->DisplayID;
- gender = info->GenerateModelId(&sp->displayid);
- sp->entry = entry;
- sp->entry = entry;
- sp->form = 0;
- sp->id = objmgr.GenerateCreatureSpawnID();
- sp->movetype = 0;
- sp->x = m_session->GetPlayer()->GetPositionX();
- sp->y = m_session->GetPlayer()->GetPositionY();
- sp->z = m_session->GetPlayer()->GetPositionZ();
- sp->o = m_session->GetPlayer()->GetOrientation();
- sp->emote_state = 0;
- sp->flags = 0;
- sp->factionid = proto->Faction;
- sp->bytes0 = sp->setbyte(0,2,gender);
- sp->bytes1 = 0;
- sp->bytes2 = 0;
- //sp->respawnNpcLink = 0;
- sp->stand_state = 0;
- sp->death_state = 0;
- sp->channel_target_creature = sp->channel_target_go = sp->channel_spell = 0;
- sp->MountedDisplayID = 0;
- sp->Item1SlotDisplay = 0;
- sp->Item2SlotDisplay = 0;
- sp->Item3SlotDisplay = 0;
- sp->CanFly = 0;
- sp->phase = m_session->GetPlayer()->GetPhase();
- Creature * p = m_session->GetPlayer()->GetMapMgr()->CreateCreature(entry);
- Arcemu::Util::ARCEMU_ASSERT( p != NULL );
- p->Load(sp, (uint32)NULL, NULL);
- p->m_loadedFromDB = true;
- p->PushToWorld(m_session->GetPlayer()->GetMapMgr());
- uint32 x = m_session->GetPlayer()->GetMapMgr()->GetPosX(m_session->GetPlayer()->GetPositionX());
- uint32 y = m_session->GetPlayer()->GetMapMgr()->GetPosY(m_session->GetPlayer()->GetPositionY());
- // Add spawn to map
- m_session->GetPlayer()->GetMapMgr()->GetBaseMap()->GetSpawnsListAndCreate(
- x,
- y)->CreatureSpawns.push_back(sp);
- MapCell * mCell = m_session->GetPlayer()->GetMapMgr()->GetCell( x, y );
- if( mCell != NULL )
- mCell->SetLoaded();
- BlueSystemMessage(m_session, "Spawned a creature `%s` with entry %u at %f %f %f on map %u", info->Name,
- entry, sp->x, sp->y, sp->z, m_session->GetPlayer()->GetMapId());
- // Save it to the database.
- p->SaveToDB();
- sGMLog.writefromsession(m_session, "spawned a %s at %u %f %f %f", info->Name, m_session->GetPlayer()->GetMapId(),sp->x,sp->y,sp->z);
- return true;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement