HomeUser Control Panel (unavailable in archive)ForumsTutorialsArt GalleryResourcesMaps

You want to learn how to make more advanced triggers?

12-23-2003, 04:39 PM#1
Dead-Inside
--== Guys, I POSTED THIS HERE TO GET YOUR OPINIONS AND ADDITIONS, now please, respond this time? ==--

Okay... This is a tutorial or a Tips&Trix sheet. It'll help you understand mathmatical triggers better. This is not super advanced, but it is essential to rely along side the 'good' triggerers.
First off, I'd like to make a simple explenation of variables and arrays, since we'll be using those.

^^Part 1^^ - Variables and Arrays:
Let's look at a variable as a little package. Inside the package, your information is stored. Let's say you store a number inside your package. Now you label your package 'MyNumberHere'. Whenever you refer to 'MyNumberHere' in a trigger, you refer to the number stored in it. You can also store a variety of other things in variables. (If you still have questions, ask)

Moving on to Arrays. Now, an array is several variables under the same name. Let's say we make our newly created package, 'MyNumberHere', an array. It would now be named MyNumberHere[x], where the x refers to the index of the array, meaning which variable you would like to add, change or get information from. (If you still have questions, as before, ask)

To create arrays and variables of different kinds, please look in your trigger editor for a button that looks like an X. It's yellow.

^^Part 2^^ - Simple math:
When you work with triggers, it's important to think in mathmatical terms. How you can work around things, and what would be the most logical, easiest way to solve things.

Now... Here's a simple math problem.
X/5 = Y
X times Y = 80
Now tell me, what's X and Y?
Can you solve the equation?
The answer's X=20 and Y=4. This was a simple problem, but it still was one. You need to practise these kinds of problems if you want a better logic in your every day life, or at least when it comes to triggers.

Now, here's a trick to get out % in WC3. You don't have a math symbol for % in WC3, which you can select, but you have +, -, x and /. To get %, use x and then use a smaller number then 1. This means it's less then a whole. So if, 100 x 0.45 becomes 45, which would be 45% of 100. This always works for percentage.

^^Part 3^^ - Some mathmatical Tips&Trix:
Here's a simple, logic, solver to get out %. You don't have a math symbol for % in Warcraft, which you can select, but you have +, -, x and /. To get %, use x and then use a smaller number then 1. This means it's less then a whole. So if, 100 x 0.45 becomes 45, which would be 45% of 100. This always works for percentage.

When you're working with arrays, and you want a number of the array... You might be working with several players. Now let's paint the picture that you have to enter 3 different numbers for each player. You got 12 players, which is quite a lot. There's an action called "(Player number(Number of (Triggering Player)))". The Triggering Player part can be cut out for other uses, such as picked player. This action is often used in determining which array number to check for, or change in an array. Now this works fine for the FIRST number you want in your array... But we needed 3, didn't we? So, we could start a new array and enter the same thing, but with the new array-name. Now, I have a better way. Let's use Arithmatic, and in the first box, enter the same as before... Then do a +, and then add the number 12 in the next box. It should look something like this:
(Player number(Number of (Triggering Player))) + 12
What this would do is make player 1 use number 13 in the array, player 2, 14, and so on. This system can be preserved with the usage of 24, 36 and so forth. You can also use this with fever players using the array, and simply use a lower number.

^^Part 4^^ - Other mapping Tips&Trix (Shorts):
When you're working with spells, remember to remove your special effects when they've played their role. If you don't, they still remain there, even if they're not visable. This will eventually clogg up RAM. If you have several effects, you need to bind each one to a variable. Use a special effects array and for the index, use an integer variable. Now, create the special effect, bind the last created special effect (Set Variable) and use your integer as the index number. And after that you need to set another variable... Your integer variable. YourIntegerVariable = YourIntegerVariable + 1. This makes it so that you will set a new number in the array each time you create a special effect in the spell you're creating. When you need to remove them, do the reverse system. Destroy SpecialEffectsArray[YourIntegerVariable] and then Set YourIntegerVariable - 1... This will destroy all of them until the last one is destroyed. You should use a loop for the second one.

Remember, when working with arrays especially, 0 is a number just as 1 and 5. You can set 0 to whatever you'd like. Meaning you might want to check something that has to do with the array itself, you can simply set the 0 in it for this. And then let the rest be Player Number ones.

Picked Player when running a trigger from a trigger? Yes, it's possible. If you have a trigger go off, say someone is killed. You can simply "Pick all units" and then run the wanted trigger. In the trigger you run, you can now use Picked Player. It's a great trick to remember. It also works for picking players. It's great.

When you're working with texts, there's a cool but rather well known effect you can add. No, I'm not talking about colors. You can take the player name of someone and then add any text behind (Or infront, or even both) it. Use Concatenate Strings. Press the first box, and scroll down to Player - Player name in the list... This will now display the name of Triggering Player, unless you change it to something else, like picked player. Happy game-messaging.

That's all for this time...
Edit: I FORGOT! Please, if you have anything to contribute to this, do it now. I want anything and everything you have to offer that isn't commonly known when you work with maps. I'm thinking about adding the agility bug and the UI bug, but they'll probably be worked out by blizzard soon, and are already posted. Anyway, GIVE ME YOUR ADDITIONS! Thx :ggani:
Regards
Dead-Inside

Additions made:
- 0 is also a usable number...
- Player Name
- Picking units and players
12-23-2003, 05:22 PM#2
th15
I think a good way to get some proper grounding in programming is to just go for some beginner's programming course in java. I did that and its really helped me understand what really is goes on behind all that script in the WE.
12-23-2003, 06:58 PM#3
Dead-Inside
Well, JAVA isn't really a good program to begin with ;). You should try Flash's "ActionScript" language. That's a good start...

Regards
Dead-Inside
12-24-2003, 09:34 AM#4
Dead-Inside
I need pointers and additions to the list please... Anyone got simple and semi-advanced maths to add to ease up triggering?

Also any other tricks would be helpful? weaaddar, come on, I know you got some tricks up your sleeve ;).

Regards
Dead-Inside
12-24-2003, 12:42 PM#5
th15
You should probably go a little into substrings and data type casting. Some of the more advanced maps require real variables to be accurate to a decimal and integer casting may screw that up for you.
12-24-2003, 07:04 PM#6
Dead-Inside
I didn't get the data type casting part??

Well... Substrings, what do you mean? As in a short on 'how to make a give gold system'? Intresting... I'll give that some thougth.

Come on ppl, I need your other ideas.
12-24-2003, 10:11 PM#7
Karma Patrol
Quote:
Well, JAVA isn't really a good program to begin with . You should try Flash's "ActionScript" language. That's a good start...

ActionScript is based off Java. Any basic programming tutorial that shows you how to use control structures and variables is appropriate.
12-24-2003, 11:12 PM#8
weaaddar
Theres advanced triggers and then theres jass. I can give tips on how to make your jass more palpable to view so I'll just shoot the basics.

MAKE YOUR VARIABLE NAMES MEANINGFUL. I use to not, and trust me I regret it.
INDENT YOUR CODE. Every start of a function, if statement, or loop you should indent. Every endfunction, endif, and endloop you should deindent.
USE FUNCTIONS FOR OPERATIONS YOU DO OFTEN. if you constantly have an equation you apply create a function that'll return the answer. Its more optimal that way.
WHEN USING BOOLEANS...when using booleans in if or return statement simply leave them at that. if (b) then, if you want it to run when true, if not(b) then if you want it to run when false.
CHECK OUT THE JASS MANUAL AND THE JASS VAULT. This is self explanatory.

SPEND ATLEAST 5 HOURS USING WORLDEDIT BEFORE COMING ON THE FORUM ASKING A QUESTION. seriously in 5 hours if you can't figure it out, you may not be at fault. This may genuinely be a limitation of the game.
12-25-2003, 09:41 AM#9
Dead-Inside
Good words... I might just add a JASS part then. But, hey... I didn't understand more then, let's say 45% of that. But it's all good.

*Is going to learn C++... Should know more*

Regards
Dead-Inside
12-25-2003, 04:05 PM#10
Shadow_Strike
i knew what a variable was, it was just kinda hard for me to apply it, sorta, but that description for the variable as a box with stuff in it really simplifies it for everyone
12-25-2003, 06:13 PM#11
dataangel
Quote:
Originally posted by weaaddar
MAKE YOUR VARIABLE NAMES MEANINGFUL.
INDENT YOUR CODE.


Bless your heart.
12-25-2003, 07:11 PM#12
Dead-Inside
Shadow: That's the point :). I've seen all kinds of extremly stupid exlenation, so I thougth a minute about how I'd write it myself, and now the time has come, heh. Anyway, thanks.

So... Anyone have anything else to offer me other then JASS?

Regards
Dead-Inside
12-29-2003, 04:26 PM#13
LegolasArcher
Just a random tidbit usefull for floating text and special effects.

When you must create one of the about over lets say every unit within the area around a unit (for trigger based spells) you would do something like:

Code:
Unit Group - Pick every unit in (Units within 350.00 of (Position of (Casting unit)) matching ((Owner of (Casting unit)) Not equal to (Owner of (Picked unit)))) and do (Actions)
    Loop - Actions
        Special Effect - Create a special effect attached to the overhead of (Casting unit) using Abilities\Spells\Other\TalkToMe\TalkToMe.mdl
The problem is, those effects wont be able to be removed unless set to a variable. This is where array use comes in. You have one integer count the total number of special effects, and the other effect array capture the effects. So the code is:
Code:
Unit Group - Pick every unit in (Units within 350.00 of (Position of (Casting unit)) matching ((Owner of (Casting unit)) Not equal to (Owner of (Picked unit)))) and do (Actions)
    Loop - Actions
        Special Effect - Create a special effect attached to the overhead of (Casting unit) using Abilities\Spells\Other\TalkToMe\TalkToMe.mdl
        -------- Sets Special Effect --------
        Set fx_effects[int_effectcount] = (Last created special effect)
        -------- Increases Effect Number --------
        Set int_effectcount = (int_effectcount + 1)
You may say, thats great, but what about multiplayer? Ill add that a little later.

Opps, I meant multiplayer and multiple castings at once
12-29-2003, 07:48 PM#14
Dead-Inside
Garg, you're trying to take over my threads? Well, add the other part.
12-30-2003, 10:33 AM#15
TheZaCrew
Maybe some people would like to know how to make advanced spells with triggers?

Quote:
Originally posted by Dead-Inside
*Is going to learn C++... Should know more*
[/b]


C++ is a good language but very difficult. First you learn the basics with consol programming which is quite easy but when you get into api where you start building windows it gets very confusing and difficult at least I think.