| 10-16-2006, 02:13 AM | #1 |
Is there a way to set a variable with a Picked Unit? It works but when you pick more than 1 unit at a time, it dosen't work... Between, my function isn't complete, its just to show you the part that I have trouble with. Here is my code: JASS://The Variable "UnderTarget" is a global variable already made. function Trig_UnderTargetCondition takes nothing returns boolean return ( IsUnitType(GetFilterUnit(), UNIT_TYPE_STRUCTURE) == false ) endfunction function Trig_UnderTarget takes nothing returns nothing //When there is only 1 unit under TargetLoc the variable is set to Picked Unit. If there is more than 1 unit, it dosen't work. set udg_UnderTarget = GetEnumUnit() endfunction function Trig_Dimension_Staff_Actions takes nothing returns nothing local unit Target = GetSpellTargetUnit() local location TargetLoc = GetUnitLoc( Target ) //Here I'm setting the group. call ForGroupBJ( GetUnitsInRangeOfLocMatching(512, TargetLoc, Condition(function Trig_UnderTargetCondition)), function Trig_HideUnderTarget ) set Target = null set TargetLoc = null endfunction |
| 10-16-2006, 03:39 AM | #2 |
It has got a memory leak, but I would say that the problem is actually with the way you are verifying that the variable was set correctly, cause it should be working completelly right. |
| 10-16-2006, 08:50 PM | #3 | |
Quote:
Verifying that the variable was set? If you mean Conditions, it dosen't work even without Conditions. Edit: I think it bug because the "unit" variable can only store 1 unit in the variable but when there is more than 1 unit, the system messes up and dosen't set the variable (I think). Is there a way to convert a "group" to multiple "unit" variable? |
| 10-16-2006, 09:00 PM | #4 |
but how do you verify it is set? |
| 10-16-2006, 09:33 PM | #5 |
With an Hide then Show trigger, 3 second between them. Hide: JASS:call ShowUnitHide( udg_UnderTarget ) Show JASS:call ShowUnitShow( udg_UnderTarget ) Only work with 1 unit. |
| 10-17-2006, 02:10 AM | #6 |
It was supposed to work with one unit |
| 10-17-2006, 09:14 PM | #7 |
The hide trigger is not supposed to work with 1 unit only. It works if I do JASS:call ShowUnitHide( GetEnumUnit()) |
| 10-17-2006, 11:36 PM | #8 |
One thing you should inform us of is what you want the trigger to do, but from looking at it, it would seem that you want the dimension staff spell to target a point and hide everyone within 512 range. I'm going to start off by saying DON'T use global variables for spells that you want to work for more than one person or want to be multiinstancable Instead of hiding units in the variable hide them right in the "Trig_UnderTarget" actions. call ShowUnitHide( GetEnumUnit() ) but then you'll want to show them later on, so just keep the unit group in a variable like this local group EffectGroup = GetUnitsInRangeOfLocMatching(512, TargetLoc, Condition(function Trig_UnderTargetCondition)) Then I will just assume that you want them to appear after a certain amount of time. so just wait and then do another action. function Staff_ShowActions takes nothing returns nothing call ShowUnitShow(GetEnumUnit()) endfunction call ForGroup(EffectGroup, function Staff_ShowActions) Your New trigger might look like this. BTW This trigger is not tested I won't it might not work right, but its the right idea. you should be able to get it from here. JASS:function Trig_UnderTargetCondition takes nothing returns boolean return ( IsUnitType(GetFilterUnit(), UNIT_TYPE_STRUCTURE) == false ) endfunction function Trig_UnderTarget takes nothing returns nothing call ShowUnitHide(GetEnumUnit()) endfunction function Staff_ShowActions takes nothing returns nothing call ShowUnitShow(GetEnumUnit()) endfunction function Trig_Dimension_Staff_Actions takes nothing returns nothing local unit Target = GetSpellTargetUnit() local location TargetLoc = GetUnitLoc( Target ) local group EffectGroup = GetUnitsInRangeOfLocMatching(512, TargetLoc, Condition(function Trig_UnderTargetCondition)) //Here I'm setting the group. //I'm not going to use ForGroupBJ because we are not using bj_wantDestroyGroup therefor ForGroup is better. call ForGroup( EffectGroup, function Trig_HideUnderTarget ) //Because I don't want to go over timer's and attachable variables. Look it up though it's better than polled wait. www.wc3jass.com>>Tutorials call PolledWait(<Wait Time>) //Look above about that forgroup thing I told you about. call ForGroup(EffectGroup, function Staff_ShowActions) //This will remove alot more of the leaks than just nulling. call RemoveLocation(TargetLoc) call DestroyGroup(EffectGroup) set Target = null set TargetLoc = null set EffectGroup = null endfunction |
