1. This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.
  2. Two Factor Authentication is now available on BeyondUnreal Forums. To configure it, visit your Profile and look for the "Two Step Verification" option on the left side. We can send codes via email (may be slower) or you can set up any TOTP Authenticator app on your phone (Authy, Google Authenticator, etc) to deliver codes. It is highly recommended that you configure this to keep your account safe.

[2K4] Weapon Help

Discussion in 'Ask a Coder' started by DeathOmen, Feb 20, 2005.

  1. DeathOmen

    DeathOmen New Member

    Joined:
    Oct 5, 2003
    Messages:
    14
    Likes Received:
    0
    *Edited* found out how to
    but i still need to know how to add a custom zoom :D
     
    Last edited by a moderator: Feb 20, 2005
  2. SamMaster

    SamMaster Master of the Super Weapons

    Joined:
    Apr 13, 2000
    Messages:
    417
    Likes Received:
    0
    Ah zooms... one of the great mysteries for me in the UScript. I know how to change the zoom hud and that's it.
     
  3. Postal

    Postal I apear to have lost my pin.

    Joined:
    Nov 14, 1999
    Messages:
    1,388
    Likes Received:
    0
    You can force a fov, but you have to remember to change it back when you switch weaps, drop weap, etc
     
  4. Smoke39

    Smoke39 whatever

    Joined:
    Jun 2, 2001
    Messages:
    1,793
    Likes Received:
    0
    Or leave it when you switch weapons, if you made a weapon that's, like, a pair of binoculars that, like... stick to your face... o.o
     
  5. DeathOmen

    DeathOmen New Member

    Joined:
    Oct 5, 2003
    Messages:
    14
    Likes Received:
    0
    nonono i have a custom texture i want to make it show up when it zooms :D
     
  6. Smoke39

    Smoke39 whatever

    Joined:
    Jun 2, 2001
    Messages:
    1,793
    Likes Received:
    0
    Look at RenderOverlays in the sniper rifle.
     
  7. DeathOmen

    DeathOmen New Member

    Joined:
    Oct 5, 2003
    Messages:
    14
    Likes Received:
    0
    been tryin cant seem to find anything :-\ o well ill keep tryin
     
  8. Wulff

    Wulff Bola Gun fun anyone?

    Joined:
    May 25, 2004
    Messages:
    613
    Likes Received:
    0

    Code:
    simulated event RenderOverlays( Canvas Canvas )
    {
    	local float tileScaleX;
    	local float tileScaleY;
    	local float bX;
    	local float bY;
    	local float fX;
    	local float fY;
    	local float ChargeBar;
    
    	local float tX;
    	local float tY;
    
    	local float barOrgX;
    	local float barOrgY;
    	local float barSizeX;
    	local float barSizeY;
    
    	if ( PlayerController(Instigator.Controller) == None )
    	{
            Super.RenderOverlays(Canvas);
    		zoomed=false;
    		return;
    	}
    
        if ( LastFOV > PlayerController(Instigator.Controller).DesiredFOV )
        {
            PlaySound(Sound'WeaponSounds.LightningGun.LightningZoomIn', SLOT_Misc,,,,,false);
        }
        else if ( LastFOV < PlayerController(Instigator.Controller).DesiredFOV )
        {
            PlaySound(Sound'WeaponSounds.LightningGun.LightningZoomOut', SLOT_Misc,,,,,false);
        }
        LastFOV = PlayerController(Instigator.Controller).DesiredFOV;
    
        if ( PlayerController(Instigator.Controller).DesiredFOV == PlayerController(Instigator.Controller).DefaultFOV )
    	{
            Super.RenderOverlays(Canvas);
    		zoomed=false;
    	}
    	else
        {
    		if ( FireMode[0].NextFireTime <= Level.TimeSeconds )
    		{
    			ChargeBar = 1.0;
    		}
    		else
    		{
    			ChargeBar = 1.0 - ((FireMode[0].NextFireTime-Level.TimeSeconds) / FireMode[0].FireRate);
    		}
    
    		tileScaleX = Canvas.SizeX / 640.0f;
    		tileScaleY = Canvas.SizeY / 480.0f;
    
    		bX = borderX * tileScaleX;
    		bY = borderY * tileScaleY;
    		fX = 2*focusX * tileScaleX;
    		fY = 2*focusY * tileScaleX;
    
    		tX = testX * tileScaleX;
    		tY = testY * tileScaleX;
    
    		barOrgX = RechargeOrigin.X * tileScaleX;
    		barOrgY = RechargeOrigin.Y * tileScaleY;
    
    		barSizeX = RechargeSize.X * tileScaleX;
    		barSizeY = RechargeSize.Y * tileScaleY;
    
            SetZoomBlendColor(Canvas);
    
            Canvas.Style = 255;
    		Canvas.SetPos(0,0);
            Canvas.DrawTile( Material'ZoomFB', Canvas.SizeX, Canvas.SizeY, 128, 128, 256, 256 ); // !! hardcoded size
    
    		Canvas.DrawColor = FocusColor;
            Canvas.DrawColor.A = 255; // 255 was the original -asp. WTF??!?!?!
    		Canvas.Style = ERenderStyle.STY_Alpha;
    
    		Canvas.SetPos((Canvas.SizeX*0.5)-fX,(Canvas.SizeY*0.5)-fY);
    		Canvas.DrawTile( Texture'SniperFocus', fX*2.0, fY*2.0, 0.0, 0.0, Texture'SniperFocus'.USize, Texture'SniperFocus'.VSize );
    
            fX = innerArrowsX * tileScaleX;
    		fY = innerArrowsY * tileScaleY;
    
            Canvas.DrawColor = ArrowColor;
    		Canvas.SetPos((Canvas.SizeX*0.5)-fX,(Canvas.SizeY*0.5)-fY);
    		Canvas.DrawTile( Texture'SniperArrows', fX*2.0, fY*2.0, 0.0, 0.0, Texture'SniperArrows'.USize, Texture'SniperArrows'.VSize );
    
    		// Draw the Charging meter  -AsP
    		Canvas.DrawColor = ChargeColor;
            Canvas.DrawColor.A = 255;
    
    		if(ChargeBar <1)
    		    Canvas.DrawColor.R = 255*ChargeBar;
    		else
            {
                Canvas.DrawColor.R = 0;
    		    Canvas.DrawColor.B = 0;
            }
    
    		if(ChargeBar == 1)
    		    Canvas.DrawColor.G = 255;
    		else
    		    Canvas.DrawColor.G = 0;
    
    		Canvas.Style = ERenderStyle.STY_Alpha;
    		Canvas.SetPos( barOrgX, barOrgY );
    		Canvas.DrawTile(Texture'Engine.WhiteTexture',barSizeX,barSizeY*ChargeBar, 0.0, 0.0,Texture'Engine.WhiteTexture'.USize,Texture'Engine.WhiteTexture'.VSize*ChargeBar);
    		zoomed = true;
    	}
    }
    I do believe that this is the code snippit you're suppose to be looking for inside the weapon coding*, just fiddle around with it to get your zoomtexture to show up properly.

    *Yeah, Smoke said it first, but to its more clear to post it.:)
     

Share This Page