Skip to content

Commit

Permalink
Fixing shell effects. Updating affects algorithm
Browse files Browse the repository at this point in the history
  • Loading branch information
SepuIka committed May 6, 2024
1 parent 357f36a commit e51ff76
Show file tree
Hide file tree
Showing 4 changed files with 52 additions and 19 deletions.
45 changes: 32 additions & 13 deletions code/modules/projectiles/effects.dm
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,9 @@
layer = 5
var/angle = 0
var/call_time = 0
var/life_time = 2
var/alpha_modifier = 1
var/update_time = 0.6

/obj/effect/projectile/New(var/turf/location)
if (istype(location))
Expand All @@ -19,12 +22,12 @@

/obj/effect/projectile/proc/update()
var/dt = world.time - call_time
if(dt > 2)
if(dt > life_time)
loc = null
qdel(src)
return
alpha *= 0.9
spawn(0.3)
alpha *= alpha_modifier
spawn(update_time)
update()

//----------------------------
Expand All @@ -51,62 +54,77 @@

/obj/effect/projectile/impact
icon_state = "dust_cloud_generic"
life_time = 6
alpha_modifier = 0.9
update_time = 0.5
var/speed_modifier = 1

/obj/effect/projectile/impact/activate(var/direction)
pixel_x = cos(direction) * 32
pixel_y = sin(direction) * 32
call_time = world.time
var/dispersion = rand(-30, 30)
var/dispersion = rand(-60, 60)
angle = direction + dispersion - 180
speed_modifier = sqrt(abs(dispersion))
speed_modifier *= sqrt(abs(dispersion)) * 0.5
update()

/obj/effect/projectile/impact/update()
var/dt = world.time - call_time
if(dt > 5)
if(dt > life_time)
loc = null
qdel(src)
return
alpha *= 0.85
alpha *= alpha_modifier
var/ds = 20
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(0.4)
spawn(update_time)
update()

/obj/effect/projectile/impact/heavy
icon_state = "dust_heavy_cloud_generic"
life_time = 10
alpha_modifier = 0.9
update_time = 0.6
speed_modifier = 1.5

//----------------------------
// Tracer
//----------------------------

/obj/effect/projectile/tracer
icon_state = "tracer_white"
life_time = 6
alpha_modifier = 0.9
update_time = 0.7

/obj/effect/projectile/tracer/activate(var/direction, var/pixel_dist, var/turf/starting)
angle = direction
pixel_x = (cos(angle) * pixel_dist) - ((x - starting.x) * world.icon_size)
pixel_y = (sin(angle) * pixel_dist) - ((y - starting.y) * world.icon_size)
transform = turn(transform, -angle)
call_time = world.time
spawn(0.5)
spawn()
update()

/obj/effect/projectile/tracer/update()
var/dt = world.time - call_time
if(dt > 2)
if(dt > life_time)
loc = null
qdel(src)
return
alpha *= 0.8
spawn(0.6)
alpha *= alpha_modifier
spawn(update_time)
update()

/obj/effect/projectile/tracer/minor
alpha = 64
life_time = 3
alpha_modifier = 0.7

/obj/effect/projectile/tracer/red
icon_state = "tracer_red"
Expand All @@ -115,4 +133,5 @@
icon_state = "tracer_green"

/obj/effect/projectile/tracer/shell
icon_state = "shell_tracer_white"
icon_state = "shell_tracer_white"
life_time = 10
1 change: 1 addition & 0 deletions code/modules/projectiles/projectile.dm
Original file line number Diff line number Diff line change
Expand Up @@ -706,6 +706,7 @@
if (istype(src, /obj/item/projectile/shell))
if (loc == trajectory.target)
var/obj/item/projectile/shell/S = src
on_impact(T)
S.initiate(loc)
return FALSE

Expand Down
25 changes: 19 additions & 6 deletions code/modules/projectiles/projectile/cannon.dm
Original file line number Diff line number Diff line change
Expand Up @@ -16,10 +16,11 @@
atype = "HE"
tracer_type = /obj/effect/projectile/tracer/shell
muzzle_type = /obj/effect/projectile/bullet/muzzle
impact_type = /obj/effect/projectile/impact/heavy
var/turf/targloc = null
var/initiated = FALSE

/obj/item/projectile/shell/update_icon()
/obj/item/projectile/shell/New()
..()
icon_state = "[atype]_shell"

Expand All @@ -40,12 +41,11 @@
return ..()

/obj/item/projectile/shell/on_impact(var/atom/A)
impact_effect(effect_transform) // generate impact effect
playsound(src, "ric_sound", 50, TRUE, -2)
if (istype(A, /turf))
var/turf/T = A
if (atype == "cannonball")
if (!istype(T, /turf/floor/beach) && !istype(T, /turf/floor/broken_floor))
if (!istype(T, /turf/floor/beach) && !istype(T, /turf/floor/broken_floor) && !istype(T, /turf/floor/trench))
T.ChangeTurf(/turf/floor/dirt/burned)
explosion(T, 1, 1, 1, 2)
else
Expand All @@ -56,6 +56,17 @@
qdel(src)
return TRUE

/obj/item/projectile/shell/impact_effect()
if (ispath(impact_type))
var/turf/effect_loc = null
if(permutated.len > 0)
effect_loc = permutated[permutated.len]
else
effect_loc = starting
for(var/i = 0, i < 10, i++)
var/obj/effect/projectile/P = new impact_type(effect_loc)
if (istype(P))
P.activate(get_angle())

/obj/item/projectile/shell/launch(atom/target, mob/user, obj/structure/cannon/modern/tank/launcher)
targloc = get_turf(target)
Expand Down Expand Up @@ -97,7 +108,8 @@
if(!T)
return
var/caliber_modifier = clamp(round(caliber / 50), 0, 4)

if (!istype(T, /turf/floor/beach) && !istype(T, /turf/floor/broken_floor) && !istype(T, /turf/floor/trench))
T.ChangeTurf(/turf/floor/dirt/burned)
if (atype == "HE")
var/he_range = caliber_modifier
var/list/fragment_types = list(/obj/item/projectile/bullet/pellet/fragment/short_range = 1)
Expand Down Expand Up @@ -183,8 +195,9 @@
icon = 'icons/obj/projectiles.dmi'
icon_state = "bullet"

/obj/item/projectile/shell/autocannon/update_icon()
return
/obj/item/projectile/shell/autocannon/New()
..()
icon_state = "bullet"

/obj/item/projectile/shell/autocannon/a20_aphe
atype = "AP"
Expand Down
Binary file modified icons/effects/projectiles.dmi
Binary file not shown.

0 comments on commit e51ff76

Please sign in to comment.