ID:154424
 
can someone tell what to add to this?

mob/verb/shout(msg as text)
set category = "Commands"
if(usr.drunk == 0)
world << "[usr]: [msg]"
else
/*what do i put here to scramble the letters?*/

if there is a way please tell.

Well, you want it so that the drunken speech is somewhat legible, right? That is you should be able to understand what the drunken fool is saying.

At the same time, you dont want for the same words to be slurred each time. You need a substitution list.

Pick a bunch of words (50?) and misspell them the way that a drunk would pronounce them, and add them to a list. Make a list with the correct spellings as well. Put the words in the same order in both lists. These words should be central to the plot of your game.

Next take the text that is spoken and compare it to the correct spelling list. Get the index number of a word in its list, and use it to find the incorrect spelling. substitute the slurred word for the correct one and output it to the listener. The drunk var could be used to determine the number of word substitutions.

SonVegitto wrote:
can someone tell what to add to this?

mob/verb/shout(msg as text)
set category = "Commands"
if(usr.drunk == 0)
world << "[usr]: [msg]"
else
/*what do i put here to scramble the letters?*/

if there is a way please tell.

Well, I haven't worked too much with strings in BYOND yet, but if you can access the characters directly as in a list, then it should be possible to do this:
  for(var/i=1,i<=length(msg),++i)
var/j=rand(1,length(msg))
var/ch=msg[i]
msg[i]=msg[j]
msg[j]=ch

Failing that, this should work:
  for(var/i=1,i<=length(msg),++i)
var/j=rand(i,length(msg))
msg=copytext(msg,1,i)+copytext(msg,j,j+1)+copytext(msg,i,j)+copytext(msg,j+1)

Now of course, that will scramble indiscriminately, switching around capital letters and lowercase, spaces and punctuation, etc. The result will be quite chaotic.

Lummox JR
In response to Lummox JR
thank you
In response to SonVegitto
Now you can make drunk people.
In response to Lummox JR
Well, I haven't worked too much with strings in BYOND yet, but if you can access the characters directly as in a list, then it should be possible to do this:

I don't think that's been implemented yet. Fortunately, you can still use copytext() to find any given letter, and you can use my replace_text() proc that I've included in s_admin as a good inspiration about how to replace a particular section of a string.
In response to Lord of Water
Whats the point of making a pub, if there arent nifty end results? :-D