Skip to main content

sm.projectile

Information about projectiles is located in /Data/Projectiles/projectiles.json.

Functions

customProjectileAttack

sm.projectile.customProjectileAttack( userdata, name, damage, position, velocity, source, fakePosThird, fakePosFirst, delay )
Server-Only

Performs a customized projectile attack from a player or unit.

Arguments:
  • userdata [ table ]: A table of custom user data.
  • name [ string ]: The projectile's name or uuid (name is deprecated, use uuid instead).
  • damage [ int ]: The damage that the projectile will inflict.
  • position [ Vec3 ]: The fire position.
  • velocity [ Vec3 ]: The direction and velocity.
  • source [ player/unit ]: The source of the projectile.
  • fakePosThird [ Vec3 ]: The visual start position in third-person. Defaults to position.
  • fakePosFirst [ Vec3 ]: The visual start position in first-person. Defaults to position.
  • delay [ int ]: The number of ticks before firing. Defaults to 0.

getProjectileMass

sm.projectile.getProjectileMass( name )

Returns the mass of the projectile.

Arguments:
  • name [ string ]: The projectile's name or uuid (name is deprecated, use uuid instead).
Returns:
  • [ number ]: The projectile's mass.

harvestableCustomProjectileAttack

sm.projectile.harvestableCustomProjectileAttack( userdata, name, damage, position, velocity, source, delay )
Server-Only

Performs a customized projectile attack from a harvestable.

Arguments:
  • userdata [ table ]: A table of custom user data.
  • name [ string ]: The projectile's name or uuid (name is deprecated, use uuid instead).
  • damage [ int ]: The damage that the projectile will inflict.
  • position [ Vec3 ]: The fire position.
  • velocity [ Vec3 ]: The direction and velocity.
  • source [ Harvestable ]: The source of the projectile.
  • delay [ int ]: The number of ticks before firing. Defaults to 0.

harvestableProjectileAttack

sm.projectile.harvestableProjectileAttack( name, damage, position, velocity, source, delay )

Performs a projectile attack from a harvestable.

Arguments:
  • name [ string ]: The projectile's name or uuid (name is deprecated, use uuid instead).
  • damage [ int ]: The damage that the projectile will inflict.
  • position [ Vec3 ]: The fire position.
  • velocity [ Vec3 ]: The direction and velocity.
  • source [ Harvestable ]: The source of the projectile.
  • delay [ int ]: The number of ticks before firing. Defaults to 0.

playerFire

sm.projectile.playerFire( name, position, velocity, fakePosThird, fakePosFirst, delay )
Client-Only

Creates and fires a projectile from a player.

The projectile is normally fired from the player's position,
but due to the weapon being held off-center it may require a fake position for where the projectile appears to be fired from.

Arguments:
  • name [ string ]: The projectile's name or uuid (name is deprecated, use uuid instead).
  • position [ Vec3 ]: The fire position.
  • velocity [ Vec3 ]: The direction and velocity.
  • fakePosThird [ Vec3 ]: The visual start position in third-person. Defaults to position.
  • fakePosFirst [ Vec3 ]: The visual start position in first-person. Defaults to position.
  • delay [ int ]: The number of ticks before firing. Defaults to 0.

projectileAttack

sm.projectile.projectileAttack( name, damage, position, velocity, source, fakePosThird, fakePosFirst )

Performs a projectile attack from a player or unit.

Arguments:
  • name [ string ]: The projectile's name or uuid (name is deprecated, use uuid instead).
  • damage [ int ]: The damage that the projectile will inflict.
  • position [ Vec3 ]: The fire position.
  • velocity [ Vec3 ]: The direction and velocity.
  • source [ player/unit ]: The source of the projectile.
  • fakePosThird [ Vec3 ]: The visual start position in third-person. Defaults to position.
  • fakePosFirst [ Vec3 ]: The visual start position in first-person. Defaults to position.

shapeCustomProjectileAttack

sm.projectile.shapeCustomProjectileAttack( userdata, name, damage, position, velocity, source, delay )
Server-Only

Performs a customized projectile attack from a shape.

Arguments:
  • userdata [ table ]: A table of custom user data.
  • name [ string ]: The projectile's name or uuid (name is deprecated, use uuid instead).
  • damage [ int ]: The damage that the projectile will inflict.
  • position [ Vec3 ]: The fire position.
  • velocity [ Vec3 ]: The direction and velocity.
  • source [ Shape ]: The source of the projectile.
  • delay [ int ]: The number of ticks before firing. Defaults to 0.

shapeFire

sm.projectile.shapeFire( source, name, damage, position, velocity, delay )
Server-Only

Creates and fires a projectile from a Shape.

Arguments:
  • source [ Shape ]: The source of the projectile.
  • name [ string ]: The projectile's name or uuid (name is deprecated, use uuid instead).
  • damage [ int ]: The damage that the projectile will inflict.
  • position [ Vec3 ]: The fire position.
  • velocity [ Vec3 ]: The direction and velocity.
  • delay [ int ]: The number of ticks before firing. Defaults to 0.

shapeProjectileAttack

sm.projectile.shapeProjectileAttack( name, damage, position, velocity, source, delay )

Performs a projectile attack.

Arguments:
  • name [ string ]: The projectile's name or uuid (name is deprecated, use uuid instead).
  • damage [ int ]: The damage that the projectile will inflict.
  • position [ Vec3 ]: The fire position.
  • velocity [ Vec3 ]: The direction and velocity.
  • source [ Shape ]: The source of the projectile.
  • delay [ int ]: The number of ticks before firing. Defaults to 0.

solveBallisticArc

sm.projectile.solveBallisticArc( firePos, targetPos, velocity, gravity )

Calculate the ballistic arc of a projectile. There are two potential solutions to the problem.

One with a low fire angle and one with a high fire angle. Solutions can be nil if no solution is found.

Arguments:
  • firePos [ Vec3 ]: The projectile's fire position.
  • targetPos [ Vec3 ]: The position the projectile should hit.
  • velocity [ number ]: The projectile's fire velocity.
  • gravity [ number ]: The gravity (positive down).
Returns:
  • [ Vec3 ]: The low angle solution.
  • [ Vec3 ]: The high angle solution.