Skip to content

Commit

Permalink
[MIRROR] Fixes Malf AI not being able to override/overload turrets th…
Browse files Browse the repository at this point in the history
…at have covers (#2530)

* Fixes Malf AI not being able to override/overload turrets that have covers (#83252)

Properly fixes #7617

🆑 ShizCalev
fix: Malf AI can now override/overload closed turrets.
fix: Fixed a scenario in which a turret would have its covers closed
while still firing.
/🆑

cleaned up a dumb proc that was added at the machinery level for
literally only turret covers, and added support for fixing turrets in
the future (through atom_fix(), which is essentially unused at this
time.)

* Fixes Malf AI not being able to override/overload turrets that have covers

---------

Co-authored-by: Afevis <[email protected]>
Co-authored-by: NovaBot13 <[email protected]>
  • Loading branch information
3 people authored and StealsThePRs committed May 17, 2024
1 parent f0b81b9 commit b2c7709
Show file tree
Hide file tree
Showing 4 changed files with 24 additions and 14 deletions.
3 changes: 0 additions & 3 deletions code/game/machinery/_machinery.dm
Original file line number Diff line number Diff line change
Expand Up @@ -1148,9 +1148,6 @@
PROTECTED_PROC(TRUE)
return

/obj/machinery/proc/can_be_overridden()
. = 1

/obj/machinery/zap_act(power, zap_flags)
if(prob(85) && (zap_flags & ZAP_MACHINE_EXPLOSIVE) && !(resistance_flags & INDESTRUCTIBLE))
explosion(src, devastation_range = 1, heavy_impact_range = 2, light_impact_range = 4, flame_range = 2, adminlog = TRUE, smoke = FALSE)
Expand Down
20 changes: 13 additions & 7 deletions code/game/machinery/porta_turret/portable_turret.dm
Original file line number Diff line number Diff line change
Expand Up @@ -420,17 +420,23 @@ DEFINE_BITFIELD(turret_flags, list(
power_change()
SetInvisibility(INVISIBILITY_NONE, id=type)
spark_system.start() //creates some sparks because they look cool
has_cover = FALSE
qdel(cover) //deletes the cover - no need on keeping it there!

/obj/machinery/porta_turret/atom_fix()
set_machine_stat(machine_stat & ~BROKEN)
has_cover = initial(has_cover)
check_should_process()
return ..()


/obj/machinery/porta_turret/process()
//the main machinery process
if(cover == null && anchored) //if it has no cover and is anchored
if(machine_stat & BROKEN) //if the turret is borked
qdel(cover) //delete its cover, assuming it has one. Workaround for a pesky little bug
else
if(has_cover)
cover = new /obj/machinery/porta_turret_cover(loc) //if the turret has no cover and is anchored, give it a cover
cover.parent_turret = src //assign the cover its parent_turret, which would be this (src)
if(has_cover && cover == null && anchored && !(machine_stat & BROKEN)) //if it has no cover and is anchored
cover = new /obj/machinery/porta_turret_cover(loc) //if the turret has no cover and is anchored, give it a cover
cover.parent_turret = src //assign the cover its parent_turret, which would be this (src)
if(raised)
cover.icon_state = "openTurretCover"

if(!on || (machine_stat & (NOPOWER|BROKEN)))
return PROCESS_KILL
Expand Down
3 changes: 0 additions & 3 deletions code/game/machinery/porta_turret/portable_turret_cover.dm
Original file line number Diff line number Diff line change
Expand Up @@ -82,9 +82,6 @@
/obj/machinery/porta_turret_cover/attack_hulk(mob/living/carbon/human/user)
return parent_turret.attack_hulk(user)

/obj/machinery/porta_turret_cover/can_be_overridden()
. = 0

/obj/machinery/porta_turret_cover/emag_act(mob/user, obj/item/card/emag/emag_card)

if((parent_turret.obj_flags & EMAGGED))
Expand Down
12 changes: 11 additions & 1 deletion code/modules/antagonists/malf_ai/malf_ai_modules.dm
Original file line number Diff line number Diff line change
Expand Up @@ -450,7 +450,12 @@ GLOBAL_LIST_INIT(malf_modules, subtypesof(/datum/ai_module))
to_chat(caller, span_warning("You can only animate machines!"))
return FALSE
var/obj/machinery/clicked_machine = clicked_on
if(!clicked_machine.can_be_overridden() || is_type_in_typecache(clicked_machine, GLOB.blacklisted_malf_machines))

if(istype(clicked_machine, /obj/machinery/porta_turret_cover)) //clicking on a closed turret will attempt to override the turret itself instead of the animated/abstract cover.
var/obj/machinery/porta_turret_cover/clicked_turret = clicked_machine
clicked_machine = clicked_turret.parent_turret

if(is_type_in_typecache(clicked_machine, GLOB.blacklisted_malf_machines))
to_chat(caller, span_warning("That machine can't be overridden!"))
return FALSE

Expand Down Expand Up @@ -538,6 +543,11 @@ GLOBAL_LIST_INIT(malf_modules, subtypesof(/datum/ai_module))
to_chat(caller, span_warning("You can only overload machines!"))
return FALSE
var/obj/machinery/clicked_machine = clicked_on

if(istype(clicked_machine, /obj/machinery/porta_turret_cover)) //clicking on a closed turret will attempt to override the turret itself instead of the animated/abstract cover.
var/obj/machinery/porta_turret_cover/clicked_turret = clicked_machine
clicked_machine = clicked_turret.parent_turret

if(is_type_in_typecache(clicked_machine, GLOB.blacklisted_malf_machines))
to_chat(caller, span_warning("You cannot overload that device!"))
return FALSE
Expand Down

0 comments on commit b2c7709

Please sign in to comment.