• 🏆 Texturing Contest #33 is OPEN! Contestants must re-texture a SD unit model found in-game (Warcraft 3 Classic), recreating the unit into a peaceful NPC version. 🔗Click here to enter!
  • 🏆 Hive's 6th HD Modeling Contest: Mechanical is now open! Design and model a mechanical creature, mechanized animal, a futuristic robotic being, or anything else your imagination can tinker with! 📅 Submissions close on June 30, 2024. Don't miss this opportunity to let your creativity shine! Enter now and show us your mechanical masterpiece! 🔗 Click here to enter!

Random Word from a chat string

Status
Not open for further replies.
Level 15
Joined
Oct 29, 2012
Messages
1,474
Hi guys, I've recently been working on a system and I wondered :

Let's assume a player has entered a rude word which is among a bunch of words. I don't know any action that lets me detect the place of the word.

EDIT : The purpose of this is : the player can color his chat text using for example #red# so I want to detect that code , thus I replace it with the fitting HTTPC code (to color it as a game-text message).

How do I do that ?

Thanks, +rep
 
Last edited:

Dr Super Good

Spell Reviewer
Level 64
Joined
Jan 18, 2005
Messages
27,214
Implementing such a system will likely be difficult and a waste of time...
  • WC3 unique strings leak and degrade string operation performance. Anything to do with chat will likely produce unique strings, especially if it has to break apart messages looking for words.
  • WC3 has no way to directly change chat messages. This means you will need to overwrite the default way to display chat with display message actions which has its own problems such as original chat still being logged and what is displayed not being logged.
  • Not all profanity and swears will be entered as a single word. A good classic was to do something like "fu ck" which is very difficult to detect and requires complex algorithms.

For a feature which does not really add anything to your map (swearing may be rude and not constructive, but it does not alter game mechanics) it probably is not worth it.

Word detection requires you to fragment the input by spaces. To minimize string leakage you sample the string 1 character at a time. Once the first non white space character is encountered you can assume that is the start of the first word. You then go over it testing if the sequence matches any of your blocked sequences until a white space character is encountered signalling the end of the word. If a match was found you log this and prepare to replace it at the end of the search process. Once the next non white space character is encountered you repeat the process as you did the first time and keep doing this until end of string is reached. If any matches were logged then you go and generate a new string replacing the matched words appropriately, otherwise you forward on the old string unmodified.

To replace messages you need to first destroy the chat log and make all default messages invisible. This is done by changing player names to a long sequence of whitespace and control characters. You then display the filtered strings as game messages. To prevent string leaks you will probably need to display the player name as a separate message with different offsets to try and line up with the actual message.
 

Dr Super Good

Spell Reviewer
Level 64
Joined
Jan 18, 2005
Messages
27,214
EDIT : The purpose of this is : the player can color his chat text using for example #red# so I want to detect that code , thus I replace it with the fitting HTTPC code (to color it as a game-text message).
Once again, there is no way to modify chat messages. The principle is otherwise similar to above except with more parsing logic.
 
Level 15
Joined
Oct 29, 2012
Messages
1,474
Once again, there is no way to modify chat messages. The principle is otherwise similar to above except with more parsing logic.

I totally realize that. I am using some chat-hiding method (I am sure you do know it) , so every submitted message will be filtered and will be shown as a game-text. That's why I wondered how to add colors.

You have to manually program the string processor to search for words like red/blue/green/yellow/brown/purple/teal/black. Maybe it's easier to just have the user type it in hex since that information can be found online.

Well the complexity of hex' codes are the main reason to force me make an algorithm that replaces "normal colour words" by normal hex codes. But you're welcome to show me what is exactly that thing that's found online?!

Thanks both , tho. (you must spread some ... yknow)
 
Status
Not open for further replies.
Top