Scripted Weapons

From Obsidian Conflict Wiki
Revision as of 17:03, 30 July 2011 by Maestro Fenix (talk | contribs)
Jump to: navigation, search
WIP.png This page is still a Work In Progress

Overview

In Obsidian Conflict, there is a system which allows a mapper to create brand new weapons based on simple plain text script files. No coding knowledge is required to create one of these scripts. Scripted weapons can be setup in many different ways and have the ability to be carried over level transitions, have their own custom ammos, and can also be held by NPCs.

Creating a Scripted Weapon Script

Note: It is best to take a look through the current scripted weapons included with the mod. Do not change scripted weapons that don't belong to you as this can cause mismatches between server and client. You can not cause any harm to a server by altering the scripted weapons, but they will not look correct on your client so if you need a new weapon, make your own.

First Lets start off with a basic script which we will add on to.

"WeaponData"
{
	// Weapon data is loaded by both the Game and Client DLLs.
	"printname"			"AK47" 
	"viewmodel"			"models/weapons/v_rif_ak47.mdl" 
	"playermodel"			"models/weapons/w_rif_ak47.mdl" 
	"anim_prefix"			"ar2" 

	"bucket"			"2" 
	"bucket_position"		"9" 

	"clip_size"			"30" 
	"clip2_size"			"0" 

	"default_clip"			"30" 
	"default_clip2"			"0" 

	"primary_ammo"			"ak47" 

	"secondary_ammo"		"None" 

	"weight"			"0" 
	"item_flags"			"0" 

	"BuiltRightHanded" 		"0"	
	"AllowFlipping" 		"1"  

	"csviewmodel"			"1" 

   	"ironsightoffset"  //Coordinates for the ironsights
	{
		"x"   "-7.00"
		"y"   "6.10"
		"z"   "2.90"
   	}


	// Sounds for the weapon. There is a max of 16 sounds per category (i.e. max 16 "single_shot" sounds)
	"SoundData"
	{
		"reload"		"Weapon_Pistol.Reload"
		"reload_npc"		"Weapon_Pistol.NPC_Reload"
		"empty"			"Weapon_Pistol.Empty"
		"single_shot"		"Weapon_AK47.Single"
		"single_shot_npc"	"Weapon_AK47.Single"
		"special1"		"Weapon_AK47.Single"
	}

        // Weapon Sprite data is loaded by the Client DLL.
	"TextureData"
	{
		"weapon"
		{
				"font"		"CSWeaponIcons"
				"character"	"b"
		}
		"weapon_s"
		{	
				"font"		"CSWeaponIconsSelected"
				"character"	"b"
		}
		"ammo"
		{
				"font"		"WeaponIcons"
				"character"	"u"
		}
		"crosshair"
		{
				"font"		"Crosshairs"
				"character"	"Q"
		}
		"autoaim"
		{
				"file"		"sprites/crosshairs"
				"x"			"0"
				"y"			"48"
				"width"		"24"
				"height"	"24"
		}
	}
	"Advanced" // only for Weapon_Scripted
	{

	// **Primary Attack**

		// 0 = none, 1 = Basic Bullet, 2 = Burst, 3 = shotgun, 4 = autoshotgun, 5 = laser, 6 = warp
		"FireType1"	"1"


		// Rate of Weapons Fire ( Not for laser or warp )
		"FireRate1"	"0.09"

		// Allow a refire as fast as the player can click, Basic Bullet Only.
		"FastFire1"	"0"

		// Allow Fire Underwater?
		"FireUnderWater1"	"0"

		// For Bullet accuracy
		"FireCone1"		"1" // Starting Value ( 0-20 )
		"FireConeLerp1"		"1" // Bool
		"FireConeLerpto1"	"5" // Value to lerp accuracy too ( 0-20 )

	// **Secondary Attack**

		// 0 = none, 1 = Basic Bullet, 2 = Burst, 3 = shotgun, 4 = autoshotgun, 5 = laser, 6 = warp, 8 = scope
		"FireType2"	"0"

	// **Global Weapon Settings**

		// Number of Recoil Animations, weapon models with ACT_VM_RECOIL animations.
		// ( Only if a weapon has recoil animations, Not for laser or warp )
		"NumberOfRecoilAnims"	"0"

		// Shots fired till next recoil animation. ( Only if a weapon has recoil animations )
		"RecoilIncrementSpeed"	"1"

		// 1 = Pistol, 2 = AR2, 3 = crossbow, 4 = physgun, 5 = shotgun, 6 = smg1
		// This is the player animation set that will be used on all players you view ingame.
		"PlayerAnimationSet"	"2"

	// **NPC Weapon Settings**

		// NPCs use a ShotRegulator in code, these settings corrispond with it.
		"NPCRateofFire"		"0.2"
		"NPCMinBursts"		"1"
		"NPCMaxBursts"		"4"
		"NPCMinRest"		"0.3"
		"NPCMaxRest"		"0.6"

		// Range the NPC can fire this weapon at, if the player is less than min, the npc cant fire and will try to get a better vantage point.
		"NPCMinRange1"		"24"
		"NPCMaxRange1"		"1500"
		"NPCMinRange2"		"24"
		"NPCMaxRange2"		"200"
	}
}

There are a number of values here you should be familiar with.

printname This is the name that will show up in-game on the players weapon selection hud.

viewmodel First Person Model (v_model used by the weapon).

playermodel Third Person Model (w_model used by the weapon).

anim_prefix Name of the animation that the playermodel will use (it got override later in Advanced Options).

bucket This is the horizontal slot on the players weapon selection hud element. It starts at 0.

bucket_position This is the vertical slot on the players weapon selection hud element. It starts at 0.

clip_size Size of the actual magazine for the Primary Fire.

clip2_size Size of the actual magazine for the Secondary Fire.

default_clip Total number of bullets/ammo that can carry for the Primary Fire, should be more than or equal to clip_size

default_clip2 Total number of bullets/ammo that can carry for the Secondary Fire, should be more than or equal to clip2_size

BuiltRightHanded Was this model built right handed?

AllowFlipping Allow the player to flip this model from right handed to left handed?

csviewmodel Was this weapon view model designed for Counter-Strike Source? (Set to 1 if you want see more of your viewmodel).

ironsightoffset Coordinates for the ironsights

Alright, and now the SoundData options. You can put soundscript entries in these fields. If you model has built in sounds you should comment them out like I have done above for the reload. The AK47 model has reload sound ques built right into the model.


Setting up a scripted weapons advanced options

Only the weapon_scripted entity can use the "Advanced" configurations. All others will only use the basic configurations. Here is a list of Advanced options you can use.

  • Primary Attack

0 = none, 1 = Basic Bullet, 2 = Burst, 3 = shotgun, 4 = autoshotgun, 5 = laser, 6 = warp 9 = NadeType

"FireType1" "1"


What type of "weapon" will shoot the primary fire.

Note: Autoshotgun, Laser and Warp types of weapon are broken at the moment.



Rate of Weapons Fire ( Not for laser or warp )

"FireRate1" "0.1"


Time between each shoot of the weapon. Less amount, more speed of fire.

Note: If you use shotgun type, you will not see any changes under "0.3", because is bugged at the moment.



Allow a refire as fast as the player can click, Basic Bullet Only.

"FastFire1" "0"


As the title says, The faster you click, the faster you shoot.

Note: Doesnt work with Shotgun type.



Allow Fire Underwater?

"FireUnderWater1" "0"


As the title says, it allows or not fire under the water.

Note: Bugged at the moment.


How many bullets in a burst. ( For Burst Weapon Only! )

"BurstAmount1" "0"

"BetweenBurstTime1" "0.05"


How many bullets are shot in a burst.



For Bullet accuracy

"FireCone1" "2" // Starting Value ( 0-20 )

"FireConeLerp1" "1" // Bool, should be 1 to use lerp

"FireConeLerpto1" "6" // Value to lerp accuracy too ( 0-20 )


This allow you make your weapon more precise or not:

FireCone1: Higher numbers makes more imprecise the weapon.

FireConeLerp1: It "randomize" the vagueness of the weapon.

FireConeLerpto1: Mix the settings of above.


  • Secondary Attack

0 = none, 1 = Basic Bullet, 2 = Burst, 3 = shotgun, 4 = autoshotgun, 5 = laser, 6 = warp, 7 = scope 8 = Launch Nade

"FireType2" "2"


What type of "weapon" will shoot the secondary fire.

Note: Autoshotgun, Laser and Warp types of weapon are broken at the moment.



Rate of Weapons Fire ( Not for laser or warp )

"FireRate2" "0.7"


Time between each shoot of the weapon. Less amount, more speed of fire.

Note: If you use shotgun type, you will not see any changes under "0.3", because is bugged at the moment.



Allow a refire as fast as the player can click, Basic Bullet Only.

"FastFire2" "0"


As the title says, The faster you click, the faster you shoot.

Note: Doesnt work with Shotgun type.



Allow Fire Underwater?

"FireUnderWater2" "0"


As the title says, it allows or not fire under the water.

Note: Bugged at the moment.



How many bullets in a burst. ( For Burst Weapon Only! )

"BurstAmount2" "4"

"BetweenBurstTime2" "0.05"


How many bullets are shot in a burst.



Secondary Fire uses Secondary Ammo Type. If 0, will use primary ammo.

"SecondaryAmmoUsed" "0" //( NOT YET FUNCTIONAL )


For Bullet accuracy

"FireCone2" "2" // Starting Value ( 0-20 )

"FireConeLerp2" "1" // Bool, should be 1 to use lerp

"FireConeLerpto2" "6" // Value to lerp accuracy too ( 0-20 )


This allow you make your weapon more precise or not:

FireCone1: Higher numbers makes more imprecise the weapon.

FireConeLerp1: It "randomize" the vagueness of the weapon.

FireConeLerpto1: Mix the settings of above.



  • Global Weapon Settings

Number of Recoil Animations, weapon models with ACT_VM_RECOIL animations. ( Only if a weapon has recoil animations, Not for laser or warp )

"NumberOfRecoilAnims" "0"


Shots fired till next recoil animation. ( Only if a weapon has recoil animations )

"RecoilIncrementSpeed" "1"


1 = Pistol, 2 = AR2, 3 = crossbow, 4 = physgun, 5 = shotgun, 6 = smg1 7 = nade This is the player animation set that will be used on all players you view ingame.

"PlayerAnimationSet" "2"


Grenade Damage

"GrenadeDamage" "100.0"


Damage done for the grenade at impact (only if you used Launch nade weapon).



Grenade Radius

"GrenadeRadius" "250.0"


Radius of damage of the grenade at impact (only if you used Launch nade weapon).



Tracer type ( Bullet weapons only ) 0 = none, 1 = normal, 2 = strider, 3 = ar2, 4 = helicopter, 5 = Gunship, 6 = Gauss, 7 = Airboat

"TracerType" "1"


Tracer Frequency

"TracerFrequency" "2"


Bullet Impact Effect, 0 = none, 1 = normal, 2 = AR2, 3 = jeep, 4 = Gauss, 5 = airboat, 6 = helicopter

"ImpactEffect" "1"


Sniper Scope Settings

"UseScopedFireCone" "1"

"ScopedFireCone" "0"

"ScopedColorR" "255"

"ScopedColorG" "255"

"ScopedColorB" "255"


  • NPC Weapon Settings

NPCs use a ShotRegulator in code, these settings corrispond with it.

"NPCRateofFire" "0.1"

"NPCMinBursts" "1"

"NPCMaxBursts" "3"

"NPCMinRest" "0.3"

"NPCMaxRest" "0.6"


Range the NPC can fire this weapon at, if the player is less than min, the npc cant fire and will try to get a better vantage point.

"NPCMinRange1" "24"

"NPCMaxRange1" "1500"

"NPCMinRange2" "24"

"NPCMaxRange2" "200"


  • Nadetype ("FireType1" "9" options)

Options only if you chosen for the primary fire "Nade type".

// 1 = frag "HandNadetype" "1"

"HandNadeTimer" "2.5" //Time that takes the grenade in explode.

"HandNadeRadius" "4.0" // This corresponds with the radius of the nade model, not the damage.

"HandNadeDmgRadius" "250.0"

"HandNadeDmg" "150.0"