Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /*
- ================
- rvVehicle::State_Wait_Driver
- ================
- */
- stateResult_t rvVehicle::State_Wait_Driver ( int blendFrames ) {
- if ( !vfl.driver || vfl.stalled ) {
- return SRESULT_WAIT;
- }
- return SRESULT_DONE;
- }
- //militia_add
- /*
- ================
- rvVehicle::ServerReceiveEvent
- ================
- */
- bool rvVehicle::ServerReceiveEvent( int event, int time, const idBitMsg &msg ) {
- int i, k;
- bool partEvent = false;
- for ( i = 0; i < positions.Num(); i ++ ) {
- partEvent = positions[i].ClientReceiveEvent( event, time, msg );
- /*
- for ( k = 0; k < positions[i].mParts.Num(); k ++ ) {
- partEvent = positions[i].mParts[k]->ClientReceiveEvent( event, time, msg );
- partEvent = positions[i].mParts[k]->ClientReceiveEvent( event, time, msg );
- continue;
- }
- */
- }
- if ( partEvent ) {
- return true;
- }
- // client->server events
- switch( event ) {
- case EVENT_VEHICLE_IMPULSE: {
- int weapon = msg.ReadBits( 6 );
- int position = msg.ReadShort();
- positions[ position ].SelectWeapon( weapon );
- return true;
- }
- /*
- case EVENT_VEHICLE_FLASHLIGHT_ON: {
- return true;
- }
- case EVENT_VEHICLE_FLASHLIGHT_OFF: {
- return true;
- }
- */
- default: {
- return false;
- }
- }
- }
- /*
- =====================
- rvVehicle::ClientDamageEffects
- =====================
- */
- void rvVehicle::ClientDamageEffects ( idActor* driver, const idVec3& dir, int damage, idEntity *inflictor, idEntity *attacker, const char *damageDefName, const float damageScale, const int location, const int save ) {
- if ( gameLocal.isMultiplayer && !gameLocal.serverInfo.GetBool( "si_playerViewEffects", "0" ) ) {
- return;
- }
- if ( !driver || !driver->IsType( idPlayer::GetClassType() ) ) {
- return;
- }
- const idDict *damageDef = gameLocal.FindEntityDefDict( damageDefName, false );
- if ( !damageDef ) {
- gameLocal.Warning( "rvVehicle::ClientDamageEffects : Unknown damageDef '%s'", damageDefName );
- return;
- }
- if ( gameLocal.isDedicatedServer ) {
- return;
- }
- idVec3 from;
- idVec3 localDir;
- idPlayer* player = driver->GetStaticPlayer();
- idUserInterface *hud = player->GetHud();
- from = dir;
- from.Normalize();
- viewAxis.ProjectVector( from, localDir );
- // Visual effects
- if ( health > 0 && damage ) {
- player->playerView.DamageImpulse( localDir, damageDef, damage );
- if ( hud ) {
- hud->HandleNamedEvent( "vehicleHit" );
- }
- if ( !stricmp( damageDef->GetString( "filter" ), "electrical" ) ) {
- if ( hud ) {
- hud->HandleNamedEvent( "electricWarningOn" );
- }
- PostEventMS( &EV_HUDShockWarningOff, spawnArgs.GetInt( "hud_shock_warning_time", "2500" ) );
- if ( damage >= spawnArgs.GetInt( "electric_stall_damage", "20" ) ) {
- rvClientCrawlEffect* effect;
- effect = new rvClientCrawlEffect ( gameLocal.GetEffect( spawnArgs , "fx_electrical_stall" ), this, SEC2MS( spawnArgs.GetFloat ( "hud_shock_warning_time", "2.5" ) ) );
- effect->Play ( gameLocal.time, false );
- if ( renderEntity.gui[ 0 ] ) {
- renderEntity.gui[ 0 ]->HandleNamedEvent( "shock_stall" );
- }
- if ( renderEntity.gui[ 1 ] ) {
- renderEntity.gui[ 1 ]->HandleNamedEvent( "shock_stall" );
- }
- vfl.stalled = true;
- PostEventMS( &EV_StalledRestart, spawnArgs.GetInt( "electric_stall_delay", "3500" ), save, damage );
- }
- }
- if ( damageDef->GetFloat( "dot_duration" ) ) {
- int endTime;
- if ( damageDef->GetFloat( "dot_duration" ) == -1 ) {
- endTime = -1;
- } else {
- endTime = gameLocal.GetTime() + SEC2MS(damageDef->GetFloat( "dot_duration" ));
- }
- int interval = SEC2MS(damageDef->GetFloat( "dot_interval", "0" ));
- if ( driver && ( endTime == -1 || gameLocal.GetTime() + interval <= endTime ) ) {//post it again
- driver->PostEventMS( &EV_DamageOverTime, interval, endTime, interval, inflictor, attacker, dir, damageDefName, damageScale, location );
- }
- if ( driver && damageDef->GetString( "fx_dot", NULL ) ) {
- driver->ProcessEvent( &EV_DamageOverTimeEffect, endTime, interval, damageDefName );
- }
- if ( driver && damageDef->GetString( "snd_dot_start", NULL ) ) {
- driver->StartSound ( "snd_dot_start", SND_CHANNEL_ANY, 0, false, NULL );
- }
- }
- // Let the hud know about the hit
- if ( hud ) {
- hud->SetStateFloat ( "hitdir", localDir.ToAngles()[YAW] + 180.0f );
- hud->HandleNamedEvent ( "playerHit" );
- }
- }
- // Sound effects
- if ( damageDef->GetFloat ( "hl_volumeDB", "-40" ) ) {
- player->HearingLoss ( damageDef );
- }
- }
- /*
- ================
- rvVehicle::IsDead
- ================
- */
- bool rvVehicle::IsDead( void ) {
- return vfl.dead;
- }
- /*
- ================
- rvVehicle::IsTelefragged
- ================
- */
- bool rvVehicle::IsTelefragged( void ) {
- return vfl.telefragged;
- }
- /*
- ================
- rvVehicle::TelefragDeath
- ================
- */
- void rvVehicle::TelefragDeath( idEntity* teleportkiller ) {
- vfl.telefragged = true;
- if ( gameLocal.isClient ) {
- return;
- }
- CancelEvents( &EV_SetFire );
- StopAllEffects( true, true );
- if ( iminantDeath ) {
- iminantDeath->Stop( true );
- iminantDeath = NULL;
- }
- if ( afterDeath ) {
- afterDeath->Stop( true );
- afterDeath = NULL;
- }
- if ( fl.onFire ) {
- StopFire();
- }
- if ( gameLocal.isClient ) {
- return;
- }
- Damage ( teleportkiller, teleportkiller, teleportkiller->GetPhysics()->GetOrigin(), "damage_vehicle_telefrag", 1.0f, INVALID_JOINT );
- }
- /*
- ================
- rvVehicle::Event_vehicleRespawn
- ================
- */
- void rvVehicle::Event_vehicleRespawn( void ) {
- if ( gameLocal.isClient ) {
- return;
- }
- CancelEvents( &EV_SetFire );
- StopAllEffects( true, true );
- vfl.fx_iminantDeath = false;
- vfl.fx_afterDeath = false;
- if ( iminantDeath ) {
- iminantDeath->Stop( true );
- iminantDeath = NULL;
- }
- if ( afterDeath ) {
- afterDeath->Stop( true );
- afterDeath = NULL;
- }
- if ( fl.onFire ) {
- StopFire();
- }
- StartSound ( "snd_death", SND_CHANNEL_ANY, 0, true, NULL );
- gameLocal.PlayEffect( gameLocal.GetEffect ( spawnArgs, "fx_death" ), GetPhysics()->GetAbsBounds().GetCenter(), GetPhysics()->GetAxis(), false, vec3_origin, true );
- this->GetSelf()->Hide();
- UpdateVisuals();
- vfl.dead = false;
- vfl.locked = false;
- vfl.stalled = false;
- vfl.telefragged = false;
- fl.hidden = true;
- hasRespawned = false;
- fl.takedamage = spawnArgs.GetBool( "takeDamage", "1" );
- incomingWarnProjectile = NULL;
- incomingWarnProjectiledist = 0.0f;
- spawnTime = gameLocal.time + SEC2MS( spawnArgs.GetInt( "respawnDelay", "6" ) );
- if ( spawnLock ) {
- vfl.spawnLocked = true;
- vfl.locked = true;
- }
- healthRegenAmount.Init( gameLocal.time, 0, healthMax, healthMax );
- health = healthRegenAmount.GetCurrentValue( gameLocal.time );
- shieldMaxHealth = spawnArgs.GetInt ( "shieldHealth", "0" );
- shieldHitTime = 0;
- shieldHealth.Init ( gameLocal.time, 0, shieldMaxHealth, shieldMaxHealth );
- team = gameLocal.GetTeamNum( spawnArgs );
- spawnLock = spawnArgs.GetBool( "spawnLock", "0" );
- if ( spawnLock ) {
- vfl.spawnLocked = true;
- vfl.locked = true;
- } else if ( !spawnLock ) {
- vfl.spawnLocked = false;
- vfl.locked = false;
- }
- ResetSpawnOrigin();
- setFireTime = GetLimitRandomInt( MIN_SETFIRE_TIME, MAX_SETFIRE_TIME );
- PostEventSec( &EV_vehicleRespawnInit, VEHICLE_RESPAWN_DELAY );
- }
- /*
- ================
- rvVehicle::Respawn
- ================
- */
- void rvVehicle::Event_Respawn( void ) {
- if ( gameLocal.isClient ) {
- return;
- }
- gameLocal.PlayEffect( gameLocal.GetEffect ( spawnArgs, "fx_respawn" ), spawnOrigin, spawnAxis, false, vec3_origin, true );
- PostEventMS( &EV_vehicleShow, SEC2MS( spawnArgs.GetInt( "respawnDelay", "6" ) ) );
- }
- /*
- ================
- rvVehicle::Event_vehicleShow
- ================
- */
- void rvVehicle::Event_vehicleRespawnEnd( void ) {
- if ( gameLocal.isClient ) {
- return;
- }
- hasRespawned = true;
- this->GetSelf()->Show();
- }
- /*
- ================
- rvVehicle::ResetSpawnOrigin
- ================
- */
- void rvVehicle::ResetSpawnOrigin( void ) {
- if ( gameLocal.isClient ) {
- return;
- }
- GetPhysics()->SetOrigin( spawnOrigin );
- GetPhysics()->SetAxis( spawnAxis );
- SetPositions();
- int i, k;
- for ( i = 0; i < positions.Num(); i ++ ) {
- for ( k = 0; k < positions[i].mParts.Num(); k ++ ) {
- positions[i].mParts[k]->RunPrePhysics();
- }
- }
- }
- /*
- ================
- rvVehicle::Event_vehicleShow
- ================
- */
- void rvVehicle::Event_vehicleShow( void ) {
- this->GetSelf()->Show();
- UpdateVisuals();
- }
- /*
- ================
- rvVehicle::Event_vehicleHide
- ================
- */
- void rvVehicle::Event_vehicleHide( void ) {
- this->GetSelf()->Hide();
- UpdateVisuals();
- }
- /*
- ================
- rvVehicle::Event_ExplodeDeath
- ================
- */
- void rvVehicle::Event_ExplodeDeath( void ) {
- if ( gameLocal.isClient ) {
- return;
- }
- CancelEvents( &EV_SetFire );
- StopAllEffects( true, true );
- if ( iminantDeath ) {
- iminantDeath->Stop( true );
- iminantDeath = NULL;
- }
- if ( afterDeath ) {
- afterDeath->Stop( true );
- afterDeath = NULL;
- }
- StopFire();
- StartSound ( "snd_death", SND_CHANNEL_ANY, 0, true, NULL );
- gameLocal.PlayEffect ( gameLocal.GetEffect ( spawnArgs, "fx_death" ), GetPhysics()->GetAbsBounds().GetCenter(), GetPhysics()->GetAxis(), false, vec3_origin, true );
- this->GetSelf()->Hide();
- fl.hidden = true;
- hasRespawned = false;
- UpdateVisuals();
- if ( !gameLocal.isMultiplayer || gameLocal.isMultiplayer && !gameLocal.serverInfo.GetBool( "si_vehicleRespawn" ) ) {
- PostEventMS( &EV_Remove, 0 );
- }
- }
- /*
- ================
- rvVehicle::ClientReceiveEvent
- ================
- */
- bool rvVehicle::ClientReceiveEvent( int event, int time, const idBitMsg &msg ) {
- if ( idEntity::ClientReceiveEvent( event, time, msg ) ) {
- return true;
- }
- if ( idActor::ClientReceiveEvent( event, time, msg ) ) {
- return true;
- }
- int i, k;
- bool partEvent = false;
- for ( i = 0; i < positions.Num(); i ++ ) {
- partEvent = positions[i].ClientReceiveEvent( event, time, msg );
- /*
- for ( k = 0; k < positions[i].mParts.Num(); k ++ ) {
- partEvent = positions[i].mParts[k]->ClientReceiveEvent( event, time, msg );
- }
- */
- }
- if ( partEvent ) {
- return true;
- }
- return false;
- }
- /*
- ==================
- rvVehicle::vehicleTeam
- ==================
- */
- int rvVehicle::vehicleTeam( void ) {
- return team;
- }
- /*
- ==================
- rvVehicle::allowSteal
- ==================
- */
- bool rvVehicle::allowSteal( void ) {
- if ( !gameLocal.isMultiplayer ) {
- return false;
- }
- if ( !gameLocal.serverInfo.GetInt( "si_vehicleSteal" ) ) {
- return false;
- }
- return true;
- }
- /*
- ==================
- rvVehicle::setToPlayerTeam
- ==================
- */
- void rvVehicle::setToPlayerTeam( int pTeam ) {
- if ( ! allowSteal() ) {
- return;
- }
- if( pTeam == TEAM_MARINE ) {
- team = TEAM_MARINE;
- } else if( pTeam == TEAM_STROGG ) {
- team = TEAM_STROGG;
- }
- }
- /*
- ==================
- rvVehicle::Health
- ==================
- */
- int rvVehicle::Health( void ) {
- return health;
- }
- /*
- ==================
- rvVehicle::hasLowHealth
- ==================
- */
- bool rvVehicle::hasLowHealth( void ) {
- if ( health < healthLow ) {
- return true;
- }
- return false;
- }
- /*
- ==================
- rvVehicle::KillDrivers
- ==================
- */
- void rvVehicle::KillDrivers ( idEntity* inflictor, idEntity* attacker, const char *damageDefName ) {
- int damage;
- if ( gameLocal.isClient ) {
- return;
- }
- if ( !inflictor ) {
- inflictor = gameLocal.world;
- }
- if ( !attacker ) {
- attacker = gameLocal.world;
- }
- const idDict *damageDef = gameLocal.FindDamageDefDict( damageDefName, false );
- if ( !damageDef ) {
- damage = GetLimitRandomInt( 0, 100 );
- } else {
- damage = damageDef->GetInt( "damage" );
- }
- for ( int i = 0; i < positions.Num(); i ++ ) {
- idActor* driver = positions[i].GetDriver();
- if ( !driver ) {
- continue;
- }
- if ( driver->IsType( idPlayer::GetClassType() ) ) {
- idPlayer* player = static_cast<idPlayer*>( driver );
- player->ViewBloodSpray( damage );
- }
- driver->KillDriver( inflictor, attacker, damageDefName, GetLimitRandomFloat( 0.0f, 3.0f ), INVALID_JOINT );
- }
- }
- /*
- =====================
- rvVehicle::GetMainDriverPosition
- =====================
- */
- rvVehiclePosition* rvVehicle::GetMainDriverPosition ( void ) {
- int i;
- rvVehiclePosition* pos = NULL;
- for ( i = 0; i < positions.Num(); i++ ) {
- if ( !positions[i].IsDriver() ) {
- continue;
- }
- pos = &positions[i];
- }
- return pos;
- }
- /*
- ==================
- rvVehicle::Event_FlippedDeath
- ==================
- */
- void rvVehicle::Event_FlippedDeath ( void ) {
- assert( !gameLocal.isClient );
- if ( !spawnArgs.GetBool( "locked_flip_death" ) ) {
- for ( int i = 0; i < positions.Num(); i ++ ) {
- idActor* driver = positions[i].GetDriver();
- if ( !driver ) {
- continue;
- }
- driver->ProcessEvent ( &AI_ExitVehicle, true );
- }
- Lock( );
- } else if ( spawnArgs.GetBool( "locked_flip_death" ) ) {
- KillDrivers ( this, this, "damage_vehicle_death" );
- }
- }
- /*
- ==================
- rvVehicle::HealthRegen
- ==================
- */
- void rvVehicle::HealthRegenSelf ( void ) {
- if ( !spawnArgs.GetBool( "regenHealth", "0" ) ) {
- return;
- }
- if ( healthRegenRate && shieldHitTime + healthRegenDelay <= gameLocal.time ) {
- if ( healthRegenAmount.IsDone( gameLocal.time )) {
- healthRegenAmount.Init( gameLocal.time, SEC2MS((float)(healthMax - health)/healthRegenRate), health, healthMax );
- } else {
- health = healthRegenAmount.GetCurrentValue( gameLocal.time );
- }
- }
- }
- /*
- ==================
- rvVehicle::HealthRegen
- ==================
- */
- void rvVehicle::HealthRegen ( const char *damageDefName, float regenVal ) {
- if ( healthRegenAmount.GetCurrentValue( gameLocal.time ) >= healthMax ) {
- healthRegenAmount.Init( gameLocal.time, 0, healthMax, healthMax );
- health = healthRegenAmount.GetCurrentValue( gameLocal.time );
- return;
- }
- if ( health > healthLow && iminantDeath ) {
- if ( iminantDeath ) {
- iminantDeath->Stop( true );
- iminantDeath = NULL;
- }
- }
- const idDict *damageDef = gameLocal.FindEntityDefDict( damageDefName, false );
- if ( !damageDef ) {
- gameLocal.Warning( "rvVehicle::HealthRegen : Unknown damageDef '%s'", damageDefName );
- return;
- }
- healthRegenAmount.Init( gameLocal.time, 0, damageDef->GetInt( "damage" ) * regenVal, healthMax );
- health = healthRegenAmount.GetCurrentValue( gameLocal.time );
- }
- /*
- ==================
- rvVehicle::GetControlMode
- ==================
- */
- int rvVehicle::GetControlMode ( void ) {
- if ( spawnArgs.GetBool( "Flying", "0" ) ) {
- return 1;
- }
- return controlMode;
- }
- /*
- ==================
- rvVehicle::GetSoundHandle
- ==================
- */
- int rvVehicle::GetSoundHandle( void ) {
- return refSound.referenceSoundHandle;
- }
- /*
- ==================
- rvVehicle::projectileWarning
- ==================
- */
- bool rvVehicle::projectileWarning ( void ) {
- if ( incomingWarnProjectile && incomingWarnProjectile->entityNumber != ENTITYNUM_WORLD && incomingWarnProjectile->IsType( idProjectile::GetClassType() ) && ( incomingWarnProjectile->fl.guidedProjectile || incomingWarnProjectile->fl.driftingProjectile ) ) {
- return true;
- }
- return false;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement