Skip to content

Bullet Profile Ammunition Modifier

Vuthakral edited this page Apr 22, 2023 · 14 revisions

The "Bullet Profile" type of the attachment base entity is used to define the characteristic of an ammunition. Such as its damage modifier, how it affects the spread, damages dealt to and from players & NPCs, and how much more or less damage they will do to specified material types.

The way this works as an "attachment" is that the first one defined in a weapon will be its default, and will always be usable with that weapon regardless of if the player has it unlocked as an attachment or not. Subsequent referenced bprofiles in a weapon will become selectable attachments so long as the player has them.

Note: While not required, it is highly recommended you consider not just making one of these for every single gun in your pack. You can use one for multiple weapons.

Step 1: Create a lua file for the attachment.

Browse to your addon's folder. You must create/save a lua document under the folder lua\entities\. What you name this file is up to you, but for your own convenience sake I would recommend naming it along the lines of drc_abp_<yourattnamehere>. This helps to find what you are looking for when sorting files alphabetically (the standard for the vast majority of file browsers.)

Step 2: Paste the basic lua in.

Below this line, you will find the basic lua required for a bullet profile attachment type.


AddCSLuaFile()

ENT.Type = "anim"
ENT.Base = "draconic_attachment_base"

ENT.PrintName 	= "CHANGE TO WHAT YOU WANT YOUR SPAWNICON TO SAY"
ENT.Author 		= "CHANGE TO YOUR NAME"
ENT.Category 	= "CHANGE TO YOUR SPAWNMENU ENTITY CATEGORY"

ENT.Spawnable = true
ENT.AdminOnly = false

ENT.InfoName = "CHANGE TO WHAT YOU WANT TO DISPLAY IN THE ATTACHMENT MENU"
ENT.InfoDescription = "CHANGE TO THE DESCRIPTION YOU WANT TO DISPLAY IN THE ATTACHMENT MENU WHEN HIGHLIGHTED"

ENT.Model = "models/Items/item_item_crate.mdl"

Step 3: Add the Bullet Table

Below this line is a table you will add to your lua file and tweak to your desired settings. Anything unchanged afterwards or that you don't need can be safely removed.


ENT.BulletTable = {
	Damage = 1,
	PvPDamageMul = 1,
	PvEDamageMul = 1,
	EvPDamageMul = 1,
	EvEDamageMul = 1,
	VehicleDamageMul = 1,
	PvEUseHL2Scale = true,
	EvPUseHL2Scale = true,
	DamageType = DMG_BULLET,
	HitboxDamageMuls = {
		["HITGROUP_GENERIC"] = 1,
		["HITGROUP_HEAD"] = 1,
		["HITGROUP_CHEST"] = 1,
		["HITGROUP_STOMACH"] = 1,
		["HITGROUP_LEFTARM"] = 1,
		["HITGROUP_RIGHTARM"] = 1,
		["HITGROUP_LEFTLEG"] = 1,
		["HITGROUP_RIGHTLEG"] = 1,
		["HITGROUP_GEAR"] = 1,
	},
	MaterialDamageMuls = {
		MAT_DEFAULT = 1,
		MAT_ANTLION = 1,
		MAT_ARMORFLESH = 1,
		MAT_BLOODYFLESH = 1,
		MAT_ZOMBIEFLESH = 1,
		MAT_STRIDER = 1,
		MAT_HUNTER = 1,
		MAT_PAPER = 1,
		MAT_EGGSHELL = 1,
		MAT_FLESH = 1,
		MAT_WATERMELON = 1,
		MAT_ALIENFLESH = 1,
		MAT_CLIP = 1, -- Unused but defined to avoid potential errors
		MAT_PLASTIC = 1,
		MAT_PLASTIC_BARREL = 1,
		MAT_PAINTCAN = 1,
		MAT_POPCAN = 1,
		MAT_CANISTER = 1,
		MAT_VENT = 1,
		MAT_GRENADE = 1,
		MAT_WEAPON = 1,
		MAT_METAL = 1,
		MAT_METALVEHICLE = 1,
		MAT_COMBINE_METAL = 1,
		MAT_COMBINE_GLASS = 1,
		MAT_GUNSHIP = 1,
		MAT_ROLLER = 1,
		MAT_SOLIDMETAL = 1,
		MAT_SLIPPERYMETAL = 1,
		MAT_METALPANEL = 1,
		MAT_METALVENT = 1,
		MAT_METAL_BARREL = 1,
		MAT_FLOATING_METAL_BARREL = 1,
		MAT_METAL_BOX = 1,
		MAT_GRATE = 1,
		MAT_CHAINLINK = 1,
		MAT_COMPUTER = 1,
		MAT_CONCRETE = 1,
		MAT_RUBBER = 1,
		MAT_RUBBERTIRE = 1,
		MAT_DIRT = 1,
		MAT_ROCK = 1,
		MAT_BOULDER = 1,
		MAT_SAND = 1,
		MAT_FOLIAGE = 1,
		MAT_SLOSH = 1,
		MAT_GRASS = 1,
		MAT_CARPET = 1,
		MAT_WOOD = 1,
		MAT_WOOD_CRATE = 1,
		MAT_WOOD_FURNITURE = 1,
		MAT_WOOD_SOLID = 1,
		MAT_WOOD_PLANK = 1,
		MAT_CARDBOARD = 1,
		MAT_TILE = 1,
		MAT_POTTERY = 1,
		MAT_SNOW = 1,
		MAT_PORCELAIN = 1,
		MAT_GLASS = 1,
		MAT_GLASSBOTTLE = 1,
		MAT_ICE = 1,
		MAT_WARPSHIELD = 1,
		MAT_ITEM = 1,
		MAT_JALOPY = 1,
		MAT_SLIME = 1,
		MAT_WADE = 1,
	},
	SplashRadius = nil,
	SplashDamageMul = 1,
	AmmoType = "Pistol",
	FallbackBaseAmmoType = "Pistol",
	NumShots = 1,
	NumShots_OC = 1,
	Force = 1,
	Kick = 1,
	KickHoriz = 1,
	Spread = 1,
	SpreadDiv = 1,
	IronRecoilMul = 1,
	RecoilUp = 1,
	RecoilDown = 1,
	RecoilHoriz = 1,
	ClipSizeMul = 1,
	ImpactDecal = nil,
	BurnDecal = nil,
	MuzzleFlash = {
		Dynamic = true,
		Mask = "effects/flashlight001",
		FarZ = 500,
		FOV = 140,
		Simple = true,
		Colour = Color(255, 180, 85, 3),
		Size = 150,
		LifeTime = 0.5,
	},
	Callback = function(info)
	end,
}

An explanation on each Bullet Table setting:

  • Damage = number | Multiplier value to scale a weapon's primary damage number. A value of 0.5 will half the damage, while 2 will double it.
  • PvPDamageMul = number | Players-vs-Player damage multiplier. A setting of 0.1 will result in only 10% damage from players dealt to players.
  • PvEDamageMul = number | Players-vs-Enemy damage multiplier. A setting of 0.1 will result in only 10% damage from players dealt to NPCs / Nextbots
  • EvPDamageMul = number | Enemy-vs-Player damage multiplier. You get the idea by now.
  • EvEDamageMul = number | Enemy-vs-Enemy damage multiplier.
  • VehicleDamageMul = number | damage multiplier applied to vehicles. This affects all vehicles including SF & LFS. Does not alter damage dealt to players.
  • PvEUseHL2Scale = true or false | Whether or not PvE damage should be scaled with the current game difficulty setting like Half-Life 2 weapons are. (default: true) (Game difficulty convar is skill 1-3, with 1 being easy, 2 being medium, and 3 being hard.)
  • EvPUseHL2Scale = true or false | Same as the previous, except scaling for NPCs & NextBots vs players.
  • DamageType = DMG Enum | https://wiki.facepunch.com/gmod/Enums/DMG
  • HitboxDamageMuls - table | Scale damage times this number based on the hitbox a bullet has connected with. Half-Life 2's original bullet scaling still applies here, so factor that into your own numbers. E.g. a headshot will still do 2x base damage, then multiplied by this. Chest is 1x, gut 0.8x, arms & legs 0.2x
  • MaterialDamageMuls = table | Scale damage times this number based on the impacted material type. There is no complete list of all MAT enums, but I believe I've covered about 90% of them. You can remove any you don't need. If you happen upon one I've missed it will print it to the console. Please report them to me!
  • SplashRadius = Distance in world units | For hitscan bullets, how large should the splash radius be? (default: nil)
  • SplashDamageMul = number | mutiplier for how much the base damage the splash should deal from the weapon's primary damage, after being affected by the rest of the above modifiers. (Scales damage down as the distance from the splash origin increases.) (Default: 1)
  • AmmoType = valid ammotype | What ammotype this ammunition uses from the player's inventory (Default: Pistol)
  • FallbackBaseAmmoType = any valid standard ammotype | The ammotype this ammunition will use when sv_drc_forcebasegameammo is set to 1. MUST be a base-game ammotype. If it is not, it will default set it to Pistol.
  • NumShots = number | How many rounds/projectiles should the weapon create?
  • NumShots_OC = number | How many rounds/projectiles should the weapon create on an overcharged shot?
  • Force = number | SWEP.Primary.Force multiplier
  • Kick = number | SWEP.Primary.Kick multiplier
  • KickHoriz = number | You get the idea.
  • Spread = number
  • SpreadDiv = number
  • IronRecoilMul = number | Only applicable when sv_drc_callofdutyspread is set to 1.
  • RecoilUp = number
  • RecoilDown = number
  • RecoilHoriz = number
  • ClipSizeMul = number | Multiplier for the "size" of a bullet. Can increase/decrease the amount of ammo can/will be loaded into the weapon's current magazine. Intended to be used in tandem with magazine attachments later on when I have time to code them. For example sake: If a weapon has 30 shots and ClipSizeMul is set to 0.5, it will only have 15 rounds. The easiest way to calculate this setting realistically is the find the percentage difference in size from whatever the standard round is you're comparing to the one you're setting up this profile for, and subtract it from 100, giving you the number you need in percentage. E.g. If a round laying flat on its side on a table is (example sake) approx. 1 inch high, and the one you're designing this profile for is 1.2 inches high, this would make it 20% larger than the standard round, meaning ClipSizeMul would need to be set to 0.8, which is 80%. (100 - 20 = 80 -> 80% -> 0.8). It sounds stupid, but it works.
  • ImpactDecal = any valid decal
  • BurnDecal = any valid decal -- This is intended for use with decals which fade away.
  • MuzzleFlash table -- Settings are pretty self explanatory, but to make it clear: Dynamic is what determines if the muzzle flash for the local player will use a dynamic shadow or not (and the three settings after it). The Simple is what determines if the weapon makes the traditional Source muzzle flash you'd expect.
  • Callback function -- Leave info in there, as this is the callback information for the bullet of a weapon. Custom function code which lets you write your own code functionality into the ammo attachment.

Step 4: Adding the bullet bullet profile to your weapon.

Simply paste this into your weapon, and replace "REPLACE ME" with your lua file's name, e.g. drc_abp_specialround.


SWEP.AttachmentTable = {
	AmmunitionTypes = {"REPLACE ME"}
}

Please note this system is in its infancy, and is very experimental. Please report any issues to me directly through either the github issues here, or by contacting me on Steam/Discord.
Clone this wiki locally