I love the smell of UnrealEd crashing in the morning. – tarquin

UE3:UTWeapon instance functions (UDK)

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

Contents

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

Instance functions

Activate

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

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

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

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

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

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

simulated function bool AmmoMaxed (int mode)

Returns true if the ammo is maxed out

AttachMuzzleFlash

simulated function AttachMuzzleFlash ()

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

AttachWeaponTo

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

function byte BestMode ()

BestMode() choose between regular or alt-fire

bReadyToFire

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

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

function bool CanAttack (Actor Other)

Overrides: Weapon.CanAttack

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

CanHeal

function bool CanHeal (Actor Other)

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

CanThrow

simulated function bool CanThrow ()

Overrides: Weapon.CanThrow

Returns true if this item can be thrown out.

CanViewAccelerationWhenFiring

simulated function bool CanViewAccelerationWhenFiring ()

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

ChangeVisibility

simulated function ChangeVisibility (bool bIsVisible)

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

CheckZoom

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

client reliable simulated function ClientEndFire (byte FireModeNum)


ClientWeaponSet

reliable client function ClientWeaponSet (bool bOptionalSet, optional bool bDoNotActivate)

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).
  • bDoNotActivate - Override, do not activate this weapon. It's just been received in the inventory.

ClientWeaponThrown

reliable client function ClientWeaponThrown ()

Overrides: Weapon.ClientWeaponThrown

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

ConsumeAmmo

function ConsumeAmmo (byte FireModeNum)

Overrides: Weapon.ConsumeAmmo

Consumes some of the ammo

CoversScreenSpace

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


CreateOverlayMesh

simulated function CreateOverlayMesh ()


DenyPickupQuery

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

simulated function float DesireAmmo (bool bDetour)

This function retuns how much of the clip is empty.

DetachMuzzleFlash

simulated function DetachMuzzleFlash ()

Remove/Detach the muzzle flash components

DetachWeapon

simulated function DetachWeapon ()

Overrides: Weapon.DetachWeapon

Detach weapon from skeletal mesh

Parameters:

  • SkeletalMeshComponent - weapon is attached to.

DisplayDebug

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

simulated function DrawLockedOn (HUD H)

Draw the locked on symbol

DrawWeaponCrosshair

simulated function DrawWeaponCrosshair (HUD HUD)

Draw the Crosshairs

DropFrom

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

simulated function bool EnableFriendlyWarningCrosshair ()


EndFire

simulated function EndFire (byte FireModeNum)

Overrides: Weapon.EndFire

We Override endfire to add support for zooming

EndZoom

simulated function EndZoom (UTPlayerController PC)

Called when zooming ends

Parameters:

  • PC - cast of Instigator.Controller for convenience

FireAmmunition

simulated function FireAmmunition ()

Overrides: Weapon.FireAmmunition

Deactiveate Spawn Protection

FireHack

function FireHack ()


FireOnRelease

function bool FireOnRelease ()

Overrides: Weapon.FireOnRelease

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

FiringPutDownWeapon

simulated function FiringPutDownWeapon ()


GetAmmoCount

simulated function int GetAmmoCount ()


GetArmAnimNodeSeq

simulated function AnimNodeSequence GetArmAnimNodeSeq ()


GetEffectLocation

simulated function Object.Vector GetEffectLocation ()

Returns:

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

GetEquipTime

simulated function float GetEquipTime ()


GetFireInterval

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

simulated function UTPlayerController.EWeaponHand GetHand ()

Returns the current Weapon Hand

GetOptimalRangeFor

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

simulated function string GetOwnerName ()


GetViewAxes

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

Overrides: Weapon.GetViewAxes

Pawn/Controller/View functions

GetWeaponRating

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

simulated function EZoomState GetZoomedState ()

Returns true if we are currently zoomed

HasAmmo

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

simulated function bool HasAnyAmmo ()

Overrides: Weapon.HasAnyAmmo

returns true if this weapon has any ammo

HolderEnteredVehicle

simulated function HolderEnteredVehicle ()

called when Instigator enters a vehicle while we are its Weapon

InstantAimHelp

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

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

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

Returns:

end trace position for instantfire()

InstantFireStartTrace

simulated function Object.Vector InstantFireStartTrace ()

Returns:

position of trace start for instantfire()

IsFullyCharged

function bool IsFullyCharged ()

Returns:

whether this is a charging weapon and is fully charged up

LagRot

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


Loaded

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

simulated function bool NeedAmmo ()

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

PerformWeaponChange

simulated function PerformWeaponChange ()

Called when the pawn is changing weapons

PlayArmAnimation

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


PlayFireEffects

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

simulated function PlayFiringSound ()

Overrides: Weapon.PlayFiringSound

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

PlayWeaponAnimation

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

simulated function PlayWeaponEquip ()

Show the weapon begin equipped

PlayWeaponPutDown

simulated function PlayWeaponPutDown ()

Show the weapon being put away

PreloadTextures

simulated function PreloadTextures (bool bForcePreload)


ProcessInstantHit

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

Overrides: Weapon.ProcessInstantHit

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

Parameters:

  • FiringMode - index of firing mode being used
  • Impact - hit information
  • NumHits - opt): number of hits to apply using this impact this is useful for handling multiple nearby impacts of multihit weapons (e.g. shotguns) without having to execute the entire damage code path for each one an omitted or <= 0 value indicates a single hit

ProjectileFire

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

simulated function bool ReadyToFire (bool bFinished)

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

RefireCheckTimer

simulated function RefireCheckTimer ()

Overrides: Weapon.RefireCheckTimer


SendToFiringState

simulated function SendToFiringState (byte FireModeNum)

Overrides: Weapon.SendToFiringState

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

ServerReselectWeapon

reliable server function ServerReselectWeapon ()

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

ServerStartFire

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

simulated function SetMuzzleFlashParams (ParticleSystemComponent PSC)

Allows a child to setup custom parameters on the muzzle flash

SetSkin

simulated function SetSkin (Material NewMaterial)

Material control

Parameters:

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

SetupArmsAnim

simulated function SetupArmsAnim ()


SetWeaponOverlayFlags

simulated function SetWeaponOverlayFlags (UTPawn OwnerPawn)


ShakeView

simulated function ShakeView ()

plays view shake on the owning client only

ShouldFireWithoutTarget

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

simulated function bool ShouldLagRot ()

Returns:

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

ShouldSwitchTo

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

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

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

simulated function StartZoom (UTPlayerController PC)

Called when zooming starts

Parameters:

  • PC - cast of Instigator.Controller for convenience

StillFiring

simulated function bool StillFiring (byte FireMode)

Overrides: Weapon.StillFiring

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

StopFireEffects

simulated function StopFireEffects (byte FireModeNum)

Overrides: Weapon.StopFireEffects

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

ThrottleLook

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

simulated function TimeWeaponEquipping ()

Overrides: Weapon.TimeWeaponEquipping

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

TimeWeaponPutDown

simulated function TimeWeaponPutDown ()

Overrides: Weapon.TimeWeaponPutDown

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

TryPutDown

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

simulated function WeaponEmpty ()

Overrides: Weapon.WeaponEmpty

Called when the weapon runs out of ammo during firing

WeaponPlaySound

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