diff --git a/code/__HELPERS/mobs.dm b/code/__HELPERS/mobs.dm index cc77f20c337..9e501827e49 100644 --- a/code/__HELPERS/mobs.dm +++ b/code/__HELPERS/mobs.dm @@ -134,3 +134,10 @@ Proc for attack log creation, because really why not return 0 var/mob/living/silicon/robot/R = thing.loc return (thing in R.module.modules) + +/proc/get_exposed_defense_zone(var/atom/movable/target) + var/obj/item/weapon/grab/G = locate() in target + if (G && G.state >= GRAB_NECK) + return pick("head", "l_hand", "r_hand", "l_foot", "r_foot", "l_arm", "r_arm", "l_leg", "r_leg") + else + return pick("chest", "groin") diff --git a/code/game/machinery/portable_turret.dm b/code/game/machinery/portable_turret.dm index 307b504b074..d517091a1f0 100644 --- a/code/game/machinery/portable_turret.dm +++ b/code/game/machinery/portable_turret.dm @@ -618,7 +618,6 @@ var/list/turret_icons else A = new projectile(loc) playsound(loc, shot_sound, 75, 1) - A.original = target // Lethal/emagged turrets use twice the power due to higher energy beams // Emagged turrets again use twice as much power due to higher firing rates @@ -626,19 +625,9 @@ var/list/turret_icons //Turrets aim for the center of mass by default. //If the target is grabbing someone then the turret smartly aims for extremities - var/obj/item/weapon/grab/G = locate() in target - if(G && G.state >= GRAB_NECK) //works because mobs are currently not allowed to upgrade to NECK if they are grabbing two people. - A.def_zone = pick("head", "l_hand", "r_hand", "l_foot", "r_foot", "l_arm", "r_arm", "l_leg", "r_leg") - else - A.def_zone = pick("chest", "groin") + var/def_zone = get_exposed_defense_zone(target) - //Shooting Code: - A.current = T - A.starting = T - A.yo = U.y - T.y - A.xo = U.x - T.x - spawn(1) - A.process() + A.launch(target, def_zone) /datum/turret_checks var/enabled diff --git a/code/game/machinery/turrets.dm b/code/game/machinery/turrets.dm index 87edc01204c..d4a327f054c 100644 --- a/code/game/machinery/turrets.dm +++ b/code/game/machinery/turrets.dm @@ -261,26 +261,17 @@ A = new /obj/item/projectile/beam/lastertag/blue( loc ) if(6) A = new /obj/item/projectile/beam/lastertag/red( loc ) - A.original = target use_power(500) else A = new /obj/item/projectile/energy/electrode( loc ) use_power(200) - + //Turrets aim for the center of mass by default. //If the target is grabbing someone then the turret smartly aims for extremities - var/obj/item/weapon/grab/G = locate() in target - if(G && G.state >= GRAB_NECK) //works because mobs are currently not allowed to upgrade to NECK if they are grabbing two people. - A.def_zone = pick("head", "l_hand", "r_hand", "l_foot", "r_foot", "l_arm", "r_arm", "l_leg", "r_leg") - else - A.def_zone = pick("chest", "groin") - - A.current = T - A.starting = T - A.yo = U.y - T.y - A.xo = U.x - T.x - spawn( 0 ) - A.process() + var/def_zone = get_exposed_defense_zone(target) + + A.launch(target, def_zone) + return @@ -507,25 +498,16 @@ cur_target = null return src.set_dir(get_dir(src,target)) - var/turf/targloc = get_turf(target) - var/target_x = targloc.x - var/target_y = targloc.y - var/target_z = targloc.z - targloc = null spawn for(var/i=1 to min(projectiles, projectiles_per_shot)) if(!src) break var/turf/curloc = get_turf(src) - targloc = locate(target_x+GaussRandRound(deviation,1),target_y+GaussRandRound(deviation,1),target_z) - if (!targloc || !curloc) - continue - if (targloc == curloc) - continue + playsound(src, 'sound/weapons/Gunshot.ogg', 50, 1) var/obj/item/projectile/A = new /obj/item/projectile(curloc) src.projectiles-- - A.current = curloc - A.yo = targloc.y - curloc.y - A.xo = targloc.x - curloc.x - A.process() + + var/def_zone = get_exposed_defense_zone(target) + + A.launch(target, def_zone) sleep(2) return diff --git a/code/game/mecha/equipment/weapons/weapons.dm b/code/game/mecha/equipment/weapons/weapons.dm index 61eaa214da9..de4c60d1a3b 100644 --- a/code/game/mecha/equipment/weapons/weapons.dm +++ b/code/game/mecha/equipment/weapons/weapons.dm @@ -48,14 +48,11 @@ /obj/item/mecha_parts/mecha_equipment/weapon/proc/Fire(atom/A, atom/target, turf/aimloc) var/obj/item/projectile/P = A - P.shot_from = src - P.original = target - P.starting = P.loc - P.current = P.loc - P.firer = chassis.occupant - P.yo = aimloc.y - P.loc.y - P.xo = aimloc.x - P.loc.x - P.process() + var/def_zone + if (chassis && istype(chassis.occupant, /mob/living/carbon/human)) + var/mob/living/carbon/human/H = chassis.occupant + def_zone = H.zone_sel.selecting + P.launch(target, def_zone) /obj/item/mecha_parts/mecha_equipment/weapon/energy name = "general energy weapon" @@ -280,4 +277,4 @@ return "* [chassis.selected==src?"":""][src.name][chassis.selected==src?"":""]\[[src.projectiles]\]" /obj/item/mecha_parts/mecha_equipment/weapon/ballistic/missile_rack/flashbang/clusterbang/limited/rearm() - return//Extra bit of security \ No newline at end of file + return//Extra bit of security diff --git a/code/modules/mob/living/bot/ed209bot.dm b/code/modules/mob/living/bot/ed209bot.dm index 570e58ec2ee..ef81a4a0b2f 100644 --- a/code/modules/mob/living/bot/ed209bot.dm +++ b/code/modules/mob/living/bot/ed209bot.dm @@ -56,8 +56,6 @@ return last_shot = world.time - var/turf/T = get_turf(src) - var/turf/U = get_turf(A) var/projectile = /obj/item/projectile/beam/stun if(emagged) @@ -65,14 +63,9 @@ playsound(loc, emagged ? 'sound/weapons/Laser.ogg' : 'sound/weapons/Taser.ogg', 50, 1) var/obj/item/projectile/P = new projectile(loc) + var/def_zone = get_exposed_defense_zone(A) + P.launch(A, def_zone) - P.original = A - P.starting = T - P.current = T - P.yo = U.y - T.y - P.xo = U.x - T.x - spawn() - P.process() return // Assembly diff --git a/code/modules/mob/living/carbon/human/species/xenomorphs/alien_powers.dm b/code/modules/mob/living/carbon/human/species/xenomorphs/alien_powers.dm index a11bccf1639..bc72354c4af 100644 --- a/code/modules/mob/living/carbon/human/species/xenomorphs/alien_powers.dm +++ b/code/modules/mob/living/carbon/human/species/xenomorphs/alien_powers.dm @@ -171,29 +171,8 @@ visible_message("[src] spits neurotoxin at [target]!", "You spit neurotoxin at [target].") - //I'm not motivated enough to revise this. Prjectile code in general needs update. - // Maybe change this to use throw_at? ~ Z - var/turf/T = loc - var/turf/U = (istype(target, /atom/movable) ? target.loc : target) - - if(!U || !T) - return - while(U && !istype(U,/turf)) - U = U.loc - if(!istype(T, /turf)) - return - if (U == T) - usr.bullet_act(new /obj/item/projectile/energy/neurotoxin(usr.loc), get_organ_target()) - return - if(!istype(U, /turf)) - return - var/obj/item/projectile/energy/neurotoxin/A = new /obj/item/projectile/energy/neurotoxin(usr.loc) - A.current = U - A.yo = U.y - T.y - A.xo = U.x - T.x - A.process() - return + A.launch(target, get_organ_target()) /mob/living/carbon/human/proc/resin() // -- TLE set name = "Secrete Resin (75)" @@ -217,4 +196,4 @@ new /obj/effect/alien/resin/membrane(loc) if("resin nest") new /obj/structure/bed/nest(loc) - return \ No newline at end of file + return diff --git a/code/modules/mob/living/simple_animal/hostile/hostile.dm b/code/modules/mob/living/simple_animal/hostile/hostile.dm index 405386a827b..2016ebd155b 100644 --- a/code/modules/mob/living/simple_animal/hostile/hostile.dm +++ b/code/modules/mob/living/simple_animal/hostile/hostile.dm @@ -155,22 +155,21 @@ var/target = target_mob visible_message("\red [src] fires at [target]!", 1) - var/tturf = get_turf(target) if(rapid) spawn(1) - Shoot(tturf, src.loc, src) + Shoot(target, src.loc, src) if(casingtype) new casingtype(get_turf(src)) spawn(4) - Shoot(tturf, src.loc, src) + Shoot(target, src.loc, src) if(casingtype) new casingtype(get_turf(src)) spawn(6) - Shoot(tturf, src.loc, src) + Shoot(target, src.loc, src) if(casingtype) new casingtype(get_turf(src)) else - Shoot(tturf, src.loc, src) + Shoot(target, src.loc, src) if(casingtype) new casingtype @@ -187,16 +186,9 @@ playsound(user, projectilesound, 100, 1) if(!A) return - if (!istype(target, /turf)) - qdel(A) - return - A.current = target - A.starting = get_turf(src) - A.original = get_turf(target) - A.yo = target:y - start:y - A.xo = target:x - start:x - spawn( 0 ) - A.process() + var/def_zone = get_exposed_defense_zone(target) + A.launch(target, def_zone) + return /mob/living/simple_animal/hostile/proc/DestroySurroundings() diff --git a/code/modules/power/singularity/emitter.dm b/code/modules/power/singularity/emitter.dm index 11606b3dc1c..a5b73bb4b0e 100644 --- a/code/modules/power/singularity/emitter.dm +++ b/code/modules/power/singularity/emitter.dm @@ -129,27 +129,16 @@ //need to calculate the power per shot as the emitter doesn't fire continuously. var/burst_time = (min_burst_delay + max_burst_delay)/2 + 2*(burst_shots-1) var/power_per_shot = active_power_usage * (burst_time/10) / burst_shots - var/obj/item/projectile/beam/emitter/A = new /obj/item/projectile/beam/emitter( src.loc ) - A.damage = round(power_per_shot/EMITTER_DAMAGE_POWER_TRANSFER) - playsound(src.loc, 'sound/weapons/emitter.ogg', 25, 1) if(prob(35)) var/datum/effect/effect/system/spark_spread/s = new /datum/effect/effect/system/spark_spread s.set_up(5, 1, src) s.start() - A.set_dir(src.dir) - A.starting = get_turf(src) - switch(dir) - if(NORTH) - A.original = locate(x, y+1, z) - if(EAST) - A.original = locate(x+1, y, z) - if(WEST) - A.original = locate(x-1, y, z) - else // Any other - A.original = locate(x, y-1, z) - A.process() + var/obj/item/projectile/beam/emitter/A = new /obj/item/projectile/beam/emitter( src.loc ) + playsound(src.loc, 'sound/weapons/emitter.ogg', 25, 1) + A.damage = round(power_per_shot/EMITTER_DAMAGE_POWER_TRANSFER) + A.launch(get_step(src.loc, src.dir)) /obj/machinery/power/emitter/attackby(obj/item/W, mob/user) @@ -235,4 +224,4 @@ return ..() - return \ No newline at end of file + return