MF_AbstractWeapon
Base class for weapon scripts. And also provides a common point of reference for certain variables used by other scripts.
Public Variables
shotSound : AudioSource
Points to the AudioSource object and will play when the gun fires.
inaccuracy : float
The error radius in degrees of fired shots.
shotSpeed : float
The velocity the shot will travel at. This value will also be given to the platform when computing an intercept path.
maxRange : float
The maximum distance the shot is to travel before expiring.
shotDuration : float
The maximum time before the shot expires.
shotSpeed, maxRange, and shotDuration are mathematically linked. You only need to supply two of the three values, and the third will be computed. If all three values are supplied, shotDuration will still be overwritten based on shotSpeed and maxRange to eliminate any inconsistency.
cycleTime : float
The time in seconds time between fired shots.
burstAmount : int
The number of shots fired before burstResetTime is triggered.
burstResetTime : float
The delay in seconds before burstAmount resets. The greater value of cycleTime and burstResetTime will be the delay used. This should also be less than reloadTime, as reloadTime will take precedence if they both occur on the same shot.
shotsPerRound : int
How many shots are fired per ammo point and per Shoot() command. This is like a shotgun blast.
maxAmmoCount : int
The maximum ammo load of the weapon. When this reaches 0, reloadTime begins and will replenish the ammo of the weapon.
unlimitedAmmo : bool
The weapon doesn’t need ammo, and doesn’t use ammo, but burstAmount and burstResetTime still affect the weapon.
reloadTime : float
The time in seconds it takes to refill the ammo load of the weapon.
dontReload : bool
This weapon never replenishes its ammo when it runs out.
active : bool
If set to false, this weapon won't fire, and will be skipped in rotation in MF_B_TurretControl. This can be used to create weapon toggle scripts for turrets with more than one weapon.
aimTolerance : float
Extra radius in degrees the weapon reads to the target size. This allows the weapon to fire at a target even if it’s not aimed perfectly. This can compensate for weapon inaccuracy and versus targets that change direction quickly. If negative, this will cause targeting to be more restricted to the center of the target.
aimTime : float
Time that platform must be aimed at a target before firing. Counts up when has a valid firing solution, and counts down when it doesn't.
requireAngle : bool
This weapon requires angle data on the target in order to fire.
requireRange : bool
This weapon requires range data on the target in order to fire.
requireVelocity : bool
This weapon requires velocity data on the target in order to fire.
requirePrecision : bool
This weapon requires precision data on the target in order to fire. Precision is a quality-of-data concept used to simulate a distinction between generalized or estimated data, and precise data.
exits : GunExit[] class { transform : Transform, particleComponent : ParticleSystem }
Weapons may have more than one exit point. This array holds all the exit transforms of a single weapon. This is particularly useful for missile banks.
particleComponent will be used as a muzzle flash. It will accept a reference to an object in the hierarchy, or a prefab. If it’s a prefab, it will be instantiated at runtime.
Hidden Variables
platformVelocity : Vector3
This is the velocity of the unit, and will be set from a control script to be imparted to fired shots.
curAmmoCount : int
Amount of remaining ammo.
curBurstCount : int
Number of shots remaining in the burst.
curExit : int
Current exit index of the weapon next to fire.
curInaccuracy : float
Current inaccuracy of the weapon.
bursting : bool
True, when the weapon is performing a full burst of fire.
delay : float
The total delay before the next shot can fire. Includes cycleTime, and any burstResetTime, or reloadTime, that may apply.
Public Methods
Shoot : void ()
Call this method when the weapon should shoot. It will internally call ReadyCheck() before trying to fire, and won’t shoot if the weapon isn’t ready.
ShootBurst : void ()
Similar to Shoot(), except it will continue to fire until curBurstCount is 0. The weapon will not process any other shoot commands, and ReadyCheck() will return false until the weapon has completed the burst.
DoFire : void ()
Use if you’ve already called ReadyCheck(), and want the weapon to fire without first checking if it’s ready. This will cause the weapon to shoot even if it shouldn’t be able to fire, such as being out of ammo.
ReadyCheck : bool ()
Returns true if the weapon is ready to fire. Will return false if it is still cycling between shots, waiting for a reload or burst reload to finish, or if it is out of ammo.
AimCheck : bool ( target : Transform, targetSize : float )
Determines if the weapon is aimed to hit the given target that has a size of targetSize. This will also take into account the weapon’s aimTolerance.
Does not account for intercept or ballistics. Normally you would use the AimCheck() that appears in a platform script.
RangeCheck : bool ( target : Transform )
RangeCheck : bool ( target : Transform, mult : float )
Always returns true. However, this method is overridden by weapon scripts for results specific to a weapon.
Base class for weapon scripts. And also provides a common point of reference for certain variables used by other scripts.
Public Variables
shotSound : AudioSource
Points to the AudioSource object and will play when the gun fires.
inaccuracy : float
The error radius in degrees of fired shots.
shotSpeed : float
The velocity the shot will travel at. This value will also be given to the platform when computing an intercept path.
maxRange : float
The maximum distance the shot is to travel before expiring.
shotDuration : float
The maximum time before the shot expires.
shotSpeed, maxRange, and shotDuration are mathematically linked. You only need to supply two of the three values, and the third will be computed. If all three values are supplied, shotDuration will still be overwritten based on shotSpeed and maxRange to eliminate any inconsistency.
cycleTime : float
The time in seconds time between fired shots.
burstAmount : int
The number of shots fired before burstResetTime is triggered.
burstResetTime : float
The delay in seconds before burstAmount resets. The greater value of cycleTime and burstResetTime will be the delay used. This should also be less than reloadTime, as reloadTime will take precedence if they both occur on the same shot.
shotsPerRound : int
How many shots are fired per ammo point and per Shoot() command. This is like a shotgun blast.
maxAmmoCount : int
The maximum ammo load of the weapon. When this reaches 0, reloadTime begins and will replenish the ammo of the weapon.
unlimitedAmmo : bool
The weapon doesn’t need ammo, and doesn’t use ammo, but burstAmount and burstResetTime still affect the weapon.
reloadTime : float
The time in seconds it takes to refill the ammo load of the weapon.
dontReload : bool
This weapon never replenishes its ammo when it runs out.
active : bool
If set to false, this weapon won't fire, and will be skipped in rotation in MF_B_TurretControl. This can be used to create weapon toggle scripts for turrets with more than one weapon.
aimTolerance : float
Extra radius in degrees the weapon reads to the target size. This allows the weapon to fire at a target even if it’s not aimed perfectly. This can compensate for weapon inaccuracy and versus targets that change direction quickly. If negative, this will cause targeting to be more restricted to the center of the target.
aimTime : float
Time that platform must be aimed at a target before firing. Counts up when has a valid firing solution, and counts down when it doesn't.
requireAngle : bool
This weapon requires angle data on the target in order to fire.
requireRange : bool
This weapon requires range data on the target in order to fire.
requireVelocity : bool
This weapon requires velocity data on the target in order to fire.
requirePrecision : bool
This weapon requires precision data on the target in order to fire. Precision is a quality-of-data concept used to simulate a distinction between generalized or estimated data, and precise data.
exits : GunExit[] class { transform : Transform, particleComponent : ParticleSystem }
Weapons may have more than one exit point. This array holds all the exit transforms of a single weapon. This is particularly useful for missile banks.
particleComponent will be used as a muzzle flash. It will accept a reference to an object in the hierarchy, or a prefab. If it’s a prefab, it will be instantiated at runtime.
Hidden Variables
platformVelocity : Vector3
This is the velocity of the unit, and will be set from a control script to be imparted to fired shots.
curAmmoCount : int
Amount of remaining ammo.
curBurstCount : int
Number of shots remaining in the burst.
curExit : int
Current exit index of the weapon next to fire.
curInaccuracy : float
Current inaccuracy of the weapon.
bursting : bool
True, when the weapon is performing a full burst of fire.
delay : float
The total delay before the next shot can fire. Includes cycleTime, and any burstResetTime, or reloadTime, that may apply.
Public Methods
Shoot : void ()
Call this method when the weapon should shoot. It will internally call ReadyCheck() before trying to fire, and won’t shoot if the weapon isn’t ready.
ShootBurst : void ()
Similar to Shoot(), except it will continue to fire until curBurstCount is 0. The weapon will not process any other shoot commands, and ReadyCheck() will return false until the weapon has completed the burst.
DoFire : void ()
Use if you’ve already called ReadyCheck(), and want the weapon to fire without first checking if it’s ready. This will cause the weapon to shoot even if it shouldn’t be able to fire, such as being out of ammo.
ReadyCheck : bool ()
Returns true if the weapon is ready to fire. Will return false if it is still cycling between shots, waiting for a reload or burst reload to finish, or if it is out of ammo.
AimCheck : bool ( target : Transform, targetSize : float )
Determines if the weapon is aimed to hit the given target that has a size of targetSize. This will also take into account the weapon’s aimTolerance.
Does not account for intercept or ballistics. Normally you would use the AimCheck() that appears in a platform script.
RangeCheck : bool ( target : Transform )
RangeCheck : bool ( target : Transform, mult : float )
Always returns true. However, this method is overridden by weapon scripts for results specific to a weapon.