Scan mind and Project mind now use vision to determine the naming in the target list (#12963)

* Scan mind and Project mind now use vision to determine the naming

* Copy pasta mistake fix

* logic fix with name dupe prevention

* Refactor ala review
This commit is contained in:
farie82
2020-09-17 18:31:08 -04:00
committed by GitHub
parent e135c2326b
commit 67e6cf5079
2 changed files with 50 additions and 23 deletions
+15 -23
View File
@@ -214,25 +214,21 @@
/obj/effect/proc_holder/spell/targeted/remotetalk/choose_targets(mob/user = usr)
var/list/targets = new /list()
var/list/validtargets = new /list()
var/turf/T = get_turf(user)
for(var/mob/living/M in range(14, T))
if(M && M.mind)
if(M == user)
continue
validtargets += M
var/list/validtargets = user.get_telepathic_targets()
if(!validtargets.len)
if(!length(validtargets))
to_chat(user, "<span class='warning'>There are no valid targets!</span>")
start_recharge()
return
targets += input("Choose the target to talk to.", "Targeting") as null|mob in validtargets
var/target_name = input("Choose the target to talk to.", "Targeting") as null|anything in validtargets
if(!targets.len || !targets[1]) //doesn't waste the spell
var/mob/living/target
if(!target_name || !(target = validtargets[target_name]))
revert_cast(user)
return
targets += target
perform(targets, user = user)
/obj/effect/proc_holder/spell/targeted/remotetalk/cast(list/targets, mob/user = usr)
@@ -249,7 +245,7 @@
target.show_message("<span class='abductor'>You hear [user.real_name]'s voice: [say]</span>")
else
target.show_message("<span class='abductor'>You hear a voice that seems to echo around the room: [say]</span>")
user.show_message("<span class='abductor'>You project your mind into [target.name]: [say]</span>")
user.show_message("<span class='abductor'>You project your mind into [(target in user.get_visible_mobs()) ? target.name : "the unknown entity"]: [say]</span>")
for(var/mob/dead/observer/G in GLOB.player_list)
G.show_message("<i>Telepathic message from <b>[user]</b> ([ghost_follow_link(user, ghost=G)]) to <b>[target]</b> ([ghost_follow_link(target, ghost=G)]): [say]</i>")
@@ -266,26 +262,22 @@
var/list/available_targets = list()
/obj/effect/proc_holder/spell/targeted/mindscan/choose_targets(mob/user = usr)
var/list/targets = new /list()
var/list/validtargets = new /list()
var/turf/T = get_turf(user)
for(var/mob/living/M in range(14, T))
if(M && M.mind)
if(M == user)
continue
validtargets += M
var/list/targets = list()
var/list/validtargets = user.get_telepathic_targets()
if(!validtargets.len)
if(!length(validtargets))
to_chat(user, "<span class='warning'>There are no valid targets!</span>")
start_recharge()
return
targets += input("Choose the target to listen to.", "Targeting") as null|mob in validtargets
var/target_name = input("Choose the target to listen to.", "Targeting") as null|anything in validtargets
if(!targets.len || !targets[1]) //doesn't waste the spell
var/mob/living/target
if(!target_name || !(target = validtargets[target_name]))
revert_cast(user)
return
targets += target
perform(targets, user = user)
/obj/effect/proc_holder/spell/targeted/mindscan/cast(list/targets, mob/user = usr)
@@ -295,7 +287,7 @@
var/message = "You feel your mind expand briefly... (Click to send a message.)"
if(REMOTE_TALK in target.mutations)
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.name].</span>")
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/removeAvailability, target), 100)
+35
View File
@@ -478,6 +478,41 @@ GLOBAL_LIST_INIT(slot_equipment_priority, list( \
return 0 //Unsupported slot
//END HUMAN
/mob/proc/get_visible_mobs()
var/list/seen_mobs = list()
for(var/mob/M in view(src))
seen_mobs += M
return seen_mobs
/**
* Returns an assoc list which contains the mobs in range and their "visible" name.
* Mobs out of view but in range will be listed as unknown. Else they will have their visible name
*/
/mob/proc/get_telepathic_targets()
var/list/validtargets = new /list()
var/turf/T = get_turf(src)
var/list/mobs_in_view = get_visible_mobs()
for(var/mob/living/M in range(14, T))
if(M && M.mind)
if(M == src)
continue
var/mob_name
if(M in mobs_in_view)
mob_name = M.name
else
mob_name = "Unknown entity"
var/i = 0
var/result_name
do
result_name = mob_name
if(i++)
result_name += " ([i])" // Avoid dupes
while(validtargets[result_name])
validtargets[result_name] = M
return validtargets
// If you're looking for `reset_perspective`, that's a synonym for this proc.
/mob/proc/reset_perspective(atom/A)
if(client)