Skip to content

Commit

Permalink
Merge pull request Civ13#2930 from SepuIka/master
Browse files Browse the repository at this point in the history
Updating artillery accuracy. Adding gunsmoke effect.
  • Loading branch information
savethetreez authored Jun 7, 2024
2 parents df0fb20 + 4c7007b commit aa406df
Show file tree
Hide file tree
Showing 5 changed files with 60 additions and 37 deletions.
44 changes: 14 additions & 30 deletions code/modules/1713/siege/piece.dm
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down Expand Up @@ -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)
Expand Down Expand Up @@ -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)
Expand Down
4 changes: 2 additions & 2 deletions code/modules/1713/siege/turret.dm
Original file line number Diff line number Diff line change
Expand Up @@ -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]
Expand Down
4 changes: 3 additions & 1 deletion code/modules/1713/weapons/guns/rocket.dm
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
38 changes: 35 additions & 3 deletions code/modules/projectiles/effects.dm
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand All @@ -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
Expand Down Expand Up @@ -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
//----------------------------
Expand Down
7 changes: 6 additions & 1 deletion code/modules/projectiles/projectile.dm
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand Down

0 comments on commit aa406df

Please sign in to comment.