From 2f6a1f28305fc592dc707c798e846ce464f1cfc5 Mon Sep 17 00:00:00 2001 From: Zuhayr Date: Mon, 6 Jul 2015 04:36:58 +0930 Subject: [PATCH] Added hats for drones. --- code/modules/clothing/clothing.dm | 11 +++ code/modules/mob/living/life.dm | 3 +- .../mob/living/silicon/robot/drone/drone.dm | 69 ++++++++++++++++--- .../silicon/robot/drone/drone_abilities.dm | 10 ++- .../silicon/robot/drone/drone_manufacturer.dm | 12 +--- html/changelogs/Zuhayr-dronehats.yml | 4 ++ 6 files changed, 86 insertions(+), 23 deletions(-) create mode 100644 html/changelogs/Zuhayr-dronehats.yml diff --git a/code/modules/clothing/clothing.dm b/code/modules/clothing/clothing.dm index 6f2515b55de..18a434eb23e 100644 --- a/code/modules/clothing/clothing.dm +++ b/code/modules/clothing/clothing.dm @@ -275,6 +275,17 @@ BLIND // can't see anything update_icon(user) user.update_action_buttons() +/obj/item/clothing/head/attack_ai(var/mob/user) + if(Adjacent(user) && istype(user, /mob/living/silicon/robot/drone)) + var/mob/living/silicon/robot/drone/D = user + if(!D.hat) + D.wear_hat(src) + D << "You crawl under \the [src]." + else + D << "You are already wearing \the [D.hat]." + return + return ..() + /obj/item/clothing/head/update_icon(var/mob/user) overlays.Cut() diff --git a/code/modules/mob/living/life.dm b/code/modules/mob/living/life.dm index d7f475ec5b2..c2f0075bfaa 100644 --- a/code/modules/mob/living/life.dm +++ b/code/modules/mob/living/life.dm @@ -125,7 +125,8 @@ //this handles hud updates. Calls update_vision() and handle_hud_icons() /mob/living/handle_regular_hud_updates() - if(!client) return 0 + if(!client) + return 0 ..() handle_vision() diff --git a/code/modules/mob/living/silicon/robot/drone/drone.dm b/code/modules/mob/living/silicon/robot/drone/drone.dm index 04e3728c6aa..0639d9d11a8 100644 --- a/code/modules/mob/living/silicon/robot/drone/drone.dm +++ b/code/modules/mob/living/silicon/robot/drone/drone.dm @@ -1,3 +1,5 @@ +var/list/drone_hat_cache = list() + /mob/living/silicon/robot/drone name = "drone" real_name = "drone" @@ -29,9 +31,26 @@ var/module_type = /obj/item/weapon/robot_module/drone var/can_pull_size = 2 var/can_pull_mobs + var/obj/item/hat + var/hat_x_offset = 0 + var/hat_y_offset = -13 holder_type = /obj/item/weapon/holder/drone +/mob/living/silicon/robot/drone/Destroy() + if(hat) + hat.loc = get_turf(src) + ..() + +/mob/living/silicon/robot/drone/construction + icon_state = "constructiondrone" + law_type = /datum/ai_laws/construction_drone + module_type = /obj/item/weapon/robot_module/drone/construction + can_pull_size = 5 + can_pull_mobs = 1 + hat_x_offset = 1 + hat_y_offset = -12 + /mob/living/silicon/robot/drone/New() ..() @@ -83,16 +102,51 @@ else overlays -= "eyes" + if(hat) + // Copied from human inventory. + // Let the drones wear hats. + var/t_state = hat.icon_state + if(hat.item_state_slots && hat.item_state_slots[slot_head_str]) + t_state = hat.item_state_slots[slot_head_str] + else if(hat.item_state) + t_state = hat.item_state + if(!drone_hat_cache["[t_state]-[icon_state]"]) // Not ideal as there's no guarantee all hat icon_states + var/t_icon = INV_HEAD_DEF_ICON // are unique across multiple dmis, but whatever. + if(hat.icon_override) + t_icon = hat.icon_override + else if(hat.item_icons && (slot_head_str in hat.item_icons)) + t_icon = hat.item_icons[slot_head_str] + var/image/I = image(icon = t_icon, icon_state = t_state) + I.pixel_x = hat_x_offset + I.pixel_y = hat_y_offset + drone_hat_cache[t_state] = I + overlays |= drone_hat_cache[t_state] + /mob/living/silicon/robot/drone/choose_icon() return /mob/living/silicon/robot/drone/pick_module() return -//Drones cannot be upgraded with borg modules so we need to catch some items before they get used in ..(). -/mob/living/silicon/robot/drone/attackby(obj/item/weapon/W as obj, mob/user as mob) +/mob/living/silicon/robot/drone/proc/wear_hat(var/obj/item/new_hat) + if(hat) + return + hat = new_hat + new_hat.loc = src + updateicon() - if(istype(W, /obj/item/borg/upgrade/)) +//Drones cannot be upgraded with borg modules so we need to catch some items before they get used in ..(). +/mob/living/silicon/robot/drone/attackby(var/obj/item/weapon/W, var/mob/user) + + if(user.a_intent == "help" && istype(W, /obj/item/clothing/head)) + if(hat) + user << "\The [src] is already wearing \the [hat]." + return + user.unEquip(W) + wear_hat(W) + user.visible_message("\The [user] puts \the [W] on \the [src].") + return + else if(istype(W, /obj/item/borg/upgrade/)) user << "\The [src] is not compatible with \the [W]." return @@ -135,7 +189,7 @@ return ..() - + /mob/living/silicon/robot/drone/emag_act(var/remaining_charges, var/mob/user) if(!client || stat == 2) user << "There's not much point subverting this heap of junk." @@ -279,13 +333,6 @@ /mob/living/silicon/robot/drone/remove_robot_verbs() src.verbs -= silicon_subsystems -/mob/living/silicon/robot/drone/construction - icon_state = "constructiondrone" - law_type = /datum/ai_laws/construction_drone - module_type = /obj/item/weapon/robot_module/drone/construction - can_pull_size = 5 - can_pull_mobs = 1 - /mob/living/silicon/robot/drone/construction/welcome_drone() src << "You are a construction drone, an autonomous engineering and fabrication system.." src << "You are assigned to a Sol Central construction project. The name is irrelevant. Your task is to complete construction and subsystem integration as soon as possible." diff --git a/code/modules/mob/living/silicon/robot/drone/drone_abilities.dm b/code/modules/mob/living/silicon/robot/drone/drone_abilities.dm index 0eaf1c87793..e5aa936a086 100644 --- a/code/modules/mob/living/silicon/robot/drone/drone_abilities.dm +++ b/code/modules/mob/living/silicon/robot/drone/drone_abilities.dm @@ -10,13 +10,13 @@ mail_destination = "" return - src << "\blue You configure your internal beacon, tagging yourself for delivery to '[new_tag]'." + src << "You configure your internal beacon, tagging yourself for delivery to '[new_tag]'." mail_destination = new_tag //Auto flush if we use this verb inside a disposal chute. var/obj/machinery/disposal/D = src.loc if(istype(D)) - src << "\blue \The [D] acknowledges your signal." + src << "\The [D] acknowledges your signal." D.flush_count = D.flush_every_ticks return @@ -27,5 +27,11 @@ if(H.a_intent == "help") get_scooped(H) return + else if(H.a_intent == "grab" && hat && !(H.l_hand && H.r_hand)) + hat.loc = get_turf(src) + H.put_in_hands(hat) + H.visible_message("\The [H] removes \the [src]'s [hat].") + hat = null + updateicon() else return ..() \ No newline at end of file diff --git a/code/modules/mob/living/silicon/robot/drone/drone_manufacturer.dm b/code/modules/mob/living/silicon/robot/drone/drone_manufacturer.dm index a292ead1b14..171fc299333 100644 --- a/code/modules/mob/living/silicon/robot/drone/drone_manufacturer.dm +++ b/code/modules/mob/living/silicon/robot/drone/drone_manufacturer.dm @@ -78,7 +78,8 @@ flick("h_lathe_leave",src) time_last_drone = world.time - var/mob/living/silicon/robot/drone/new_drone = new drone_type(get_turf(src)) + if(player.mob && player.mob.mind) player.mob.mind.reset() + var/mob/living/silicon/robot/drone/new_drone = PoolOrNew(drone_type, get_turf(src)) new_drone.transfer_personality(player) new_drone.master_fabricator = src @@ -90,7 +91,6 @@ set name = "Join As Drone" set desc = "If there is a powered, enabled fabricator in the game world with a prepared chassis, join as a maintenance drone." - if(ticker.current_state < GAME_STATE_PLAYING) src << "The game hasn't started yet!" return @@ -108,17 +108,11 @@ if(jobban_isbanned(src,"Cyborg")) usr << "You are banned from playing synthetics and cannot spawn as a drone." return - + if(!MayRespawn(1)) return var/deathtime = world.time - src.timeofdeath - if(istype(src,/mob/dead/observer)) - var/mob/dead/observer/G = src - if(G.has_enabled_antagHUD == 1 && config.antag_hud_restricted) - usr << "Upon using the antagHUD you forfeighted the ability to join the round." - return - var/deathtimeminutes = round(deathtime / 600) var/pluralcheck = "minute" if(deathtimeminutes == 0) diff --git a/html/changelogs/Zuhayr-dronehats.yml b/html/changelogs/Zuhayr-dronehats.yml new file mode 100644 index 00000000000..06dc80786d3 --- /dev/null +++ b/html/changelogs/Zuhayr-dronehats.yml @@ -0,0 +1,4 @@ +author: Zuhayr +delete-after: True +changes: + - rscadd: "Click a hat on a drone with help intent to equip it. Drag the drone onto yourself with grab intent to remove it."