diff --git a/code/_onclick/adjacent.dm b/code/_onclick/adjacent.dm index c60f7ceed628..678c5373fe67 100644 --- a/code/_onclick/adjacent.dm +++ b/code/_onclick/adjacent.dm @@ -25,7 +25,7 @@ * If you are diagonally adjacent, ensure you can pass through at least one of the mutually adjacent square. * Passing through in this case ignores anything with the throwpass flag, such as tables, racks, and morgue trays. */ -/turf/Adjacent(atom/neighbor, atom/target = null) +/turf/Adjacent(atom/neighbor, atom/target = null, list/ignore_list) var/turf/T0 = get_turf(neighbor) if(T0 == src) return TRUE @@ -34,7 +34,7 @@ if(T0.x == x || T0.y == y) // Check for border blockages - return T0.ClickCross(get_dir(T0,src), border_only = 1) && src.ClickCross(get_dir(src,T0), border_only = 1, target_atom = target) + return T0.ClickCross(get_dir(T0,src), border_only = 1, ignore_list = ignore_list) && src.ClickCross(get_dir(src,T0), border_only = 1, target_atom = target, ignore_list = ignore_list) // Not orthagonal var/in_dir = get_dir(neighbor,src) // eg. northwest (1+8) @@ -42,14 +42,14 @@ var/d2 = in_dir - d1 // eg north (1+8) - 8 = 1 for(var/d in list(d1,d2)) - if(!T0.ClickCross(d, border_only = 1)) + if(!T0.ClickCross(d, border_only = 1, ignore_list = ignore_list)) continue // could not leave T0 in that direction var/turf/T1 = get_step(T0,d) - if(!T1 || T1.density || !T1.ClickCross(get_dir(T1,T0)|get_dir(T1,src), border_only = 0)) + if(!T1 || T1.density || !T1.ClickCross(get_dir(T1,T0)|get_dir(T1,src), border_only = 0, ignore_list = ignore_list)) continue // couldn't enter or couldn't leave T1 - if(!src.ClickCross(get_dir(src,T1), border_only = 1, target_atom = target)) + if(!src.ClickCross(get_dir(src,T1), border_only = 1, target_atom = target, ignore_list = ignore_list)) continue // could not enter src return TRUE // we don't care about our own density @@ -131,8 +131,11 @@ Quick adjacency (to turf): This is defined as any dense ON_BORDER object, or any dense object without throwpass. The border_only flag allows you to not objects (for source and destination squares) */ -/turf/proc/ClickCross(target_dir, border_only, target_atom = null) +/turf/proc/ClickCross(target_dir, border_only, target_atom = null, list/ignore_list) for(var/obj/O in src) + if(O in ignore_list) + continue + if(!O.density || O == target_atom || O.throwpass) continue // throwpass is used for anything you can click through diff --git a/code/datums/ammo/misc.dm b/code/datums/ammo/misc.dm index bcb9673548db..a482d2686055 100644 --- a/code/datums/ammo/misc.dm +++ b/code/datums/ammo/misc.dm @@ -51,6 +51,8 @@ /datum/ammo/flamethrower/tank_flamer flamer_reagent_id = "napalmx" + max_range = 8 + /datum/ammo/flamethrower/sentry_flamer flags_ammo_behavior = AMMO_IGNORE_ARMOR|AMMO_IGNORE_COVER|AMMO_FLAME flamer_reagent_id = "napalmx" @@ -267,6 +269,9 @@ nade_type = /obj/item/explosive/grenade/smokebomb icon_state = "smoke_shell" +/datum/ammo/grenade_container/tank_glauncher + max_range = 8 + /datum/ammo/hugger_container name = "hugger shell" ping = null diff --git a/code/datums/ammo/rocket.dm b/code/datums/ammo/rocket.dm index 722602cada69..83a94b2d8c5f 100644 --- a/code/datums/ammo/rocket.dm +++ b/code/datums/ammo/rocket.dm @@ -144,6 +144,8 @@ return return ..() +/datum/ammo/rocket/ap/tank_towlauncher + max_range = 8 /datum/ammo/rocket/ltb name = "cannon round" diff --git a/code/modules/projectiles/projectile.dm b/code/modules/projectiles/projectile.dm index 9026a3e849e6..c1a43bda0ae8 100644 --- a/code/modules/projectiles/projectile.dm +++ b/code/modules/projectiles/projectile.dm @@ -211,8 +211,8 @@ if(F && !(projectile_flags & PROJECTILE_SHRAPNEL)) permutated |= F //Don't hit the shooter (firer) - else if (S && (projectile_flags & PROJECTILE_SHRAPNEL)) - permutated |= S + if (S) + permutated |= get_atom_on_turf(S) //Don't hit the originating object permutated |= src //Don't try to hit self. shot_from = S @@ -357,8 +357,14 @@ if((speed * world.tick_lag) >= get_dist(current_turf, target_turf)) SEND_SIGNAL(src, COMSIG_BULLET_TERMINAL) + + var/list/ignore_list + var/obj/item/hardpoint/hardpoint = shot_from + if(istype(hardpoint)) + LAZYOR(ignore_list, hardpoint.owner) //if fired from a vehicle, exclude the vehicle's body from the adjacency check + // Check we can reach the turf at all based on pathed grid - if(check_canhit(current_turf, next_turf)) + if(check_canhit(current_turf, next_turf, ignore_list)) return TRUE // Actually move @@ -594,9 +600,9 @@ if(SEND_SIGNAL(src, COMSIG_BULLET_POST_HANDLE_MOB, L, .) & COMPONENT_BULLET_PASS_THROUGH) return FALSE -/obj/projectile/proc/check_canhit(turf/current_turf, turf/next_turf) +/obj/projectile/proc/check_canhit(turf/current_turf, turf/next_turf, list/ignore_list) var/proj_dir = get_dir(current_turf, next_turf) - if((proj_dir & (proj_dir - 1)) && !current_turf.Adjacent(next_turf)) + if((proj_dir & (proj_dir - 1)) && !current_turf.Adjacent(next_turf, ignore_list = ignore_list)) ammo.on_hit_turf(current_turf, src) current_turf.bullet_act(src) return TRUE diff --git a/code/modules/vehicles/apc/apc.dm b/code/modules/vehicles/apc/apc.dm index 24b137a6804a..78219e439832 100644 --- a/code/modules/vehicles/apc/apc.dm +++ b/code/modules/vehicles/apc/apc.dm @@ -178,7 +178,7 @@ GLOBAL_LIST_EMPTY(command_apc_list) V.add_hardpoint(FPW) FPW.dir = turn(V.dir, 90) FPW.name = "Left "+ initial(FPW.name) - FPW.origins = list(2, 0) + FPW.origins = list(1, 0) FPW.muzzle_flash_pos = list( "1" = list(-18, 14), "2" = list(18, -42), @@ -191,7 +191,7 @@ GLOBAL_LIST_EMPTY(command_apc_list) V.add_hardpoint(FPW) FPW.dir = turn(V.dir, -90) FPW.name = "Right "+ initial(FPW.name) - FPW.origins = list(-2, 0) + FPW.origins = list(-1, 0) FPW.muzzle_flash_pos = list( "1" = list(16, 14), "2" = list(-18, -42), diff --git a/code/modules/vehicles/hardpoints/hardpoint.dm b/code/modules/vehicles/hardpoints/hardpoint.dm index 485b03573414..3aaa81daf19f 100644 --- a/code/modules/vehicles/hardpoints/hardpoint.dm +++ b/code/modules/vehicles/hardpoints/hardpoint.dm @@ -314,45 +314,6 @@ return data -/// Traces backwards from the gun origin to the vehicle to check for obstacles between the vehicle and the muzzle. -/obj/item/hardpoint/proc/clear_los() - if(origins[1] == 0 && origins[2] == 0) //skipping check for modules we don't need this - return TRUE - - var/turf/muzzle_turf = get_origin_turf() - - var/turf/checking_turf = muzzle_turf - while(!(owner in checking_turf)) - // Dense turfs block LoS - if(checking_turf.density) - return FALSE - - // Ensure that we can pass over all objects in the turf - for(var/obj/object in checking_turf) - // Since vehicles are multitile the - if(object == owner) - continue - - // Non-dense objects are irrelevant - if(!object.density) - continue - - // Make sure we can pass object from all directions - if(!HAS_FLAG(object.pass_flags.flags_can_pass_all, PASS_OVER_THROW_ITEM)) - if(!HAS_FLAG(object.flags_atom, ON_BORDER)) - return FALSE - //If we're behind the object, check the behind pass flags - else if(dir == object.dir && !HAS_FLAG(object.pass_flags.flags_can_pass_behind, PASS_OVER_THROW_ITEM)) - return FALSE - //If we're in front, check front pass flags - else if(dir == turn(object.dir, 180) && !HAS_FLAG(object.pass_flags.flags_can_pass_front, PASS_OVER_THROW_ITEM)) - return FALSE - - // Trace back towards the vehicle - checking_turf = get_step(checking_turf, turn(dir,180)) - - return TRUE - //----------------------------- //------INTERACTION PROCS---------- //----------------------------- @@ -613,10 +574,6 @@ to_chat(user, SPAN_WARNING("The target is not within your firing arc!")) return NONE - if(!clear_los()) - to_chat(user, SPAN_WARNING("The muzzle is obstructed!")) - return NONE - return handle_fire(target, user, params) /// Actually fires the gun, sets up the projectile and fires it. diff --git a/code/modules/vehicles/hardpoints/hardpoint_ammo/gl_ammo.dm b/code/modules/vehicles/hardpoints/hardpoint_ammo/gl_ammo.dm index 2ab0c3f828fb..bce002de1e36 100644 --- a/code/modules/vehicles/hardpoints/hardpoint_ammo/gl_ammo.dm +++ b/code/modules/vehicles/hardpoints/hardpoint_ammo/gl_ammo.dm @@ -4,7 +4,7 @@ caliber = "grenade" icon_state = "glauncher_2" w_class = SIZE_LARGE - default_ammo = /datum/ammo/grenade_container + default_ammo = /datum/ammo/grenade_container/tank_glauncher max_rounds = 10 gun_type = /obj/item/hardpoint/secondary/grenade_launcher diff --git a/code/modules/vehicles/hardpoints/hardpoint_ammo/tow_ammo.dm b/code/modules/vehicles/hardpoints/hardpoint_ammo/tow_ammo.dm index 59a5a18bb1fa..4e509211c6f6 100644 --- a/code/modules/vehicles/hardpoints/hardpoint_ammo/tow_ammo.dm +++ b/code/modules/vehicles/hardpoints/hardpoint_ammo/tow_ammo.dm @@ -5,6 +5,6 @@ caliber = "rocket" //correlates to any rocket mags icon_state = "quad_rocket" w_class = SIZE_LARGE - default_ammo = /datum/ammo/rocket/ap + default_ammo = /datum/ammo/rocket/ap/tank_towlauncher max_rounds = 5 gun_type = /obj/item/hardpoint/secondary/towlauncher diff --git a/code/modules/vehicles/hardpoints/holder/tank_turret.dm b/code/modules/vehicles/hardpoints/holder/tank_turret.dm index 403c5871f36b..bdf106aecac3 100644 --- a/code/modules/vehicles/hardpoints/holder/tank_turret.dm +++ b/code/modules/vehicles/hardpoints/holder/tank_turret.dm @@ -212,8 +212,3 @@ target = L return ..() - -/obj/item/hardpoint/holder/tank_turret/get_origin_turf() - var/origin_turf = ..() - origin_turf = get_step(get_step(origin_turf, owner.dir), owner.dir) //this should get us tile in front of tank to prevent grenade being stuck under us. - return origin_turf diff --git a/code/modules/vehicles/hardpoints/primary/arc_sentry.dm b/code/modules/vehicles/hardpoints/primary/arc_sentry.dm index 4b5087b2e608..30efdbcfd0e9 100644 --- a/code/modules/vehicles/hardpoints/primary/arc_sentry.dm +++ b/code/modules/vehicles/hardpoints/primary/arc_sentry.dm @@ -33,7 +33,6 @@ ) burst_delay = 2 burst_amount = 3 - projectile_type = /obj/projectile/arc_sentry /// Potential targets the turret can shoot at var/list/targets = list() @@ -97,12 +96,6 @@ return try_fire(target, null, params) - -/obj/item/hardpoint/primary/arc_sentry/generate_bullet(mob/user, turf/origin_turf) - var/obj/projectile/arc_sentry/made_projectile = ..() - made_projectile.permutated += owner - return made_projectile - /obj/item/hardpoint/primary/arc_sentry/start_fire(datum/source, atom/object, turf/location, control, params) if(QDELETED(object)) return @@ -199,31 +192,3 @@ return FALSE return ..() - -/obj/projectile/arc_sentry/Initialize(mapload, datum/cause_data/cause_data) - . = ..() - RegisterSignal(src, COMSIG_BULLET_POST_HANDLE_OBJ, PROC_REF(check_passthrough)) - -/obj/projectile/arc_sentry/check_canhit(turf/current_turf, turf/next_turf) - var/proj_dir = get_dir(current_turf, next_turf) - var/obj/item/hardpoint/arc_sentry = shot_from - if(!(arc_sentry.owner in current_turf) && !(arc_sentry.owner in next_turf) && (proj_dir & (proj_dir - 1)) && !current_turf.Adjacent(next_turf)) - ammo.on_hit_turf(current_turf, src) - current_turf.bullet_act(src) - return TRUE - - // Check for hits that would occur when moving to turf, such as a blocking cade - if(scan_a_turf(next_turf, proj_dir)) - return TRUE - - return FALSE - -/obj/projectile/arc_sentry/proc/check_passthrough(datum/source, obj/hit_obj, bool) - SIGNAL_HANDLER - - if(!istype(shot_from, /obj/item/hardpoint)) - return - - var/obj/item/hardpoint/sentry = shot_from - if(sentry.owner == hit_obj) - return COMPONENT_BULLET_PASS_THROUGH diff --git a/code/modules/vehicles/hardpoints/primary/autocannon.dm b/code/modules/vehicles/hardpoints/primary/autocannon.dm index b6dc2cedc674..fa865f40daa1 100644 --- a/code/modules/vehicles/hardpoints/primary/autocannon.dm +++ b/code/modules/vehicles/hardpoints/primary/autocannon.dm @@ -10,8 +10,6 @@ health = 500 firing_arc = 60 - origins = list(0, -3) - ammo = new /obj/item/ammo_magazine/hardpoint/ace_autocannon max_clips = 2 diff --git a/code/modules/vehicles/hardpoints/primary/dual_cannon.dm b/code/modules/vehicles/hardpoints/primary/dual_cannon.dm index 4033a4bffb2a..7cb4b9a621bb 100644 --- a/code/modules/vehicles/hardpoints/primary/dual_cannon.dm +++ b/code/modules/vehicles/hardpoints/primary/dual_cannon.dm @@ -14,7 +14,7 @@ health = 500 firing_arc = 60 - origins = list(0, -2) + origins = list(0, 1) ammo = new /obj/item/ammo_magazine/hardpoint/boyars_dualcannon max_clips = 2 diff --git a/code/modules/vehicles/hardpoints/primary/flamer.dm b/code/modules/vehicles/hardpoints/primary/flamer.dm index 13beee9dd2c2..d0e0596c141d 100644 --- a/code/modules/vehicles/hardpoints/primary/flamer.dm +++ b/code/modules/vehicles/hardpoints/primary/flamer.dm @@ -10,8 +10,6 @@ health = 400 firing_arc = 90 - origins = list(0, -3) - ammo = new /obj/item/ammo_magazine/hardpoint/primary_flamer max_clips = 1 @@ -33,9 +31,8 @@ BULLET_TRAIT_ENTRY(/datum/element/bullet_trait_iff) )) -/obj/item/hardpoint/primary/flamer/try_fire(target, user, params) - var/turf/origin_turf = get_origin_turf() - if(origin_turf == get_turf(target)) +/obj/item/hardpoint/primary/flamer/try_fire(atom/target, mob/living/user, params) + if(get_turf(target) in owner.locs) to_chat(user, SPAN_WARNING("The target is too close.")) return NONE diff --git a/code/modules/vehicles/hardpoints/primary/ltb.dm b/code/modules/vehicles/hardpoints/primary/ltb.dm index 19b5c7e7b9b4..6cb84cf453da 100644 --- a/code/modules/vehicles/hardpoints/primary/ltb.dm +++ b/code/modules/vehicles/hardpoints/primary/ltb.dm @@ -10,8 +10,6 @@ health = 500 firing_arc = 60 - origins = list(0, -3) - ammo = new /obj/item/ammo_magazine/hardpoint/ltb_cannon max_clips = 3 diff --git a/code/modules/vehicles/hardpoints/primary/minigun.dm b/code/modules/vehicles/hardpoints/primary/minigun.dm index 81b383b3fbc2..7ae7c20c9870 100644 --- a/code/modules/vehicles/hardpoints/primary/minigun.dm +++ b/code/modules/vehicles/hardpoints/primary/minigun.dm @@ -9,8 +9,6 @@ health = 350 firing_arc = 90 - origins = list(0, -3) - ammo = new /obj/item/ammo_magazine/hardpoint/ltaaap_minigun max_clips = 1 diff --git a/code/modules/vehicles/hardpoints/secondary/cupola.dm b/code/modules/vehicles/hardpoints/secondary/cupola.dm index f259d6ea2623..c1336eb05739 100644 --- a/code/modules/vehicles/hardpoints/secondary/cupola.dm +++ b/code/modules/vehicles/hardpoints/secondary/cupola.dm @@ -10,8 +10,6 @@ health = 350 firing_arc = 120 - origins = list(0, -2) - ammo = new /obj/item/ammo_magazine/hardpoint/m56_cupola max_clips = 1 diff --git a/code/modules/vehicles/hardpoints/secondary/flamer.dm b/code/modules/vehicles/hardpoints/secondary/flamer.dm index 5557cfb24e17..4bdc9e602974 100644 --- a/code/modules/vehicles/hardpoints/secondary/flamer.dm +++ b/code/modules/vehicles/hardpoints/secondary/flamer.dm @@ -10,8 +10,6 @@ health = 300 firing_arc = 120 - origins = list(0, -2) - ammo = new /obj/item/ammo_magazine/hardpoint/secondary_flamer max_clips = 1 @@ -29,14 +27,28 @@ scatter = 6 fire_delay = 3.0 SECONDS +/obj/item/hardpoint/secondary/small_flamer/try_fire(atom/target, mob/living/user, params) + if(get_turf(target) in owner.locs) + to_chat(user, SPAN_WARNING("The target is too close.")) + return NONE + + return ..() + /obj/item/hardpoint/secondary/small_flamer/handle_fire(atom/target, mob/living/user, params) - var/turf/origin_turf = get_origin_turf() + //step forward along path so flame starts outside hull + var/list/turfs = get_line(get_origin_turf(), get_turf(target)) + var/turf/origin_turf + for(var/turf/turf as anything in turfs) + if(turf in owner.locs) + continue + origin_turf = turf + break var/distance = get_dist(origin_turf, get_turf(target)) var/fire_amount = min(ammo.current_rounds, distance+1, max_range) ammo.current_rounds -= fire_amount - new /obj/flamer_fire(origin_turf, create_cause_data(initial(name), user), null, fire_amount, null, FLAMESHAPE_LINE, target, CALLBACK(src, PROC_REF(display_ammo), user)) + new /obj/flamer_fire(origin_turf, create_cause_data(initial(name), user), null, fire_amount, null, FLAMESHAPE_LINE, target) play_firing_sounds() diff --git a/code/modules/vehicles/hardpoints/secondary/frontal_cannon.dm b/code/modules/vehicles/hardpoints/secondary/frontal_cannon.dm index 536b5742cfcd..d0df1d295ffc 100644 --- a/code/modules/vehicles/hardpoints/secondary/frontal_cannon.dm +++ b/code/modules/vehicles/hardpoints/secondary/frontal_cannon.dm @@ -13,7 +13,7 @@ health = 350 firing_arc = 120 - origins = list(0, -2) + origins = list(0, -1) ammo = new /obj/item/ammo_magazine/hardpoint/m56_cupola/frontal_cannon max_clips = 1 diff --git a/code/modules/vehicles/hardpoints/secondary/grenade_launcher.dm b/code/modules/vehicles/hardpoints/secondary/grenade_launcher.dm index efd151e93cb3..ecaf36213d34 100644 --- a/code/modules/vehicles/hardpoints/secondary/grenade_launcher.dm +++ b/code/modules/vehicles/hardpoints/secondary/grenade_launcher.dm @@ -9,9 +9,6 @@ health = 500 firing_arc = 90 - var/max_range = 7 - - origins = list(0, -2) ammo = new /obj/item/ammo_magazine/hardpoint/tank_glauncher max_clips = 3 @@ -34,9 +31,8 @@ BULLET_TRAIT_ENTRY(/datum/element/bullet_trait_iff) )) -/obj/item/hardpoint/secondary/grenade_launcher/try_fire(mob/user, atom/A) - var/turf/origin_turf = get_origin_turf() - if(origin_turf == get_turf(A)) +/obj/item/hardpoint/secondary/grenade_launcher/try_fire(atom/target, mob/living/user, params) + if(get_turf(target) in owner.locs) to_chat(user, SPAN_WARNING("The target is too close.")) return NONE diff --git a/code/modules/vehicles/hardpoints/secondary/tow.dm b/code/modules/vehicles/hardpoints/secondary/tow.dm index 7c58f7970c7b..30eadf224bda 100644 --- a/code/modules/vehicles/hardpoints/secondary/tow.dm +++ b/code/modules/vehicles/hardpoints/secondary/tow.dm @@ -9,8 +9,6 @@ health = 500 firing_arc = 60 - origins = list(0, -2) - ammo = new /obj/item/ammo_magazine/hardpoint/towlauncher max_clips = 1 diff --git a/code/modules/vehicles/hardpoints/special/firing_port_weapon.dm b/code/modules/vehicles/hardpoints/special/firing_port_weapon.dm index 780c195f00be..f051d9a21bb5 100644 --- a/code/modules/vehicles/hardpoints/special/firing_port_weapon.dm +++ b/code/modules/vehicles/hardpoints/special/firing_port_weapon.dm @@ -20,8 +20,6 @@ allowed_seat = VEHICLE_SUPPORT_GUNNER_ONE - origins = list(0, 0) - ammo = new /obj/item/ammo_magazine/hardpoint/firing_port_weapon max_clips = 1 diff --git a/code/modules/vehicles/hardpoints/support/flare.dm b/code/modules/vehicles/hardpoints/support/flare.dm index 432c9636dadd..da1390b861d4 100644 --- a/code/modules/vehicles/hardpoints/support/flare.dm +++ b/code/modules/vehicles/hardpoints/support/flare.dm @@ -15,8 +15,6 @@ health = 500 firing_arc = 120 - origins = list(0, -2) - ammo = new /obj/item/ammo_magazine/hardpoint/flare_launcher max_clips = 3