Legacy:ONSWeapon: Difference between revisions

From Unreal Wiki, The Unreal Engine Documentation Site
Sweavo (talk | contribs)
No edit summary
 
SuperApe (talk | contribs)
mNo edit summary
 
(One intermediate revision by the same user not shown)
Line 1: Line 1:
{{classbox| [[Legacy:UT2004|UT2004]] :: [[Legacy:Actor|Actor]] >> ONSWeapon}}
{{classbox| [[Legacy:UT2004|UT2004]] :: [[Legacy:Actor|Actor]] >> ONSWeapon (Package: Onslaught)}}


==Summary ==
This is the non-placable parent class of all of the vehicle and turret weapons found in the Onslaught [[Legacy:Gametype|Gametype]].


This is the base class of all of the vehicle and turret weapons found in the Onslaught Gametype.
==Properties==


Something to note about all ONSWeapon sub-classes is that they only can fire when in one of the firing states. InstantFireMode or ProjectileFireMode. This takes place through the ONSWeapon property bInstantFire which is checked in ONSWeapon's PostNetBeginPlay() function to goto one of the two states.
===Weapon Bone Rotation System===


==Properties ==
====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 :


===Weapon Bone Rotation System ===
====Hidden====
; var() name YawBone :
; float YawConstraintDelta :
; var() float YawStartConstraint :
; rotator CurrentAim :
; var() float YawEndConstraint :
; vector WeaponFireLocation : written by CalcWeaponFire
; var float YawConstraintDelta :
; rotator WeaponFireRotation :  written by CalcWeaponFire
; var() name PitchBone :
; var() int PitchUpLimit :
; var() int PitchDownLimit :
; var rotator CurrentAim :
; var vector WeaponFireLocation : written by CalcWeaponFire
; var rotator WeaponFireRotation :  written by CalcWeaponFire


; var() name WeaponFireAttachmentBone :
===Flags===
; var() name GunnerAttachmentBone :
; var() float WeaponFireOffset :
; var() float DualFireOffset : If your weapon has twin muzzles, e.g. Energy Turret and Raptor, this causes shots to alternate from each barrel.
; var() vector WeaponOffset


; var() rotator LastRotation :
====Main====
; var() float RotationsPerSecond :
; 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?


===Bools ===
====Hidden====
; var bool bInstant Rotation : //NOTE: Gradual rotation via RotationsPerSecond still used for non-owning net clients to smooth rotation changes
; bool bInstantRotation : NOTE: Gradual rotation via RotationsPerSecond still used for non-owning net clients to smooth rotation changes
; var bool bActive :
; bool bActive :
; var() bool bInstantFire : As Noted Above specifies InstantFireState instead of ProjectileFireState for the generic weapon firing code to use.
; bool bShowChargingBar : Bender Style?
; var() bool bDualIndependantTargeting : // When using a DualFireOffset each shot will be independantly targeted at the crosshair
; bool bCallInstigatorPostRender : If Instigator exists, during this actor's native PostRender(), call Instigator->PostRender() (used when weapon is visible but owner is bHidden)
; var bool bShowChargingBar : Bender Style?
; bool bForceCenterAim : Not Used on The Goliath?
; var bool bCallInstigatorPostRender ://if Instigator exists, during this actor's native PostRender(), call Instigator->PostRender() (used when weapon is visible but owner is bHidden)
; bool bDoOffsetTrace : Trace from outside vehicle's collision back towards weapon to determine firing offset.  Probably Another Goliathy Type Feature
; var    bool   bForceCenterAim : Not Used on The Goliath?
; bool bIsAltFire :
; var()  bool    bAimable : Determines whether the weapon can be physically turned by the player (i.e. turret rotation or gun barrel pitch).
; bool bIsRepeatingFF :
; var bool bDoOffsetTrace : //trace from outside vehicle's collision back towards weapon to determine firing offset
; bool bCorrectAim (out, native, const) : Indicates gun can hit what controller is aiming at


Probably Another Goliathy Type Feature
===Aiming===
; var() bool bAmbientFireSound :
; var() bool bAmbientAltFireSound :
; var() bool bInheritVelocity :
; var bool bIsAltFire :
; var bool bIsRepeatingFF :
; var() bool bReflective : Can be reflected by shield gun shield?
; var const bool bCorrectAim : // output variable - set natively - means gun can hit what controller is aiming at


===Aiming ===
====Main====
; var() float FireIntervalAimLock : //fraction of FireInterval/AltFireInterval during which you can't move the gun
; float FireIntervalAimLock : Fraction of FireInterval/AltFireInterval during which you can't move the gun
; var float AimLockReleaseTime : //when this time is reached gun can move again
; var vector CurrentHitLocation :
; var float Spread :
; var float AimTraceRange :


===Impact/Damage ===
====Hidden====
; var vector LastHitLocation :
; float AimLockReleaseTime : When this time is reached gun can move again
; var byte FlashCount :
; vector CurrentHitLocation :
; var byte OldFlashCount :
; float Spread :
; var byte HitCount :
; float AimTraceRange :
; var byte OldHitCount :


===Team Skins ===
===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 :
; var byte Team :
; var() Material RedSkin :
; Var() Material BlueSkin :


===Timing ===
===Timing===
; var() float FireInterval, AltFireInterval :
 
; var float FireCountDown :
====Main====
; float FireInterval, AltFireInterval :
 
====Hidden====
; float FireCountDown :
 
===Effects===


===Effects ===
====Main====
; var() class<Emitter> FlashEmitterClass :
; class<[[Legacy:Emitter|Emitter]]> FlashEmitterClass :
; var Emitter FlashEmitter :
; class<[[Legacy:Emitter|Emitter]]> EffectEmitterClass :
; var() class<Emitter> EffectEmitterClass :
; class<[[Legacy:ONSWeaponAmbientEmitter|ONSWeaponAmbientEmitter]]> AmbientEffectEmitterClass :
; var Emitter EffectEmitter :
; var() class<ONSWeaponAmbientEmitter> AmbientEffectEmitterClass :
; var ONSWeaponAmbientEmitter AmbientEffectEmitter :


===Sound ===
====Hidden====
; var() sound FireSoundClass :
; [[Legacy:Emitter|Emitter]] FlashEmitter :
; var() float FireSoundVolume :
; [[Legacy:Emitter|Emitter]] EffectEmitter :
; var() float FireSoundRadius :
; [[Legacy:ONSWeaponAmbientEmitter|ONSWeaponAmbientEmitter]] AmbientEffectEmitter :
; var() float FireSoundPitch :
; var() sound AltFireSoundClass :
; var() float AltFireSoundVolume :
; var() float AltFireSoundRadius :
; var() float AltFireSoundPitch : Why ISN'T this here? :0
; var() float AmbientSoundScaling :


===Force Feedback ===
===Sound===
; var() string FireForce :
; var() string AltFireForce :


===Instant Fire Stuff ===
Each of these properties are available to edit.
; var class<DamageType> DamageType :
; sound FireSoundClass :
; var int DamageMin, DamageMax : Instant Hits work by applying damage as RealDamage = DamageMin + Rand(DamageMax-DamageMin)
; float FireSoundVolume :
; var float TraceRange :
; float FireSoundRadius :
; var float Momentum :
; float FireSoundPitch :
; sound AltFireSoundClass :
; float AltFireSoundVolume :
; float AltFireSoundRadius :
; float AltFireSoundPitch : Why ISN'T this here? :0
; float AmbientSoundScaling :


===Projectile Fire Stuff ===
===Force Feedback===
; var() class<Projectile> ProjectileClass :
; var() class<Projectile> AltFireProjectileClass :
; var 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.
; var() vector ShakeRotMag :            // how far to rot view
; string FireForce :
; var() vector            ShakeRotRate:          // how fast to rot view
; string AltFireForce :
; var() float            ShakeRotTime:        // how much time to rot the instigator's view
; var() vector            ShakeOffsetMag:        // max view offset vertically
; var() vector            ShakeOffsetRate:       // how fast to offset view vertically
; var() float            ShakeOffsetTime:       // how much time to offset view


===AI ===
===Instant Fire Stuff===


ONSWeapon defines the struct [[Legacy:ONSWeaponAIInfo|ONSWeaponAIInfo]]
Each of these properties are hidden.
; var ONSWeaponAIInfo AIInfo[2] :
; class<[[Legacy:DamageType|DamageType]]> DamageType :
; varFireProperties SavedFireProperties[2] :
; int DamageMin, DamageMax : Instant Hits work by applying damage as RealDamage = DamageMin + Rand(DamageMax-DamageMin)
; float TraceRange :
; float Momentum :


===DEBUGGING ===
===Projectile Fire Stuff===
; var string DebugInfo :


==Replication ==
====Main====
; class<[[Legacy:Projectile|Projectile]]> ProjectileClass :
; class<[[Legacy:Projectile|Projectile]]> AltFireProjectileClass :


I am still pretty lost when it comes to replication. An explanation of what this says would be nice though.
====Hidden====
; array<[[Legacy:Projectile|Projectile]]> Projectiles : Ignore these when doing third person aiming trace (only necessary if projectiles fired have bProjTarget==true)


<uscript>
===Camera Shakes===
replication
{
    reliable if (bNetDirty && !bNetOwner && Role == ROLE_Authority)
        CurrentHitLocation, FlashCount;
    reliable if (bNetDirty && Role == ROLE_Authority)
        HitCount, LastHitLocation, bActive, bForceCenterAim, bCallInstigatorPostRender, Team;
}
</uscript>


==Functions ==
Each of these properties are available to edit.
; native function int LimitPitch(int Pitch, rotator ForwardRotation, optional int WeaponYaw) :
; vector ShakeRotMag : How far to rot view
; simulated function DisplayDebug(Canvas Canvas, out float YL, out float YPos) : This will draw the state of bActive, bCorrectAim and the DebugInfo String :
; vector ShakeRotRate: How fast to rot view
; simulated function PostBeginPlay() :  
; 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 [[Legacy:ONSWeaponAIInfo|ONSWeaponAIInfo]].  These properties are hidden.
; [[Legacy:ONSWeaponAIInfo|ONSWeaponAIInfo]] AIInfo[2] :
; [[Legacy:FireProperties|FireProperties]] SavedFireProperties[2] :
 
===Debugging===
 
This property is hidden.
; string DebugInfo :
 
==Replication==
 
The following properties are '''reliable if''' <tt>Role == ROLE_Authority</tt> and <tt>bNetDirty</tt> is true:
; HitCount
; LastHitLocation
; bActive
; bForceCenterAim
; bCallInstigatorPostRender
 
If in addition to the above conditions the following properties are also '''reliable if''' <tt>bNetOwner</tt> is false:
; CurrentHitLocation
; FlashCount
 
==Functions==
; int LimitPitch( int Pitch, rotator ForwardRotation, optional int WeaponYaw ) (native) :
; DisplayDebug( [[Legacy:Canvas|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  
:::Calculate YawConstraintDelta  
:::Setup Drawing of the Charging Bar  
:::Setup Drawing of the Charging Bar  
:::Apply Berserk Fire Modifier If APplicable?
:::Apply Berserk Fire Modifier If APplicable?
; simulated function PostNetBeginPlay() :  
; PostNetBeginPlay() (simulated) :  
:::Sets the weapon into a state, either InstantFireMode if bInstantFire == true or ProjectileFireMode
:::Sets the weapon into a state, either InstantFireMode if bInstantFire == true or ProjectileFireMode
:::InitEffect  
:::InitEffect  
:::Super()
:::Super()
; simulated function InitEffects() : Attaches FlashEmitterClass and AmbientEffectEmitterClass to their locations based on WeaponFireAttachmentBone if they are != none
; InitEffects() (simulated) : Attaches FlashEmitterClass and AmbientEffectEmitterClass to their locations based on WeaponFireAttachmentBone if they are != none
; simulated function SetGRI(GameReplicationInfo GRI) :
; SetGRI( [[Legacy:GameReplicationInfo|GameReplicationInfo]] GRI ) (simulated) :
; simulated function SetFireRateModifier(float Modifier) :
; SetFireRateModifier( float Modifier ) (simulated) :
; function SpawnHitEffects(actor HitActor, vector HitLocation, vector HitNormal ) : EMPTY
; SpawnHitEffects( [[Legacy:Actor|Actor]] HitActor, vector HitLocation, vector HitNormal ) : EMPTY
; simulated event ClientSpawnHitEffects() :
; ShakeView() (simulated) : If the person using our ONSWeapon is a player controller call WeaponShakeView(ShakeRotMag, ShakeRotRate, SHakeRotTime, ShakeOffsetMag, ShakeOffsetRate, ShakeOffsetTime)
; simulated function ShakeView() : If the person using our ONSWeapon is a player controller call WeaponShakeView(ShakeRotMag, ShakeRotRate, SHakeRotTime, ShakeOffsetMag, ShakeOffsetRate, ShakeOffsetTime)
; ClientStartFire( [[Legacy:Controller|Controller]] C, bool bAltFire ) (simulated) : ClientStartFire() and ClientStopFire() are only called for the client that owns the weapon (and not at all for bots)
; simulated function ClientStartFire(Controller C, bool bAltFire) : //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
:: This is where force feedback is activated and OwnerEffects() is called
; simulated function ClientStopFire(Controller C, bool bWasAltFire) : Stops Force Feedback and our AmbientEffectEmitter if it exists  
; ClientStopFire( [[Legacy:Controller|Controller]] C, bool bWasAltFire ) (simulated) : Stops Force Feedback and our AmbientEffectEmitter if it exists  
; simulated function ClientPlayForceFeedback( String EffectName ) : Verify It's a Valid PlayerController And Get TO IT
; ClientPlayForceFeedback( String EffectName ) (simulated) : Verify It's a Valid PlayerController And Get TO IT
; simulated function StopForceFeedback( String EffectName ) : Verify It's a Valid PlayerController and Get TO IT
; StopForceFeedback( String EffectName ) (simulated) : Verify It's a Valid PlayerController and Get TO IT
; simulated event OwnerEffects() : //do effects (muzzle flash, force feedback, etc) immediately for the weapon's owner (don't wait for replication)
; OwnerEffects() (simulated) : //do effects (muzzle flash, force feedback, etc) immediately for the weapon's owner (don't wait for replication)
; event bool AttemptFire(Controller C, bool bAltFire) : Fire if we can (This means FireCountdown is <= 0)  
; 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( [[Legacy:Controller|Controller]] C ) : This Non-State Version just writes a friendly message to the logs
; AltFire( [[Legacy:Controller|Controller]] C ) : This Non-State Version just writes a friendly message to the logs
; bool CanAttack( [[Legacy:Actor|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.
; [[Legacy:Projectile|Projectile]] SpawnProjectile( class<[[Legacy:Projectile|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( [[Legacy:Controller|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( [[Legacy:LevelInfo|LevelInfo]] L ) (static) :
 
==Events==
; ClientSpawnHitEffects() (simulated) :
; bool AttemptFire( [[Legacy:Controller|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 call Fire() or AltFire()
::: If we can fire we will set FireCountdown to either FireInterval or AltFireInterval
::: If we can fire we will set FireCountdown to either FireInterval or AltFireInterval
Line 167: Line 222:
::: If we can fire, we will return true
::: If we can fire, we will return true
::: Aimlock is implemented here as AimLockReleaseTime = Level.TimeSeconds + FireCountDown*FireIntervalAimLock
::: Aimlock is implemented here as AimLockReleaseTime = Level.TimeSeconds + FireCountDown*FireIntervalAimLock
; function rotator AdjustAim(bool bAltFire) : This tells a bot how to line up a shot
; FlashMuzzleFlash() (simulated) :
; function byte BestMode() : //AI: return the best fire mode for the situation
 
; function Fire( Controller C ) : This Non-State Version just writes a friendly message to the logs
==States==
; function AltFire( Controller C ) : This Non-State Version just writes a friendly message to the logs
 
; function bool CanAttack(Actor Other) : // return false if out of range, can't see target, etc.
===InstantFireMode===
; simulated function float MaxRange() : Gives a max distance for bots to use when deciding how to use a weapon.
; function 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
; function CeaseFire(Controller C) : Stops ambient sounds being played and resets Flash/Hit Count
; simulated event FlashMuzzleFlash() :
; simulated function Destroyed() : Cleans up Effects (DestroyEffects()) and calls SUper()
; simulated function DestroyEffects() :
; simulated function SetTeam( byte T ) : Sets the current Skin to the proper teams skin
; simulated function SimulateTraceFire( out vector Start, out Rotator Dir, out vector HitLocation, out vector HitNormal ) :  Client Side Trace, does NOT apply damage, Does predict hit locations
; function TraceFire( Vector Start, rotator dir ) : Does a trace and applies damage
; function SpawnBeamEffect(Vector Start, Rotator Dir, Vector HitLocation, Vector HitNormal, int ReflectNum) : EMPTY
; simulated function CalcWeaponFire() : Calculates the exact spot the weapon is firing From based on rotation/coords/bDualIndependentTargeting, and writes them to WeaponFireLocation and WeaponFireRotation
; simulated function float ChargeBar() :
; static function StaticPrecache( LevelInfo L ) :


==States ==
====Functions====
; Fire( [[Legacy:Controller|Controller]] C) : Apply Some Effects and Call TraceFire to do damage
; AltFire( [[Legacy:Controller|Controller]] C) : EMPTY
; SpawnHitEffects( [[Legacy:Actor|Actor]] HitActor, vector HitLocation, vector HitNormal ) (simulated) : Actually spawns hit effects on a client


===InstantFireMode ===
====Events====
; function Fire(Controller C) : Apply Some Effects and Call TraceFire to do damage
; ClientSpawnHitEffects() (simulated) : Determines the Hit Location and Calls SpawnHitEffects()
; function AltFire(Controller C) : EMPTY
; simulated event ClientSpawnHitEffects() : Determines the Hit Location and Calls SpawnHitEffects()
; simulated function SpawnHitEffects( actor HitActor, vector HitLocation, vector HitNormal ) : Actually spawns hit effects on a client


===ProjectileFireMode ===
===ProjectileFireMode===
; function Fire(Controller C) : <uscript>SpawnProjectile(ProjectileClass, false)</uscript>
; Fire( [[Legacy:Controller|Controller]] C) : Spawn the ProjectileClass()
; function AltFire( Controller C ) : <uscript> if (AltFireProjectileClass == None)
; AltFire( [[Legacy:Controller|Controller]] C ) : If the AltFireProjectileClass is None, then Fire.  Otherwise, spawn the AltFireProjectileClass.
            Fire(C);
        else
            SpawnProjectile(AltFireProjectileClass, True);</uscript>


==Default Properties ==
==Notes==


<uscript>
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.
defaultproperties
{
    YawEndConstraint=65535.000000
    PitchUpLimit=5000
    PitchDownLimit=60000
    RotationsPerSecond=0.750000
    bAimable=True
    bCorrectAim=True
    FireInterval=0.500000
    FireSoundVolume=160.000000
    FireSoundRadius=300.000000
    FireSoundPitch=1.000000
    AltFireSoundVolume=160.000000
    AltFireSoundRadius=300.000000
    AmbientSoundScaling=1.000000
    DamageType=XWeapons.DamTypeMinigunBullet
    DamageMin=6
    DamageMax=6
    TraceRange=10000.000000
    Momentum=1.000000
    AIInfo(0)=(aimerror=600.000000,RefireRate=0.900000)
    AIInfo(1)=(aimerror=600.000000,RefireRate=0.900000)
    DrawType=DT_Mesh
    bIgnoreEncroachers=True
    bReplicateInstigator=True
    RemoteRole=ROLE_SimulatedProxy
    NetUpdateFrequency=5.000000
    SoundVolume=255
    SoundRadius=100.000000
    bBlockZeroExtentTraces=False
    bBlockNonZeroExtentTraces=False
    bNoRepMesh=True
}
</uscript>


==Discussion==
==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...?
'''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.


[[Category:Legacy Class (UT2004)|{{PAGENAME}}]]
[[Category:Legacy Class (UT2004)|{{PAGENAME}}]]

Latest revision as of 12:59, 31 December 2005

UT2004 :: Actor >> ONSWeapon (Package: Onslaught)

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

Emitter FlashEmitter
Emitter EffectEmitter
ONSWeaponAmbientEmitter AmbientEffectEmitter

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.