Welcome, Guest. Please login or register. Did you miss your activation email?

* TUTORIAL SECTION RULES

This section is for SMOD TUTORIALS & GUIDES ONLY.
You may create a new topic in the appropriate area to share your tutorial. If you post anything off-topic here you will be temp-banned. This is so we don't hassle the moderators too much, they are volunteers.

If you need help with a tutorial, post a reply in its thread . Do not start a new topic for help here!

Author Topic: [SMOD] Custom Weapon Script with Explainations  (Read 26043 times)

0 Members and 1 Guest are viewing this topic.

Offline Onemanshow

  • JuanMan
  • *
  • *
  • +67% chance to make useful post
  • Onemanshow is awe-inspiring!Onemanshow is awe-inspiring!Onemanshow is awe-inspiring!Onemanshow is awe-inspiring!Onemanshow is awe-inspiring!Onemanshow is awe-inspiring!Onemanshow is awe-inspiring!Onemanshow is awe-inspiring!Onemanshow is awe-inspiring!Onemanshow is awe-inspiring!Onemanshow is awe-inspiring!Onemanshow is awe-inspiring!
[SMOD] Custom Weapon Script with Explainations
« on: December 14, 2009, 08:02:46 PM »
SMOD (as of 40a) allows players to code in up to 30 new weapons that go on top of SMOD's already extensive arsenal. A wide variety of weapons are possible with the features in the custom weapon script, although somewhat limited when in comes to unconventional weapons.

This is a re-written version of the same guide on the SMOD: Tactical forums with more information and better formatting and is primarily intended for players who have at least a small understanding of SMOD's code. This is not intended as a walkthrough to make a custom weapon, but to shed light on what each function does. I recommend you only use this as a reference as it is not in a very script-friendly format.

This is a work-in-progress and more information will be added as it is found.

A special note: For anyone who is adding custom weapons without replacing the stock ones, you might be interested to know that Half-Life 2 (and SMOD) can only draw 64 weapons on the HUD at the same time. Including all possible custom weapons and all stock SMOD weapons (sans weapon_nodemaker and weapon_annabelle) brings this total to 69 weapons. 5 of which will not be selectable. Use caution when adding over 25 custom weapons into SMOD.


WeaponData
{
NOTE: Most of the functions here work on any SMOD weapon. Not just custom weapons.

   "printname"         "#HL2_Crowbar"
Weapon name that shows on the HUD. #HL2_ prefix points to a localized entry from the resource/smod_language.txt.

   "viewmodel"         "models/weapons/v_crowbar.mdl"
Path to first person view model.

   "playermodel"         "models/weapons/w_crowbar.mdl"

Path to third person/world view model.

   "anim_prefix"         "crowbar"

What animation set to use for the Third Person model. Supported:
Code: [Select]
AR2
Shotgun
Pistol
Crowbar
SMG1
SMG2
Grenade
SLAM
Physgun

   "bucket"            "0"
Defines the row the weapon will appear in on the HUD. 0-5 supported.

   "bucket_position"         "0"
Defines weapon slot in a row. Recommended MAX is 15.

   "clip_size"         "30"

Primary ammo Clip size.

   "clip2_size"         "-1"
Secondary ammo Clip size.

   "default_clip"         "100"
Primary ammo to give when picked up. NOTE: This seems to also affect the clip size for the weapon when NPC's hold it, and may cause issues with them if it is set higher then the player's clip size.

   "default_clip2"         "-1"
Secondary ammo to give when picked up.

   "primary_ammo"         "None"
Primary ammo type this weapon uses. Supported:
Code: [Select]
pistol
smg1
smg1_grenade
ar2
ar2_altfire
grenade
xbowbolt
buckshot
rpg_missile
customammo1-10

   "secondary_ammo"         "None"
Secondary ammo type this weapon uses. See above for list.

   "weight"            "0"
How much NPC's like this weapon over others. Mainly applies for Citizens/Rebels when deciding to pick up a weapon and the autoselect priority it takes for the player.

   "item_flags"         "0"
Special flags to use. Should only be used for grenade/RPG weapons. From the Valve Wiki:
Code: [Select]
1 / ITEM_FLAG_NOAUTORELOAD
    Weapon does not automatically reload.
2 / ITEM_FLAG_NOAUTOSWITCHEMPTY
    Weapon does not automatically switch to another weapon when empty.
3 / ITEM_FLAG_LIMITINWORLD
    Weapon is limited in world.
4 / ITEM_FLAG_EXHAUSTIBLE
    A player can totally exhaust their ammo supply and lose this weapon. The Frag Grenade has this flag.
5 / ITEM_FLAG_DOHITLOCATIONDMG
    This weapon takes hit location into account when applying damage.
6 / ITEM_FLAG_NOAMMOPICKUPS
    Don't draw ammo pickup sprites/sounds when ammo is received.
6 / ITEM_FLAG_NOITEMPICKUP
    Don't draw weapon pickup when this weapon is picked up by the player.

   "BuiltRightHanded"         "1"
Defines if the model is built right handed for model flipping.

   "AllowFlipping"         "0"
Defines if the model can be flipped with the cl_righthand command.

   "CSViewModel"         "1"
Adds support for weapons that do not use Half-Life 2 muzzle and brass effects. Supports weapons from Counter Strike:Source, Day Of Defeat:Source, and Insurgency.

   "CSWorldModel"         "1"
Forces NPC's to be able to attack with this weapon even if the world model does not have NPC support. May cause bugs. Model editing is needed to properly fix world models.

   "MuzzleType"         "MZRIFLE"

If CSViewModel is 1, Defines what muzzle flash sprite to use. Supported:
Code: [Select]
MZRIFLE
MZSMG
CSRIFLE
CSSMG

   "MuzzleSize"         "1.5"
If CSViewModel is 1, Scales the size of the muzzleflash above.

   "MuzzleAttach"         "0"
If CSViewModel is 1, Forces the muzzle to attach to the "muzzle" attachment (if supported in the model).

   "MuzzleOfs"         "-3"
If CSViewModel is 1, Offsets the muzzle to the right/left. Useful for Day of Defeat: Source models.

   "LagScale"         "0.8"
Scales the movement lag effect Half-Life 2 uses for its view models. DO NOT USE 0.0!

   "RunSpeed"         "0.6"
Player speed multiplier when holding the weapon. (1 = hl2 default)

   "DisableROAimmode"      "1"
Disables freeaim on this weapon if ROAimMode convar is enabled.

   "NoDrop"         "1"
Defines if the player can drop this weapon.

   "Adjust" {
      "Forward"      "4"
      "Up"         "1"
      "Fov"         "-20"
   }


Adjusts the origin of this weapon (view model).

   IronSight {
      "right"      "-4.5"
      "up"      "2.0"
      "forward"   "0"
      "fov"       "-30"
      "pitch"       "1"
      "yaw"      "2"
      "roll"      "3"
      "AdjustAccuracy"   "0.5" //Accuracy multiplier when using the ironsights on this weapon. 0.5=50% bonus to accuracy.
      }


Sets the ironsight origin of this weapon (view model). Most of the settings in "Ironsight" can also be used for "Adjust" as well.
SPECIAL NOTE: Due to a bug, The "Yaw" angle is not locked when using the ironsights. Meaning that a large amount can result in the ironsights not looking right when aiming up/down.

    "VMDOF"
    {
        "Default"
        {
            "start"                    "39"
            "end"                    "-12"
        }
       
        "IronSight"
        {
            "start"                    "2"
            "end"                    "4"
        }
    }


Defines the limits of the Depth Of Field blur effect SMOD can use on the viewmodel.

   //Sounds aliases for the weapon. There is a max of 16 sounds per category (i.e. max 16 "single_shot" sounds) The full script file for them is "game_sounds_weapons.txt" or "game_sounds_cs_weapons.txt"
   SoundData
   {
      "single_shot"      "Weapon_Crowbar.Single"
      "double_shot"      "Weapon_IRifle.Single"
      "reload"         "Weapon_Pistol.Reload"
      "single_shot_npc"      "Weapon_M249.Single"
      "double_shot_npc"      "Weapon_AR2.NPC_Double"
      "reload_npc"      "Weapon_Pistol.NPC_Reload"
      "empty"         "Weapon_Pistol.Empty"
      "special1"      "Weapon_Pistol.Special1"
      "special2"      "Weapon_Pistol.Special2"
      "burst"         "Weapon_Pistol.Burst"
      "melee_hit"      "Weapon_Crowbar.Melee_Hit"
      "melee_hit_world"      "Weapon_Crowbar.Melee_HitWorld"
   }


  // Weapon Sprite data is loaded by the Client DLL.
   TextureData
   {
      "weapon"
      {
            "font"      "WeaponIcons"
            "character"   "c"
      }
      "weapon_s"
      {   
            "font"      "WeaponIconsSelected"
            "character"   "c"
      }
      "ammo"
      {
            "font"      "WeaponIcons"
            "character"   "c"
      }
      "ammo2"
      {
            "file"      "sprites/640hud7"
            "x"      "48"
            "y"      "72"
            "width"      "24"
            "height"      "24"
      }
      "crosshair"
      {
            "font"      "Crosshairs"
            "character"   "Q"
      }
      "autoaim"
      {
            "file"      "sprites/crosshairs"
            "x"      "0"
            "y"      "48"
            "width"      "24"
            "height"      "24"
      }
   }


Defines weapon and ammo HUD icons. Some fields can use a sprite texture (See "ammo2") but typically use Font Files. Do not use a sprite for the "ammo" field as SMOD does not support sprites for it.


CUSTOM WEAPON SPECIFIC CODE:

  "WeaponSpec" { This covers the most basic custom weapon characteristics.

      "WeaponType"   "4"
The basic type of this weapon. Supported: 0 (semi-auto), 1 (automatic), 2 (shotgun), 3 (autoshotgun), 4 (melee), 5 (grenade).

      "FireRate"   "1.0"

Rate of Fire for this weapon. Lower is faster. 0.1=600 rounds-per-minute according to the Half-Life 2 source code.  NOTE ON SHOTGUNS: Because of the differences between how Counter Strike: Source and Half-Life 2 shotgun's are coded, Only CS:S shotguns should be set to 0.0. HL2 shotguns should be set to around 0.25 otherwise you may have animation glitches.

      "UnderWater"   "1"
Defines if the weapon can be fired underwater.

      "Akimbo"      "1"
Defines if the viewmodel is using the CS:S Dual Elites weapon events and will add support for them when set to 1.

      "AttachedGL"   "1"

Sets if the weapon uses the (BulletEntitySpawn) code as its secondary fire.

      "FireMode"   "1"

Defines if the model can switch fire modes with the secondary fire. The settings:
Code: [Select]
1 (single)
2 (burst)
4 (automatic)

For example, if you want to use all 3 modes set "FireMode" to "7". if you want semi-auto and 3-round-burst set "FireMode" to "3". "WeaponType" above sets the default fire mode.


      "Options" {   Miscellaneous options for the weapon. 

         "FireSoundVolume"   ""
How many game units away can NPC's hear this weapon being fired from. Half-Life 2 default is 1500.

         "ReloadSound"      "1"

Sets if the weapon uses the reload sound from the "SoundData" alias above. If the weapon has the sound(s) coded into its QC file set this to 0. NOTE: This can act buggy and may not play.

         "LastFireSound"      "1"
If set to 1, It will use the sound "special3" in "SoundData" as its last bullet fire sound.

         "LastDryFireActivity"   "0"
If set to 1, Will use the weapon's "ACT_VM_DRYFIRE" animation when empty (if the weapon has one). Set to "0" if the weapon does not have the animation.

         "TurnoffScope"      "0"
             "TurnoffIron"         "0"

Defines if the weapon will take you out of scoped or ironsight mode when fired. Good for bolt-action rifles or pump-action shotguns.

         "CrossHairMove"      "0.02"
Multiplier for how much the dynamic crosshair will open when moving.(?)

         "CrossHairMinSize"   "20.0"
The minimum size of SMOD's dynamic crosshair when using this weapon. (when using "crosshair 2" command)

         "TimeScale"      "2.0"
Controls the timescale of the view model animations. 1.0 is default speed. May not work for all weapons?

         "en bloc Clip"      "1"
Sets if the weapon's clip must be emptied before it can reload.

         "ViewModelSkin"      ""
Can switch what hand skin to use for the viewmodel if it has one. Mainly for Insurgency/Day of Defeat:Source models.

         "FireLag"   "0.8"   
How long the fire button must be held before actually firing. Good for minigun-type weapons.

         "IsGatlingGun"   "1"   
Sets the weapon to use special gatling/minigun events.
      }


      "LaserPointer" {
  This is for a weapon's laser sight (if any). This is typically for secondary fire, but can be changed below.

         "AccBonus"   "0.5"
Defines the accuracy multiplier when using the laser. (0.5 = 50% bonus) NOTE: Currently as of SMOD 40a this command seems broken and will always give the maximum accuracy possible.

         "UseButton"   "1"
Defines if the laser can be (de)activated with the +use key instead of secondary fire.

         "UseIronsight"   "1"
Defines if the laser can be (de)activated with the ironsight key instead of secondary fire.

         "DeactivateinReload"   "1"
Sets if the laser turns off when reloading.

         "Material"   "sprites/blueglow1.vmt"
Path for the desired sprite to use for the laser.

         "DrawTrail"   "1"
Sets if a red trail should be drawn as the laser moves. Best when used only with a red sprite.

         "PointerSize"   ".5"
Defines the size multiplier of the dot.

         "TraceLength"   "32"

Distance (in game units) where the dot is at its maximum size.

         "DrawRange"   "250"
Distance (in game units) where the dot is at its minimum size.

         "SwitchSound"   "0"
Defines if a sound should play when turning on/off the laser.

         "FixSize"   "1"
Sets if the dot should never change in size.
     }


      "Melee" {
This covers a weapon's melee attack (if any). This can either be for the primary or secondary fire.

         "Primary" { Use this block if you want the melee attacks to use the primary fire.

            "Range"      "80"
Range in game units that the melee weapon can hit at.

            "Frame"      "2"

The animation frame that the melee projectile will generate. This can be affected by your Frames per Second in-game.

            "NextAttack"   "5"
Sets the animation frame/speed multiplier for the next attack. This can be affected by your Frames per Second in-game.

            "Damage"   "8"
Damage the attack does.

            "DamageType"   "DMG_CLUB"
Defines the type of damage caused by the attack. Supported:
Code: [Select]
DMG_CLUB
DMG_CRUSH
DMG_BULLET
DMG_SLASH
DMG_BURN
DMG_BLAST
DMG_SHOCK
DMG_ENERGYBEAM
         }

         "Secondary" {
         }

Putting values in the "Secondary" part will use secondary fire to do a melee attack instead of primary fire. You can use both as well.

         "Force"      "0.2"
Sets the physical force multiplier the attack has to physical objects and ragdolls.

         "ImpactEffect"   "0"

Defines if the melee attack should have effects and decals. Types:
Code: [Select]
0(default)
1(nodecal)
2(nodecal,nosound)
3(noeffect)

         "Decal"      "ManhackCut"
What decal type to use.

      }


      "HandGrenade" {
This applies to hand grenade weapons only.

         "ThrowFrame"   "3"
The animation frame that the grenade will generate. This can be affected by your frames per second in-game. If the animation already has an event to throw the grenade use "-1".
      }


      "Activities" {
This is to redirect the animations of a view model without needing to decompile it. This is especially helpful for getting weapons that do not use Half-Life 2/Counter-Strike: Source events to work in SMOD. You can get the event names from the Half-Life Model Viewer in the SDK.
Code: [Select]
         "PrimaryFire"      ""
The animation to use for the weapon's primary fire. Typically "ACT_VM_HITCENTER" or "ACT_VM_PRIMARYATTACK".

         "SecondaryFire"      ""
The animation to use for the weapon's secondary fire. Typically "ACT_VM_HITCENTER" or "ACT_VM_SECONDARYATTACK".

         "Reload"         ""
The animation to use for reloading. Typically "ACT_VM_RELOAD".

         "DryFire"         ""
The animation to use for the weapon's last shot. Typically "ACT_VM_DRYFIRE". Only used if "LastDryFireActivity" is "1".

         "DryFireLeft"      ""
Similar as above. But only applies to the left-hand weapon when "Akimbo" is "1" Typically "ACT_VM_DRYFIRE_LEFT".

         "Idle"         ""
The weapon's idle animation. Typically "ACT_VM_IDLE".

         "GLFire"         ""
The animation to use for the grenade launcher.  Typically "ACT_VM_SECONDARYATTACK". Only applies if "AttachedGL" is "1".

         "ModeSwitch"      ""
The animation to use for switching the fire mode. Most weapons will not have an animation for this.

         "Deploy"         ""
The animation to use for drawing the weapon. Typically "ACT_VM_DRAW".

         "IronSightPrimaryFire"   ""
The animation to use for firing the weapon while using the ironsights. Typically "ACT_VM_ISHOOT".
     
         "ShotgunReloadStart"   ""
Shotgun reloads are broken up into 3 different animations. This is the start. Typically "ACT_SHOTGUN_RELOAD_START".

         "ShotgunReload"   ""
Shotgun reloads are broken up into 3 different animations. This is the insert loop. Typically "ACT_VM_RELOAD".

         "ShotgunReloadFinish"   ""
Shotgun reloads are broken up into 3 different animations. This is the end. Typically "ACT_SHOTGUN_RELOAD_FINISH".

         "ShotgunPump"   ""
Shotgun pump animation played between shots or after reloading. Typically "ACT_SHOTGUN_PUMP". Note that Counter Strike:Source weapons have a pump animation built into the firing animation.

         "Prefire"   ""
Minigun prefire spin-up. Only used if "IsGatlingGun" is set to 1. Typically "ACT_VM_RECOIL3"

         "GatlingFire1"   ""
Minigun firing animation. Possibly doubles as spin-down. Typically "ACT_VM_PRIMARYATTACK" or "ACT_VM_RECOIL1"

         "GatlingFire2"   ""
Minigun firing animation. Possibly doubles as spin-down. Typically "ACT_VM_PRIMARYATTACK" or "ACT_VM_RECOIL1"
}


      "Detonator" {
This is for a custom explosive detonator that is not timed or impact detonated. It is always used with the secondary fire key. SPECIAL NOTE: This especially relies on animations whose event names are of "standard" bullet-firing weapons I.E "ACT_VM_PRIMARYATTACK". Grenade view models will typically not work unless you decompile the model and change the event names.

         "DetType"   ""
The type of custom explosive that the detonator will work on.

         "Radius"      ""
The radius (in game units) that the detonator will work at from explosives.
      }


      "Recoil" {
This is the recoil values for the weapon.

         "PunchPitch"   "-10.0 10.0"
         "PunchYaw"   "-10.0 10.0"

Defines the amount of "punch" type of recoil used. Punch-type recoil will punch the view and then return it to normal after firing. As an example, the punch values used by the default HL2 Pistol are:
Code: [Select]
"PunchPitch"    "0.6 -0.6"
"PunchYaw"    "-0.25 0.5"

         "EnableSnap"   "0"
Defines if "snap" type recoil can be used. Snap-type recoil will kick the view and set it at a new position. If you turn this on and have recoil values set in punch but have no values set in snap this will make it so that controlled firing will return the view to normal after firing but rapid/full-auto firing will "snap" the view instead.

         "SnapPitch"   "-0.0 0.0"
         "SnapYaw"   "-0.0 0.0"

Defines the amount of "Snap" recoil used. Will not take effect unless "EnableSnap" is set to 1.

         "Crouch"   "1.0"
Recoil multiplier when crouching.

         "Amp"      "1.0"
Defines the recoil multiplier per-shot.

         "PunchLimit"   "1.0"

Defines the punch recoil limit.
    }


      "Spread" {
This is for the custom weapon's spread or Cone of Fire.

         "Default"      "3.0"

Defines the base degree of accuracy for the weapon. Some HL2 values as examples:
Code: [Select]
Pistol: 1.0
SMG1: 5.0
AR2: 3.0
357: 0.0
Shotgun: 10.0

         "MaxSpread"   "5.0"

The maximum degree of inaccuracy for the weapon.

         "Run"      "1.0"
The maximum degree of inaccuracy for the weapon while running. May or may not be tied to "MaxSpread".

         "RunSpeed"   "100"

The speed in game units that the "Run" spread takes effect at.

         "Crouch"   "0.8"

Spread multiplier when crouching.

         "Fire"      "1.3"
Spread multiplier per-shot.
      }


      "Scope" {
This is for the custom weapon's scope (if any). Defaults to secondary fire, but can be set to other keys too.

         "Type"      "3"
Defines what scope texture to use. Types Supported:
Code: [Select]
0(no overlay)
1(SVD)
2(SVD with glowing crosshairs?)
3(Crossbow)
4(CSS-like scope)
5-10: (Will use customscope1-5.vtf in your materials/vgui folder if available)

         "Switch"      "1"
How many magnification levels the scope has.

         "ZoomFact"   "8.0"
The maximum magnification factor of the scope.

         "CrosshairOff"   "0"
Defines if the crosshair should be turned off when using the scope.

         "AccBonus"   "0.07"
The accuracy multiplier when using the scope. (0.5 = 50% bonus)

         "FireRate"   "0.3"
Defines the rate of fire for the weapon only when using the scope. Lower is faster. 0.1=600 Rounds Per Minute according to comments in the HL2 code.

         "DrawViewmodel"   "0"
Defines if the viewmodel should be drawn when using the scope.

         "Drift"      ""
The amount of "bobing" to apply to the scoped view. 0.4 recommended.

         "UseButton"   "1"
Defines if the scope can be (de)activated with the use key instead of secondary fire.

         "IronsightIsScope"   "1"
Defines if the scope can be (de)activated with the ironsight key instead of secondary fire.
      }


      "Burst" {
Settings for the burst mode. If this is present a burst fire mode will be added regardless of the fire mode(s) set above.

         "FireCount"   "3"
How many bullets to fire in a burst.

         "Delay"      "0.2"
Delay (in seconds) to wait before allowing another burst.

         "AccBonus"   "2.0"
Accuracy multiplier when using the burst mode on this weapon. 0.5=50% bonus to accuracy.

         "RecoilBonus"   "2.0"
Recoil multiplier when using the burst mode on this weapon. 0.5=50% lower recoil(?).
      }

      "Bullet" {
The primary fire of this weapon (if none other is defined).

         "AmmoType"   "Pistol"

The type of bullet to use for the weapon. Types Supported:
Code: [Select]
AR2   
Pistol   
SMG1   
357 (BULLET HAS LOTS OF FORCE BY DEFAULT)   
Buckshot   
SniperRound  (BULLET HAS LOTS OF FORCE BY DEFAULT. VERY FAST IN BULLET TIME)       
CombineCannon   
AirboatGun (VERY FAST IN BULLET TIME. CAN DAMAGE OBJECTS\NPCS INVINCIBLE TO NORMAL GUNS)   
StriderMinigun (BULLET HAS LOTS OF FORCE BY DEFAULT)     
HelicopterGun (VERY FAST IN BULLET TIME)
SMG1Grenade (SETS ZOMBIES ON FIRE)
AR2AltFire (DISINTEGRATES ENEMIES ON DEATH) 
Ak47   
Grease
kar98   
CustomAmmo1 (UNCONFIRMED)   
CustomAmmo2 (UNCONFIRMED)   
CustomAmmo3 (UNCONFIRMED)   
CustomAmmo4 (UNCONFIRMED)   
CustomAmmo5 (UNCONFIRMED)
CustomAmmo6 (UNCONFIRMED)   
CustomAmmo7 (UNCONFIRMED)   
CustomAmmo8 (UNCONFIRMED)   
CustomAmmo9 (UNCONFIRMED)   
CustomAmmo10 (UNCONFIRMED)

         "Damage"   "6"
The amount of damage each bullet does.

         "ShotCount"   "1"

The amount of bullets to fire each shot. Primarily for shotguns.

         "Tracer"      "3"
Defines how many shots before a tracer is generated. For example, "3" means 1 in 3 shots will be a tracer.

         "Force"      "0.5"
Sets the physical force multiplier the bullet has to physical objects and ragdolls.

         "Penetrate"   "8"
The level of bullet penetration each bullet has. Only applies if bullet penetration is enabled.

         "TraceLength"   "2000"
How far (in game units) the shot can travel before it is removed from the game world. If "Attenuate" is enabled, it also controls the maximum damage drop-off range.

         "Attenuate"   "200"
How far (in game units) the shot can travel before its damage begins to drop off. The further it travels, the more damage will be reduced. Best used along with "TraceLength".   
      }


      "EnergyBullet" {
This is to use an energy projectile for the primary fire instead. This relies on the "Bullet" code for damage, force, etc. And will not function correctly if said code is not present.

         "DamageType"      "1024"
The damage type this projectile has. This seems to accept both names and numeric values. From the Valve Wiki:
Code: [Select]
0 DMG_GENERIC
1 DMG_CRUSH
2 DMG_BULLET
4 DMG_SLASH
8 DMG_BURN
16 DMG_FREEZE
32 DMG_FALL
64 DMG_BLAST
128 DMG_CLUB
256 DMG_SHOCK
512 DMG_SONIC
1024 DMG_ENERGYBEAM
16384 DMG_DROWN
32768 DMG_PARALYSE
65536 DMG_NERVEGAS
131072 DMG_POISON
262144 DMG_RADIATION
524288 DMG_DROWNRECOVER
1048576 DMG_CHEMICAL
2097152 DMG_SLOWBURN
4194304 DMG_SLOWFREEZE
 

         "Bounce"      "2"
How many times the projectile can ricochet off objects. This will not apply if the projectile hits NPC's or certain props.

         "Size"         "6"
Size multiplier of the projectile sprite.

         "LightRadius"      "8"
The radius of the light generated by the projectile.

         "LightColor"      "255 0 0"
The color of the light generated by the projectile. This is in Red Green Blue format.

         "Speed"         "1000"
Speed (in game units) of the projectile. NOTE: At 3000 units and above, the projectile will not travel as intended resulting in extreme inaccuracy and odd behavior.

         "SpriteMaterial"      "effects/redflare"
The folder path to the desired material to use for the projectile sprite.

         "Gravity"         "300"
The gravity that the projectile has. Half-Life 2 default is 600. Set to "0" for no gravity on the projectile.

         "TrailSize"      "3"
Size multiplier of the projectile's trail.

         "TrailTime"      "3"
How long (in seconds) to generate a trail.

         "FlyTime"      "3"
How long (in seconds) before the projectile is removed from the game world.
      }

      "BulletEntitySpawn" {
This is typically for grenades or grenade launchers. Defaults to primary fire, but if "AttachedGL" is "1" it will use the secondary fire instead.

         "Class"      "rpg_missile"
Defines what class to use. Known classes:
Code: [Select]
custom_explosive: To use a custom explosive type.
crossbow_bolt: Crossbow Bolt.
grenade_anm14: SMOD's AN-M14 grenade.
grenade_ar2: Half-Life 2 SMG1 Grenade.
grenade_spit: Bullsquid spit. (Missing files to work. Files must be manually added to SMOD)
npc_satchel: S.L.A.M Satchel. Can only be detonated by being damaged.
rpg_missile: Fires a unguided RPG missile.
prop_combine_ball: Fires an AR2 AltFire ball that is smaller, Has no explosion effect and disappears after hitting an object or NPC.
umd: Exploding PSP UMD. When used by a custom weapon, it only explodes when walked over and does no damage.

         "Model"      ""

Model to use for the projectile?

         "Type"      "SMG1Grenade"

Type of custom explosive to use.

         "ZVector"   "100"
The vertical correction (in game units) from the player to set the projectile.

         "NPCZVector"   "100"

The vertical correction (in game units) from the NPC to set the projectile.

         "Power"      "500"
The velocity of the projectile.

         "Mass"      ""
The mass (in kilograms) of the projectile. Useful if you want a projectile to deliver impact damage instead of exploding. 

         "AngVelocity"   "1000"
The angular velocity of the projectile. High amounts will have it spinning wildly in the air.

         "RemoveTimer"   ""

How many seconds before the entity is removed from the game world.
      }

      "Npc" {
This is special NPC-only settings for when NPC's use the weapon.

         "AdjustSpread"   ""
The accuracy multiplier when NPC's use the weapon. 0.5=50% bonus to accuracy. NOTE: This command may not actually work.

         "AnimType"   "smg1"
The animation override for NPC's using this weapon. Types Supported:
Code: [Select]
pistol
smg1
ar2
shotgun
rpg(?)
crowbar (may not work)
stunbaton (for metrocops only (?)/may not work)
NOTE: This may also influence the weapon's behavior in the player's hands as well.

         "RifleAnim"   "0"
Obsolete from what I can tell. Use "AnimType" instead.

         "BurstMax"   "20"
The maximum amount of rounds that a NPC can fire during a burst.

         "BurstMin"   "10"
The minimum amount of rounds that a NPC can fire during a burst.

         "FireRate"   "0.03"

Rate of Fire for this weapon when used by NPC's. Lower is faster. 0.1=600 rounds-per-minute according to the Half-Life 2 source code.

         "Range"      "2096"
The maximum range (in game units) NPC's will use this weapon. NPC's will not use a weapon beyond 4096 units regardless of this value, unless they are specifically overridden in map flags.

         "MuzzleFire"   "1"
Sets if the weapon has a muzzle flash while in a NPC's hands.

         "UseGL"      "1"
Sets if Combine Elites will use the weapon's grenade launcher (if any).

         "UseLaserPointer"   "1"

Defines if NPC's using the weapon will use the laser sight (if any).

         "FireRagdoll"      "0"
Defines if NPC's can fire this weapon as they die. Set to "0" for slow-firing weapons like Pistols and Shotguns. Only applies if "ragdoll_holdweapon" is enabled.
      }
   }
}


Many thanks to Business, Skepsis, tiw, sirmasters, and The SMOD Author for the information in this tutorial.
« Last Edit: March 03, 2015, 05:06:58 PM by Counter-Life™ »

Offline BIZ

  • 32-Bit Hobo
  • *
  • *
  • +0% chance to make useful post
  • BIZ hides in shadows.
    • BSNOOCH.COM
Re: Custom Weapon Script with Explainations
« Reply #1 on: August 21, 2010, 01:41:36 PM »
item_flags

Code: [Select]
1 : ITEM_FLAG_NOAUTORELOAD
    // Weapon does not automatically reload.
2 : ITEM_FLAG_NOAUTOSWITCHEMPTY
    // Weapon does not automatically switch to another weapon when empty.
3 : ITEM_FLAG_LIMITINWORLD
    // Weapon is limited in world.
4 : ITEM_FLAG_EXHAUSTIBLE
    // A player can totally exhaust their ammo supply and lose this weapon. The Frag Grenade has this flag.
5 : ITEM_FLAG_DOHITLOCATIONDMG
    // This weapon takes hit location into account when applying damage.
6 : ITEM_FLAG_NOAMMOPICKUPS
    // Don't draw ammo pickup sprites/sounds when ammo is received.
6 : ITEM_FLAG_NOITEMPICKUP
    // Don't draw weapon pickup when this weapon is picked up by the player.

Offline Doritosman

  • *
  • +1% chance to make useful post
  • Doritosman has no influence.
Re: Custom Weapon Script with Explainations
« Reply #2 on: June 27, 2011, 03:04:30 AM »
This topic correctly describes how the burst delay works, but in the smodwiki (http://smod.wikidot.com/script:weapon-custom/) the explanation's incorrect. It should be corrected to cause less confusion.

The item_flags use the binary system (or whatever it's called) like the firemode in the customweapon scripts. Think it should be mentioned somewhere to help with people who wants to use it.

Offline BIZ

  • 32-Bit Hobo
  • *
  • *
  • +0% chance to make useful post
  • BIZ hides in shadows.
    • BSNOOCH.COM
Re: Custom Weapon Script with Explainations
« Reply #3 on: June 27, 2011, 05:33:19 AM »
hmm, sorry we do not maintain that wiki...

Offline sirmasters

  • *
  • +5% chance to make useful post
  • sirmasters barely matters.sirmasters barely matters.
    • My Twitter (My Forums are inactive at the moment)
Re: [SMOD] Custom Weapon Script with Explainations
« Reply #4 on: December 26, 2011, 05:08:21 AM »
Sorry to bump this, but I found some stuff while looking in the DLLs using a hex editor involving the "Activities" section. I'll post the stuff that wasn't probably known.
Code: [Select]
ShotgunReloadStart - When your shotgun is about to reload

ShotgunPump - Pumping the shotgun, either after a shot or after finishing reloading

ShotgunReloadFinish - Played after finishing putting all the buck-shots in the gun.

ShotgunReload - When putting the buck-shot in

Prefire - Mini-gun spin up animation

GatlingFire2 - When firing with the mini-gun settings, maybe for second animation layer or something

GatlingFire1 - When firing with the mini-gun settings

These are all tested in SMOD 40 and are confirmed to work for that version.
._. I love coffee.

Offline Counter-Life™

  • *
  • *
  • +17% chance to make useful post
  • Counter-Life™ is a rising star!Counter-Life™ is a rising star!Counter-Life™ is a rising star!Counter-Life™ is a rising star!Counter-Life™ is a rising star!Counter-Life™ is a rising star!
    • Youtube Channel
Re: [SMOD] Custom Weapon Script with Explainations
« Reply #5 on: February 12, 2013, 06:48:12 PM »
I just noticed "MuzzleOfs" sets Muzzleflash up/down.

Offline Davidos667

  • *
  • +1% chance to make useful post
  • Davidos667 has no influence.
Re: [SMOD] Custom Weapon Script with Explainations
« Reply #6 on: March 05, 2013, 08:40:02 PM »
The bullettype Buckshot seems to make npcs jump when they die in bullettime (unfortunately.)

Anyone that can confirm?

Offline Counter-Life™

  • *
  • *
  • +17% chance to make useful post
  • Counter-Life™ is a rising star!Counter-Life™ is a rising star!Counter-Life™ is a rising star!Counter-Life™ is a rising star!Counter-Life™ is a rising star!Counter-Life™ is a rising star!
    • Youtube Channel
Re: [SMOD] Custom Weapon Script with Explainations
« Reply #7 on: March 05, 2013, 10:18:10 PM »
The bullettype Buckshot seems to make npcs jump when they die in bullettime (unfortunately.)

Anyone that can confirm?

I think the bullets just have a strong force, try to set it to 0.5

Offline Davidos667

  • *
  • +1% chance to make useful post
  • Davidos667 has no influence.
Re: [SMOD] Custom Weapon Script with Explainations
« Reply #8 on: March 06, 2013, 02:13:27 PM »
The bullettype Buckshot seems to make npcs jump when they die in bullettime (unfortunately.)

Anyone that can confirm?

I think the bullets just have a strong force, try to set it to 0.5

Nnnope, even with 0 the corpses still jump, with twitch or ex_action ,none of the bullets have an effect on the bodies (with force and such) if you don't have the ragdolls set up to perform actions. Derp

Offline Monkatraz

  • *
  • *
  • +4% chance to make useful post
  • Monkatraz has no influence.
Re: [SMOD] Custom Weapon Script with Explainations
« Reply #9 on: January 21, 2015, 07:31:57 AM »
BTW, found a way past the 3000 speed limit on EnergyBullet, you need to set sv_maxvelocity higher (say 10000)
MLG

Offline HentaiSpirit

  • *
  • +1% chance to make useful post
  • HentaiSpirit has no influence.
Re: [SMOD] Custom Weapon Script with Explainations
« Reply #10 on: September 22, 2016, 07:14:08 PM »
Why is the charge bow reload sound didn't play ?
No sorcery lies beyond my grasp !