mirror of
https://github.com/CHOMPStation2/CHOMPStation2.git
synced 2026-01-03 05:52:43 +00:00
- Added a parser to adminhelps. When someone sends an adminhelp it looks through the words for mob names, keys and ckeys. These are then displayed in bold and black with a (?) next to them. Clicking the questionmark will display additional information about the mob.
Screenshot: http://www.kamletos.si/Adminhelp%20parser%206.PNG git-svn-id: http://tgstation13.googlecode.com/svn/trunk@3778 316c924e-a436-60f5-8080-3fe189b3f50e
This commit is contained in:
@@ -1230,6 +1230,37 @@ var/global/BSACooldown = 0
|
|||||||
sleep(2)
|
sleep(2)
|
||||||
cl.jumptomob(M)
|
cl.jumptomob(M)
|
||||||
|
|
||||||
|
if (href_list["adminmoreinfo"])
|
||||||
|
var/mob/M = locate(href_list["adminmoreinfo"])
|
||||||
|
if(src && src.owner)
|
||||||
|
var/location_description = ""
|
||||||
|
var/special_role_description = ""
|
||||||
|
var/health_description = ""
|
||||||
|
var/turf/T = get_turf(M)
|
||||||
|
|
||||||
|
//Location
|
||||||
|
if(T && isturf(T))
|
||||||
|
if(T.loc && isarea(T.loc))
|
||||||
|
location_description = "([T.x], [T.y], [T.z] in area <b>[T.loc]</b>)"
|
||||||
|
else
|
||||||
|
location_description = "([T.x], [T.y], [T.z])"
|
||||||
|
|
||||||
|
//Job + antagonist
|
||||||
|
if(M.mind)
|
||||||
|
special_role_description = "Role: <b>[M.mind.assigned_role]</b>; Antagonist: <font color='red'><b>[M.mind.special_role]</b></font>; Has been rev: [(M.mind.has_been_rev)?"Yes":"No"]"
|
||||||
|
else
|
||||||
|
special_role_description = "Role: <i>Mind datum missing</i> Antagonist: <i>Mind datum missing</i>; Has been rev: <i>Mind datum missing</i>;"
|
||||||
|
|
||||||
|
//Health
|
||||||
|
health_description = "Oxy: [M.oxyloss] - Tox: [M.toxloss] - Fire: [M.fireloss] - Brute: [M.bruteloss] - Clone: [M.cloneloss] - Brain: [M.brainloss]"
|
||||||
|
|
||||||
|
src.owner << "<b>Info about [M.name]:</b> "
|
||||||
|
src.owner << "Mob type = [M.type]; Damage = [health_description]"
|
||||||
|
src.owner << "Name = <b>[M.name]</b>; Real_name = [M.real_name]; Original_name = [M.original_name]; Key = <b>[M.key]</b>;"
|
||||||
|
src.owner << "Location = [location_description];"
|
||||||
|
src.owner << "[special_role_description]"
|
||||||
|
src.owner << "(<a href='?src=\ref[usr];priv_msg=\ref[M]'>PM</a>) (<A HREF='?src=\ref[src];adminplayeropts=\ref[M]'>PP</A>) (<A HREF='?src=\ref[src];adminplayervars=\ref[M]'>VV</A>) (<A HREF='?src=\ref[src];adminplayersubtlemessage=\ref[M]'>SM</A>) (<A HREF='?src=\ref[src];adminplayerobservejump=\ref[M]'>JMP</A>) (<A HREF='?src=\ref[src];secretsadmin=check_antagonist'>CA</A>)"
|
||||||
|
|
||||||
if (href_list["adminspawncookie"])
|
if (href_list["adminspawncookie"])
|
||||||
var/mob/M = locate(href_list["adminspawncookie"])
|
var/mob/M = locate(href_list["adminspawncookie"])
|
||||||
if(M && ishuman(M))
|
if(M && ishuman(M))
|
||||||
|
|||||||
@@ -1,3 +1,8 @@
|
|||||||
|
|
||||||
|
|
||||||
|
//This is a list of words which are ignored by the parser when comparing message contents for names. MUST BE IN LOWER CASE!
|
||||||
|
var/list/adminhelp_ignored_words = list("unknown","the","a","an", "monkey", "alien")
|
||||||
|
|
||||||
/client/verb/adminhelp(msg as text)
|
/client/verb/adminhelp(msg as text)
|
||||||
set category = "Admin"
|
set category = "Admin"
|
||||||
set name = "Adminhelp"
|
set name = "Adminhelp"
|
||||||
@@ -10,23 +15,88 @@
|
|||||||
msg = sanitize(copytext(msg,1,MAX_MESSAGE_LEN))
|
msg = sanitize(copytext(msg,1,MAX_MESSAGE_LEN))
|
||||||
if (!msg) return
|
if (!msg) return
|
||||||
|
|
||||||
|
var/original_msg = msg
|
||||||
|
|
||||||
|
//The symbol <20> (fancy multiplication sign) will be used to mark where to put replacements, so the original message must not contain it.
|
||||||
|
msg = dd_replaceText(msg, "<22>", "")
|
||||||
|
msg = dd_replaceText(msg, "HOLDERREF", "HOLDER-REF") //HOLDERREF is a key word which gets replaced with the admin's holder ref later on, so it mustn't be in the original message
|
||||||
|
msg = dd_replaceText(msg, "ADMINREF", "ADMIN-REF") //ADMINREF is a key word which gets replaced with the admin's client's ref. So it mustn't be in the original message.
|
||||||
|
|
||||||
|
var/list/msglist = dd_text2list(msg, " ")
|
||||||
|
|
||||||
|
var/list/mob/mobs = list()
|
||||||
|
|
||||||
|
for(var/mob/M in world)
|
||||||
|
mobs += M
|
||||||
|
|
||||||
|
var/list/replacement_value = list() //When a word match is found, the word matched will get replaced with an <20> (fancy multiplication symbol).
|
||||||
|
//This list will contain a list of values which the <20> will be replaced with in the same order as indexes in this list.
|
||||||
|
//So if this list has the value list("John","Jane") and msg is, at the end, "This is <20> and he griffed <20>" the text to
|
||||||
|
//display will be "This is John and he griffe Jane". The strings in this list are a bit more complex than 'John' and 'Jane' tho.
|
||||||
|
|
||||||
|
//we will try to locate each word of the message in our lists of names and clients
|
||||||
|
//for each mob that we have found
|
||||||
|
//split the mob's info into a list. "John Arnolds" becomes list("John","Arnolds") so we can iterate through this
|
||||||
|
//for each of the name parts IE. "John", "Arnolds", etc. in the current name.
|
||||||
|
for(var/i = 1; i <= msglist.len; i++)
|
||||||
|
var/word = msglist[i]
|
||||||
|
var/original_word = word
|
||||||
|
word = dd_replaceText(word, ".", "")
|
||||||
|
word = dd_replaceText(word, ",", "")
|
||||||
|
word = dd_replaceText(word, "!", "")
|
||||||
|
word = dd_replaceText(word, "?", "") //Strips some common punctuation characters so the actual word can be better compared.
|
||||||
|
word = dd_replaceText(word, ";", "")
|
||||||
|
word = dd_replaceText(word, ":", "")
|
||||||
|
word = dd_replaceText(word, "(", "")
|
||||||
|
word = dd_replaceText(word, ")", "")
|
||||||
|
if(lowertext(word) in adminhelp_ignored_words)
|
||||||
|
continue
|
||||||
|
for(var/mob/M in mobs)
|
||||||
|
var/list/namelist = dd_text2list("[M.name] [M.real_name] [M.original_name] [M.ckey] [M.key]", " ")
|
||||||
|
var/word_is_match = 0 //Used to break from this mob for loop if a match is found
|
||||||
|
for(var/namepart in namelist)
|
||||||
|
if( lowertext(word) == lowertext(namepart) )
|
||||||
|
msglist[i] = "<22>"
|
||||||
|
var/description_string = "<b><font color='black'>[original_word] (<A HREF='?src=HOLDERREF;adminmoreinfo=\ref[M]'>?</A>)</font></b>"
|
||||||
|
replacement_value += description_string
|
||||||
|
mobs -= M //If a mob is found then remove it from the list of mobs, so we don't get the same mob reported a million times.
|
||||||
|
word_is_match = 1
|
||||||
|
break
|
||||||
|
if(word_is_match)
|
||||||
|
break //Breaks execution of the mob loop, since a match was already found.
|
||||||
|
|
||||||
|
var/j = 1 //index to the next element in the replacement_value list
|
||||||
|
for(var/i = 1; i <= msglist.len; i++)
|
||||||
|
var/word = msglist[i]
|
||||||
|
if(word == "<22>")
|
||||||
|
msglist[i] = replacement_value[j]
|
||||||
|
j++
|
||||||
|
|
||||||
|
msg = dd_list2text(msglist, " ")
|
||||||
|
|
||||||
if(mob)
|
if(mob)
|
||||||
var/ref_mob = "\ref[src.mob]"
|
var/ref_mob = "\ref[src.mob]"
|
||||||
for (var/client/X)
|
for (var/client/X)
|
||||||
if (X.holder)
|
if (X.holder)
|
||||||
if(X.sound_adminhelp)
|
if(X.sound_adminhelp)
|
||||||
X << 'adminhelp.ogg'
|
X << 'adminhelp.ogg'
|
||||||
X << "\blue <b><font color=red>HELP: </font>[key_name(src, X)] (<A HREF='?src=\ref[X.holder];adminplayeropts=[ref_mob]'>PP</A>) (<A HREF='?src=\ref[X.holder];adminplayervars=[ref_mob]'>VV</A>) (<A HREF='?src=\ref[X.holder];adminplayersubtlemessage=[ref_mob]'>SM</A>) (<A HREF='?src=\ref[X.holder];adminplayerobservejump=[ref_mob]'>JMP</A>) (<A HREF='?src=\ref[X.holder];secretsadmin=check_antagonist'>CA</A>):</b> [msg]"
|
var/msg_to_send = "\blue <b><font color=red>HELP: </font>[key_name(src, X)] (<A HREF='?src=\ref[X.holder];adminplayeropts=[ref_mob]'>PP</A>) (<A HREF='?src=\ref[X.holder];adminplayervars=[ref_mob]'>VV</A>) (<A HREF='?src=\ref[X.holder];adminplayersubtlemessage=[ref_mob]'>SM</A>) (<A HREF='?src=\ref[X.holder];adminplayerobservejump=[ref_mob]'>JMP</A>) (<A HREF='?src=\ref[X.holder];secretsadmin=check_antagonist'>CA</A>):</b> [msg]"
|
||||||
|
msg_to_send = dd_replaceText(msg_to_send, "HOLDERREF", "\ref[holder]")
|
||||||
|
msg_to_send = dd_replaceText(msg_to_send, "ADMINREF", "\ref[X]")
|
||||||
|
X << msg_to_send
|
||||||
else
|
else
|
||||||
var/ref_client = "\ref[src]"
|
var/ref_client = "\ref[src]"
|
||||||
for (var/client/X)
|
for (var/client/X)
|
||||||
if (X.holder)
|
if (X.holder)
|
||||||
if(X.sound_adminhelp)
|
if(X.sound_adminhelp)
|
||||||
X << 'adminhelp.ogg'
|
X << 'adminhelp.ogg'
|
||||||
X << "\blue <b><font color=red>HELP: </font>[key_name(src, X)] (<A HREF='?src=\ref[X.holder];adminplayervars=[ref_client]'>VV</A>) (<A HREF='?src=\ref[X.holder];secretsadmin=check_antagonist'>CA</A>):</b> [msg]"
|
var/msg_to_send = "\blue <b><font color=red>HELP: </font>[key_name(src, X)] (<A HREF='?src=\ref[X.holder];adminplayervars=[ref_client]'>VV</A>) (<A HREF='?src=\ref[X.holder];secretsadmin=check_antagonist'>CA</A>):</b> [msg]"
|
||||||
|
msg_to_send = dd_replaceText(msg_to_send, "HOLDERREF", "\ref[holder]")
|
||||||
|
msg_to_send = dd_replaceText(msg_to_send, "ADMINREF", "\ref[X]")
|
||||||
|
X << msg_to_send
|
||||||
|
|
||||||
src << "<font color='blue'>PM to-<b>Admins</b>: [msg]</font>"
|
src << "<font color='blue'>PM to-<b>Admins</b>: [original_msg]</font>"
|
||||||
log_admin("HELP: [key_name(src)]: [msg]")
|
log_admin("HELP: [key_name(src)]: [original_msg]")
|
||||||
if(tension_master)
|
if(tension_master)
|
||||||
tension_master.new_adminhelp()
|
tension_master.new_adminhelp()
|
||||||
send2irc(ckey, msg)
|
send2irc(ckey, msg)
|
||||||
|
|||||||
Reference in New Issue
Block a user