bool Transporter::CreateAsTransporter(uint32 EntryID, const char* Name) { // Lookup GameobjectInfo if(!CreateFromProto(EntryID,0,0,0,0,0)) return false; SetUInt32Value(GAMEOBJECT_FLAGS,40); SetByte(GAMEOBJECT_BYTES_1,GAMEOBJECT_BYTES_ANIMPROGRESS, 100); //Maybe this would be the perfect way, so there would be no extra checks in Object.cpp: SetByte( GAMEOBJECT_BYTES_1, 0, GAMEOBJECT_TYPE_TRANSPORT ); //but these fields seems to change often and between server flavours (ArcEmu, Aspire, name another one) - by: VLack aka. VLsoft if( pInfo ) pInfo->Type = GAMEOBJECT_TYPE_TRANSPORT; else sLog.outString("Transporter id[%i] name[%s] - can't set GAMEOBJECT_TYPE - it will behave badly!",EntryID,Name); // Generate waypoints if(!GenerateWaypoints()) return false; // Set position SetMapId(m_WayPoints[0].mapid); SetPosition(m_WayPoints[0].x, m_WayPoints[0].y, m_WayPoints[0].z, 0); SetUInt32Value(GAMEOBJECT_LEVEL, m_period); // ITS OVER 9000!!!!! No, really, it is. // Add to world AddToWorld(); return true; }
void GameObject::Spawn() { if(!this->IsInWorld()) AddToWorld(); CALL_GO_SCRIPT_EVENT(this, OnSpawn)(); }
void ActorRigid::_Update() { StickyData* StickyD = GetPhysicsSettings()->GetStickyData(); if(StickyD->CreationQueue.empty()) return; RemoveFromWorld(); AddToWorld(); for( Whole X = 0 ; X < StickyD->CreationQueue.size() ; ++X ) { StickyConstraintConstructionInfo& CurrInfo = StickyD->CreationQueue[X]; /*ObjectPair NewPair(CurrInfo.ActA,CurrInfo.ActB); Collision* Col = Entresol::GetSingletonPtr()->GetPhysicsManager()->GetCollision(&NewPair); if(Col) Entresol::GetSingletonPtr()->GetPhysicsManager()->RemoveCollision(Col);//*/ StickyConstraint* NewSticky = new StickyConstraint(CurrInfo.ActA,CurrInfo.ActB,CurrInfo.TransA,CurrInfo.TransB); NewSticky->SetAngularLimitLower(Vector3()); NewSticky->SetAngularLimitUpper(Vector3()); NewSticky->SetLinearLimitLower(Vector3()); NewSticky->SetLinearLimitUpper(Vector3()); /*NewSticky->SetUpperLinLimit(0.0); NewSticky->SetUpperAngLimit(0.0); NewSticky->SetLowerLinLimit(0.0); NewSticky->SetLowerAngLimit(0.0);//*/ Entresol::GetSingletonPtr()->GetPhysicsManager()->_GetPhysicsWorldPointer()->addConstraint(NewSticky->GetConstraintBase(),true); StickyD->StickyConstraints.push_back(NewSticky); CurrInfo.ActA->GetPhysicsSettings()->GetStickyData()->StickyConstraints.push_back(NewSticky); NewSticky->GetConstraintBase()->setOverrideNumSolverIterations(100); } StickyD->CreationQueue.clear(); }
bool Transporter::CreateAsTransporter(uint32 EntryID, const char* Name, int32 Time) { // Lookup GameobjectInfo if (!CreateFromProto(EntryID, 0, 0, 0, 0, 0)) return false; // Override these flags to avoid mistakes in proto SetFlags(40); SetAnimProgress(100); //Maybe this would be the perfect way, so there would be no extra checks in Object.cpp: //but these fields seems to change often and between server flavours (ArcEmu, Aspire, name another one) - by: VLack aka. VLsoft if (pInfo) pInfo->Type = GAMEOBJECT_TYPE_TRANSPORT; else LOG_ERROR("Transporter id[%i] name[%s] - can't set GAMEOBJECT_TYPE - it will behave badly!", EntryID, Name); m_overrides = GAMEOBJECT_INFVIS | GAMEOBJECT_ONMOVEWIDE; //Make it forever visible on the same map // Set period m_period = Time; // Generate waypoints if (!GenerateWaypoints()) return false; // Set position SetMapId(m_WayPoints[0].mapid); SetPosition(m_WayPoints[0].x, m_WayPoints[0].y, m_WayPoints[0].z, 0); SetLevel(m_period); // Add to world AddToWorld(); return true; }
bool Transporter::CreateAsTransporter(uint32 EntryID, const char* Name, int32 Time) { // Lookup GameobjectInfo if(!CreateFromProto(EntryID,0,0,0,0,0)) return false; // Override these flags to avoid mistakes in proto SetUInt32Value(GAMEOBJECT_FLAGS,40); SetUInt32Value(GAMEOBJECT_ANIMPROGRESS, 100); // Set period m_period = Time; // Generate waypoints if(!GenerateWaypoints()) return false; // Set position SetMapId(m_WayPoints[0].mapid); SetPosition(m_WayPoints[0].x, m_WayPoints[0].y, m_WayPoints[0].z, 0); // Add to world AddToWorld(); return true; }
void Transport::TeleportTransport(uint32 newMapid, float x, float y, float z) { Map const* oldMap = GetMap(); Relocate(x, y, z); for(PlayerSet::const_iterator itr = m_passengers.begin(); itr != m_passengers.end();) { Player* pPlayer = *itr; ++itr; if(pPlayer->isDead() && !pPlayer->HasFlag(PLAYER_FLAGS, PLAYER_FLAGS_GHOST)) pPlayer->ResurrectPlayer(1.0f); pPlayer->TeleportTo(newMapid, x, y, z, GetOrientation(), TELE_TO_NOT_LEAVE_TRANSPORT); } //we need to create and save new Map object with 'newMapid' because if not done -> lead to invalid Map object reference... //player far teleport would try to create same instance, but we need it NOW for transport... RemoveFromWorld(); ResetMap(); Map * newMap = sMapMgr->CreateMap(newMapid, this, 0); SetMap(newMap); ASSERT(GetMap()); AddToWorld(); if(oldMap != newMap) { UpdateForMap(oldMap); UpdateForMap(newMap); } for(CreatureSet::iterator itr = m_NPCPassengerSet.begin(); itr != m_NPCPassengerSet.end(); ++itr) (*itr)->FarTeleportTo(newMap, x, y, z, (*itr)->GetOrientation()); }
void Pet::InitializeMe(bool first) { // set up ai and shit GetAIInterface()->Init(this,AITYPE_PET,MOVEMENTTYPE_NONE,m_Owner); GetAIInterface()->SetUnitToFollow(m_Owner); GetAIInterface()->SetFollowDistance(3.0f); SetCreatureName(objmgr.GetCreatureName(GetEntry())); m_Owner->SetSummon(this); m_Owner->SetUInt64Value(UNIT_FIELD_SUMMON, this->GetGUID()); SetUInt32Value(UNIT_FIELD_PETNUMBER, GetGUIDLow()); SetUInt32Value(UNIT_FIELD_PET_NAME_TIMESTAMP, (uint32)time(NULL)); bHasLoyalty = m_Owner->getClass() == HUNTER ? true : false; // Load our spells if(Summon) { SetDefaultSpells(); } else { // Pull from database... :/ QueryResult * query = sDatabase.Query("SELECT * FROM playerpetspells WHERE ownerguid=%u and petnumber=%u", m_Owner->GetGUIDLow(), m_PetNumber); if(query) { do { Field * f = query->Fetch(); SpellEntry* spell = sSpellStore.LookupEntry(f[2].GetUInt32()); uint16 flags = f[3].GetUInt16(); mSpells.insert ( make_pair( spell, flags ) ); } while(query->NextRow()); } delete query; } SetPetDiet(); _setFaction(); m_State = 1; // dont set agro on spawn if(first) { // Set up default actionbar SetDefaultActionbar(); } InitializeSpells(); AddToWorld(); // Add into the world sEventMgr.AddEvent(this, &Pet::Update, (uint32)100, EVENT_PET_UPDATE, 100, 0); // set to active if(!bExpires) UpdatePetInfo(false); }
//------------------------------------------------------------------------------ //! InitializeEmptyInstance //! Initialize empty animator. Only to use with serialization. bool CBulletObjectAnimator::InitEmptyInstance() { // get node scaling core::vector3df scaling = sceneNode->getScale(); // prepare collision shape collisionShape = CreateBulletCollisionShape(sceneManager, &geometry, scaling, bulletMesh); if (collisionShape == NULL) return NULL; InitPhysics(); AddToWorld(bulletWorldID); return true; }
void CWorld::AddCharacter(int formID) { //auto idx = std::find_if(m_characters.begin(), m_characters.end(), // [=](std::shared_ptr<CCharacter> p)->bool{ return p->GetID() == formID; }); auto idx = m_characters.find(formID); if(idx != m_characters.end()) return; auto obj = std::shared_ptr<CCharacter>(new CCharacter(formID)); if(obj->CreateIfValid()) { LogInfo("Add character %08x", formID); m_characters.insert(std::make_pair(formID, obj)); obj->AddToWorld(m_pWorld); } }
void Transport::TeleportTransport(uint32 newMapid, float x, float y, float z) { Map const* oldMap = GetMap(); Relocate(x, y, z); // we need to create and save new Map object with 'newMapid' because if not done -> lead to invalid Map object reference... // player far teleport would try to create same instance, but we need it NOW for transport... RemoveFromWorld(); ResetMap(); Map* newMap = sMapMgr->CreateBaseMap(newMapid); SetMap(newMap); ASSERT(GetMap()); AddToWorld(); for (UnitSet::iterator itr = _passengers.begin(); itr != _passengers.end();) { Unit* passenger = *itr; ++itr; switch (passenger->GetTypeId()) { case TYPEID_UNIT: passenger->ToCreature()->FarTeleportTo(newMap, x, y, z, passenger->GetOrientation()); break; case TYPEID_PLAYER: if (passenger->isDead() && !passenger->HasFlag(PLAYER_FLAGS, PLAYER_FLAGS_GHOST)) passenger->ToPlayer()->ResurrectPlayer(1.0f); passenger->ToPlayer()->TeleportTo(newMapid, x, y, z, GetOrientation(), TELE_TO_NOT_LEAVE_TRANSPORT); break; } } if (oldMap != newMap) { UpdateForMap(oldMap); UpdateForMap(newMap); } MoveToNextWayPoint(); }
void Transporter::TeleportTransport(uint32 newMapid, uint32 oldmap, float x, float y, float z) { //sEventMgr.RemoveEvents(this, EVENT_TRANSPORTER_NEXT_WAYPOINT); RemoveFromWorld(false); SetMapId(newMapid); SetPosition(x, y, z, m_position.o, false); AddToWorld(); WorldPacket packet(SMSG_TRANSFER_PENDING, 12); packet << newMapid; packet << getEntry(); packet << oldmap; for (auto passengerGuid : m_passengers) { auto passenger = objmgr.GetPlayer(passengerGuid); if (passenger == nullptr) continue; passenger->GetSession()->SendPacket(&packet); bool teleport_successful = passenger->Teleport(LocationVector(x, y, z, passenger->GetOrientation()), this->GetMapMgr()); if (!teleport_successful) { passenger->RepopAtGraveyard(passenger->GetPositionX(), passenger->GetPositionY(), passenger->GetPositionZ(), passenger->GetMapId()); } else { if (!passenger->HasUnitMovementFlag(MOVEFLAG_TRANSPORT)) { passenger->AddUnitMovementFlag(MOVEFLAG_TRANSPORT); } } } this->RespawnCreaturePassengers(); }
void DynamicObject::Create(Unit * caster, Spell * pSpell, float x, float y, float z, uint32 duration, float radius) { Object::_Create(m_GuidLow, m_GuidHigh, caster->GetMapId(),x, y, z, 0); SetInstanceID(caster->GetInstanceID()); if(pSpell->g_caster) { m_parentSpell = pSpell; } p_caster = pSpell->p_caster; m_spellProto = pSpell->m_spellInfo; SetUInt64Value(DYNAMICOBJECT_CASTER, caster->GetGUID()); m_uint32Values[OBJECT_FIELD_ENTRY] = m_spellProto->Id; m_uint32Values[DYNAMICOBJECT_BYTES] = 0x01eeeeee; m_uint32Values[DYNAMICOBJECT_SPELLID] = m_spellProto->Id; m_floatValues[OBJECT_FIELD_SCALE_X] = 1.0f; m_floatValues[DYNAMICOBJECT_RADIUS] = radius; m_floatValues[DYNAMICOBJECT_POS_X] = x; m_floatValues[DYNAMICOBJECT_POS_Y] = y; m_floatValues[DYNAMICOBJECT_POS_Z] = z; m_aliveDuration = duration; u_caster = caster; m_faction = caster->m_faction; m_factionDBC = caster->m_factionDBC; if(caster->dynObj != 0) { // expire next update caster->dynObj->m_aliveDuration = 1; caster->dynObj->UpdateTargets(); } caster->dynObj = this; AddToWorld(); }
bool Transporter::CreateAsTransporter(uint32 EntryID, const char* Name) { // Try to spawn the Gameobject, no need for locations. if(!CreateFromProto(EntryID,0,0.0f,0.0f,0.0f,0.0f)) return false; SetUInt32Value(GAMEOBJECT_FLAGS,40); SetByte(GAMEOBJECT_BYTES_1,GAMEOBJECT_BYTES_ANIMPROGRESS, 100); // Generate waypoints if(!GenerateWaypoints()) return false; // Set position SetMapId(m_WayPoints[0].mapid); SetPosition(m_WayPoints[0].x, m_WayPoints[0].y, m_WayPoints[0].z, 0); SetUInt32Value(GAMEOBJECT_LEVEL, m_period); // ITS OVER 9000!!!!! No, really, it is. // Add to world AddToWorld(); return true; }
void Transporter::TransportPassengers(uint32 mapid, uint32 oldmap, float x, float y, float z) { sEventMgr.RemoveEvents(this, EVENT_TRANSPORTER_NEXT_WAYPOINT); if(mPassengers.size() > 0) { PassengerIterator itr = mPassengers.begin(); PassengerIterator it2; WorldPacket Pending(SMSG_TRANSFER_PENDING, 12); Pending << mapid << GetEntry() << oldmap; WorldPacket NewWorld; LocationVector v; for(; itr != mPassengers.end();) { it2 = itr++; Player* plr = objmgr.GetPlayer(it2->first); if(!plr) { // remove from map mPassengers.erase(it2); continue; } if(!plr->GetSession() || !plr->IsInWorld()) continue; plr->GetMovementInfo()->GetTransportPosition(v); v.x += x; v.y += y; v.z += z; v.o += plr->GetOrientation(); if(mapid == 530 && !plr->GetSession()->HasFlag(ACCOUNT_FLAG_XPACK_01)) { // player is not flagged to access bc content, repop at graveyard plr->RepopAtGraveyard(plr->GetPositionX(), plr->GetPositionY(), plr->GetPositionZ(), plr->GetMapId()); continue; } if(mapid == 571 && !plr->GetSession()->HasFlag(ACCOUNT_FLAG_XPACK_02)) { plr->RepopAtGraveyard(plr->GetPositionX(), plr->GetPositionY(), plr->GetPositionZ(), plr->GetMapId()); continue; } // Lucky bitch. Do it like on official. if(plr->isDead()) plr->RemoteRevive(); if( plr->GetVehicle() ) plr->GetVehicle()->RemovePassenger( plr ); plr->GetMovementInfo()->SetTransportLock(true); plr->GetSession()->SendPacket(&Pending); plr->_Relocate(mapid, v, false, true, 0); } } // Set our position RemoveFromWorld(false); SetMapId(mapid); SetPosition(x,y,z,m_position.o); AddToWorld(); }
void Transporter::TransportPassengers(uint32 mapid, uint32 oldmap, float x, float y, float z) { sEventMgr.RemoveEvents(this, EVENT_TRANSPORTER_NEXT_WAYPOINT); if (mPassengers.size() > 0) { PassengerIterator itr = mPassengers.begin(); PassengerIterator it2; WorldPacket Pending(SMSG_TRANSFER_PENDING, 12); Pending << mapid << GetEntry() << oldmap; WorldPacket NewWorld; LocationVector v; for (; itr != mPassengers.end();) { it2 = itr; ++itr; Player* plr = objmgr.GetPlayer(it2->first); if (!plr) { // remove all non players from map mPassengers.erase(it2); continue; } if (!plr->GetSession() || !plr->IsInWorld()) continue; v.x = x + plr->transporter_info.x; v.y = y + plr->transporter_info.y; v.z = z + plr->transporter_info.z; v.o = plr->GetOrientation(); if (mapid == 530 && !plr->GetSession()->HasFlag(ACCOUNT_FLAG_XPACK_01)) { // player does not have BC content, repop at graveyard plr->RepopAtGraveyard(plr->GetPositionX(), plr->GetPositionY(), plr->GetPositionZ(), plr->GetMapId()); continue; } if (mapid == 571 && !plr->GetSession()->HasFlag(ACCOUNT_FLAG_XPACK_02)) { plr->RepopAtGraveyard(plr->GetPositionX(), plr->GetPositionY(), plr->GetPositionZ(), plr->GetMapId()); continue; } plr->GetSession()->SendPacket(&Pending); plr->_Relocate(mapid, v, false, true, 0); // Lucky bitch. Do it like on official. if (plr->IsDead()) { plr->ResurrectPlayer(); plr->SetHealth(plr->GetMaxHealth()); plr->SetPower(POWER_TYPE_MANA, plr->GetMaxPower(POWER_TYPE_MANA)); } } } // Set our position RemoveFromWorld(false); SetMapId(mapid); SetPosition(x, y, z, m_position.o, false); AddToWorld(); }
CTrigger::CTrigger(CLevel *pLevel, CInputBinaryStream &Stream): CObject(OFET_TRIGGER, pLevel), m_nWait(0) { m_iColGroup = COL_TRIGGER; m_iColMask = COL_NONE; m_pColObj = new btCollisionObject(); m_pColObj->setUserPointer(this); m_pColObj->setCollisionFlags(m_pColObj->getCollisionFlags() | btCollisionObject::CF_NO_CONTACT_RESPONSE); m_nUid = Stream.ReadUInt32(); Stream.ReadString2(); // script name Stream.ignore(1); // unknown bool bBox = Stream.ReadUInt8() ? true : false; Stream.ignore(3); // unknown2 SetResetTime((unsigned)(Stream.ReadFloat() * 1000)); SetResetsCount(Stream.ReadUInt16()); // 0xFFFF - infinity Stream.ignore(2); // unknown3 SetUseKeyRequired(Stream.ReadUInt8() ? true : false); Stream.ReadString2(); // key name bool bWeaponActivates = Stream.ReadUInt8() ? true : false; Stream.ignore(1); // unknown4 bool bNpc = Stream.ReadUInt8() ? true : false; m_bAuto = Stream.ReadUInt8() ? true : false; bool bVehicleActivates = Stream.ReadUInt8() ? true : false; SetPos(Stream.ReadVector()); if(bBox) { btMatrix3x3 RotMatrix; RotMatrix[2] = Stream.ReadVector(); RotMatrix[0] = Stream.ReadVector(); RotMatrix[1] = Stream.ReadVector(); SetRotMatrix(RotMatrix); btVector3 Size;// = Stream.ReadVector(); Size.setY(Stream.ReadFloat()); Size.setX(Stream.ReadFloat()); Size.setZ(Stream.ReadFloat()); SetBoxShape(Size); bool bOneWay = Stream.ReadUInt8() ? true : false; } else SetSphereShape(Stream.ReadFloat()); unsigned nAirlockRoomUid = Stream.ReadUInt32(); unsigned nAttachedToUid = Stream.ReadUInt32(); unsigned nUseClutterUid = Stream.ReadUInt32(); m_bEnabled = Stream.ReadUInt8() ? false : true; // is disabled float fButtonActiveTime = Stream.ReadFloat(); float fInsideTime = Stream.ReadFloat(); Stream.ignore(4); // unknown5 unsigned cLinks = Stream.ReadUInt32(); if(cLinks > 128) CLogger::GetInst().PrintError("Warning! Trigger can be corruptted: %u links\n", cLinks); m_Links.reserve(cLinks); for(unsigned i = 0; i < cLinks; ++i) m_Links.push_back(Stream.ReadUInt32()); AddToWorld(); }
void Transporter::TransportPassengers(uint32 mapid, uint32 oldmap, float x, float y, float z) { sEventMgr.RemoveEvents(this, EVENT_TRANSPORTER_NEXT_WAYPOINT); #ifdef CLUSTERING WorldPacket data(ICMSG_TRANSPORTER_MAP_CHANGE, 24); data << GetEntry() << mapid << oldmap << x << y << z; sClusterInterface.SendPacket(&data); #endif if(mPassengers.size() > 0) { PassengerIterator itr = mPassengers.begin(); PassengerIterator it2; WorldPacket Pending(SMSG_TRANSFER_PENDING, 12); Pending << mapid << GetEntry() << oldmap; WorldPacket NewWorld; LocationVector v; for(; itr != mPassengers.end();) { it2 = itr; ++itr; Player* plr = objmgr.GetPlayer(it2->first); if(!plr) { // remove from map mPassengers.erase(it2); continue; } if(!plr->GetSession() || !plr->IsInWorld()) continue; v.x = x + plr->m_TransporterX; v.y = y + plr->m_TransporterY; v.z = z + plr->m_TransporterZ; v.o = plr->GetOrientation(); if(mapid == 530 && !plr->GetSession()->HasFlag(ACCOUNT_FLAG_XPACK_01)) { // player is not flagged to access bc content, repop at graveyard plr->RepopAtGraveyard(plr->GetPositionX(), plr->GetPositionY(), plr->GetPositionZ(), plr->GetMapId()); continue; } if(mapid == 571 && !plr->GetSession()->HasFlag(ACCOUNT_FLAG_XPACK_02)) { plr->RepopAtGraveyard(plr->GetPositionX(), plr->GetPositionY(), plr->GetPositionZ(), plr->GetMapId()); continue; } // Lucky bitch. Do it like on official. if(plr->isDead()) { /*plr->ResurrectPlayer(NULL); plr->SetUInt32Value(UNIT_FIELD_HEALTH, plr->GetUInt32Value(UNIT_FIELD_MAXHEALTH)); plr->SetUInt32Value(UNIT_FIELD_POWER1, plr->GetUInt32Value(UNIT_FIELD_MAXPOWER1));*/ plr->RemoteRevive(); } if( plr->m_CurrentVehicle ) plr->m_CurrentVehicle->RemovePassenger( plr ); plr->m_lockTransportVariables = true; plr->GetSession()->SendPacket(&Pending); } } // Set our position RemoveFromWorld(false); SetPosition(x,y,z,m_position.o,false); #ifndef CLUSTERING SetMapId(mapid); AddToWorld(); #endif }