void ChatHandler::SpawnCreature(GameClient *pClient, char* pName, uint32 display_id, uint32 npcFlags, uint32 faction_id, uint32 level) { wowWData data; // Create the requested monster Character *chr = pClient->getCurrentChar(); float x = chr->getPositionX(); float y = chr->getPositionY(); float z = chr->getPositionZ(); float o = chr->getOrientation(); Unit* pUnit = new Unit(); UpdateMask unitMask; WorldServer::getSingletonPtr()->mObjectMgr.SetCreateUnitBits(unitMask); pUnit->Create(world.m_hiCreatureGuid++, (uint8*)pName, x, y, z, o); pUnit->setMapId(chr->getMapId()); pUnit->setZone(chr->getZone()); data.clear(); pUnit->setUpdateValue(OBJECT_FIELD_ENTRY, world.addCreatureName((uint8*)pUnit->getCreatureName())); pUnit->setUpdateFloatValue(OBJECT_FIELD_SCALE_X, 1.0f); pUnit->setUpdateValue(UNIT_FIELD_DISPLAYID, display_id); pUnit->setUpdateValue(UNIT_NPC_FLAGS , npcFlags); pUnit->setUpdateValue(UNIT_FIELD_FACTIONTEMPLATE , faction_id); pUnit->setUpdateValue(UNIT_FIELD_HEALTH, 100 + 30*level); pUnit->setUpdateValue(UNIT_FIELD_MAXHEALTH, 100 + 30*level); pUnit->setUpdateValue(UNIT_FIELD_LEVEL , level); pUnit->setUpdateFloatValue(UNIT_FIELD_COMBATREACH , 1.5f); pUnit->setUpdateFloatValue(UNIT_FIELD_MAXDAMAGE , 5.0f); pUnit->setUpdateFloatValue(UNIT_FIELD_MINDAMAGE , 8.0f); pUnit->setUpdateValue(UNIT_FIELD_BASEATTACKTIME, 1900); pUnit->setUpdateValue(UNIT_FIELD_BASEATTACKTIME+1, 2000); pUnit->setUpdateFloatValue(UNIT_FIELD_BOUNDINGRADIUS, 2.0f); pUnit->CreateObject(&unitMask, &data, 0); // add to the world list of creatures WPAssert( pUnit->getGUID() != 0 ); world.mCreatures[pUnit->getGUID()] = pUnit; // send create message to everyone world.SendGlobalMessage(&data); DatabaseInterface *dbi = Database::getSingleton( ).createDatabaseInterface( ); dbi->saveCreature(pUnit); Database::getSingleton( ).removeDatabaseInterface(dbi); }
void ChatHandler::GenCreature(GameClient *pClient, uint32 StartId, uint32 EndId ,uint32 StepId ) { char* pName= "Def Name "; uint32 CurrentId=1; uint16 ModuloId=0; uint32 npcFlags=0; uint32 faction_id=0; uint32 level=10; wowWData data; // Create the requested monster Character *chr = pClient->getCurrentChar(); float x = chr->getPositionX(); float y = chr->getPositionY(); float z = chr->getPositionZ(); float o = chr->getOrientation(); for (CurrentId=StartId;CurrentId<=EndId;CurrentId++) { x+= (float) 5.0f; ModuloId++; if ( ModuloId>=StepId) { x-= (float) 5.0f *(float) ModuloId; ModuloId=0; y+= (float) 10.0f; } sprintf(pName,"Id:%i",CurrentId); Unit* pUnit = new Unit(); UpdateMask unitMask; WorldServer::getSingletonPtr()->mObjectMgr.SetCreateUnitBits(unitMask); pUnit->Create(world.m_hiCreatureGuid++, (uint8*)pName, x, y, z, o); pUnit->setMapId(chr->getMapId()); pUnit->setZone(chr->getZone()); data.clear(); pUnit->setUpdateValue(OBJECT_FIELD_ENTRY, world.addCreatureName((uint8*)pUnit->getCreatureName())); pUnit->setUpdateFloatValue(OBJECT_FIELD_SCALE_X, 1.0f); pUnit->setUpdateValue(UNIT_FIELD_DISPLAYID, CurrentId); pUnit->setUpdateValue(UNIT_NPC_FLAGS , npcFlags); pUnit->setUpdateValue(UNIT_FIELD_FACTIONTEMPLATE , faction_id); pUnit->setUpdateValue(UNIT_FIELD_HEALTH, 100 + 30*level); pUnit->setUpdateValue(UNIT_FIELD_MAXHEALTH, 100 + 30*level); pUnit->setUpdateValue(UNIT_FIELD_LEVEL , level); pUnit->setUpdateFloatValue(UNIT_FIELD_COMBATREACH , 1.5f); pUnit->setUpdateFloatValue(UNIT_FIELD_MAXDAMAGE , 5.0f); pUnit->setUpdateFloatValue(UNIT_FIELD_MINDAMAGE , 8.0f); pUnit->setUpdateValue(UNIT_FIELD_BASEATTACKTIME, 1900); pUnit->setUpdateValue(UNIT_FIELD_BASEATTACKTIME+1, 2000); pUnit->setUpdateFloatValue(UNIT_FIELD_BOUNDINGRADIUS, 2.0f); pUnit->CreateObject(&unitMask, &data, 0); // add to the world list of creatures WPAssert( pUnit->getGUID() != 0 ); world.mCreatures[pUnit->getGUID()] = pUnit; // send create message to everyone world.SendGlobalMessage(&data); DatabaseInterface *dbi = Database::getSingleton( ).createDatabaseInterface( ); char sql[512]; sprintf(sql, "insert into skin set id_skin='%i',name='%s',type='0',race='0', gender='0'", CurrentId,pName); dbi->doQuery(sql); //dbi->saveCreature(pUnit); Database::getSingleton( ).removeDatabaseInterface(dbi); } }