Ejemplo n.º 1
0
void AircraftClass::DoINSAlign(void)
{
	//if they enter the coords after 2 mins of alignment, we start from the beginning
	if(CheckUFC)
	{
		if(OTWDriver.pCockpitManager && OTWDriver.pCockpitManager->mpIcp &&
			OTWDriver.pCockpitManager->mpIcp->INSEnterPush())
		{
			CheckUFC = FALSE;
			OTWDriver.pCockpitManager->mpIcp->ClearINSEnter();
			if(INSAlignmentTimer >= 120)
				INSAlignmentTimer = 0;
		}
	}

	if(INSAlignmentTimer >= 120)
		CheckUFC = TRUE;

	//Dont align if the UFC isn't powered
	if(!HasPower(UFCPower))
		return;

	if(INSState(INS_AlignFlight))
		INSAlignmentTimer += 8 * SimLibMajorFrameTime;	//reach 480 in 1 min
	else
		INSAlignmentTimer += SimLibMajorFrameTime;
	
	if(INSAlignmentTimer >= 12)	//12 seconds
		INSStatus = 90;
	if(INSAlignmentTimer >= 60)	//60 Seconds
		INSStatus = 79;
	if(INSAlignmentTimer >= 90)	//90 seconds
		INSStatus = 70;
	if(INSAlignmentTimer >= 155)	//every 65 seconds one step less
		INSStatus = 60;
	if(INSAlignmentTimer >= 220)
		INSStatus = 50;
	if(INSAlignmentTimer >= 285)
		INSStatus = 40;
	if(INSAlignmentTimer >= 350)
		INSStatus = 30;
	if(INSAlignmentTimer >= 415)
		INSStatus = 20;
	if(INSAlignmentTimer >= 480)	//8 minutes
		INSStatus = 10;
}
Ejemplo n.º 2
0
// updates the panel prop (if any) with a skin to reflect the button's state
void CASW_Button_Area::UpdatePanelSkin()
{
	if ( !m_hPanelProp.Get() )
		return;

	if ( asw_debug_button_skin.GetBool() )
	{
		Msg( "CASW_Button_Area:%d: UpdatePanelSkin\n", entindex() );
	}
	CBaseAnimating *pAnim = dynamic_cast<CBaseAnimating*>(m_hPanelProp.Get());
	while (pAnim)
	{		
		if (HasPower())
		{
			if (m_bIsLocked)
			{
				pAnim->m_nSkin = 1;	// locked skin
				if ( asw_debug_button_skin.GetBool() )
				{
					Msg( "  Panel is locked, setting prop %d skin to %d\n", pAnim->entindex(), pAnim->m_nSkin.Get() );
				}
			}
			else
			{
				pAnim->m_nSkin = 2;	// unlocked skin
				if ( asw_debug_button_skin.GetBool() )
				{
					Msg( "  Panel is unlocked, setting prop %d skin to %d\n", pAnim->entindex(), pAnim->m_nSkin.Get() );
				}
			}
		}
		else
		{
			pAnim->m_nSkin = 0;	// no power skin
			if ( asw_debug_button_skin.GetBool() )
			{
				Msg( "  Panel is no power, setting prop %d skin to %d\n", pAnim->entindex(), pAnim->m_nSkin.Get() );
			}
		}

		if (m_bMultiplePanelProps)
			pAnim = dynamic_cast<CBaseAnimating*>(gEntList.FindEntityByName( pAnim, m_szPanelPropName ));
		else
			pAnim = NULL;
	}
}
Ejemplo n.º 3
0
bool C_ASW_Button_Area::GetUseAction(ASWUseAction &action, C_ASW_Marine *pUser)
{
	action.UseIconRed = 255;
	action.UseIconGreen = 255;
	action.UseIconBlue = 255;
	action.bShowUseKey = true;
	action.iInventorySlot = -1;
	if (!HasPower())
	{
		action.iUseIconTexture = GetNoPowerIconTextureID();
		TryLocalize( GetNoPowerText(), action.wszText, sizeof( action.wszText ) );
		action.UseTarget = this;
		action.fProgress = GetHackProgress();
		action.bShowUseKey = false;
		return true;
	}
	if (IsLocked())
	{
		CASW_Marine_Profile *pProfile = pUser->GetMarineProfile();

		if ( m_bAnyoneCanHack || pProfile->CanHack() )
		{
			action.iUseIconTexture = GetHackIconTextureID();
			TryLocalize( GetHackIconText(pUser), action.wszText, sizeof( action.wszText ) );
			action.UseTarget = this;
			action.fProgress = GetHackProgress();
		}
		else
		{
			action.iUseIconTexture = GetLockedIconTextureID();
			TryLocalize( GetLockedIconText(), action.wszText, sizeof( action.wszText ) );
			action.UseTarget = this;
			action.fProgress = GetHackProgress();
		}	
	}

	else
	{
		action.iUseIconTexture = GetUseIconTextureID();
		TryLocalize( GetUseIconText(), action.wszText, sizeof( action.wszText ) );
		action.UseTarget = this;
		action.fProgress = -1;
	}
	return true;
}
Ejemplo n.º 4
0
void AircraftClass::EWSFlareBurst(void)
{
	PlayerRwrClass* theRwr = (PlayerRwrClass*)FindSensor(this, SensorClass::RWR);

	if (mFaults && (mFaults->GetFault(FaultClass::cmds_fault) & FaultClass::bus))
		return;

	if(theRwr)
	{
		if(!theRwr->IsOn() || !HasPower(AircraftClass::EWSFlarePower))
			return;
	}
	else	//no RWR, return anyway
		return;

	//set our next release time
	FlareBurstInterval = static_cast<VU_TIME>(SimLibElapsedTime + (OTWDriver.pCockpitManager->mpIcp->fFLARE_BI[EWSProgNum] * CampaignSeconds));
	//Drop one right now
	FlareCount++;
	DropFlare();
}
Ejemplo n.º 5
0
void AircraftClass::CalcINSDrift(void)
{
	/*ok do this.
	after 6min make it drift with 0.1 nm pr hour in a randon direction.
	after 12 min - 0.2
	18 min - 0.3
	........
	60min 1.0
	after 8min...if they take it after 2 min then add 10% to the drift speeds
	ie 6min - 0.11 nm/hour
	*/
	//check for changing direction
	INSDriftDirectionTimer -= SimLibMajorFrameTime;
	if(INSDriftDirectionTimer <= 0.0F)
	{
		if(rand()%11 > 5)
			INSDriftLatDirection = 1;
		else
			INSDriftLatDirection = -1;
		if(rand()%11 > 5)
			INSDriftLongDirection = 1;
		else
			INSDriftLongDirection = -1;

		INSDriftDirectionTimer = 300.0F;
	}
	//difference from alignment till now
	INSTimeDiff = (float)vuxGameTime - INSAlignmentStart;
	INSTimeDiff /= 1000;	//to get seconds
	INSTimeDiff /= 60;	//minutes
#ifndef _DEBUG
	//no drift when GPS is powered
	if(HasPower(GPSPower))
		INSAlignmentStart = vuxGameTime;
#endif
	if(INSStatus <= 10)
	{
		//per 6 minutes 0.1NM drift -> 0.01666666666NM per minute
		INSLatDrift = 0.01666666666F * INSTimeDiff;
		//get it in feet
		INSLatDrift *= NM_TO_FT;
		INSLongDrift = INSLatDrift;

		//drift in random direction
		INSLatDrift *= INSDriftLatDirection;
		INSLongDrift *= INSDriftLongDirection;
	}
	else
	{	//10% more drift per hour
		float Factor = 10;
		//find our alignment status and calculate how much more drift we have
		Factor = (float)(10 - ((100 - INSStatus)/10));
		//"precise drift"
		INSLatDrift = 0.01666666666F * INSTimeDiff;
		//add the additional drift factor, in percent, 10% max
		//60 equals 100% (70-10)
		INSLatDrift += (INSLatDrift/60) * Factor;
		//get it in feet
		INSLatDrift *= NM_TO_FT;
		INSLongDrift = INSLatDrift;	//drifts the same in both directions

		//drift in random direction
		INSLatDrift *= INSDriftLatDirection;
		INSLongDrift *= INSDriftLongDirection;
	}
}
Ejemplo n.º 6
0
void CASW_Button_Area::ActivateUseIcon( CASW_Marine* pMarine, int nHoldType )
{
	if ( nHoldType == ASW_USE_HOLD_START )
		return;

	// player has used this item
	//Msg("Player has activated a button area\n");
	if ( !HasPower() || !ASWGameResource() )
	{
		// todo: launch a window on the client saying there's no power, or whatever message is desired
		//Msg("We don't have the power cap'n\n");
		return;
	}
	if ( m_bIsLocked )
	{
		if ( pMarine->GetMarineProfile()->CanHack() )
		{
			// can hack, get the player to launch his hacking window				
			if ( !m_bIsInUse )
			{				
				if ( pMarine->StartUsing(this) )
				{
					if ( GetHackProgress() <= 0 && pMarine->GetMarineResource() )
					{
						pMarine->GetMarineResource()->m_iDamageTakenDuringHack = 0;
					}
					m_iAliensKilledBeforeHack = ASWGameResource()->GetAliensKilledInThisMission();

					m_OnButtonHackStarted.FireOutput( pMarine, this );
					if ( !asw_simple_hacking.GetBool() && pMarine->IsInhabited() )
					{
						if ( !GetCurrentHack() )	// if we haven't created a hack object for this computer yet, then create one	
						{
							m_hDoorHack = (CASW_Hack_Wire_Tile*) CreateEntityByName( "asw_hack_wire_tile" );
						}

						if ( GetCurrentHack() )
						{
							GetCurrentHack()->InitHack( pMarine->GetCommander(), pMarine, this );
						}
					}

					if ( m_iHackLevel > 20 )
					{
						pMarine->GetMarineSpeech()->Chatter( CHATTER_HACK_LONG_STARTED );
					}
					else
					{
						pMarine->GetMarineSpeech()->Chatter( CHATTER_HACK_STARTED );
					}
				}
			}
			else
			{
				if ( pMarine->m_hUsingEntity.Get() == this )
				{
					pMarine->StopUsing();
				}
				//Msg("Panel already in use");
			}
			//Msg("Unlocked button\n");
			// test hack puzzle so far
			/*
			m_hDoorHack = (CASW_Hack_Door*) CreateEntityByName( "asw_hack_door" );
			if (GetCurrentHack())
			{
				//for (int i=0;i<10;i++)
				//{
					GetCurrentHack()->InitHack(pPlayer, pMarine, this);
					GetCurrentHack()->BuildPuzzle(7);
					GetCurrentHack()->ShowPuzzleStatus();
				//}
			}
			*/
			
			
		}
		else
		{
			// can't hack (play some access denied sound)
			//Msg("Access denied\n");
			EmitSound("ASWComputer.AccessDenied");

			// check for a nearby AI tech marine
			float flMarineDistance;
			CASW_Marine *pTech = UTIL_ASW_NearestMarine( WorldSpaceCenter(), flMarineDistance, MARINE_CLASS_TECH, true );
			if ( pTech && flMarineDistance < asw_tech_order_hack_range.GetFloat() )
			{
				//Msg( "Told tech to hack panel\n" );
				pTech->OrderHackArea( this );
			}
			return;
		}
	}
	else
	{
		if ( pMarine )
		{
			pMarine->GetMarineSpeech()->Chatter(CHATTER_USE);
		}
		ActivateUnlockedButton( pMarine );
	}	
}