BOOL CObject_Bus::RemovePassenger(ObjID_t nPassengerID) { if(nPassengerID == INVALID_ID) return FALSE; INT nCount = GetPassengerCount(); if(nCount > 0) { INT i; for(i = 0; i < nCount; i++) { if(m_anPassengerIDs[i] == nPassengerID) { if(m_abPassengerAttacheds[i] && m_pRenderInterface != NULL) { CObject *pObj = (CObject*)(CObjectManager::GetMe()->FindServerObject(m_anPassengerIDs[i])); if(pObj != NULL && pObj->GetRenderInterface() != NULL) { if(pObj != NULL && g_theKernel.IsKindOf(pObj->GetClass(), GETCLASS(CObject_Character))) { ((CObject_Character*)pObj)->Bus_UpdateCharActionSetFile(); } m_pRenderInterface->Detach_Object(pObj->GetRenderInterface()); } } m_anPassengerIDs[i] = m_anPassengerIDs[nCount - 1]; m_abPassengerAttacheds[i] = m_abPassengerAttacheds[nCount - 1]; m_anPassengerIDs[nCount - 1] = INVALID_ID; m_abPassengerAttacheds[nCount - 1] = FALSE; return TRUE; } } } return FALSE; }
VOID CObject_Bus::DetachCharacterInterface(ObjID_t nObjID) { if(nObjID == INVALID_ID) return ; INT nCount = GetPassengerCount(); if(nCount > 0) { INT i; for(i = 0; i < nCount; i++) { if(m_anPassengerIDs[i] == nObjID) { if(m_abPassengerAttacheds[i] && m_pRenderInterface != NULL) { CObject *pObj = (CObject*)(CObjectManager::GetMe()->FindServerObject(m_anPassengerIDs[i])); if(pObj != NULL && pObj->GetRenderInterface() != NULL) { m_pRenderInterface->Detach_Object(pObj->GetRenderInterface()); } } m_anPassengerIDs[i] = m_anPassengerIDs[nCount - 1]; m_abPassengerAttacheds[i] = m_abPassengerAttacheds[nCount - 1]; m_anPassengerIDs[nCount - 1] = INVALID_ID; m_abPassengerAttacheds[nCount - 1] = FALSE; return ; } } } }
void Vehicle::RemovePassenger(Player * player) { if (player == NULL || player->GetVehicle() != this || player->GetVehicleSeat() >= GetPassengerCount() || m_passengers[player->GetVehicleSeat()] != player) return; SendFarsightPacket(player, false); RelocateToVehicle(player); if (player == m_controller) { WorldPacket data; m_controller = NULL; SetCharmedByGUID( 0); RemoveFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_PLAYER_CONTROLLED_CREATURE); player->GetSession()->SetActiveMover(player->GetNewGUID()); data.Initialize(SMSG_CLIENT_CONTROL_UPDATE); data << GetNewGUID() << uint8(0); player->GetSession()->SendPacket(&data); } //clear refs uint8 seat = player->GetVehicleSeat(); player->ResetVehicleSettings(); m_passengers[seat] = NULL; }
void Vehicle::MoveVehicle(float x, float y, float z, float o) { m_owner->SetPosition(x, y, z, o); int8 passengercount = GetPassengerCount(); for (int8 i=0; i < passengercount; i++) if( m_passengers[i] != NULL && m_passengers[i] != m_owner ) //there is a chance that owner is also present in vehicle. Is there a double setposition there ? m_passengers[i]->SetPosition(x, y, z, o); }
void Vehicle::SetDeathState(DeathState s) { Creature::setDeathState(s); int8 passengercount = GetPassengerCount(); for (int8 i= 0; i < passengercount; ++i) if (m_passengers[i] != NULL) RemovePassenger(m_passengers[i]); }
void Vehicle::MoveVehicle(float x, float y, float z, float o) { SetPosition(x, y, z, o); int8 passengercount = GetPassengerCount(); for (int8 i= 0; i < passengercount; ++i) if (m_passengers[i] != NULL) m_passengers[i]->SetPosition(x, y, z, o); }
//----------------------------------------------------------------------------- // Purpose: //----------------------------------------------------------------------------- void CBaseTFVehicle::VehiclePassengerThink( void ) { SetNextThink( gpGlobals->curtime + 10.0, PASSENGER_THINK_CONTEXT ); if ( IsPlacing() ) { ResetDeteriorationTime(); return; } // If there are any passengers in the vehicle, push off deterioration time if ( GetPassengerCount() ) { ResetDeteriorationTime(); return; } // See if there are any team members nearby if ( GetTeam() ) { int iNumPlayers = GetTFTeam()->GetNumPlayers(); for ( int i = 0; i < iNumPlayers; i++ ) { if ( GetTFTeam()->GetPlayer(i) ) { Vector vecOrigin = GetTFTeam()->GetPlayer(i)->GetAbsOrigin(); if ( (vecOrigin - GetAbsOrigin()).LengthSqr() < DETERIORATION_DISTANCE ) { // Found one nearby, reset our deterioration time ResetDeteriorationTime(); return; } } } } }
void Vehicle::RemovePassenger(Unit * passenger) { if( HasAllProtoAvailable() == false ) return; ASSERT(this && passenger); if (passenger == NULL || // Are we passing NULL pointers? passenger->GetVehicle() != this || // Are we trying to dismount from something invalid? passenger->GetSeatID() >= MAX_PASSENGERS || // Are we trying to dismount someone in an inexcisting seat? m_passengers[passenger->GetSeatID()] != passenger) // Are we trying to dismount someone who's seat we do not own? { // ASSERT( false ); //wow, we are not expecting this situation at all return; } if(passenger->IsPlayer()) // The passenger is a player { Player * player = static_cast<Player*>(passenger); //remove pet action bar in case we had any sStackWolrdPacket( data, SMSG_PET_SPELLS, 9 ); data << uint64(0); player->GetSession()->SendPacket(&data); if( passenger != m_owner ) { // SendHeartbeatPacket(player); // RelocateToVehicle(player); if( IsMount == false ) SendFarsightPacket(player, false); // player->SetUInt64Value(UNIT_FIELD_TARGET, 0); //loose targetting, but why ? if( IsMount == false && player == m_controller) // Are we the driver of this vehicle? { m_controller = NULL; player->UnPossess(); // passenger->RemoveFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_PLAYER_CONTROLLED); } player->GetSession()->SetActiveMover( player->GetNewGUID() ); passenger->Unroot(); WorldPacket data; data.Initialize(SMSG_MONSTER_MOVE); data << player->GetNewGUID(); // PlayerGUID data << uint8(0x40); // Unk - blizz uses 0x40 data << player->GetPosition(); // Player Position xyz data << getMSTime(); // Timestamp data << uint8(0x4); // Flags data << player->GetOrientation(); // Orientation data << uint32(0x01000000); // MovementFlags data << uint32(0); // MovementTime data << uint32(1); // Pointcount data << m_owner->GetPosition(); // Vehicle Position xyz player->SendMessageToSet(&data, true); } if( passenger == m_owner ) { // Send others that we are no longer a vehicle sStackWolrdPacket( data, SMSG_CONVERT_VEHICLE, 9+4); data << passenger->GetNewGUID() ; data << uint32( 0 ); player->SendMessageToSet(&data,true); } player->m_noFallDamage = false; } else if(passenger->IsCreature()) { static_cast<Creature*>(passenger)->ResetParentInfo(); passenger->SetPosition( m_owner->GetPositionX(), m_owner->GetPositionY(), m_owner->GetPositionZ(), m_owner->GetOrientation(), true); } else { sLog.outDebug("Error while removing passenger."); } //clear refs uint8 seat = passenger->GetSeatID(); passenger->m_vehicle_data = NULL; passenger->m_CurrentVehicleSeat = VEHICLE_PASSENGER_SLOT_INVALID; m_passengers[seat] = NULL; passenger->RemoveFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_NOT_SELECTABLE | UNIT_FLAG_MOUNTABLE); passenger->RemoveFlag(UNIT_NPC_FLAGS, UNIT_NPC_FLAG_VEHICLE); if( GetPassengerCount() < GetOccupancyLimit() && m_owner->IsPlayer() == false && m_owner != passenger ) m_owner->SetFlag(UNIT_NPC_FLAGS, UNIT_NPC_FLAG_SPELLCLICK); if(m_vehicledata->flags & VEHICLE_FLAG_DISABLE_AI_ON_ENTER) m_owner->EnableAI(); --m_passengerCount; if( m_passengerCount <= 0 && IsMount ) { m_owner->DestoryVehicle(); return; //we just killed ourself, do not do anything after that function call } }
void Vehicle::AddPassenger(Unit * passenger, int8 seat) { if( HasAllProtoAvailable() == false ) return; ASSERT( passenger ); if( !passenger->IsInWorld() ) return; if(GetPassengerCount() + 1 > GetOccupancyLimit()) // Check if there is place left for us { return; } // Check if we're a vehicle trying to mount a non-player seat position if( seat == VEHICLE_PASSENGER_SLOT_INVALID || seat >= MAX_PASSENGERS || seat >= GetOccupancyLimit() || m_passengers[seat] != NULL) { return; } //right now mount owners are using seat 0 with is not actually a seat. In case there are crash reports we should check if picked seat is also valid in DBC // if( m_vehicleEntry->m_seatID[ seat ] == 0 ) return; m_passengers[seat] = passenger; // Set this vehicle and seat to player passenger->SetVehicle(this, seat); //set controler if( m_controller == NULL ) { m_controller = passenger; if( IsMount == false ) { //should not posses self ? if( m_controller != m_owner && passenger->IsPlayer() ) SafePlayerCast( passenger )->Possess( m_owner ); // passenger->SetFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_PLAYER_CONTROLLED); } } if( passenger->IsPlayer() ) { Player * player = SafePlayerCast(passenger); if( passenger != m_owner ) { if( IsMount == false ) SendFarsightPacket(player, true); //focus on vehicle instead us ? But why ? player->GetSession()->SetActiveMover( GetNewGUID() ); //loose movement control ? } if( IsMount == false ) player->m_noFallDamage = true; // Show the vehicle action bar. Is this to owner or to seat ? SendVehicleActionBar( player ); if( passenger != m_owner ) SendRidePacket( passenger, GetSeatData()->seat[seat] ); //seems like this is a mount if( passenger == m_owner ) { // Send others that we now have a vehicle sStackWolrdPacket( data, SMSG_CONVERT_VEHICLE, 9+4); data << passenger->GetNewGUID() ; data << uint32( proto->vehicleId ); player->SendMessageToSet(&data,true); //is this for all players or only the real vehicle controller data.Initialize(SMSG_CONTROL_VECHICLE); player->GetSession()->SendPacket(&data); } } // Remove shapeshift auras passenger->RemoveAllAuraType(SPELL_AURA_MOD_SHAPESHIFT); passenger->RemoveAllAuraType(SPELL_AURA_TRANSFORM); if( passenger != m_owner ) { passenger->Root(); passenger->SetFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_NOT_SELECTABLE); } else if( passenger == m_owner ) m_owner->SetFlag(UNIT_NPC_FLAGS, UNIT_NPC_FLAG_VEHICLE); if(m_vehicledata->flags & VEHICLE_FLAG_DISABLE_AI_ON_ENTER) m_owner->DisableAI(); // Check if we exceeded maximum passenger capacity if( GetPassengerCount() >= GetOccupancyLimit() ) m_owner->RemoveFlag(UNIT_NPC_FLAGS, UNIT_NPC_FLAG_SPELLCLICK); m_passengerCount++; // Count the passenger as inside the vehicle }