Fixes diagonal ship to ship combat, fixes overmap projectiles being slower than they should be, other fixes. (#15057)

This commit is contained in:
Matt Atlas
2022-11-09 17:34:08 +01:00
committed by GitHub
parent e53b6f06e3
commit ce008a820e
9 changed files with 152 additions and 27 deletions

View File

@@ -91,6 +91,7 @@
/obj/item/ship_ammunition/attackby(obj/item/I, mob/user)
. = ..()
if(I.force > 10 && (ammunition_flags & SHIP_AMMO_FLAG_VERY_FRAGILE))
log_and_message_admins("[user] has caused the cookoff of [src] by attacking it with [I]!", user)
cookoff(FALSE)
/obj/item/ship_ammunition/ex_act(severity)
@@ -191,7 +192,7 @@
impact_sounds = list(BULLET_IMPACT_MEAT = SOUNDS_BULLET_MEAT, BULLET_IMPACT_METAL = SOUNDS_BULLET_METAL)
accuracy = 100
var/obj/item/ship_ammunition/ammo
var/primed = FALSE //If primed, we don't interact with map edges. Projectiles might spawn on a landmark at the edge of space, and we don't want them to get tp'd away.
var/primed = FALSE
var/hit_target = FALSE //First target we hit. Used to report if a hit was successful.
/obj/item/projectile/ship_ammo/Destroy()
@@ -201,7 +202,12 @@
/obj/item/projectile/ship_ammo/touch_map_edge()
if(primed)
return
for(var/mob/living/carbon/human/H in human_mob_list)
if(AreConnectedZLevels(H.z, z))
to_chat(H, SPAN_WARNING("The flooring below you vibrates a little as shells fly by the hull of the ship!"))
H.playsound_simple(null, 'sound/effects/explosionfar.ogg', 25)
shake_camera(H, 2, 2)
..()
if(ammo.touch_map_edge(z))
ammo.original_projectile = src
forceMove(ammo)

View File

@@ -414,6 +414,7 @@
to_chat(usr, SPAN_WARNING("The console shows an error screen: the weapon isn't loaded!"))
if(SHIP_GUN_FIRING_SUCCESSFUL)
to_chat(usr, SPAN_WARNING("The console shows a positive message: firing sequence successful!"))
log_and_message_admins("[usr] has fired [cannon] with target [linked.targeting] and entry point [LM]!", location = get_turf(usr))
if(href_list["viewing"])
if(usr)

View File

@@ -29,7 +29,13 @@
/obj/effect/overmap/projectile/process()
if(target)
move_to()
check_entry()
if(!moving)
check_entry()
/obj/effect/overmap/projectile/Move()
. = ..()
if(.)
check_entry()
/obj/effect/overmap/projectile/Destroy()
ammunition = null
@@ -42,16 +48,16 @@
return
var/turf/T = get_turf(src)
for(var/obj/effect/overmap/A in T)
if(A == ammunition.origin)
if(ammunition && A == ammunition.origin)
continue
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.
STOP_PROCESSING(SSprocessing, src) //Also, don't sleep in process().
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.
@@ -64,29 +70,30 @@
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>)")
say_dead_direct("A projectile ([name]) has entered a z-level at [entry_target.name]!")
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/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
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)
var/entry_dir_choice = (dir & NORTH) || (dir & SOUTH) ? list(EAST, WEST) : list(NORTH, SOUTH)
var/turf/entry_turf = get_ranged_target_turf(entry_turf_initial, entry_dir_choice, 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>)")
log_and_message_admins("A projectile ([widowmaker.name]) has entered a z-level at [entry_target.name], with direction [dir2text(widowmaker.dir)]! (<A HREF='?_src_=holder;adminplayerobservecoodjump=1;X=[widowmaker.x];Y=[widowmaker.y];Z=[widowmaker.z]'>JMP</a>)")
say_dead_direct("A projectile ([widowmaker.name]) has entered a z-level at [entry_target.name], with direction [dir2text(widowmaker.dir)]!")
widowmaker.launch_projectile(target_turf)
qdel(src)
if(istype(A, /obj/effect/overmap/event))
@@ -100,10 +107,11 @@
walk(src, 0)
moving = FALSE
return
if(ammunition.ammunition_behaviour == SHIP_AMMO_BEHAVIOUR_DUMBFIRE)
walk_towards(src, get_step(src, dir), speed)
else if(ammunition.ammunition_behaviour == SHIP_AMMO_BEHAVIOUR_GUIDED)
walk_towards(src, target, speed)
if(!moving)
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()