Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Gun Smoke Particles #13963

Merged
merged 5 commits into from
Sep 26, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions code/__DEFINES/conflict.dm
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,7 @@
#define GUN_NO_PITCH_SHIFT_NEAR_EMPTY (1<<13)
#define GUN_SHOWS_AMMO_REMAINING (1<<14) //Whether the mob sprite reflects the ammo level
#define GUN_SHOWS_LOADED (1<<15) //Whether the mob sprite as loaded or unloaded, a binary version of the above
#define GUN_SMOKE_PARTICLES (1<<16) //Whether the gun has smoke particles

//reciever_flags. Used to determin how the gun cycles, what kind of ammo it uses, etc.
#define AMMO_RECIEVER_REQUIRES_UNIQUE_ACTION (1<<0)
Expand Down
3 changes: 2 additions & 1 deletion code/_globalvars/bitfields.dm
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,8 @@ GLOBAL_LIST_INIT(bitfields, list(
"GUN_AMMO_COUNT_BY_SHOTS_REMAINING" = GUN_AMMO_COUNT_BY_SHOTS_REMAINING,
"GUN_NO_PITCH_SHIFT_NEAR_EMPTY" = GUN_NO_PITCH_SHIFT_NEAR_EMPTY,
"GUN_SHOWS_AMMO_REMAINING" = GUN_SHOWS_AMMO_REMAINING,
"GUN_SHOWS_LOADED" = GUN_SHOWS_LOADED
"GUN_SHOWS_LOADED" = GUN_SHOWS_LOADED,
"GUN_SMOKE_PARTICLES" = GUN_SMOKE_PARTICLES
),
"flags_flamer_features" = list(
"FLAMER_IS_LIT" = FLAMER_IS_LIT,
Expand Down
25 changes: 24 additions & 1 deletion code/modules/projectiles/gun_system.dm
Original file line number Diff line number Diff line change
@@ -1,3 +1,19 @@
/particles/firing_smoke
icon = 'icons/effects/96x96.dmi'
icon_state = "smoke5"
width = 500
height = 500
count = 5
spawning = 15
lifespan = 0.5 SECONDS
fade = 2.4 SECONDS
grow = 0.12
drift = generator(GEN_CIRCLE, 8, 8)
scale = 0.1
spin = generator(GEN_NUM, -20, 20)
velocity = list(50, 0)
friction = generator(GEN_NUM, 0.3, 0.6)

/obj/item/weapon/gun
name = "Guns"
desc = "Its a gun. It's pretty terrible, though."
Expand Down Expand Up @@ -968,7 +984,14 @@
simulate_recoil(dual_wield, firing_angle)

projectile_to_fire.fire_at(target, master_gun ? gun_user : loc, src, projectile_to_fire.ammo.max_range, projectile_to_fire.projectile_speed, firing_angle, suppress_light = HAS_TRAIT(src, TRAIT_GUN_SILENCED))

if(CHECK_BITFIELD(flags_gun_features, GUN_SMOKE_PARTICLES))
var/x_component = sin(firing_angle) * 40
var/y_component = cos(firing_angle) * 40
var/obj/effect/abstract/particle_holder/gun_smoke = new(get_turf(src), /particles/firing_smoke)
gun_smoke.particles.velocity = list(x_component, y_component)
addtimer(VARSET_CALLBACK(gun_smoke.particles, count, 0), 5)
addtimer(VARSET_CALLBACK(gun_smoke.particles, drift, 0), 3)
QDEL_IN(gun_smoke, 0.6 SECONDS)
shots_fired++

if(fire_animation) //Fires gun firing animation if it has any. ex: rotating barrel
Expand Down
15 changes: 12 additions & 3 deletions code/modules/projectiles/guns/grenade_launchers.dm
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ The Grenade Launchers
/obj/item/weapon/gun/grenade_launcher
w_class = WEIGHT_CLASS_BULKY
gun_skill_category = SKILL_FIREARMS
flags_gun_features = GUN_WIELDED_FIRING_ONLY|GUN_AMMO_COUNTER
flags_gun_features = GUN_WIELDED_FIRING_ONLY|GUN_AMMO_COUNTER|GUN_SMOKE_PARTICLES
reciever_flags = NONE
throw_speed = 2
throw_range = 10
Expand Down Expand Up @@ -87,6 +87,15 @@ The Grenade Launchers
grenade_to_launch.throw_at(target, max_range, 3, (gun_user ? gun_user : loc))
if(fire_animation)
flick("[fire_animation]", src)
if(CHECK_BITFIELD(flags_gun_features, GUN_SMOKE_PARTICLES))
var/firing_angle = Get_Angle(user_turf, target)
var/x_component = sin(firing_angle) * 40
var/y_component = cos(firing_angle) * 40
var/obj/effect/abstract/particle_holder/gun_smoke = new(get_turf(src), /particles/firing_smoke)
gun_smoke.particles.velocity = list(x_component, y_component)
addtimer(VARSET_CALLBACK(gun_smoke.particles, count, 0), 5)
addtimer(VARSET_CALLBACK(gun_smoke.particles, drift, 0), 3)
QDEL_IN(gun_smoke, 0.6 SECONDS)
return TRUE

/obj/item/weapon/gun/grenade_launcher/get_ammo_list()
Expand Down Expand Up @@ -141,7 +150,7 @@ The Grenade Launchers
slot = ATTACHMENT_SLOT_UNDER
attach_delay = 3 SECONDS
detach_delay = 3 SECONDS
flags_gun_features = GUN_AMMO_COUNTER|GUN_IS_ATTACHMENT|GUN_ATTACHMENT_FIRE_ONLY|GUN_WIELDED_STABLE_FIRING_ONLY|GUN_WIELDED_FIRING_ONLY
flags_gun_features = GUN_AMMO_COUNTER|GUN_IS_ATTACHMENT|GUN_ATTACHMENT_FIRE_ONLY|GUN_WIELDED_STABLE_FIRING_ONLY|GUN_WIELDED_FIRING_ONLY|GUN_SMOKE_PARTICLES
pixel_shift_x = 14
pixel_shift_y = 18
allowed_ammo_types = list(
Expand Down Expand Up @@ -199,7 +208,7 @@ The Grenade Launchers
flags_equip_slot = ITEM_SLOT_BACK|ITEM_SLOT_BELT
wield_delay = 0.2 SECONDS
aim_slowdown = 1
flags_gun_features = GUN_AMMO_COUNTER
flags_gun_features = GUN_AMMO_COUNTER|GUN_SMOKE_PARTICLES
attachable_allowed = list()
attachable_offset = list("muzzle_x" = 33, "muzzle_y" = 18,"rail_x" = 14, "rail_y" = 22, "under_x" = 19, "under_y" = 14, "stock_x" = 19, "stock_y" = 14)
fire_delay = 1.05 SECONDS
Expand Down
18 changes: 9 additions & 9 deletions code/modules/projectiles/guns/mounted.dm
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@
burst_scatter_mult = 0

flags_item = IS_DEPLOYABLE|TWOHANDED
flags_gun_features = GUN_AMMO_COUNTER|GUN_DEPLOYED_FIRE_ONLY|GUN_WIELDED_FIRING_ONLY|GUN_IFF
flags_gun_features = GUN_AMMO_COUNTER|GUN_DEPLOYED_FIRE_ONLY|GUN_WIELDED_FIRING_ONLY|GUN_IFF|GUN_SMOKE_PARTICLES
gun_firemode_list = list(GUN_FIREMODE_BURSTFIRE, GUN_FIREMODE_AUTOMATIC)

attachable_allowed = list(
Expand Down Expand Up @@ -114,7 +114,7 @@
windup_sound = 'sound/weapons/guns/fire/tank_minigun_start.ogg'

flags_item = IS_DEPLOYABLE|TWOHANDED
flags_gun_features = GUN_AMMO_COUNTER|GUN_DEPLOYED_FIRE_ONLY|GUN_WIELDED_FIRING_ONLY
flags_gun_features = GUN_AMMO_COUNTER|GUN_DEPLOYED_FIRE_ONLY|GUN_WIELDED_FIRING_ONLY|GUN_SMOKE_PARTICLES
gun_firemode_list = list(GUN_FIREMODE_AUTOMATIC)
actions_types = list(/datum/action/item_action/aim_mode)
aim_time = 2 SECONDS
Expand Down Expand Up @@ -172,7 +172,7 @@
extra_delay = 1.5 SECONDS

flags_item = IS_DEPLOYABLE|TWOHANDED|DEPLOYED_NO_PICKUP|DEPLOY_ON_INITIALIZE
flags_gun_features = GUN_AMMO_COUNTER|GUN_DEPLOYED_FIRE_ONLY|GUN_WIELDED_FIRING_ONLY|GUN_IFF
flags_gun_features = GUN_AMMO_COUNTER|GUN_DEPLOYED_FIRE_ONLY|GUN_WIELDED_FIRING_ONLY|GUN_IFF|GUN_SMOKE_PARTICLES
gun_firemode_list = list(GUN_FIREMODE_AUTOMATIC, GUN_FIREMODE_BURSTFIRE, GUN_FIREMODE_AUTOBURST)

attachable_allowed = list(/obj/item/attachable/scope/unremovable/standard_atgun)
Expand Down Expand Up @@ -216,7 +216,7 @@
fire_delay = 0.7 SECONDS

flags_item = IS_DEPLOYABLE|TWOHANDED|DEPLOYED_NO_PICKUP|DEPLOY_ON_INITIALIZE
flags_gun_features = GUN_AMMO_COUNTER|GUN_DEPLOYED_FIRE_ONLY|GUN_WIELDED_FIRING_ONLY
flags_gun_features = GUN_AMMO_COUNTER|GUN_DEPLOYED_FIRE_ONLY|GUN_WIELDED_FIRING_ONLY|GUN_SMOKE_PARTICLES
gun_firemode_list = list(GUN_FIREMODE_AUTOMATIC)

attachable_allowed = list(/obj/item/attachable/scope/unremovable/tl102/nest)
Expand Down Expand Up @@ -258,7 +258,7 @@
fire_delay = 3 SECONDS

flags_item = IS_DEPLOYABLE|TWOHANDED|DEPLOYED_NO_PICKUP|DEPLOY_ON_INITIALIZE
flags_gun_features = GUN_AMMO_COUNTER|GUN_DEPLOYED_FIRE_ONLY|GUN_WIELDED_FIRING_ONLY
flags_gun_features = GUN_AMMO_COUNTER|GUN_DEPLOYED_FIRE_ONLY|GUN_WIELDED_FIRING_ONLY|GUN_SMOKE_PARTICLES
gun_firemode_list = list(GUN_FIREMODE_SEMIAUTO)
backblastdamage = FALSE

Expand Down Expand Up @@ -292,7 +292,7 @@
aim_slowdown = 3
wield_delay = 5 SECONDS

flags_gun_features = GUN_AMMO_COUNTER|GUN_IFF
flags_gun_features = GUN_AMMO_COUNTER|GUN_IFF|GUN_SMOKE_PARTICLES

// This is a deployed IFF-less MACHINEGUN, has 500 rounds, drums do not fit anywhere but your belt slot and your back slot. But it has 500 rounds. That's nice.

Expand All @@ -319,7 +319,7 @@
burst_amount = 1

flags_item = IS_DEPLOYABLE|TWOHANDED
flags_gun_features = GUN_AMMO_COUNTER|GUN_DEPLOYED_FIRE_ONLY|GUN_WIELDED_FIRING_ONLY
flags_gun_features = GUN_AMMO_COUNTER|GUN_DEPLOYED_FIRE_ONLY|GUN_WIELDED_FIRING_ONLY|GUN_SMOKE_PARTICLES
gun_firemode_list = list(GUN_FIREMODE_AUTOMATIC)

attachable_allowed = list(
Expand Down Expand Up @@ -383,7 +383,7 @@
attachable_offset = list("muzzle_x" = 45, "muzzle_y" = 19,"rail_x" = 18, "rail_y" = 24, "under_x" = 28, "under_y" = 13, "stock_x" = 0, "stock_y" = 0)

flags_item = IS_DEPLOYABLE|TWOHANDED
flags_gun_features = GUN_AMMO_COUNTER|GUN_WIELDED_FIRING_ONLY
flags_gun_features = GUN_AMMO_COUNTER|GUN_WIELDED_FIRING_ONLY|GUN_SMOKE_PARTICLES
deployable_item = /obj/machinery/deployable/mounted
gun_firemode_list = list(GUN_FIREMODE_AUTOMATIC)
actions_types = list(/datum/action/item_action/aim_mode)
Expand Down Expand Up @@ -435,7 +435,7 @@
attachable_allowed = list(/obj/item/attachable/scope/unremovable/standard_atgun)

flags_item = IS_DEPLOYABLE|TWOHANDED|DEPLOYED_NO_PICKUP|DEPLOY_ON_INITIALIZE|DEPLOYED_NO_ROTATE_ANCHORED|DEPLOYED_ANCHORED_FIRING_ONLY
flags_gun_features = GUN_AMMO_COUNTER|GUN_DEPLOYED_FIRE_ONLY|GUN_WIELDED_FIRING_ONLY
flags_gun_features = GUN_AMMO_COUNTER|GUN_DEPLOYED_FIRE_ONLY|GUN_WIELDED_FIRING_ONLY|GUN_SMOKE_PARTICLES

gun_firemode_list = list(GUN_FIREMODE_SEMIAUTO)
actions_types = list(/datum/action/item_action/aim_mode)
Expand Down
22 changes: 11 additions & 11 deletions code/modules/projectiles/guns/pistols.dm
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@
/obj/item/attachable/buildasentry,
)

flags_gun_features = GUN_CAN_POINTBLANK|GUN_AMMO_COUNTER
flags_gun_features = GUN_CAN_POINTBLANK|GUN_AMMO_COUNTER|GUN_SMOKE_PARTICLES
actions_types = list(/datum/action/item_action/aim_mode) // all pistols can aim mode
aim_speed_modifier = 0.65
scatter = -2
Expand Down Expand Up @@ -95,7 +95,7 @@
)

muzzleflash_iconstate = "muzzle_flash_laser"
flags_gun_features = GUN_CAN_POINTBLANK|GUN_ENERGY|GUN_AMMO_COUNTER|GUN_IS_ATTACHMENT
flags_gun_features = GUN_CAN_POINTBLANK|GUN_ENERGY|GUN_AMMO_COUNTER|GUN_IS_ATTACHMENT|GUN_SMOKE_PARTICLES
reciever_flags = AMMO_RECIEVER_MAGAZINES|AMMO_RECIEVER_AUTO_EJECT|AMMO_RECIEVER_DO_NOT_EJECT_HANDFULS|AMMO_RECIEVER_CYCLE_ONLY_BEFORE_FIRE
actions_types = list()
wield_delay = 0.5 SECONDS
Expand Down Expand Up @@ -190,7 +190,7 @@
/obj/item/attachable/shoulder_mount,
)

flags_gun_features = GUN_CAN_POINTBLANK|GUN_AMMO_COUNTER
flags_gun_features = GUN_CAN_POINTBLANK|GUN_AMMO_COUNTER|GUN_SMOKE_PARTICLES
attachable_offset = list("muzzle_x" = 31, "muzzle_y" = 22,"rail_x" = 13, "rail_y" = 24, "under_x" = 21, "under_y" = 17, "stock_x" = 21, "stock_y" = 17)

fire_delay = 0.2 SECONDS
Expand Down Expand Up @@ -247,7 +247,7 @@
/obj/item/attachable/buildasentry,
/obj/item/attachable/shoulder_mount,
)
flags_gun_features = GUN_CAN_POINTBLANK|GUN_AMMO_COUNTER
flags_gun_features = GUN_CAN_POINTBLANK|GUN_AMMO_COUNTER|GUN_SMOKE_PARTICLES
fire_delay = 0.15 SECONDS
damage_mult = 1.3

Expand Down Expand Up @@ -328,7 +328,7 @@
/obj/item/attachable/shoulder_mount,
)

flags_gun_features = GUN_CAN_POINTBLANK|GUN_AMMO_COUNTER
flags_gun_features = GUN_CAN_POINTBLANK|GUN_AMMO_COUNTER|GUN_SMOKE_PARTICLES
attachable_offset = list("muzzle_x" = 31, "muzzle_y" = 19,"rail_x" = 9, "rail_y" = 23, "under_x" = 22, "under_y" = 14, "stock_x" = 20, "stock_y" = 17)

fire_delay = 0.7 SECONDS
Expand Down Expand Up @@ -374,7 +374,7 @@
/obj/item/attachable/shoulder_mount,
)

flags_gun_features = GUN_CAN_POINTBLANK|GUN_AMMO_COUNTER
flags_gun_features = GUN_CAN_POINTBLANK|GUN_AMMO_COUNTER|GUN_SMOKE_PARTICLES
attachable_offset = list("muzzle_x" = 30, "muzzle_y" = 19,"rail_x" = 10, "rail_y" = 22, "under_x" = 21, "under_y" = 18, "stock_x" = 21, "stock_y" = 18)
//Making the gun have an invisible silencer since it's supposed to have one.
starting_attachment_types = list(/obj/item/attachable/suppressor/unremovable/invisible)
Expand Down Expand Up @@ -414,7 +414,7 @@
/obj/item/attachable/lace,
)

flags_gun_features = GUN_CAN_POINTBLANK|GUN_AMMO_COUNTER
flags_gun_features = GUN_CAN_POINTBLANK|GUN_AMMO_COUNTER|GUN_SMOKE_PARTICLES
attachable_offset = list("muzzle_x" = 25, "muzzle_y" = 20,"rail_x" = 12, "rail_y" = 22, "under_x" = 17, "under_y" = 15, "stock_x" = 22, "stock_y" = 17)

fire_delay = 0.15 SECONDS
Expand Down Expand Up @@ -442,7 +442,7 @@
/obj/item/attachable/lace,
)

flags_gun_features = GUN_CAN_POINTBLANK|GUN_AMMO_COUNTER
flags_gun_features = GUN_CAN_POINTBLANK|GUN_AMMO_COUNTER|GUN_SMOKE_PARTICLES
attachable_offset = list("muzzle_x" = 28, "muzzle_y" = 20,"rail_x" = 10, "rail_y" = 22, "under_x" = 17, "under_y" = 15, "stock_x" = 22, "stock_y" = 17)

fire_delay = 0.15 SECONDS
Expand Down Expand Up @@ -470,7 +470,7 @@
allowed_ammo_types = list(/obj/item/ammo_magazine/pistol/highpower)
force = 10

flags_gun_features = GUN_CAN_POINTBLANK|GUN_AMMO_COUNTER
flags_gun_features = GUN_CAN_POINTBLANK|GUN_AMMO_COUNTER|GUN_SMOKE_PARTICLES
attachable_offset = list("muzzle_x" = 27, "muzzle_y" = 20,"rail_x" = 8, "rail_y" = 22, "under_x" = 18, "under_y" = 15, "stock_x" = 16, "stock_y" = 15)

fire_delay = 1 SECONDS
Expand Down Expand Up @@ -684,7 +684,7 @@ It is a modified Beretta 93R, and can fire three round burst or single fire. Whe
type_of_casings = null
gun_skill_category = SKILL_PISTOLS
attachable_allowed = list()
flags_gun_features = GUN_AMMO_COUNTER
flags_gun_features = GUN_AMMO_COUNTER|GUN_SMOKE_PARTICLES

fire_delay = 0.3 SECONDS
burst_delay = 0.2 SECONDS
Expand Down Expand Up @@ -753,7 +753,7 @@ It is a modified Beretta 93R, and can fire three round burst or single fire. Whe
/obj/item/attachable/lace,
)

flags_gun_features = GUN_AMMO_COUNTER|GUN_IFF
flags_gun_features = GUN_AMMO_COUNTER|GUN_IFF|GUN_SMOKE_PARTICLES
gun_skill_category = SKILL_SMARTGUN
actions_types = list() // Inherits aimmode, but has IFF so..
gun_firemode_list = list(GUN_FIREMODE_AUTOMATIC, GUN_FIREMODE_SEMIAUTO)
Expand Down
2 changes: 1 addition & 1 deletion code/modules/projectiles/guns/revolvers.dm
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
hand_reload_sound = 'sound/weapons/guns/interact/revolver_load.ogg'
type_of_casings = "bullet"
load_method = SINGLE_CASING|SPEEDLOADER //codex
flags_gun_features = GUN_CAN_POINTBLANK|GUN_AMMO_COUNTER|GUN_NO_PITCH_SHIFT_NEAR_EMPTY
flags_gun_features = GUN_CAN_POINTBLANK|GUN_AMMO_COUNTER|GUN_NO_PITCH_SHIFT_NEAR_EMPTY|GUN_SMOKE_PARTICLES
actions_types = list(/datum/action/item_action/aim_mode)
aim_speed_modifier = 0.75
aim_fire_delay = 0.25 SECONDS
Expand Down
Loading