ONSWeapon
This is the non-placable parent class of all of the vehicle and turret weapons found in the Onslaught Gametype.
Properties
Weapon Bone Rotation System
Main
- name YawBone
- float YawStartConstraint
- float YawEndConstraint
- name PitchBone
- int PitchUpLimit
- int PitchDownLimit
- name WeaponFireAttachmentBone
- name GunnerAttachmentBone
- float WeaponFireOffset
- float DualFireOffset
- If your weapon has twin muzzles, e.g. Energy Turret and Raptor, this causes shots to alternate from each barrel.
- vector WeaponOffset
- rotator LastRotation
- float RotationsPerSecond
Hidden
- float YawConstraintDelta
- rotator CurrentAim
- vector WeaponFireLocation
- written by CalcWeaponFire
- rotator WeaponFireRotation
- written by CalcWeaponFire
Flags
Main
- bool bInstantFire
- As Noted Above specifies InstantFireState instead of ProjectileFireState for the generic weapon firing code to use.
- bool bDualIndependantTargeting
- When using a DualFireOffset each shot will be independantly targeted at the crosshair
- bool bAimable
- Determines whether the weapon can be physically turned by the player (i.e. turret rotation or gun barrel pitch).
- bool bAmbientFireSound
- bool bAmbientAltFireSound
- bool bInheritVelocity
- bool bReflective
- Can be reflected by shield gun shield?
Hidden
- bool bInstantRotation
- NOTE: Gradual rotation via RotationsPerSecond still used for non-owning net clients to smooth rotation changes
- bool bActive
- bool bShowChargingBar
- Bender Style?
- bool bCallInstigatorPostRender
- If Instigator exists, during this actor's native PostRender(), call Instigator→PostRender() (used when weapon is visible but owner is bHidden)
- bool bForceCenterAim
- Not Used on The Goliath?
- bool bDoOffsetTrace
- Trace from outside vehicle's collision back towards weapon to determine firing offset. Probably Another Goliathy Type Feature
- bool bIsAltFire
- bool bIsRepeatingFF
- bool bCorrectAim (out, native, const)
- Indicates gun can hit what controller is aiming at
Aiming
Main
- float FireIntervalAimLock
- Fraction of FireInterval/AltFireInterval during which you can't move the gun
Hidden
- float AimLockReleaseTime
- When this time is reached gun can move again
- vector CurrentHitLocation
- float Spread
- float AimTraceRange
Impact/Damage
Each of these properties is hidden.
- vector LastHitLocation
- byte FlashCount
- byte OldFlashCount
- byte HitCount
- byte OldHitCount
Team Skins
Main
- Material RedSkin
- Material BlueSkin
Hidden
- var byte Team
Timing
Main
- float FireInterval, AltFireInterval
Hidden
- float FireCountDown
Effects
Main
- class<Emitter> FlashEmitterClass
- class<Emitter> EffectEmitterClass
- class<ONSWeaponAmbientEmitter?> AmbientEffectEmitterClass
Hidden
Sound
Each of these properties are available to edit.
- sound FireSoundClass
- float FireSoundVolume
- float FireSoundRadius
- float FireSoundPitch
- sound AltFireSoundClass
- float AltFireSoundVolume
- float AltFireSoundRadius
- float AltFireSoundPitch
- Why ISN'T this here? :0
- float AmbientSoundScaling
Force Feedback
Each of these properties are available to edit.
- string FireForce
- string AltFireForce
Instant Fire Stuff
Each of these properties are hidden.
- class<DamageType> DamageType
- int DamageMin, DamageMax
- Instant Hits work by applying damage as RealDamage = DamageMin + Rand(DamageMax-DamageMin)
- float TraceRange
- float Momentum
Projectile Fire Stuff
Main
- class<Projectile> ProjectileClass
- class<Projectile> AltFireProjectileClass
Hidden
- array<Projectile> Projectiles
- Ignore these when doing third person aiming trace (only necessary if projectiles fired have bProjTarget==true)
Camera Shakes
Each of these properties are available to edit.
- vector ShakeRotMag
- How far to rot view
- vector ShakeRotRate
- How fast to rot view
- float ShakeRotTime
- How much time to rot the instigator's view
- vector ShakeOffsetMag
- Max view offset vertically
- vector ShakeOffsetRate
- How fast to offset view vertically
- float ShakeOffsetTime
- How much time to offset view
AI
ONSWeapon defines the struct ONSWeaponAIInfo. These properties are hidden.
- ONSWeaponAIInfo AIInfo[2]
- FireProperties? SavedFireProperties[2]
Debugging
This property is hidden.
- string DebugInfo
Replication
The following properties are reliable if Role == ROLE_Authority and bNetDirty is true:
- HitCount
- LastHitLocation
- bActive
- bForceCenterAim
- bCallInstigatorPostRender
If in addition to the above conditions the following properties are also reliable if bNetOwner is false:
- CurrentHitLocation
- FlashCount
Functions
- int LimitPitch( int Pitch, rotator ForwardRotation, optional int WeaponYaw ) (native)
- DisplayDebug( Canvas Canvas, out float YL, out float YPos ) (simulated)
- This will draw the state of bActive, bCorrectAim and the DebugInfo String :
- PostBeginPlay() (simulated)
Calculate YawConstraintDelta
Setup Drawing of the Charging Bar
Apply Berserk Fire Modifier If APplicable?
- PostNetBeginPlay() (simulated)
Sets the weapon into a state, either InstantFireMode if bInstantFire == true or ProjectileFireMode
InitEffect
Super()
- InitEffects() (simulated)
- Attaches FlashEmitterClass and AmbientEffectEmitterClass to their locations based on WeaponFireAttachmentBone if they are != none
- SetGRI( GameReplicationInfo GRI ) (simulated)
- SetFireRateModifier( float Modifier ) (simulated)
- SpawnHitEffects( Actor HitActor, vector HitLocation, vector HitNormal )
- EMPTY
- ShakeView() (simulated)
- If the person using our ONSWeapon is a player controller call WeaponShakeView(ShakeRotMag, ShakeRotRate, SHakeRotTime, ShakeOffsetMag, ShakeOffsetRate, ShakeOffsetTime)
- ClientStartFire( Controller C, bool bAltFire ) (simulated)
- ClientStartFire() and ClientStopFire() are only called for the client that owns the weapon (and not at all for bots)
This is where force feedback is activated and OwnerEffects() is called
- ClientStopFire( Controller C, bool bWasAltFire ) (simulated)
- Stops Force Feedback and our AmbientEffectEmitter if it exists
- ClientPlayForceFeedback( String EffectName ) (simulated)
- Verify It's a Valid PlayerController And Get TO IT
- StopForceFeedback( String EffectName ) (simulated)
- Verify It's a Valid PlayerController and Get TO IT
- OwnerEffects() (simulated)
- //do effects (muzzle flash, force feedback, etc) immediately for the weapon's owner (don't wait for replication)
- rotator AdjustAim( bool bAltFire )
- This tells a bot how to line up a shot
- byte BestMode()
- AI: return the best fire mode for the situation
- Fire( Controller C )
- This Non-State Version just writes a friendly message to the logs
- AltFire( Controller C )
- This Non-State Version just writes a friendly message to the logs
- bool CanAttack( Actor Other)
- Return false if out of range, can't see target, etc.
- float MaxRange() (simulated)
- Gives a max distance for bots to use when deciding how to use a weapon.
- Projectile SpawnProjectile( class<Projectile> ProjClass, bool bAltFire )
First thing this function does is determine the spawn location, this can either be WeaponFireLocation or is computed through a collision trace if bDoOffsetTrace == true
Next the projectile is spawned, if bInheritVelocity == true then the Projectile.Velocity = Instigator.Velocity
Firing Noises are played using FireClass/AltFireClass and FireSoundRadius/AltFireSoundRadius
As i look at the code here, i notice that AltFireSoundVolume is not used here but rather FireSoundVolume/255.0 is used in both the primary and secondary firing modes.
The projectile that was spawned is returned
- CeaseFire( Controller C)
- Stops ambient sounds being played and resets Flash/Hit Count
- Destroyed() (simulated)
- Cleans up Effects (DestroyEffects()) and calls SUper()
- DestroyEffects() (simulated)
- SetTeam( byte T ) (simulated)
- Sets the current Skin to the proper teams skin
- SimulateTraceFire( out vector Start, out Rotator Dir, out vector HitLocation, out vector HitNormal ) (simulated)
- Client Side Trace, does NOT apply damage, Does predict hit locations
- TraceFire( vector Start, rotator dir )
- Does a trace and applies damage
- SpawnBeamEffect( vector Start, rotator Dir, vector HitLocation, vector HitNormal, int ReflectNum )
- EMPTY
- CalcWeaponFire() (simulated)
- Calculates the exact spot the weapon is firing From based on rotation/coords/bDualIndependentTargeting, and writes them to WeaponFireLocation and WeaponFireRotation
- float ChargeBar() (simulated)
- StaticPrecache( LevelInfo L ) (static)
Events
- ClientSpawnHitEffects() (simulated)
- bool AttemptFire( Controller C, bool bAltFire)
- Fire if we can (This means FireCountdown is <= 0)
If we can fire, we will call Fire() or AltFire()
If we can fire we will set FireCountdown to either FireInterval or AltFireInterval
If we can fire aimlock will be applied
If we can fire, we will return true
Aimlock is implemented here as AimLockReleaseTime = Level.TimeSeconds + FireCountDown*FireIntervalAimLock
- FlashMuzzleFlash() (simulated)
States
InstantFireMode
Functions
- Fire( Controller C)
- Apply Some Effects and Call TraceFire to do damage
- AltFire( Controller C)
- EMPTY
- SpawnHitEffects( Actor HitActor, vector HitLocation, vector HitNormal ) (simulated)
- Actually spawns hit effects on a client
Events
- ClientSpawnHitEffects() (simulated)
- Determines the Hit Location and Calls SpawnHitEffects()
ProjectileFireMode
- Fire( Controller C)
- Spawn the ProjectileClass()
- AltFire( Controller C )
- If the AltFireProjectileClass is None, then Fire. Otherwise, spawn the AltFireProjectileClass.
Notes
ONSWeapon sub-classes can only fire when in one of the two firing states: InstantFireMode or ProjectileFireMode. This takes place through the ONSWeapon property bInstantFire which is checked in ONSWeapon's PostNetBeginPlay() function.
Discussion
Sweavo: anyone know how to tell when the player has released the fire button? AFAICT CeaseWeaponFire doesn't happen until after the FireInterval expires...?
SuperApe: I believe there is a StopFiring() function within AIController or something. The function definitions should be separated from states and events, the words "function", "event", "simulated", etc. should be properly formatted. "var()" and "var" should be removed and the properties should be labeled as Hidden accordingly. EDIT: done.