# SpatialFear.SFUseKeyTrigger

00001 00002 00003 00004 00005 00006 00007 00008 00009 00010 00011 00012 00013 00014 00015 00016 00017 00018 00019 00020 00021 00022 00023 00024 00025 00026 00027 00028 00029 00030 00031 00032 00033 00034 00035 00036 00037 00038 00039 00040 00041 00042 00043 00044 00045 00046 00047 00048 00049 00050 00051 00052 00053 00054 00055 00056 00057 00058 00059 00060 00061 00062 00063 00064 00065 00066 00067 00068 00069 00070 00071 00072 00073 00074 00075 00076 00077 00078 00079 00080 00081 00082 00083 00084 00085 00086 00087 00088 |
    //=============================================================================
    // Spatial Fear
    // Class: SFUseKeyTrigger
    // Descritption: SFTrigger subclass, that can be configured to ignore touching/untouching,
    // but instead fires  an event, when the trigger is in range of the UseKey trace.
    // UseKey trace is issued by the SFPlayer class.
    // Range of the use key trace can be configured on the SFPlayer, with the property
    // UseKeyRange or the console command: "SFUseKeyRange" and defaults to 100 UUs.
    //
    // Author: Markus Nuebel
    //=============================================================================

    class SFUseKeyTrigger extends SFTrigger;

    var (SpatialFear) bool bShowHUDHint; // This flags determines, if a HUD hint (Icon) is displayed, when the player get close to the trigger. The UseKeyHint icon is displayed only for triggers which have a line of sight to the player. If they are inside of some geometry, and cannot be seen, use the bDirectional flag and set it's direction. In this case the direction will be checked instead of the line of sight. Defaults to true.
    var (SpatialFear) bool IgnoreTouching; //Ignore touch/untouch and instead fire when within a range of a UseKey trace. Defaults to true.
    var (SpatialFear) localized string ActorTip; // Actor tip displayed over actor, when within range: Defautl: ""
    var (SpatialFear) bool bNeedsLineOfSight; // This flags determines, the display of a HUD hint icon requires a lineOfSight to the mover. Default: false
    var bool m_bTriggerNoMore; // Private: Keeps track of trigger only once triggers. Default: false

    // Called when something touches the trigger.
    function Touch( actor Other )
    {
    	// Only fire event in parent class, when configured
    	if(!IgnoreTouching)
    		Super.Touch(Other);
    }

    // Called when something un touches the trigger.
    function UnTouch( actor Other )
    {
    	// Only fire event in parent class, when configured
    	if(!IgnoreTouching)
    		Super.UnTouch(Other);
    }

    // Manually fires the actors event
    function FireEvent( actor Other )
    {
    	local actor A;

    	// The trigger has already been fired and is configured to trigger only once
    	if(m_bTriggerNoMore )
    		return;

    	// Only fire when touching is ignored
    	if(!IgnoreTouching)
    		return;

    	if( Other.IsA('SFPlayer') && IsRelevant(Other))
    	{
    		if ( ReTriggerDelay > 0 )
    		{
    			if ( Level.TimeSeconds - TriggerTime < ReTriggerDelay )
    				return;
    			TriggerTime = Level.TimeSeconds;
    		}
    		// Broadcast the Trigger message to all matching actors.
    		if( Event != '' )
    			foreach AllActors( class 'Actor', A, Event )
    				A.Trigger( Other, Other.Instigator );

    		if ( Other.IsA('Pawn') && (Pawn(Other).SpecialGoal == self) )
    			Pawn(Other).SpecialGoal = None;

    		if( Message != "" )
    			// Send a string message to the toucher.
    			Other.Instigator.ClientMessage( Message );

    		if( bTriggerOnceOnly )
    		{
    			// SF is not using collision
    			// Ignore future touches.
    			// SetCollision(False);
    			m_bTriggerNoMore = true;
    		}
    		else if ( RepeatTriggerTime > 0 )
    			SetTimer(RepeatTriggerTime, false);
    	}
    }

    defaultproperties
    {
         bShowHUDHint=True
         IgnoreTouching=True
    }

class file time: 12/7/2003 3:58:24 PM - creation time: 12/7/2003 4:03:45 PM
Created with UnCodeX