The three virtues of a programmer: Laziness, Impatience, and Hubris. – Larry Wall

UE3:UTWeapon instance functions (UT3)

From Unreal Wiki, The Unreal Engine Documentation Site
Jump to: navigation, search
UT3 Object >> Actor >> Inventory >> Weapon >> GameWeapon >> UTWeapon (instance functions)

Contents

UTWeapon instance functions in other games:
UDK
Other member categories for this class:
internal variables

Instance functions[edit]

Activate[edit]

simulated function Activate ()

Overrides: Weapon.Activate

All inventory use the Activate() function when an item is selected for use. For weapons, this function starts the Equipping process. If the weapon is the inactive state, it will go to the 'WeaponEquipping' followed by 'Active' state, and ready to be fired.

ActiveRenderOverlays[edit]

simulated function ActiveRenderOverlays (HUD H)

Overrides: Inventory.ActiveRenderOverlays

Access to HUD and Canvas. Event always called when the InventoryManager considers this Inventory Item currently "Active" (for example active weapon)

Parameters:

  • HUD - HUD with canvas to draw on

AddAmmo[edit]

function int AddAmmo (int Amount)

Overrides: Weapon.AddAmmo

This function is used to add ammo back to a weapon. It's called from the Inventory Manager

AdjustPlayerDamage[edit]

function AdjustPlayerDamage (out int Damage, Controller InstigatedBy, Object.Vector HitLocation, out Object.Vector Momentum, class<DamageTypeDamageType)

called every time owner takes damage while holding this weapon - used by shield gun

AdjustWeaponTimingForConsole[edit]

simulated function AdjustWeaponTimingForConsole ()

Adjust weapon equip and fire timings so they match between PC and console This is important so the sounds match up.

AllowSwitchTo[edit]

simulated function bool AllowSwitchTo (Weapon NewWeapon)

called on both Instigator's current weapon and its pending weapon (if they exist)

Returns:

whether Instigator is allowed to switch to NewWeapon

AmmoMaxed[edit]

simulated function bool AmmoMaxed (int mode)

Returns true if the ammo is maxed out

AttachMuzzleFlash[edit]

simulated function AttachMuzzleFlash ()

Called on a client, this function Attaches the WeaponAttachment to the Mesh.

AttachWeaponTo[edit]

simulated function AttachWeaponTo (SkeletalMeshComponent MeshCpnt, optional name SocketName)

Overrides: Weapon.AttachWeaponTo

Attach Weapon Mesh, Weapon MuzzleFlash and Muzzle Flash Dynamic Light to a SkeletalMesh

Parameters:

  • who - is the pawn to attach to

BestMode[edit]

function byte BestMode ()

BestMode() choose between regular or alt-fire

bReadyToFire[edit]

simulated function bool bReadyToFire ()

Returns:

false if the weapon isn't ready to be fired. For example, if it's in the Inactive/WeaponPuttingDown states.

CalcInventoryWeight[edit]

simulated function CalcInventoryWeight ()

Each Weapon needs to have a unique InventoryWeight in order for weapon switching to work correctly. This function calculates that weight using the various inventory values

CanAttack[edit]

function bool CanAttack (Actor Other)

Overrides: Weapon.CanAttack

return false if out of range, can't see target, etc.

CanHeal[edit]

function bool CanHeal (Actor Other)

CanHeal() used by bot AI should return true if this weapon is able to heal Other

CanThrow[edit]

simulated function bool CanThrow ()

Overrides: Weapon.CanThrow

Returns true if this item can be thrown out.

CanViewAccelerationWhenFiring[edit]

simulated function bool CanViewAccelerationWhenFiring ()

This determines whether or not the Weapon can have ViewAcceleration when Firing.

ChangeVisibility[edit]

simulated function ChangeVisibility (bool bIsVisible)

This function is called from the pawn when the visibility of the weapon changes

CheckZoom[edit]

simulated function bool CheckZoom (byte FireModeNum)

We Override beginfire to add support for zooming. Should only be called from BeginFire()

Parameters:

  • FireModeNum - The current Firing Mode

Returns:

true we should abort the BeginFire call

ClientEndFire[edit]

client reliable simulated function ClientEndFire (byte FireModeNum)


ClientWeaponSet[edit]

reliable client function ClientWeaponSet (bool bOptionalSet)

Overrides: Weapon.ClientWeaponSet

(Description copied from Weapon.ClientWeaponSet)
is called by the server to tell the client about potential weapon changes after the player runs over a weapon (the client decides whether to actually switch weapons or not. Network: LocalPlayer

Parameters:

  • bOptionalSet - Set to true if the switch is optional. (simple weapon pickup and weight against current weapon).

ClientWeaponThrown[edit]

reliable client function ClientWeaponThrown ()

Overrides: Weapon.ClientWeaponThrown

This function is called when the client needs to discard the weapon

ConsumeAmmo[edit]

function ConsumeAmmo (byte FireModeNum)

Overrides: Weapon.ConsumeAmmo

Consumes some of the ammo

CoversScreenSpace[edit]

simulated function bool CoversScreenSpace (Object.Vector ScreenLoc, Canvas Canvas)


CreateOverlayMesh[edit]

simulated function CreateOverlayMesh ()


DenyPickupQuery[edit]

function bool DenyPickupQuery (class<InventoryItemClass, Actor Pickup)

Overrides: Weapon.DenyPickupQuery

When you pickup an weapon, the inventory system has a chance to restrict the pickup.

DesireAmmo[edit]

simulated function float DesireAmmo (bool bDetour)

This function retuns how much of the clip is empty.

DetachMuzzleFlash[edit]

simulated function DetachMuzzleFlash ()

Remove/Detach the muzzle flash components

DetachWeapon[edit]

simulated function DetachWeapon ()

Overrides: Weapon.DetachWeapon

Detach weapon from skeletal mesh

Parameters:

  • SkeletalMeshComponent - weapon is attached to.

DisplayDebug[edit]

simulated function DisplayDebug (HUD HUD, out float out_YL, out float out_YPos)

Overrides: Weapon.DisplayDebug

list important Weapon variables on canvas. HUD will call DisplayDebug() on the current ViewTarget when the ShowDebug exec is used

Parameters:

  • HUD - HUD with canvas to draw on
  • out_YL - Height of the current font
  • out_YPos - Y position on Canvas. out_YPos += out_YL, gives position to draw text for next debug line.

DrawLockedOn[edit]

simulated function DrawLockedOn (HUD H)

Draw the locked on symbol

DrawWeaponCrosshair[edit]

simulated function DrawWeaponCrosshair (HUD HUD)

Draw the Crosshairs

DropFrom[edit]

function DropFrom (Object.Vector StartLocation, Object.Vector StartVelocity)

Overrides: Weapon.DropFrom

(Description copied from Weapon.DropFrom)
Drop this weapon out in to the world

Parameters:

  • StartLocation - The World Location to drop this item from
  • StartVelocity - The initial velocity for the item when dropped

EnableFriendlyWarningCrosshair[edit]

simulated function bool EnableFriendlyWarningCrosshair ()


EndFire[edit]

simulated function EndFire (byte FireModeNum)

Overrides: Weapon.EndFire

We Override endfire to add support for zooming

EndZoom[edit]

simulated function EndZoom (UTPlayerController PC)

Called when zooming ends

Parameters:

  • PC - cast of Instigator.Controller for convenience

FireAmmunition[edit]

simulated function FireAmmunition ()

Overrides: Weapon.FireAmmunition

Deactiveate Spawn Protection

FireHack[edit]

function FireHack ()


FireOnRelease[edit]

function bool FireOnRelease ()

Overrides: Weapon.FireOnRelease

tells AI that it needs to release the fire button for this weapon to do anything

FiringPutDownWeapon[edit]

simulated function FiringPutDownWeapon ()


GetAmmoCount[edit]

simulated function int GetAmmoCount ()


GetArmAnimNodeSeq[edit]

simulated function AnimNodeSequence GetArmAnimNodeSeq ()


GetEffectLocation[edit]

simulated function Object.Vector GetEffectLocation ()

Returns:

the location + offset from which to spawn effects (primarily tracers)

GetEquipTime[edit]

simulated function float GetEquipTime ()


GetFireInterval[edit]

simulated function float GetFireInterval (byte FireModeNum)

Overrides: Weapon.GetFireInterval

Returns interval in seconds between each shot, for the firing state of FireModeNum firing mode.

Parameters:

  • FireModeNum - fire mode

Returns:

Period in seconds of firing mode

GetHand[edit]

simulated function UTPlayerController.EWeaponHand GetHand ()

Returns the current Weapon Hand

GetOptimalRangeFor[edit]

function float GetOptimalRangeFor (Actor Target)

used by bot AI to get the optimal range for shooting Target can be called on friendly Targets if trying to heal it

GetOwnerName[edit]

simulated function string GetOwnerName ()


GetPhysicalFireStartLoc[edit]

simulated function Object.Vector GetPhysicalFireStartLoc (optional Object.Vector AimDir)

Overrides: Weapon.GetPhysicalFireStartLoc

This function returns the world location for spawning the projectile, pulled in to the Pawn's collision along the AimDir direction.

GetViewAxes[edit]

simulated function GetViewAxes (out Object.Vector xaxis, out Object.Vector yaxis, out Object.Vector zaxis)

Overrides: Weapon.GetViewAxes

Pawn/Controller/View functions

GetWeaponRating[edit]

simulated function float GetWeaponRating ()

Overrides: Weapon.GetWeaponRating

Returns a weight reflecting the desire to use the given weapon, used for AI and player best weapon selection.

Parameters:

  • Weapon - W

Returns:

Weapon rating (range -1.f to 1.f)

GetZoomedState[edit]

simulated function EZoomState GetZoomedState ()

Returns true if we are currently zoomed

GivenTo[edit]

function GivenTo (Pawn NewOwner, bool bDoNotActivate)

Overrides: Weapon.GivenTo

(Description copied from Weapon.GivenTo)
This Weapon has just been given to this Pawn

Parameters:

  • thisPawn - new weapon owner

HasAmmo[edit]

simulated function bool HasAmmo (byte FireModeNum, optional int Amount)

Overrides: Weapon.HasAmmo

This function checks to see if the weapon has any ammo available for a given fire mode.

Parameters:

  • FireModeNum - The Fire Mode to Test For
  • Amount - Optional] Check to see if this amount is available. If 0 it will default to checking for the ShotCost

HasAnyAmmo[edit]

simulated function bool HasAnyAmmo ()

Overrides: Weapon.HasAnyAmmo

returns true if this weapon has any ammo

HolderEnteredVehicle[edit]

simulated function HolderEnteredVehicle ()

called when Instigator enters a vehicle while we are its Weapon

InstantAimHelp[edit]

simulated function Actor.ImpactInfo InstantAimHelp (Object.Vector StartTrace, Object.Vector EndTrace, Actor.ImpactInfo RealImpact)

Look for "near miss" of target within UTPC.AimHelpModifier() * AimingHelpRadius Return that target as a hit if it was a near miss

InstantFire[edit]

simulated function InstantFire ()

Overrides: Weapon.InstantFire

Performs an 'Instant Hit' shot. Also, sets up replication for remote clients, and processes all the impacts to deal proper damage and play effects.

Network: Local Player and Server

InstantFireEndTrace[edit]

simulated function Object.Vector InstantFireEndTrace (Object.Vector StartTrace)

Returns:

end trace position for instantfire()

InstantFireStartTrace[edit]

simulated function Object.Vector InstantFireStartTrace ()

Returns:

position of trace start for instantfire()

IsFullyCharged[edit]

function bool IsFullyCharged ()

Returns:

whether this is a charging weapon and is fully charged up

LagRot[edit]

simulated function int LagRot (int NewValue, int LastValue, float MaxDiff, int Index)


Loaded[edit]

simulated function Loaded (optional bool bUseWeaponMax)

Cheat Help function the loads out the weapon

Parameters:

  • bUseWeaponMax - Optional] If true, this function will load out the weapon with the actual maximum, not 999

NeedAmmo[edit]

simulated function bool NeedAmmo ()

Returns true if the current ammo count is less than the default ammo count

PerformWeaponChange[edit]

simulated function PerformWeaponChange ()

Called when the pawn is changing weapons

PlayArmAnimation[edit]

simulated function PlayArmAnimation (name Sequence, float fDesiredDuration, optional bool OffHand, optional bool bLoop, optional SkeletalMeshComponent SkelMesh)


PlayFireEffects[edit]

simulated function PlayFireEffects (byte FireModeNum, optional Object.Vector HitLocation)

Overrides: Weapon.PlayFireEffects

PlayFireEffects Is the root function that handles all of the effects associated with a weapon. This function creates the 1st person effects. It should only be called on a locally controlled player.

PlayFiringSound[edit]

simulated function PlayFiringSound ()

Overrides: Weapon.PlayFiringSound

Tells the weapon to play a firing sound (uses CurrentFireMode)

PlayWeaponAnimation[edit]

simulated function PlayWeaponAnimation (name Sequence, float fDesiredDuration, optional bool bLoop, optional SkeletalMeshComponent SkelMesh)

Overrides: Weapon.PlayWeaponAnimation

(Description copied from Weapon.PlayWeaponAnimation)
Play an animation on the weapon mesh Network: Local Player and clients

Parameters:

  • Anim - Sequence to play on weapon skeletal mesh
  • desired - duration, in seconds, animation should be played

PlayWeaponEquip[edit]

simulated function PlayWeaponEquip ()

Show the weapon begin equipped

PlayWeaponPutDown[edit]

simulated function PlayWeaponPutDown ()

Show the weapon being put away

PreloadTextures[edit]

simulated function PreloadTextures (bool bForcePreload)


ProcessInstantHit[edit]

simulated function ProcessInstantHit (byte FiringMode, Actor.ImpactInfo Impact)

Overrides: Weapon.ProcessInstantHit

(Description copied from Weapon.ProcessInstantHit)
Processes a successful 'Instant Hit' trace and eventually spawns any effects. Network: LocalPlayer and Server

Parameters:

  • HitActor - Actor hit by trace
  • AimDir - Aim direction of shot
  • HitLocation - world location vector where HitActor was hit by trace
  • HitNormal - hit normal vector
  • HitInto - TraceHitInfo struct returning useful info like component hit, bone, material..

ProjectileFire[edit]

simulated function Projectile ProjectileFire ()

Overrides: Weapon.ProjectileFire

Fires a projectile. Spawns the projectile, but also increment the flash count for remote client effects. Network: Local Player and Server

ReadyToFire[edit]

simulated function bool ReadyToFire (bool bFinished)

ReadyToFire() called by NPC firing weapon. bFinished should only be true if called from the Finished() function

RefireCheckTimer[edit]

simulated function RefireCheckTimer ()

Overrides: Weapon.RefireCheckTimer


SendToFiringState[edit]

simulated function SendToFiringState (byte FireModeNum)

Overrides: Weapon.SendToFiringState

Don't send a zoomed fire mode in to a firing state

ServerReselectWeapon[edit]

reliable server function ServerReselectWeapon ()

This function is called whenever you attempt to reselect the same weapon

ServerStartFire[edit]

reliable server function ServerStartFire (byte FireModeNum)

Overrides: Weapon.ServerStartFire

When StartFire() is called on a client, it replicates the start by calling ServerStartFire. This begins the event on server. Server side actors (such as bots) should not call ServerStartFire directly and should instead call StartFire().

Network: Dedicated Server only, or Listen Server for remote clients.

SetMuzzleFlashParams[edit]

simulated function SetMuzzleFlashParams (ParticleSystemComponent PSC)

Allows a child to setup custom parameters on the muzzle flash

SetSkin[edit]

simulated function SetSkin (Material NewMaterial)

Material control

Parameters:

  • NewMaterial - The new material to apply or none to clear it

SetupArmsAnim[edit]

simulated function SetupArmsAnim ()


SetWeaponOverlayFlags[edit]

simulated function SetWeaponOverlayFlags (UTPawn OwnerPawn)


ShakeView[edit]

simulated function ShakeView ()

plays view shake on the owning client only

ShouldFireWithoutTarget[edit]

function bool ShouldFireWithoutTarget ()

called by AI when camping/defending return true if it is useful to fire this weapon even though bot doesn't have a target for example, a weapon that launches turrets or mines

ShouldLagRot[edit]

simulated function bool ShouldLagRot ()

Returns:

whether the weapon's rotation is allowed to lag behind the holder's rotation

ShouldSwitchTo[edit]

simulated function bool ShouldSwitchTo (UTWeapon InWeapon)

returns true if this weapon is currently lower priority than InWeapon used to determine whether to switch to InWeapon this is the server check, so don't check clientside settings (like weapon priority) here

SplashJump[edit]

function bool SplashJump ()

return true if recommend jumping while firing to improve splash damage (by shooting at feet) true for R.L., for example

StartFire[edit]

simulated function StartFire (byte FireModeNum)

Overrides: Weapon.StartFire

Called on the LocalPlayer, Fire sends the shoot request to the server (ServerStartFire) and them simulates the firing effects locally. Call path: PlayerController::StartFire -> Pawn::StartFire -> InventoryManager::StartFire Network: LocalPlayer

StartZoom[edit]

simulated function StartZoom (UTPlayerController PC)

Called when zooming starts

Parameters:

  • PC - cast of Instigator.Controller for convenience

StillFiring[edit]

simulated function bool StillFiring (byte FireMode)

Overrides: Weapon.StillFiring

This function returns true if the weapon is still firing in a given mode

StopFireEffects[edit]

simulated function StopFireEffects (byte FireModeNum)

Overrides: Weapon.StopFireEffects

StopFireEffects Main function to stop any active effects This is called from Pawn::WeaponStoppedFiring

ThrottleLook[edit]

simulated function ThrottleLook (out float aTurn, out float aLookup)

Allow the weapon to adjust the turning speed of the pawn

Parameters:

  • aTurn - The aTurn value from PlayerInput to throttle
  • aLookup - The aLookup value from playerInput to throttle

FIXME: Add support for validation on a server

TimeWeaponEquipping[edit]

simulated function TimeWeaponEquipping ()

Overrides: Weapon.TimeWeaponEquipping

Sets the timing for equipping a weapon. The WeaponEquipped event is trigged when expired

TimeWeaponPutDown[edit]

simulated function TimeWeaponPutDown ()

Overrides: Weapon.TimeWeaponPutDown

Sets the timing for putting a weapon down. The WeaponIsDown event is trigged when expired

TryPutDown[edit]

simulated function bool TryPutDown ()

Overrides: Weapon.TryPutDown

When attempting to put the weapon down, look to see if our MinReloadPct has been met. If so just put it down

WeaponEmpty[edit]

simulated function WeaponEmpty ()

Overrides: Weapon.WeaponEmpty

Called when the weapon runs out of ammo during firing

WeaponPlaySound[edit]

simulated function WeaponPlaySound (SoundCue Sound, optional float NoiseLoudness)

Overrides: Weapon.WeaponPlaySound

(Description copied from Weapon.WeaponPlaySound)
This function handles playing sounds for weapons. How it plays the sound depends on the following:

If we are a listen server, then this sound is played and replicated as normal If we are a remote client, but locally controlled (ie: we are on the client) we play the sound and don't replicate it If we are a dedicated server, play the sound and replicate it to everyone BUT the owner (he will play it locally).

Parameters:

  • SoundCue - The Source Cue to play