From 8ea8937db13c56b487843c5726a1b2675f3c3832 Mon Sep 17 00:00:00 2001 From: SepuIka <63119568+SepuIka@users.noreply.github.com> Date: Fri, 7 Jun 2024 15:56:47 +0300 Subject: [PATCH 1/3] Adding gun smoke --- code/modules/projectiles/effects.dm | 38 ++++++++++++++++++++++++-- code/modules/projectiles/projectile.dm | 7 ++++- 2 files changed, 41 insertions(+), 4 deletions(-) diff --git a/code/modules/projectiles/effects.dm b/code/modules/projectiles/effects.dm index 93eca7f83b..ad47e2ef9d 100644 --- a/code/modules/projectiles/effects.dm +++ b/code/modules/projectiles/effects.dm @@ -5,7 +5,7 @@ mouse_opacity = FALSE var/angle = 0 var/call_time = 0 - var/life_time = 2 + var/life_time = 0.6 var/alpha_modifier = 1 var/update_time = 0.6 @@ -18,8 +18,7 @@ pixel_y = sin(direction) * 25 transform = turn(transform, -direction) call_time = world.time - spawn(0.3) - update() + update() /obj/effect/projectile/proc/update() var/dt = world.time - call_time @@ -49,6 +48,39 @@ icon_state = "bolt" layer = 5 +/obj/effect/projectile/bullet/muzzle/gunsmoke + icon_state = "dust_cloud_generic" + life_time = 8 + alpha_modifier = 0.8 + update_time = 0.4 + var/speed_modifier = 1 + +/obj/effect/projectile/bullet/muzzle/gunsmoke/activate(var/direction) + pixel_x = cos(direction) * 16 + pixel_y = sin(direction) * 16 + call_time = world.time + var/dispersion = rand(-20, 20) + angle = direction + dispersion + speed_modifier *= sqrt(abs(dispersion)) * 2 + update() + +/obj/effect/projectile/bullet/muzzle/gunsmoke/update() + var/dt = world.time - call_time + if(dt > life_time) + loc = null + qdel(src) + return + alpha *= alpha_modifier + var/ds = 30 + if(speed_modifier != 0) + ds /= speed_modifier + if(dt != 0) + ds /= dt + pixel_x += cos(angle) * sqrt(ds) + pixel_y += sin(angle) * sqrt(ds) + spawn(update_time) + update() + //---------------------------- // Impact //---------------------------- diff --git a/code/modules/projectiles/projectile.dm b/code/modules/projectiles/projectile.dm index a47cffc3f4..d7dfeb28ba 100644 --- a/code/modules/projectiles/projectile.dm +++ b/code/modules/projectiles/projectile.dm @@ -855,10 +855,15 @@ if (silenced) did_muzzle_effect = TRUE return - if (ispath(muzzle_type)) + if (ispath(muzzle_type) && !did_muzzle_effect) var/obj/effect/projectile/M = new muzzle_type(starting) if (istype(M)) M.activate(get_angle()) + if(!istype(muzzle_type, /obj/effect/projectile/laser)) + for(var/i = 0, i < 15, i++) + spawn (i * 0.3) + var/obj/effect/projectile/bullet/muzzle/gunsmoke/S = new/obj/effect/projectile/bullet/muzzle/gunsmoke(starting) + S.activate(get_angle()) did_muzzle_effect = TRUE /obj/item/projectile/proc/tracer_effect() From 54a17361d58c416c16a7625ac1ba53f9872105bb Mon Sep 17 00:00:00 2001 From: SepuIka <63119568+SepuIka@users.noreply.github.com> Date: Sat, 8 Jun 2024 00:11:55 +0300 Subject: [PATCH 2/3] Artillery accuracy rework. Better cannon aiming algorithm. - Making artillery accuracy depending on firing distance. Radius of dispersion of rockets is 20% of the distance. Radius of dispersion of mortar is 15% of the distance. --- code/modules/1713/siege/piece.dm | 44 ++++++++++--------------------- code/modules/1713/siege/turret.dm | 4 +-- 2 files changed, 16 insertions(+), 32 deletions(-) diff --git a/code/modules/1713/siege/piece.dm b/code/modules/1713/siege/piece.dm index 6bf64ce48c..0f8d3a0cb7 100644 --- a/code/modules/1713/siege/piece.dm +++ b/code/modules/1713/siege/piece.dm @@ -589,16 +589,12 @@ var/hit = FALSE - var/tx = x + target_x + rand(-2,2) - var/ty = y + target_y + rand(-2,2) - if (tx < 1) - tx = 1 - if (tx > world.maxx) - tx = world.maxx - if (ty < 1) - ty = 1 - if (ty > world.maxy) - ty = world.maxy + var/dispersion_dir = rand(0, 360) + var/dispersion_dist = rand(0, distance * 0.2) + var/dispersion_x = trunc(cos(dispersion_dir) * dispersion_dist) + var/dispersion_y = trunc(sin(dispersion_dir) * dispersion_dist) + var/tx = clamp(x + target_x + dispersion_x, 1, world.maxx) + var/ty = clamp(y + target_y + dispersion_y, 1, world.maxy) target = locate(tx, ty, z) var/highcheck = high var/area/target_area = get_area(target) @@ -731,24 +727,12 @@ var/hit = FALSE - var/tx = x + target_x + rand(-1,1) - var/ty = y + target_y + rand(-1,1) - - if (istype(src, /obj/structure/cannon/modern/naval)) - tx += rand(-4,4) - ty += rand(-4,4) - else - tx += rand(-1,1) - ty += rand(-1,1) - - if (tx < 1) - tx = 1 - if (tx > world.maxx) - tx = world.maxx - if (ty < 1) - ty = 1 - if (ty > world.maxy) - ty = world.maxy + var/dispersion_dir = rand(0, 360) + var/dispersion_dist = rand(0, distance * 0.15) + var/dispersion_x = trunc(cos(dispersion_dir) * dispersion_dist) + var/dispersion_y = trunc(sin(dispersion_dir) * dispersion_dist) + var/tx = clamp(x + target_x + dispersion_x, 1, world.maxx) + var/ty = clamp(y + target_y + dispersion_y, 1, world.maxy) target = locate(tx, ty, z) var/highcheck = high var/area/target_area = get_area(target) @@ -985,8 +969,8 @@ /obj/structure/cannon/proc/get_target_coords() var/actual_azimuth = azimuth - 90 - target_x = ceil(distance * cos(-actual_azimuth)) - target_y = ceil(distance * sin(-actual_azimuth)) + target_x = trunc(distance * cos(-actual_azimuth)) + target_y = trunc(distance * sin(-actual_azimuth)) /obj/structure/cannon/proc/sway() if (azimuth > 315 || azimuth < 45) diff --git a/code/modules/1713/siege/turret.dm b/code/modules/1713/siege/turret.dm index e2443143b3..a74181c91f 100644 --- a/code/modules/1713/siege/turret.dm +++ b/code/modules/1713/siege/turret.dm @@ -248,8 +248,8 @@ var/next_shot_delay = 1 var/actual_azimuth = azimuth - 90 - var/target_x = ceil(distance * cos(-actual_azimuth)) - var/target_y = ceil(distance * sin(-actual_azimuth)) + var/target_x = trunc(distance * cos(-actual_azimuth)) + var/target_y = trunc(distance * sin(-actual_azimuth)) if(istype(weapons[selected_weapon], /obj/item/weapon/gun/projectile/automatic/stationary/autocannon)) var/obj/item/weapon/gun/projectile/automatic/stationary/autocannon/A = weapons[selected_weapon] From 4c7007baa749f876780b7ac2b4520fd2a4e5f9c2 Mon Sep 17 00:00:00 2001 From: SepuIka <63119568+SepuIka@users.noreply.github.com> Date: Sat, 8 Jun 2024 00:13:06 +0300 Subject: [PATCH 3/3] Fixing atgm missile sprite --- code/modules/1713/weapons/guns/rocket.dm | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/code/modules/1713/weapons/guns/rocket.dm b/code/modules/1713/weapons/guns/rocket.dm index b4b353c9cf..cdff796389 100644 --- a/code/modules/1713/weapons/guns/rocket.dm +++ b/code/modules/1713/weapons/guns/rocket.dm @@ -646,10 +646,12 @@ caliber = 88 /obj/item/projectile/shell/missile/atgm - icon_state = "atgm_missile" atype = "HE" caliber = 120 tracer_type = null + New() + ..() + icon_state = "atgm_missile" /obj/item/projectile/shell/missile/atgm/process() if(permutated.len > 2 && firer && firer.client)