Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- const string[][] punctuation_rep = {{"\0"},{"."},{","},{";"},{":"},{"!"},{"?"},{"/"}};
- void MakeRetardedSentence( string& outMessage )
- {
- CritterCl@ chosen = GetChosen();
- if( !valid( chosen ) || chosen.Stat[ ST_INTELLECT ] > int( retard_chance.length() ) )
- return;
- int IN = chosen.Stat[ ST_INTELLECT ] - 1;
- string message = "";
- uint hits = 0;
- int widx = -1;
- array< string@ >@ words = split( outMessage, " " );
- while( ( widx = words.find( "" ) ) >= 0 )
- words.removeAt( widx ); // splitEx... don't!
- // make sure that we don't count 'empty words'
- for( uint w = 0, wLen = words.length(); w < wLen; w++ )
- {
- if( words[ w ].length() > 0 )
- {
- if( Random( 0, 100 ) <= retard_chance[ IN ] )
- {
- for(uint wx = 0, wxlen = punctuation_rep.length(); wx < wxlen; wx++)
- {
- for( uint r = 0, rLen = retard_replace.length(); r < rLen; r++ )
- {
- array< string > replace = retard_replace[ r ];
- array< string > replacepunct = punctuation_rep[ wx ][0];
- if( replace.length() > 1 && strlwr( replace[ 0 ] ) == (strlwr( words[ w ] ) + replacepunct[wx][0]))
- {
- string replacement = replace[ Random( 1, replace.length() - 1 ) + replacepunct[wx][0] ]; //
- if( wLen > 1 || ( wLen == 1 && replacement.length() > 1 ) )
- {
- words[ w ] = replacement;
- hits++;
- }
- break;
- }
- }
- }
- }
- }
- if( w > 0 )
- message += " ";
- if( words[ w ].length() > 0 )
- message += words[ w ];
- }
- #ifdef __DEBUG__
- Message( "Retard'O'Meter: " + hits + "/" + words.length() );
- #endif
- outMessage = message;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement