Exemplo n.º 1
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;
}
Exemplo n.º 2
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 );
	}	
}