• 🏆 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!
  • It's time for the first HD Modeling Contest of 2024. Join the theme discussion for Hive's HD Modeling Contest #6! Click here to post your idea!

[Solved] A Player types a specific word, to play a sound -Trigger Condensing

Status
Not open for further replies.
Level 4
Joined
Dec 31, 2014
Messages
68
Hello,
I am trying to trim down some triggers in my level.

One of them was that that when player 1,2 or 3 types something specific it plays an individual sound.

This is what I had done originally in my map but there were quite a lot of individual triggers for them.
  • Example
    • Events
      • Player - Player 1 (Red) types a chat message containing TEST as A substring
      • Player - Player 2 (Blue) types a chat message containing TEST as A substring
      • Player - Player 3 (Teal) types a chat message containing TEST as A substring
    • Conditions
    • Actions
      • Sound - Play TEST <gen>
The sheer number of these I have can't be doing my level any favors so is there a way I can condense them all into 1 trigger?

Something to the effect of;

  • Events
    • Player - A Player types a chat message
  • Conditions
  • Actions
    • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
      • If - Conditions
        • The Chat Message Contains TEST
      • Then - Actions
        • Sound - Play test <gen>
      • Else - Actions
    • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
      • If - Conditions
        • The Chat Message Contains EXAMPLE
      • Then - Actions
        • Sound - Play example<gen>
      • Else - Actions
Is this possible and if so can you give me an example trigger?
I couldn't find a way to be able to do this searching around.

Thanks.
 
Last edited by a moderator:
Level 37
Joined
Jul 22, 2015
Messages
3,485
Just use a lot of events.

  • Sound Init
    • Events
      • Player - Player 1 (Red) types a chat message containing test as A substring
      • Player - Player 2 (Blue) types a chat message containing test as A substring
      • Player - Player 3 (Teal) types a chat message containing test as A substring
      • Player - Player 1 (Red) types a chat message containing example as A substring
      • Player - Player 2 (Blue) types a chat message containing example as A substring
      • Player - Player 3 (Teal) types a chat message containing example as A substring
    • Conditions
    • Actions
      • Set stringVariable = (Entered chat string)
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • stringVariable Equal to test
        • Then - Actions
          • -------- play test sound --------
        • Else - Actions
          • -------- example --------

You can even go as far as making sure that TEST and EXAMPLE are the only words in the string.

  • Conditions
    • Or - Any (Conditions) are true
      • Conditions
        • And - All (Conditions) are true
          • Conditions
            • (Substring((Entered chat string), 1, 4)) Equal to test
            • (Substring((Entered chat string), 5, (Length of (Entered chat string)))) Equal to <Empty String>
        • And - All (Conditions) are true
          • Conditions
            • (Substring((Entered chat string), 1, 7)) Equal to example
            • (Substring((Entered chat string), 8, (Length of (Entered chat string)))) Equal to <Empty String>
 

Chaosy

Tutorial Reviewer
Level 40
Joined
Jun 9, 2011
Messages
13,183
You can use this:
  • Untitled Trigger 001
    • Events
      • Player - Player 1 (Red) types a chat message containing <Empty String> as An exact match
    • Conditions
    • Actions
      • Set msg = (Entered chat string)
      • Custom script: call PlaySond(udg_msg)
You just write the path of a sound and it will play.
Units\Footman\What1.wav for example (do not try that, I just wrote something down it's likely invalid)

I could make this work with other strings as well, though I'd need an hashtable for that. Aka, when you type "hello" the sound "Units\Rifleman\Yes2.wav" will play
 
Last edited:
Level 4
Joined
Dec 31, 2014
Messages
68
Thanks Chaosy, sry for the late reply

Originally I made the trigger as;
Player1,2,3 typed x
Player1,2,3 typed y
Player1,2,3 typed z
For all of them, I didn't realize it only needed <Empty String> as an event so thank you for that!
 
Status
Not open for further replies.
Top