Weapon Scripting
From No Quarter Wiki
- In No Quarter, we have added a couple of extra parameters to the regular weapon scripts that allow you to take more control over the way the weapon actually behaves. This section will describe how to set up a weapon script and how to deploy it on your server. But first, lets go over the different features that weapon scripts allow:
New Server and Client keys
name
- Description
- Name of the weapon (max. 22 characters).
- Parameters
- Type: text
- Usage: name <text>
- Example: name "MP40"
damage
- Description
- This controls damage inflicted per shot.
- Parameters
- Type: integer
- Usage: damage <value>
- Example: damage 22
spread
- Description
- This controls spread of bullets. The overall tendancy of the weapon to shoot at the crosshair. Value of 0 means weapon will always hit directly on the crosshair. Higher values give the weapon less accuracy. Use in conjunction with SpeadScaleAdd, SpreadScaleAddRando, CrouchSpreadRatio and ProneSpreadRatio to give complete control of weapon spread.
- Parameters
- Type: integer
- Usage: spread <value>
- Example: spread 400
coolRate
- Description
- This controls the speed at which a weapon cools when it has overheated.
- Parameters
- Type: integer
- Usage: coolRate <value>
- Example: coolRate 2000
defaultStartingAmmo
- Description
- Amount of ammo you start with.
- Parameters
- Type: integer
- Usage: defaultStartingAmmo <value>
- Example: defaultStartingAmmo 75
defaultStartingClip
- Description
- Amount in first clip you start with
- Parameters
- Type: integer
- Usage: defaultStartingClip <value>
- Example: defaultStartingClip 30
fireDelayTime
- Description
- Amount of time before firing first round.
- Parameters
- Type: integer
- Usage: fireDelayTime <value>
- Example: fireDelayTime 150
maxammo
- Description
- Maximum amount of ammo you can carry.
- Parameters
- Type: integer
- Usage: maxammo <value>
- Example: maxammo 90
maxclip
- Description
- Maximum amount of ammo per clip.
- Parameters
- Type: integer
- Usage: maxclip <value>
- Example: maxclip 30
maxHeat
- Description
- Time it takes for weapon to overheat.
- Parameters
- Type: integer
- Usage: maxHeat <value>
- Example: maxHeat 1200
mod
- Description
- Method of Death, eats a number yet. Before we add support for text ( eg. MOD_MP40 ) please ignore it.
- Parameters
- Type: integer
- Usage: mod <value>
- Example: mod 0
nextShotTime
- Description
- Time between fired rounds (Rate of Fire), in miliseconds.
- Parameters
- Type: integer
- Usage: nextShotTime <value>
- Example: nextShotTime 120
reloadTime
- Description
- Time this weapon needs to reload in miliseconds. NOTE: This value is used only if no animations are available ( no/invalid weapon.cfg ).
- Parameters
- Type: integer
- Usage: reloadTime <value>
- Example: reloadTime 2200
SpreadScaleAdd
- Description
- Amount of spread to add as trigger is held.
- Parameters
- Type: integer
- Usage: SpreadScaleAdd <value>
- Example: SpreadScaleAdd 1
SpreadScaleAddRand
- Description
- Random amount of spread to add as trigger is held. ( 0 to value of this ). Added to SpreadScaleAdd.
- Parameters
- Type: integer
- Usage: SpreadScaleAddRand <value>
- Example: SpreadScaleAddRand 10
recoilDuration
- Description
- Amount of time to move to recoilPitch and/or recoilYaw
- Parameters
- Type: integer
- Usage: recoilDuration <value>
- Example: recoilDuration 400
recoilYaw
- Description
- Distance left or right to move view from weapon firing.
- Parameters
- Type: floating point
- Usage: recoilYaw <value>
- Example: recoilYaw 0.5
recoilPitch
- Description
- Distance up or down to move view from weapon firing.
- Parameters
- Type: floating point
- Usage: recoilPitch <value>
- Example: recoilPitch 0.5
limboKill
- Description
- Makes death by that weapon unrevivable.
- Parameters
- Type: text
- Usage: limboKill <yes/no>
- Example: limboKill "no"
KillMessage
- Description
- First part of obituary, (<TARGET> <KillMessage> <KILLER> <KillMessage2>)
- Parameters
- Type: text
- Usage: KillMessage <message>
- Example: KillMessage "was killed by"
KillMessage2
- Description
- Second part of obituary, ( <TARGET> <KillMessage> <KILLER> <KillMessage2>)
- Parameters
- Type: text
- Usage: KillMessage2 <message>
- Example: KillMessage2 "'s thompson"
selfKillMessage
- Description
- Self-Kill obituary.
- Parameters
- Type: text
- Usage: selfKillMessage <message>
- Example: selfKillMessage "killed himself"
HeadshotWeapon
- Description
- Weapon can make headshots.
- Note: No value required, the entry will activate itself.
- Parameters
- Type: NOTHING
- Usage: HeadshotWeapon
- Example: HeadshotWeapon
GibbingWeapon
- Description
- Weapon can gib dead bodies.
- Note: No value required, the entry will activate itself.
- Parameters
- Type: NOTHING
- Usage: GibbingWeapon
- Example: GibbingWeapon
movementSpeedScale
- Description
- Speed reduction when player is holding this weapon.
- Parameters
- Type: floating point
- Usage: movementSpeedScale <value>
- Example: movementSpeedScale 0.8
bulletReflection
- Description
- Bullets may reflect off metal surfaces.
- Note: No value required, the entry will activate itself.
- Parameters
- Type: NOTHING
- Usage: bulletReflection
- Example: bulletReflection
CrouchSpreadRatio
- Description
- Spread reduction when player is crouching.
- Parameters
- Type: floating point
- Usage: CrouchSpreadRatio <value>
- Example: CrouchSpreadRatio 0.66
ProneSpreadRatio
- Description
- Spread reduction when player is proning.
- Parameters
- Type: floating point
- Usage: ProneSpreadRatio <value>
- Example: ProneSpreadRatio 0.33
noMidclipReload
- Description
- Weapon cannot reload when clip is not empty (eg. etmain's Garand)
- Parameters
- Type: text
- Usage: noMidclipReload <yes/no>
- Example: noMidclipReload "no"
DistanceFalloff
- Description
- Damage of this weapon is reduced by distance (Only weapons using bullets or pellets).
- Note: No value required, the entry will activate itself.
- Parameters
- Type: NOTHING
- Usage: DistanceFalloff
- Example: DistanceFalloff
HeadshotRatio
- Description
- Multiplier of damage when a headshot is inflicted with this weapon.
- Parameters
- Type: floating point
- Usage: HeadshotRatio <value>
- Example: HeadshotRatio 2.0
minHeadshotDamage
- Description
- Minimal damage that can be inflicted by making a headshot with this weapon.
- Parameters
- Type: integer
- Usage: minHeadshotDamage <value>
- Example: minHeadshotDamage 50
spreadRatio
- Description
- Ratio at which the spread is increased by moving/turning.
- Parameters
- Type: floating point
- Usage: spreadRatio <value>
- Example: spreadRatio 0.6
velocity2spread
- Description
- Moving around will cause this weapon to increase its spread.
- Note: No value required, the entry will activate itself.
- Parameters
- Type: NOTHING
- Usage: velocity2spread
- Example: velocity2spread
viewchange2spread
- Description
- Turning around will cause this weapon to increase its spread.
- Note: No value required, the entry will activate itself.
- Parameters
- Type: NOTHING
- Usage: viewchange2spread
- Example: viewchange2spread
New Client keys
foreShorten
- Description
- Reduction of model X axis.
- Parameters
- Type: floating point
- Usage: foreShorten <value>
- Example: foreShorten 0.8
offset
- Description
- Offset of weapon model.
- Parameters
- Type: vector
- Usage: offset <value>
- Example: offset 5.8 1.5 -0.4
recoil_pitchAdd
- Description
- Screen shake after attack. ( Up/Down )
- Parameters
- Type: integer
- Usage: recoil_pitchAdd <value>
- Example: recoil_pitchAdd 2
recoil_pitchAddRandom
- Description
- Up/Down kick after firing. Added to recoil_pitchAdd.
- Parameters
- Type: integer
- Usage: recoil_pitchAddRandom <value>
- Example: recoil_pitchAddRandom 2
recoil_yawRandom
- Description
- Random kick after firing ( Left/Right ).
- Parameters
- Type: integer
- Usage: recoil_yawRandom <value>
- Example: recoil_yawRandom 2
brassModel
- Description
- Model of casing for machinegunEjectBrass.
- Parameters
- Type: path
- Usage: brassModel <path>
- Example: brassModel "models/weapons2/shells/9mm.md3
bounceSound
- Description
- Sound when this weapon hits ground.
- Parameters
- Type: path
- Usage: bounceSound <path>
- Example: bounceSound "sound/weapons/bounce.wav"
clipBounceSound
- Description
- Sound when clip of this weapon hits ground.
- Parameters
- Type: path
- Usage: clipBounceSound <path>
- Example: clipBounceSound "sound/weapons/clipBounce.wav"
deathBySound
- Description
- Sound made by players killed with this weapon. Flamethrower uses this. Up to 4 of deathBySound can be defined.
- Parameters
- Type: path
- Usage: deathBySound <path>
- Example: deathBySound "sound/player/deathByThis.wav"
deathBySoundFar
- Description
- Sound made by players killed with this weapon. Flamethrower uses this. Up to 4 of deathBySoundFar can be defined. Played when player died further from viewport.
- Parameters
- Type: path
- Usage: deathBySoundFar <path>
- Example: deathBySoundFar "sound/player/deathByThis_echo.wav"
flashSmokeShader
- Description
- If defined, smoke using this shader will appear after firing, use keys bellow to specify it.
- Parameters
- Type: path
- Usage: flashSmokeShader <path>
- Example: flashSmokeShader "smokeParticle"
flashSmokeSize
- Description
- Size of this smoke. Default is 8
- Parameters
- Type: floating point
- Usage: flashSmokeSize <value>
- Example: flashSmokeSize 8.5
flashSmokeAlpha
- Description
- Transparency of this smoke. Defualt 0.25
- Parameters
- Type: floating point
- Usage: flashSmokeAlpha <value>
- Example: flashSmokeAlpha 0.5
flashSmokeLife
- Description
- Time this smoke lasts. Default 500.
- Parameters
- Type: integer
- Usage: flashSmokeLife <value>
- Example: flashSmokeLife 800
Setup (Changed in 1.2.5)
- Since No Quarter 1.2.5 the weapon scripts have been changed to include all weapon data used by the game. Older weapon scripts have therefore become obsolete, and will cause erratic behaviour on your server when used! First thing to do is to copy out the .weap file of the weapon you want to edit. The .weap files are located inside the (noquarter_v1.2.5.pk3) pk3 in the "weapons" folder. The name of the weapon is usually the name of the script.
- For this example, we'll use the mp40. So I copy out mp40.weap from noquarter_b1.0.2.pk3. Open it up in a text editor and you should see it start with some of the following:
weaponDef |
{ |
// This basically fills out weaponInfo_t |
client { |
- This is where you will add most server keys, before the client { part. Now, add in both { } after weaponDef like below:
weaponDef |
{ |
both |
{ |
} |
// This basically fills out weaponInfo_t |
client { |
- Now, you will add server keys (see at the top of this page) you wish to change in between the both brackets. Add as many keys as you want. Here is an example.
weaponDef |
{ |
both |
{ |
damage 21 |
spread 300 |
nextShotTime 110 |
SpreadScaleAdd 15 |
SpreadScaleAddRand 10 |
HeadShotWeapon |
GibbingWeapon |
} |
// This basically fills out weaponInfo_t |
client { |
- Now, I save this file as it was originally called: mp40.weap
- Note: The example above can only be used in No Quarter releases below 1.2.5!
- Note: For weapon with an alternate fire mode (rifle nades, bipod on some guns, scoped weapons, etc), make another entry after both { } called both_altweap { }. In there, put all the keys for the alternate mode.
- Tip: Syntax errors in scripts might cause server-crashes. Test your scripts weapon by weapon. Make sure all brackets { ... } are set correctly, all var-names match and string-var-values are surrounded by quotation marks >>> VAR "VALUE" <<<.
Implementation
- In the 'noquarter' directory on your server, create a new directory for your weapon scripts. In this example, I'm creating a directory called 'weaponmods' . It's in this new directory you will place all your custom weapon (.weap) scripts. So, drop them in there.
- Set the g_weaponScriptsDir CVAR in your server/noquarter cfg to whatever you named your weapon script directory. In my example, I would set g_weaponScriptsDir "weaponmods".
- Important Note:
- In case you set new client keys/client related data in the 'client' or 'both' functions of your weapon script, you also have to deliver your weap-files to clients.
- Create a new pk3 (or add to your custom pk3) containing a directory other than "weapons" (f.e. "weaponmods") with all your custom weap-files.
- Copy the pk3 to your 'noquarter' directory on the server (and to your external download URL if it exists).
- Now set the g_weaponScriptsDir CVAR in your server/noquarter cfg to point to the directory used in the pk3.
- The last step is to (re)start your server. Changing weapon scripts while the server is running is NOT recommended. Your weapons could disappear or behave erratically!