# SFItem.SFFlashlight

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 00089 00090 00091 00092 00093 00094 00095 00096 00097 00098 00099 00100 00101 00102 00103 00104 00105 00106 00107 00108 00109 00110 00111 00112 00113 00114 00115 00116 00117 00118 00119 00120 00121 00122 00123 00124 00125 00126 00127 00128 00129 00130 00131 00132 00133 00134 00135 00136 00137 00138 00139 00140 00141 00142 00143 00144 00145 00146 00147 00148 |
    //=============================================================================
    // Spatial Fear
    // Class: SFFlashlight
    // Description: An Unreal-like flashlight.
    //
    // Author: Jacek Zagrodzki, model by Ivan Tanzuira
    // Modified by: Markus Nuebel
    //=============================================================================

    class SFFlashlight extends SFPickup;

    #exec MESH IMPORT MESH=SFFlashlight ANIVFILE=MODELS\SFFlashlight_a.3d DATAFILE=MODELS\SFFlashlight_d.3d X=0 Y=0 Z=0
    #exec MESH ORIGIN MESH=SFFlashlight X=0 Y=0 Z=0

    #exec MESH SEQUENCE MESH=SFFlashlight SEQ=All          STARTFRAME=0 NUMFRAMES=1
    #exec MESH SEQUENCE MESH=SFFlashlight SEQ=SFFlashlight STARTFRAME=0 NUMFRAMES=1

    #exec TEXTURE IMPORT NAME=JSFFlashlight1 FILE=TEXTURES\SFFlashlight1.PCX GROUP=Skins FLAGS=2 // 1 - Default

    #exec MESHMAP NEW   MESHMAP=SFFlashlight MESH=SFFlashlight
    #exec MESHMAP SCALE MESHMAP=SFFlashlight X=0.05 Y=0.05 Z=0.1

    #exec MESHMAP SETTEXTURE MESHMAP=SFFlashlight NUM=1 TEXTURE=JSFFlashlight1

    var FlashLightBeam s;
    var float Charge, TimeChange;
    var int Status;
    var Vector HitNormal,HitLocation,EndTrace,StartTrace,X,Y,Z,NewHitLocation;

    function Activate()
    {
    	GotoState('Activated');
    }

    state Activated
    {
    	function endstate()
    	{
    		if (s!=None) s.Destroy();
    		bActive = false;
    	}

    	function Tick( float DeltaTime )
    	{
    		TimeChange += DeltaTime*10;
    		if (TimeChange > 1)
    		{
    			Charge		-= int(TimeChange);
    			TimeChange	= TimeChange - int(TimeChange);
    		}

    		if (s == None) Return;

    		if ( Pawn(Owner) == None )
    		{
    			s.Destroy();
    			UsedUp();
    			return;
    		}
    		if (Charge<-0)
    		{
    			GotoState('Deactivated');
    		}
    		if (Charge<400) s.LightBrightness=byte(Charge*0.7+10);

    		GetAxes(Pawn(Owner).ViewRotation,X,Y,Z);
    		EndTrace = Pawn(Owner).Location + 10000* Vector(Pawn(Owner).ViewRotation);
    		Trace(HitLocation,HitNormal,EndTrace,Pawn(Owner).Location, True);
    		s.SetLocation(HitLocation-vector(Pawn(Owner).ViewRotation)*64);
    //		s.LightRadius = fmin(Vsize(HitLocation-Pawn(Owner).Location)/200,14) + 2.0;
    	}

    	function BeginState()
    	{
    		Status = 2;
    		TimeChange = 0;
    		Owner.PlaySound(ActivateSound);
    		GetAxes(Pawn(Owner).ViewRotation,X,Y,Z);
    		EndTrace = Pawn(Owner).Location + 10000* Vector(Pawn(Owner).ViewRotation);
    		Trace(HitLocation,HitNormal,EndTrace,Pawn(Owner).Location+Y*17);
    		s = Spawn(class'FlashLightBeam',Owner, '', HitLocation+HitNormal*40);
    		s.LightHue = LightHue;
    		s.LightSaturation = LightSaturation;
    		s.LightRadius = LightRadius;

    		if (Charge<400)
    		{
    			s.LightBrightness=byte(Charge*0.6+10);
    		}

    		if (s==None) GoToState('DeActivated');
    	}

    Begin:
    }

    state DeActivated
    {
    	function BeginState()
    	{
    		Status = 1;

    		// Call to base class
    		Super.BeginState();

    		SetTimer(0.5, false);
    	}

    	function Timer()
    	{
    		if(Charge < Default.Charge)
    		{
    			Charge	+= 5;
    			SetTimer(0.5,false);
    		}
    	}

    Begin:
    	s.Destroy();
    	Owner.PlaySound(DeActivateSound);
    }

    defaultproperties
    {
         Charge=1100.000000
         ItemDescription="Flashlight:\nAn illumination device.  Has a limited power supply, but recharges automatically."
         ItemIcon=Texture'SfResource1.Icons.FlashlightIco'
         bIsActiveItem=True
         bManualPickup=True
         ItemName="Flashlight"
         PlayerViewMesh=LodMesh'SFItem.SFFlashlight'
         PickupViewMesh=LodMesh'SFItem.SFFlashlight'
         PickupSound=Sound'UnrealShare.Pickups.GenPickSnd'
         ActivateSound=Sound'UnrealI.Pickups.fFieldh2'
         M_Activated=""
         M_Selected=""
         M_Deactivated=""
         RemoteRole=ROLE_DumbProxy
         Mesh=LodMesh'SFItem.SFFlashlight'
         CollisionRadius=22.000000
         CollisionHeight=4.000000
         LightHue=145
         LightSaturation=180
         LightRadius=7
    }

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