|
23 | 23 | QDEL_NULL(granted_action)
|
24 | 24 | return ..()
|
25 | 25 |
|
| 26 | +///A list containing users of the Hivemind NIFSoft |
| 27 | +GLOBAL_LIST_EMPTY(hivemind_users) |
| 28 | + |
| 29 | +/obj/item/disk/nifsoft_uploader/hivemind |
| 30 | + name = "Hivemind" |
| 31 | + loaded_nifsoft = /datum/nifsoft/hivemind |
| 32 | + |
| 33 | +/datum/nifsoft/hivemind |
| 34 | + name = "Hivemind" |
| 35 | + program_desc = "Hivemind is a program developed as a more reliable simulacrum of the mysterious means of communication that some varieties of slime share. It's built on a specific configuration of the NIF capable of generating a localized subspace network; the content the user's very thoughts, serving as a high-tech means of telepathic communication between NIF users." |
| 36 | + activation_cost = 10 |
| 37 | + active_mode = TRUE |
| 38 | + active_cost = 0.2 |
| 39 | + purchase_price = 350 |
| 40 | + buying_category = NIFSOFT_CATEGORY_UTILITY |
| 41 | + ui_icon = "users" |
| 42 | + |
| 43 | + ///The network that the user is currently hosting |
| 44 | + var/datum/component/mind_linker/active_linking/nif/user_network |
| 45 | + ///What networks are the user connected to? |
| 46 | + var/list/network_list = list() |
| 47 | + ///What network is the user sending messages to? This is saved from the keyboard so the user doesn't have to change the channel every time. |
| 48 | + var/datum/component/mind_linker/active_linking/nif/active_network |
| 49 | + ///The physical keyboard item being used to send messages |
| 50 | + var/obj/item/hivemind_keyboard/linked_keyboard |
| 51 | + ///What action is being used to summon the Keyboard? |
| 52 | + var/datum/action/innate/hivemind_keyboard/keyboard_action |
| 53 | + |
| 54 | +/datum/nifsoft/hivemind/New() |
| 55 | + . = ..() |
| 56 | + |
| 57 | + user_network = linked_mob.AddComponent(/datum/component/mind_linker/active_linking/nif, \ |
| 58 | + network_name = "Hivemind Link", \ |
| 59 | + linker_action_path = /datum/action/innate/hivemind_config, \ |
| 60 | + ) |
| 61 | + |
| 62 | + keyboard_action = new(linked_mob) |
| 63 | + keyboard_action.Grant(linked_mob) |
| 64 | + |
| 65 | + active_network = user_network |
| 66 | + network_list += user_network |
| 67 | + GLOB.hivemind_users += linked_mob |
| 68 | + |
| 69 | +/datum/nifsoft/hivemind/Destroy() |
| 70 | + if(linked_mob in GLOB.hivemind_users) |
| 71 | + GLOB.hivemind_users -= linked_mob |
| 72 | + |
| 73 | + if(keyboard_action) |
| 74 | + keyboard_action.Remove() |
| 75 | + QDEL_NULL(keyboard_action) |
| 76 | + |
| 77 | + if(linked_keyboard) |
| 78 | + qdel(linked_keyboard) |
| 79 | + |
| 80 | + linked_keyboard = null |
| 81 | + |
| 82 | + for(var/datum/component/mind_linker/active_linking/nif/hivemind as anything in network_list) |
| 83 | + hivemind.linked_mobs -= linked_mob |
| 84 | + var/mob/living/hivemind_owner = hivemind.parent |
| 85 | + |
| 86 | + to_chat(hivemind_owner, span_abductor("[linked_mob] has left your Hivemind.")) |
| 87 | + to_chat(linked_mob, span_abductor("You have left [hivemind_owner]'s Hivemind.")) |
| 88 | + |
| 89 | + qdel(user_network) |
| 90 | + return ..() |
| 91 | + |
| 92 | +/datum/nifsoft/hivemind/activate() |
| 93 | + . = ..() |
| 94 | + if(!active) |
| 95 | + if(linked_keyboard) |
| 96 | + qdel(linked_keyboard) |
| 97 | + linked_keyboard = null |
| 98 | + |
| 99 | + return TRUE |
| 100 | + |
| 101 | + linked_keyboard = new |
| 102 | + linked_keyboard.connected_network = active_network |
| 103 | + linked_mob.put_in_hands(linked_keyboard) |
| 104 | + linked_keyboard.source_user = linked_mob |
| 105 | + |
| 106 | + linked_mob.visible_message(span_notice("The [linked_keyboard] materializes in [linked_mob]'s hands."), span_notice("The [linked_keyboard] appears in your hands.")) |
| 107 | + return TRUE |
| 108 | + |
| 109 | +/datum/action/innate/hivemind_config |
| 110 | + name = "Hivemind Configuration Settings" |
| 111 | + background_icon = 'monkestation/code/modules/blueshift/icons/mob/actions/action_backgrounds.dmi' |
| 112 | + background_icon_state = "android" |
| 113 | + button_icon = 'monkestation/code/modules/blueshift/icons/mob/actions/actions_nif.dmi' |
| 114 | + button_icon_state = "phone_settings" |
| 115 | + |
| 116 | +/datum/action/innate/hivemind_config/Activate() |
| 117 | + . = ..() |
| 118 | + var/datum/component/mind_linker/active_linking/nif/link = target |
| 119 | + |
| 120 | + var/choice = tgui_input_list(owner, "Chose your option", "Hivemind Configuration Menu", list("Link a user","Remove a user","Change Hivemind color","Change active Hivemind","Leave a Hivemind", "Toggle invites")) |
| 121 | + if(!choice) |
| 122 | + return |
| 123 | + |
| 124 | + switch(choice) |
| 125 | + if("Link a user") |
| 126 | + link.invite_user() |
| 127 | + |
| 128 | + if("Remove a user") |
| 129 | + link.remove_user() |
| 130 | + |
| 131 | + if("Leave a Hivemind") |
| 132 | + leave_hivemind() |
| 133 | + |
| 134 | + if("Change active Hivemind") |
| 135 | + change_hivemind() |
| 136 | + |
| 137 | + if("Change Hivemind color") |
| 138 | + link.change_chat_color() |
| 139 | + |
| 140 | + if("Toggle invites") |
| 141 | + toggle_invites() |
| 142 | + |
| 143 | +/datum/action/innate/hivemind_config/proc/change_hivemind() |
| 144 | + var/mob/living/carbon/human/user = owner |
| 145 | + var/datum/nifsoft/hivemind/hivemind = user.find_nifsoft(/datum/nifsoft/hivemind) |
| 146 | + |
| 147 | + var/datum/component/mind_linker/active_linking/nif/new_active_hivemind = tgui_input_list(user, "Choose a Hivemind to set as active.", "Switch Hivemind", hivemind.network_list) |
| 148 | + if(!new_active_hivemind) |
| 149 | + return FALSE |
| 150 | + |
| 151 | + hivemind.active_network = new_active_hivemind |
| 152 | + to_chat(user, span_abductor("You are now sending messages to [new_active_hivemind.name].")) |
| 153 | + |
| 154 | + if(hivemind.active) |
| 155 | + hivemind.activate() |
| 156 | + hivemind.activate() |
| 157 | + |
| 158 | +/datum/action/innate/hivemind_config/proc/leave_hivemind() |
| 159 | + var/mob/living/carbon/human/user = owner |
| 160 | + var/datum/nifsoft/hivemind/hivemind = user.find_nifsoft(/datum/nifsoft/hivemind) |
| 161 | + |
| 162 | + var/list/network_list = hivemind.network_list |
| 163 | + network_list -= hivemind.user_network |
| 164 | + |
| 165 | + var/datum/component/mind_linker/active_linking/nif/hivemind_to_leave = tgui_input_list(user, "Choose a Hivemind to disconnect from.", "Remove Hivemind", network_list) |
| 166 | + if(!hivemind_to_leave) |
| 167 | + return FALSE |
| 168 | + |
| 169 | + to_chat(hivemind_to_leave.parent, span_abductor("[user] has been removed from your Hivemind.")) |
| 170 | + to_chat(user, span_abductor("You have left [hivemind_to_leave.parent]'s Hivemind.")) |
| 171 | + |
| 172 | + hivemind.network_list -= hivemind_to_leave |
| 173 | + hivemind_to_leave.linked_mobs -= user |
| 174 | + |
| 175 | + |
| 176 | +/datum/action/innate/hivemind_config/proc/toggle_invites() |
| 177 | + var/mob/living/carbon/human/user = owner |
| 178 | + if(user in GLOB.hivemind_users) |
| 179 | + GLOB.hivemind_users -= user |
| 180 | + to_chat(user, span_abductor("You are now unable to receive invites.")) |
| 181 | + return |
| 182 | + |
| 183 | + GLOB.hivemind_users += user |
| 184 | + to_chat(user, span_abductor("You are now able to receive invites.")) |
| 185 | + |
| 186 | +/datum/action/innate/hivemind_keyboard |
| 187 | + name = "Hivemind Keyboard" |
| 188 | + background_icon = 'monkestation/code/modules/blueshift/icons/mob/actions/action_backgrounds.dmi' |
| 189 | + background_icon_state = "android" |
| 190 | + button_icon = 'monkestation/code/modules/blueshift/icons/mob/actions/actions_nif.dmi' |
| 191 | + button_icon_state = "phone" |
| 192 | + |
| 193 | +/datum/action/innate/hivemind_keyboard/Activate() |
| 194 | + . = ..() |
| 195 | + var/mob/living/carbon/human/user = owner |
| 196 | + var/datum/nifsoft/hivemind/hivemind_nifsoft = user.find_nifsoft(/datum/nifsoft/hivemind) |
| 197 | + |
| 198 | + if(!hivemind_nifsoft) |
| 199 | + return FALSE |
| 200 | + |
| 201 | + hivemind_nifsoft.activate() |
| 202 | + |
| 203 | +/datum/component/mind_linker |
| 204 | + ///Is does the component give an action to speak? By default, yes |
| 205 | + var/speech_action = TRUE |
| 206 | + ///Does the component check to see if the person being linked has a mindshield or anti-magic? |
| 207 | + var/linking_protection = TRUE |
| 208 | + |
| 209 | +/datum/component/mind_linker/active_linking/nif |
| 210 | + speech_action = FALSE |
| 211 | + linking_protection = FALSE |
| 212 | + |
| 213 | + ///What is the name of the hivemind? This is mostly here for the TGUI selection menus. |
| 214 | + var/name = "" |
| 215 | + |
| 216 | +/datum/component/mind_linker/active_linking/nif/New() |
| 217 | + . = ..() |
| 218 | + |
| 219 | + var/mob/living/owner = parent |
| 220 | + name = owner.name + "'s " + network_name |
| 221 | + |
| 222 | +///Lets the user add someone to their Hivemind through a choice menu that shows everyone that has the Hivemind NIFSoft. |
| 223 | +/datum/component/mind_linker/active_linking/nif/proc/invite_user() |
| 224 | + var/list/hivemind_users = GLOB.hivemind_users.Copy() |
| 225 | + var/mob/living/carbon/human/owner = parent |
| 226 | + |
| 227 | + //This way people already linked don't show up in the selection menu |
| 228 | + for(var/mob/living/user as anything in linked_mobs) |
| 229 | + if(user in hivemind_users) |
| 230 | + hivemind_users -= user |
| 231 | + |
| 232 | + hivemind_users -= owner |
| 233 | + |
| 234 | + var/mob/living/carbon/human/person_to_add = tgui_input_list(owner, "Choose a person to invite to your Hivemind.", "Invite User", hivemind_users) |
| 235 | + if(!person_to_add) |
| 236 | + return |
| 237 | + |
| 238 | + if(tgui_alert(person_to_add, "[owner] wishes to add you to their Hivemind, do you accept?", "Incoming Hivemind Invite", list("Accept", "Reject")) != "Accept") |
| 239 | + to_chat(owner, span_warning("[person_to_add] denied the request to join your Hivemind.")) |
| 240 | + return |
| 241 | + |
| 242 | + linked_mobs += person_to_add |
| 243 | + |
| 244 | + var/datum/nifsoft/hivemind/target_hivemind = person_to_add.find_nifsoft(/datum/nifsoft/hivemind) |
| 245 | + |
| 246 | + if(!target_hivemind) |
| 247 | + return FALSE |
| 248 | + |
| 249 | + target_hivemind.network_list += src |
| 250 | + to_chat(person_to_add, span_abductor("You have now been added to [owner]'s Hivemind")) |
| 251 | + to_chat(owner, span_abductor("[person_to_add] has now been added to your Hivemind")) |
| 252 | + |
| 253 | +///Removes a user from the list of connected people within a hivemind |
| 254 | +/datum/component/mind_linker/active_linking/nif/proc/remove_user() |
| 255 | + var/mob/living/carbon/human/owner = parent |
| 256 | + var/mob/living/carbon/human/person_to_remove = tgui_input_list(owner, "Choose a person to remove from your Hivemind.", "Remove User", linked_mobs) |
| 257 | + |
| 258 | + if(!person_to_remove) |
| 259 | + return |
| 260 | + |
| 261 | + var/datum/nifsoft/hivemind/target_hivemind |
| 262 | + target_hivemind = person_to_remove.find_nifsoft(/datum/nifsoft/hivemind) |
| 263 | + |
| 264 | + if(!target_hivemind) |
| 265 | + return FALSE |
| 266 | + |
| 267 | + linked_mobs -= person_to_remove |
| 268 | + target_hivemind.network_list -= src |
| 269 | + to_chat(person_to_remove, span_abductor("You have now been removed from [owner]'s Hivemind.")) |
| 270 | + to_chat(owner, span_abductor("[person_to_remove] has now been removed from your Hivemind.")) |
| 271 | + |
| 272 | +/datum/component/mind_linker/active_linking/nif/proc/change_chat_color() |
| 273 | + var/mob/living/carbon/human/owner = parent |
| 274 | + var/new_chat_color = tgui_color_picker(owner, "", "Choose Color", COLOR_ASSEMBLY_GREEN) |
| 275 | + |
| 276 | + if(!new_chat_color) |
| 277 | + return FALSE |
| 278 | + |
| 279 | + chat_color = new_chat_color |
| 280 | + |
| 281 | +/obj/item/hivemind_keyboard |
| 282 | + name = "Hivemind Interface Device" |
| 283 | + desc = "A holographic gesture controller, hooked to hand and finger signals of the user's own choice. This is paired with the Hivemind program itself, used as a means of filtering out unwanted thoughts from being added to the network, ensuring that only intentional thoughts of communication can go through." |
| 284 | + icon = 'icons/obj/devices/remote.dmi' |
| 285 | + icon_state = "generic_delivery" |
| 286 | + lefthand_file = 'icons/mob/inhands/items/devices_lefthand.dmi' |
| 287 | + righthand_file = 'icons/mob/inhands/items/devices_righthand.dmi' |
| 288 | + inhand_icon_state = "electronic" |
| 289 | + ///What Hivemind are messages being sent to? |
| 290 | + var/datum/component/mind_linker/active_linking/nif/connected_network |
| 291 | + //Who owns the controller? |
| 292 | + var/datum/weakref/source_user |
| 293 | + |
| 294 | +/obj/item/hivemind_keyboard/Destroy(force) |
| 295 | + . = ..() |
| 296 | + connected_network = null |
| 297 | + |
| 298 | +/obj/item/hivemind_keyboard/attack_self(mob/user, modifiers) |
| 299 | + . = ..() |
| 300 | + send_message(user) |
| 301 | + |
| 302 | +/obj/item/hivemind_keyboard/proc/send_message(mob/living/carbon/human/user) |
| 303 | + var/mob/living/carbon/human/kebyoard_owner = source_user |
| 304 | + var/mob/living/carbon/human/network_owner = connected_network.parent |
| 305 | + var/message = tgui_input_text(user, "Enter a message to transmit.", "[connected_network.network_name] Telepathy") |
| 306 | + if(!message || QDELETED(src) || QDELETED(user) || user.stat == DEAD) |
| 307 | + return |
| 308 | + |
| 309 | + if(QDELETED(connected_network)) |
| 310 | + to_chat(user, span_warning("The link seems to have been severed.")) |
| 311 | + return |
| 312 | + |
| 313 | + var/datum/asset/spritesheet/sheet = get_asset_datum(/datum/asset/spritesheet/chat) |
| 314 | + var/tag = sheet.icon_tag("nif-phone") |
| 315 | + var/hivemind_icon = "" |
| 316 | + |
| 317 | + if(tag) |
| 318 | + hivemind_icon = tag |
| 319 | + |
| 320 | + var/formatted_message = "<i><font color=[connected_network.chat_color]>\ [hivemind_icon][network_owner.real_name]'s [connected_network.network_name]\] <b>[kebyoard_owner]:</b> [message]</font></i>" |
| 321 | + log_directed_talk(user, network_owner, message, LOG_SAY, "mind link ([connected_network.network_name])") |
| 322 | + |
| 323 | + var/list/all_who_can_hear = assoc_to_keys(connected_network.linked_mobs) + network_owner |
| 324 | + |
| 325 | + for(var/mob/living/recipient as anything in all_who_can_hear) |
| 326 | + var/avoid_highlighting = (recipient == user) || (network_owner == user) |
| 327 | + to_chat(recipient, formatted_message, type = MESSAGE_TYPE_RADIO, avoid_highlighting = avoid_highlighting) |
| 328 | + |
| 329 | + for(var/mob/recipient as anything in GLOB.dead_mob_list) |
| 330 | + to_chat(recipient, "[FOLLOW_LINK(recipient, user)] [formatted_message]", type = MESSAGE_TYPE_RADIO) |
| 331 | + |
26 | 332 | /obj/item/disk/nifsoft_uploader/money_sense
|
27 | 333 | name = "Automatic Apprasial"
|
28 | 334 | loaded_nifsoft = /datum/nifsoft/money_sense
|
|
0 commit comments