# SFWeapon.SFUSrifle

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 00256 00257 00258 00259 00260 00261 00262 00263 00264 00265 00266 00267 00268 00269 00270 00271 00272 00273 00274 00275 00276 00277 00278 00279 00280 00281 00282 00283 00284 00285 00286 00287 00288 00289 00290 00291 00292 00293 00294 00295 00296 00297 00298 00299 00300 00301 00302 00303 00304 00305 00306 00307 00308 00309 00310 00311 00312 00313 00314 00315 00316 00317 00318 00319 00320 00321 00322 00323 00324 00325 00326 00327 00328 00329 00330 00331 00332 00333 00334 00335 00336 00337 00338 00339 00340 00341 00342 00343 00344 00345 00346 00347 00348 00349 00350 00351 00352 00353 00354 00355 00356 00357 00358 00359 00360 00361 00362 00363 00364 00365 00366 00367 00368 00369 00370 00371 00372 00373 00374 00375 00376 00377 00378 00379 00380 00381 00382 00383 00384 00385 00386 00387 00388 00389 00390 00391 00392 00393 00394 00395 00396 00397 00398 00399 00400 00401 00402 00403 00404 00405 00406 00407 00408 00409 00410 00411 00412 00413 00414 00415 00416 00417 00418 00419 00420 00421 00422 00423 00424 00425 00426 00427 00428 00429 00430 00431 00432 00433 00434 00435 00436 00437 00438 00439 00440 00441 00442 00443 00444 00445 00446 00447 00448 00449 00450 00451 00452 00453 00454 00455 00456 00457 00458 00459 00460 00461 00462 00463 00464 00465 00466 00467 00468 00469 00470 00471 00472 00473 00474 00475 00476 00477 00478 00479 00480 00481 00482 00483 00484 00485 00486 00487 00488 00489 00490 00491 00492 00493 00494 00495 00496 00497 00498 00499 00500 00501 00502 00503 00504 00505 00506 00507 00508 00509 00510 00511 00512 00513 00514 00515 00516 00517 00518 00519 00520 00521 00522 00523 00524 00525 00526 00527 00528 00529 00530 00531 00532 00533 00534 00535 00536 00537 00538 00539 00540 00541 00542 00543 00544 00545 00546 00547 00548 00549 00550 00551 00552 00553 00554 00555 00556 00557 00558 00559 00560 00561 00562 00563 00564 00565 00566 00567 00568 00569 00570 00571 00572 00573 00574 00575 00576 00577 00578 00579 00580 00581 00582 00583 00584 00585 00586 00587 00588 00589 00590 00591 00592 00593 00594 00595 00596 00597 00598 00599 00600 00601 00602 00603 00604 00605 00606 00607 00608 00609 00610 00611 00612 00613 00614 00615 00616 00617 00618 00619 00620 00621 00622 00623 00624 00625 00626 00627 00628 00629 00630 00631 00632 00633 00634 00635 00636 00637 00638 00639 00640 00641 00642 00643 00644 00645 00646 00647 00648 00649 |
    //=============================================================================
    // Spatial Fear
    // Class: SFUSRifle
    // Descripton: Subclasses of SFweapon
    //				Implements the SFUSRifle weapon
    //
    // Author: Markus Nuebel
    //=============================================================================

    class SFUSrifle expands SFWeapon;

    #exec OBJ LOAD FILE=Textures\SFUSRifle.utx  PACKAGE=SFWeapon GROUP=USRifle
    #exec OBJ LOAD FILE=SPF-Content.uax  PACKAGE=SPF-Content GROUP=Weapons

    //#exec AUDIO IMPORT FILE="Sounds\SonicRifle.wav"	NAME=Fire PACKAGE=SFWeapon GROUP=Sonic

    #exec TEXTURE IMPORT NAME=ushud1 FILE=TEXTURES\ushud01.pcx GROUP=Skins FLAGS=2
    #exec TEXTURE IMPORT NAME=ushud2 FILE=TEXTURES\ushud02.pcx GROUP=Skins FLAGS=2
    #exec TEXTURE IMPORT NAME=ushud3 FILE=TEXTURES\ushud03.pcx GROUP=Skins FLAGS=2
    #exec TEXTURE IMPORT NAME=ushud4 FILE=TEXTURES\ushud04.pcx GROUP=Skins FLAGS=2
    #exec TEXTURE IMPORT NAME=ushud5 FILE=TEXTURES\ushud05.pcx GROUP=Skins FLAGS=2
    #exec TEXTURE IMPORT NAME=ushud6 FILE=TEXTURES\ushud06.pcx GROUP=Skins FLAGS=2
    #exec TEXTURE IMPORT NAME=ushud7 FILE=TEXTURES\ushud07.pcx GROUP=Skins FLAGS=2
    #exec TEXTURE IMPORT NAME=ushud8 FILE=TEXTURES\ushud08.pcx GROUP=Skins FLAGS=2
    #exec TEXTURE IMPORT NAME=ushud9 FILE=TEXTURES\ushud09.pcx GROUP=Skins FLAGS=2
    #exec TEXTURE IMPORT NAME=ushud10 FILE=TEXTURES\ushud10.pcx GROUP=Skins FLAGS=2
    #exec TEXTURE IMPORT NAME=ushud11 FILE=TEXTURES\ushud11.pcx GROUP=Skins FLAGS=2
    #exec TEXTURE IMPORT NAME=ushud12 FILE=TEXTURES\ushud12.pcx GROUP=Skins FLAGS=2
    #exec TEXTURE IMPORT NAME=ushud13 FILE=TEXTURES\ushud13.pcx GROUP=Skins FLAGS=2
    #exec TEXTURE IMPORT NAME=ushud14 FILE=TEXTURES\ushud14.pcx GROUP=Skins FLAGS=2
    #exec TEXTURE IMPORT NAME=ushud15 FILE=TEXTURES\ushud15.pcx GROUP=Skins FLAGS=2
    #exec TEXTURE IMPORT NAME=ushud16 FILE=TEXTURES\ushud16.pcx GROUP=Skins FLAGS=2
    #exec TEXTURE IMPORT NAME=ushud17 FILE=TEXTURES\ushud17.pcx GROUP=Skins FLAGS=2
    #exec TEXTURE IMPORT NAME=ushud18 FILE=TEXTURES\ushud18.pcx GROUP=Skins FLAGS=2
    #exec TEXTURE IMPORT NAME=ushud19 FILE=TEXTURES\ushud19.pcx GROUP=Skins FLAGS=2
    #exec TEXTURE IMPORT NAME=ushud20 FILE=TEXTURES\ushud20.pcx GROUP=Skins FLAGS=2

    #exec MESH IMPORT MESH=SFUSRiflem ANIVFILE=MODELS\SFUSRiflem_a.3d DATAFILE=MODELS\SFUSRiflem_d.3d X=0 Y=0 Z=0
    #exec MESH ORIGIN MESH=SFUSRiflem X=0 Y=0 Z=0

    #exec MESH SEQUENCE MESH=SFUSRiflem SEQ=All    STARTFRAME=0 NUMFRAMES=66
    #exec MESH SEQUENCE MESH=SFUSRiflem SEQ=still  STARTFRAME=0 NUMFRAMES=1
    #exec MESH SEQUENCE MESH=SFUSRiflem SEQ=still2 STARTFRAME=1 NUMFRAMES=1
    #exec MESH SEQUENCE MESH=SFUSRiflem SEQ=fire1  STARTFRAME=2 NUMFRAMES=21
    #exec MESH SEQUENCE MESH=SFUSRiflem SEQ=fire2  STARTFRAME=23 NUMFRAMES=21
    #exec MESH SEQUENCE MESH=SFUSRiflem SEQ=select STARTFRAME=44 NUMFRAMES=11
    #exec MESH SEQUENCE MESH=SFUSRiflem SEQ=down   STARTFRAME=55 NUMFRAMES=11

    #exec TEXTURE IMPORT NAME=JSFUSRiflem1 FILE=TEXTURES\SFUSRiflem1.PCX GROUP=Skins FLAGS=2 // 3 - Default
    #exec TEXTURE IMPORT NAME=JSFUSRiflem2 FILE=TEXTURES\SFUSRiflem2.PCX GROUP=Skins PALETTE=JSFUSRiflem1 // 1 - Default
    #exec TEXTURE IMPORT NAME=JSFUSRiflem3 FILE=TEXTURES\SFUSRiflem3.PCX GROUP=Skins PALETTE=JSFUSRiflem1 // 2 - Default
    #exec TEXTURE IMPORT NAME=JSFUSRiflem4 FILE=TEXTURES\SFUSRiflem4.PCX GROUP=Skins PALETTE=JSFUSRiflem1 // Material #4
    #exec TEXTURE IMPORT NAME=JSFUSRiflem5 FILE=TEXTURES\SFUSRiflem5.PCX GROUP=Skins PALETTE=JSFUSRiflem1 // Material #5
    #exec TEXTURE IMPORT NAME=JSFUSRiflem6 FILE=TEXTURES\SFUSRiflem6.PCX GROUP=Skins PALETTE=JSFUSRiflem1 // 6- Default

    #exec MESHMAP NEW   MESHMAP=SFUSRiflem MESH=SFUSRiflem
    #exec MESHMAP SCALE MESHMAP=SFUSRiflem X=0.03 Y=0.03 Z=0.06

    #exec MESHMAP SETTEXTURE MESHMAP=SFUSRiflem NUM=1 TEXTURE=JSFUSRiflem1
    #exec MESHMAP SETTEXTURE MESHMAP=SFUSRiflem NUM=2 TEXTURE=JSFUSRiflem2
    #exec MESHMAP SETTEXTURE MESHMAP=SFUSRiflem NUM=3 TEXTURE=JSFUSRiflem3
    #exec MESHMAP SETTEXTURE MESHMAP=SFUSRiflem NUM=4 TEXTURE=JSFUSRiflem4
    #exec MESHMAP SETTEXTURE MESHMAP=SFUSRiflem NUM=5 TEXTURE=JSFUSRiflem5
    #exec MESHMAP SETTEXTURE MESHMAP=SFUSRiflem NUM=6 TEXTURE=JSFUSRiflem6

    #exec MESH IMPORT MESH=SFUSRiflehand ANIVFILE=MODELS\SFUSRiflehand_a.3d DATAFILE=MODELS\SFUSRiflehand_d.3d X=0 Y=0 Z=0
    #exec MESH ORIGIN MESH=SFUSRiflehand X=0 Y=0 Z=0

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

    #exec TEXTURE IMPORT NAME=JSFUSRiflehand1 FILE=TEXTURES\SFUSRiflehand1.PCX GROUP=Skins FLAGS=2 // 3 - Default
    #exec TEXTURE IMPORT NAME=JSFUSRiflehand2 FILE=TEXTURES\SFUSRiflehand2.PCX GROUP=Skins PALETTE=JSFUSRiflehand1 // 1 - Default
    #exec TEXTURE IMPORT NAME=JSFUSRiflehand3 FILE=TEXTURES\SFUSRiflehand3.PCX GROUP=Skins PALETTE=JSFUSRiflehand1 // 2 - Default
    #exec TEXTURE IMPORT NAME=JSFUSRiflehand4 FILE=TEXTURES\SFUSRiflehand4.PCX GROUP=Skins PALETTE=JSFUSRiflehand1 // Material #4
    #exec TEXTURE IMPORT NAME=JSFUSRiflehand5 FILE=TEXTURES\SFUSRiflehand5.PCX GROUP=Skins PALETTE=JSFUSRiflehand1 // Material #5

    #exec MESHMAP NEW   MESHMAP=SFUSRiflehand MESH=SFUSRiflehand
    #exec MESHMAP SCALE MESHMAP=SFUSRiflehand X=0.1 Y=0.1 Z=0.2

    #exec MESHMAP SETTEXTURE MESHMAP=SFUSRiflehand NUM=1 TEXTURE=JSFUSRiflehand1
    #exec MESHMAP SETTEXTURE MESHMAP=SFUSRiflehand NUM=2 TEXTURE=JSFUSRiflehand2
    #exec MESHMAP SETTEXTURE MESHMAP=SFUSRiflehand NUM=3 TEXTURE=JSFUSRiflehand3
    #exec MESHMAP SETTEXTURE MESHMAP=SFUSRiflehand NUM=4 TEXTURE=JSFUSRiflehand4
    #exec MESHMAP SETTEXTURE MESHMAP=SFUSRiflehand NUM=5 TEXTURE=JSFUSRiflehand5

    #exec MESH IMPORT MESH=SFUSRiflepick ANIVFILE=MODELS\SFUSRiflepick_a.3d DATAFILE=MODELS\SFUSRiflepick_d.3d X=0 Y=0 Z=0
    #exec MESH ORIGIN MESH=SFUSRiflepick X=0 Y=0 Z=0

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

    #exec TEXTURE IMPORT NAME=JSFUSRiflepick1 FILE=TEXTURES\SFUSRiflepick1.PCX GROUP=Skins FLAGS=2 // 3 - Default
    #exec TEXTURE IMPORT NAME=JSFUSRiflepick2 FILE=TEXTURES\SFUSRiflepick2.PCX GROUP=Skins PALETTE=JSFUSRiflepick1 // 1 - Default
    #exec TEXTURE IMPORT NAME=JSFUSRiflepick3 FILE=TEXTURES\SFUSRiflepick3.PCX GROUP=Skins PALETTE=JSFUSRiflepick1 // 2 - Default
    #exec TEXTURE IMPORT NAME=JSFUSRiflepick4 FILE=TEXTURES\SFUSRiflepick4.PCX GROUP=Skins PALETTE=JSFUSRiflepick1 // Material #4
    #exec TEXTURE IMPORT NAME=JSFUSRiflepick5 FILE=TEXTURES\SFUSRiflepick5.PCX GROUP=Skins PALETTE=JSFUSRiflepick1 // Material #5

    #exec MESHMAP NEW   MESHMAP=SFUSRiflepick MESH=SFUSRiflepick
    #exec MESHMAP SCALE MESHMAP=SFUSRiflepick X=0.08 Y=0.08 Z=0.16

    #exec MESHMAP SETTEXTURE MESHMAP=SFUSRiflepick NUM=1 TEXTURE=JSFUSRiflepick1
    #exec MESHMAP SETTEXTURE MESHMAP=SFUSRiflepick NUM=2 TEXTURE=JSFUSRiflepick2
    #exec MESHMAP SETTEXTURE MESHMAP=SFUSRiflepick NUM=3 TEXTURE=JSFUSRiflepick3
    #exec MESHMAP SETTEXTURE MESHMAP=SFUSRiflepick NUM=4 TEXTURE=JSFUSRiflepick4
    #exec MESHMAP SETTEXTURE MESHMAP=SFUSRiflepick NUM=5 TEXTURE=JSFUSRiflepick5

    var (SpatialFear) float fVisionRange; // Range of night vision. Default: 2000UUs
    var (SpatialFear) Sound m_sndEnergyUse; // Sound displayed, when energy is used up for night vision
    var name 	IdleAnims[2];
    var bool 	m_bVisionEnabled;
    var Actor	m_actDummy;
    var travel 	SFTexDummy m_actTexDummy;
    var int 	m_nVisionHSize, m_nVisionVSize;
    var bool 	m_bInitialized;
    var Texture m_arVisonTex[20];
    var int		m_nVisionXOffset;
    var int		m_nVisionYOffset;
    var vector 	m_vecSavedOffset ;
    var int 	m_nVisibleLifeForms;
    var int		m_nTickTracker;
    var SFFontInfo	m_Fonts;

    function PostBeginPlay()
    {
    	// Call to base class
    	Super.PostBeginPlay();

    	// Create the dummy actor, that holds the texture
    	m_actTexDummy = spawn(class'sfitem.SFTexDummy',,, Location);
    	m_actTexDummy.bHidden=true;
    	m_actTexDummy.DrawScale=0.0001f;

    	m_Fonts	= spawn(class'SpatialFear.SFFontInfo');
    }

    function SetSkins(Actor actor, out Texture oldSkins[9])
    {
    	local int     i;
    	local texture curSkin;

    	for (i=0; i<8; i++)
    	{
    		oldSkins[i] = actor.MultiSkins[i];
    	}
    	oldSkins[i] = actor.Skin;

    	for (i=0; i<8; i++)
    		if(None == actor.MultiSkins[i])
    			//actor.MultiSkins[i] = m_actDummy.Multiskins[1];//NightVisonTex; //Texture'SFWeapon.liquid.virus_sfx';
    			actor.MultiSkins[i] = m_actTexDummy.getWaveTex();
    //	actor.Skin = m_actDummy.Multiskins[1]; //Texture'SFWeapon.liquid.virus_sfx';
    	actor.Skin = m_actTexDummy.getWaveTex();
    }

    function ResetSkins(Actor actor, Texture oldSkins[9])
    {
    	local int i;

    	for (i=0; i<8; i++)
    	{
    		actor.MultiSkins[i] = oldSkins[i];
    	}
    	actor.Skin = oldSkins[i];
    }

    // Returns the owner heading in degrees
    function float getHeading()
    {
    	return ((Pawn(Owner).ViewRotation.Yaw*360/65535)+360)%360;
    }

    function Tick(float fDelta)
    {
    	local vector		X,Y,Z;

    	// Call to base class
    	Super.Tick(fDelta);

    	if(None != Owner)
    	{
    		// Get player orientation
    		GetAxes(Pawn(Owner).ViewRotation,X,Y,Z);
    		// Reposition dummy
    		m_actTexDummy.SetLocation(Location+X*80+Y*80+Z*80);
    	}
    	m_actTexDummy.SetCollision(false, false);
    	m_actTexDummy.DrawScale=0.01f;
    }
    simulated function bool isNightVisionObject(Actor A)
    {
    	return (A.IsA('Pawn') && (A!=Owner) && (!A.bHidden));
    }

    // Draws an actor with changed display properties
    simulated function drawChangedActor(Canvas C, Actor A, ERenderStyle NewStyle, texture NewTexture, bool bLighting, bool bEnviroMap )
    {
    	local Texture		oldSkins[9];
    	local ERenderStyle 	styleOld;
    	local Texture			texOld;
    	local bool 			bLightingOld;
    	local bool 			bEnviroMapOld;

    	// Retrieve current settings
    	styleOld		= A.Style;
    	texOld			= A.texture;
    	bLightingOld	= A.bUnlit;
    	bEnviroMapOld	= A.bMeshEnviromap;

    	// Set the new settings for the actor
    	A.Style		= NewStyle;
    //	A.texture 	= NewTexture;
    	SetSkins(A, oldSkins);
    //	A.bUnlit 	= bLighting;
    //	A.bMeshEnviromap 	= bEnviromap;

    	// Draw the actor
    	C.DrawActor(A, False, False);
    	A.bHidden=false;

    	// Restore old settings
    	A.Style				= styleOld;
    	ResetSkins(A, oldSkins);
    //	A.texture			= texOld;
    	A.bUnlit			= bLightingOld;
    	A.bMeshEnviromap	= bEnviroMapOld;

    }

    /*
    // Renders the surrounding texture
    simulated function renderVision(Canvas C)
    {
    	local int i, j;
    	local Texture tex;
    	local byte 	styleOld;
    	local int	x,y;

    	styleOld	= C.Style;
    	C.Style		= ERenderStyle.STY_Masked;

    	// Draw the black frame
    	C.SetPos(0,0);
    	C.DrawRect(Texture'BlackTexture', C.ClipX, m_nVisionYOffset);
    	C.SetPos(0,0);
    	C.DrawRect(Texture'BlackTexture', m_nVisionXOffset, C.ClipY);
    	C.SetPos(C.ClipX-m_nVisionXOffset,0);
    	C.DrawRect(Texture'BlackTexture', m_nVisionXOffset, C.ClipY);
    	C.SetPos(0,C.ClipY-m_nVisionYOffset);
    	C.DrawRect(Texture'BlackTexture', C.ClipX, m_nVisionYOffset);

    	for(i=0; i<3; i++)
    	{
    		for(j=0; j<4; j++)
    		{
    			tex = m_arVisonTex[i*4+j];
    			C.SetPos(m_nVisionXOffset+m_nVisionHSize*j, m_nVisionYOffset+m_nVisionVSize*i);
    			C.DrawTile(tex, m_nVisionHSize, m_nVisionVSize, 0, 0, tex.USize, tex.VSize);
    		}
    	}

    	C.Style=styleOld;
    }
    */

    // Renders the surrounding texture
    simulated function renderVision(Canvas C)
    {
    	local int i, j;
    	local Texture tex;
    	local byte 	styleOld;
    	local int	x,y;
    	local float	XL, YL;
    	local string	strText;
    	local float		fTime;

    	styleOld	= C.Style;
    	C.Style		= ERenderStyle.STY_Masked;

    	// Draw the black frame
    	C.SetPos(0,0);

    	for(i=0; i<4; i++)
    	{
    		for(j=0; j<5; j++)
    		{
    			tex = m_arVisonTex[i*5+j];
    			C.SetPos(m_nVisionHSize*j, m_nVisionVSize*i);
    			C.DrawTile(tex, m_nVisionHSize, m_nVisionVSize, 0, 0, 256, 256);
    		}
    	}

    	C.Style=styleOld;

    	// No need to do this every frame, just eye candy
    	m_nTickTracker=0;
    	// Draw the lifeform tracker
    	C.StrLen("Lifeforms In Range:", XL, YL);
    	C.SetPos((C.ClipX-XL)/2,YL);
    	C.Font = m_Fonts.GetSmallFont(C.ClipX);
    	C.DrawColor.R = 20;
    	C.DrawColor.G = 200;
    	C.DrawColor.B = 0;
    	C.DrawText("Lifeforms In Range:");
    	strText	= string(m_nVisibleLifeForms);
    	C.StrLen(strText, XL, YL);
    	C.SetPos((C.ClipX-XL)/2,3*YL);
    	C.DrawText(strText);
    	// Draw the heading tracker
    	strText	= class'SFUtils'.static.FormatFloat(getHeading());
    	C.SetPos((2*XL),C.ClipY/2);
    	C.DrawText(strText);

    	// Draw the level time
    	fTime	= Level.TimeSeconds;
    	// Row 1
    	fTime	= (fTime*Level.TimeSeconds)%1000;
    	strText = string(fTime);
    	strText = Left( strText, Instr(strText, ".")-1);
    	C.StrLen(strText, XL, YL);
    	C.SetPos(C.ClipX-(XL+YL),(C.ClipY/2)-YL);
    	C.DrawText(strText);
    	//  Row2
    	fTime	= (fTime*3*Level.TimeSeconds)%1000;
    	strText = string(fTime);
    	strText = Left( strText, Instr(strText, ".")-1);
    	C.StrLen(strText, XL, YL);
    	C.SetPos(C.ClipX-(XL+YL),(C.ClipY/2));
    	C.DrawText(strText);
    	//  Row3
    	fTime	= (fTime*6*Level.TimeSeconds)%1000;
    	strText = string(fTime);
    	strText = Left( strText, Instr(strText, ".")-1);
    	C.StrLen(strText, XL, YL);
    	C.SetPos(C.ClipX-(XL+YL),(C.ClipY/2)+YL);
    	C.DrawText(strText);
    }

    // Retrieves the angle between the two given vectors in radians
    function float getAngle(vector vecFirst, vector vecSecond)
    {
    	return Normal(vecFirst) dot Normal(vecSecond);
    }

    //
    simulated function drawNightVisionActors(Canvas C)
    {
    	local Texture		oldSkins[9];
    	local vector X,Y,Z;
    	local Actor	A;
    	local float	fDist;
    	local float	fOldGlow;
    	local float fAngle;

    	// Reset counter
    	m_nVisibleLifeForms = 0;

    	// Some inits
    	GetAxes(Pawn(Owner).ViewRotation,X,Y,Z);

    	foreach VisibleActors(class'Actor', A)
    	{
    		if ((A!=None) && isNightVisionObject(A))
    		{
    			// Calculate the distance
    			fDist = VSize(A.Location - Location);

    			//If within range of vision module
    			if (( Owner.Level.Netmode == NM_Standalone) && (fDist <= fVisionRange))
    			{
    				fOldGlow = A.AmbientGlow;
    				SetSkins(A, oldSkins);
    				A.AmbientGlow = 255;
    				C.DrawActor(A, False);
    				A.bHidden=false;
    				A.AmbientGlow =  fOldGlow;
    				ResetSkins(A, oldSkins);

    				// Check, if in front
    				fAngle	= getAngle(X, A.Location-Owner.Location);
    				if(fAngle > 0.7)
    					m_nVisibleLifeForms++;

    			}

    		}
    	}
    }

    simulated function PostRender( canvas Canvas )
    {
    	local PlayerPawn P;
    	local float Scale;

    	// Calculate texture stretching on first run
    	m_nVisionXOffset	= 128*Canvas.ClipX/1280;
    	m_nVisionYOffset	= 128*Canvas.ClipY/1024;
    //	m_nVisionHSize = (Canvas.ClipX-2*m_nVisionXOffset)/4;
    //	m_nVisionVSize = (Canvas.ClipY-2*m_nVisionYOffset)/3;
    	m_bInitialized = true;

    	m_nVisionHSize = (Canvas.ClipX)/5;
    	m_nVisionVSize = (Canvas.ClipY)/4;

    	Super.PostRender(Canvas);
    	P = PlayerPawn(Owner);
    	if ( (P != None) && m_bVisionEnabled )
    	{
    		bOwnsCrossHair = true;
    		Scale = Canvas.ClipX/640;
    		Canvas.SetPos(0.5 * Canvas.ClipX - 128 * Scale, 0.5 * Canvas.ClipY - 128 * Scale );
    		if ( Level.bHighDetailMode )
    			Canvas.Style = ERenderStyle.STY_Translucent;
    		else
    			Canvas.Style = ERenderStyle.STY_Normal;
    		drawNightVisionActors(Canvas);
    		renderVision(Canvas);
    	}
    	else
    		bOwnsCrossHair = false;
    }

    simulated function PlayFiring()
    {
    	local int r;

    	PlaySound(FireSound, SLOT_None, Pawn(Owner).SoundDampening*3.0);
    	if(!IsInState('NightVision'))
    		PlayAnim('Fire1',m_fCurrentRate, 0.05);
    	else
    		PlayAnim('Fire2',m_fCurrentRate, 0.05);
    }

    simulated function PlayIdleAnim()
    {
    	if ( Mesh != PickupViewMesh )
    		LoopAnim(IdleAnims[Rand(2)],0.6, 0.3);

    }

    function AltFire( float Value )
    {
    	GotoState('NightVision');
    }

    // Tracks the energy cell usage
    simulated function Timer()
    {
    	// Use enfergy cells every five seconds
    	if ( AmmoType.UseAmmo(1) )
    	{
    		PlaySound(m_sndEnergyUse, SLOT_None, Pawn(Owner).SoundDampening*3.0);
    		SetTimer(5.0, false);
    	}
    	else
    	{
    		restoreNightVision();
    		Pawn(Owner).StopFiring();
    		Pawn(Owner).SwitchToBestWeapon();
    		if ( bChangeWeapon )
    			GotoState('DownWeapon');
    		//GotoState('');
    	}
    }

    // Set up the vision display
    simulated function	setupNightVision()
    {
    	if(m_bVisionEnabled)
    		return;

    	// Setup the night vision here
    	PlayerPawn(Owner).ClientAdjustGlow(-0.2,vect(0,128,0));
        DrawType=DT_None;
    	m_vecSavedOffset = FireOffset;
    	FireOffset= vect(0.0,0.0,0.0);
    	m_bVisionEnabled=true;
    }

    // restores normal view
    simulated function restoreNightVision()
    {
    	local Actor A;

    	if(!m_bVisionEnabled)
    		return;

    	// Restor normal view
    	PlayerPawn(Owner).ClientAdjustGlow(0.2,vect(0,-128,0));
        DrawType=DT_Mesh;
    //	FireOffset=Default.FireOffset;
    	FireOffset=m_vecSavedOffset ;
    	m_bVisionEnabled=false;
    }

    state Idle
    {

    	function AnimEnd()
    	{
    		PlayIdleAnim();
    	}

    Begin:
    	bPointing=False;
    	if ( AmmoType.AmmoAmount<=0 )
    		Pawn(Owner).SwitchToBestWeapon();  //Goto Weapon that has Ammo
    	if ( Pawn(Owner).bFire!=0 )
    		Fire(0.0);
    	PlayIdleAnim();
    }

    simulated function restorePlayerView()
    {
    	restoreNightVision();
    	SetTimer(0.0, false);
    	GotoState('');
    }

    function ChangedWeapon()
    {
    	if(Pawn(Owner).Weapon != Self)
    		restorePlayerView();
    	// Call to base class
    	Super.ChangedWeapon();
    }

    function DropFrom(vector StartLocation)
    {
    	restorePlayerView();
    	// Call to base class
    	Super.DropFrom(StartLocation);
    }
    ///////////////////////////////////////////////////////
    state NightVision
    {
    ignores Fire, AltFire;

    	simulated function BeginState()
    	{
    		if ( Owner.IsA('PlayerPawn') )
    		{
    			if(!m_bVisionEnabled)
    			{
    				if(AmmoType.UseAmmo(1))	// Cannot change when there is no ammo left
    				{
    					setupNightVision();
    					SetTimer(5.0, false);
    				}
    				GotoState('Idle');
    			}
    			else
    			{
    				restoreNightVision();
    				SetTimer(0.0, false);
    				GotoState('Idle');
    			}

    		}
    		else
    		{
    			Pawn(Owner).bFire = 1;
    			Pawn(Owner).bAltFire = 0;
    			Global.Fire(0);
    		}

    	}

    }

    defaultproperties
    {
         fVisionRange=2000.000000
         m_sndEnergyUse=Sound'Botpack.Translocator.TDisrupt'
         IdleAnims(0)=Still
         IdleAnims(1)=Still2
         m_arVisonTex(0)=Texture'SFWeapon.Skins.ushud1'
         m_arVisonTex(1)=Texture'SFWeapon.Skins.ushud2'
         m_arVisonTex(2)=Texture'SFWeapon.Skins.ushud3'
         m_arVisonTex(3)=Texture'SFWeapon.Skins.ushud4'
         m_arVisonTex(4)=Texture'SFWeapon.Skins.ushud5'
         m_arVisonTex(5)=Texture'SFWeapon.Skins.ushud6'
         m_arVisonTex(6)=Texture'SFWeapon.Skins.ushud7'
         m_arVisonTex(7)=Texture'SFWeapon.Skins.ushud8'
         m_arVisonTex(8)=Texture'SFWeapon.Skins.ushud9'
         m_arVisonTex(9)=Texture'SFWeapon.Skins.ushud10'
         m_arVisonTex(10)=Texture'SFWeapon.Skins.ushud11'
         m_arVisonTex(11)=Texture'SFWeapon.Skins.ushud12'
         m_arVisonTex(12)=Texture'SFWeapon.Skins.ushud13'
         m_arVisonTex(13)=Texture'SFWeapon.Skins.ushud14'
         m_arVisonTex(14)=Texture'SFWeapon.Skins.ushud15'
         m_arVisonTex(15)=Texture'SFWeapon.Skins.ushud16'
         m_arVisonTex(16)=Texture'SFWeapon.Skins.ushud17'
         m_arVisonTex(17)=Texture'SFWeapon.Skins.ushud18'
         m_arVisonTex(18)=Texture'SFWeapon.Skins.ushud19'
         m_arVisonTex(19)=Texture'SFWeapon.Skins.ushud20'
         MaxTargetRange=6000
         MaxTargetRangeAlt=6000
         fNormalRate=0.333300
         fDesiredRate=0.250000
         fDamage=45.000000
         AmmoPerShot=4
         Icon=Texture'SfResource1.Icons.usrifleico'
         bInstantHit=True
         bCanUpgradeLaserSight=True
         bCanUpgradeEnergyBooster=True
         LaserSightUpgradeMessage="Upgraded Ultra Sonic Rifle with Laser Sight"
         bShake=True
         m_fTrailEffectIntervallSize=91.000000
         m_clsHitWallEffect=Class'Botpack.UT_LightWallHitEffect'
         m_clsTrailEffect=Class'SFWeapon.SFShockBeam'
         WeaponDescription="Classification: Ultra Sonic Rifle:\nThe weapon of choice for night time operations, this rifle emits a highly focused sonic wave.\nIt also incorporates a night vision enhancement that interfaces a sonic imaging system with a HUD visor."
         InstFlash=-0.300000
         InstFog=(X=400.000000,Y=200.000000)
         AmmoName=Class'SFWeapon.SFUSAmmo'
         PickupAmmoCount=20
         FireOffset=(X=15.000000,Y=-9.000000,Z=-12.000000)
         shakemag=250.000000
         shaketime=0.200000
         RefireRate=1.000000
         AltRefireRate=0.830000
         FireSound=Sound'SPF-Content.Weapons.USFire'
         SelectSound=Sound'SPF-Content.Weapons.USSelect'
         bDrawMuzzleFlash=True
         AutoSwitchPriority=7
         InventoryGroup=7
         PickupMessage="You got the Ultra Sonic Rifle."
         ItemName="Ultra Sonic Rifle"
         PlayerViewOffset=(X=3.000000,Y=-1.600000,Z=-1.700000)
         PlayerViewMesh=LodMesh'SFWeapon.SFUSRiflem'
         PlayerViewScale=0.380000
         PickupViewMesh=LodMesh'SFWeapon.SFUSRiflehand'
         ThirdPersonMesh=LodMesh'SFWeapon.SFUSRiflepick'
         PickupSound=Sound'SPF-Content.Weapons.USPickup'
         Mesh=LodMesh'SFWeapon.SFUSRiflehand'
         bNoSmooth=False
         CollisionRadius=33.000000
         CollisionHeight=7.000000
         Mass=50.000000
    }

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