Refactored 'IsAdvancedToolUser' into a macro plus relative trait. Tweaked 'can_hold_items'. (#54665)

The PR aims to allow advanced tool users to be defined by traits rather than a hardcoded proc.
Also necessary for the CanUseTopic refactor I'm working on, which will be PRed separately for atomization purposes.
This PR also fixes an inconsistency with can_hold_items (since monkeys can actually hold items).
This commit is contained in:
Ghom
2020-11-10 15:15:31 -03:00
committed by GitHub
parent c98fd1fc3d
commit 91bfedcd16
34 changed files with 48 additions and 55 deletions
+3 -1
View File
@@ -107,7 +107,8 @@ Remember to update _globalvars/traits.dm if you're adding/removing/renaming trai
#define TRAIT_CLUMSY "clumsy"
#define TRAIT_CHUNKYFINGERS "chunkyfingers" //means that you can't use weapons with normal trigger guards.
#define TRAIT_DUMB "dumb"
#define TRAIT_MONKEYLIKE "monkeylike" //sets IsAdvancedToolUser to FALSE
#define TRAIT_ADVANCEDTOOLUSER "advancedtooluser" //Whether a mob is dexterous enough to use machines and certain items or not.
#define TRAIT_MONKEYLIKE "monkeylike" //Antagonizes the above.
#define TRAIT_PACIFISM "pacifism"
#define TRAIT_IGNORESLOWDOWN "ignoreslow"
#define TRAIT_IGNOREDAMAGESLOWDOWN "ignoredamageslowdown"
@@ -325,6 +326,7 @@ Remember to update _globalvars/traits.dm if you're adding/removing/renaming trai
#define SCRYING_ORB "scrying-orb"
#define ABDUCTOR_ANTAGONIST "abductor-antagonist"
#define NUKEOP_TRAIT "nuke-op"
#define JUNGLE_FEVER_TRAIT "jungle_fever"
#define DEATHSQUAD_TRAIT "deathsquad"
#define MEGAFAUNA_TRAIT "megafauna"
#define CLOWN_NUKE_TRAIT "clown-nuke"
+2
View File
@@ -614,3 +614,5 @@ GLOBAL_LIST_EMPTY(species_list)
else
. = pick(ais)
return .
#define ISADVANCEDTOOLUSER(mob) (HAS_TRAIT(mob, TRAIT_ADVANCEDTOOLUSER) && !HAS_TRAIT(mob, TRAIT_MONKEYLIKE))
+1
View File
@@ -24,6 +24,7 @@ GLOBAL_LIST_INIT(traits_by_type, list(
"TRAIT_CLUMSY" = TRAIT_CLUMSY,
"TRAIT_CHUNKYFINGERS" = TRAIT_CHUNKYFINGERS,
"TRAIT_DUMB" = TRAIT_DUMB,
"TRAIT_ADVANCEDTOOLUSER" = TRAIT_ADVANCEDTOOLUSER,
"TRAIT_MONKEYLIKE" = TRAIT_MONKEYLIKE,
"TRAIT_PACIFISM" = TRAIT_PACIFISM,
"TRAIT_IGNORESLOWDOWN" = TRAIT_IGNORESLOWDOWN,
+1 -1
View File
@@ -51,7 +51,7 @@
/atom/proc/can_interact(mob/user)
if(!user.can_interact_with(src))
return FALSE
if((interaction_flags_atom & INTERACT_ATOM_REQUIRES_DEXTERITY) && !user.IsAdvancedToolUser())
if((interaction_flags_atom & INTERACT_ATOM_REQUIRES_DEXTERITY) && !ISADVANCEDTOOLUSER(user))
to_chat(user, "<span class='warning'>You don't have the dexterity to do this!</span>")
return FALSE
if(!(interaction_flags_atom & INTERACT_ATOM_IGNORE_INCAPACITATED) && user.incapacitated((interaction_flags_atom & INTERACT_ATOM_IGNORE_RESTRAINED), !(interaction_flags_atom & INTERACT_ATOM_CHECK_GRAB)))
+1 -1
View File
@@ -94,7 +94,7 @@
/obj/machinery/sleeper/MouseDrop_T(mob/target, mob/user)
if(HAS_TRAIT(user, TRAIT_UI_BLOCKED) || !Adjacent(user) || !user.Adjacent(target) || !iscarbon(target) || !user.IsAdvancedToolUser())
if(HAS_TRAIT(user, TRAIT_UI_BLOCKED) || !Adjacent(user) || !user.Adjacent(target) || !iscarbon(target) || !ISADVANCEDTOOLUSER(user))
return
close_machine(target)
+1 -1
View File
@@ -140,7 +140,7 @@
toggle_open(user)
/obj/machinery/dna_scannernew/MouseDrop_T(mob/target, mob/user)
if(user.stat != CONSCIOUS || HAS_TRAIT(user, TRAIT_UI_BLOCKED) || !Adjacent(user) || !user.Adjacent(target) || !iscarbon(target) || !user.IsAdvancedToolUser())
if(user.stat != CONSCIOUS || HAS_TRAIT(user, TRAIT_UI_BLOCKED) || !Adjacent(user) || !user.Adjacent(target) || !iscarbon(target) || !ISADVANCEDTOOLUSER(user))
return
close_machine(target)
+1 -1
View File
@@ -198,7 +198,7 @@
/obj/machinery/hypnochair/MouseDrop_T(mob/target, mob/user)
if(HAS_TRAIT(user, TRAIT_UI_BLOCKED) || !Adjacent(user) || !user.Adjacent(target) || !isliving(target) || !user.IsAdvancedToolUser())
if(HAS_TRAIT(user, TRAIT_UI_BLOCKED) || !Adjacent(user) || !user.Adjacent(target) || !isliving(target) || !ISADVANCEDTOOLUSER(user))
return
close_machine(target)
+1 -1
View File
@@ -421,7 +421,7 @@ GLOBAL_VAR_INIT(embedpocalypse, FALSE) // if true, all items will be able to emb
/obj/item/attack_alien(mob/user)
var/mob/living/carbon/alien/A = user
if(!A.has_fine_manipulation)
if(!ISADVANCEDTOOLUSER(A))
if(src in A.contents) // To stop Aliens having items stuck in their pockets
A.dropItemToGround(src)
to_chat(user, "<span class='warning'>Your claws aren't capable of such fine manipulation!</span>")
+1 -1
View File
@@ -375,7 +375,7 @@ GLOBAL_LIST_INIT(transit_tube_recipes, list(
return TRUE
/obj/item/pipe_dispenser/pre_attack(atom/A, mob/user)
if(!user.IsAdvancedToolUser() || istype(A, /turf/open/space/transit))
if(!ISADVANCEDTOOLUSER(user) || istype(A, /turf/open/space/transit))
return ..()
var/atom/attack_target = A
+1 -1
View File
@@ -9,7 +9,7 @@
var/dumped = FALSE
/obj/item/suspiciousphone/attack_self(mob/living/user)
if(!user.IsAdvancedToolUser())
if(!ISADVANCEDTOOLUSER(user))
to_chat(user, "<span class='warning'>This device is too advanced for you!</span>")
return
if(dumped)
+1 -1
View File
@@ -199,7 +199,7 @@ GLOBAL_LIST_EMPTY(PDAs)
/obj/item/pda/interact(mob/user)
if(!user.IsAdvancedToolUser())
if(!ISADVANCEDTOOLUSER(user))
to_chat(user, "<span class='warning'>You don't have the dexterity to do this!</span>")
return
@@ -59,7 +59,7 @@
if((HAS_TRAIT(user, TRAIT_CLUMSY) || HAS_TRAIT(user, TRAIT_DUMB)) && prob(50)) //too dumb to use flashlight properly
return ..() //just hit them in the head
if(!user.IsAdvancedToolUser())
if(!ISADVANCEDTOOLUSER(user))
to_chat(user, "<span class='warning'>You don't have the dexterity to do this!</span>")
return
@@ -75,7 +75,7 @@
if (!diode)
to_chat(user, "<span class='notice'>You point [src] at [target], but nothing happens!</span>")
return
if (!user.IsAdvancedToolUser())
if (!ISADVANCEDTOOLUSER(user))
to_chat(user, "<span class='warning'>You don't have the dexterity to do this!</span>")
return
if(HAS_TRAIT(user, TRAIT_CHUNKYFINGERS))
+1 -1
View File
@@ -48,7 +48,7 @@
return FALSE
/obj/item/dnainjector/attack(mob/target, mob/user)
if(!user.IsAdvancedToolUser())
if(!ISADVANCEDTOOLUSER(user))
to_chat(user, "<span class='warning'>You don't have the dexterity to do this!</span>")
return
if(used)
@@ -143,7 +143,7 @@
/obj/machinery/implantchair/MouseDrop_T(mob/target, mob/user)
if(user.stat || !Adjacent(user) || !user.Adjacent(target) || !isliving(target) || !user.IsAdvancedToolUser())
if(user.stat || !Adjacent(user) || !user.Adjacent(target) || !isliving(target) || !ISADVANCEDTOOLUSER(user))
return
if(isliving(user))
var/mob/living/L = user
+1 -1
View File
@@ -46,7 +46,7 @@
return ..()
/obj/item/inducer/proc/cantbeused(mob/user)
if(!user.IsAdvancedToolUser())
if(!ISADVANCEDTOOLUSER(user))
to_chat(user, "<span class='warning'>You don't have the dexterity to use [src]!</span>")
return TRUE
+1 -1
View File
@@ -137,7 +137,7 @@ GLOBAL_LIST_INIT(bibleitemstates, list("bible", "koran", "scrapbook", "burning",
/obj/item/storage/book/bible/attack(mob/living/M, mob/living/carbon/human/user, heal_mode = TRUE)
if (!user.IsAdvancedToolUser())
if (!ISADVANCEDTOOLUSER(user))
to_chat(user, "<span class='warning'>You don't have the dexterity to do this!</span>")
return
+1 -1
View File
@@ -281,7 +281,7 @@
. = ..()
if (flag)
return
if (!user.IsAdvancedToolUser())
if (!ISADVANCEDTOOLUSER(user))
to_chat(user, "<span class='warning'>You don't have the dexterity to do this!</span>")
return
src.add_fingerprint(user)
+1 -1
View File
@@ -58,7 +58,7 @@
/turf/closed/mineral/attackby(obj/item/I, mob/user, params)
if (!user.IsAdvancedToolUser())
if (!ISADVANCEDTOOLUSER(user))
to_chat(usr, "<span class='warning'>You don't have the dexterity to do this!</span>")
return
+1 -1
View File
@@ -178,7 +178,7 @@
/turf/closed/wall/attackby(obj/item/W, mob/user, params)
user.changeNext_move(CLICK_CD_MELEE)
if (!user.IsAdvancedToolUser())
if (!ISADVANCEDTOOLUSER(user))
to_chat(user, "<span class='warning'>You don't have the dexterity to do this!</span>")
return
+10
View File
@@ -47,6 +47,16 @@
. = ..()
/datum/antagonist/monkey/apply_innate_effects(mob/living/mob_override)
. = ..()
var/mob/living/M = mob_override || owner.current
ADD_TRAIT(M, TRAIT_ADVANCEDTOOLUSER, JUNGLE_FEVER_TRAIT)
/datum/antagonist/monkey/remove_innate_effects(mob/living/mob_override)
. = ..()
var/mob/living/M = mob_override || owner.current
REMOVE_TRAIT(M, TRAIT_ADVANCEDTOOLUSER, JUNGLE_FEVER_TRAIT)
/datum/antagonist/monkey/create_team(datum/team/monkey/new_team)
if(!new_team)
for(var/datum/antagonist/monkey/H in GLOB.antagonists)
@@ -350,7 +350,7 @@ GLOBAL_VAR_INIT(cryo_overlay_cover_off, mutable_appearance('icons/obj/cryogenics
. += "[src] seems empty."
/obj/machinery/atmospherics/components/unary/cryo_cell/MouseDrop_T(mob/target, mob/user)
if(user.incapacitated() || !Adjacent(user) || !user.Adjacent(target) || !iscarbon(target) || !user.IsAdvancedToolUser())
if(user.incapacitated() || !Adjacent(user) || !user.Adjacent(target) || !iscarbon(target) || !ISADVANCEDTOOLUSER(user))
return
if(isliving(target))
var/mob/living/L = target
+1 -1
View File
@@ -31,7 +31,7 @@
return (BRUTELOSS)
/obj/item/instrument/attack_self(mob/user)
if(!user.IsAdvancedToolUser())
if(!ISADVANCEDTOOLUSER(user))
to_chat(user, "<span class='warning'>You don't have the dexterity to do this!</span>")
return TRUE
interact(user)
@@ -12,7 +12,6 @@
bubble_icon = "alien"
type_of_meat = /obj/item/food/meat/slab/xeno
var/has_fine_manipulation = 0
var/move_delay_add = 0 // movement delay to add
status_flags = CANUNCONSCIOUS|CANPUSH
@@ -71,9 +70,6 @@
/mob/living/carbon/alien/reagent_check(datum/reagent/R) //can metabolize all reagents
return 0
/mob/living/carbon/alien/IsAdvancedToolUser()
return has_fine_manipulation
/mob/living/carbon/alien/get_status_tab_items()
. = ..()
. += "Intent: [a_intent]"
@@ -135,7 +131,7 @@ Des: Removes all infected images from the alien.
qdel(src)
/mob/living/carbon/alien/can_hold_items()
return has_fine_manipulation
return ISADVANCEDTOOLUSER(src) && ..()
/mob/living/carbon/alien/on_lying_down(new_lying_angle)
. = ..()
@@ -22,6 +22,7 @@
AddComponent(/datum/component/personal_crafting)
AddComponent(/datum/component/footstep, FOOTSTEP_MOB_HUMAN, 1, -6)
AddComponent(/datum/component/bloodysoles/feet)
ADD_TRAIT(src, TRAIT_ADVANCEDTOOLUSER, ROUNDSTART_TRAIT)
GLOB.human_list += src
/mob/living/carbon/human/proc/setup_human_dna()
@@ -900,9 +901,6 @@
/mob/living/carbon/human/is_literate()
return TRUE
/mob/living/carbon/human/can_hold_items()
return TRUE
/mob/living/carbon/human/update_gravity(has_gravity,override = 0)
if(dna?.species) //prevents a runtime while a human is being monkeyfied
override = dna.species.override_float
@@ -84,11 +84,6 @@
//Check inventory slots
return (wear_id?.GetID() || belt?.GetID())
/mob/living/carbon/human/IsAdvancedToolUser()
if(HAS_TRAIT(src, TRAIT_MONKEYLIKE))
return FALSE
return TRUE//Humans can use guns and such
/mob/living/carbon/human/reagent_check(datum/reagent/R)
return dna.species.handle_chemicals(R,src)
// if it returns 0, it will run the usual on_mob_life for that reagent. otherwise, it will stop after running handle_chemicals for the species.
@@ -108,12 +108,6 @@
internal = null
return
/mob/living/carbon/monkey/IsAdvancedToolUser()//Unless its monkey mode monkeys can't use advanced tools
if(mind && is_monkey(mind))
return TRUE
return FALSE
/mob/living/carbon/monkey/can_use_guns(obj/item/G)
if(G.trigger_guard == TRIGGER_GUARD_NONE)
to_chat(src, "<span class='warning'>You are unable to fire this!</span>")
+1 -1
View File
@@ -1102,7 +1102,7 @@
if(G.trigger_guard == TRIGGER_GUARD_NONE)
to_chat(src, "<span class='warning'>You are unable to fire this!</span>")
return FALSE
if(G.trigger_guard != TRIGGER_GUARD_ALLOW_ALL && !IsAdvancedToolUser())
if(G.trigger_guard != TRIGGER_GUARD_ALLOW_ALL && !ISADVANCEDTOOLUSER(src))
to_chat(src, "<span class='warning'>You try to fire [G], but can't use the trigger!</span>")
return FALSE
return TRUE
@@ -403,3 +403,6 @@
/mob/living/silicon/robot/swap_hand()
cycle_modules()
/mob/living/silicon/robot/can_hold_items()
return FALSE //held_items are used for modules.
+1 -3
View File
@@ -58,6 +58,7 @@
diag_hud_set_status()
diag_hud_set_health()
add_sensors()
ADD_TRAIT(src, TRAIT_ADVANCEDTOOLUSER, ROUNDSTART_TRAIT)
/mob/living/silicon/Destroy()
QDEL_NULL(radio)
@@ -164,9 +165,6 @@
to_chat(user, "<span class='alert'>[p_their(TRUE)] outer shell is too tough.</span>")
return FALSE
/mob/living/silicon/IsAdvancedToolUser()
return TRUE
/proc/islinked(mob/living/silicon/robot/bot, mob/living/silicon/ai/ai)
if(!istype(bot) || !istype(ai))
return FALSE
@@ -176,6 +176,7 @@
update_simplemob_varspeed()
if(dextrous)
AddComponent(/datum/component/personal_crafting)
ADD_TRAIT(src, TRAIT_ADVANCEDTOOLUSER, ROUNDSTART_TRAIT)
if(speak)
speak = string_list(speak)
@@ -610,10 +611,7 @@
return (..() || access_card)
/mob/living/simple_animal/can_hold_items()
return dextrous
/mob/living/simple_animal/IsAdvancedToolUser()
return dextrous
return dextrous && ..()
/mob/living/simple_animal/activate_hand(selhand)
if(!dextrous)
+1 -5
View File
@@ -925,10 +925,6 @@
client.last_turn = world.time + MOB_FACE_DIRECTION_DELAY
return TRUE
///This might need a rename but it should replace the can this mob use things check
/mob/proc/IsAdvancedToolUser()
return FALSE
/mob/proc/swap_hand()
var/obj/item/held_item = get_active_held_item()
if(SEND_SIGNAL(src, COMSIG_MOB_SWAP_HANDS, held_item) & COMPONENT_BLOCK_SWAP)
@@ -1192,7 +1188,7 @@
///Can this mob hold items
/mob/proc/can_hold_items()
return FALSE
return length(held_items)
/**
* Get the mob VV dropdown extras
+1 -1
View File
@@ -63,7 +63,7 @@
/obj/item/hand_labeler/attack_self(mob/user)
if(!user.IsAdvancedToolUser())
if(!ISADVANCEDTOOLUSER(user))
to_chat(user, "<span class='warning'>You don't have the dexterity to use [src]!</span>")
return
mode = !mode
+2 -2
View File
@@ -440,7 +440,7 @@ GLOBAL_LIST_INIT(wire_node_generating_types, typecacheof(list(/obj/structure/gri
/obj/item/stack/cable_coil/proc/check_menu(mob/living/user)
if(!istype(user))
return FALSE
if(!user.IsAdvancedToolUser())
if(!ISADVANCEDTOOLUSER(user))
to_chat(user, "<span class='warning'>You don't have the dexterity to do this!</span>")
return FALSE
if(user.incapacitated() || !user.Adjacent(src))
@@ -738,7 +738,7 @@ GLOBAL_LIST(hub_radial_layer_list)
/obj/structure/cable/multilayer/proc/check_menu(mob/living/user)
if(!istype(user))
return FALSE
if(!user.IsAdvancedToolUser())
if(!ISADVANCEDTOOLUSER(user))
to_chat(user, "<span class='warning'>You don't have the dexterity to do this!</span>")
return FALSE
if(user.incapacitated() || !user.Adjacent(src))