Weapons


Weapons are composed of two parts: the first person view weapon that players use and a sprite to represent the item you pickup and store in your inventory.
Please refer to the sprites section for more information on sprites.

Weapon item sprite script file content example

// Every script operation must end with a semicolon. Spaces or line returns are ignored.;
// Base game sprite file names are a number, so only use non-number names to add new sprite. Ex: BlueChicken.txt;
// Don't put spaces in file names.;
// This file contains only a small subset of all possible sprite commands. To make your own sprite, take a similar existing one and copy its script file.;

// This sprite script is for the item corresponding to the Chicken Garand weapon.;

// If true, the sprite will be placed on the ground after being created.;
placeOnGround = false;

// Init is the main sprite-creation command. It requires some commands to be called before it and others after it.;
// definition: Init(Sprite scale vector(scale x, scale y, scale z), material, movement type, collision type, destructible type, activation type);
// It's possible to randomly choose a material by adding multiple ones separated by ':'. Example: 15:BlueChickenMaterial:33:PotatoMaterial;
// Movement types;
// 0 : No movement (but can be moved);
// 1 : Projectile;
// 2 : Enemy;
// 3 : Static (cannot be moved at all);
// 4 : Physics (bouncing);
// Collision types;
// 0 : No collisions;
// 1 : The flat mesh has collisions;
// 2 : The capsule shape around the sprite has collisions;
// 3 : Overlap (don't use);
// Destruction types;
// 0 : Can't be destroyed;
// 1 : Disappears on destruction;
// 2 : Explodes (not used, becomes 1);
// 3 : Slice (not used, becomes 1);
// 4 : Falls down like a flat mesh;
// 5 : Context (depends on how the destruction happened. Mostly for enemies);
// Activation types;
// 0 : Can't be activated;
// 1 : Can only be activated once;
// 2 : Can be activated infinitely;
// 3 : This is a switch;
Init(vector(1.2,1.2,1.2), itemChickenGarandMaterial, 0, 2, 1, 0);

// AI is a subject on its own. Please check the AI section in the modding documentation at https://blazingbitgames.com/mods ;
// This calls the ADD_POTENTIAL_SECRET_ITEM AI command.;
ai.AddNode(364, -1.0, -1.0, 0);

// This calls the KILL_IF_CLOSE AI command which starts after 0.5 seconds and stays active.;
ai.AddNode(2, 0.5, -1.0, 3, 100.0, 0.0, 0.0);

// This calls the FOLLOW_PLAYER AI command which starts after 0.5 seconds and stays active.;
ai.AddNode(0, 0.5, -1.0, 5, 250.0, 0.0, 200.0, -1.0, 0.0);

// Once killed by KILL_IF_CLOSE, will call the PICKUP_WEAPON AI command and give the player the corresponding weapon to this sprite.;
ai.AddDeathNode(10, 0);

// Set what to do when colliding with an object of any type;
// Collision responses;
// 0 : Ignore;
// 2 : Block;
capsule.CollisionResponseToAllChannels = 0;

// Set what to do when colliding with an object of type 0;
// Possible collision types;
// 0 : Static (walls or static sprites);
// 1 : Dynamic (most moving sprites);
// 2 : Pawn (the player);
// 6 : Usually for projectiles that can pass through most objects;
// 7 : Most projectiles;
// 14 : The player in multiplayer;
capsule.SetCollisionResponseToChannel(0, 2);

// Set the type of collision of this sprite's capsule. This affects how it'll react with other objects it can collide with.;
capsule.CollisionObjectType = 7;

// This command will add a light to the sprite.;
AddLight();
// Set the color of the light (red, green, blue). The light color will be overriden by the game according to the weapon's rarity.;
lightColor = vector(1.0, 1.0, 1.0);
// Set how far the light goes.;
light.LightFunctionFadeDistance = 50.0;
// Set to true for the light to cast shadows.;
light.CastShadows = false;
// Set how fast the brightness of the light falls.;
light.LightFalloffExponent = 40.0;
// Set the base brightness of the light.;
light.Intensity = 15.0;

First person weapon

  • Weapons are created by adding a .txt script file in the /Script/Weapons folder of a mod.
  • The name of the .txt file will be how this weapon will be referred to in other script files.
  • To replace a base game weapon, you must name the .txt file using the right weapon ID.
  • Using the same name as a previous mod's weapon will overwrite it.
  • Weapons must be registered in the /Script/Weapons.txt file.;

    Weapons.txt file content example

    // Every script operation must end with a semicolon. Spaces or line returns are ignored.;

    // Call this function if you don't want the original weapons, or weapons from previous mods, to spawn in the game.;
    //ClearAllSpawningWeapons();

    // Definition: AddWeapon(weaponId, weaponSpriteId, addToWeaponSpawnList, weaponLevel, ammoType, shiny);
    // If addToWeaponSpawnList is true, it will make sure the weapon might spawn when killing enemies or opening chests. If set to false, you can still have the weapon appear in deathmatch.;
    // weaponLevel and ammoType are used to determine what type of weapon to spawn and at what odds.;
    // If shiny is true, the weapon will only spawn from NG+ shiny enemies.;
    AddWeapon(ChickenGarand, BlueChickenGarandItem, true, 1, 0, false);

    // This will override the SAWED_OFF weapon with another one defined in this mod.;
    AddWeapon(2, 24, true, 1, 0, false);

    Weapon script file content example

    // Every script operation must end with a semicolon. Spaces or line returns are ignored.;
    // Base game weapon file names are a number, so only use non-number names to add new weapons. Ex: ChickenGarand.txt;
    // Don't put spaces in file names.;
    // This file contains only a small subset of all possible weapons commands. To make your own weapon, take a similar existing one and copy its script file.;

    // This weapon script is for a reskin of the Garand weapon that shoots chickens.;

    // The damage players get if the weapon is blood ammo.;
    bloodAmmoDamage = 1;

    // The minimum angle at which casings fly off.;
    minCasingAngle = 150.0;

    // The maximum angle at which casings fly off.;
    maxCasingAngle = 350.0;

    // How far the sound of firing this weapon goes in cubes. Wakes up enemies.;
    soundRange = 20.0;

    // Delay when reloading before casings are ejected.;
    //casingTime = 0.4;

    // The sound to play when firing.;
    fireSound.m_sound = ChickenGarandFireSound;

    fireSound.m_volumeMin = 1.5;
    fireSound.m_volumeMax = 1.5;
    fireSound.m_pitchMin = 0.9;
    fireSound.m_pitchMax = 1.1;

    // The sound to play when there's no more ammo.;
    noAmmoSound.m_sound = 23;

    // The sound to play when reloading.;
    reloadSound.m_sound = 692;

    // Unused!
    genericGunIdle = true;

    // The sound to play after firing the last bullet in the magazine.;
    lastBulletSound.m_sound = 690;
    lastBulletSound.m_volumeMin = 1.0;
    lastBulletSound.m_volumeMax = 1.0;

    // The sound to play when switching to this weapon.;
    pulloutSound.m_sound = 693;
    pulloutSound.m_volumeMin = 0.5;
    pulloutSound.m_volumeMax = 0.5;
    pulloutSound.m_pitchMin = 0.9;
    pulloutSound.m_pitchMax = 1.1;

    // True if we should spawn a magazine after firing the last bullet in the magazine.;
    magazineOnLastBullet = true;

    // The velocity at which to eject the magazine.;
    magazineCasingVel = true;

    // The sprite ID of the magazine sprite.;
    magazineType = 1156;

    // Definition: Init(texture, normalTexture, emissiveTexture, itemTexture, fireRate, damage, automatic, recoil, name, level);
    // To add a space to the name, use the code: %20 ;
    Init(ChickenGarand.png, ChickenGarandNormal.png, ChickenGarandEmissive.png,
    itemChickenGarand.png, 0.1, 8, false, 2.0, "CHICKEN%20GARAND", 1);
    // Set the dirty/bloody texture.;
    dirtyTexture=ChickenGarand_Sp.png;
    // Definition: InitBulletWeapon(ammoType, ammoConsumption, magazineSize, reloadTime, ammoToAddPerReload, bulletVelocity, bulletsPerShot, casingsPerShot, casingsOnReload, casingSpriteID, bulletSpriteID);
    InitBulletWeapon(0, 1, 8, 1.0, 8, 20000.0, 1, 1, false, 127, BlueChicken);

    // AddPotentialStats determines which modifier/stat the weapon can have when of a higher rarity.;
    // For help choosing potential stats in script, take the list below and remove the stat IDs that the weapon can't support.;
    //AddPotentialStats(0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29);
    AddPotentialStats(0, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 15, 16, 17, 18, 19, 20, 22, 23, 24, 25, 26, 27, 28, 29);

    // All animation init functions have this definition: (offset, frameAmount, duration, clamp);
    // If one of these values contains a = or a ?, it means that the value to use can be different depending on a condition.;
    // The format of conditions is this: X=Y?V:W , which translates to: if condition X equals Y use V and if not use W.;
    // The possible conditions:;
    // 0 : MAGAZINE : magazine size at the time of doing the animation;
    // 1 : PREV_MAGAZINE : magazine size it had before doing the animation;
    // 2 : MAIN_MAGAZINE : magazine of the main weapon instead of our own when using alternate fire modes.;
    // 3 : NONE : Don't use a condition if you're going to set that...;
    // Set the start firing animation to frame 2, with 2 frames, no end to the duration and clamp the animation.;
    InitStartFiringAnim(2, 2, -1.0, true);

    // Set the stop firing animation to frame 4 if no ammo in the magazine or 0 if there is ammo. 2 frames of animation, an animation lasting 3 seconds and looping.;
    InitStopFiringAnim(0=0?4:0, 2, 3.0, false);

    // Set the reload animation to frame 10, 9 total frames, no end to the duration and clamp the animation.;
    InitReloadAnim(10, 9, -1.0, true);

    // This declares that the primary fire settings of this weapon are done and we're now adding an alternate fire mode.;
    // In this case, it's a melee bayonet attack.;
    [secondary]

    bloodAmmoDamage = 1;
    fireSound.m_sound = 694;
    fireSound.m_pitchMin = 0.9;
    fireSound.m_pitchMax = 1.1;

    // If true, the weapon will still attack if pressing and holding the attack button while the previous attack is still ongoing.;
    forceFireEnabled = true;

    // Sound to play when the melee attack hits a non-enemy surface.;
    hitSound.m_sound = 28;
    hitSound.m_pitchMin = 0.35;
    hitSound.m_pitchMax = 0.5;

    // Sound to play when the melee attack hits an enemy.;
    hitEnemySound.m_sound = 695;
    hitEnemySound.m_volumeMin = 0.8;
    hitEnemySound.m_volumeMax = 0.8;
    hitEnemySound.m_pitchMin = 0.9;
    hitEnemySound.m_pitchMax = 1.1;

    // The particle ID of the particle to spawn if hitting a non-enemy surface.;
    bladeHitParticle = 159;

    // The particle ID of the particle to spawn if hitting an enemy.;
    bladeBloodParticle = 160;
    // The particle ID of the particle to spawn if hitting an enemy with green blood.;
    bladeBloodGreenParticle = 163;

    // The decal ID of the decal left on a non-enemy surface.;
    bladeHoleDecal = 110;

    soundRange = 7.0;
    genericGunIdle = true;

    Init(ChickenGarand.png, ChickenGarandNormal.png, ChickenGarandEmissive.png,
    itemChickenGarand.png, 0.25, 8, false, 5.0, "CHICKEN%20GARAND", 1);
    dirtyTexture=ChickenGarand_Sp.png;

    // Definition: InitBlade(length, angle, blunt);
    // length: distance the attack can reach.;
    // angle: the angle of the arc in front of the player when attacking.;
    // blunt: if true, stops the arc if hitting something, preventing hitting multiple targets at once.;
    InitBlade(450.0, 5.0, true);

    // Secondary fire modes can have less possible stats than the main fire mode, but NEVER more.;
    AddPotentialStats(0, 2, 3, 4, 5, 6, 7, 8, 10, 11, 12, 15, 16, 19, 20, 22, 23, 24, 25, 26, 27, 28, 29);

    // If the main fire mode magazine is 0, use frame 8 or use frame 6 if not.
    InitStartFiringAnim(2=0?8:6, 2, -1.0, true);

    // If the main fire mode magazine is 0, use frame 4 or use frame 0 if not.
    InitStopFiringAnim(2=0?4:0, 2, 3.0, false);