bool Corpse::Create( uint32 guidlow, Player *owner, uint32 mapid, float x, float y, float z, float ang ) { SetInstanceId(owner->GetInstanceId()); WorldObject::_Create(guidlow, HIGHGUID_CORPSE, mapid); Relocate(x,y,z,ang); if(!IsPositionValid()) { sLog.outError("ERROR: Corpse (guidlow %d, owner %s) not created. Suggested coordinates isn't valid (X: %f Y: %f)", guidlow,owner->GetName(),x,y); return false; } SetFloatValue( OBJECT_FIELD_SCALE_X, 1 ); SetFloatValue( CORPSE_FIELD_POS_X, x ); SetFloatValue( CORPSE_FIELD_POS_Y, y ); SetFloatValue( CORPSE_FIELD_POS_Z, z ); SetFloatValue( CORPSE_FIELD_FACING, ang ); SetUInt64Value( CORPSE_FIELD_OWNER, owner->GetGUID() ); m_grid = MaNGOS::ComputeGridPair(GetPositionX(), GetPositionY()); return true; }
bool Corpse::Create(uint32 guidlow, Player *owner) { SetInstanceId(owner->GetInstanceId()); WorldObject::_Create(guidlow, HIGHGUID_CORPSE, owner->GetMapId()); Relocate(owner->GetPositionX(), owner->GetPositionY(), owner->GetPositionZ(), owner->GetOrientation()); if (!IsPositionValid()) { sLog.outLog(LOG_DEFAULT, "ERROR: Corpse (guidlow %d, owner %s) not created. Suggested coordinates isn't valid (X: %f Y: %f)", guidlow,owner->GetName(),owner->GetPositionX(), owner->GetPositionY()); return false; } SetFloatValue(OBJECT_FIELD_SCALE_X, 1); SetFloatValue(CORPSE_FIELD_POS_X, GetPositionX()); SetFloatValue(CORPSE_FIELD_POS_Y, GetPositionY()); SetFloatValue(CORPSE_FIELD_POS_Z, GetPositionZ()); SetFloatValue(CORPSE_FIELD_FACING, GetOrientation()); SetUInt64Value(CORPSE_FIELD_OWNER, owner->GetGUID()); m_grid = Hellground::ComputeGridPair(GetPositionX(), GetPositionY()); return true; }
bool Vehicle::Create(uint32 guidlow, Map *map, uint32 Entry, uint32 vehicleId, uint32 team) { SetMapId(map->GetId()); SetInstanceId(map->GetInstanceId()); Object::_Create(guidlow, Entry, HIGHGUID_VEHICLE); if(!InitEntry(Entry, team)) return false; m_defaultMovementType = IDLE_MOTION_TYPE; AIM_Initialize(); SetVehicleId(vehicleId); SetUInt32Value(UNIT_NPC_FLAGS, UNIT_NPC_FLAG_SPELLCLICK); SetFloatValue(UNIT_FIELD_HOVERHEIGHT, 1.0f); CreatureInfo const *ci = GetCreatureInfo(); setFaction(team == ALLIANCE ? ci->faction_A : ci->faction_H); SetMaxHealth(ci->maxhealth); SelectLevel(ci); SetHealth(GetMaxHealth()); for( int i = 0; i < 4; ++i ) this->m_spells[i] = this->GetCreatureInfo()->spells[i]; // So our vehicles can have spells on bar GetMotionMaster()->MovePoint(0, GetPositionX(), GetPositionY(), GetPositionZ()+2 ); // So we can fly with Dragon Vehicles return true; }
bool DynamicObject::Create( uint32 guidlow, Unit *caster, uint32 spellId, uint32 effIndex, float x, float y, float z, int32 duration, float radius ) { SetInstanceId(caster->GetInstanceId()); WorldObject::_Create(guidlow, HIGHGUID_DYNAMICOBJECT, caster->GetMapId()); Relocate(x,y,z,0); if(!IsPositionValid()) { sLog.outError("ERROR: DynamicObject (spell %u eff %u) not created. Suggested coordinates isn't valid (X: %f Y: %f)",spellId,effIndex,GetPositionX(),GetPositionY()); return false; } SetEntry(spellId); SetFloatValue( OBJECT_FIELD_SCALE_X, 1 ); SetUInt64Value( DYNAMICOBJECT_CASTER, caster->GetGUID() ); SetUInt32Value( DYNAMICOBJECT_BYTES, 0x00000001 ); SetUInt32Value( DYNAMICOBJECT_SPELLID, spellId ); SetFloatValue( DYNAMICOBJECT_RADIUS, radius); SetFloatValue( DYNAMICOBJECT_POS_X, x ); SetFloatValue( DYNAMICOBJECT_POS_Y, y ); SetFloatValue( DYNAMICOBJECT_POS_Z, z ); SetUInt32Value( DYNAMICOBJECT_CASTTIME, getMSTime() ); // new 2.4.0 m_aliveDuration = duration; m_radius = radius; m_effIndex = effIndex; m_spellId = spellId; m_casterGuid = caster->GetGUID(); return true; }
bool Vehicle::Create(uint32 guidlow, Map *map, uint32 Entry, uint32 vehicleId, uint32 team) { SetMapId(map->GetId()); SetInstanceId(map->GetInstanceId()); Object::_Create(guidlow, Entry, HIGHGUID_VEHICLE); if(!InitEntry(Entry, team)) return false; m_defaultMovementType = IDLE_MOTION_TYPE; AIM_Initialize(); SetVehicleId(vehicleId); SetUInt32Value(UNIT_NPC_FLAGS, UNIT_NPC_FLAG_SPELLCLICK); SetFloatValue(UNIT_FIELD_HOVERHEIGHT, 1.0f); CreatureInfo const *ci = GetCreatureInfo(); setFaction(team == ALLIANCE ? ci->faction_A : ci->faction_H); SetMaxHealth(ci->maxhealth); SelectLevel(ci); SetHealth(GetMaxHealth()); return true; }
void Totem::Summon(Unit* owner) { sLog.outDebug("AddObject at Totem.cpp line 49"); SetInstanceId(owner->GetInstanceId()); owner->GetMap()->Add((Creature*)this); // select totem model in dependent from owner team CreatureInfo const *cinfo = GetCreatureInfo(); if(owner->GetTypeId()==TYPEID_PLAYER && cinfo) { uint32 display_id = objmgr.ChooseDisplayId(((Player*)owner)->GetTeam(),cinfo); CreatureModelInfo const *minfo = objmgr.GetCreatureModelRandomGender(display_id); if (minfo) display_id = minfo->modelid; SetDisplayId(display_id); } WorldPacket data(SMSG_GAMEOBJECT_SPAWN_ANIM_OBSOLETE, 8); data << GetGUID(); SendMessageToSet(&data,true); AIM_Initialize(); switch(m_type) { case TOTEM_PASSIVE: CastSpell(this, GetSpell(), true); break; case TOTEM_STATUE: CastSpell(GetOwner(), GetSpell(), true); break; default: break; } }
bool GameObject::LoadFromDB(uint32 guid, QueryResult *result, uint32 InstanceId) { bool external = (result != NULL); if (!external) // 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 result = sDatabase.PQuery("SELECT `id`,`map`,`position_x`,`position_y`,`position_z`,`orientation`,`rotation0`,`rotation1`,`rotation2`,`rotation3`,`loot`,`spawntimesecs`,`animprogress`,`dynflags`,`respawntime`,`guid` " "FROM `gameobject` LEFT JOIN `gameobject_respawn` ON ((`gameobject`.`guid`=`gameobject_respawn`.`guid`) AND (`gameobject_respawn`.`instance` = '%u')) WHERE `gameobject`.`guid` = '%u'", InstanceId, guid); if( !result ) { sLog.outErrorDb("ERROR: Gameobject (GUID: %u) not found in table `gameobject`, can't load. ",guid); return false; } Field *fields = result->Fetch(); uint32 entry = fields[0].GetUInt32(); uint32 map_id=fields[1].GetUInt32(); float x = fields[2].GetFloat(); float y = fields[3].GetFloat(); float z = fields[4].GetFloat(); float ang = fields[5].GetFloat(); float rotation0 = fields[6].GetFloat(); float rotation1 = fields[7].GetFloat(); float rotation2 = fields[8].GetFloat(); float rotation3 = fields[9].GetFloat(); uint32 animprogress = fields[12].GetUInt32(); uint32 dynflags = fields[13].GetUInt32(); uint32 stored_guid = guid; if (InstanceId != 0) guid = objmgr.GenerateLowGuid(HIGHGUID_GAMEOBJECT); SetInstanceId(InstanceId); if (!Create(guid,entry, map_id, x, y, z, ang, rotation0, rotation1, rotation2, rotation3, animprogress, dynflags) ) { if (!external) delete result; return false; } m_DBTableGuid = stored_guid; lootid=fields[10].GetUInt32(); m_respawnDelayTime=fields[11].GetUInt32(); m_respawnTime=fields[14].GetUInt64(); if(m_respawnTime && m_respawnTime <= time(NULL)) // ready to respawn { m_respawnTime = 0; sDatabase.PExecute("DELETE FROM `gameobject_respawn` WHERE `guid` = '%u' AND `instance` = '%u'", m_DBTableGuid, GetInstanceId()); } if (!external) delete result; _LoadQuests(); return true; }
bool GameObject::LoadFromDB(uint32 guid, uint32 InstanceId) { GameObjectData const* data = objmgr.GetGOData(guid); if( !data ) { sLog.outErrorDb("ERROR: Gameobject (GUID: %u) not found in table `gameobject`, can't load. ",guid); return false; } uint32 entry = data->id; uint32 map_id = data->mapid; float x = data->posX; float y = data->posY; float z = data->posZ; float ang = data->orientation; float rotation0 = data->rotation0; float rotation1 = data->rotation1; float rotation2 = data->rotation2; float rotation3 = data->rotation3; uint32 animprogress = data->animprogress; uint32 dynflags = data->dynflags; uint32 stored_guid = guid; if (InstanceId != 0) guid = objmgr.GenerateLowGuid(HIGHGUID_GAMEOBJECT); SetInstanceId(InstanceId); if (!Create(guid,entry, map_id, x, y, z, ang, rotation0, rotation1, rotation2, rotation3, animprogress, dynflags) ) return false; m_DBTableGuid = stored_guid; if(data->spawntimesecs >= 0) { m_spawnedByDefault = true; m_respawnDelayTime=data->spawntimesecs; m_respawnTime=objmgr.GetGORespawnTime(stored_guid,InstanceId); if(m_respawnTime && m_respawnTime <= time(NULL)) // ready to respawn { m_respawnTime = 0; objmgr.SaveGORespawnTime(m_DBTableGuid,GetInstanceId(),0); } } else { m_spawnedByDefault = false; m_respawnDelayTime=-data->spawntimesecs; m_respawnTime = 0; } return true; }
bool Corpse::LoadFromDB(uint32 guid, Field *fields) { // 0 1 2 3 4 5 6 7 8 //result = CharacterDatabase.PQuery("SELECT position_x,position_y,position_z,orientation,map,data,time,corpse_type,instance FROM corpse WHERE guid = '%u'",guid); float positionX = fields[0].GetFloat(); float positionY = fields[1].GetFloat(); float positionZ = fields[2].GetFloat(); float ort = fields[3].GetFloat(); uint32 mapid = fields[4].GetUInt32(); Object::_Create(guid, 0, HIGHGUID_CORPSE); if(!LoadValues( fields[5].GetString() )) { sLog.outError("Corpse #%d have broken data in `data` field. Can't be loaded.",guid); return false; } m_time = time_t(fields[6].GetUInt64()); m_type = CorpseType(fields[7].GetUInt32()); if(m_type >= MAX_CORPSE_TYPE) { sLog.outError("Corpse (guidlow %d, owner %d) have wrong corpse type, not load.",GetGUIDLow(),GUID_LOPART(GetOwnerGUID())); return false; } uint32 instanceid = fields[8].GetUInt32(); // overwrite possible wrong/corrupted guid SetUInt64Value(OBJECT_FIELD_GUID, MAKE_NEW_GUID(guid, 0, HIGHGUID_CORPSE)); // place SetInstanceId(instanceid); SetMapId(mapid); Relocate(positionX, positionY, positionZ, ort); if(!IsPositionValid()) { sLog.outError("Corpse (guidlow %d, owner %d) not created. Suggested coordinates isn't valid (X: %f Y: %f)", GetGUIDLow(), GUID_LOPART(GetOwnerGUID()), GetPositionX(), GetPositionY()); return false; } m_grid = MaNGOS::ComputeGridPair(GetPositionX(), GetPositionY()); return true; }
void Totem::Summon(Unit* owner) { CreatureInfo const *cinfo = GetCreatureInfo(); if (owner->GetTypeId()==TYPEID_PLAYER && cinfo) { uint32 modelid = 0; if(((Player*)owner)->GetTeam() == HORDE) { if(cinfo->Modelid_H1) modelid = cinfo->Modelid_H1; else if(cinfo->Modelid_H2) modelid = cinfo->Modelid_H2; } else { if(cinfo->Modelid_A1) modelid = cinfo->Modelid_A1; else if(cinfo->Modelid_A2) modelid = cinfo->Modelid_A2; } if (modelid) SetDisplayId(modelid); else sLog.outErrorDb("Totem::Summon: Missing modelid information for entry %u, team %u, totem will use default values.",GetEntry(),((Player*)owner)->GetTeam()); } // Only add if a display exists. sLog.outDebug("AddObject at Totem.cpp line 49"); SetInstanceId(owner->GetInstanceId()); owner->GetMap()->Add((Creature*)this); WorldPacket data(SMSG_GAMEOBJECT_SPAWN_ANIM_OBSOLETE, 8); data << GetGUID(); SendMessageToSet(&data,true); AIM_Initialize(); switch(m_type) { case TOTEM_PASSIVE: CastSpell(this, GetSpell(), true); break; case TOTEM_STATUE: CastSpell(GetOwner(), GetSpell(), true); break; default: break; } if(GetEntry() == SENTRY_TOTEM_ENTRY) SetReactState(REACT_AGGRESSIVE); }
bool Vehicle::Create(uint32 guidlow, Map *map, uint32 phaseMask, uint32 Entry, uint32 vehicleId, uint32 team, const CreatureData *data) { SetMapId(map->GetId()); SetInstanceId(map->GetInstanceId()); SetPhaseMask(phaseMask,false); CreatureInfo const *cinfo = objmgr.GetCreatureTemplate(Entry); if(!cinfo) { sLog.outErrorDb("Creature entry %u does not exist.", Entry); return false; } Object::_Create(guidlow, Entry, HIGHGUID_VEHICLE); if(!UpdateEntry(Entry, team, data)) return false; if(!vehicleId) { CreatureDataAddon const *cainfo = GetCreatureAddon(); if(!cainfo) return false; vehicleId = cainfo->vehicle_id; } if(!SetVehicleId(vehicleId)) return false; LoadCreaturesAddon(); m_regenHealth = false; m_creation_time = getMSTime(); SetFloatValue(UNIT_FIELD_HOVERHEIGHT, 1.0f); //RemoveMonsterMoveFlag(MONSTER_MOVE_WALK); //Notify the map's instance data. //Only works if you create the object in it, not if it is moves to that map. //Normally non-players do not teleport to other maps. if(map->IsDungeon() && ((InstanceMap*)map)->GetInstanceData()) { ((InstanceMap*)map)->GetInstanceData()->OnCreatureCreate(this); } return true; }
void Totem::Summon(Unit* owner) { sLog.outDebug("AddObject at Totem.cpp line 49"); SetInstanceId(owner->GetInstanceId()); owner->GetMap()->Add((Creature*)this); // select totem model in dependent from owner team [-ZERO] not implemented/useful CreatureInfo const *cinfo = GetCreatureInfo(); if(owner->GetTypeId() == TYPEID_PLAYER && cinfo) { uint32 display_id = sObjectMgr.ChooseDisplayId(((Player*)owner)->GetTeam(), cinfo); CreatureModelInfo const *minfo = sObjectMgr.GetCreatureModelRandomGender(display_id); if (minfo) display_id = minfo->modelid; SetDisplayId(display_id); } WorldPacket data(SMSG_GAMEOBJECT_SPAWN_ANIM_OBSOLETE, 8); data << GetGUID(); SendMessageToSet(&data,true); AIM_Initialize(); if (owner->GetTypeId() == TYPEID_UNIT && ((Creature*)owner)->AI()) ((Creature*)owner)->AI()->JustSummoned((Creature*)this); // there are some totems, which exist just for their visual appeareance if (!GetSpell()) return; switch(m_type) { case TOTEM_PASSIVE: CastSpell(this, GetSpell(), true); break; case TOTEM_STATUE: CastSpell(GetOwner(), GetSpell(), true); break; default: break; } }
bool DynamicObject::Create( uint32 guidlow, Unit *caster, uint32 spellId, uint32 effIndex, float x, float y, float z, int32 duration, float radius ) { SetInstanceId(caster->GetInstanceId()); WorldObject::_Create(guidlow, 0xF0007000, caster->GetMapId(), x, y, z, 0, (uint8)-1); SetUInt32Value( OBJECT_FIELD_ENTRY, spellId ); SetFloatValue( OBJECT_FIELD_SCALE_X, 1 ); SetUInt64Value( DYNAMICOBJECT_CASTER, caster->GetGUID() ); SetUInt32Value( DYNAMICOBJECT_BYTES, 0x00000001 ); SetUInt32Value( DYNAMICOBJECT_SPELLID, spellId ); SetFloatValue( DYNAMICOBJECT_RADIUS, radius); SetFloatValue( DYNAMICOBJECT_POS_X, x ); SetFloatValue( DYNAMICOBJECT_POS_Y, y ); SetFloatValue( DYNAMICOBJECT_POS_Z, z ); m_aliveDuration = duration; m_radius = radius; m_effIndex = effIndex; m_spellId = spellId; m_casterGuid = caster->GetGUID(); return true; }
bool GameObject::Create(uint32 guidlow, uint32 name_id, Map *map, float x, float y, float z, float ang, float rotation0, float rotation1, float rotation2, float rotation3, uint32 animprogress, uint32 go_state) { Relocate(x,y,z,ang); SetMapId(map->GetId()); SetInstanceId(map->GetInstanceId()); if(!IsPositionValid()) { sLog.outError("ERROR: Gameobject (GUID: %u Entry: %u ) not created. Suggested coordinates isn't valid (X: %f Y: %f)",guidlow,name_id,x,y); return false; } GameObjectInfo const* goinfo = objmgr.GetGameObjectInfo(name_id); if (!goinfo) { sLog.outErrorDb("Gameobject (GUID: %u Entry: %u) not created: it have not exist entry in `gameobject_template`. Map: %u (X: %f Y: %f Z: %f) ang: %f rotation0: %f rotation1: %f rotation2: %f rotation3: %f",guidlow, name_id, map->GetId(), x, y, z, ang, rotation0, rotation1, rotation2, rotation3); return false; } Object::_Create(guidlow, goinfo->id, HIGHGUID_GAMEOBJECT); m_goInfo = goinfo; if (goinfo->type >= MAX_GAMEOBJECT_TYPE) { sLog.outErrorDb("Gameobject (GUID: %u Entry: %u) not created: it have not exist GO type '%u' in `gameobject_template`. It's will crash client if created.",guidlow,name_id,goinfo->type); return false; } SetFloatValue(GAMEOBJECT_POS_X, x); SetFloatValue(GAMEOBJECT_POS_Y, y); SetFloatValue(GAMEOBJECT_POS_Z, z); SetFloatValue(GAMEOBJECT_FACING, ang); //this is not facing angle int64 rotation = 0; float f_rot1 = sin(ang / 2.0f); int64 i_rot1 = f_rot1 / atan(pow(2.0f, -20.0f)); rotation |= (i_rot1 << 43 >> 43) & 0x00000000001FFFFF; //float f_rot2 = sin(0.0f / 2.0f); //int64 i_rot2 = f_rot2 / atan(pow(2.0f, -20.0f)); //rotation |= (((i_rot2 << 22) >> 32) >> 11) & 0x000003FFFFE00000; //float f_rot3 = sin(0.0f / 2.0f); //int64 i_rot3 = f_rot3 / atan(pow(2.0f, -21.0f)); //rotation |= (i_rot3 >> 42) & 0x7FFFFC0000000000; SetUInt64Value(GAMEOBJECT_ROTATION, rotation); SetFloatValue(GAMEOBJECT_PARENTROTATION+0, rotation0); SetFloatValue(GAMEOBJECT_PARENTROTATION+1, rotation1); SetFloatValue(GAMEOBJECT_PARENTROTATION+2, rotation2); SetFloatValue(GAMEOBJECT_PARENTROTATION+3, rotation3); SetFloatValue(OBJECT_FIELD_SCALE_X, goinfo->size); SetUInt32Value(GAMEOBJECT_FACTION, goinfo->faction); SetUInt32Value(GAMEOBJECT_FLAGS, goinfo->flags); SetEntry(goinfo->id); SetUInt32Value(GAMEOBJECT_DISPLAYID, goinfo->displayId); SetGoState(go_state); SetGoType(GameobjectTypes(goinfo->type)); SetGoAnimProgress(animprogress); // Spell charges for GAMEOBJECT_TYPE_SPELLCASTER (22) if (goinfo->type == GAMEOBJECT_TYPE_SPELLCASTER) m_charges = goinfo->spellcaster.charges; //Notify the map's instance data. //Only works if you create the object in it, not if it is moves to that map. //Normally non-players do not teleport to other maps. if(map->IsDungeon() && ((InstanceMap*)map)->GetInstanceData()) { ((InstanceMap*)map)->GetInstanceData()->OnObjectCreate(this); } return true; }
bool Creature::LoadFromDB(uint32 guid, QueryResult *result, uint32 InstanceId) { bool external = (result != NULL); if (!external) // 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 result = sDatabase.PQuery("SELECT `id`,`map`,`position_x`,`position_y`,`position_z`,`orientation`,`spawntimesecs`,`spawndist`,`spawn_position_x`,`spawn_position_y`,`spawn_position_z`,`curhealth`,`curmana`,`respawntime`,`DeathState`,`MovementType`,`auras` " "FROM `creature` LEFT JOIN `creature_respawn` ON ((`creature`.`guid`=`creature_respawn`.`guid`) AND (`creature_respawn`.`instance` = '%u')) WHERE `creature`.`guid` = '%u'", InstanceId, guid); if(!result) { sLog.outErrorDb("Creature (GUID: %u) not found in table `creature`, can't load. ",guid); return false; } Field *fields = result->Fetch(); uint32 stored_guid = guid; if (InstanceId != 0) guid = objmgr.GenerateLowGuid(HIGHGUID_UNIT); SetInstanceId(InstanceId); if(!Create(guid,fields[1].GetUInt32(),fields[2].GetFloat(),fields[3].GetFloat(), fields[4].GetFloat(),fields[5].GetFloat(),fields[0].GetUInt32())) { if (!external) delete result; return false; } m_DBTableGuid = stored_guid; if(GetCreatureInfo()->rank > 0) this->m_corpseDelay *= 3; //if creature is elite, then remove corpse later SetHealth(fields[11].GetUInt32()); SetPower(POWER_MANA,fields[12].GetUInt32()); m_respawnradius = fields[7].GetFloat(); respawn_cord[0] = fields[8].GetFloat(); respawn_cord[1] = fields[9].GetFloat(); respawn_cord[2] = fields[10].GetFloat(); m_respawnDelay = fields[6].GetUInt32(); m_deathState = (DeathState)fields[14].GetUInt32(); if(m_deathState == JUST_DIED) // Dont must be set to JUST_DEAD, see Creature::setDeathState JUST_DIED -> CORPSE promoting. { sLog.outErrorDb("Creature (GUIDLow: %u Entry: %u ) in wrong state: JUST_DEAD (1). State set to ALIVE.",GetGUIDLow(),GetEntry()); m_deathState = ALIVE; } else if(m_deathState < ALIVE || m_deathState > DEAD) { sLog.outErrorDb("Creature (GUIDLow: %u Entry: %u ) in wrong state: %d. State set to ALIVE.",GetGUIDLow(),GetEntry(),m_deathState); m_deathState = ALIVE; } m_respawnTime = (time_t)fields[13].GetUInt64(); if(m_respawnTime > time(NULL)) // not ready to respawn m_deathState = DEAD; else // ready to respawn { m_respawnTime = 0; sDatabase.PExecute("DELETE FROM `creature_respawn` WHERE `guid` = '%u' AND `instance` = '%u'", m_DBTableGuid, GetInstanceId()); } { uint32 mtg = fields[15].GetUInt32(); if(mtg < MAX_DB_MOTION_TYPE) m_defaultMovementType = MovementGeneratorType(mtg); else { m_defaultMovementType = IDLE_MOTION_TYPE; sLog.outErrorDb("Creature (GUID: %u ID: %u) have wrong movement generator type value %u, ignore and set to IDLE.",guid,GetEntry(),mtg); } } if(!external) delete result; LoadFlagRelatedData(); AIM_Initialize(); return true; }
bool GameObject::Create(uint32 guidlow, uint32 name_id, Map *map, float x, float y, float z, float ang, float rotation0, float rotation1, float rotation2, float rotation3, uint32 animprogress, GOState go_state, uint32 ArtKit) { Relocate(x,y,z,ang); SetMapId(map->GetId()); SetInstanceId(map->GetInstanceId()); if(!IsPositionValid()) { sLog.outError("Gameobject (GUID: %u Entry: %u ) not created. Suggested coordinates isn't valid (X: %f Y: %f)",guidlow,name_id,x,y); return false; } GameObjectInfo const* goinfo = ObjectMgr::GetGameObjectInfo(name_id); if (!goinfo) { sLog.outErrorDb("Gameobject (GUID: %u Entry: %u) not created: it have not exist entry in `gameobject_template`. Map: %u (X: %f Y: %f Z: %f) ang: %f rotation0: %f rotation1: %f rotation2: %f rotation3: %f",guidlow, name_id, map->GetId(), x, y, z, ang, rotation0, rotation1, rotation2, rotation3); return false; } Object::_Create(guidlow, goinfo->id, HIGHGUID_GAMEOBJECT); m_goInfo = goinfo; if (goinfo->type >= MAX_GAMEOBJECT_TYPE) { sLog.outErrorDb("Gameobject (GUID: %u Entry: %u) not created: it have not exist GO type '%u' in `gameobject_template`. It's will crash client if created.",guidlow,name_id,goinfo->type); return false; } SetFloatValue(GAMEOBJECT_POS_X, x); SetFloatValue(GAMEOBJECT_POS_Y, y); SetFloatValue(GAMEOBJECT_POS_Z, z); SetFloatValue(GAMEOBJECT_ROTATION+0, rotation0); SetFloatValue(GAMEOBJECT_ROTATION+1, rotation1); UpdateRotationFields(rotation2,rotation3); // GAMEOBJECT_FACING, GAMEOBJECT_ROTATION+2/3 SetFloatValue(OBJECT_FIELD_SCALE_X, goinfo->size); SetUInt32Value(GAMEOBJECT_FACTION, goinfo->faction); SetUInt32Value(GAMEOBJECT_FLAGS, goinfo->flags); SetEntry(goinfo->id); SetUInt32Value(GAMEOBJECT_DISPLAYID, goinfo->displayId); SetGoState(go_state); SetGoType(GameobjectTypes(goinfo->type)); SetGoAnimProgress(animprogress); SetUInt32Value (GAMEOBJECT_ARTKIT, ArtKit); // Spell charges for GAMEOBJECT_TYPE_SPELLCASTER (22) if (goinfo->type == GAMEOBJECT_TYPE_SPELLCASTER) m_charges = goinfo->spellcaster.charges; //Notify the map's instance data. //Only works if you create the object in it, not if it is moves to that map. //Normally non-players do not teleport to other maps. if(map->IsDungeon() && ((InstanceMap*)map)->GetInstanceData()) { ((InstanceMap*)map)->GetInstanceData()->OnObjectCreate(this); } return true; }
bool GameObject::Create(uint32 guidlow, uint32 name_id, Map *map, float x, float y, float z, float ang, float rotation0, float rotation1, float rotation2, float rotation3, uint32 animprogress, uint32 go_state) { Relocate(x,y,z,ang); SetMapId(map->GetId()); SetInstanceId(map->GetInstanceId()); if(!IsPositionValid()) { sLog.outError("ERROR: Gameobject (GUID: %u Entry: %u ) not created. Suggested coordinates isn't valid (X: %f Y: %f)",guidlow,name_id,x,y); return false; } GameObjectInfo const* goinfo = objmgr.GetGameObjectInfo(name_id); if (!goinfo) { sLog.outErrorDb("Gameobject (GUID: %u Entry: %u) not created: it have not exist entry in `gameobject_template`. Map: %u (X: %f Y: %f Z: %f) ang: %f rotation0: %f rotation1: %f rotation2: %f rotation3: %f",guidlow, name_id, map->GetId(), x, y, z, ang, rotation0, rotation1, rotation2, rotation3); return false; } Object::_Create(guidlow, goinfo->id, HIGHGUID_GAMEOBJECT); m_DBTableGuid = guidlow; if (goinfo->type >= MAX_GAMEOBJECT_TYPE) { sLog.outErrorDb("Gameobject (GUID: %u Entry: %u) not created: it have not exist GO type '%u' in `gameobject_template`. It's will crash client if created.",guidlow,name_id,goinfo->type); return false; } // SetUInt32Value(GAMEOBJECT_TIMESTAMP, (uint32)time(NULL)); SetFloatValue(GAMEOBJECT_POS_X, x); SetFloatValue(GAMEOBJECT_POS_Y, y); SetFloatValue(GAMEOBJECT_POS_Z, z); SetFloatValue(GAMEOBJECT_FACING, ang); //this is not facing angle SetFloatValue (GAMEOBJECT_ROTATION, rotation0); SetFloatValue (GAMEOBJECT_ROTATION+1, rotation1); SetFloatValue (GAMEOBJECT_ROTATION+2, rotation2); SetFloatValue (GAMEOBJECT_ROTATION+3, rotation3); SetFloatValue(OBJECT_FIELD_SCALE_X, goinfo->size); SetUInt32Value(GAMEOBJECT_FACTION, goinfo->faction); SetUInt32Value(GAMEOBJECT_FLAGS, goinfo->flags); m_flags = goinfo->flags; SetUInt32Value (OBJECT_FIELD_ENTRY, goinfo->id); SetUInt32Value (GAMEOBJECT_DISPLAYID, goinfo->displayId); SetUInt32Value (GAMEOBJECT_STATE, go_state); SetUInt32Value (GAMEOBJECT_TYPE_ID, goinfo->type); SetUInt32Value (GAMEOBJECT_ANIMPROGRESS, animprogress); // Spell charges for GAMEOBJECT_TYPE_SPELLCASTER (22) if (goinfo->type == GAMEOBJECT_TYPE_SPELLCASTER) m_charges = goinfo->spellcaster.charges; //Notify the map's instance data. //Only works if you create the object in it, not if it is moves to that map. //Normally non-players do not teleport to other maps. if(map && map->GetInstanceData()) { map->GetInstanceData()->OnObjectCreate(this); } return true; }