Announcement

Collapse
No announcement yet.

How to make sniper zoom in my new weapon?

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

    How to make sniper zoom in my new weapon?

    I have read the scripts of ligtning gun alt fire , but i don't quite understand...

    can anybody teach me? i am a newbie = =|||

    #2
    Just setting your weapons secondary fire to be the sniper zoom would do the trick.
    In 'defaultproperties', just add
    FireModeClass(1)=Class'XWeapons.SniperZoom'

    Comment


      #3
      don't know why , after i change to XWeapons.SniperZoom , the AltFire is totally disabled in game. Why ?

      Comment


        #4
        there should some functions associated with SniperZoom , but I can't distinguish which is , and which is not ?

        Comment


          #5
          anyone, please help ~!

          Comment


            #6
            when the firemodeclass(1) is set to sniper zoom, the firemode class(0) will still work. the second firemode is just a zoom effect for the firemodeclass(0) if you will.

            Comment


              #7
              not sure, but the classic sniper might be easier to understand

              Comment


                #8
                The alt-FireMode class is a red herring. It's just there because weapons need two firing modes. The zooming is done in the weapon class.

                It calls various PlayerController functions, such as ToggleZoom() (Switches between zoomed in and normal), StopZoom() (freezes zooming at the current zoom level) and EndZoom() (returns FOV to normal).

                There are also a few extra bits, such as drawing the scope textures, and changing the colour depending on fog.

                Comment


                  #9
                  yeah , done ~ after i copied all function of the lightning gun functions...

                  BTW, can i make a classic look of zoom , like the green circle and the number showing the zoom level ?

                  Comment


                    #10
                    BTW , can i change to the classic look of zoom , like the green circle and the number showing the zoom level (i don't like the lightning gun zoom) ?

                    Comment


                      #11
                      Well, if you copied the Sniper Rifle functions instead of the Lightning Gun functions, you'd think you'd get the Sniper Rifle zoom instead...

                      Comment


                        #12
                        but the XWeapons.SniperRifle is Lightning Gun...
                        Where is the Classic SniperRifle ??? I can't find it ...

                        Comment


                          #13
                          UTClassic.ClassicSniperRifel

                          I think this is what your going to be looking for:

                          Code:
                          simulated event RenderOverlays( Canvas Canvas )
                          {
                          	local float CX,CY,Scale;
                          	local float chargeBar;
                          	local float barOrgX, barOrgY;
                          	local float barSizeX, 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);
                          		}
                          
                          		CX = Canvas.ClipX/2;
                          		CY = Canvas.ClipY/2;
                          		Scale = Canvas.ClipX/1024;
                          
                          		Canvas.Style = ERenderStyle.STY_Alpha;
                          		Canvas.SetDrawColor(0,0,0);
                          
                          		// Draw the crosshair
                          		Canvas.SetPos(CX-169*Scale,CY-155*Scale);
                          		Canvas.DrawTile(texture'NewSniperRifle.COGAssaultZoomedCrosshair',169*Scale,310*Scale, 164,35, 169,310);
                          		Canvas.SetPos(CX,CY-155*Scale);
                          		Canvas.DrawTile(texture'NewSniperRifle.COGAssaultZoomedCrosshair',169*Scale,310*Scale, 332,345, -169,-310);
                          
                          		// Draw Cornerbars
                          		Canvas.SetPos(160*Scale,160*Scale);
                          		Canvas.DrawTile(texture'NewSniperRifle.COGAssaultZoomedCrosshair', 111*Scale, 111*Scale , 0 , 0, 111, 111);
                          
                          		Canvas.SetPos(Canvas.ClipX-271*Scale,160*Scale);
                          		Canvas.DrawTile(texture'NewSniperRifle.COGAssaultZoomedCrosshair', 111*Scale, 111*Scale , 111 , 0, -111, 111);
                          
                          		Canvas.SetPos(160*Scale,Canvas.ClipY-271*Scale);
                          		Canvas.DrawTile(texture'NewSniperRifle.COGAssaultZoomedCrosshair', 111*Scale, 111*Scale, 0 , 111, 111, -111);
                          
                          		Canvas.SetPos(Canvas.ClipX-271*Scale,Canvas.ClipY-271*Scale);
                          		Canvas.DrawTile(texture'NewSniperRifle.COGAssaultZoomedCrosshair', 111*Scale, 111*Scale , 111 , 111, -111, -111);
                          
                          
                          		// Draw the 4 corners
                          		Canvas.SetPos(0,0);
                          		Canvas.DrawTile(texture'NewSniperRifle.COGAssaultZoomedCrosshair',160*Scale,160*Scale, 0, 274, 159, -158);
                          
                          		Canvas.SetPos(Canvas.ClipX-160*Scale,0);
                          		Canvas.DrawTile(texture'NewSniperRifle.COGAssaultZoomedCrosshair',160*Scale,160*Scale, 159,274, -159, -158);
                          
                          		Canvas.SetPos(0,Canvas.ClipY-160*Scale);
                          		Canvas.DrawTile(texture'NewSniperRifle.COGAssaultZoomedCrosshair',160*Scale,160*Scale, 0,116, 159, 158);
                          
                          		Canvas.SetPos(Canvas.ClipX-160*Scale,Canvas.ClipY-160*Scale);
                          		Canvas.DrawTile(texture'NewSniperRifle.COGAssaultZoomedCrosshair',160*Scale,160*Scale, 159, 116, -159, 158);
                          
                          		// Draw the Horz Borders
                          		Canvas.SetPos(160*Scale,0);
                          		Canvas.DrawTile(texture'NewSniperRifle.COGAssaultZoomedCrosshair', Canvas.ClipX-320*Scale, 160*Scale, 284, 512, 32, -160);
                          
                          		Canvas.SetPos(160*Scale,Canvas.ClipY-160*Scale);
                          		Canvas.DrawTile(texture'NewSniperRifle.COGAssaultZoomedCrosshair', Canvas.ClipX-320*Scale, 160*Scale, 284, 352, 32, 160);
                          
                          		// Draw the Vert Borders
                          		Canvas.SetPos(0,160*Scale);
                          		Canvas.DrawTile(texture'NewSniperRifle.COGAssaultZoomedCrosshair', 160*Scale, Canvas.ClipY-320*Scale, 0,308, 160,32);
                          
                          		Canvas.SetPos(Canvas.ClipX-160*Scale,160*Scale);
                          		Canvas.DrawTile(texture'NewSniperRifle.COGAssaultZoomedCrosshair', 160*Scale, Canvas.ClipY-320*Scale, 160,308, -160,32);
                          
                          		// Draw the Charging meter
                          		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;
                          	}
                          }
                          Im pretty new at this as well, but I recently took this and replaced the super shock rifel zoom with it. Although I modified it to only draw the crosshair, it worked perfectly.

                          Comment


                            #14
                            thanks ~ i have finished my weapon!

                            Comment

                            Working...
                            X