Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Properly splits attack_ai() and attack_robot() where in make sense #11310

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions beestation.dme
Original file line number Diff line number Diff line change
Expand Up @@ -357,6 +357,7 @@
#include "code\_onclick\other_mobs.dm"
#include "code\_onclick\overmind.dm"
#include "code\_onclick\pai.dm"
#include "code\_onclick\silicon.dm"
#include "code\_onclick\telekinesis.dm"
#include "code\_onclick\hud\_defines.dm"
#include "code\_onclick\hud\action_button.dm"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@
#define COMPONENT_NO_AFTERATTACK (1<<0)
///from base of atom/attack_hulk(): (/mob/living/carbon/human)
#define COMSIG_ATOM_HULK_ATTACK "hulk_attack"
///from base of atom/attack_ai(): (/mob/user)
#define COMSIG_ATOM_ATTACK_AI "attack_ai"
///from base of atom/animal_attack(): (/mob/user)
#define COMSIG_ATOM_ATTACK_ANIMAL "attack_animal"
//from base of atom/attack_basic_mob(): (/mob/user)
Expand All @@ -25,3 +27,7 @@
#define COMSIG_ATOM_ATTACK_HAND "atom_attack_hand"
///from base of atom/attack_paw(): (mob/user)
#define COMSIG_ATOM_ATTACK_PAW "atom_attack_paw"
///from base of atom/attack_robot(): (mob/user)
#define COMSIG_ATOM_ATTACK_ROBOT "atom_attack_robot"
///from base of atom/attack_silicon(): (mob/user)
#define COMSIG_ATOM_ATTACK_SILICON "atom_attack_silicon"
6 changes: 5 additions & 1 deletion code/_onclick/ai.dm
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,11 @@
A.attack_ai(src)

/atom/proc/attack_ai(mob/user)
return
if(SEND_SIGNAL(src, COMSIG_ATOM_ATTACK_AI, user) & COMPONENT_CANCEL_ATTACK_CHAIN)
return TRUE
if(attack_silicon(user))
return TRUE
return FALSE

/*
Since the AI handles shift, ctrl, and alt-click differently
Expand Down
7 changes: 5 additions & 2 deletions code/_onclick/cyborg.dm
Original file line number Diff line number Diff line change
Expand Up @@ -182,5 +182,8 @@
A.attack_robot(src)

/atom/proc/attack_robot(mob/user)
attack_ai(user)
return
if(SEND_SIGNAL(src, COMSIG_ATOM_ATTACK_ROBOT, user) & COMPONENT_CANCEL_ATTACK_CHAIN)
return TRUE
if(attack_silicon(user))
return TRUE
return FALSE
9 changes: 9 additions & 0 deletions code/_onclick/silicon.dm
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
/**
* Often times, we want functionality to be available to both AIs and Cyborgs.
*
* returns TRUE if action has been done
*/
/atom/proc/attack_silicon(mob/user)
if(SEND_SIGNAL(src, COMSIG_ATOM_ATTACK_SILICON, user) & COMPONENT_CANCEL_ATTACK_CHAIN)
return TRUE
return FALSE
12 changes: 8 additions & 4 deletions code/game/machinery/_machinery.dm
Original file line number Diff line number Diff line change
Expand Up @@ -462,6 +462,9 @@ Class Procs:
user.visible_message("<span class='danger'>[user] smashes [src] with [user.p_their()] paws[damage ? "." : ", without leaving a mark!"]</span>", null, null, COMBAT_MESSAGE_RANGE)

/obj/machinery/attack_robot(mob/user)
if(isAI(user))
CRASH("An AI just tried to run attack_robot().") // They should not be running the same procs anymore.
. = ..()
if(!(interaction_flags_machine & INTERACT_MACHINE_ALLOW_SILICON) && !IsAdminGhost(user))
return FALSE
if(Adjacent(user) && can_buckle && has_buckled_mobs()) //so that borgs (but not AIs, sadly (perhaps in a future PR?)) can unbuckle people from machines
Expand All @@ -475,12 +478,13 @@ Class Procs:
return _try_interact(user)

/obj/machinery/attack_ai(mob/user)
if(iscyborg(user))
CRASH("A cyborg just tried to run attack_ai().") // They should not be running the same procs anymore.
. = ..()
if(!(interaction_flags_machine & INTERACT_MACHINE_ALLOW_SILICON) && !IsAdminGhost(user))
return FALSE
if(iscyborg(user))// For some reason attack_robot doesn't work
return attack_robot(user)
else
return _try_interact(user)

return _try_interact(user)

/obj/machinery/_try_interact(mob/user)
if((interaction_flags_machine & INTERACT_MACHINE_WIRES_IF_OPEN) && panel_open && (attempt_wire_interaction(user) == WIRE_INTERACTION_BLOCK))
Expand Down
6 changes: 2 additions & 4 deletions code/game/machinery/announcement_system.dm
Original file line number Diff line number Diff line change
Expand Up @@ -155,16 +155,14 @@ GLOBAL_LIST_EMPTY(announcement_systems)
update_icon()
. = TRUE

/obj/machinery/announcement_system/attack_robot(mob/living/silicon/user)
. = attack_ai(user)

/obj/machinery/announcement_system/attack_ai(mob/user)
/obj/machinery/announcement_system/attack_silicon(mob/user)
if(!user.canUseTopic(src, !issilicon(user)))
return
if(machine_stat & BROKEN)
to_chat(user, "<span class='warning'>[src]'s firmware appears to be malfunctioning!</span>")
return
interact(user)
return TRUE

/obj/machinery/announcement_system/proc/act_up() //does funny breakage stuff
if(!obj_break()) // if badmins flag this unbreakable or its already broken
Expand Down
5 changes: 1 addition & 4 deletions code/game/machinery/buttons.dm
Original file line number Diff line number Diff line change
Expand Up @@ -116,13 +116,10 @@ CREATION_TEST_IGNORE_SUBTYPES(/obj/machinery/button)
if(do_after(eminence, 20, target=get_turf(eminence)))
attack_hand(eminence)

/obj/machinery/button/attack_ai(mob/user)
/obj/machinery/button/attack_silicon(mob/user)
if(!panel_open)
return attack_hand(user)

/obj/machinery/button/attack_robot(mob/user)
return attack_ai(user)

/obj/machinery/button/proc/setup_device()
if(id && istype(device, /obj/item/assembly/control))
var/obj/item/assembly/control/A = device
Expand Down
4 changes: 2 additions & 2 deletions code/game/machinery/cell_charger.dm
Original file line number Diff line number Diff line change
Expand Up @@ -103,8 +103,8 @@
removecell()
return COMPONENT_CANCEL_ATTACK_CHAIN

/obj/machinery/cell_charger/attack_ai(mob/user)
return
/obj/machinery/cell_charger/attack_silicon(mob/user)
return TRUE

/obj/machinery/cell_charger/emp_act(severity)
. = ..()
Expand Down
5 changes: 1 addition & 4 deletions code/game/machinery/cloning.dm
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,7 @@
reagents.reaction(user.loc)
src.reagents.clear_reagents()

/obj/machinery/clonepod/attack_ai(mob/user)
/obj/machinery/clonepod/attack_silicon(mob/user)
return attack_hand(user)

/obj/machinery/clonepod/examine(mob/user)
Expand Down Expand Up @@ -179,9 +179,6 @@
if(mob_occupant)
. = (100 * ((mob_occupant.health + 100) / (heal_level + 100)))

/obj/machinery/clonepod/attack_ai(mob/user)
return examine(user)

//Start growing a human clone in the pod!
/obj/machinery/clonepod/proc/growclone(clonename, ui, mutation_index, mindref, last_death, datum/species/mrace, list/features, factions, datum/bank_account/insurance, list/traumas, body_only, experimental)
var/result = CLONING_SUCCESS
Expand Down
2 changes: 1 addition & 1 deletion code/game/machinery/computer/apc_control.dm
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@
active_apc.remote_control = null
active_apc = null

/obj/machinery/computer/apc_control/attack_ai(mob/user)
/obj/machinery/computer/apc_control/attack_silicon(mob/user)
if(!IsAdminGhost(user))
to_chat(user,"<span class='warning'>[src] does not support AI control.</span>") //You already have APC access, cheater!
return
Expand Down
4 changes: 2 additions & 2 deletions code/game/machinery/cryopod.dm
Original file line number Diff line number Diff line change
Expand Up @@ -43,8 +43,8 @@ GLOBAL_LIST_EMPTY(cryopod_computers)
GLOB.cryopod_computers -= src
..()

/obj/machinery/computer/cryopod/attack_ai()
attack_hand()
/obj/machinery/computer/cryopod/attack_silicon()
return attack_hand()

/obj/machinery/computer/cryopod/attack_hand(mob/user = usr)
if(machine_stat & (NOPOWER|BROKEN))
Expand Down
3 changes: 2 additions & 1 deletion code/game/machinery/dish_drive.dm
Original file line number Diff line number Diff line change
Expand Up @@ -102,11 +102,12 @@
else
step_towards(I, src)

/obj/machinery/dish_drive/attack_ai(mob/living/user)
/obj/machinery/dish_drive/attack_silicon(mob/living/user)
if(machine_stat)
return
to_chat(user, "<span class='notice'>You send a disposal transmission signal to [src].</span>")
do_the_dishes(TRUE)
return TRUE

/obj/machinery/dish_drive/AltClick(mob/living/user)
if(user.canUseTopic(src, !issilicon(user)))
Expand Down
3 changes: 2 additions & 1 deletion code/game/machinery/doors/airlock.dm
Original file line number Diff line number Diff line change
Expand Up @@ -769,7 +769,7 @@
. += "<span class='notice'>Alt-click [src] to [ secondsElectrified ? "un-electrify" : "permanently electrify"] it.</span>"
. += "<span class='notice'>Ctrl-Shift-click [src] to [ emergency ? "disable" : "enable"] emergency access.</span>"

/obj/machinery/door/airlock/attack_ai(mob/user)
/obj/machinery/door/airlock/attack_silicon(mob/user)
if(!canAIControl(user))
if(canAIHack())
hack(user)
Expand All @@ -784,6 +784,7 @@
return

ui_interact(user)
return TRUE

/obj/machinery/door/airlock/proc/hack(mob/user)
set waitfor = 0
Expand Down
5 changes: 1 addition & 4 deletions code/game/machinery/doors/firedoor.dm
Original file line number Diff line number Diff line change
Expand Up @@ -229,7 +229,7 @@
return ..()


/obj/machinery/door/firedoor/attack_ai(mob/user)
/obj/machinery/door/firedoor/attack_silicon(mob/user)
add_fingerprint(user)
if(welded || operating || machine_stat & NOPOWER)
return TRUE
Expand All @@ -239,9 +239,6 @@
close()
return TRUE

/obj/machinery/door/firedoor/attack_robot(mob/user)
return attack_ai(user)

/obj/machinery/door/firedoor/attack_alien(mob/user)
add_fingerprint(user)
if(welded)
Expand Down
5 changes: 1 addition & 4 deletions code/game/machinery/firealarm.dm
Original file line number Diff line number Diff line change
Expand Up @@ -193,10 +193,7 @@ CREATION_TEST_IGNORE_SUBTYPES(/obj/machinery/firealarm)
else
alarm(user)

/obj/machinery/firealarm/attack_ai(mob/user)
return attack_hand(user)

/obj/machinery/firealarm/attack_robot(mob/user)
/obj/machinery/firealarm/attack_silicon(mob/user)
return attack_hand(user)

/obj/machinery/firealarm/attackby(obj/item/W, mob/user, params)
Expand Down
2 changes: 1 addition & 1 deletion code/game/machinery/flasher.dm
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@ CREATION_TEST_IGNORE_SUBTYPES(/obj/machinery/flasher)
return ..()

//Let the AI trigger them directly.
/obj/machinery/flasher/attack_ai()
/obj/machinery/flasher/attack_silicon()
if (anchored)
return flash()

Expand Down
4 changes: 1 addition & 3 deletions code/game/machinery/igniter.dm
Original file line number Diff line number Diff line change
Expand Up @@ -116,11 +116,9 @@ MAPPING_DIRECTIONAL_HELPERS(/obj/machinery/sparker, 26)
update_appearance()
return TRUE

/obj/machinery/sparker/attack_ai()
/obj/machinery/sparker/attack_silicon()
if (anchored)
return ignite()
else
return

/obj/machinery/sparker/proc/ignite()
if (!(powered()))
Expand Down
2 changes: 1 addition & 1 deletion code/game/machinery/navbeacon.dm
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,7 @@
else
return ..()

/obj/machinery/navbeacon/attack_ai(mob/user)
/obj/machinery/navbeacon/attack_silicon(mob/user)
interact(user, 1)

/obj/machinery/navbeacon/attack_paw()
Expand Down
8 changes: 1 addition & 7 deletions code/game/machinery/porta_turret/portable_turret.dm
Original file line number Diff line number Diff line change
Expand Up @@ -941,13 +941,7 @@ DEFINE_BUFFER_HANDLER(/obj/machinery/turretid)
to_chat(user, "<span class='danger'>You short out the turret controls' access analysis module.</span>")
locked = FALSE

/obj/machinery/turretid/attack_robot(mob/user)
if(!ailock)
return attack_hand(user)
else
to_chat(user, "<span class='notice'>There seems to be a firewall preventing you from accessing this device.</span>")

/obj/machinery/turretid/attack_ai(mob/user)
/obj/machinery/turretid/attack_silicon(mob/user)
if(!ailock || IsAdminGhost(user))
return attack_hand(user)
else
Expand Down
4 changes: 2 additions & 2 deletions code/game/machinery/porta_turret/portable_turret_construct.dm
Original file line number Diff line number Diff line change
Expand Up @@ -185,8 +185,8 @@
new /obj/item/assembly/prox_sensor(loc)
build_step = PTURRET_GUN_EQUIPPED

/obj/machinery/porta_turret_construct/attack_ai()
return
/obj/machinery/porta_turret_construct/attack_silicon()
return TRUE

#undef PTURRET_UNSECURED
#undef PTURRET_BOLTED
Expand Down
3 changes: 1 addition & 2 deletions code/game/machinery/porta_turret/portable_turret_cover.dm
Original file line number Diff line number Diff line change
Expand Up @@ -23,14 +23,13 @@
//>necessary
//I'm not fixing it because i'm fucking bored of this code already, but someone should just reroute these to the parent turret's procs.

/obj/machinery/porta_turret_cover/attack_ai(mob/user)
/obj/machinery/porta_turret_cover/attack_silicon(mob/user)
. = ..()
if(.)
return

return parent_turret.attack_ai(user)


/obj/machinery/porta_turret_cover/attack_hand(mob/user)
. = ..()
if(.)
Expand Down
2 changes: 0 additions & 2 deletions code/game/machinery/status_display.dm
Original file line number Diff line number Diff line change
Expand Up @@ -449,8 +449,6 @@ MAPPING_DIRECTIONAL_HELPERS(/obj/machinery/status_display/ai, 32)
. = ..()

/obj/machinery/status_display/ai/attack_ai(mob/living/silicon/ai/user)
if(!isAI(user))
return
var/list/choices = list()
for(var/emotion_const in emotion_map)
var/icon_state = emotion_map[emotion_const]
Expand Down
5 changes: 2 additions & 3 deletions code/game/machinery/syndicatebeacon.dm
Original file line number Diff line number Diff line change
Expand Up @@ -42,9 +42,8 @@
to_chat(user, "<span class='notice'>You deactivate the beacon.</span>")


/obj/machinery/power/singularity_beacon/attack_ai(mob/user)
return

/obj/machinery/power/singularity_beacon/attack_silicon(mob/user)
return TRUE

/obj/machinery/power/singularity_beacon/attack_hand(mob/user)
. = ..()
Expand Down
7 changes: 4 additions & 3 deletions code/game/objects/items.dm
Original file line number Diff line number Diff line change
Expand Up @@ -542,11 +542,12 @@ GLOBAL_VAR_INIT(rpg_loot_items, FALSE)
return
attack_paw(A)

/obj/item/attack_ai(mob/user)
/obj/item/attack_robot(mob/living/user)
. = ..()
if(.)
return
if(istype(src.loc, /obj/item/robot_module))
//If the item is part of a cyborg module, equip it
if(!iscyborg(user))
return
var/mob/living/silicon/robot/R = user
if(!R.low_power_mode) //can't equip modules with an empty cell.
R.activate_module(src)
Expand Down
4 changes: 2 additions & 2 deletions code/game/objects/items/devices/powersink.dm
Original file line number Diff line number Diff line change
Expand Up @@ -100,8 +100,8 @@
/obj/item/powersink/attack_paw()
return

/obj/item/powersink/attack_ai()
return
/obj/item/powersink/attack_silicon()
return TRUE

/obj/item/powersink/attack_hand(mob/user)
. = ..()
Expand Down
2 changes: 1 addition & 1 deletion code/game/objects/items/devices/radio/intercom.dm
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ CREATION_TEST_IGNORE_SUBTYPES(/obj/item/radio/intercom)
return
return ..()

/obj/item/radio/intercom/attack_ai(mob/user)
/obj/item/radio/intercom/attack_silicon(mob/user)
interact(user)

/obj/item/radio/intercom/attack_paw(mob/user)
Expand Down
2 changes: 1 addition & 1 deletion code/game/objects/structures/barsigns.dm
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@
if(BURN)
playsound(src.loc, 'sound/items/welder.ogg', 100, 1)

/obj/structure/sign/barsign/attack_ai(mob/user)
/obj/structure/sign/barsign/attack_silicon(mob/user)
return attack_hand(user)

/obj/structure/sign/barsign/attack_hand(mob/user)
Expand Down
2 changes: 1 addition & 1 deletion code/game/objects/structures/fireaxe.dm
Original file line number Diff line number Diff line change
Expand Up @@ -131,7 +131,7 @@ MAPPING_DIRECTIONAL_HELPERS(/obj/structure/fireaxecabinet, 32)
/obj/structure/fireaxecabinet/attack_paw(mob/living/user)
return attack_hand(user)

/obj/structure/fireaxecabinet/attack_ai(mob/user)
/obj/structure/fireaxecabinet/attack_silicon(mob/user)
toggle_lock(user)
return

Expand Down
10 changes: 4 additions & 6 deletions code/game/objects/structures/mineral_doors.dm
Original file line number Diff line number Diff line change
Expand Up @@ -40,12 +40,10 @@
if(!door_opened)
return TryToSwitchState(AM)

/obj/structure/mineral_door/attack_ai(mob/user) //those aren't machinery, they're just big fucking slabs of a mineral
if(isAI(user)) //so the AI can't open it
return
else if(iscyborg(user)) //but cyborgs can
if(get_dist(user,src) <= 1) //not remotely though
return TryToSwitchState(user)
/obj/structure/mineral_door/attack_robot(mob/user) //those aren't machinery, they're just big fucking slabs of a mineral
// so the AI can't open it but cyborgs can
if(get_dist(user,src) <= 1) //not remotely though
return TryToSwitchState(user)

/obj/structure/mineral_door/attack_paw(mob/user)
return attack_hand(user)
Expand Down
Loading
Loading