RuneI
Class Instrument

source: c:\runehov\RuneI\Classes\Instrument.uc
Core.Object
   |
   +--Engine.Actor
      |
      +--Engine.Decoration
         |
         +--RuneI.DecorationRune
            |
            +--RuneI.Instrument
Direct Known Subclasses:Drum, Gong, Horn

class Instrument
extends RuneI.DecorationRune

//============================================================================= // Instrument. //=============================================================================
Variables
 bool bTriggerOnceOnly


Function Summary
 bool CanBeUsed(Actor Other)
     
//============================================================================
//
// CanBeUsed
//
// Whether the actor can be used.
//============================================================================
 name GetUseAnim()
     
//============================================================================
//
// GetUseAnim
//
// Returns the animation that the player (or a viking) should play when
// this item is 'used'. 
//============================================================================
 int GetUsePriority()
     
//============================================================================
//
// GetUsePriority
//
// Returns the priority of the weapon, lower is better
//============================================================================
 void PlayInstrument(Actor Musician)
     
//============================================================
//
// PlayInstrument
//
// Override with playing sounds, anims, dynamics, etc. and call from stimuli
//============================================================
 void Trigger(Actor Other, Pawn EventInstigator)
     
//============================================================
// Stimulus
//============================================================
 bool UseTrigger(Actor Other)



Source Code


00001	//=============================================================================
00002	// Instrument.
00003	//=============================================================================
00004	class Instrument expands DecorationRune
00005		abstract;
00006	
00007	var() bool bTriggerOnceOnly;
00008	var	  bool bWasTriggered;
00009	
00010	//============================================================
00011	// Stimulus
00012	//============================================================
00013	
00014	function Trigger(actor Other, pawn EventInstigator)
00015	{
00016		PlayInstrument(Other);
00017	}
00018	
00019	function bool UseTrigger(actor Other)
00020	{
00021		PlayInstrument(Other);
00022		return true;
00023	}
00024	
00025	//============================================================================
00026	//
00027	// CanBeUsed
00028	//
00029	// Whether the actor can be used.
00030	//============================================================================
00031	
00032	function bool CanBeUsed(Actor Other)
00033	{
00034		// Can only be used if the player is facing it
00035		if(!Other.ActorInSector(self, ANGLE_45))
00036			return(false);
00037	
00038		return(true);
00039	}
00040	
00041	//============================================================================
00042	//
00043	// GetUsePriority
00044	//
00045	// Returns the priority of the weapon, lower is better
00046	//============================================================================
00047	
00048	function int GetUsePriority()
00049	{
00050		return(7);
00051	}
00052	
00053	//============================================================================
00054	//
00055	// GetUseAnim
00056	//
00057	// Returns the animation that the player (or a viking) should play when
00058	// this item is 'used'. 
00059	//============================================================================
00060	
00061	function name GetUseAnim()
00062	{
00063		return('pumpTrigger'); // TEMP:  Using pumpTrigger until we have proper instrument anims
00064	}
00065	
00066	//============================================================
00067	//
00068	// PlayInstrument
00069	//
00070	// Override with playing sounds, anims, dynamics, etc. and call from stimuli
00071	//============================================================
00072	function PlayInstrument(actor Musician)
00073	{
00074		local actor A;
00075	
00076		if(bTriggerOnceOnly && bWasTriggered)
00077		{ // Don't allow re-triggering if it isn't necessary
00078			return;
00079		}
00080	
00081		// Broadcast the Trigger message to all matching actors.
00082		if( Event != '' )
00083			foreach AllActors( class 'Actor', A, Event )
00084				A.Trigger(Musician, Musician.Instigator);
00085	
00086		bWasTriggered = true;
00087	}
00088	
00089	defaultproperties
00090	{
00091	     bTriggerOnceOnly=True
00092	}

End Source Code