Warcraft III resources & community, 2003–2006 · archived

Help The Noob (me) With Triggers !!1

12 posts
#1

Help The Noob (me) With Triggers !!1

well what i try to do is a simple trigger that works like this: when any of the players say "hi" it will play sound [insert sound here].
now i know how to work with the sound meneger... my problem is doing the trigger itself, i mean when at the event part in the option of "player types text" there are 50 options like sub-string and contrtive (something like that)...
i need someone to guide me.
thanks alot for your help :)
(sorry if my english is bad)
#2
For the Event you should use:
Player - Player X write a chat message containing <hi> as an exact match.

Copy and paste this one time for every player, X being the player (for example Player 1)
#3
You wanna have it that if any player tipes "hi" it plays that sound? This trigger here works for every player.


Events
Player - Player 1 (Red) types a chat message containing hi as An exact match
Player - Player 2 (Blue) types a chat message containing hi as An exact match
Player - Player 3 (Teal) types a chat message containing hi as An exact match
Player - Player 4 (Purple) types a chat message containing hi as An exact match
Player - Player 5 (Yellow) types a chat message containing hi as An exact match
Player - Player 6 (Orange) types a chat message containing hi as An exact match
Player - Player 7 (Green) types a chat message containing hi as An exact match
Player - Player 8 (Pink) types a chat message containing hi as An exact match
Player - Player 9 (Gray) types a chat message containing hi as An exact match
Player - Player 10 (Light Blue) types a chat message containing hi as An exact match
Player - Player 11 (Dark Green) types a chat message containing hi as An exact match
Player - Player 12 (Brown) types a chat message containing hi as An exact match
Conditions
Actions
Sound - Play [Your Sound]


Edit: Damn, again to slow :cry:
#4
thx alot guys... and how do i make it play a random sound from a set of audios i made.... and how do i make a set of audios ?
#5
Hm, I would do it this way:

Create a integer variable (here I named it SoundChooser)

for example I have three sounds
Sound#1
Sound#2
Sound#3

then create this trigger

Actions
Set SoundChooser = (Random integer number between 1 and 10)

perhaps here you need to add a small wait action

If (All Conditions are True) then do (Then Actions) else do (Else Actions)
If - Conditions
SoundChooser Equal to 1
Then - Actions
Sound - Play Sound#1
Else - Actions
[list]If (All Conditions are True) then do (Then Actions) else do (Else Actions)
If - Conditions
SoundChooser Equal to 2
Then - Actions
Sound - Play Sound#2
Else - Actions
[list]If (All Conditions are True) then do (Then Actions) else do (Else Actions)
If - Conditions
SoundChooser Equal to 3
Then - Actions
Sound - Play Sound#3
Else - Actions
    ...and so on
[/list:u][/list:u]


BTW if anyone knows a better method plz respond
#6
I do, in fact, know a slightly better method. The only problem with what you've got there is all those nested if's.

So, the easy way to get around that is this.

Make a sound array variable. Like, "soundArHi[]"

In your Map Init trigger, set each index of this variable to one of your set of sounds.

Set soundArHi[1] = Pants
Set soundArHi[2] = Sqwuak
Set soundArHi[3] = Flaming wagon
etc.

In your trigger that fires with the "hi" message, or whatever, instead of doing nested If's, do

Play Sound - soundArHi[random integer between 1 and 3]

This means there's no If's and only one primary action, instead of an action for each possibility.
#7
Hmm... The only problem with Panto's method is that you have to create many variables... In DarkShadow's, you can just use a variable called Random for every random choose, because it changes every time anyway...
#8
Actually, it's one variable array, which is defined one time, at the beginning of the map, when you define each the possible random sounds. There's not even a variable needing to be set inside the trigger that plays the sound.

Arranging actions so that as few run as possible is one of the key parts of cutting down processor intensity and reducing map lag.
#9
I meant if you use many different random actions in one map, then it can be quite annoying to create all those variables, but if you only have 1 or 2 different actions of this kind in your map, then you should do it Panto's way.
#10
In my opinion, both ideas work fine. btw Panto's way is still one variable, but multiple arrays.
#11
No, you need one variable for every type of random-chooser. You can't use a sound variable to a random unit-type, you have to create many different ones, that can make the other way more handy, because that'a only one integer variable. You're also more free with an IF/then/else chooser, like:

Set Random = Random Integer Value between 1 and 3.

If Random Equal to 1 then do Unit - Create 1 footman at random point in playable map area.

If Random Equal to 2 then do Unit - Create 2 zergling at centre of Region 001.

If Random Equal to 3 then do Unit - Create Random integer number between 2 and 3 footman at Position of Random unit in playable Map area offset by 200 facing Random integer value between 240 and 260 degrees.

Now, this would require a variable for every bolded value, and it would also need an Integer Random chooser for the array anyway...
#12
I stand by the principle of keeping as few actions in the trigger that runs more than once.

As far as creating variables, that's not particularly... hard. They don't take up much memory...