| 07-01-2008, 05:21 AM | #1 |
Can somebody please help me? I am trying to take advantage of local variables to make an ability mui. I constructed this trigger in gui, converted it to jass, replaced all instances of udg_WindTarget with WindTarget, and replaced the first action with "local unit WindTarget = GetAttackedUnitBJ()" However, Warcraft does not like this trigger. Can somebody tell me where I messed up? I will guess and say I broke it by replacing udg_WindTarget with WindTarget in the if/then/else unit has buff function, even though the action defining WindTarget is a few lines down. How should I fix this? Here is the trigger: JASS:function Trig_Orb_of_Wind_Conditions takes nothing returns boolean if ( not ( UnitHasItemOfTypeBJ(GetAttacker(), 'I00Y') == true ) ) then return false endif return true endfunction function Trig_Orb_of_Wind_Func003Func004002003001 takes nothing returns boolean return ( IsPlayerEnemy(GetOwningPlayer(GetFilterUnit()), GetOwningPlayer(GetAttacker())) == true ) endfunction function Trig_Orb_of_Wind_Func003Func004002003002 takes nothing returns boolean return ( IsUnitAliveBJ(GetFilterUnit()) == true ) endfunction function Trig_Orb_of_Wind_Func003Func004002003 takes nothing returns boolean return GetBooleanAnd( Trig_Orb_of_Wind_Func003Func004002003001(), Trig_Orb_of_Wind_Func003Func004002003002() ) endfunction function Trig_Orb_of_Wind_Func003Func006C takes nothing returns boolean if ( not ( IsUnitGroupEmptyBJ(udg_TempUnitGroup) == false ) ) then return false endif return true endfunction function Trig_Orb_of_Wind_Func003C takes nothing returns boolean if ( not ( UnitHasBuffBJ(WindTarget, 'Blsh') == true ) ) then return false endif return true endfunction function Trig_Orb_of_Wind_Actions takes nothing returns nothing local unit WindTarget = GetAttackedUnitBJ() call TriggerSleepAction( 0.15 ) if ( Trig_Orb_of_Wind_Func003C() ) then call UnitRemoveBuffBJ( 'Blsh', WindTarget ) set udg_TempPoint = GetUnitLoc(WindTarget) set udg_TempUnitGroup = GetUnitsInRangeOfLocMatching(250.00, udg_TempPoint, Condition(function Trig_Orb_of_Wind_Func003Func004002003)) call RemoveLocation( udg_TempPoint ) if ( Trig_Orb_of_Wind_Func003Func006C() ) then set udg_HeroSpellUnit[4] = GroupPickRandomUnit(udg_TempUnitGroup) set udg_TempPoint = GetUnitLoc(udg_HeroSpellUnit[4]) call CreateNUnitsAtLoc( 1, 'H008', Player(5), udg_TempPoint, bj_UNIT_FACING ) set udg_TempUnit = GetLastCreatedUnit() call RemoveLocation( udg_TempPoint ) call UnitAddAbilityBJ( 'A01O', udg_TempUnit ) call IssueTargetOrderBJ( udg_TempUnit, "cyclone", udg_HeroSpellUnit[4] ) else endif call DestroyGroup( udg_TempUnitGroup ) else endif endfunction //=========================================================================== function InitTrig_Orb_of_Wind takes nothing returns nothing set gg_trg_Orb_of_Wind = CreateTrigger( ) call TriggerRegisterAnyUnitEventBJ( gg_trg_Orb_of_Wind, EVENT_PLAYER_UNIT_ATTACKED ) call TriggerAddCondition( gg_trg_Orb_of_Wind, Condition( function Trig_Orb_of_Wind_Conditions ) ) call TriggerAddAction( gg_trg_Orb_of_Wind, function Trig_Orb_of_Wind_Actions ) endfunction Sorry for the newb question, and thanks for your help. |
| 07-01-2008, 07:44 AM | #2 |
The problem is that you're referencing "WindTarget" in a function in which it doesn't exist. However, fixing that is not the easiest way to go about this; instead, we can go back to your GUI trigger and add in about 4 lines that will make it easily MUI without having to convert to JASS. I don't know what your trigger looks like, so I'm guessing, but let's assume it looks like this: Trigger: Trigger: |
| 07-01-2008, 11:35 AM | #3 |
You could also not use a variable at all and just always use the "attacked unit" event response, it is thread-specific so even if the trigger fires multiple times during the wait the value of "attacked unit" for this instance of the trigger will remain the same. If you stay with the Jass you have now, however, the easiest way to fix this would be to replace if ( Trig_Orb_of_Wind_Func003C() ) then with if UnitHasBuffBJ(WindTarget, 'Blsh') then and remove that function. You can apply the same principle in other places, so you can get rid of those ugly functions that GUI triggers generate. Furthermore, you might want to optimize your code by replacing those BJ functions that do nothing useful, like UnitHasBuffBJ and GetAttackedUnitBJ. If you go to wc3jass.com, click the "function finder" link at the top and enter the names of those functions, you'll see what they can be replaced with. |
| 07-01-2008, 04:54 PM | #4 |
Huh, I thought the bug I was having with the trigger before I tried converting it into jass was due to (attacked unit) no longer being valid after the wait, but I was wrong. It works great now, no variables needed. Thanks a lot guys! You rock. |
| 07-01-2008, 10:45 PM | #5 |
Oh, I thought Attacked Unit didn't work after waits. Guess I was wrong. :P |
| 07-01-2008, 11:49 PM | #6 |
As far as I know only spell event responses don't work like this, but instead get overridden by other triggers running, everything else I ever used does work like this. |
