Scripted Weapons/zh-hans

From Obsidian Conflict Wiki
Jump to: navigation, search
黑曜石战争简体中文站: [[::Scripted Weapons|English]]  • [[::Scripted Weapons/zh-hans|中文(简体)‎]]

简介

在黑曜石战争中, 这个系统允许地图制作者们使用script来制作一个全新的武器. 注意:不需要代码编写的知识! 自定义武器系统拥有多个设置,可以允许您制作一个全新的武器, 拥有自定义的弹药,当然也可以让NPC持有他们

创建一个自定义武器

注意: 这是预览包含在Mod中脚本武器的最好方法.不要修改不属于你脚本武器,因为这可能会导致服务器和客户端之间数据的不匹配.你不能使用被修改的脚本武器造成任何伤害,但它们将会被认为是客户端的错误,所以如果你需要一个新武器,请自己制作个新的

首先我们来看一下一个简单的武器例子.

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


	// 武器的声音(每个声音类型最多为16种)
	"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" // 为脚本武器设置其他属性
	{

	// **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**
        //   NPC武器设置

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