Scripted Weapons

From Obsidian Conflict Wiki
Revision as of 00:45, 8 March 2008 by Skidz (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"
	{
		"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"
	}

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.

playermodel Third Person Model.

bucket This is the horizontal slot on the players weapon selection hud element.

bucket_position This is the vertical slot on the players weapon selection hud element.

clip_size Size of the Primary Clip

clip2_size Size of the Secondary Clip

default_clip Default bullets in the Primary Clip, should be less than or equal to clip_size

default_clip2 Default bullets in the Secondary Clip, should be less 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?

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

"FireType1" "1"


Rate of Weapons Fire ( Not for laser or warp )

"FireRate1" "0.1"


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

"FastFire1" "0"


Allow Fire Underwater?

"FireUnderWater1" "0"


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

"BurstAmount1" "0"

"BetweenBurstTime1" "0.05"


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 )


  • Secondary Attack

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

"FireType2" "2"


Rate of Weapons Fire ( Not for laser or warp )

"FireRate2" "0.7"


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

"FastFire2" "0"


Allow Fire Underwater?

"FireUnderWater2" "0"


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

"BurstAmount2" "4"

"BetweenBurstTime2" "0.05"


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 )


  • 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"


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"