| 01-25-2004, 03:24 PM | #1 |
I want to have a spell pool and as a periodic event I want a random spell from that pool to be given to my unit. It's a unit, not a hero. I need help plz. Can't figure it out :P Really all I need is a random way to add a 1 spell out of a set of spells to a unit every 5 minutes. |
| 01-25-2004, 03:45 PM | #2 |
Try something like this... E: Every 5 minutes C: Whatever A: Set IntegerVariable = Random number from 1 - (However many spells you may have) If/Then/Else - Multiple Actions If: IntegerVariable = 1, do action: Unit - Add ability (One of your abilities goes here) Else: Do Nothing If/Then/Else - Multiple Actions If: IntegerVariable = 2, do action: Unit - Add ability (Another ability goes here) Else: Do Nothing And so on... Hope this helps. ;) |
| 01-25-2004, 04:53 PM | #3 |
alright, but how do you make it so the unit doesn't get the same ability twice? just use an ability comparison? |
| 01-25-2004, 05:26 PM | #4 |
Try setting all your spells to an array (lets say spells[]) Than call: Give <Unit> Spells[Random Number between 1 and <number of spells> |
| 01-25-2004, 06:17 PM | #5 |
I DON'T UNDERSTAND HOW TO USE AN ARRAY, MY MENTAL IMAGE OF IT IS VERY FUZZY. Please, if someone can help me to understand arrays I would be grateful, (give ya 50 points :P) But I gotta UNDERSTAND IT! |
| 01-25-2004, 07:37 PM | #6 |
Arrays aren't difficult to understand when they are explained properly. Here is my go at explaining them properly:D. Think of variable arrays as drawers in filing cabinets. Now, each drawer can only hold specific types of things, like one drawer can hold only music, while another can hold only business documents. Now think of these in warcraft terms. Each drawer can only hold units, or points, etc... The index of the array (the thing in the []'s) is essentially telling where the data will be stored. Think of them like files inside of your drawer. So inside the business documents drawer you have things that tell where each document will be placed, say like a folder named payroll, and another named misc. All indexes in warcraft are integers, so if you stored a unit in a unit array, with the index of 5, you would be storing the unit in the folder with the number 5 on it. You can only store one thing in each file though. If you want to recall the unit then you would go to find it in the same place you stored it, which would be in your unit array [5]. I hope that this helps you understand arrays better. |
| 01-25-2004, 09:00 PM | #7 |
Think of array's as a filing cabnet. The Filing cabnet is the array. So you give the name of the filing cabnet(the array) whatever you want. For now lets call it filecabnet. When you define an array you make a decision on how big, or how much info it holds. Lets say you need to store 10 things inside your filecabnet, or the array. Then you would declare it like this: filecabnet[10] Lets say the first peice of info you want to store is characters or heroes. Pick them up and place then anywhere in the filecabnet[10] array. Wherever you put it, that will be its ID, so to speak. Lets say you put it in the first cabnet. Therefore, filecabnet[0], will hold characters. hope this helps |
| 01-25-2004, 11:54 PM | #8 |
Yeah. An array is just a bunch of different variables that are labeled the same. Using arrays can save you tons of time... for example, if you had to make 6 different variables to specify 6 different units that were all carrying a certain sword, you might normally make 6 different variables... Carrier1, Carrier2, Carrier3, Carrier4, Carrier5, and Carrier6. But, with an array, you could just make a 6-size array named Carriers. Then, whenever you want to identify the certain unit, you could say Carrier[5] or something. |
| 01-26-2004, 12:58 AM | #9 |
Yep variables r like triggers... but they r for like specific things and more advanced |
| 01-26-2004, 12:41 PM | #10 |
so an array is a variable. carrier[1] is the same as carrier (var). The difference is when you want to have like 10 carriers, it makes more sense to use an array cause you just have to type "10" instead of typing carrier, carrier2, carrier3, carrier4, etc... Also an array can only be one type of variable (unit/unit-type/integer/etc...)? Is that about it? Is that everything that an array encompasses? |
| 01-26-2004, 03:55 PM | #11 | |
Quote:
Yes, array is a basicly a varible, its more like a bunch of varibles of the SAME TYPE stuck togther. Array are very useful when u need to do something for multiple (e.g.) players. its good to use the "For (Var):=1 To (Array's Max Size) Do" loop. E.g.- For I:=1 To 10 Do Carrier[i]:=Kill unit; that was more like in pascal (programing language), but if u know pascal, u know its very very similar to WC's Triggers. |
| 01-26-2004, 04:19 PM | #12 |
well, it's hard to decide who to give the +50 points too... I believe it goes to the file cabinet guy :P Anyway, message me on how exactly to give or exchange points and I'll take care of it. Thx. Arrays really help :) I would say that the most important thing that arrays do is assign a group of information to INTEGERS. So before arrays you could not have a random way to decide if you wanted to have say, skills selected, or anything else that is not an integer (strings, etc...). By using arrays you can very neatly select the information in your array using the INTEGERS that refer to them! |
| 01-26-2004, 04:26 PM | #13 |
arrays are kinda easy when u imagine it right...all you have to do is decide how it should look like and make it that way....anyhows, practice makes perfect :) as for the spell pool idea, it sounds good, but u could add more finesse to it.... |
| 01-26-2004, 09:45 PM | #14 |
I just have a question Bulletbutter, do you ever read the entire thing before posting? You posted basically what i said. |
