UE2:Weapon (UT2004)

From Unreal Wiki, The Unreal Engine Documentation Site
Jump to navigation Jump to search
UT2004 Object >> Actor >> Inventory >> Weapon
Package: 
Engine

Abstract base class for all kinds of weapons.

Constants

NUM_FIRE_MODES

Value: 2

Array size for various fire mode variables.

Properties

See Weapon properties.

Enums

EWeaponClientState

WS_None 
WS_Hidden 
WS_BringUp 
WS_PutDown 
WS_ReadyToFire 

Functions

Native functions

InitWeaponFires

native final function InitWeaponFires ()


Other native code

Weapon firing updates

void AWeapon::TickAuthoritative( FLOAT DeltaSeconds )
{
	guardSlow(AWeapon::TickAuthoritative);
	
	AActor::TickAuthoritative( DeltaSeconds );
	
	if( bDeleteMe )
		return;
	
	if ( Instigator && Instigator->Weapon == this && !Instigator->bDeleteMe && Instigator->Controller != NULL && !Instigator->Controller->bDeleteMe 
		&& !Instigator->bNoWeaponFiring )
	{
		eventWeaponTick(DeltaSeconds);
		// client & server: update mode timing
		for (INT mode=0; mode<UCONST_NUM_FIRE_MODES; mode++ )
		{
			if (FireMode[mode] != NULL)
			{
				FireMode[mode]->ModeTick( DeltaSeconds );
				
				if (!Instigator || !Instigator->Controller) // pawn was killed during mode tick (ie: shieldgun against the wall)
					return;
				
				if (Role == ROLE_Authority)
				{
					if (FireMode[mode]->bServerDelayStartFire)
					{
						if (FireMode[mode]->NextFireTime <= Level->TimeSeconds + FireMode[mode]->PreFireTime)
							eventServerStartFire(mode);
					}
					else if (FireMode[mode]->bServerDelayStopFire)
					{
						FireMode[mode]->bServerDelayStopFire = false;
						//debugf(TEXT("ServerDelayStopFire %f"), Level->TimeSeconds);
						eventStopFire(mode);
					}
				}
			}
		}
		
		// client side only: determine when firing starts and stops
		if ( Instigator->IsLocallyControlled() && !bEndOfRound )
		{
			if ( (ClientState == WS_None) || (ClientState == WS_Hidden) )
			{
				debugf(TEXT("%s ClientState was WRONG! (%d)"),GetName(),ClientState);
				ClientState = WS_ReadyToFire;
			}
			
			if ( ClientState == WS_ReadyToFire )
			{
				UBOOL bAltFire = Instigator->Controller->bAltFire;
				UBOOL bFire = Instigator->Controller->bFire;
				AWeapon *MyDefault = Cast<AWeapon>(GetClass()->GetDefaultActor());
				if ( MyDefault && MyDefault->ExchangeFireModes )
				{
					Exchange(bFire,bAltFire);
				}
				
				if (FireMode[0] != NULL)
				{
					if (FireMode[0]->bIsFiring && !bFire)
					{
						eventClientStopFire(0);
					}
					else if (!FireMode[0]->bIsFiring && bFire)
					{
						eventClientStartFire(0);
					}
				}
				
				if (FireMode[1] != NULL)
				{
					if (FireMode[1]->bIsFiring && !bAltFire)
					{
						eventClientStopFire(1);
					}
					else if (!FireMode[1]->bIsFiring && bAltFire)
					{                                       
						eventClientStartFire(1);
					}
				}
			}
			else if ( TimerRate<=0.f )
			{
				debugf(TEXT("%s no timer running with clientstate %d"),GetName(),ClientState);
				TimerRate = 0.3f;
			}
		}
	}
	
	unguardSlow;
}

Events

AnimEnd

simulated event AnimEnd (int channel)

Overrides: Actor.AnimEnd


ClientStartFire

simulated event ClientStartFire (int Mode)


ClientStopFire

simulated event ClientStopFire (int Mode)


Destroyed

simulated event Destroyed ()

Overrides: Inventory.Destroyed


PostBeginPlay

simulated event PostBeginPlay ()

Overrides: Actor.PostBeginPlay


PostNetReceive

simulated event PostNetReceive ()

Overrides: Actor.PostNetReceive


RenderOverlays

simulated event RenderOverlays (Canvas Canvas)

Overrides: Inventory.RenderOverlays


ServerStartFire

event ServerStartFire (byte Mode)


StopFire

simulated event StopFire (int Mode)


Timer

simulated event Timer ()

Overrides: Actor.Timer


WeaponTick

simulated event WeaponTick (float dt)


Other instance functions

See Weapon instance functions.

States

Hidden

PendingClientWeaponSet

PendingClientWeaponSet.BeginState

simulated event BeginState ()

Overrides: Object.BeginState (global)


PendingClientWeaponSet.EndState

simulated event EndState ()

Overrides: Object.EndState (global)


PendingClientWeaponSet.Timer

simulated event Timer ()

Overrides: Timer (global)