//=============================================================================
// TranslatorEvent.
//=============================================================================
class TranslatorEvent expands Triggers;

#exec AUDIO IMPORT FILE="Sounds\Pickups\TransA3.WAV" NAME="TransA3" GROUP="Pickups"
#exec Texture Import File=Textures\Message.pcx Name=S_Message Mips=Off Flags=2

// Human readable triggering message.
var() string[255] Message;
var() string[255] AltMessage;
var() string[255] Hint;
var() bool bTriggerOnly;
var() sound NewMessageSound;
var() bool bTriggerAltMessage;
var string[255] Temp;
var bool bHitOnce;
var Translator Trans;


function Trigger( actor Other, pawn EventInstigator )
{
	local Actor Targets;

	if (bTriggerAltMessage) 
	{
		Temp = Message;
		Message = AltMessage;
		AltMessage = Temp;
		bHitOnce = False;
		foreach TouchingActors(class'Actor', Targets)
			if (Targets == Other) Touch(Other);
	}
	else Touch(Other);
}

function UnTrigger( actor Other, pawn EventInstigator )
{
	UnTouch(Other);
}


function Touch( actor Other )
{
	local inventory Inv;
	
	if (PlayerPawn(Other)==None) Return;
	
	if (Hint=="" && Message=="") Return;
	
	for( Inv=Other.Inventory; Inv!=None; Inv=Inv.Inventory ) 	
		if (Translator(Inv)!=None) 
		{
			Translator(Inv).Hint = Hint;
			Translator(Inv).bShowHint = False;
			if (Message=="") Return;
			Trans = Translator(Inv);
			if (!bHitOnce) Translator(Inv).bNewMessage = true;
			else Translator(Inv).bNotNewMessage = true;
			Translator(Inv).OlderMessage = Translator(Inv).OldMessage;
			Translator(Inv).OldMessage = Translator(Inv).NewMessage;
			Translator(Inv).NewMessage = Message;
			if (!bHitOnce) Pawn(Other).ClientMessage("New Translator Message");
			else Pawn(Other).ClientMessage("Translator Message");
			bHitOnce = True;			
			PlaySound(NewMessageSound, SLOT_Misc);
			Break;
		}
	
}

function UnTouch( actor Other )
{
	if (Trans!=None)	{
		Trans.bNewMessage = False;
		Trans.bNotNewMessage = False;
		if (Trans.State=='Activated') Trans.GoToState('Deactivated');
	}
}

