From 6b10b648d20cd9c5c732bb0ff01fce47aaa2c92b Mon Sep 17 00:00:00 2001 From: Loganbacca Date: Fri, 10 Jul 2015 15:17:53 +1200 Subject: [PATCH 1/5] Implements turret trajectory prediction - Adds trajectory checking for turrets, so they don't burn holes through other objects (like walls and AI's) if they wouldn't hit them anyway. --- code/game/machinery/portable_turret.dm | 6 +++++- code/modules/projectiles/projectile.dm | 9 ++++----- 2 files changed, 9 insertions(+), 6 deletions(-) diff --git a/code/game/machinery/portable_turret.dm b/code/game/machinery/portable_turret.dm index 10d86aa4b2..6a0ad704a2 100644 --- a/code/game/machinery/portable_turret.dm +++ b/code/game/machinery/portable_turret.dm @@ -605,8 +605,12 @@ var/list/turret_icons if(!raised) //the turret has to be raised in order to fire - makes sense, right? return - update_icon() + + //targeting check, can we hit them? + if(!check_trajectory(target, src)) + return + var/obj/item/projectile/A if(emagged || lethal) A = new eprojectile(loc) diff --git a/code/modules/projectiles/projectile.dm b/code/modules/projectiles/projectile.dm index 9feebbd64b..d60169d836 100644 --- a/code/modules/projectiles/projectile.dm +++ b/code/modules/projectiles/projectile.dm @@ -385,7 +385,7 @@ return //cannot shoot yourself if(istype(A, /obj/item/projectile)) return - if(istype(A, /mob/living)) + if(istype(A, /mob/living) || istype(A, /obj/mecha) || istype(A, /obj/vehicle)) result = 2 //We hit someone, return 1! return result = 1 @@ -424,15 +424,14 @@ if(istype(M)) return 1 -/proc/check_trajectory(atom/target as mob, var/mob/living/user as mob, var/pass_flags=PASSTABLE|PASSGLASS|PASSGRILLE, flags=null) //Checks if you can hit them or not. - if(!istype(target) || !istype(user)) +/proc/check_trajectory(atom/target as mob|obj, atom/firer as mob|obj, var/pass_flags=PASSTABLE|PASSGLASS|PASSGRILLE, flags=null) //Checks if you can hit them or not. + if(!istype(target) || !istype(firer)) return 0 - var/obj/item/projectile/test/trace = new /obj/item/projectile/test(get_step_to(user,target)) //Making the test.... + var/obj/item/projectile/test/trace = new /obj/item/projectile/test(get_step_to(firer,target)) //Making the test.... trace.target = target if(!isnull(flags)) trace.flags = flags //Set the flags... trace.pass_flags = pass_flags //And the pass flags to that of the real projectile... - trace.firer = user var/output = trace.process() //Test it! qdel(trace) //No need for it anymore return output //Send it back to the gun! From ba7e3ae9e855ac2a2d6861bec825bd3940a48913 Mon Sep 17 00:00:00 2001 From: Loganbacca Date: Fri, 10 Jul 2015 16:12:30 +1200 Subject: [PATCH 2/5] Cargo train vs projectiles If a cargo train has a mob riding it, there is a chance the mob will be hit by the projectile instead. --- code/modules/projectiles/projectile.dm | 2 +- code/modules/vehicles/cargo_train.dm | 7 +++++++ 2 files changed, 8 insertions(+), 1 deletion(-) diff --git a/code/modules/projectiles/projectile.dm b/code/modules/projectiles/projectile.dm index d60169d836..335df66105 100644 --- a/code/modules/projectiles/projectile.dm +++ b/code/modules/projectiles/projectile.dm @@ -37,7 +37,7 @@ var/dispersion = 0.0 var/damage = 10 - var/damage_type = BRUTE //BRUTE, BURN, TOX, OXY, CLONE are the only things that should be in here + var/damage_type = BRUTE //BRUTE, BURN, TOX, OXY, CLONE, HALLOSS are the only things that should be in here var/nodamage = 0 //Determines if the projectile will skip any damage inflictions var/taser_effect = 0 //If set then the projectile will apply it's agony damage using stun_effect_act() to mobs it hits, and other damage will be ignored var/check_armour = "bullet" //Defines what armor to use when it hits things. Must be set to bullet, laser, energy,or bomb //Cael - bio and rad are also valid diff --git a/code/modules/vehicles/cargo_train.dm b/code/modules/vehicles/cargo_train.dm index b539dde039..c6ff870988 100644 --- a/code/modules/vehicles/cargo_train.dm +++ b/code/modules/vehicles/cargo_train.dm @@ -79,6 +79,13 @@ return ..() +//cargo trains are open topped, so there is a chance the projectile will hit the mob ridding the train instead +/obj/vehicle/train/cargo/bullet_act(var/obj/item/projectile/Proj) + if(buckled_mob && prob(70)) + buckled_mob.bullet_act(Proj) + return + ..() + /obj/vehicle/train/cargo/update_icon() if(open) icon_state = initial(icon_state) + "_open" From f30fa4b4bef090cafb06c47a2e70d97e7b63770d Mon Sep 17 00:00:00 2001 From: Loganbacca Date: Fri, 10 Jul 2015 16:18:21 +1200 Subject: [PATCH 3/5] Changelog --- html/changelogs/Loganbacca-fixes.yml | 37 ++++++++++++++++++++++++++++ 1 file changed, 37 insertions(+) create mode 100644 html/changelogs/Loganbacca-fixes.yml diff --git a/html/changelogs/Loganbacca-fixes.yml b/html/changelogs/Loganbacca-fixes.yml new file mode 100644 index 0000000000..a8d0df8941 --- /dev/null +++ b/html/changelogs/Loganbacca-fixes.yml @@ -0,0 +1,37 @@ +################################ +# Example Changelog File +# +# Note: This file, and files beginning with ".", and files that don't end in ".yml" will not be read. If you change this file, you will look really dumb. +# +# Your changelog will be merged with a master changelog. (New stuff added only, and only on the date entry for the day it was merged.) +# When it is, any changes listed below will disappear. +# +# Valid Prefixes: +# bugfix +# wip (For works in progress) +# tweak +# soundadd +# sounddel +# rscadd (general adding of nice things) +# rscdel (general deleting of nice things) +# imageadd +# imagedel +# maptweak +# spellcheck (typo fixes) +# experiment +################################# + +# Your name. +author: Loganbacca + +# Optional: Remove this file after generating master changelog. Useful for PR changelogs that won't get used again. +delete-after: True + +# Any changes you've made. See valid prefix list above. +# INDENT WITH TWO SPACES. NOT TABS. SPACES. +# SCREW THIS UP AND IT WON'T WORK. +# Also, all entries are changed into a single [] after a master changelog generation. Just remove the brackets when you add new entries. +# Please surround your changes in double quotes ("), as certain characters otherwise screws up compiling. The quotes will not show up in the changelog. +changes: + - bugfix: "Turrets no longer burn holes through the AI." + - tweak: "Projectiles now have a chance of hitting mobs riding cargo trains." From c04fc312e26bc3f5672f6175e46c77d7ea406279 Mon Sep 17 00:00:00 2001 From: Loganbacca Date: Sat, 11 Jul 2015 01:41:03 +1200 Subject: [PATCH 4/5] Moved trajectory check to during target assessment --- code/game/machinery/portable_turret.dm | 21 ++++++++--------- code/modules/projectiles/projectile.dm | 2 +- html/changelogs/Loganbacca-fixes.yml | 32 -------------------------- 3 files changed, 10 insertions(+), 45 deletions(-) diff --git a/code/game/machinery/portable_turret.dm b/code/game/machinery/portable_turret.dm index 6a0ad704a2..e5b5e53cbd 100644 --- a/code/game/machinery/portable_turret.dm +++ b/code/game/machinery/portable_turret.dm @@ -474,20 +474,21 @@ var/list/turret_icons if(!L) return TURRET_NOT_TARGET - // If emagged not even the dead get a rest - if(emagged) - return L.stat ? TURRET_SECONDARY_TARGET : TURRET_PRIORITY_TARGET - if(issilicon(L)) // Don't target silica return TURRET_NOT_TARGET - if(L.stat) //if the perp is dead/dying, no need to bother really + if(L.stat && !emagged) //if the perp is dead/dying, no need to bother really return TURRET_NOT_TARGET //move onto next potential victim! - var/dst = get_dist(src, L) //if it's too far away, why bother? - if(dst > 7) + if(get_dist(src, L) > 7) //if it's too far away, why bother? return 0 + if(!check_trajectory(L, src)) //check if we have true line of sight + return TURRET_NOT_TARGET + + if(emagged) // If emagged not even the dead get a rest + return L.stat ? TURRET_SECONDARY_TARGET : TURRET_PRIORITY_TARGET + if(check_synth) //If it's set to attack all non-silicons, target them! if(L.lying) return lethal ? TURRET_SECONDARY_TARGET : TURRET_NOT_TARGET @@ -498,6 +499,7 @@ var/list/turret_icons if(isanimal(L) || issmall(L)) // Animals are not so dangerous return check_anomalies ? TURRET_SECONDARY_TARGET : TURRET_NOT_TARGET + if(isxenomorph(L) || isalien(L)) // Xenos are dangerous return check_anomalies ? TURRET_PRIORITY_TARGET : TURRET_NOT_TARGET @@ -606,11 +608,6 @@ var/list/turret_icons return update_icon() - - //targeting check, can we hit them? - if(!check_trajectory(target, src)) - return - var/obj/item/projectile/A if(emagged || lethal) A = new eprojectile(loc) diff --git a/code/modules/projectiles/projectile.dm b/code/modules/projectiles/projectile.dm index 335df66105..73ca2b7476 100644 --- a/code/modules/projectiles/projectile.dm +++ b/code/modules/projectiles/projectile.dm @@ -427,7 +427,7 @@ /proc/check_trajectory(atom/target as mob|obj, atom/firer as mob|obj, var/pass_flags=PASSTABLE|PASSGLASS|PASSGRILLE, flags=null) //Checks if you can hit them or not. if(!istype(target) || !istype(firer)) return 0 - var/obj/item/projectile/test/trace = new /obj/item/projectile/test(get_step_to(firer,target)) //Making the test.... + var/obj/item/projectile/test/trace = new /obj/item/projectile/test(get_turf(firer)) //Making the test.... trace.target = target if(!isnull(flags)) trace.flags = flags //Set the flags... diff --git a/html/changelogs/Loganbacca-fixes.yml b/html/changelogs/Loganbacca-fixes.yml index a8d0df8941..fd4c2f8b00 100644 --- a/html/changelogs/Loganbacca-fixes.yml +++ b/html/changelogs/Loganbacca-fixes.yml @@ -1,37 +1,5 @@ -################################ -# Example Changelog File -# -# Note: This file, and files beginning with ".", and files that don't end in ".yml" will not be read. If you change this file, you will look really dumb. -# -# Your changelog will be merged with a master changelog. (New stuff added only, and only on the date entry for the day it was merged.) -# When it is, any changes listed below will disappear. -# -# Valid Prefixes: -# bugfix -# wip (For works in progress) -# tweak -# soundadd -# sounddel -# rscadd (general adding of nice things) -# rscdel (general deleting of nice things) -# imageadd -# imagedel -# maptweak -# spellcheck (typo fixes) -# experiment -################################# - -# Your name. author: Loganbacca - -# Optional: Remove this file after generating master changelog. Useful for PR changelogs that won't get used again. delete-after: True - -# Any changes you've made. See valid prefix list above. -# INDENT WITH TWO SPACES. NOT TABS. SPACES. -# SCREW THIS UP AND IT WON'T WORK. -# Also, all entries are changed into a single [] after a master changelog generation. Just remove the brackets when you add new entries. -# Please surround your changes in double quotes ("), as certain characters otherwise screws up compiling. The quotes will not show up in the changelog. changes: - bugfix: "Turrets no longer burn holes through the AI." - tweak: "Projectiles now have a chance of hitting mobs riding cargo trains." From 7a82e1c563bc457d34643f46226d4704aecfc4d8 Mon Sep 17 00:00:00 2001 From: Loganbacca Date: Sat, 11 Jul 2015 13:14:56 +1200 Subject: [PATCH 5/5] Fixed turrets accidentally killing the AI --- code/game/machinery/portable_turret.dm | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/code/game/machinery/portable_turret.dm b/code/game/machinery/portable_turret.dm index e5b5e53cbd..934aeec09c 100644 --- a/code/game/machinery/portable_turret.dm +++ b/code/game/machinery/portable_turret.dm @@ -474,14 +474,14 @@ var/list/turret_icons if(!L) return TURRET_NOT_TARGET - if(issilicon(L)) // Don't target silica + if(!emagged && issilicon(L)) // Don't target silica return TURRET_NOT_TARGET if(L.stat && !emagged) //if the perp is dead/dying, no need to bother really return TURRET_NOT_TARGET //move onto next potential victim! if(get_dist(src, L) > 7) //if it's too far away, why bother? - return 0 + return TURRET_NOT_TARGET if(!check_trajectory(L, src)) //check if we have true line of sight return TURRET_NOT_TARGET @@ -489,6 +489,9 @@ var/list/turret_icons if(emagged) // If emagged not even the dead get a rest return L.stat ? TURRET_SECONDARY_TARGET : TURRET_PRIORITY_TARGET + if(lethal && locate(/mob/living/silicon/ai) in get_turf(L)) //don't accidentally kill the AI! + return TURRET_NOT_TARGET + if(check_synth) //If it's set to attack all non-silicons, target them! if(L.lying) return lethal ? TURRET_SECONDARY_TARGET : TURRET_NOT_TARGET