The three virtues of a programmer: Laziness, Impatience, and Hubris. – Larry Wall
UE3:Weapon instance functions (UT3)
Contents
- 1 Instance functions
- 1.1 Activate
- 1.2 AddAmmo
- 1.3 AddSpread
- 1.4 AdjustFOVAngle
- 1.5 AttachWeaponTo
- 1.6 BeginFire
- 1.7 CalcWeaponFire
- 1.8 CanAttack
- 1.9 CanThrow
- 1.10 ClearFlashCount
- 1.11 ClearFlashLocation
- 1.12 ClearPendingFire
- 1.13 ClientWeaponSet
- 1.14 ClientWeaponThrown
- 1.15 ConsumeAmmo
- 1.16 CustomFire
- 1.17 DemoBeginFire
- 1.18 DemoEndFire
- 1.19 DenyClientWeaponSet
- 1.20 DenyPickupQuery
- 1.21 DetachWeapon
- 1.22 DisplayDebug
- 1.23 DoOverrideNextWeapon
- 1.24 DoOverridePrevWeapon
- 1.25 DropFrom
- 1.26 DumpWeaponDebugToLog
- 1.27 EndFire
- 1.28 FireAmmunition
- 1.29 FireModeUpdated
- 1.30 FireOnRelease
- 1.31 FocusOnLeader
- 1.32 ForceEndFire
- 1.33 GetAdjustedAim
- 1.34 GetAIRating
- 1.35 GetDamageRadius
- 1.36 GetFireInterval
- 1.37 GetPhysicalFireStartLoc
- 1.38 GetProjectileClass
- 1.39 GetTraceOwner
- 1.40 GetTraceRange
- 1.41 GetViewAxes
- 1.42 GetWeaponAnimNodeSeq
- 1.43 GetWeaponDebug
- 1.44 GetWeaponRating
- 1.45 GivenTo
- 1.46 HasAmmo
- 1.47 HasAnyAmmo
- 1.48 HolderDied
- 1.49 IncrementFlashCount
- 1.50 InstantFire
- 1.51 IsActiveWeapon
- 1.52 ItemRemovedFromInvManager
- 1.53 MaxRange
- 1.54 PassThroughDamage
- 1.55 PendingFire
- 1.56 PlayFireEffects
- 1.57 PlayFiringSound
- 1.58 PlayWeaponAnimation
- 1.59 ProcessInstantHit
- 1.60 ProjectileFire
- 1.61 PutDownWeapon
- 1.62 RangedAttackTime
- 1.63 RecommendLongRangedAttack
- 1.64 RecommendRangedAttack
- 1.65 RefireCheckTimer
- 1.66 RelativeStrengthVersus
- 1.67 SendToFiringState
- 1.68 ServerStartFire
- 1.69 ServerStopFire
- 1.70 SetCurrentFireMode
- 1.71 SetFlashLocation
- 1.72 SetPendingFire
- 1.73 ShouldRefire
- 1.74 StartFire
- 1.75 StillFiring
- 1.76 StopFire
- 1.77 StopFireEffects
- 1.78 StopWeaponAnimation
- 1.79 SuggestAttackStyle
- 1.80 SuggestDefenseStyle
- 1.81 TimeWeaponEquipping
- 1.82 TimeWeaponFiring
- 1.83 TimeWeaponPutDown
- 1.84 TryPutDown
- 1.85 WeaponCalcCamera
- 1.86 WeaponEmpty
- 1.87 WeaponLog
- 1.88 WeaponPlaySound
This is an auto-generated page and may need human attention. Please remove the {{autogenerated}} tag if the page seems reasonably complete or replace it with the {{expand}} tag if the page is not yet complete. |
Instance functions
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
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
Adds any fire spread offset to the passed in rotator
Parameters:
- Aim - the base aim direction
Returns:
- the adjusted aim direction
AdjustFOVAngle
This function can be used by a weapon to override a playercontroller's FOVAngle. It should be overriden in a subclass.
AttachWeaponTo
AttachWeaponTo is called when it's time to attach the weapon's mesh to a location. it should be subclassed.
BeginFire
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
CalcWeaponFire
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
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
CanThrow
Returns true if this item can be thrown out.
ClearFlashCount
Clear flashCount variable on Pawn. and call WeaponStoppedFiring event. Call this on the server and local player.
Network: Server or Local Player
ClearFlashLocation
Reset flash location variable. and call stop firing. Network: Server only
ClearPendingFire
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
This function is called when the client needs to discard the weapon
ConsumeAmmo
Consumes ammunition when firing a shot. Subclass me to define weapon ammunition consumption.
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.
DemoBeginFire
DemoEndFire
Passes on EndFire calls to demos
DenyClientWeaponSet
Returns true if this weapon wants to deny a ClientWeaponSwitch call
DenyPickupQuery
Overrides: Inventory.DenyPickupQuery
When you pickup an weapon, the inventory system has a chance to restrict the pickup.
DetachWeapon
Detach weapon components from instigator. Perform any clean up. Should be subclassed.
DisplayDebug
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
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
hook to override Previous weapon call.
DropFrom
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
DumpWeaponDebugToLog
Dump debug information for this weapon to log file.
EndFire
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
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
Event called when Pawn.FiringMode has been changed. bViaReplication indicates if this was the result of a replication call.
FireOnRelease
FocusOnLeader
ForceEndFire
Clear all pending fires. This is non replicated flag.
GetAdjustedAim
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
AI interface
GetDamageRadius
Returns the DamageRadius of projectiles being shot
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
GetPhysicalFireStartLoc
This function returns the world location for spawning the projectile, pulled in to the Pawn's collision along the AimDir direction.
GetProjectileClass
Returns the type of projectile to spawn. We use a function so subclasses can override it if needed (case in point, homing rockets).
GetTraceOwner
Returns:
- the actor that 'owns' this weapon's traces (i.e. can't be hit by them)
GetTraceRange
Range of weapon Used for Traces (CalcWeaponFire, InstantFire, ProjectileFire, AdjustAim...) State scoped accessor function. Override in proper state
Returns:
- range of weapon, to be used mainly for traces.
GetViewAxes
Returns the base view aim of the weapon owner
GetWeaponAnimNodeSeq
Returns the AnimNodeSequence the weapon is using to play animations.
GetWeaponDebug
Retrieves important weapon debug information as an array of strings. That can then be dumped or displayed on HUD.
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)
GivenTo
Overrides: Inventory.GivenTo
This Weapon has just been given to this Pawn
Parameters:
- thisPawn - new weapon owner
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.
Returns:
- true if ammo is available for Firemode FireModeNum.
HasAnyAmmo
returns true if this weapon has any ammo left, regardless of the actual firing mode.
HolderDied
Pawn holding this weapon as active weapon just died.
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
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
Informs if this weapon is active for the player
Returns:
- true if this an active weapon for the player
ItemRemovedFromInvManager
Overrides: Inventory.ItemRemovedFromInvManager
A notification call when this weapon is removed from the Inventory of a pawn
See: Inventory::ItemRemovedFromInvManager
MaxRange
Returns the Maximum Range for this weapon
PassThroughDamage
returns true if should pass trace through this hitactor
PendingFire
Pending Fire / Inv Manager
PlayFireEffects
PlayFireEffects Main function to play Weapon fire effects. This is called from Pawn::WeaponFired in the base implementation.
PlayFiringSound
PlayFiringSound - Called after a shot is fired.
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
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
Fires a projectile. Spawns the projectile, but also increment the flash count for remote client effects. Network: Local Player and Server
PutDownWeapon
This function is called to put a weapon down
RangedAttackTime
RecommendLongRangedAttack
RecommendRangedAttack
RefireCheckTimer
RelativeStrengthVersus
SendToFiringState
Send weapon to proper firing state Also sets the CurrentFireMode. Network: LocalPlayer and Server
Parameters:
- FireModeNum - Fire Mode.
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.
ServerStopFire
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
Set current firing mode. Network: Local Player and Server.
SetFlashLocation
This function sets up the Location of a hit to be replicated to all remote clients.
Network: Server only
SetPendingFire
ShouldRefire
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
StillFiring
This function returns true if the weapon is still firing in a given mode
StopFire
This initiates the shutdown of a weapon that is firing. Network: Local Player
StopFireEffects
StopFireEffects Main function to stop any active effects This is called from Pawn::WeaponStoppedFiring
StopWeaponAnimation
Stops an animation on the weapon mesh Network: Local Player and clients
SuggestAttackStyle
SuggestDefenseStyle
TimeWeaponEquipping
Sets the timing for equipping a weapon. The WeaponEquipped event is trigged when expired
TimeWeaponFiring
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
Sets the timing for putting a weapon down. The WeaponIsDown event is trigged when expired
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
WeaponCalcCamera allows a weapon to adjust the pawn's controller's camera. Should be subclassed
WeaponEmpty
Called when the weapon runs out of ammo during firing
WeaponLog
Prints out weapon debug information to log file
Parameters:
- Msg - String to display
- FuncStr - String telling where the log came from (format: Class::Function)
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