Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- //=============================================================================
- // ceskiHUDIronSights.
- //=============================================================================
- //
- //fake iron sights for WeaponSMG5
- //slightly modified by FGR with permission from Ceski
- //
- class ceskiHUDIronSights extends DeusExScopeView;
- var float gunlagX, gunlagY;
- var float lastEye, curEye;
- var vector lastLoc, curLoc;
- var rotator lastRot, curRot;
- var vector lastVel, curVel;
- var float lastJump;
- function PlaySwish(int swishNum)
- {
- local Sound swishSound;
- if (swishNum == 1)
- swishSound = Sound'RifleSelect';
- else
- swishSound = Sound'RifleSelect';
- Player.PlaySound(swishSound, SLOT_None);
- }
- function ActivateView(int newFOV, bool bNewBinocs, bool bInstant)
- {
- desiredFOV = Player.DefaultFOV - newFOV;
- if (Player != None)
- {
- curEye = Player.EyeHeight;
- lastEye = Player.EyeHeight;
- curLoc = Player.Location;
- lastLoc = Player.Location;
- curRot = Player.ViewRotation;
- lastRot = Player.ViewRotation;
- curVel = Player.Velocity;
- lastVel = Player.Velocity;
- lastJump = 0;
- PlaySwish(1);
- Player.bob = 0.008;
- Player.desiredFOV = desiredFOV;
- bViewVisible = True;
- Show();
- }
- }
- function ShowView()
- {
- if (bViewVisible)
- {
- curEye = Player.EyeHeight;
- lastEye = Player.EyeHeight;
- curLoc = Player.Location;
- lastLoc = Player.Location;
- curRot = Player.ViewRotation;
- lastRot = Player.ViewRotation;
- curVel = Player.Velocity;
- lastVel = Player.Velocity;
- lastJump = 0;
- PlaySwish(1);
- Player.bob = 0.008;
- Player.SetFOVAngle(desiredFOV);
- Show();
- }
- }
- function DeactivateView()
- {
- if (Player != None)
- {
- PlaySwish(2);
- Player.bob = Player.Default.bob;
- Player.DesiredFOV = Player.Default.DefaultFOV;
- bViewVisible = False;
- Hide();
- }
- }
- function HideView()
- {
- if (bViewVisible)
- {
- Hide();
- PlaySwish(2);
- Player.bob = Player.Default.bob;
- Player.SetFOVAngle(Player.Default.DefaultFOV);
- }
- }
- event DrawWindow(GC gc)
- {
- local float sightX, sightY, sightWidth, sightHeight;
- local int toffset;
- local float gunTest;
- local float tempLag1,tempLag2;
- local rotator tempRot1,tempRot2;
- local float diffEye;
- local vector diffLoc;
- local rotator diffRot;
- local vector diffVel;
- local float centerDist;
- Super(window).DrawWindow(gc);
- if (GetRootWindow().parentPawn != None)
- {
- if (Player.IsInState('Dying'))
- return;
- }
- //--------------------------------------------
- //gun lag stuff
- //--------------------------------------------
- //update variables
- curEye = Player.EyeHeight;
- curLoc = Player.Location;
- curRot = Player.ViewRotation;
- curVel = Player.Velocity;
- //update differences
- diffEye = curEye - lastEye;
- if (Abs(diffEye) > 8.0 || Abs(diffEye) < 0.01)
- diffEye = 0;
- diffLoc = curLoc - lastLoc;
- tempRot1 = curRot;
- tempRot2 = lastRot;
- if (tempRot1.Pitch >= 32768)
- tempRot1.Pitch = tempRot1.Pitch - 65536;
- if (tempRot2.Pitch >= 32768)
- tempRot2.Pitch = tempRot2.Pitch - 65536;
- diffRot = tempRot1 - tempRot2;
- if (diffRot.Yaw >= 32768)
- diffRot.Yaw = diffRot.Yaw - 65536;
- else if (diffRot.Yaw <= -32768)
- diffRot.Yaw = diffRot.Yaw + 65536;
- diffVel = curVel - lastVel;
- if (Abs(diffVel.X) < 0.1)
- diffVel.X = 0;
- if (Abs(diffVel.Y) < 0.1)
- diffVel.Y = 0;
- if (Abs(diffVel.Z) < 0.1)
- diffVel.Z = 0;
- //return to center lag
- if (abs(gunlagX) > 0)
- gunlagX = gunlagX * 0.5;
- if (abs(gunlagX) < 0.1)
- gunlagX = 0;
- if (abs(gunlagY) > 0)
- gunlagY = gunlagY * 0.5;
- if (abs(gunlagY) < 0.1)
- gunlagY = 0;
- //jump lag
- if ((lastJump == 1) && (Player.Physics == PHYS_Falling))
- {
- gunlagY += 16;
- lastJump = 0;
- }
- if ((lastVel.Z == 0) && (curVel.Z > 0) && (Player.Physics == PHYS_Falling))
- {
- gunlagY += 6;
- lastJump = 1;
- }
- //land lag
- if ((lastJump <= -Player.JumpZ) && (Player.Physics == PHYS_Walking))
- {
- gunlagY += 16;
- lastJump = 0;
- }
- if ((lastVel.Z <= -Player.JumpZ) && (Player.Physics == PHYS_Walking))
- {
- gunlagY += 6;
- lastJump = lastVel.Z;
- }
- //look lag
- if (diffRot != rot(0,0,0))
- {
- tempLag1 = -FClamp(diffRot.Yaw,-3000,3000)/3000*32;
- tempLag2 = FClamp(diffRot.Pitch,-3000,3000)/3000*32;
- if (abs(tempLag1) > 1)
- gunlagX += tempLag1;
- if (abs(tempLag2) > 1)
- gunlagY += tempLag2;
- }
- //crouch lag
- if (diffEye != 0)
- gunlagY += FClamp(diffEye,-10,10)/10*8;
- //movement lag
- if (diffVel != vect(0,0,0))
- {
- //forward and back
- gunTest = normal(vector(lastRot)) dot (diffLoc*vect(1,1,0));
- if (gunTest > 0.01)
- gunlagY += FClamp((vsize(curVel)-vsize(lastVel)),-1.6,1.6)/1.6*2;
- if (gunTest < -0.01)
- gunlagY -= FClamp((vsize(curVel)-vsize(lastVel)),-1.6,1.6)/1.6*2;
- //left and right
- gunTest = normal(vector(lastRot+rot(0,-16384,0))) dot (diffLoc*vect(1,1,0));
- if (gunTest > 0.01)
- gunlagX += FClamp((vsize(curVel)-vsize(lastVel)),-1.6,1.6)/1.6*2;
- if (gunTest < -0.01)
- gunlagX -= FClamp((vsize(curVel)-vsize(lastVel)),-1.6,1.6)/1.6*2;
- }
- //update variables
- lastEye = Player.EyeHeight;
- lastLoc = Player.Location;
- lastRot = Player.ViewRotation;
- lastVel = Player.Velocity;
- //move in sync with Player bob
- if (abs(Player.WalkBob.X) > 0)
- gunlagX += Player.WalkBob.X*4;
- if (abs(Player.WalkBob.Z) > 0)
- gunlagY += Player.WalkBob.Z*4;
- //make sure we stay in reticle
- gunlagX = FClamp(gunlagX,-32,32);
- gunlagY = FClamp(gunlagY,-32,32);
- //--------------------------------------------
- //draw ironsights
- //--------------------------------------------
- sightWidth = 256;
- sightHeight = 256;
- sightX = (width-sightWidth)*0.5;
- sightY = (height-sightHeight)*0.5;
- //timing for shooting animation
- toffset = 26.0 * (Player.Level.TimeSeconds % 0.2);
- //some day...
- //if (WeaponPistolY(Player.inHand) != None)
- //{
- //}
- if (WeaponSMG5(Player.inHand) != None)
- {
- //draw that annoying vignetting crap that every single game has these days
- gc.SetStyle(DSTY_Modulated);
- gc.DrawPattern(0, 0, width, 128, 4, 128, Texture'HUDGradient1');
- gc.DrawPattern(0, height-128, width, 128, 4, 128, Texture'HUDGradient2');
- gc.DrawPattern(0, 0, 64, height, 64, 4, Texture'HUDGradient3');
- gc.DrawPattern(width-64, 0, 64, height, 64, 4, Texture'HUDGradient4');
- //if we're shooting, cycle through muzzleflashes and both ironsight sizes
- if (WeaponSMG5(Player.inHand).bFiring && WeaponSMG5(Player.inHand).IsAnimating() && (WeaponSMG5(Player.inHand).AnimSequence == 'Shoot'))
- {
- if (toffset == 0)
- {
- gc.SetStyle(DSTY_Modulated);
- gc.DrawTexture(sightX+gunlagX, sightY+gunlagY-24, sightWidth, sightHeight, 0, 0, Texture'HUDIronSights1b');
- gc.DrawTexture(sightX+gunlagX, sightY+256+gunlagY-24, sightWidth, sightHeight, 0, 0, Texture'HUDIronSights2b');
- gc.DrawPattern(sightX+gunlagX, sightY+512+gunlagY-24, sightWidth, sightY, 0, 0, Texture'HUDIronSights3b');
- gc.DrawPattern(sightX+gunlagX, height-64, sightWidth, sightY, 0, 0, Texture'HUDIronSights4b');
- gc.SetStyle(DSTY_Translucent);
- gc.DrawTexture(sightX+gunlagX, sightY+72+gunlagY-24, 256, 256, 0, 0, Texture'HUDMuzzleFlash1');
- }
- else if (toffset == 1)
- {
- gc.SetStyle(DSTY_Modulated);
- gc.DrawTexture(sightX+gunlagX, sightY+gunlagY-16, sightWidth, sightHeight, 0, 0, Texture'HUDIronSights1b');
- gc.DrawTexture(sightX+gunlagX, sightY+256+gunlagY-16, sightWidth, sightHeight, 0, 0, Texture'HUDIronSights2b');
- gc.DrawPattern(sightX+gunlagX, sightY+512+gunlagY-16, sightWidth, sightY, 0, 0, Texture'HUDIronSights3b');
- gc.DrawPattern(sightX+gunlagX, height-64, sightWidth, sightY, 0, 0, Texture'HUDIronSights4b');
- gc.SetStyle(DSTY_Translucent);
- gc.DrawTexture(sightX+gunlagX, sightY+72+gunlagY-16, 256, 256, 0, 0, Texture'HUDMuzzleFlash2');
- }
- else if (toffset == 3)
- {
- gc.SetStyle(DSTY_Modulated);
- gc.DrawTexture(sightX+gunlagX, sightY+gunlagY-24, sightWidth, sightHeight, 0, 0, Texture'HUDIronSights1b');
- gc.DrawTexture(sightX+gunlagX, sightY+256+gunlagY-24, sightWidth, sightHeight, 0, 0, Texture'HUDIronSights2b');
- gc.DrawPattern(sightX+gunlagX, sightY+512+gunlagY-24, sightWidth, sightY, 0, 0, Texture'HUDIronSights3b');
- gc.DrawPattern(sightX+gunlagX, height-64, sightWidth, sightY, 0, 0, Texture'HUDIronSights4b');
- gc.SetStyle(DSTY_Translucent);
- gc.DrawTexture(sightX+gunlagX, sightY+72+gunlagY-24, 256, 256, 0, 0, Texture'HUDMuzzleFlash3');
- }
- else if (toffset == 4)
- {
- gc.SetStyle(DSTY_Modulated);
- gc.DrawTexture(sightX+gunlagX, sightY+gunlagY-16, sightWidth, sightHeight, 0, 0, Texture'HUDIronSights1b');
- gc.DrawTexture(sightX+gunlagX, sightY+256+gunlagY-16, sightWidth, sightHeight, 0, 0, Texture'HUDIronSights2b');
- gc.DrawPattern(sightX+gunlagX, sightY+512+gunlagY-16, sightWidth, sightY, 0, 0, Texture'HUDIronSights3b');
- gc.DrawPattern(sightX+gunlagX, height-64, sightWidth, sightY, 0, 0, Texture'HUDIronSights4b');
- gc.SetStyle(DSTY_Translucent);
- gc.DrawTexture(sightX+gunlagX, sightY+72+gunlagY-16, 256, 256, 0, 0, Texture'HUDMuzzleFlash4');
- }
- else
- {
- gc.SetStyle(DSTY_Modulated);
- gc.DrawTexture(sightX+gunlagX, sightY+gunlagY-8, sightWidth, sightHeight, 0, 0, Texture'HUDIronSights1a');
- gc.DrawTexture(sightX+gunlagX, sightY+256+gunlagY-8, sightWidth, sightHeight, 0, 0, Texture'HUDIronSights2a');
- gc.DrawPattern(sightX+gunlagX, sightY+512+gunlagY-8, sightWidth, sightY, 0, 0, Texture'HUDIronSights3a');
- gc.DrawPattern(sightX+gunlagX, height-64, sightWidth, sightY, 0, 0, Texture'HUDIronSights4a');
- }
- }
- else
- {
- //if we're crouching, use the large ironsights
- if (Player.bForceDuck || Player.bIsCrouching)
- {
- gc.SetStyle(DSTY_Modulated);
- gc.DrawTexture(sightX+gunlagX, sightY+gunlagY-22, sightWidth, sightHeight, 0, 0, Texture'HUDIronSights1b');
- gc.DrawTexture(sightX+gunlagX, sightY+256+gunlagY-22, sightWidth, sightHeight, 0, 0, Texture'HUDIronSights2b');
- gc.DrawPattern(sightX+gunlagX, sightY+512+gunlagY-22, sightWidth, sightY, 0, 0, Texture'HUDIronSights3b');
- gc.DrawPattern(sightX+gunlagX, height-64, sightWidth, sightY, 0, 0, Texture'HUDIronSights4b');
- }
- //use the basic ironsights
- else
- {
- gc.SetStyle(DSTY_Modulated);
- gc.DrawTexture(sightX+gunlagX, sightY+gunlagY, sightWidth, sightHeight, 0, 0, Texture'HUDIronSights1a');
- gc.DrawTexture(sightX+gunlagX, sightY+256+gunlagY, sightWidth, sightHeight, 0, 0, Texture'HUDIronSights2a');
- gc.DrawPattern(sightX+gunlagX, sightY+512+gunlagY, sightWidth, sightY, 0, 0, Texture'HUDIronSights3a');
- gc.DrawPattern(sightX+gunlagX, height-64, sightWidth, sightY, 0, 0, Texture'HUDIronSights4a');
- }
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement