本文整理汇总了C++中Creature::Create方法的典型用法代码示例。如果您正苦于以下问题:C++ Creature::Create方法的具体用法?C++ Creature::Create怎么用?C++ Creature::Create使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Creature
的用法示例。
在下文中一共展示了Creature::Create方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: AddNPCPassenger
uint32 Transport::AddNPCPassenger(uint32 tguid, uint32 entry, float x, float y, float z, float o, uint32 anim)
{
Map* map = GetMap();
Creature* pCreature = new Creature;
if(!pCreature->Create(sObjectMgr->GenerateLowGuid(HIGHGUID_UNIT), map, GetPhaseMask(), entry, 0, GetGOInfo()->faction, 0, 0, 0, 0))
{
delete pCreature;
return 0;
}
pCreature->SetTransport(this);
pCreature->AddUnitMovementFlag(MOVEMENTFLAG_ONTRANSPORT);
pCreature->m_movementInfo.guid = GetGUID();
pCreature->m_movementInfo.t_pos.Relocate(x, y, z, o);
if(anim)
pCreature->SetUInt32Value(UNIT_NPC_EMOTESTATE, anim);
pCreature->Relocate(
GetPositionX() + (x * cos(GetOrientation()) + y * sin(GetOrientation() + float(M_PI))),
GetPositionY() + (y * cos(GetOrientation()) + x * sin(GetOrientation())),
z + GetPositionZ(),
o + GetOrientation());
pCreature->SetHomePosition(pCreature->GetPositionX(), pCreature->GetPositionY(), pCreature->GetPositionZ(), pCreature->GetOrientation());
if(!pCreature->IsPositionValid())
{
sLog->outError("Creature (guidlow %d, entry %d) not created. Suggested coordinates isn't valid (X: %f Y: %f)", pCreature->GetGUIDLow(), pCreature->GetEntry(), pCreature->GetPositionX(), pCreature->GetPositionY());
delete pCreature;
return 0;
}
map->Add(pCreature);
m_NPCPassengerSet.insert(pCreature);
if(tguid == 0)
{
++currenttguid;
tguid = currenttguid;
}
else
currenttguid = std::max(tguid, currenttguid);
pCreature->SetGUIDTransport(tguid);
sScriptMgr->OnAddCreaturePassenger(this, pCreature);
return tguid;
}
示例2: AddCapturePoint
bool OutdoorPvPObjective::AddCapturePoint(uint32 entry, uint32 map, float x, float y, float z, float o, float rotation0, float rotation1, float rotation2, float rotation3)
{
Map * pMap = MapManager::Instance().FindMap(map);
if(!pMap)
return false;
GameObject* go = new GameObject;
if (!go->Create(sObjectMgr.GenerateLowGuid(HIGHGUID_GAMEOBJECT), entry, pMap,
PHASEMASK_NORMAL, x, y, z, o, rotation0, rotation1, rotation2, rotation3, 100, GO_STATE_READY))
{
sLog.outError("OutdoorPvP: Gameobject template %u not found in database.", entry);
delete go;
// TODO: Should we return here?
//return false;
}
else
go->AddToWorld();
Creature* pCreature = new Creature;
if (!pCreature->Create(sObjectMgr.GenerateLowGuid(HIGHGUID_UNIT), pMap,PHASEMASK_NORMAL, OPVP_TRIGGER_CREATURE_ENTRY, 0))
{
sLog.outError("OutdoorPvP: Can't create creature entry: %u",entry);
delete pCreature;
return false;
}
pCreature->Relocate(x, y, z, o);
if (!pCreature->IsPositionValid())
{
sLog.outError("OutdoorPvP: Creature (guidlow %d, entry %d) not added to opvp. Suggested coordinates isn't valid (X: %f Y: %f)",pCreature->GetGUIDLow(),pCreature->GetEntry(),pCreature->GetPositionX(),pCreature->GetPositionY());
delete pCreature;
return false;
}
pCreature->AIM_Initialize();
pMap->Add(pCreature);
m_CapturePointCreature = MAKE_NEW_GUID(pCreature->GetGUID(), OPVP_TRIGGER_CREATURE_ENTRY, HIGHGUID_UNIT);
m_CapturePoint = MAKE_NEW_GUID(go->GetGUID(), entry, HIGHGUID_GAMEOBJECT);
// TODO: Use proper outdoor PvP GO type.
GameObjectInfo const* goinfo = go->GetGOInfo();
m_ShiftMaxPhase = goinfo->raw.data[17];
m_ShiftMaxCaptureSpeed = m_ShiftMaxPhase / float(goinfo->raw.data[16]);
m_NeutralValue = goinfo->raw.data[12];
return true;
}
示例3: HandleAddSpwCommand
bool ChatHandler::HandleAddSpwCommand(const char* args)
{
char* charID = strtok((char*)args, " ");
if (!charID)
return false;
uint32 id = atoi(charID);
//QueryResult *result = sDatabase.PQuery("SELECT `modelid`,`flags`,`faction`,`level`,`name` FROM `creature_template` WHERE `entry` = '%u'", id);
//if(result)
//{
//Field *fields = result->Fetch();
//WorldPacket data;
Player *chr = m_session->GetPlayer();
float x = chr->GetPositionX();
float y = chr->GetPositionY();
float z = chr->GetPositionZ();
float o = chr->GetOrientation();
Creature* pCreature = new Creature;
if (!pCreature->Create(objmgr.GenerateLowGuid(HIGHGUID_UNIT), chr->GetMapId(), x, y, z, o, id))
{
delete pCreature;
return false;
}
pCreature->AIM_Initialize();
//pCreature->SetUInt32Value(UNIT_FIELD_HEALTH , 1); // temp set on 1 HP needs to be MAX HP (strange error)
sLog.outDebug(LANG_ADD_OBJ);
MapManager::Instance().GetMap(pCreature->GetMapId())->Add(pCreature);
pCreature->SaveToDB();
//delete result;
return true;
//}
//else
// delete result;
//return false;
}
示例4: AddNPCPassengerInInstance
Creature* Transporter::AddNPCPassengerInInstance(uint32 entry, float x, float y, float z, float o, uint32 /*anim*/)
{
MapMgr* map = GetMapMgr();
CreatureProperties const* creature_properties = sMySQLStore.getCreatureProperties(entry);
if (creature_properties == nullptr || map == nullptr)
return nullptr;
#if VERSION_STRING != Cata
float transporter_x = obj_movement_info.transport_data.relativePosition.x + x;
float transporter_y = obj_movement_info.transport_data.relativePosition.y + y;
float transporter_z = obj_movement_info.transport_data.relativePosition.z + z;
#else
float transporter_x = obj_movement_info.getTransportPosition()->x + x;
float transporter_y = obj_movement_info.getTransportPosition()->y + y;
float transporter_z = obj_movement_info.getTransportPosition()->z + z;
#endif
Creature* pCreature = map->CreateCreature(entry);
pCreature->Create(map->GetMapId(), transporter_x, transporter_y, transporter_z, (std::atan2(transporter_x, transporter_y) + float(M_PI)) + o);
pCreature->Load(creature_properties, transporter_x, transporter_y, transporter_z, (std::atan2(transporter_x, transporter_y) + float(M_PI)) + o);
pCreature->AddToWorld(map);
pCreature->SetUnitMovementFlags(MOVEFLAG_TRANSPORT);
#if VERSION_STRING != Cata
pCreature->obj_movement_info.transport_data.relativePosition.x = x;
pCreature->obj_movement_info.transport_data.relativePosition.y = y;
pCreature->obj_movement_info.transport_data.relativePosition.z = z;
pCreature->obj_movement_info.transport_data.relativePosition.o = o;
pCreature->obj_movement_info.transport_data.transportGuid = getGuid();
#else
pCreature->obj_movement_info.setTransportData(getGuid(), x, y, z, o, 0, 0);
#endif
pCreature->m_transportData.transportGuid = this->getGuid();
pCreature->m_transportData.relativePosition.x = x;
pCreature->m_transportData.relativePosition.y = y;
pCreature->m_transportData.relativePosition.z = z;
pCreature->m_transportData.relativePosition.o = o;
m_creatureSetMutex.Acquire();
m_NPCPassengerSet.insert(pCreature);
m_creatureSetMutex.Release();
return pCreature;
}
示例5: AddNPCPassenger
Creature* Transport::AddNPCPassenger(uint32 tguid, uint32 entry, float x, float y, float z, float o, uint32 anim)
{
Map* map = GetMap();
//make it world object so it will not be unloaded with grid
Creature* creature = new Creature(true);
if (!creature->Create(sObjectMgr->GenerateLowGuid(HIGHGUID_UNIT), map, GetPhaseMask(), entry, 0, GetGOInfo()->faction, 0, 0, 0, 0))
{
delete creature;
return 0;
}
creature->SetTransport(this);
creature->AddUnitMovementFlag(MOVEMENTFLAG_ONTRANSPORT);
creature->m_movementInfo.guid = GetGUID();
creature->m_movementInfo.t_pos.Relocate(x, y, z, o);
o += GetOrientation();
MapManager::NormalizeOrientation(o);
creature->Relocate(
GetPositionX() + (x * cos(GetOrientation()) + y * sin(GetOrientation() + float(M_PI))),
GetPositionY() + (y * cos(GetOrientation()) + x * sin(GetOrientation())),
z + GetPositionZ(),
o);
creature->SetHomePosition(creature->GetPositionX(), creature->GetPositionY(), creature->GetPositionZ(), creature->GetOrientation());
creature->SetTransportHomePosition(creature->m_movementInfo.t_pos);
if (!creature->IsPositionValid())
{
sLog->outError("Creature (guidlow %d, entry %d) not created. Suggested coordinates isn't valid (X: %f Y: %f)", creature->GetGUIDLow(), creature->GetEntry(), creature->GetPositionX(), creature->GetPositionY());
delete creature;
return 0;
}
map->AddToMap(creature);
m_NPCPassengerSet.insert(creature);
creature->setActive(true);
sScriptMgr->OnAddCreaturePassenger(this, creature);
return creature;
}
示例6: CreateNPCPassenger
Creature* Transport::CreateNPCPassenger(uint32 entry, float x, float y, float z, float o, CreatureData const* data /*= NULL*/)
{
Map* map = GetMap();
Creature* creature = new Creature();
if (!creature->Create(sObjectMgr->GenerateLowGuid(HIGHGUID_UNIT), map, GetPhaseMask(), entry, 0, GetGOInfo()->faction, 0.0f, 0.0f, 0.0f, 0.0f, data))
{
delete creature;
return NULL;
}
creature->SetTransport(this);
creature->AddUnitMovementFlag(MOVEMENTFLAG_ONTRANSPORT);
creature->m_movementInfo.guid = GetGUID();
creature->m_movementInfo.t_pos.Relocate(x, y, z, o);
o += GetOrientation();
MapManager::NormalizeOrientation(o);
creature->Relocate(GetPositionX() + (x * cos(GetOrientation()) + y * sin(GetOrientation() + float(M_PI))),
GetPositionY() + (y * cos(GetOrientation()) + x * sin(GetOrientation())),
z + GetPositionZ(), o);
creature->SetHomePosition(creature->GetPositionX(), creature->GetPositionY(), creature->GetPositionZ(), creature->GetOrientation());
if (!creature->IsPositionValid())
{
sLog->outError("Creature (guidlow %d, entry %d) not created. Suggested coordinates isn't valid (X: %f Y: %f)",creature->GetGUIDLow(),creature->GetEntry(),creature->GetPositionX(),creature->GetPositionY());
delete creature;
return NULL;
}
creature->setActive(true);
map->Add(creature);
AddPassenger(creature);
sScriptMgr->OnAddCreaturePassenger(this, creature);
return creature;
}
示例7:
Creature *Battlefield::SpawnCreature(uint32 entry, float x, float y, float z, float o, TeamId team)
{
//Get map object
Map* map = const_cast<Map*>(sMapMgr->CreateBaseMap(_MapId));
if (!map)
{
sLog->outError("Can't create creature entry: %u map not found", entry);
return 0;
}
//Create creature
Creature* creature = new Creature;
if (!creature->Create(sObjectMgr->GenerateLowGuid(HIGHGUID_UNIT), map, PHASEMASK_NORMAL, entry, 0, team, x, y, z, o))
{
sLog->outError("Can't create creature entry: %u", entry);
delete creature;
return NULL;
}
creature->SetHomePosition(x, y, z, o);
CreatureTemplate const* cinfo = sObjectMgr->GetCreatureTemplate(entry);
if (!cinfo)
{
sLog->outErrorDb("Battleground::AddCreature: entry %u does not exist.", entry);
return NULL;
}
// force using DB speeds -- do we really need this?
creature->SetSpeed(MOVE_WALK, cinfo->speed_walk);
creature->SetSpeed(MOVE_RUN, cinfo->speed_run);
// Set creature in world
map->AddToMap(creature);
creature->setActive(true);
return creature;
}
示例8: AddNPCPassengerInInstance
// gunship data
Creature* Transport::AddNPCPassengerInInstance(uint32 entry, float x, float y, float z, float o, uint32 anim)
{
Map* map = GetMap();
Creature* creature = new Creature;
if (!creature->Create(sObjectMgr->GenerateLowGuid(HIGHGUID_UNIT), map, GetPhaseMask(), entry, 0, GetGOInfo()->faction, 0, 0, 0, 0))
{
delete creature;
return 0;
}
creature->SetTransport(this);
creature->AddUnitMovementFlag(MOVEMENTFLAG_ONTRANSPORT);
creature->m_movementInfo.guid = GetGUID();
creature->m_movementInfo.transport.pos.Relocate(x, y, z, o);
creature->Relocate(
GetPositionX() + (x * cos(GetOrientation()) + y * sin(GetOrientation() + float(M_PI))),
GetPositionY() + (y * cos(GetOrientation()) + x * sin(GetOrientation())),
z + GetPositionZ(),
o + GetOrientation());
creature->SetHomePosition(creature->GetPositionX(), creature->GetPositionY(), creature->GetPositionZ(), creature->GetOrientation());
if (!creature->IsPositionValid())
{
delete creature;
return 0;
}
map->AddToMap(creature);
m_NPCPassengerSet.insert(creature);
creature->setActive(true);
sScriptMgr->OnAddCreaturePassenger(this, creature);
return creature;
}
示例9: SpawnCreature
Creature* Battlefield::SpawnCreature(uint32 entry, Position const& pos)
{
//Get map object
Map* map = sMapMgr->CreateBaseMap(m_MapId);
if (!map)
{
TC_LOG_ERROR("bg.battlefield", "Battlefield::SpawnCreature: Can't create creature entry: %u, map not found.", entry);
return nullptr;
}
CreatureTemplate const* cinfo = sObjectMgr->GetCreatureTemplate(entry);
if (!cinfo)
{
TC_LOG_ERROR("bg.battlefield", "Battlefield::SpawnCreature: entry %u does not exist.", entry);
return nullptr;
}
float x, y, z, o;
pos.GetPosition(x, y, z, o);
Creature* creature = new Creature();
if (!creature->Create(map->GenerateLowGuid<HighGuid::Creature>(), map, PHASEMASK_NORMAL, entry, x, y, z, o))
{
TC_LOG_ERROR("bg.battlefield", "Battlefield::SpawnCreature: Can't create creature entry: %u", entry);
delete creature;
return nullptr;
}
creature->SetHomePosition(x, y, z, o);
// Set creature in world
map->AddToMap(creature);
creature->setActive(true);
return creature;
}
示例10: AddCreature
bool OutdoorPvPObjective::AddCreature(uint32 type, uint32 entry, uint32 teamval, uint32 map, float x, float y, float z, float o, uint32 spawntimedelay)
{
CreatureInfo const *cinfo = objmgr.GetCreatureTemplate(entry);
if(!cinfo)
{
return false;
}
uint32 displayId = objmgr.ChooseDisplayId(teamval, cinfo, NULL);
CreatureModelInfo const *minfo = objmgr.GetCreatureModelRandomGender(displayId);
if (!minfo)
{
return false;
}
else
displayId = minfo->modelid; // it can be different (for another gender)
uint32 guid = objmgr.GenerateLowGuid(HIGHGUID_UNIT);
CreatureData& data = objmgr.NewOrExistCreatureData(guid);
data.id = entry;
data.mapid = map;
data.displayid = displayId;
data.equipmentId = cinfo->equipmentId;
data.posX = x;
data.posY = y;
data.posZ = z;
data.orientation = o;
data.spawntimesecs = spawntimedelay;
data.spawndist = 0;
data.currentwaypoint = 0;
data.curhealth = cinfo->maxhealth;
data.curmana = cinfo->maxmana;
data.is_dead = false;
data.movementType = cinfo->MovementType;
data.spawnMask = 1;
data.phaseMask = PHASEMASK_NORMAL;
objmgr.AddCreatureToGrid(guid, &data);
m_Creatures[type] = MAKE_NEW_GUID(guid, entry, HIGHGUID_UNIT);
m_CreatureTypes[m_Creatures[type]] = type;
Map * pMap = MapManager::Instance().FindMap(map);
if(!pMap)
return true;
Creature* pCreature = new Creature;
if (!pCreature->Create(guid, pMap, PHASEMASK_NORMAL, entry, teamval))
{
sLog.outError("OutdoorPvPObjective: Can't create creature entry: %u",entry);
delete pCreature;
return true;
}
pCreature->AIM_Initialize();
pCreature->Relocate(x, y, z, o);
if(!pCreature->IsPositionValid())
{
sLog.outError("OutdoorPvPObjective: ERROR: Creature (guidlow %d, entry %d) not added to opvp. Suggested coordinates isn't valid (X: %f Y: %f)",pCreature->GetGUIDLow(),pCreature->GetEntry(),pCreature->GetPositionX(),pCreature->GetPositionY());
return false;
}
if(spawntimedelay)
pCreature->SetRespawnDelay(spawntimedelay);
pMap->Add(pCreature);
return true;
}
示例11: InstallAllAccessories
void Vehicle::InstallAllAccessories()
{
if(!GetMap())
return;
CreatureDataAddon const *cainfo = GetCreatureAddon();
if(!cainfo || !cainfo->passengers)
return;
for (CreatureDataAddonPassengers const* cPassanger = cainfo->passengers; cPassanger->seat_idx != -1; ++cPassanger)
{
// Continue if seat already taken
if(GetPassenger(cPassanger->seat_idx))
continue;
uint32 guid = 0;
bool isVehicle = false;
// Set guid and check whatever it is
if(cPassanger->guid != 0)
guid = cPassanger->guid;
else
{
CreatureDataAddon const* passAddon;
passAddon = ObjectMgr::GetCreatureTemplateAddon(cPassanger->entry);
if(passAddon && passAddon->vehicle_id != 0)
isVehicle = true;
else
guid = sObjectMgr.GenerateLowGuid(HIGHGUID_UNIT);
}
// Create it
Creature *pPassenger = new Creature;
if(!isVehicle)
{
uint32 entry = cPassanger->entry;
if(entry == 0)
{
CreatureData const* data = sObjectMgr.GetCreatureData(guid);
if(!data)
{
delete pPassenger;
continue;
}
entry = data->id;
}
if(!pPassenger->Create(guid, GetMap(), GetPhaseMask(), entry, 0))
{
delete pPassenger;
continue;
}
pPassenger->LoadFromDB(guid, GetMap());
pPassenger->Relocate(GetPositionX(), GetPositionY(), GetPositionZ());
GetMap()->Add(pPassenger);
pPassenger->AIM_Initialize();
}
else
pPassenger = (Creature*)SummonVehicle(cPassanger->entry, GetPositionX(), GetPositionY(), GetPositionZ(), 0);
// Enter vehicle...
pPassenger->EnterVehicle(this, cPassanger->seat_idx, true);
// ...and send update. Without this, client wont show this new creature/vehicle...
WorldPacket data;
pPassenger->BuildHeartBeatMsg(&data);
pPassenger->SendMessageToSet(&data, false);
}
}
示例12: Creature
void
Spell::Effect_Summon_Pet(uint32 i)
{
WorldPacket data;
if(m_caster->GetUInt64Value(UNIT_FIELD_SUMMON) != 0)//If there is already a summon
{
Creature *OldSummon = objmgr.GetObject<Creature>(m_caster->GetUInt64Value(UNIT_FIELD_SUMMON));
if(!OldSummon)
{
m_caster->SetUInt64Value(UNIT_FIELD_SUMMON, 0);
sLog.outError("Warning!Old Summon could not be found!");
} else {
data.clear();
data.Initialize(SMSG_DESTROY_OBJECT);
data << OldSummon->GetGUID();
OldSummon->SendMessageToSet (&data, true);
if (OldSummon->GetMapCell())
OldSummon->GetMapCell()->RemoveObject (OldSummon);
OldSummon->RemoveFromMap();
OldSummon->RemoveFromWorld();
OldSummon->DeleteFromDB();
objmgr.RemoveObject_Free(OldSummon);
}
}
//Create new summon
Creature *NewSummon = new Creature();
CreatureTemplate *SummonInfo = objmgr.GetCreatureTemplate(m_spellInfo->EffectMiscValue[i]);
if(SummonInfo == NULL)
{
sLog.outError("No Minion found for CreatureTemplate %u", m_spellInfo->EffectMiscValue[i]);
return;
}
NewSummon->Create(objmgr.GenerateLowGuid(HIGHGUID_UNIT), SummonInfo->Name.c_str(), m_caster->GetMapId(), m_caster->GetPositionX(), m_caster->GetPositionY(), m_caster->GetPositionZ(), m_caster->GetOrientation());
NewSummon->SetLevel(m_caster->GetLevel());
NewSummon->SetUInt32Value(UNIT_FIELD_DISPLAYID, SummonInfo->Model);
NewSummon->SetUInt32Value(UNIT_FIELD_NATIVEDISPLAYID, SummonInfo->Model);
NewSummon->SetUInt64Value(UNIT_FIELD_SUMMONEDBY, m_caster->GetGUID());
NewSummon->SetUInt32Value(UNIT_NPC_FLAGS , 0);
NewSummon->SetUInt32Value(UNIT_FIELD_HEALTH , 28 + 30 * m_caster->GetLevel());
NewSummon->SetUInt32Value(UNIT_FIELD_MAXHEALTH , 28 + 30 * m_caster->GetLevel());
NewSummon->SetFaction(m_caster->GetFaction());
NewSummon->SetScale( SummonInfo->Size );
NewSummon->SetUInt32Value(UNIT_FIELD_BYTES_0,2048);
NewSummon->SetUInt32Value(UNIT_FIELD_FLAGS, UNIT_FLAG_NONE);
NewSummon->SetUInt32Value(UNIT_FIELD_BASEATTACKTIME, SummonInfo->Attack[0]);
NewSummon->SetUInt32Value(UNIT_FIELD_BASEATTACKTIME+1, SummonInfo->Attack[1]);
NewSummon->SetUInt32Value(UNIT_FIELD_BOUNDINGRADIUS, SummonInfo->BoundingRadius);
NewSummon->SetUInt32Value(UNIT_FIELD_COMBATREACH, SummonInfo->CombatReach);
NewSummon->SetMinDamage((float)SummonInfo->Damage[0]);
NewSummon->SetMaxDamage((float)SummonInfo->Damage[1]);
NewSummon->SetUInt32Value(UNIT_FIELD_BYTES_1,0);
NewSummon->SetUInt32Value(UNIT_FIELD_PETNUMBER, NewSummon->GetGUIDLow());
NewSummon->SetUInt32Value(UNIT_FIELD_PET_NAME_TIMESTAMP,5);
NewSummon->SetUInt32Value(UNIT_FIELD_PETEXPERIENCE,0);
NewSummon->SetUInt32Value(UNIT_FIELD_PETNEXTLEVELEXP,1000);
NewSummon->SetUInt32Value(UNIT_CREATED_BY_SPELL, m_spellInfo->Id);
NewSummon->SetUInt32Value(UNIT_FIELD_STAT0,22);
NewSummon->SetUInt32Value(UNIT_FIELD_STAT1,22); //////////TODO: GET THE RIGHT INFORMATIONS FOR THIS!!!
NewSummon->SetUInt32Value(UNIT_FIELD_STAT2,25);
NewSummon->SetUInt32Value(UNIT_FIELD_STAT3,28);
NewSummon->SetUInt32Value(UNIT_FIELD_STAT4,27);
NewSummon->SetUInt32Value(UNIT_FIELD_RESISTANCES+0,0);
NewSummon->SetUInt32Value(UNIT_FIELD_RESISTANCES+1,0);
NewSummon->SetUInt32Value(UNIT_FIELD_RESISTANCES+2,0);
NewSummon->SetUInt32Value(UNIT_FIELD_RESISTANCES+3,0);
NewSummon->SetUInt32Value(UNIT_FIELD_RESISTANCES+4,0);
NewSummon->SetUInt32Value(UNIT_FIELD_RESISTANCES+5,0);
NewSummon->SetUInt32Value(UNIT_FIELD_RESISTANCES+6,0);
NewSummon->SetUInt32Value(UNIT_FIELD_ATTACK_POWER,24);
NewSummon->SetUInt32Value(UNIT_FIELD_BASE_MANA, SummonInfo->MaxMana);
NewSummon->SetUInt32Value(OBJECT_FIELD_ENTRY, SummonInfo->Entry);
NewSummon->SetPosition(m_caster->GetPositionX(), m_caster->GetPositionY(), m_caster->GetPositionZ(), m_caster->GetOrientation());
NewSummon->SetZoneId(m_caster->GetZoneId());
NewSummon->SaveToDB();
objmgr.AddObject( NewSummon );
NewSummon->PlaceOnMap();
NewSummon->AddToWorld();
m_caster->SetUInt64Value(UNIT_FIELD_SUMMON, NewSummon->GetGUID());
sLog.outDebug("New Pet has guid %u", NewSummon->GetGUID());
if(objmgr.GetObject<Player>(m_caster->GetGUID()) )//if the caster is a player
{
data.clear();
data.Initialize(SMSG_PET_SPELLS);
data << (uint64)NewSummon->GetGUID() << uint32(0x00000101) << uint32(0x00000000) << uint32(0x07000001) << uint32(0x07000002);
data << uint32(0x02000000) << uint32(0x07000000) << uint32(0x04000000) << uint32(0x03000000) << uint32(0x06000002) << uint32(0x05000000);
data << uint32(0x06000000) << uint32(0x06000001) << uint8(0x02)/*Number of spells*/ << uint32(3110)/*SpellID1*/ << uint32(6307)/*SpellID2*/;
((Player*)m_caster)->GetSession()->SendPacket(&data);
}
}
示例13: HandleNpcAddCommand
//add spawn of creature
static bool HandleNpcAddCommand(ChatHandler* handler, const char* args) {
if (!*args)
return false;
char* charID = handler->extractKeyFromLink((char*) args,
"Hcreature_entry");
if (!charID)
return false;
char* team = strtok(NULL, " ");
int32 teamval = 0;
if (team) {
teamval = atoi(team);
}
if (teamval < 0) {
teamval = 0;
}
uint32 id = atoi(charID);
Player *chr = handler->GetSession()->GetPlayer();
float x = chr->GetPositionX();
float y = chr->GetPositionY();
float z = chr->GetPositionZ();
float o = chr->GetOrientation();
Map *map = chr->GetMap();
if (chr->GetTransport())
{
if (!map->ToInstanceMap())
{
if(chr->GetTransport()->AddNPCPassenger(0, id, chr->GetTransOffsetX(), chr->GetTransOffsetY(), chr->GetTransOffsetZ(), chr->GetTransOffsetO()))
{
WorldDatabase.PQuery("INSERT INTO creature_transport (guid, transport_entry, npc_entry, TransOffsetX, TransOffsetY, TransOffsetZ, TransOffsetO, emote) values (%u, %u, %u, %f, %f, %f, %f, 0)", 0, chr->GetTransport()->GetEntry(),id, chr->GetTransOffsetX(), chr->GetTransOffsetY(), chr->GetTransOffsetZ(), chr->GetTransOffsetO());
}
}
else
{
chr->GetTransport()->AddNPCPassengerInInstance(0, id, chr->GetTransOffsetX(), chr->GetTransOffsetY(), chr->GetTransOffsetZ(), chr->GetTransOffsetO());
WorldDatabase.PQuery("INSERT INTO creature_transport (guid, transport_entry, npc_entry, TransOffsetX, TransOffsetY, TransOffsetZ, TransOffsetO, emote) values (%u, %u, %u, %f, %f, %f, %f, 0)", 0, chr->GetTransport()->GetEntry(),id, chr->GetTransOffsetX(), chr->GetTransOffsetY(), chr->GetTransOffsetZ(), chr->GetTransOffsetO());
}
return true;
}
Creature* pCreature = new Creature;
if (!pCreature->Create(sObjectMgr->GenerateLowGuid(HIGHGUID_UNIT), map, chr->GetPhaseMaskForSpawn(), id, 0, (uint32)teamval, x, y, z, o))
{
delete pCreature;
return false;
}
pCreature->SaveToDB(map->GetId(), (1 << map->GetSpawnMode()),
chr->GetPhaseMaskForSpawn());
uint32 db_guid = pCreature->GetDBTableGUIDLow();
// To call _LoadGoods(); _LoadQuests(); CreateTrainerSpells();
pCreature->LoadFromDB(db_guid, map);
map->Add(pCreature);
sObjectMgr->AddCreatureToGrid(db_guid, sObjectMgr->GetCreatureData(db_guid));
WorldDatabase.PQuery("INSERT INTO creature_spawn (guid, account) values (%u, %u)", db_guid, handler->GetSession()->GetAccountId());
return true;
}
示例14:
Creature * CBattleground::SpawnSpiritGuide(float x, float y, float z, float o, uint32 horde)
{
if(horde > 1)
horde = 1;
CreatureInfo * pInfo = CreatureNameStorage.LookupEntry(13116 + horde);
if(pInfo == 0)
{
return NULL;
}
Creature * pCreature = m_mapMgr->CreateCreature(pInfo->Id);
pCreature->Create(pInfo->Name, m_mapMgr->GetMapId(), x, y, z, o);
pCreature->SetInstanceID(m_mapMgr->GetInstanceID());
pCreature->SetUInt32Value(OBJECT_FIELD_ENTRY, 13116 + horde);
pCreature->SetFloatValue(OBJECT_FIELD_SCALE_X, 1.0f);
pCreature->SetUInt32Value(UNIT_FIELD_HEALTH, 100000);
pCreature->SetUInt32Value(UNIT_FIELD_POWER1, 4868);
pCreature->SetUInt32Value(UNIT_FIELD_POWER3, 200);
pCreature->SetUInt32Value(UNIT_FIELD_POWER5, 2000000);
pCreature->SetUInt32Value(UNIT_FIELD_MAXHEALTH, 10000);
pCreature->SetUInt32Value(UNIT_FIELD_MAXPOWER1, 4868);
pCreature->SetUInt32Value(UNIT_FIELD_MAXPOWER3, 200);
pCreature->SetUInt32Value(UNIT_FIELD_MAXPOWER5, 2000000);
pCreature->SetUInt32Value(UNIT_FIELD_LEVEL, 60);
pCreature->SetUInt32Value(UNIT_FIELD_FACTIONTEMPLATE, 84 - horde);
pCreature->SetUInt32Value(UNIT_FIELD_BYTES_0, 0 | (2 << 8) | (1 << 16));
pCreature->SetUInt32Value(UNIT_VIRTUAL_ITEM_SLOT_DISPLAY, 22802);
pCreature->SetUInt32Value(UNIT_VIRTUAL_ITEM_INFO, 2 | (0xA << 8) | (2 << 16) | (0x11 << 24));
pCreature->SetUInt32Value(UNIT_VIRTUAL_ITEM_INFO_01, 2);
pCreature->SetUInt32Value(UNIT_FIELD_FLAGS, UNIT_FLAG_PLUS_MOB | UNIT_FLAG_NOT_ATTACKABLE_9 | UNIT_FLAG_UNKNOWN_10 | UNIT_FLAG_PVP); // 4928
pCreature->SetUInt32Value(UNIT_FIELD_AURA, 22011);
pCreature->SetUInt32Value(UNIT_FIELD_AURAFLAGS, 9);
pCreature->SetUInt32Value(UNIT_FIELD_AURALEVELS, 0x3C);
pCreature->SetUInt32Value(UNIT_FIELD_AURAAPPLICATIONS, 0xFF);
pCreature->SetUInt32Value(UNIT_FIELD_BASEATTACKTIME, 2000);
pCreature->SetUInt32Value(UNIT_FIELD_BASEATTACKTIME_01, 2000);
pCreature->SetFloatValue(UNIT_FIELD_BOUNDINGRADIUS, 0.208f);
pCreature->SetFloatValue(UNIT_FIELD_COMBATREACH, 1.5f);
pCreature->SetUInt32Value(UNIT_FIELD_DISPLAYID, 13337 + horde);
pCreature->SetUInt32Value(UNIT_FIELD_NATIVEDISPLAYID, 13337 + horde);
pCreature->SetUInt32Value(UNIT_CHANNEL_SPELL, 22011);
pCreature->SetUInt32Value(UNIT_MOD_CAST_SPEED, 1065353216);
pCreature->SetUInt32Value(UNIT_NPC_FLAGS, UNIT_NPC_FLAG_SPIRITGUIDE);
pCreature->SetUInt32Value(UNIT_FIELD_BYTES_2, 1 | (0x10 << 8));
pCreature->DisableAI();
pCreature->PushToWorld(m_mapMgr);
return pCreature;
}
示例15: HandleAddSHCommand
bool ChatHandler::HandleAddSHCommand(const char *args)
{
WorldPacket data;
Player *chr = m_session->GetPlayer();
float x = chr->GetPositionX();
float y = chr->GetPositionY();
float z = chr->GetPositionZ();
float o = chr->GetOrientation();
Creature* pCreature = new Creature();
pCreature->Create(objmgr.GenerateLowGuid(HIGHGUID_UNIT), "Spirit Healer", chr->GetMapId(), x, y, z, o, objmgr.AddCreatureName(pCreature->GetName(), 5233));
pCreature->SetZoneId(chr->GetZoneId());
pCreature->SetUInt32Value(OBJECT_FIELD_ENTRY, objmgr.AddCreatureName(pCreature->GetName(), 5233));
pCreature->SetFloatValue(OBJECT_FIELD_SCALE_X, 1.0f);
pCreature->SetUInt32Value(UNIT_FIELD_DISPLAYID, 5233);
pCreature->SetUInt32Value(UNIT_NPC_FLAGS, 33);
pCreature->SetUInt32Value(UNIT_FIELD_FACTIONTEMPLATE , 35);
pCreature->SetUInt32Value(UNIT_FIELD_HEALTH, 100);
pCreature->SetUInt32Value(UNIT_FIELD_MAXHEALTH, 100);
pCreature->SetUInt32Value(UNIT_FIELD_LEVEL, 60);
pCreature->SetUInt32Value(UNIT_FIELD_FLAGS, 768);
pCreature->SetUInt32Value(UNIT_FIELD_AURA+0, 10848);
pCreature->SetUInt32Value(UNIT_FIELD_AURALEVELS+0, 0xEEEEEE3C);
pCreature->SetUInt32Value(UNIT_FIELD_AURAAPPLICATIONS+0, 0xEEEEEE00);
pCreature->SetUInt32Value(UNIT_FIELD_AURAFLAGS+0, 0x00000009);
pCreature->SetFloatValue(UNIT_FIELD_COMBATREACH , 1.5f);
pCreature->SetFloatValue(UNIT_FIELD_MAXDAMAGE , 5.0f);
pCreature->SetFloatValue(UNIT_FIELD_MINDAMAGE , 8.0f);
pCreature->SetUInt32Value(UNIT_FIELD_BASEATTACKTIME, 1900);
pCreature->SetUInt32Value(UNIT_FIELD_BASEATTACKTIME+1, 2000);
pCreature->SetFloatValue(UNIT_FIELD_BOUNDINGRADIUS, 2.0f);
pCreature->AIM_Initialize();
Log::getSingleton( ).outError("AddObject at Level3.cpp line 455");
MapManager::Instance().GetMap(pCreature->GetMapId())->Add(pCreature);
pCreature->SaveToDB();
std::stringstream ss,ss2,ss3;
QueryResult *result;
result = sDatabase.Query( "SELECT MAX(ID) FROM npc_gossip" );
if( result )
{
ss2 << "INSERT INTO npc_gossip ( ID , NPC_GUID, GOSSIP_TYPE, TEXTID, OPTION_COUNT) VALUES ("
<< (*result)[0].GetUInt32()+1 << ", "
<< pCreature->GetGUIDLow() << ", "
<< 1 << ", "
<< 1 << ", "
<< 1 << ")";
sDatabase.Execute( ss2.str( ).c_str( ) );
delete result;
result = NULL;
result = sDatabase.Query( "SELECT MAX(ID) FROM npc_options" );
if( result )
{
ss << "INSERT INTO npc_options ( `ID` , `GOSSIP_ID`, `TYPE`, `OPTION`, `NPC_TEXT_NEXTID`, `SPECIAL`) VALUES ("
<< (*result)[0].GetUInt32()+1 << ", "
<< (*result)[0].GetUInt32()+2 << ", "
<< 0 << ", '"
<< "Return me to life." << "', "
<< 0 << ", "
<< 2 << ")";
sDatabase.Execute( ss.str( ).c_str( ) );
delete result;
result = NULL;
}
result = sDatabase.Query( "SELECT MAX(ID) FROM npc_text" );
if( result )
{
ss3 << "INSERT INTO npc_text ( ID , TYPE_UNUSED, TEXT) VALUES ("
<< (*result)[0].GetUInt32()+1 << ", "
<< 0 << ", '"
<< "It is not yet your time. I shall aid your journey back to the realm of the living... For a price." << "')";
sDatabase.Execute( ss3.str( ).c_str( ) );
delete result;
result = NULL;
}
}
return true;
}