Anti Turret Cheese (#9915)

This commit is contained in:
Werner
2020-09-07 23:36:51 +02:00
committed by GitHub
parent 475929ce4c
commit bc7f0563bf
4 changed files with 77 additions and 10 deletions
+1
View File
@@ -44,6 +44,7 @@
#define PASSGRILLE 0x4
#define PASSDOORHATCH 0x8
#define PASSMOB 0x10
#define PASSTRACE 0x20 //Used by turrets in the check_trajectory proc to target mobs hiding behind certain things (such as closets)
// Bitmasks for the flags_inv variable. These determine when a piece of clothing hides another, i.e. a helmet hiding glasses.
#define HIDEGLOVES 0x1
+33 -10
View File
@@ -491,8 +491,10 @@
for(var/v in view(world.view, src))
if(isliving(v))
var/mob/living/L = v
assess_and_assign(L, targets, secondarytargets)
assess_and_assign_living(v, targets, secondarytargets)
if(istype(v,/obj/structure/closet))
assess_and_assign_closet(v, targets, secondarytargets)
if(!tryToShootAt(targets))
if(!tryToShootAt(secondarytargets) && !resetting) // if no valid targets, go for secondary targets
@@ -520,13 +522,34 @@
popDown()
resetting = FALSE
/obj/machinery/porta_turret/proc/assess_and_assign(var/mob/living/L, var/list/targets, var/list/secondarytargets)
/obj/machinery/porta_turret/proc/assess_and_assign_living(var/mob/living/L, var/list/targets, var/list/secondarytargets)
switch(assess_living(L))
if(TURRET_PRIORITY_TARGET)
targets += L
if(TURRET_SECONDARY_TARGET)
secondarytargets += L
/obj/machinery/porta_turret/proc/assess_and_assign_closet(var/obj/structure/closet/C, var/list/targets, var/list/secondarytargets)
if(is_type_in_list(C,list(/obj/structure/closet/statue,/obj/structure/closet/hydrant,/obj/structure/closet/walllocker)))
return
if(!lethal)
return
//If someone in the locker is a primary target, we assign the locker as a primary target and return immediately.
//If someone in the locker is a secondary target, we remember that and only assign the locker as a secondary target, if there is no other primary target in the locker.
var/found_secondary = FALSE
for(var/O in C.contents)
if(!isliving(O))
continue
switch(assess_living(O))
if(TURRET_PRIORITY_TARGET)
targets += C
return
if(TURRET_SECONDARY_TARGET)
found_secondary = TRUE
if(found_secondary)
secondarytargets += C
/obj/machinery/porta_turret/proc/assess_living(var/mob/living/L)
if(!istype(L))
return TURRET_NOT_TARGET
@@ -546,7 +569,7 @@
if(get_dist(src, L) > 7) //if it's too far away, why bother?
return TURRET_NOT_TARGET
var/flags = PASSTABLE
var/flags = PASSTABLE|PASSTRACE
if(ispath(projectile, /obj/item/projectile/beam) || ispath(eprojectile, /obj/item/projectile/beam))
flags |= PASSTABLE|PASSGLASS|PASSGRILLE
@@ -598,14 +621,14 @@
return H.assess_perp(src, check_access, check_weapons, check_records, check_arrest)
/obj/machinery/porta_turret/proc/tryToShootAt(var/list/mob/living/targets)
/obj/machinery/porta_turret/proc/tryToShootAt(var/list/targets)
if(targets.len && last_target && (last_target in targets) && target(last_target))
return 1
while(targets.len > 0)
var/mob/living/M = pick(targets)
targets -= M
if(target(M))
var/T = pick(targets)
targets -= T
if(target(T))
return 1
@@ -657,7 +680,7 @@
src.raising = raising
density = raised || raising
/obj/machinery/porta_turret/proc/target(var/mob/living/target)
/obj/machinery/porta_turret/proc/target(var/target)
if(disabled)
return
if(target)
@@ -674,7 +697,7 @@
/obj/machinery/porta_turret/proc/reset_last_fired()
last_fired = FALSE
/obj/machinery/porta_turret/proc/shootAt(var/mob/living/target)
/obj/machinery/porta_turret/proc/shootAt(var/target)
//any emagged turrets will shoot extremely fast! This not only is deadly, but drains a lot power!
if(last_fired || !raised) //prevents rapid-fire shooting, unless it's been emagged
return
@@ -86,6 +86,8 @@
/obj/structure/closet/CanPass(atom/movable/mover, turf/target, height=0, air_group=0)
if(air_group || (height==0 || wall_mounted)) return 1
if(istype(mover) && mover.checkpass(PASSTRACE))
return 1
return (!density)
/obj/structure/closet/proc/can_open()
@@ -0,0 +1,41 @@
################################
# 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
# balance
# admin
# backend
# security
# refactor
#################################
# Your name.
author: Arrow768
# 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:
- rscadd: "Updates the targeting algorithm of turrets so they are a bit more difficult."