Skip to content

Commit

Permalink
add: chatbubble for telepathy users. (ss220-space#3815)
Browse files Browse the repository at this point in the history
  • Loading branch information
Daeberdir authored and Etrnlmelancholy committed Jan 3, 2024
1 parent c4e9cdd commit fbfac76
Show file tree
Hide file tree
Showing 9 changed files with 80 additions and 20 deletions.
5 changes: 5 additions & 0 deletions code/__DEFINES/hud.dm
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@
#define DIAG_TRACK_HUD "22"// Mech tracking beacon
#define DIAG_PATH_HUD "23"//Bot path indicators
#define GLAND_HUD "24"//Gland indicators for abductors
#define THOUGHT_HUD "25"//Telepathy bubbles

//by default everything in the hud_list of an atom is an image
//a value in hud_list with one of these will change that behavior
Expand Down Expand Up @@ -59,6 +60,7 @@
#define ANTAG_HUD_BLOB 22
#define TAIPAN_HUD 23
#define ANTAG_HUD_THIEF 24
#define THOUGHTS_HUD 25

// Notification action types
#define NOTIFY_JUMP "jump"
Expand All @@ -80,3 +82,6 @@
/// Used for HUD objects
#define APPEARANCE_UI (RESET_COLOR|RESET_TRANSFORM|NO_CLIENT_COLOR|PIXEL_SCALE)

//Just for comfortable thoughts_hud management.
#define THOUGHTS_HUD_PRECISE 1
#define THOUGHTS_HUD_DISPERSE -1
3 changes: 2 additions & 1 deletion code/datums/hud.dm
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,8 @@ GLOBAL_LIST_INIT(huds, list( \
ANTAG_HUD_EVENTMISC = new/datum/atom_hud/antag/hidden(),\
ANTAG_HUD_BLOB = new/datum/atom_hud/antag/hidden(),\
TAIPAN_HUD = new/datum/atom_hud/antag(),\
ANTAG_HUD_THIEF = new/datum/atom_hud/antag/hidden()\
ANTAG_HUD_THIEF = new/datum/atom_hud/antag/hidden(),\
THOUGHTS_HUD = new/datum/atom_hud/thoughts()\
))

/datum/atom_hud
Expand Down
34 changes: 34 additions & 0 deletions code/game/data_huds.dm
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,9 @@
/datum/atom_hud/data/hydroponic
hud_icons = list(PLANT_NUTRIENT_HUD, PLANT_WATER_HUD, PLANT_STATUS_HUD, PLANT_HEALTH_HUD, PLANT_TOXIN_HUD, PLANT_PEST_HUD, PLANT_WEED_HUD)

/datum/atom_hud/thoughts
hud_icons = list(THOUGHT_HUD)

/* MED/SEC/DIAG HUD HOOKS */

/*
Expand Down Expand Up @@ -468,6 +471,37 @@
return
holder.icon_state = "hudweed[RoundPlantBar(weedlevel/10)]"

/*~~~~~~~~~~~~~~~~~~
TELEPATHY HUD
~~~~~~~~~~~~~~~~~~*/

/mob/living/proc/thoughts_hud_set(thoughts, say_test = -1)
if(!src)
return
if(!(client?.prefs.toggles & PREFTOGGLE_SHOW_TYPING))
var/image/holder = hud_list[THOUGHT_HUD]
if(thoughts)
if(!typing)
holder.icon_state = "hudthoughtstyping"
typing = TRUE
else if(say_test > -1)
holder.icon_state = "hudthoughts-[say_test]"
addtimer(CALLBACK(src, PROC_REF(thoughts_hud_set), FALSE), 3 SECONDS)
if(!thoughts && typing)
holder.icon_state = ""
typing = FALSE

/datum/atom_hud/thoughts/proc/manage_hud(mob/user, perception)
if(!user)
return
user.thoughtsHUD += perception
if(user.thoughtsHUD && !(user in hudusers))
add_hud_to(user)
add_to_hud(user)
else if(!user.thoughtsHUD && (user in hudusers))
remove_hud_from(user)
remove_from_hud(user)

/*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
I'll just put this somewhere near the end...
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~*/
Expand Down
52 changes: 35 additions & 17 deletions code/game/dna/genes/vg_powers.dm
Original file line number Diff line number Diff line change
Expand Up @@ -199,15 +199,17 @@

/datum/dna/gene/basic/grant_spell/remotetalk/activate(mob/living/M, connected, flags)
..()
var/datum/atom_hud/thoughts/hud = GLOB.huds[THOUGHTS_HUD]
M.AddSpell(new /obj/effect/proc_holder/spell/mindscan(null))
hud.manage_hud(M, THOUGHTS_HUD_PRECISE)


/datum/dna/gene/basic/grant_spell/remotetalk/deactivate(mob/user)
/datum/dna/gene/basic/grant_spell/remotetalk/deactivate(mob/living/user)
..()
var/datum/atom_hud/thoughts/hud = GLOB.huds[THOUGHTS_HUD]
for(var/obj/effect/proc_holder/spell/S in user.mob_spell_list)
if(istype(S, /obj/effect/proc_holder/spell/mindscan))
user.RemoveSpell(S)

hud.manage_hud(user, THOUGHTS_HUD_DISPERSE)

/obj/effect/proc_holder/spell/remotetalk
name = "Project Mind"
Expand All @@ -223,19 +225,27 @@
return new /datum/spell_targeting/telepathic


/obj/effect/proc_holder/spell/remotetalk/cast(list/targets, mob/user = usr)
/obj/effect/proc_holder/spell/remotetalk/cast(list/targets, mob/living/carbon/human/user = usr)
if(!ishuman(user))
return
if(user.mind?.miming) // Dont let mimes telepathically talk
to_chat(user,"<span class='warning'>You can't communicate without breaking your vow of silence.</span>")
return
var/say = input("What do you wish to say") as text|null
if(!say || usr.stat)
return
say = strip_html(say)
say = pencode_to_html(say, usr, format = 0, fields = 0)

for(var/mob/living/target in targets)
var/datum/atom_hud/thoughts/hud = GLOB.huds[THOUGHTS_HUD]
hud.manage_hud(target, THOUGHTS_HUD_PRECISE)
user.hud_typing = 1
user.thoughts_hud_set(TRUE)
var/say = input("What do you wish to say") as text|null
user.hud_typing = 0
if(!say || usr.stat)
hud.manage_hud(target, THOUGHTS_HUD_DISPERSE)
user.thoughts_hud_set(FALSE)
return
user.thoughts_hud_set(TRUE, say_test(say))
addtimer(CALLBACK(hud, TYPE_PROC_REF(/datum/atom_hud/thoughts/, manage_hud), target, THOUGHTS_HUD_DISPERSE), 3 SECONDS)
say = strip_html(say)
say = pencode_to_html(say, usr, format = 0, fields = 0)
log_say("(TPATH to [key_name(target)]) [say]", user)
user.create_log(SAY_LOG, "Telepathically said '[say]' using [src]", target)
if(target.dna?.GetSEState(GLOB.remotetalkblock))
Expand All @@ -250,7 +260,7 @@
/obj/effect/proc_holder/spell/mindscan
name = "Scan Mind"
desc = "Offer people a chance to share their thoughts!"
base_cooldown = 0
base_cooldown = 45 SECONDS
clothes_req = FALSE
stat_allowed = CONSCIOUS
action_icon_state = "genetic_mindscan"
Expand All @@ -265,20 +275,23 @@
if(!ishuman(user))
return
for(var/mob/living/target in targets)
var/datum/atom_hud/thoughts/hud = GLOB.huds[THOUGHTS_HUD]
var/message = "You feel your mind expand briefly... (Click to send a message.)"
if(target.dna?.GetSEState(GLOB.remotetalkblock))
message = "You feel [user.real_name] request a response from you... (Click here to project mind.)"
user.show_message("<span class='abductor'>You offer your mind to [(target in user.get_visible_mobs()) ? target.name : "the unknown entity"].</span>")
target.show_message("<span class='abductor'><A href='?src=[UID()];target=[target.UID()];user=[user.UID()]'>[message]</a></span>")
available_targets += target
addtimer(CALLBACK(src, PROC_REF(removeAvailability), target), 100)
hud.manage_hud(target, THOUGHTS_HUD_PRECISE)
addtimer(CALLBACK(src, PROC_REF(removeAvailability), target), 45 SECONDS)


/obj/effect/proc_holder/spell/mindscan/proc/removeAvailability(mob/living/target)
if(target in available_targets)
var/datum/atom_hud/thoughts/hud = GLOB.huds[THOUGHTS_HUD]
available_targets -= target
if(!(target in available_targets))
target.show_message("<span class='abductor'>You feel the sensation fade...</span>")
hud.manage_hud(target, THOUGHTS_HUD_DISPERSE)
target.show_message("<span class='abductor'>You feel the sensation fade...</span>")


/obj/effect/proc_holder/spell/mindscan/Topic(href, href_list)
Expand All @@ -291,10 +304,14 @@
var/mob/living/target = locateUID(href_list["target"])
if(!(target in available_targets))
return
available_targets -= target
target.hud_typing = 1
target.thoughts_hud_set(TRUE)
var/say = input("What do you wish to say") as text|null
if(!say)
target.hud_typing = 0
if(!say || target.stat)
target.thoughts_hud_set(FALSE)
return
target.thoughts_hud_set(TRUE, say_test(say))
say = strip_html(say)
say = pencode_to_html(say, target, format = 0, fields = 0)
user.create_log(SAY_LOG, "Telepathically responded '[say]' using [src]", target)
Expand All @@ -309,7 +326,8 @@


/obj/effect/proc_holder/spell/mindscan/Destroy()
available_targets.Cut()
for(var/mob/living/target in available_targets)
removeAvailability(target)
return ..()


Expand Down
1 change: 1 addition & 0 deletions code/modules/mob/dead/observer/observer.dm
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,7 @@ GLOBAL_VAR_INIT(observer_default_invisibility, INVISIBILITY_OBSERVER)
real_name = name

//starts ghosts off with all HUDs.
show_me_the_hud(THOUGHTS_HUD)
toggle_all_huds_on(body)
..()

Expand Down
2 changes: 1 addition & 1 deletion code/modules/mob/living/carbon/human/human_defines.dm
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
/mob/living/carbon/human

hud_possible = list(HEALTH_HUD,STATUS_HUD,ID_HUD,WANTED_HUD,IMPMINDSHIELD_HUD,IMPCHEM_HUD,IMPTRACK_HUD,SPECIALROLE_HUD,GLAND_HUD)
hud_possible = list(HEALTH_HUD,STATUS_HUD,ID_HUD,WANTED_HUD,IMPMINDSHIELD_HUD,IMPCHEM_HUD,IMPTRACK_HUD,SPECIALROLE_HUD,GLAND_HUD,THOUGHT_HUD)
pressure_resistance = 25
//Marking colour and style
var/list/m_colours = DEFAULT_MARKING_COLOURS //All colours set to #000000.
Expand Down
2 changes: 1 addition & 1 deletion code/modules/mob/living/living_defines.dm
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@
var/last_hallucinator_log // Used to log, what was last infliction to hallucination

var/blood_volume = 0 //how much blood the mob has
hud_possible = list(HEALTH_HUD,STATUS_HUD,SPECIALROLE_HUD)
hud_possible = list(HEALTH_HUD,STATUS_HUD,SPECIALROLE_HUD,THOUGHT_HUD)

var/list/status_effects //a list of all status effects the mob has

Expand Down
1 change: 1 addition & 0 deletions code/modules/mob/mob_defines.dm
Original file line number Diff line number Diff line change
Expand Up @@ -123,6 +123,7 @@
/// Whether antagHUD has been enabled previously.
var/has_enabled_antagHUD = FALSE
var/antagHUD = FALSE // Whether AntagHUD is active right now
var/thoughtsHUD = 0 //Just a handler for permanent/temporary THOUGHTS_HUD changing.
var/can_change_intents = 1 //all mobs can change intents by default.
///Override for sound_environments. If this is set the user will always hear a specific type of reverb (Instead of the area defined reverb)
var/sound_environment_override = SOUND_ENVIRONMENT_NONE
Expand Down
Binary file modified icons/mob/hud.dmi
Binary file not shown.

0 comments on commit fbfac76

Please sign in to comment.