Fixes some ship weapon bugs. (#15035)

* Fixes some ship weapon bugs.

* missed entry

* list sort

* cl + fix

Co-authored-by: Matt Atlas <liermattia@gmail.com>
This commit is contained in:
Matt Atlas
2022-11-06 18:24:51 +01:00
committed by GitHub
co-authored by Matt Atlas
parent 592ae59940
commit ee4e9000f0
10 changed files with 135 additions and 67 deletions
@@ -38,58 +38,61 @@
return ..()
/obj/effect/overmap/projectile/proc/check_entry()
if(!ammunition)
return
var/turf/T = get_turf(src)
for(var/obj/effect/overmap/visitable/V in T)
if(V == ammunition.origin)
for(var/obj/effect/overmap/A in T)
if(A == ammunition.origin)
continue
if((V.check_ownership(entry_target)) || (V == target)) //Target spotted!
if(istype(V, /obj/effect/overmap/visitable/sector/exoplanet) && (ammunition.overmap_behaviour & SHIP_AMMO_CAN_HIT_SHIPS))
//Manually stopping & going invisible because this proc needs to sleep for a bit.
invisibility = 100
moving = FALSE
STOP_PROCESSING(SSprocessing, src) //Also, don't sleep in process().
var/obj/item/projectile/ship_ammo/widowmaker = new ammunition.original_projectile.type
widowmaker.ammo = ammunition
qdel(ammunition.original_projectile) //No longer needed.
var/turf/laze = get_turf(entry_target)
ammunition.original_projectile = widowmaker
playsound(laze, 'sound/weapons/gunshot/ship_weapons/orbital_travel.ogg')
laze.visible_message(SPAN_DANGER("<font size=6>A bright star is getting closer from the sky...!</font>"))
sleep(11 SECONDS) //Let the sound play!
widowmaker.primed = TRUE
widowmaker.forceMove(entry_target)
widowmaker.on_hit(laze, is_landmark_hit = TRUE)
log_and_message_admins("A projectile ([name]) has entered a z-level at [entry_target.name]! (<A HREF='?_src_=holder;adminplayerobservecoodjump=1;X=[widowmaker.x];Y=[widowmaker.y];Z=[widowmaker.z]'>JMP</a>)")
qdel(widowmaker)
qdel(src)
else if(istype(V, /obj/effect/overmap/visitable) && (ammunition.overmap_behaviour & SHIP_AMMO_CAN_HIT_SHIPS))
if(istype(V, /obj/effect/overmap/visitable/ship))
var/obj/effect/overmap/visitable/ship/VS = V
if(istype(ammunition.origin, /obj/effect/overmap/visitable/ship))
var/obj/effect/overmap/visitable/ship/OR = ammunition.origin
if(VS.fore_dir != OR.fore_dir)
var/naval_heading = SSatlas.headings_to_naval["[OR.fore_dir]"]["[ammunition.heading]"]
var/corrected_heading = SSatlas.naval_to_dir["[VS.fore_dir]"][naval_heading]
ammunition.heading = corrected_heading
var/obj/item/projectile/ship_ammo/widowmaker = new ammunition.original_projectile.type
widowmaker.ammo = ammunition
qdel(ammunition.original_projectile) //No longer needed.
ammunition.original_projectile = widowmaker
widowmaker.primed = TRUE
var/turf/entry_turf_initial = get_ranged_target_turf(entry_target, reverse_dir[entry_target.dir], 20)
var/turf/entry_turf = get_ranged_target_turf(entry_turf_initial, pick(list(EAST, WEST)), 5)
widowmaker.forceMove(entry_turf)
widowmaker.dir = ammunition.heading
var/turf/target_turf = get_step(widowmaker, widowmaker.dir)
widowmaker.on_translate(entry_turf, target_turf)
log_and_message_admins("A projectile ([widowmaker.name]) has entered a z-level at [entry_target.name], with direction [dir_name(widowmaker.dir)]! (<A HREF='?_src_=holder;adminplayerobservecoodjump=1;X=[widowmaker.x];Y=[widowmaker.y];Z=[widowmaker.z]'>JMP</a>)")
widowmaker.launch_projectile(target_turf)
qdel(src)
else if(istype(V, /obj/effect/overmap/event) && (ammunition.overmap_behaviour & SHIP_AMMO_CAN_HIT_HAZARDS))
var/obj/effect/overmap/event/EV = V
if(EV.can_be_destroyed)
qdel(EV)
if(istype(A, /obj/effect/overmap/visitable))
var/obj/effect/overmap/visitable/V = A
if((V.check_ownership(entry_target)) || (V == target)) //Target spotted!
if(istype(V, /obj/effect/overmap/visitable/sector/exoplanet) && (ammunition.overmap_behaviour & SHIP_AMMO_CAN_HIT_SHIPS))
//Manually stopping & going invisible because this proc needs to sleep for a bit.
invisibility = 100
moving = FALSE
STOP_PROCESSING(SSprocessing, src) //Also, don't sleep in process().
var/obj/item/projectile/ship_ammo/widowmaker = new ammunition.original_projectile.type
widowmaker.ammo = ammunition
qdel(ammunition.original_projectile) //No longer needed.
var/turf/laze = get_turf(entry_target)
ammunition.original_projectile = widowmaker
playsound(laze, 'sound/weapons/gunshot/ship_weapons/orbital_travel.ogg')
laze.visible_message(SPAN_DANGER("<font size=6>A bright star is getting closer from the sky...!</font>"))
sleep(11 SECONDS) //Let the sound play!
widowmaker.primed = TRUE
widowmaker.forceMove(entry_target)
widowmaker.on_hit(laze, is_landmark_hit = TRUE)
log_and_message_admins("A projectile ([name]) has entered a z-level at [entry_target.name]! (<A HREF='?_src_=holder;adminplayerobservecoodjump=1;X=[widowmaker.x];Y=[widowmaker.y];Z=[widowmaker.z]'>JMP</a>)")
qdel(widowmaker)
qdel(src)
else if(istype(V, /obj/effect/overmap/visitable) && (ammunition.overmap_behaviour & SHIP_AMMO_CAN_HIT_SHIPS))
if(istype(V, /obj/effect/overmap/visitable/ship))
var/obj/effect/overmap/visitable/ship/VS = V
if(istype(ammunition.origin, /obj/effect/overmap/visitable/ship))
var/obj/effect/overmap/visitable/ship/OR = ammunition.origin
if(VS.fore_dir != OR.fore_dir)
var/naval_heading = SSatlas.headings_to_naval["[OR.fore_dir]"]["[ammunition.heading]"]
var/corrected_heading = SSatlas.naval_to_dir["[VS.fore_dir]"][naval_heading]
ammunition.heading = corrected_heading
var/obj/item/projectile/ship_ammo/widowmaker = new ammunition.original_projectile.type
widowmaker.ammo = ammunition
qdel(ammunition.original_projectile) //No longer needed.
ammunition.original_projectile = widowmaker
widowmaker.primed = TRUE
var/turf/entry_turf_initial = get_ranged_target_turf(entry_target, reverse_dir[entry_target.dir], 20)
var/turf/entry_turf = get_ranged_target_turf(entry_turf_initial, pick(list(EAST, WEST)), 5)
widowmaker.forceMove(entry_turf)
widowmaker.dir = ammunition.heading
var/turf/target_turf = get_step(widowmaker, widowmaker.dir)
widowmaker.on_translate(entry_turf, target_turf)
log_and_message_admins("A projectile ([widowmaker.name]) has entered a z-level at [entry_target.name], with direction [dir_name(widowmaker.dir)]! (<A HREF='?_src_=holder;adminplayerobservecoodjump=1;X=[widowmaker.x];Y=[widowmaker.y];Z=[widowmaker.z]'>JMP</a>)")
widowmaker.launch_projectile(target_turf)
qdel(src)
if(istype(A, /obj/effect/overmap/event))
var/obj/effect/overmap/event/EV = A
if(EV.can_be_destroyed && (ammunition.overmap_behaviour & SHIP_AMMO_CAN_HIT_HAZARDS))
qdel(EV)
qdel(src)
/obj/effect/overmap/projectile/proc/move_to()