Fixes some overmap projectile bugs. (#15072)

Co-authored-by: Matt Atlas <liermattia@gmail.com>
This commit is contained in:
Matt Atlas
2022-11-10 23:56:16 +01:00
committed by GitHub
co-authored by Matt Atlas
parent 3db4416b7e
commit f1423a881e
5 changed files with 77 additions and 25 deletions
@@ -33,6 +33,13 @@
. = ..()
update_status()
/obj/item/ship_ammunition/Destroy()
origin = null
overmap_target = null
entry_point = null
original_projectile = null
return ..()
/obj/item/ship_ammunition/attackby(obj/item/I, mob/user)
if(I.ispen())
var/obj/item/pen/P = I
@@ -51,11 +51,11 @@
/obj/machinery/ship_weapon/ex_act(severity)
switch(severity)
if(1)
add_damage(250)
add_damage(50)
if(2)
add_damage(100)
add_damage(25)
if(3)
add_damage(75)
add_damage(10)
/obj/machinery/ship_weapon/proc/add_damage(var/amount)
damage = max(0, min(damage + amount, max_damage))
@@ -9,16 +9,18 @@
var/atom/target //The target is the actual overmap object we're hitting.
var/obj/entry_target //The entry target is where the projectile itself is going to spawn in world.
var/range = OVERMAP_PROJECTILE_RANGE_ULTRAHIGH
var/current_range_counter = 0
var/speed = 0 //A projectile with 0 speed does not move. Note that this is the 'lag' variable on walk_towards! Lower speed is better.
var/moving = FALSE //Is the projectile actively moving on the overmap?
var/entering = FALSE //Are we entering an entry point?
/obj/effect/overmap/projectile/Initialize(var/maploading, var/sx, var/sy)
. = ..()
x = sx
y = sy
z = current_map.overmap_z
START_PROCESSING(SSprocessing, src)
addtimer(CALLBACK(src, .proc/move_to), 1)
/obj/effect/overmap/projectile/Bump(var/atom/A)
if(istype(A, /turf/unsimulated/map/edge))
@@ -26,16 +28,12 @@
qdel(src)
..()
/obj/effect/overmap/projectile/process()
if(target)
move_to()
if(!moving)
check_entry()
/obj/effect/overmap/projectile/Move()
. = ..()
if(.)
check_entry()
if(!check_entry())
. = ..()
current_range_counter++
if(current_range_counter >= range)
qdel(src)
/obj/effect/overmap/projectile/Destroy()
ammunition = null
@@ -43,7 +41,13 @@
entry_target = null
return ..()
/obj/effect/overmap/projectile/proc/prepare_for_entry()
moving = FALSE
entering = FALSE
walk(src, 0)
/obj/effect/overmap/projectile/proc/check_entry()
. = FALSE
if(!ammunition)
return
var/turf/T = get_turf(src)
@@ -54,10 +58,9 @@
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.
STOP_PROCESSING(SSprocessing, src) //Also, don't sleep in process().
invisibility = 100
moving = FALSE
. = TRUE
//Manually stopping because this proc needs to sleep for a bit.
prepare_for_entry()
var/obj/item/projectile/ship_ammo/widowmaker = new ammunition.original_projectile.type
widowmaker.ammo = ammunition
qdel(ammunition.original_projectile) //No longer needed.
@@ -74,12 +77,14 @@
qdel(widowmaker)
qdel(src)
else if(istype(V, /obj/effect/overmap/visitable) && (ammunition.overmap_behaviour & SHIP_AMMO_CAN_HIT_SHIPS))
. = TRUE
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/naval_heading = SSatlas.headings_to_naval["[VS.dir]"]["[ammunition.heading]"]
var/corrected_heading = SSatlas.naval_to_dir["[VS.fore_dir]"][naval_heading]
ammunition.heading = corrected_heading
prepare_for_entry()
var/obj/item/projectile/ship_ammo/widowmaker = new ammunition.original_projectile.type
widowmaker.ammo = ammunition
qdel(ammunition.original_projectile) //No longer needed.
@@ -99,6 +104,7 @@
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))
. = TRUE
qdel(EV)
qdel(src)
@@ -107,18 +113,12 @@
walk(src, 0)
moving = FALSE
return
if(!moving)
if(!moving && !entering)
if(ammunition.ammunition_behaviour == SHIP_AMMO_BEHAVIOUR_DUMBFIRE)
walk(src, ammunition.heading, speed)
else if(ammunition.ammunition_behaviour == SHIP_AMMO_BEHAVIOUR_GUIDED)
walk_towards(src, target, speed)
moving = TRUE
/obj/effect/overmap/projectile/Destroy()
if(!QDELETED(ammunition))
QDEL_NULL(ammunition)
ammunition = null
return ..()
moving = TRUE
/obj/effect/overmap/projectile/get_scan_data(mob/user)
. = ..()
@@ -20,6 +20,8 @@
/obj/item/projectile/ship_ammo/longbow/launch_projectile(atom/target, target_zone, mob/user, params, angle_override, forced_spread)
if(ammo.impact_type == SHIP_AMMO_IMPACT_AP)
penetrating = 1
if(ammo.impact_type == SHIP_AMMO_IMPACT_BUNKERBUSTER)
penetrating = 3
. = ..()
/obj/item/projectile/ship_ammo/longbow/on_hit(atom/target, blocked, def_zone, is_landmark_hit)