| 08-22-2006, 12:11 AM | #1 |
Hey i need some help with JASS that I'm using. I'm new to JASS so don't laugh at me too much :P. Also thanks to wonder_priest for the script. I want this to pick the closest unit that is not paused, that is the same type of udg_ChainArray[Player number of owner of damage source], and in the range of 128. JASS:function GetNearestUnitMatching takes real range, location source, boolexpr cond returns unit local group g=CreateGroup() local location ul local unit u local unit n local real dist call GroupEnumUnitsInRangeOfLoc(g,source,range,cond,cond2) loop set u=FirstOfGroup(g) exitwhen u==null set ul=GetUnitLoc(u) set dist=DistanceBetweenPoints(source,ul) call RemoveLocation(ul) if dist<range then set n=u set range=dist endif call GroupRemoveUnit(g,u) endloop call DestroyGroup(g) set ul=null set g=null set u=null return n endfunction Here is the gui that I'm using, and want to know what to change to the custom script. Would like it if someone could change udg_ChainArray[1] to udg_ChainArray[Player number of owner of damage source] Trigger: Custom Script: set udg_ChainArray[1]=GetNearestUnitMatching(128,Location(0,0),null) |
| 08-22-2006, 12:49 AM | #2 |
udg_ChainArray[GetPlayerId(GetOwningPlayer(GetAttacker()))] |
| 08-22-2006, 01:23 AM | #3 |
You can always do what you want in gui, then convert to custom text to see what it looks like. Better add +1 to the player number if you will be referring to it via gui as well (gui uses GetConvertedPlayerId which returns GetPlayerId + 1) simply add +1 before the ] in the code Alevice gave you |
| 08-22-2006, 02:11 AM | #4 |
all right, but can i get some help with the closest unit? Thanks for the help so far. |
