| 11-13-2003, 05:41 PM | #1 |
I have an idea to make a Hero mimic spell. I want to create a custom hero that has a particular model/stats/etc... He will have 4 spells just like every other hero, except that his ultimate will be Mimic. Now, I know I have to use triggers for this. I want Mimic to do the following... 1. Copy the unit being targeted perfectly except for player control/color/model file. 2. Have all the spells of the targeted Hero except for the Ultimate. I really don't have anywhere to begin because I can't find something in the triggers that will load the targeted units 1-3 spells into a variable. If someone could help me with this. I would really appreciate it. |
| 11-13-2003, 05:50 PM | #2 |
If you want to keep track of heroes' learned skill levels you'll need to make your own arrays for them and "set ArrayMember[custom value of learning Hero] to (ArrayMember[custom value of learning Hero] + 1)" With generic unit event "Hero learns an ability." Don't try to use "Event Response - skill level of learned ability" because it screws up - it counts every skill level as one higher than it is, except for level 1. Bizarre and nonsensical. |
| 11-13-2003, 06:00 PM | #3 |
You know what?? That is REALLY helpful, thank you... but I still have more to ask... When defining an array. (trouble understanding an array) You set variable = (anyvariable) and under /variable let's call it "learnedspells." So I check the box that says array, for the number of arrays do I count 3 spells for every hero? That's 72 arrays for 1 variable and how do I get to the specific spell(array) that I wanted to mimic? Or do I create a variable for every hero and have the array only be 3 so I can keep track of their spells? If you could post a sample trigger for me that would help me out a lot. |
| 11-13-2003, 06:26 PM | #4 |
Ah. Ok here's a quick explanation of how I mean to use arrays. You have to set it up so that all units you want to track have been given a custom value. This custom value stores each unit's Index in a given array. So, you don't want to create hundreds of arrays, each with three members (one for each ability); you create three arrays (one for each ability) each with hundreds of members. This is advantageous because: 1. Arrays can change size to accommodate more or fewer units. 2. You can't create new Global variables at run-time (as far as I know). So let's say I want to track the all units of type "MyUnitType." A sample set of triggers for array-tracking these would go like this (not word-for word code, just what it should do). Variables needed: (integer)NumberOfArrayMembers (integer array)SkillLevel1 (integer array)SkillLevel2 (integer array)SkillLevel3 Trigger 1: adds newly created units to the array. Event - a unit enters the playable map area Condition - unit-type of entering unit equal to MyUnitType Action - add 1 to numberOfArrayMembers Action - set the custom value of the entering unit to NumberOfArrayMembers Action - set SkillLevel1[numberOfArrayMembers] to 0 (assuming these units enter with skill level zero...) Action - set SkillLevel2[numberofarraymembers] to 0 Action - set skilllevel3[numberofarraymembers] to 0 Trigger 2: one of these units gains a skill level Event - generic unit event - a hero learns a skill Condition - unit-type of learning hero equal to MyUnitType Action - if learned skill equal to (whatever abilities are being tracked by slot 1) then do: ----------add 1 to SkillLevel1[custom value of learning hero] Action - if learned skill equal to (whatever abilities are being tracked by slot 2) then do: ----------add 1 to skillLevel2[custom value of learning hero] ETC. Now if you're keeping track of a whole lot of units and there might be many new ones coming into play, it's a good idea to create a third trigger that catches them when they die and removes them from the array - but since you probably want to keep the values when the heroes die because they can be resurrected, and because there can't be all that many heroes at once, it might not be necessary here. Also - be careful about the resurrecting - I'm not sure if that would count as "a unit entering the playable map area" so you might want to try a different kind of event, like a unit finishes training a unit, or something.... I dunno. But do you get the idea? |
| 11-13-2003, 07:11 PM | #5 |
Ok, so you're saying I need 4 variable arrays. 1. Variable array for players0-9 (does not matter which order) 2. Variable array for skill1 (I only need to set the skill arrays for 1?) 3. Variable array for skill2 4. Variable array for skill3 set trigger 1 saying. if then statement saying... Assign the array 0-9 to the 0-9 players entering the playable map area. (0 counts as a number) Also, saying set the skill variable arrays to 0. (assuming they start at 0. They start with one unspent skill point) with the condition that it's a specific unit-type... (that would mean 10 OR conditions for the 10 heros) then set trigger 2 saying. a generic unit event - unit learns a skill condition is specific unit-type (0-9) OR's add 1 to tracked skill? add 1 to tracked skill? add 1 to tracked skill? Depending on what one is learned? do I have to track every spell that I am using in the game then? Let me know if I'm right here, I have never worked with arrays and I need help getting my mind around what exactly they're used for and HOW to use them gramatically. |
| 11-13-2003, 07:37 PM | #6 |
Wait, no - you don't need to know how many players there are. I was assuming each player was going to have more than one hero, too... I hope that's not wrong. Ok you might already understand this, but here's the way an array works - it's actually a lot simpler than it looks. Say I have an integer array Bob. Bob is actually just a big indexed list of individual integer variables, and a way of referring to those variables. So when I say "Bob[4]" I'm referring to the variable in Bob with index 4. Now, in my example, I used "NumberOfArrayMembers" to keep track of the number of variables in each array - that's not the number of players, that's just a way of keeping track of how many values are being held in the array, so that any new units can be added. For instance, say I've been keeping track of Bob and I know that it contains exactly X variables. Well, to add a new variable, all I have to do is set Bob[X+1] to some value - Warcraft automatically creates the new variable. This is what makes arrays so powerful. The other trick I'm using is setting each unit's custom value to the index in the array of the variables that relate to it. Marking each unit this way lets you tell where in the list its information is recorded. Am I making sense? Do you know all this already? I hope I'm helping at least a little... :bgrun: |
| 11-13-2003, 07:39 PM | #7 |
what's the difference between a normal variable and a variable array? I am really lost in this whole array thing... |
| 11-13-2003, 07:41 PM | #8 |
An array is simply a lot of variables of the same type and a way of referring to them. The array has no value - its component variables contain the values. |
| 11-13-2003, 07:44 PM | #9 |
my goodness... I understand integer variables and that you can set a number to x. you can do this with many other things too. Now, an array seems to me like a sub system of variables within a variable. But what's the dif if you have to specify which variable you have to use anyway? what's the dif between saying Variable1 = 1 and Variable[1] = 1? I am not understanding how to use the arrays. I must be missing something... |
| 11-13-2003, 07:48 PM | #10 |
An array lets you add new members to it, so it can contain a theoretically infinite number of variables. If you have a LOT of variables of the same type, or you don't know how many variables you'll need, it's almost always easier to make an array. |
| 11-13-2003, 07:49 PM | #11 |
I want to keep track of every spell that a unit has. like this Player1herospells = spell1,spell2,spell3 Player2herospells = spell1,spell2,spell3 etc... then when my hero casts his ultimate on say "player1hero" I will do something like this... Get player1herospells set myherospells = player1herospells so now my hero has successfully mimiced player1hero's spells. 1-3 but will still keep his Ultimate of mimic. |
| 11-13-2003, 07:50 PM | #12 |
ok, I think I'm startin to get it, plz bear with me :/ |
| 11-13-2003, 07:55 PM | #13 |
so, I would have a lot of "learned hero skill" variables. I would have 3 for each skill and 3 for each hero. so 9 variables of the same type per hero. now how do I set this up so that the hero's are still seperated from one another but within each hero there are the 9 types of variable that have the 3 different levels of the skills that they know... Am I making any sense?? :) lol |
| 11-13-2003, 08:11 PM | #14 |
Ah ok. You're thinking of using each array to hold all the information you want about one unit, while I'm trying to use each array to hold one piece of information about every unit. The main advantage that my method has is this: how to refer to the information you've stored in the array? With your system, you have a whole lot of arrays, each with 3 values in it. Let's say they look like this: HeroOneSkills[1,2,3] HeroTwoSkills[1,2,3] HeroThreeSkills[1,2,3] HeroFourSkills[1,2,3] ...Hero"N"Skills[1,2,3] What do you do when HeroOne casts this ability on HeroTwo? You'll want to pull out the values contained in HeroTwoSkills, but how will you tell the computer that? You'll need a whole bunch of If/Then/Elses that work like this: If targeted hero is equal to HeroOne then set A = HeroOneSkills[1]; set B = HeroOneSkills[2]; set C = HeroOneSkills[3] If targeted hero is equal to HeroTwo then set A =.... If targeted hero is equal to HeroThree then set A =.... If targeted hero is equal to HeroFour then set A =.... ...If targeted hero is equal to Hero"N" then set A =.... If/Then/Else statements are generally slow and not very elegant. If instead you use each array to hold one piece of information about each unit, you have something that looks like this: FirstSkill[1,2,3,4,5...n] SecondSkill[1,2,3,4,5...n] ThirdSkill[1,2,3,4,5...n] And an integer variable to keep track of the number of units: NumberOfUnits Well, now when HeroOne casts this ability on HeroTwo, HeroTwo has the Custom Value: 2! So all I have to do to set A, B, and C to the targetted hero's skill levels is: Set A = FirstSkill[custom value of targeted unit] Set B = SecondSkill[custom value of targeted unit] Set C = ThirdSkill[custom value of targeted unit] No if statements necessary. Make sense? |
| 11-13-2003, 08:43 PM | #15 |
YES! This should be in the Tutorial Section :) lol... Well, maybe not, but I think this will help many others with understanding arrays. So, without you specifying anything, an array remembers where and when it got the information? No code or anything necessary? It creates it's own variables and remembers where it got the data? Then when you want to call upon the data, you're saying instead of using a million if/then statements just use a/b/c as custom values and have them pull the information from the array? Is that right? |
