Advertisement
Guest User

Untitled

a guest
Oct 20th, 2017
91
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.71 KB | None | 0 0
  1. const string[][] punctuation_rep = {{"\0"},{"."},{","},{";"},{":"},{"!"},{"?"},{"/"}};
  2.  
  3. void MakeRetardedSentence( string& outMessage )
  4. {
  5. CritterCl@ chosen = GetChosen();
  6. if( !valid( chosen ) || chosen.Stat[ ST_INTELLECT ] > int( retard_chance.length() ) )
  7. return;
  8. int IN = chosen.Stat[ ST_INTELLECT ] - 1;
  9. string message = "";
  10. uint hits = 0;
  11. int widx = -1;
  12. array< string@ >@ words = split( outMessage, " " );
  13. while( ( widx = words.find( "" ) ) >= 0 )
  14. words.removeAt( widx ); // splitEx... don't!
  15. // make sure that we don't count 'empty words'
  16.  
  17.  
  18. for( uint w = 0, wLen = words.length(); w < wLen; w++ )
  19. {
  20. if( words[ w ].length() > 0 )
  21. {
  22. if( Random( 0, 100 ) <= retard_chance[ IN ] )
  23. {
  24. for(uint wx = 0, wxlen = punctuation_rep.length(); wx < wxlen; wx++)
  25. {
  26. for( uint r = 0, rLen = retard_replace.length(); r < rLen; r++ )
  27. {
  28. array< string > replace = retard_replace[ r ];
  29. array< string > replacepunct = punctuation_rep[ wx ][0];
  30. if( replace.length() > 1 && strlwr( replace[ 0 ] ) == (strlwr( words[ w ] ) + replacepunct[wx][0]))
  31. {
  32. string replacement = replace[ Random( 1, replace.length() - 1 ) + replacepunct[wx][0] ]; //
  33. if( wLen > 1 || ( wLen == 1 && replacement.length() > 1 ) )
  34. {
  35. words[ w ] = replacement;
  36. hits++;
  37. }
  38. break;
  39. }
  40. }
  41. }
  42. }
  43. }
  44. if( w > 0 )
  45. message += " ";
  46. if( words[ w ].length() > 0 )
  47. message += words[ w ];
  48. }
  49. #ifdef __DEBUG__
  50. Message( "Retard'O'Meter: " + hits + "/" + words.length() );
  51. #endif
  52. outMessage = message;
  53. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement