# SFScoutBot.SFScoutBot

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 00149 00150 00151 00152 00153 00154 00155 00156 00157 00158 00159 00160 00161 00162 00163 00164 00165 00166 00167 00168 00169 00170 00171 00172 00173 00174 00175 00176 00177 00178 00179 00180 00181 00182 00183 00184 00185 00186 00187 00188 00189 00190 00191 00192 00193 00194 00195 00196 00197 00198 00199 00200 00201 00202 00203 00204 00205 00206 00207 00208 00209 00210 00211 00212 00213 00214 00215 00216 00217 00218 00219 00220 00221 00222 00223 00224 00225 00226 00227 00228 00229 00230 00231 00232 00233 00234 00235 00236 00237 00238 00239 00240 00241 00242 00243 00244 00245 00246 00247 00248 00249 00250 00251 00252 00253 00254 00255 |
    //=============================================================================
    // Spatial Fear
    // Class: SFScoutBot
    // Description: Ok, here it is, a beta version of Scout Bot :))
    //              Scoutbot can be activated by any trigger or by SFBotRemote item.
    //              To link a ScoutBot with a trigger os remote you have to
    //              set "event" of a trigger or remote to "tag" of a ScoutBot.
    //              To deactivate ScoutBot simply press the usekey.
    //
    //              Keep in mind that it is just a beta of and some things might
    //              be screwed up.
    //
    // Code:  Jacek Zagrodzki
    // Model: Dean Stamp
    //=============================================================================
    class SFScoutBot extends SFDecoration;

    #exec MESH IMPORT MESH=SFScoutBot ANIVFILE=MODELS\SFScoutBot_a.3d DATAFILE=MODELS\SFScoutBot_d.3d X=0 Y=0 Z=0
    #exec MESH ORIGIN MESH=SFScoutBot X=0 Y=0 Z=0 YAW=64

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

    #exec TEXTURE IMPORT NAME=JSFScoutBot FILE=TEXTURES\SFScoutBot.PCX GROUP=Skins FLAGS=2 // skin01

    #exec MESHMAP NEW   MESHMAP=SFScoutBot MESH=SFScoutBot
    #exec MESHMAP SCALE MESHMAP=SFScoutBot X=0.075 Y=0.075 Z=0.15

    #exec MESHMAP SETTEXTURE MESHMAP=SFScoutBot NUM=1 TEXTURE=JSFScoutBot

    // PUBLIC VARIABLES:
    //
    var(ScoutBot) class<HUD>	BotHUDClass;
    var(ScoutBot) int			BotFOV;

    var(ScoutBot) float		AccelRate;
    var(ScoutBot) float		RotationRate;

    var(ScoutBot) float		SpeedDumpening;
    var(ScoutBot) float		RotationDumpening;

    // PRIVATE VARIABLES:
    /////
    var SFPlayer		aPlayer;		// reference/pointer to a player that uses ScoutBot
    var HUD			BotHUD;

    var bool			bScouting;
    var SFScoutBotRemote	RemoteControl;	// a pointer to a piece of inventory that is controller of this ScoutBot
    var FlashLightBeam		LightBeam;

    var name			oldState;
    var float			oldFOV;
    var HUD			oldHUD;
    var bool			oldBehind;

    // variables use for movement:
    var rotator		ViewRotation;

    var float		PitchAccel;
    var float		PitchVel;

    var float		YawAccel;
    var float		YawVel;

    function PostBeginPlay()
    {
    	BotHUD 		= spawn(BotHUDClass, Self);
    }

    function ActivateLight()
    {
    	LightBeam = Spawn(class'FlashLightBeam',self, '', Location);
    	LightBeam.LightHue			= 140;
    	LightBeam.LightSaturation	= 200;
    	LightBeam.LightRadius		= 5;

    }

    function UpdateLight(rotator rotViewRotation)
    {
    	local vector HitNormal,HitLocation,EndTrace,StartTrace,X,Y,Z,NewHitLocation;

    	GetAxes(rotViewRotation,X,Y,Z);
    	EndTrace = Location + 10000* Vector(rotViewRotation);
    	Trace(HitLocation,HitNormal,EndTrace,Location, True);

    	LightBeam.SetLocation(HitLocation-vector(rotViewRotation)*32);

    }

    event Trigger( Actor Other, Pawn EventInstigator )
    {
    	aPlayer=SFPlayer(EventInstigator);

    	if(aPlayer == None)
    		return;

    	if(!aPlayer.CanAcceptScoutBotLinkup())
    		return;

    	if(!bScouting)
    	{
    		bScouting = true;
    		aPlayer.ScoutBot = Self;
    		aPlayer.ViewTarget = Self;

    		aPlayer.Acceleration = vect(0,0,0);

    		oldState = aPlayer.GetStateName();
    		aPlayer.GotoState('Scouting');

    		// setting other parameters:
    		oldFOV = aPlayer.DesiredFOV;
    		aPlayer.DesiredFOV = BotFOV;

    		oldHUD = aPlayer.myHUD;
    		aPlayer.myHUD = BotHUD;

    		oldBehind = aPlayer.bBehindView;

    		ActivateLight();
    		UpdateLight(ViewRotation);

    	}
    	else
    	{

    		bScouting = false;
    		aPlayer.ScoutBot = None;
    		aPlayer.myHUD = oldHUD;
    		aPlayer.GotoState(oldState);
    		aPlayer.ViewTarget = none;
    		aPlayer.DesiredFOV = oldFOV;
    		aPlayer.bBehindView = oldBehind;
    		LightBeam.Destroy();

    		Acceleration = vect(0,0,0);
    		PitchAccel = 0.0;
    		YawAccel = 0.0;
    	}
    }

    function Tick(float DTime)
    {
    	local vector	OffSet;
    	local rotator	newRot;

    	// dumpening velocity and rotation:
    	Velocity -= DTime*0.1*SpeedDumpening * Velocity;
    	PitchVel -= DTime*0.1*RotationDumpening * PitchVel;
    	YawVel -= DTime*0.1*RotationDumpening * YawVel;

    	// acceleration affecting velocity and rotation:
    	Velocity += DTime * Acceleration;
    	PitchVel += DTime * PitchAccel;
    	YawVel += DTime * YawAccel;

    	ViewRotation.Pitch += PitchVel*DTime;
    	ViewRotation.Yaw += YawVel*DTime;

    	//
    	MoveSmooth(Velocity*DTime);
    	SetRotation(ViewRotation);

    	if(bScouting)
    	{
    		// checking if an owner player is alive:
    		if(aPlayer.IsInState('Dying'))
    		{
    			oldState = 'Dying';
    			Destroy();
    		}

    		// checking if fov is correct
    		if(aPlayer.DesiredFOV != BotFOV)
    			aPlayer.DesiredFOV = BotFOV;

    		// forcing first person view
    		if(aPlayer.bBehindView != false)
    			aPlayer.bBehindView = false;

    		// Update the light
    		UpdateLight(ViewRotation);
    	}
    	else
    	{

    	}
    }

    event Destroyed()
    {
    	BotHUD.Destroy();

    	if(bScouting)
    		Trigger(None, aPlayer);

    	if(RemoteControl != None)
    	{
    		RemoteControl.TargetBot = None;
    		SFHUD(aPlayer.myHUD).removeFromActiveItemBelt(RemoteControl);
    	}
    }

    function ModifyDamage( out int Damage, out Pawn EventInstigator, out vector HitLocation, out vector Momentum, out name DamageType)
    {
    	Velocity += Damage * Normal(Momentum);
    }

    //function ProcessMove(float DTime, vector NewAccel, eDodgeDir DodgeMove, rotator DeltaRot)
    function Drop(vector BlahBlahBlah)
    {
    	local vector X,Y,Z;

    	aPlayer.aForward *= 0.001;
    	aPlayer.aStrafe  *= 0.0015;
    	aPlayer.aUp      *= 0.0005;
    	aPlayer.aLookup  *= 0.2;
    	aPlayer.aTurn    *= 0.2;

    	GetAxes(Rotation,X,Y,Z);
    	Acceleration = AccelRate * (aPlayer.aForward*X + aPlayer.aStrafe*Y + aPlayer.aUp*vect(0,0,1));

    	PitchAccel = RotationRate * aPlayer.aLookUp;
    	YawAccel = RotationRate * aPlayer.aTurn;
    }

    defaultproperties
    {
         BotHUDClass=Class'SFScoutBot.SFScoutBotHUD'
         BotFOV=120
         AccelRate=50.000000
         RotationRate=50.000000
         SpeedDumpening=20.000000
         RotationDumpening=40.000000
         bDestroyable=True
         Health=125
         EffectWhenDestroyed=Class'UnrealShare.SpriteBallExplosion'
         EffectWhenDamaged=Class'UnrealShare.ParticleBurst'
         ChunkType=Class'UnrealShare.WallFragments'
         ChunksNumber=6
         ChunkScale=0.350000
         bStatic=False
         Physics=PHYS_Flying
         DrawType=DT_Mesh
         Mesh=LodMesh'SFScoutBot.SFScoutBot'
         CollisionHeight=14.000000
    }

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