Mostly Harmless

UE3:Weapon instance functions (UDK)

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

Contents

Weapon instance functions in other games:
RTNP, U1, UT, U2, U2XMP, UE2Runtime, UT2003, UT2004, UT3

Instance functions[edit]

Activate[edit]

simulated function 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.

AddAmmo[edit]

function int AddAmmo (int Amount)

Add ammo to weapon

Parameters:

  • Amount - to add.

Returns:

Amount actually added. (In case magazine is already full and some ammo is left Subclass me to define ammo addition rules.

AddSpread[edit]

simulated function Object.Rotator AddSpread (Object.Rotator BaseAim)

Adds any fire spread offset to the passed in rotator

Parameters:

  • Aim - the base aim direction

Returns:

the adjusted aim direction

AdjustFOVAngle[edit]

simulated function float AdjustFOVAngle (float FOVAngle)

This function can be used by a weapon to override a playercontroller's FOVAngle. It should be overriden in a subclass.

AttachWeaponTo[edit]

simulated function AttachWeaponTo (SkeletalMeshComponent MeshCpnt, optional name SocketName)

AttachWeaponTo is called when it's time to attach the weapon's mesh to a location. it should be subclassed.

BeginFire[edit]

simulated function BeginFire (byte FireModeNum)

BeginFire is the point at which the server and client sync up their code path. It's job is to set the weapon in to the firing state. Network: LocalPlayer and Server

CacheAIController[edit]

simulated function CacheAIController ()


CalcWeaponFire[edit]

simulated function Actor.ImpactInfo CalcWeaponFire (Object.Vector StartTrace, Object.Vector EndTrace, optional out array<Actor.ImpactInfoImpactList, optional Object.Vector Extent)

CalcWeaponFire: Simulate an instant hit shot. This doesn't deal any damage nor trigger any effect. It just simulates a shot and returns the hit information, to be post-processed later.

ImpactList returns a list of ImpactInfo containing all listed impacts during the simulation. CalcWeaponFire however returns one impact (return variable) being the first geometry impact straight, with no direction change. If you were to do refraction, reflection, bullet penetration or something like that, this would return exactly when the crosshair sees: The first 'real geometry' impact, skipping invisible triggers and volumes.

Parameters:

  • StartTrace - world location to start trace from
  • EndTrace - world location to end trace at
  • Extent - extent of trace performed

Returns:

first 'real geometry' impact that occured.

Output: ImpactList list of all impacts that occured during simulation

Note: if an impact didn't occur, and impact is still returned, with its HitLocation being the EndTrace value.

CanAttack[edit]

function bool CanAttack (Actor Other)


CanThrow[edit]

simulated function bool CanThrow ()

Returns true if this item can be thrown out.

ClearAllPendingFire[edit]

final simulated function ClearAllPendingFire ()

Ensure that all pending fire flags are 0

ClearFlashCount[edit]

simulated function ClearFlashCount ()

Clear flashCount variable on Pawn. and call WeaponStoppedFiring event. Call this on the server and local player.

Network: Server or Local Player

ClearFlashLocation[edit]

function ClearFlashLocation ()

Reset flash location variable. and call stop firing. Network: Server only

ClearPendingFire[edit]

final simulated function ClearPendingFire (int FireMode)


ClientGivenTo[edit]

reliable client function ClientGivenTo (Pawn NewOwner, bool bDoNotActivate)

Overrides: Inventory.ClientGivenTo

(Description copied from Inventory.ClientGivenTo)
This Inventory Item has just been given to this Pawn (owning client only)

Parameters:

  • thisPawn - new Inventory owner
  • bDoNotActivate - If true, this item will not try to activate

ClientWeaponSet[edit]

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

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[edit]

reliable client function ClientWeaponThrown ()

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

ConsumeAmmo[edit]

function ConsumeAmmo (byte FireModeNum)

Consumes ammunition when firing a shot. Subclass me to define weapon ammunition consumption.

CustomFire[edit]

simulated function CustomFire ()

If the weapon isn't an instant hit, or a simple projectile, it should use the tyoe EWFT_Custom. In those cases this function will be called. It should be subclassed by the custom weapon.

DenyClientWeaponSet[edit]

simulated function bool DenyClientWeaponSet ()

Returns true if this weapon wants to deny a ClientWeaponSwitch call

DenyPickupQuery[edit]

function bool DenyPickupQuery (class<InventoryItemClass, Actor Pickup)

Overrides: Inventory.DenyPickupQuery

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

DetachWeapon[edit]

simulated function DetachWeapon ()

Detach weapon components from instigator. Perform any clean up. Should be subclassed.

DisplayDebug[edit]

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

Overrides: Actor.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.

DoOverrideNextWeapon[edit]

simulated function bool DoOverrideNextWeapon ()

hook to override Next weapon call. For example the physics gun uses it to have mouse wheel change the distance of the held object. Warning: only use in firing state, otherwise it breaks weapon switching

DoOverridePrevWeapon[edit]

simulated function bool DoOverridePrevWeapon ()

hook to override Previous weapon call.

DropFrom[edit]

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

Overrides: Inventory.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

EndFire[edit]

simulated function EndFire (byte FireModeNum)

Like BeginFire, this function puts a client and the server in sync and shuts down the firing sequence on both. Network: LocalPlayer and Server

FireAmmunition[edit]

simulated function FireAmmunition ()

FireAmmunition: Perform all logic associated with firing a shot - Fires ammunition (instant hit or spawn projectile) - Consumes ammunition - Plays any associated effects (fire sound and whatnot)

Network: LocalPlayer and Server

FireModeUpdated[edit]

simulated function FireModeUpdated (byte FiringMode, bool bViaReplication)

Event called when Pawn.FiringMode has been changed. bViaReplication indicates if this was the result of a replication call.

FireOnRelease[edit]

function bool FireOnRelease ()


FocusOnLeader[edit]

function bool FocusOnLeader (bool bLeaderFiring)


ForceEndFire[edit]

simulated function ForceEndFire ()

Clear all pending fires. This is non replicated flag.

GetAdjustedAim[edit]

simulated function Object.Rotator GetAdjustedAim (Object.Vector StartFireLoc)

GetAdjustedAim begins a chain of function class that allows the weapon, the pawn and the controller to make on the fly adjustments to where this weapon is pointing.

GetAIRating[edit]

function float GetAIRating ()

AI interface

GetDamageRadius[edit]

function float GetDamageRadius ()

Returns the DamageRadius of projectiles being shot

GetFireInterval[edit]

simulated function float GetFireInterval (byte FireModeNum)

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

GetPendingFireLength[edit]

final simulated function int GetPendingFireLength ()

Pending Fire / Inv Manager

GetProjectileClass[edit]

function class<ProjectileGetProjectileClass ()

Returns the type of projectile to spawn. We use a function so subclasses can override it if needed (case in point, homing rockets).

GetTraceOwner[edit]

simulated function Actor GetTraceOwner ()

Returns:

the actor that 'owns' this weapon's traces (i.e. can't be hit by them)

GetViewAxes[edit]

simulated function GetViewAxes (out Object.Vector XAxis, out Object.Vector YAxis, out Object.Vector ZAxis)

Returns the base view aim of the weapon owner

GetWeaponAnimNodeSeq[edit]

simulated function AnimNodeSequence GetWeaponAnimNodeSeq ()

Returns the AnimNodeSequence the weapon is using to play animations.

GetWeaponDebug[edit]

simulated function GetWeaponDebug (out array<stringDebugInfo)

Retrieves important weapon debug information as an array of strings. That can then be dumped or displayed on HUD.

GetWeaponRating[edit]

simulated function float GetWeaponRating ()

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

Returns:

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

HandleFinishedFiring[edit]

simulated function HandleFinishedFiring ()


HasAmmo[edit]

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

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.

Returns:

true if ammo is available for Firemode FireModeNum.

HasAnyAmmo[edit]

simulated function bool HasAnyAmmo ()

returns true if this weapon has any ammo left, regardless of the actual firing mode.

HolderDied[edit]

function HolderDied ()

Pawn holding this weapon as active weapon just died.

IncrementFlashCount[edit]

simulated function IncrementFlashCount ()

Increment Pawn's FlashCount variable. This is used to play weapon fire effects on remote clients. Call this on the server and local player.

Network: Server and Local Player

InstantFire[edit]

simulated function 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

IsActiveWeapon[edit]

simulated function bool IsActiveWeapon ()

Informs if this weapon is active for the player

Returns:

true if this an active weapon for the player

ItemRemovedFromInvManager[edit]

function ItemRemovedFromInvManager ()

Overrides: Inventory.ItemRemovedFromInvManager

A notification call when this weapon is removed from the Inventory of a pawn

See: Inventory::ItemRemovedFromInvManager

MaxRange[edit]

simulated function float MaxRange ()

Returns the Maximum Range for this weapon

NotifyWeaponFinishedFiring[edit]

function NotifyWeaponFinishedFiring (byte FireMode)

AI function to handle a firing sequence (ie burst/melee strike/etc) being finished

NotifyWeaponFired[edit]

function NotifyWeaponFired (byte FireMode)

AI function to handle a single shot being fired

PendingFire[edit]

final simulated function bool PendingFire (int FireMode)


PlayFireEffects[edit]

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

PlayFireEffects Main function to play Weapon fire effects. This is called from Pawn::WeaponFired in the base implementation.

PlayFiringSound[edit]

simulated function PlayFiringSound ()

PlayFiringSound - Called after a shot is fired.

PlayWeaponAnimation[edit]

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

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

ProcessInstantHit[edit]

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

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[edit]

simulated function Projectile ProjectileFire ()

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

PutDownWeapon[edit]

simulated function PutDownWeapon ()

This function is called to put a weapon down

RangedAttackTime[edit]

function float RangedAttackTime ()


RecommendLongRangedAttack[edit]

function bool RecommendLongRangedAttack ()


RecommendRangedAttack[edit]

function bool RecommendRangedAttack ()


RefireCheckTimer[edit]

simulated function RefireCheckTimer ()


RelativeStrengthVersus[edit]

function float RelativeStrengthVersus (Pawn P, float Dist)


SendToFiringState[edit]

simulated function SendToFiringState (byte FireModeNum)

Send weapon to proper firing state Also sets the CurrentFireMode. Network: LocalPlayer and Server

Parameters:

  • FireModeNum - Fire Mode.

ServerStartFire[edit]

reliable server function ServerStartFire (byte FireModeNum)

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.

ServerStopFire[edit]

reliable server function ServerStopFire (byte FireModeNum)

When StopFire is called on a client, ServerStopFire is used to initiate the sequence on the server. Network: Dedicated Server only, or Listen Server for remote clients.

SetCurrentFireMode[edit]

simulated function SetCurrentFireMode (byte FiringModeNum)

Set current firing mode. Network: Local Player and Server.

SetFlashLocation[edit]

function SetFlashLocation (Object.Vector HitLocation)

This function sets up the Location of a hit to be replicated to all remote clients.

Network: Server only

SetPendingFire[edit]

final simulated function SetPendingFire (int FireMode)


ShouldRefire[edit]

simulated function bool ShouldRefire ()

Check if current fire mode can/should keep on firing. This is called from a firing state after each shot is fired to decide if the weapon should fire again, or stop and go to the active state. The default behavior, implemented here, is keep on firing while player presses fire and there is enough ammo. (Auto Fire).

Returns:

true to fire again, false to stop firing and return to Active State.

StartFire[edit]

simulated function StartFire (byte FireModeNum)

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

StillFiring[edit]

simulated function bool StillFiring (byte FireMode)

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

StopFire[edit]

simulated function StopFire (byte FireModeNum)

This initiates the shutdown of a weapon that is firing. Network: Local Player

StopFireEffects[edit]

simulated function StopFireEffects (byte FireModeNum)

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

StopWeaponAnimation[edit]

simulated function StopWeaponAnimation ()

Stops an animation on the weapon mesh Network: Local Player and clients

SuggestAttackStyle[edit]

function float SuggestAttackStyle ()


SuggestDefenseStyle[edit]

function float SuggestDefenseStyle ()


TimeWeaponEquipping[edit]

simulated function TimeWeaponEquipping ()

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

TimeWeaponFiring[edit]

simulated function TimeWeaponFiring (byte FireModeNum)

Sets the timing for the firing state on server and local client. By default, a constant looping Rate Of Fire (ROF) is set up. When the delay has expired, the RefireCheckTimer event is triggered.

Network: LocalPlayer and Server

Parameters:

  • FireModeNum - Fire Mode.

TimeWeaponPutDown[edit]

simulated function TimeWeaponPutDown ()

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

TryPutDown[edit]

simulated function bool TryPutDown ()

Put Down current weapon Once the weapon is put down, the InventoryManager will switch to InvManager.PendingWeapon.

Returns:

returns true if the weapon can be put down.

WeaponCalcCamera[edit]

simulated function WeaponCalcCamera (float fDeltaTime, out Object.Vector out_CamLoc, out Object.Rotator out_CamRot)

WeaponCalcCamera allows a weapon to adjust the pawn's controller's camera. Should be subclassed

WeaponEmpty[edit]

simulated function WeaponEmpty ()

Called when the weapon runs out of ammo during firing

WeaponIsDown[edit]

simulated function WeaponIsDown ()


WeaponPlaySound[edit]

simulated function WeaponPlaySound (SoundCue Sound, optional float NoiseLoudness)

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