| 01-12-2003, 04:28 AM | #1 |
Guest | Ok, without giving to much info away, i need some help with my latest project. Ok, i have three balls (wisps). Each player controls a one unit. Players can grab and drop the balls. Each player can only hold one ball at a time. I need some way of keeping track of who has balls, its really easy with just one ball, but i cant seem to figure it out with 3 balls. The way i needed it to work is: I have an array that will hold 3 units, the ones holding a ball. When a unit attacks a ball, the ball is removed, and the unit is added to the first empty slot in the array. When the ball is dropped (by ordering a ball carrier to attack the ground), the unit is removed from the array, and a ball is created. The part i have the most trouble with "When a unit attacks a ball, the ball is removed, and the unit is added to the first empty slot in the array" I can figure out how to check which slots are empty and only add it to the first empty slot it finds. Any help is much appreciated |
| 01-12-2003, 05:13 AM | #2 |
Guest | Wait, can you explain how exactly the game works? When what unit attacks what unit, what will happen? Tell me the workings and exactly what you want, and ill try to help. |
| 01-12-2003, 01:51 PM | #3 |
Guest | Ok, when a villager unit attacks a wisp (no damage is caused), the wisp is removed and a special effect is placed on the villager to indicate he has a "ball" (a wisp). When that villager is ordered to attack the ground, the ball is droped ie: a new wisp is created and the effect on the villager is removed. Heres what the trigger i need help with looks like if it only handled one ball: E: Unit - A unit ownened by Neutral Passive is attacked C: BallCarrier Not Equal To (Attacking Unit) A: Set BallCarrier = (Attacking Unit) Unit - Remove (Attacked Unit) from the game Now i need to rewrite that trigger so that it would work if there are 3 possible balls players can pick up. Each villager can only carry one ball at a time. Does that Explain it better? |
| 01-12-2003, 09:41 PM | #4 |
Hmm, you could try making a boolean variable for each guy indicating if he is currently holding a ball and then put conditions stating that the variable can't be on, or something like that. Just play around with booleans. Or maybe have a unit variable, one for each ball, and when someone picks up the ball the variable is set to that person, and have conditions stoping him from picking up another... Am I making sense? |
| 01-12-2003, 11:00 PM | #5 | ||||
Here's a Custom trigger I've written some time ago to manage an array of 4 workers I had. Since the workers would be ocnsntantly dying, changing tasks, etc, I had to keep track of the four ones that would be the workers to do special stuff. That would be your ball units, I guess. To add them to the array: Quote:
To remove them from the array: Quote:
Anyway, this can be very confusing, but you can use it as reference if you want. Well, here is what is happening here. In the assign function, the triggering unit is stored in the position of the workers array (udg_CornField1Workers) at the first empty slot, with is the one that corresponds to the Index variable (udg_CornField1WorkersIndex). In the begining, the index is 0, so the worker is placed in the first slot, and the index is moved to the second slot. Then, when the second worker is placed on the array, it will be placed on the second slot, because index was added. Sometimes, however, a worker will get out of this array, So we use the second function. Basiclly, what this function do is check if the Triggering unit is in the array. If the unit is, then we check in wich slot of the array he is. if it's the first one, we move the second one to the first slot, and the third one to the second slot, then we do Index = Index - 1. This way, when we add another worker, he will be placed on third slot, and the guy we wanted to remove from the arrays is out. If we get the guy from the second slot, then we keep the guy in first slot where he is, and place the guy on the third slot at the second slot, and do Index = Index - 1. This way, the third slot is always free when somebody leaves the array. Same goes when the third slot guy goes away. I know this is a little confusing, but that's how i've done. I don't know if that's the way you are planning to deal with this, but if you want, I can send you the map. [edit] I was bored, so I converted it to something more familiar to what you want. I havn't tested these custom triggers however, but they were based on the ones I use. Here's the assign trigger: Quote:
and the unassign trigger: Quote:
|
| 01-13-2003, 01:49 AM | #6 |
Guest | EEK!:whoa2::whoa2: I dont know crap about that.... /me begins decyphering code.... uhhh... it doesnt look that hard to understand (i have plenty of programing experience) but can that be converted to worldedit triggers? or do i have to import them to my map as it is? Well, thanx for the help, at least its a finger in the right direction :D |
| 01-13-2003, 11:22 AM | #7 |
Sorry, but I don't know how to do that in triggers. I prefers triggers too, but I had to use JASS here, because I couldn't do that with triggers. Pretty much al that is happening is that there is a if/then/else trigger, but we use it to do several actions instead of just one. |
| 01-13-2003, 08:22 PM | #8 |
Guest | algumacoisaqq, ur a genius! I managed to decypher that jass code convert it to the triggers works pretty well so far, Ill give u credit on the map. Thanx a lot! |
