| 08-27-2007, 09:12 AM | #1 |
Hi, Im trying to make a function that instead of having to use a player group to kill multiple units i can just type one line of code. eg. JASS:call KillUnits(udg_Thrall, a, b, udg_Jike) |
| 08-27-2007, 03:33 PM | #2 |
I don't understand, why di you have to use a player group to kill multiple units? |
| 08-27-2007, 04:17 PM | #3 | |
It can't be done in the way you want it (if I understand you), because functions in jass have a fixed number of arguments, there aren't optional arguments or something, so the only way you can do this is to write the function for any needed number of arguments. e.g.:
So there isn't really an advantage to: JASS:call KillUnit(udg_Thrall) call KillUnit(a) call KillUnit(b) call KillUnit(udg_Jike) |
| 08-27-2007, 10:06 PM | #4 |
oh damit, ty anyway |
| 08-27-2007, 11:54 PM | #5 |
You could do this: JASS:struct UnitCollection unit array units[50] integer amount static method Kill takes nothing returns nothing local integer i = 0 loop exitwhen i == this.amount etcetc kill unit this.units[i] set i = i + 1 endloop enmethod endstruct function SpellThatKillsUnits takes something returns something local UnitCollection uc = UnitCollection.create() local integer amount = 3 //The amount of units you're gonna kill in this spell ... set uc.units[0] = Unit 1 //wherever you get it. set uc.units[1] = Unit 2 //wherever you get it. set uc.units[2] = Unit 3 //wherever you get it. set uc.amount = 3 //3 units! call uc.Kill() endfunction And you would have a completely useless home-made unit group! |
| 08-28-2007, 02:00 AM | #6 |
You could also do it by making a function that takes 5 unit arguments but passing some of them as null if you didn't need to kill 5 units but 3. |
| 08-28-2007, 07:02 AM | #7 |
Pyro, your a genius NO ONE TELL ME HOW TO DO THAT I NEED THE PRACTICE |
