Weapon¶

Weapons are fully customizable, all pieces of the weapon can be changed with immense possibility of creation
Tip
Please take a look at our Default’s Weapon package with all built-in Weapons already properly configured and ready to use: https://github.com/nanos-world/nanos-world-weapons.
Usage¶
-- spawning a AK47
local NewWeapon = Weapon(
Vector(-900, 185, 215), -- Spawn Location
Rotator(0, 90, 90), -- Spawn Rotation
"NanosWorld::SK_AK47", -- Model
0, -- Collision (Normal)
true, -- Gravity Enabled
30, -- Default Ammo in the Clip
1000, -- Default Ammo in the Bag
30, -- Clip Capacity
30, -- Base Damage
20, -- Spread
1, -- Bullet Count (1 for common weapons, > 1 for shotguns)
30, -- Ammo to Reload (Ammo Clip for common weapons, 1 for shotguns)
20000, -- Max Bullet Distance
7500, -- Bullet Speed (visual only)
Color(20, 10000, 0), -- Bullet Color
0.5, -- Sight's FOV multiplier
Vector(0, 0, -14.85), -- Sight Location
Rotator(-1, 0, 0), -- Sight Rotation
Vector(26, 0, 8.5), -- Left Hand Location
Rotator(0, 60, 90), -- Left Hand Rotation
Vector(-10, 0, 0), -- Right Hand Offset
1, -- Handling Mode (0. SingleHandedWeapon, 1. DoubleHandedWeapon, 2. SingleHandedMelee, 3. DoubleHandedMelee, 4. Throwable, 5. Torch, 6. Barrel, 7. Box)
0.15, -- Cadence (1 shot at each 0.15seconds)
true, -- Can Hold Use (keep pressing to keep firing, common to automatic weapons)
false, -- Need to release to Fire (common to Bows)
"NanosWorld::P_Bullet_Trail_System", -- Bullet Trail Particle
"NanosWorld::P_Weapon_BarrelSmoke", -- Barrel Particle
"NanosWorld::P_Weapon_Shells_762x39", -- Shells Particle
"NanosWorld::A_Rifle_Dry", -- Weapon's Dry Sound
"NanosWorld::A_Rifle_Load", -- Weapon's Load Sound
"NanosWorld::A_Rifle_Unload", -- Weapon's Unload Sound
"NanosWorld::A_AimZoom", -- Weapon's Zooming Sound
"NanosWorld::A_Rattle", -- Weapon's Aiming Sound
"NanosWorld::A_AK47_Shot", -- Weapon's Shot Sound
"NanosWorld::AM_Mannequin_Reload_Rifle", -- Character's Reloading Animation
"NanosWorld::AM_Mannequin_Sight_Fire", -- Character's Aiming Animation
"NanosWorld::SM_AK47_Mag_Empty" -- Magazine Mesh
)
Using our Default Weapons Package https://github.com/nanos-world/nanos-world-weapons (already built-in included) for spawning an AK47:
-- Includes this Package in your Package
Package:RequirePackage("NanosWorldWeapons")
-- Spawning the AK47
local my_ak47 = NanosWorldWeapons.AK47(Vector(1035, 154, 300), Rotator())
Constructor Parameters¶
Type |
Name |
Default |
Location |
Vector(0, 0, 0) |
|
Rotation |
Rotation(0, 0, 0) |
|
ModelName |
Skeletal Mesh Path |
|
CollisionType |
0 (Normal) |
|
GravityEnabled |
true |
|
AmmoClip |
32 |
|
AmmoBag |
1024 |
|
ClipCapacity |
32 |
|
BaseDamage |
30 |
|
Spread (the higher the less precision) |
20 |
|
BulletCount (how many bullets are fired at once - 1 for common weapons and >1 for shotguns) |
1 |
|
AmmoToReload (AmmoClip for common weapons, 1 for shotguns) |
32 |
|
BulletMaxDistance |
20000 |
|
BulletVelocity (visuals only) |
7500 |
|
BulletColor |
Color(10000, 20, 0) |
|
SightFOVMultiplier (amount of FOV reduced when Aiming Down Sights (ADS)) |
0.5 |
|
SightLocation (offset applied to align player’s head to weapon’s sight when ADS) |
||
SightRotation (rotation applied on the weapon when ADS) |
||
LeftHandLocation (location relative to weapon’s root to put the left hand) |
||
LeftHandRotation (rotation relative to weapon’s root to put the left hand) |
||
RightHandOffset (offset of right hand - to offset the weapon as well) |
||
HandlingMode (0. SingleHandedWeapon, 1. DoubleHandedWeapon, 2. SingleHandedMelee, 3. DoubleHandedMelee, 4. Throwable, 5. Torch) |
0 |
|
Cadence (frequency of shots in seconds) |
0.15 |
|
CanHoldUse (enables keep holding to keep firing) |
true |
|
ReleaseToShot (needs to release the fire button to shot) |
false |
|
BulletTrailParticle (particle of bullet trail) |
||
BarrelParticle (particle of muzzle fire effect) |
||
ShellsParticle (particle of shells being spit out) |
||
DrySound (sound when weapon is dry) |
||
LoadSound |
||
UnloadSound |
||
ZoomingSound (sound when switching aimings (wheel mouse)) |
||
AimingSound (sound when going from no aim to aiming) |
||
ShotSound |
||
CharacterReloadingAnimation |
||
CharacterAimingAnimation |
||
MagazineMesh (mesh used when reloading) |
Static Mesh Path |
Properties¶
Type |
Name |
Description |
|
BaseDamage |
Weapon’s Base Damage |
||
Cadence |
Speed of shots (1 shot at each |
||
ClipCapacity |
Weapon’s Clip Capacity |
||
SightFOVMultiplier |
Amount of FOV reduced when Aiming Down Sights (ADS) |
||
Spread |
The higher the less precision |
Functions¶
Returns |
Name |
Description |
|
SetAmmoBag(number NewAmmo) |
Sets this Weapon’s Ammo Bag |
||
SetAmmoClip(number NewAmmo) |
Sets this Weapon’s Ammo Clip |
||
SetBulletColor(Color Color) |
Bullet Color |
||
Left Hand Offset |
|||
SetRightHandOffset(Vector Offset) |
Offset of Right Hand |
||
Offset applied to align player’s head to weapon’s sight and rotation applied on the weapon when ADS |
|||
GetAmmoBag() |
Gets this Weapon’s Ammo Bag |
||
GetAmmoClip() |
Gets this Weapon’s Ammo Clip |
||
GetBulletColor() |
|||
GetRightHandOffset() |
Functions (Inherited from Pickable)¶
Returns |
Name |
Description |
|
Spawns and Attaches a SkeletalMesh into this Actor, the SkeletalMesh must have the same Skeletal used by this Actor Mesh, and will follow all animations from it. Uses a custom ID to be used for removing it further |
|||
AddStaticMeshAttached(string ID, string StaticMeshPath, string Socket = “”, Vector RelativeLocation = Vector(), Rotator RelativeRotation = Rotator()) |
Spawns and Attaches a StaticMesh into this Actor in a Socket with relative Location and Rotation. Uses a custom ID to be used for removing it further |
||
PullUse() |
Force this Pickable to be used (e.g. if this is a Weapon, will fire) |
||
ReleaseUse() |
Force this Pickable to be released the usage |
||
RemoveSkeletalMeshAttached(string ID) |
Removes, if existing, a SkeletalMesh from this Actor given it’s custom ID |
||
RemoveStaticMeshAttached(string ID) |
Removes, if existing, a StaticMesh from this Actor given it’s custom ID |
||
GetAssetName() |
Gets the Asset name |
||
GetHandler() |
Gets the Character (if existing) which is holding this |
Functions (Inherited from Actor)¶
Returns |
Name |
Description |
|
AddImpulse(Vector Force) |
Applies a Force in world coordinate on this Actor (the force is applied on Client side, by the (in most of cases) the closest player of this object) |
||
AttachTo(Actor Other, string BoneName, Vector RelativeLocation, Rotator RelativeRotation) |
Attaches this Actor to any other Actor with a Relative Offset/Rotation |
||
Destroy() |
Destroys this Actor |
||
SetCollision(number CollisionType) |
Sets the actor’s collision (0 - Normal, 1 - Static Only, 2 - No Collision) |
||
SetGravityEnabled(boolean NewGravity) |
Sets the actor’s gravity enabled |
||
SetHighlightEnabled(boolean Enabled) |
Sets if this Actors is Highlighting |
||
SetInitialLocation(Vector NewInitialLocation) |
Sets the initial location |
||
SetLocation(Vector NewLocation) |
Sets the actor’s location in the game world |
||
SetRotation(Rotator NewRotation) |
Sets the actor’s rotation in the game world |
||
SetScale(Vector Scale) |
Sets the actor’s scale |
||
SetTintColor(Color NewTintColor) |
Sets the tint color, for completely paint an object, multiply the color by 10 or 100 |
||
SetValue(string Key, any Value) |
Sets a value in this entity, which can be accessed by any package (local only) |
||
Smoothly moves this actor to a Location with a certain Speed |
|||
Smoothly rotates this actor to a Rotation with a certain Speed |
|||
IsGravityEnabled() |
Gets the actor’s gravity enabled |
||
IsValid() |
Returns if this is Valid |
||
GetCollision() |
Gets the current actor’s collision |
||
GetID() |
Gets the network ID of this entity (same in both client and server) |
||
GetLocation() |
Get the actor’s position in the game world |
||
GetInitialLocation() |
Gets the initial location |
||
GetRotation() |
Gets the actor’s rotation in the game world |
||
GetScale() |
Gets the actor’s scale |
||
GetTintColor() |
Gets the Tint Color |
||
GetType() |
Returns the type of this Actor |
||
any |
GetValue(string Key) |
Gets a value given a key |
|
GetVelocity() |
Returns the current actor Velocity |
Events¶
Name |
Arguments |
Description |
|
Fire |
When this weapon is fired |
||
Reload |
When this weapon is reloaded, optionally by a Character |
Events (Inherited from Pickable)¶
Name |
Arguments |
Description |
|
Drop |
Entity pickable, Character character, boolean WasTriggeredByPlayer |
When a Character drops this |
|
Hit |
Entity pickable, number Intensity |
When this Entity hits something |
|
PickUp |
Entity pickable, Character character |
When a Character picks up this |
Events (Inherited from Actor)¶
Name |
Arguments |
Description |
|
Destroy |
Entity actor |
Triggered when an Entity is Destroyed |
|
Spawn |
Entity actor |
Triggered when an Entity is Spawned/Created |