void Vehicle::InstallAccessory (uint32 entry, int8 seatId, bool minion) { if (Unit *passenger = GetPassenger(seatId)) { // already installed if (passenger->GetEntry() == entry) { ASSERT(passenger->GetTypeId() == TYPEID_UNIT); if (me->GetTypeId() == TYPEID_UNIT && me->ToCreature()->IsInEvadeMode() && passenger->ToCreature()->IsAIEnabled) passenger->ToCreature()->AI()->EnterEvadeMode(); return; } passenger->ExitVehicle(); // this should not happen } if (Creature *accessory = me->SummonCreature(entry, *me, TEMPSUMMON_CORPSE_TIMED_DESPAWN, 30000)) { if (minion) accessory->AddUnitTypeMask(UNIT_MASK_ACCESSORY); accessory->EnterVehicle(this, seatId); if (GetBase()->GetTypeId() == TYPEID_UNIT) sScriptMgr->OnInstallAccessory(this, accessory); } }
void Vehicle::InstallAccessory(uint32 entry, int8 seatId) { if(Unit *passenger = GetPassenger(seatId)) { // already installed if(passenger->GetEntry() == entry) return; passenger->ExitVehicle(); // this should not happen } const CreatureInfo *cInfo = objmgr.GetCreatureTemplate(entry); if(!cInfo) return; Creature *accessory; if(cInfo->VehicleId) accessory = SummonVehicle(entry, GetPositionX(), GetPositionY(), GetPositionZ()); else accessory = SummonCreature(entry, GetPositionX(), GetPositionY(), GetPositionZ()); if(!accessory) return; accessory->EnterVehicle(this, seatId); // This is not good, we have to send update twice accessory->SendMovementFlagUpdate(); }
//----------------------------------------------------------------------------- // Purpose: //----------------------------------------------------------------------------- bool CBaseTFVehicle::GetPassengerExitPoint( int nRole, Vector *pAbsPosition, QAngle *pAbsAngles ) { // FIXME: Clean this up CBasePlayer *pPlayer = GetPassenger(nRole); GetPassengerExitPoint( pPlayer, nRole, pAbsPosition, pAbsAngles ); return true; }
void Vehicle::InstallAccessory(uint32 entry, int8 seatId, bool minion) { if (Unit *passenger = GetPassenger(seatId)) { // already installed if (passenger->GetEntry() == entry) { assert(passenger->GetTypeId() == TYPEID_UNIT); if (me->GetTypeId() == TYPEID_UNIT && me->ToCreature()->IsInEvadeMode() && passenger->ToCreature()->IsAIEnabled) passenger->ToCreature()->AI()->EnterEvadeMode(); return; } passenger->ExitVehicle(); // this should not happen } //TODO: accessory should be minion if (Creature *accessory = me->SummonCreature(entry, *me, TEMPSUMMON_CORPSE_TIMED_DESPAWN, 30000)) { if (minion) accessory->AddUnitTypeMask(UNIT_MASK_ACCESSORY); accessory->EnterVehicle(this, seatId); // This is not good, we have to send update twice accessory->SendMovementFlagUpdate(); } }
void VehicleKit::InstallAccessory(VehicleAccessory const* accessory) { if (Unit *passenger = GetPassenger(accessory->uiSeat)) { // already installed if (passenger->GetEntry() == accessory->uiAccessory) return; passenger->ExitVehicle(); } if (Creature* summoned = m_pBase->SummonCreature(accessory->uiAccessory, m_pBase->GetPositionX() + accessory->m_offsetX, m_pBase->GetPositionY() + accessory->m_offsetY, m_pBase->GetPositionZ() + accessory->m_offsetZ, m_pBase->GetOrientation() + accessory->m_offsetX, TEMPSUMMON_CORPSE_TIMED_DESPAWN, 30000)) { SetDestination(accessory->m_offsetX,accessory->m_offsetY,accessory->m_offsetZ,accessory->m_offsetO,0.0f,0.0f); summoned->SetCreatorGuid(ObjectGuid()); summoned->SetFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_DISABLE_MOVE); summoned->EnterVehicle(m_pBase, accessory->uiSeat); SetDestination(); if (summoned->GetVehicle()) DEBUG_LOG("Vehicle::InstallAccessory %s accessory added, seat %u of %s",summoned->GetObjectGuid().GetString().c_str(), accessory->uiSeat, m_pBase->GetObjectGuid().GetString().c_str()); else { sLog.outError("Vehicle::InstallAccessory cannot install %s to seat %u of %s",summoned->GetObjectGuid().GetString().c_str(), accessory->uiSeat, m_pBase->GetObjectGuid().GetString().c_str()); summoned->ForcedDespawn(); } } else sLog.outError("Vehicle::InstallAccessory cannot summon creature id %u (seat %u of %s)",accessory->uiAccessory, accessory->uiSeat,m_pBase->GetObjectGuid().GetString().c_str()); }
CClientPlayer * CClientVehicle::GetOccupant(BYTE byteSeatId) { if(byteSeatId == 0) return GetDriver(); return GetPassenger(byteSeatId - 1); }
void VehicleKit::InstallAccessory(VehicleAccessory const* accessory) { if (Unit* passenger = GetPassenger(accessory->seatId)) { // already installed if (passenger->GetEntry() == accessory->passengerEntry) return; GetBase()->RemoveSpellsCausingAura(SPELL_AURA_CONTROL_VEHICLE, passenger->GetObjectGuid()); } if (Creature* summoned = GetBase()->SummonCreature(accessory->passengerEntry, GetBase()->GetPositionX() + accessory->m_offsetX, GetBase()->GetPositionY() + accessory->m_offsetY, GetBase()->GetPositionZ() + accessory->m_offsetZ, GetBase()->GetOrientation() + accessory->m_offsetX, TEMPSUMMON_CORPSE_TIMED_DESPAWN, 30000)) { summoned->SetCreatorGuid(ObjectGuid()); summoned->SetFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_DISABLE_MOVE); int32 seatId = accessory->seatId + 1; SetDestination(accessory->m_offsetX,accessory->m_offsetY,accessory->m_offsetZ,accessory->m_offsetO,0.0f,0.0f); summoned->CastCustomSpell(GetBase(), SPELL_RIDE_VEHICLE_HARDCODED, &seatId, &seatId, NULL, true); SetDestination(); if (summoned->GetVehicle()) DEBUG_LOG("Vehicle::InstallAccessory %s accessory added, seat %i (real %i) of %s",summoned->GetObjectGuid().GetString().c_str(), accessory->seatId, GetSeatId(summoned), GetBase()->GetObjectGuid().GetString().c_str()); else { sLog.outError("Vehicle::InstallAccessory cannot install %s to seat %u of %s",summoned->GetObjectGuid().GetString().c_str(), accessory->seatId, GetBase()->GetObjectGuid().GetString().c_str()); summoned->ForcedDespawn(); } } else sLog.outError("Vehicle::InstallAccessory cannot summon creature id %u (seat %u of %s)",accessory->passengerEntry, accessory->seatId,GetBase()->GetObjectGuid().GetString().c_str()); }
void Vehicle::InstallAccessory(uint32 entry, int8 seatId, bool isVehicle, bool minion) { if(Unit *passenger = GetPassenger(seatId)) { // already installed if(passenger->GetEntry() == entry) { assert(passenger->GetTypeId() == TYPEID_UNIT); return; } passenger->ExitVehicle(); // this should not happen } //TODO: accessory should be minion if(isVehicle) { if(Vehicle *accessory = SummonVehicle(entry, 0, 0, 0, 0)) { accessory->EnterVehicle(this, seatId, true); // This is not good, we have to send update twice accessory->BuildVehicleInfo(accessory); } }else{ if(Creature *accessory = SummonCreature(entry, 0, 0, 0, 0, TEMPSUMMON_CORPSE_TIMED_DESPAWN, 30000)) { accessory->EnterVehicle(this, seatId); // This is not good, we have to send update twice WorldPacket data; accessory->BuildHeartBeatMsg(&data); accessory->SendMessageToSet(&data, false); } } }
void Vehicle::RegeneratePower(Powers power) { uint32 curValue = GetPower(power); uint32 maxValue = GetMaxPower(power); if (curValue >= maxValue) return; float addvalue = 0.0f; // hack: needs more research of power type from the dbc. // It must contains some info about vehicles like Salvaged Chopper. if(m_vehicleInfo->m_powerType == POWER_TYPE_PYRITE) return; addvalue = 10.0f; ModifyPower(power, (int32)addvalue); for(int i =0; i != MAX_SEAT; i++) { if(Unit *pPassanger = GetPassenger(i)) { if(pPassanger->GetTypeId() == TYPEID_PLAYER) SendCreateUpdateToPlayer((Player*)pPassanger); } } }
void Vehicle::Relocate(Position pos) { sLog->outDebug(LOG_FILTER_VEHICLES, "Vehicle::Relocate %u", _me->GetEntry()); std::set<Unit*> vehiclePlayers; for (int8 i = 0; i < 8; i++) vehiclePlayers.insert(GetPassenger(i)); // passengers should be removed or they will have movement stuck RemoveAllPassengers(); for (std::set<Unit*>::const_iterator itr = vehiclePlayers.begin(); itr != vehiclePlayers.end(); ++itr) { if (Unit* plr = (*itr)) { // relocate/setposition doesn't work for player plr->NearTeleportTo(pos.GetPositionX(), pos.GetPositionY(), pos.GetPositionZ(), pos.GetOrientation()); //plr->TeleportTo(pPlayer->GetMapId(), triggerPos.GetPositionX(), triggerPos.GetPositionY(), triggerPos.GetPositionZ(), triggerPos.GetOrientation(), TELE_TO_NOT_LEAVE_COMBAT); } } _me->UpdatePosition(pos, true); // problems, and impossible to do delayed enter //pPlayer->EnterVehicle(veh); }
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) continue; entry = data->id; } if(!pPassenger->Create(guid, GetMap(), GetPhaseMask(), entry, 0)) 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); } }
//----------------------------------------------------------------------------- // Purpose: Modify the player view/camera while in a vehicle //----------------------------------------------------------------------------- void CFourWheelServerVehicle::GetVehicleViewPosition( int nRole, Vector *pAbsOrigin, QAngle *pAbsAngles ) { Assert( nRole == VEHICLE_DRIVER ); CBasePlayer *pPlayer = GetPassenger( VEHICLE_DRIVER ); Assert( pPlayer ); *pAbsAngles = pPlayer->EyeAngles(); // yuck. this is an in/out parameter. GetFourWheelVehiclePhysics()->GetVehicleViewPosition( "vehicle_driver_eyes", 1.0f, pAbsOrigin, pAbsAngles ); }
int CBaseTFVehicle::LocateEntryPoint( CBaseTFPlayer *pPlayer, float* fBest2dDistanceSqr ) { // Get the players origin and compare it to all the entry points on the // vehicle. Vector vecPlayerPos = pPlayer->GetAbsOrigin(); Vector vecEntryPos; QAngle vecEntryAngle; int iMinEntry = -1; float flMinDistance2 = INITIAL_MAX_DISTANCE; // Is the player the owner of the vehicle? bool bOwner = ( pPlayer == GetOwner() ); char szPassengerEyes[32]; for( int iEntryPoint = 0; iEntryPoint < m_nMaxPassengers; ++iEntryPoint ) { // If not the owner, check to see if the entry point is available. The // entry point is always available for the owner. bool bOccupied = ( GetPassenger( iEntryPoint ) != NULL ); // Also check for child vehicles... if ( bOccupied && !bOwner ) continue; // FIXME: Cache off the entry point Q_snprintf( szPassengerEyes, sizeof( szPassengerEyes ), "vehicle_feet_passenger%d", iEntryPoint ); int nAttachmentIndex = LookupAttachment( szPassengerEyes ); float flDistance2; if (nAttachmentIndex > 0) { GetAttachment( nAttachmentIndex, vecEntryPos, vecEntryAngle ); Vector vecDelta = vecEntryPos - vecPlayerPos; flDistance2 = vecDelta.AsVector2D().LengthSqr(); } else { // No attachment? Choose it if we must as a last resort flDistance2 = INITIAL_MAX_DISTANCE - 1; } if ( flDistance2 < flMinDistance2 ) { flMinDistance2 = flDistance2; iMinEntry = iEntryPoint; } } if( fBest2dDistanceSqr ) { *fBest2dDistanceSqr = flMinDistance2; } return iMinEntry; }
void CAPC2FourWheelServerVehicle::GetVehicleViewPosition( int nRole, Vector *pAbsOrigin, QAngle *pAbsAngles ) { //FixMe, wtf? #ifndef DEBUG Assert( nRole == VEHICLE_DRIVER ); #endif CBaseCombatCharacter *pPlayer = GetPassenger( VEHICLE_ROLE_DRIVER ); Assert( pPlayer ); float flPitchFactor=1.0; *pAbsAngles = pPlayer->EyeAngles(); matrix3x4_t vehicleEyePosToWorld; Vector vehicleEyeOrigin; QAngle vehicleEyeAngles; GetAPC()->GetAttachment( "cannon_muzzle", vehicleEyeOrigin, vehicleEyeAngles ); Vector up,forward; GetAPC()->GetVectors(NULL,&forward,&up); vehicleEyeOrigin+=(forward*37)+(up*35); AngleMatrix( vehicleEyeAngles, vehicleEyePosToWorld ); //#ifdef HL2_DLL // // View dampening. // if ( r_VehicleViewDampen.GetInt() ) // { // GetAPC()->DampenEyePosition( vehicleEyeOrigin, vehicleEyeAngles ); // } //#endif // Compute the relative rotation between the unperterbed eye attachment + the eye angles matrix3x4_t cameraToWorld; AngleMatrix( *pAbsAngles, cameraToWorld ); matrix3x4_t worldToEyePos; MatrixInvert( vehicleEyePosToWorld, worldToEyePos ); matrix3x4_t vehicleCameraToEyePos; ConcatTransforms( worldToEyePos, cameraToWorld, vehicleCameraToEyePos ); // Now perterb the attachment point vehicleEyeAngles.x = RemapAngleRange( PITCH_CURVE_ZERO * flPitchFactor, PITCH_CURVE_LINEAR, vehicleEyeAngles.x ); vehicleEyeAngles.z = RemapAngleRange( ROLL_CURVE_ZERO * flPitchFactor, ROLL_CURVE_LINEAR, vehicleEyeAngles.z ); AngleMatrix( vehicleEyeAngles, vehicleEyeOrigin, vehicleEyePosToWorld ); // Now treat the relative eye angles as being relative to this new, perterbed view position... matrix3x4_t newCameraToWorld; ConcatTransforms( vehicleEyePosToWorld, vehicleCameraToEyePos, newCameraToWorld ); // output new view abs angles MatrixAngles( newCameraToWorld, *pAbsAngles ); // UNDONE: *pOrigin would already be correct in single player if the HandleView() on the server ran after vphysics MatrixGetColumn( newCameraToWorld, 3, *pAbsOrigin ); }
void Vehicle::TeleportVehicle(float x, float y, float z, float ang) { vehiclePlayers.clear(); for (int8 i = 0; i < 8; i++) if (Unit* player = GetPassenger(i)) vehiclePlayers.insert(player->GetGUID()); RemoveAllPassengers(); // this can unlink Guns from Siege Engines _me->NearTeleportTo(x, y, z, ang); for (GuidSet::const_iterator itr = vehiclePlayers.begin(); itr != vehiclePlayers.end(); ++itr) if (Unit* player = sObjectAccessor->FindUnit(*itr)) player->NearTeleportTo(x, y, z, ang); }
void VehicleKit::InstallAccessory(VehicleAccessory const* accessory) { if (Unit* passenger = GetPassenger(accessory->seatId)) { // already installed if (passenger->GetEntry() == accessory->passengerEntry) return; GetBase()->RemoveSpellsCausingAura(SPELL_AURA_CONTROL_VEHICLE, passenger->GetObjectGuid()); } if (Creature* summoned = GetBase()->SummonCreature(accessory->passengerEntry, GetBase()->GetPositionX() + accessory->m_offsetX, GetBase()->GetPositionY() + accessory->m_offsetY, GetBase()->GetPositionZ() + accessory->m_offsetZ, GetBase()->GetOrientation() + accessory->m_offsetO, TEMPSUMMON_DEAD_DESPAWN, 0)) { summoned->SetCreatorGuid(ObjectGuid()); summoned->SetFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_DISABLE_MOVE); bool hideAccessory = false; SeatMap::const_iterator seat = m_Seats.find(accessory->seatId); if (seat != m_Seats.end()) { if (seat->second.seatInfo->m_flags & SEAT_FLAG_HIDE_PASSENGER) // coommon case hideAccessory = true; } if (!hideAccessory && (accessory->m_flags & ACCESSORY_FLAG_HIDE)) hideAccessory = true; if (hideAccessory) summoned->SetDisplayId(DEFAULT_HIDDEN_MODEL_ID); // set to empty model SetDestination(accessory->m_offsetX, accessory->m_offsetY, accessory->m_offsetZ, accessory->m_offsetO, 0.0f, 0.0f); int32 seatId = accessory->seatId + 1; summoned->SetPhaseMask(GetBase()->GetPhaseMask(), true); summoned->CastCustomSpell(GetBase(), SPELL_RIDE_VEHICLE_HARDCODED, &seatId, &seatId, NULL, true); SetDestination(); if (summoned->GetVehicle()) DEBUG_LOG("Vehicle::InstallAccessory %s accessory added, seat %i (real %i) of %s", summoned->GetGuidStr().c_str(), accessory->seatId, GetSeatId(summoned), GetBase()->GetGuidStr().c_str()); else { sLog.outError("Vehicle::InstallAccessory cannot install %s to seat %u of %s", summoned->GetGuidStr().c_str(), accessory->seatId, GetBase()->GetGuidStr().c_str()); summoned->ForcedDespawn(); } } else sLog.outError("Vehicle::InstallAccessory cannot summon creature id %u (seat %u of %s)", accessory->passengerEntry, accessory->seatId, GetBase()->GetGuidStr().c_str()); }
void VehicleKit::InstallAccessory( uint32 entry, int8 seatId, bool minion /*= true*/ ) { if (Unit *passenger = GetPassenger(seatId)) { // already installed if (passenger->GetEntry() == entry) return; passenger->ExitVehicle(); } if (Creature *accessory = m_pBase->SummonCreature(entry, m_pBase->GetPositionX(), m_pBase->GetPositionY(), m_pBase->GetPositionZ(), 0.0f, TEMPSUMMON_CORPSE_TIMED_DESPAWN, 30000)) accessory->EnterVehicle(this, seatId); }
void Vehicle::InstallAccessory(uint32 entry, int8 seatId, bool minion, uint8 type, uint32 summonTime) { if (Unit *passenger = GetPassenger(seatId)) { // already installed if (passenger->GetEntry() == entry) { ASSERT(passenger->GetTypeId() == TYPEID_UNIT); if (me->GetTypeId() == TYPEID_UNIT) { if (me->ToCreature()->IsInEvadeMode() && passenger->ToCreature()->IsAIEnabled) { passenger->ToCreature()->AI()->EnterEvadeMode(); return; } else if (passenger->ToTempSummon()->GetSummonType() == TEMPSUMMON_MANUAL_DESPAWN) { passenger->ExitVehicle(); passenger->ToTempSummon()->DespawnOrUnsummon(); ASSERT(!GetPassenger(seatId)) } } }
void Vehicle::InstallAccessory(uint32 entry, int8 seatId, bool minion, uint8 type, uint32 summonTime) { sLog->outDebug(LOG_FILTER_VEHICLES, "Vehicle: Installing accessory entry %u on vehicle entry %u (seat:%i)", entry, GetCreatureEntry(), seatId); if (Unit* passenger = GetPassenger(seatId)) { // already installed if (passenger->GetEntry() == entry) { ASSERT(passenger->GetTypeId() == TYPEID_UNIT); if (_me->GetTypeId() == TYPEID_UNIT) { if (_me->ToCreature()->IsInEvadeMode() && passenger->ToCreature()->IsAIEnabled) passenger->ToCreature()->AI()->EnterEvadeMode(); return; } } else passenger->ExitVehicle(); // this should not happen } if (TempSummon* accessory = _me->SummonCreature(entry, *_me, TempSummonType(type), summonTime)) { accessory->setFaction(_me->getFaction()); if (minion) accessory->AddUnitTypeMask(UNIT_MASK_ACCESSORY); if (!_me->HandleSpellClick(accessory, seatId)) { accessory->UnSummon(); return; } // this cannot be checked instantly like this // spellsystem is delaying everything to next update tick //if (!accessory->IsOnVehicle(me)) //{ // accessory->UnSummon(); // return; // Something went wrong in the spellsystem //} // This is not good, we have to send update twice accessory->SendMovementFlagUpdate(); if (GetBase()->GetTypeId() == TYPEID_UNIT) sScriptMgr->OnInstallAccessory(this, accessory); } }
void Vehicle::Relocate(Position pos) { std::set<Unit*> vehiclePlayers; for(int8 i = 0; i < 8; i++) vehiclePlayers.insert(GetPassenger(i)); // passengers should be removed or they will have movement stuck RemoveAllPassengers(); for(std::set<Unit*>::const_iterator itr = vehiclePlayers.begin(); itr != vehiclePlayers.end(); ++itr) { if(Unit* plr = (*itr)) plr->NearTeleportTo(pos.GetPositionX(), pos.GetPositionY(), pos.GetPositionZ(), pos.GetOrientation()); } _me->SetPosition(pos, true); }
void CWalkerMiniStrider::StartFiringLargeGun() { CBasePlayer *pPlayer = GetPassenger( VEHICLE_DRIVER ); Assert( pPlayer ); if ( !pPlayer ) return; // Figure out what we're shooting at. Vector vSrc = GetLargeGunShootOrigin(); Vector vEyePos = pPlayer->EyePosition(); Vector vEyeForward; AngleVectors( pPlayer->LocalEyeAngles(), &vEyeForward ); trace_t trace; UTIL_TraceLine( vEyePos, vEyePos + vEyeForward * 2000, MASK_SOLID, this, COLLISION_GROUP_NONE, &trace ); if ( trace.fraction < 1 ) { m_vLargeGunForward = trace.endpos - vSrc; VectorNormalize( m_vLargeGunForward ); trace_t trace; UTIL_TraceLine( vSrc, vSrc + m_vLargeGunForward * 2000, MASK_SOLID, this, COLLISION_GROUP_NONE, &trace ); if ( trace.fraction < 1 ) { EnableWalkMode( false ); m_vLargeGunTargetPos = trace.endpos; m_flLargeGunCountdown = LARGE_GUN_FIRE_TIME; m_bFiringLargeGun = true; // Show an energy beam until we actually shoot. m_pEnergyBeam = CBeam::BeamCreate( "sprites/physbeam.vmt", 25 ); m_pEnergyBeam->SetColor( 255, 0, 0 ); m_pEnergyBeam->SetBrightness( 100 ); m_pEnergyBeam->SetNoise( 4 ); m_pEnergyBeam->PointsInit( vSrc, m_vLargeGunTargetPos ); m_pEnergyBeam->LiveForTime( LARGE_GUN_FIRE_TIME ); // Play a charge-up sound. CPASAttenuationFilter filter( this, "Skirmisher.GunChargeSound" ); EmitSound( filter, 0, "Skirmisher.GunChargeSound", &vSrc ); } } }
void Vehicle::InstallAccessory(uint32 entry, int8 seatId, bool minion, uint8 type, uint32 summonTime) { /// @Prevent adding accessories when vehicle is uninstalling. (Bad script in OnUninstall/OnRemovePassenger/PassengerBoarded hook.) if (_status == STATUS_UNINSTALLING) { sLog->outError("Vehicle GuidLow: %u, Entry: %u attempts to install accessory Entry: %u on seat %d with STATUS_UNINSTALLING! " "Check Uninstall/PassengerBoarded script hooks for errors.", _me->GetGUIDLow(), _me->GetEntry(), entry, (int32)seatId); return; } #if defined(ENABLE_EXTRAS) && defined(ENABLE_EXTRA_LOGS) sLog->outDebug(LOG_FILTER_VEHICLES, "Vehicle: Installing accessory entry %u on vehicle entry %u (seat:%i)", entry, GetCreatureEntry(), seatId); #endif if (Unit* passenger = GetPassenger(seatId)) { // already installed if (passenger->GetEntry() == entry) { ASSERT(passenger->GetTypeId() == TYPEID_UNIT); if (_me->GetTypeId() == TYPEID_UNIT) { if (_me->ToCreature()->IsInEvadeMode() && passenger->ToCreature()->IsAIEnabled) passenger->ToCreature()->AI()->EnterEvadeMode(); return; } } else passenger->ExitVehicle(); // this should not happen } if (TempSummon* accessory = _me->SummonCreature(entry, *_me, TempSummonType(type), summonTime)) { if (minion) accessory->AddUnitTypeMask(UNIT_MASK_ACCESSORY); if (!_me->HandleSpellClick(accessory, seatId)) { accessory->UnSummon(); return; } if (GetBase()->GetTypeId() == TYPEID_UNIT) sScriptMgr->OnInstallAccessory(this, accessory); } }
void Vehicle::InstallAccessory(uint32 entry, int8 seatId, bool minion, uint8 type, uint32 summonTime) { if (Unit *passenger = GetPassenger(seatId)) { // already installed if (passenger->GetEntry() == entry) { ASSERT(passenger->GetTypeId() == TYPEID_UNIT); if (me->GetTypeId() == TYPEID_UNIT) { if (me->ToCreature()->IsInEvadeMode() && passenger->ToCreature()->IsAIEnabled) passenger->ToCreature()->AI()->EnterEvadeMode(); return; } } else passenger->ExitVehicle(); // this should not happen } if (Creature *accessory = me->SummonCreature(entry, *me, TempSummonType(type), summonTime)) { if (minion) accessory->AddUnitTypeMask(UNIT_MASK_ACCESSORY); if (!me->HandleSpellClick(accessory, seatId)) { accessory->AddObjectToRemoveList(); return; } if (!accessory->IsOnVehicle(me)) { accessory->AddObjectToRemoveList(); return; // Something went wrong in the spellsystem } // This is not good, we have to send update twice accessory->SendMovementFlagUpdate(); if (GetBase()->GetTypeId() == TYPEID_UNIT) sScriptMgr->OnInstallAccessory(this, accessory); } }
void CWalkerMiniStrider::UpdateLargeGun() { float dt = GetTimeDelta(); if ( !m_bFiringLargeGun ) return; m_flLargeGunCountdown -= dt; if ( m_flLargeGunCountdown <= 0 ) { // Fire! Vector vSrc = GetLargeGunShootOrigin(); trace_t trace; UTIL_TraceLine( vSrc, vSrc + m_vLargeGunForward * 2000, MASK_SOLID, this, COLLISION_GROUP_NONE, &trace ); if ( trace.fraction < 1 ) { CBasePlayer *pDriver = GetPassenger( VEHICLE_DRIVER ); if ( pDriver ) { UTIL_ImpactTrace( &trace, DMG_ENERGYBEAM, "Strider" ); Vector vHitPos = trace.endpos; float flDamageRadius = 100; float flDamage = 100; CPASFilter filter( vHitPos ); te->Explosion( filter, 0.0, &vHitPos, g_sModelIndexFireball, 2.0, 15, TE_EXPLFLAG_NONE, flDamageRadius, flDamage ); UTIL_ScreenShake( vHitPos, 10.0, 150.0, 1.0, 100, SHAKE_START ); RadiusDamage( CTakeDamageInfo( this, pDriver, flDamage, DMG_BLAST ), vHitPos, flDamageRadius, CLASS_NONE ); } } StopFiringLargeGun(); } }
void VehicleKit::InstallAccessory( uint32 entry, int8 seatId, bool minion) { if (Unit *passenger = GetPassenger(seatId)) { // already installed if (passenger->GetEntry() == entry) return; passenger->ExitVehicle(); } if (Creature* accessory = m_pBase->SummonCreature(entry, m_pBase->GetPositionX(), m_pBase->GetPositionY(), m_pBase->GetPositionZ(), 0.0f, TEMPSUMMON_CORPSE_TIMED_DESPAWN, 30000)) { accessory->SetCreatorGuid(ObjectGuid()); accessory->EnterVehicle(this, seatId); accessory->SetFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_DISABLE_MOVE); accessory->SendHeartBeat(); } }
void Vehicle::Relocate (Position pos) { sLog->outDebug(LOG_FILTER_VEHICLES, "Vehicle::Relocate %u", me->GetEntry()); std::set<Unit*> vehiclePlayers; for (int8 i = 0; i < 8; i++) vehiclePlayers.insert(GetPassenger(i)); // passengers should be removed or they will have movement stuck RemoveAllPassengers(); for (std::set<Unit*>::const_iterator itr = vehiclePlayers.begin(); itr != vehiclePlayers.end(); ++itr) { if (Unit* player = (*itr)) { // relocate/setposition doesn't work for player player->NearTeleportTo(pos.GetPositionX(), pos.GetPositionY(), pos.GetPositionZ(), pos.GetOrientation()); } } me->UpdatePosition(pos, true); }
void VehicleKit::InstallAccessory(VehicleAccessory const* accessory) { if (Unit *passenger = GetPassenger(accessory->uiSeat)) { // already installed if (passenger->GetEntry() == accessory->uiAccessory) return; passenger->ExitVehicle(); } if (Creature* summoned = m_pBase->SummonCreature(accessory->uiAccessory, m_pBase->GetPositionX() + accessory->m_offsetX, m_pBase->GetPositionY() + accessory->m_offsetY, m_pBase->GetPositionZ() + accessory->m_offsetZ, m_pBase->GetOrientation() + accessory->m_offsetX, TEMPSUMMON_CORPSE_TIMED_DESPAWN, 30000)) { SetDestination(accessory->m_offsetX,accessory->m_offsetY,accessory->m_offsetZ,accessory->m_offsetO,0.0f,0.0f); summoned->SetCreatorGuid(ObjectGuid()); summoned->SetFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_DISABLE_MOVE); summoned->EnterVehicle(this, accessory->uiSeat); SetDestination(); } }
//----------------------------------------------------------------------------- // Purpose: Try to board the vehicle //----------------------------------------------------------------------------- void CBaseTFVehicle::AttemptToBoardVehicle( CBaseTFPlayer *pPlayer ) { if ( !CanGetInVehicle( pPlayer ) ) return; // Locate the entry point. int nRole = LocateEntryPoint( pPlayer ); if ( nRole != -1 ) { // Set the owner flag. bool bOwner = ( pPlayer == GetOwner() ); if ( bOwner ) { // Check to see if a player exists at this location (role). CBaseTFPlayer *pExistingPlayer = static_cast<CBaseTFPlayer*>( GetPassenger( nRole ) ); if ( pExistingPlayer ) { pExistingPlayer->LeaveVehicle(); // Get in the vehicle. pPlayer->GetInVehicle( this, nRole ); // Then see if we can move the other player to another slot in this vehicle int nEmptyRole = GetEmptyRole(); if ( nEmptyRole != -1 ) { pExistingPlayer->GetInVehicle( this, nEmptyRole ); } return; } } // Get in the vehicle. pPlayer->GetInVehicle( this, nRole ); } }
void CWalkerMiniStrider::WalkerThink() { float dt = GetTimeDelta(); BaseClass::WalkerThink(); // Shoot the machine gun? if ( !m_bFiringLargeGun ) { if ( m_LastButtons & IN_ATTACK ) { if ( !m_bFiringMachineGun ) StartFiringMachineGun(); } else if ( m_bFiringMachineGun ) { StopFiringMachineGun(); } } // Fire the large gun? if ( !m_bFiringMachineGun ) { if ( m_LastButtons & IN_ATTACK2 ) { if ( !m_bFiringLargeGun ) StartFiringLargeGun(); } } UpdateCrouch(); // Make sure it's crouched when there is no driver. if ( GetPassenger( VEHICLE_DRIVER ) ) { if ( m_LastButtons & IN_DUCK ) { Crouch(); } else { UnCrouch(); } } else { Crouch(); } if ( m_bFiringMachineGun ) { while ( gpGlobals->curtime > m_flNextShootTime ) { FireMachineGun(); } } UpdateLargeGun(); // Move our torso within range of our feet. if ( m_flOriginToLowestLegHeight != -1 ) { Vector vCenter = WorldSpaceCenter(); //NDebugOverlay::EntityBounds( this, 255, 100, 0, 0 ,0 ); //NDebugOverlay::Line( vCenter, vCenter-Vector(0,0,2000), 255,0,0, true, 0 ); trace_t trace; UTIL_TraceLine( vCenter, vCenter - Vector( 0, 0, 2000 ), MASK_SOLID_BRUSHONLY, this, COLLISION_GROUP_NONE, &trace ); if ( trace.fraction < 1 ) { m_flWantedZ = trace.endpos.z + m_flOriginToLowestLegHeight; } // Move our Z towards the wanted Z. if ( m_flWantedZ != -1 ) { Vector vCur = vCenter; vCur.z = Approach( m_flWantedZ, vCur.z, STRIDER_TORSO_VERTICAL_SLIDE_SPEED * dt ); SetAbsOrigin( GetAbsOrigin() + Vector( 0, 0, vCur.z - vCenter.z ) ); } } }
void CWalkerMiniStrider::FireMachineGun() { CBaseEntity *pDriver = GetPassenger( VEHICLE_DRIVER ); if ( pDriver ) { // Alternate the gun we're firing char *attachmentNames[2] = { "MachineGun_Left", "MachineGun_Right" }; int iAttachment = LookupAttachment( attachmentNames[!m_bFiringLeftGun] ); m_bFiringLeftGun = !m_bFiringLeftGun; Vector vAttachmentPos; QAngle vAttachmentAngles; GetAttachment( iAttachment, vAttachmentPos, vAttachmentAngles ); Vector vEyePos = pDriver->EyePosition(); Vector vEyeForward; QAngle vecAngles = pDriver->LocalEyeAngles(); // Use the skirmisher's yaw vecAngles[YAW] = GetAbsAngles()[YAW]; AngleVectors( vecAngles, &vEyeForward ); // Trace ahead to find out where the crosshair is aiming trace_t trace; float flMaxRange = tf_skirmisher_machinegun_range.GetFloat(); UTIL_TraceLine( vEyePos, vEyePos + vEyeForward * flMaxRange, MASK_SOLID, this, COLLISION_GROUP_NONE, &trace ); Vector vecDir; if ( trace.fraction < 1.0 ) { vecDir = (trace.endpos - vAttachmentPos ); VectorNormalize( vecDir ); } else { vecDir = vEyeForward; } // Shoot! TFGameRules()->FireBullets( CTakeDamageInfo( this, pDriver, tf_skirmisher_machinegun_damage.GetFloat(), DMG_BULLET ), 1, // Num shots vAttachmentPos, vecDir, VECTOR_CONE_3DEGREES, // Spread flMaxRange, // Range DMG_BULLET, 1, // Tracer freq entindex(), iAttachment, // Attachment ID "MinigunTracer" ); m_flNextShootTime += (1.0f / tf_skirmisher_machinegun_rof.GetFloat()); // Play the fire sound. Vector vCenter = WorldSpaceCenter(); CPASAttenuationFilter filter( this, "Skirmisher.GunSound" ); EmitSound( filter, 0, "Skirmisher.GunSound", &vCenter ); } }