Scopes?

  • 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.

Cookie

Project Leader - Unreal Badlands
Dec 3, 2001
25
0
0
The Corral
www.unrealbadlands.com
Different Way

We did it a little differently than UT's Sniper Rifle. For AltFire we set up a switch case that changed the player's FOV everytime he hits AltFire. Granted this isn't as cool as the Sniper Rifle's zoom function. But it makes more sense for scopes with a single focal point.
 

Dexter13

The Coding Machine
Dec 18, 2001
111
0
0
Visit site
i was wondering

Sorry to be naive, I know what cases and switches are, but how do you make it change the FOV? is it sort of:

PlayerPawn(Owner).FOV==FOV*2? (for example)

I know that's probably wrong, and I'm not sure where to define the FOV, or how to apply a scope canvas.
 

Papapishu

我是康
Jun 18, 2001
2,043
0
0
43
void
www.vovoid.com
this is the zoom state from sniperrifle that is called when the user presses altfire...

Code:
state Zooming
{
	simulated function Tick(float DeltaTime)
	{
		if ( Pawn(Owner).bAltFire == 0 )
		{
			if ( (PlayerPawn(Owner) != None) && PlayerPawn(Owner).Player.IsA('ViewPort') )
				PlayerPawn(Owner).StopZoom();
			SetTimer(0.0,False);
			GoToState('Idle');
		}
	}

	simulated function BeginState()
	{
		if ( Owner.IsA('PlayerPawn') )
		{
			if ( PlayerPawn(Owner).Player.IsA('ViewPort') )
				PlayerPawn(Owner).ToggleZoom();
			SetTimer(0.2,True);
		}
		else
		{
			Pawn(Owner).bFire = 1;
			Pawn(Owner).bAltFire = 0;
			Global.Fire(0);
		}
	}
}

As you can see, it uses the function togglezoom that can be found in the pawn class...
That function checks wheter the fov is the default value or not and if it's not it ends the zoom, else it zooms...
The endzoom and startzoom and stopzoom sets the bZooming value to true or false which makes the UpdateEyeHeight function alter the zoom.
If you check the end of UpdateEyeHeight you'll find the piece that takes care of the zooming effect.
In EndZoom you'll also find a resetter that resets the DesiredFOV(the one when zoomed in) to the DefaultFOV (the one you've set as default)
Hope this helps... :)
 

Cookie

Project Leader - Unreal Badlands
Dec 3, 2001
25
0
0
The Corral
www.unrealbadlands.com
Almost

Here's a real basic way to change the FOV between two values

Var() Enum EMode {M_NormalZoom,M_CloseZoom} Mode;

function altfire()
{
ChooseZoom()
}

function ChooseZoom()
{

switch (Mode)
{
case M_NormalZoom:
Mode= M_NormalZoom;
PlayerPawn.Console Command("FOV 90");
break;

case M_CloseZoom:
Mode= M_FlameThrower;
PlayerPawn.ConsoleCommand("FOV 45");
break;
}

This "should" work, I was doing it off the top of my head. If you want different levels of zooming, simply add more cases to the function. Also remember to add a check for DefaultFOV whenever you switch weapons, because FOV is referenced from the PlayerPawn, not the weapon.
 

2COOL4-U

New Member
Mar 17, 2001
505
0
0
37
dot NL
2cool.free.fr
Re: Almost

Code:
Var() Enum EMode {M_NormalZoom,M_CloseZoom} Mode; 

function altfire()
{
      ChooseZoom()
}
  
function ChooseZoom()
{ 

      switch (Mode) 
      { 
             case M_NormalZoom: 
             Mode= M_NormalZoom; 
             PlayerPawn.Console Command("FOV 90"); 
             break; 

             case M_CloseZoom: 
             Mode= M_FlameThrower; 
             PlayerPawn.ConsoleCommand("FOV 45"); 
             break; 
}
M_FlameThrower isn't in the Enum. And I think it's better to do a PlayerPawn.FOV(45). And also if the weapon has its mode set to M_NormalZoom how will it ever get a different mode?
 

Cookie

Project Leader - Unreal Badlands
Dec 3, 2001
25
0
0
The Corral
www.unrealbadlands.com
Duh

Like I said it was off the top of my head, but he's right. M_Flamethrower is the wrong enum, I was thinking of another switch I had done. Sorry. FOV 90 is still needed though, but it should be the last case, not the first. Also ther shouldn't be a space in "ConsoleCommand" in the first case. And I'm sure there's several other mistakes... but the basic idea is right.
 

Wormbo

Administrator
Staff member
Jun 4, 2001
5,913
36
48
Germany
www.koehler-homepage.de
Maybe you want to try Zoom Stops like in Chaos UT:
Code:
simulated function bool ClientAltFire( float Value )
{
	ZoomNext();
	GotoState('Idle');
	return true;
}

function AltFire( float Value )
{
	ClientAltFire(Value);
}

simulated function ZoomNext()
{
	if ( Owner.IsA('PlayerPawn') && Level.Netmode != NM_DedicatedServer ) {
		if ( PlayerPawn(Owner).Player.IsA('ViewPort') ) {
			switch ZoomStop {
			case 0 : PlayerPawn(Owner).DesiredFOV=30.0;
				 PlayerPawn(Owner).FOVAngle = PlayerPawn(Owner).DesiredFOV; 
				 break;
			case 1 : PlayerPawn(Owner).DesiredFOV=15.0;
				 PlayerPawn(Owner).FOVAngle = PlayerPawn(Owner).DesiredFOV;
				 FireOffset=vect(0.0,0.0,0.0);
				 break;
			case 2 : PlayerPawn(Owner).DesiredFOV=10.0;
				 PlayerPawn(Owner).FOVAngle = PlayerPawn(Owner).DesiredFOV;
				 FireOffset=vect(0.0,0.0,0.0);
				 break;
			case 3 : PlayerPawn(Owner).DesiredFOV = PlayerPawn(Owner).DefaultFOV;
				 PlayerPawn(Owner).FOVAngle = PlayerPawn(Owner).DesiredFOV;
				 break;
			}
		}
	}
	ZoomStop+=1;
}
This toggles between normal view and zoom x3, x6 and x9.