| 04-07-2008, 02:54 AM | #1 |
So I have two spells. One needs to add a +Damage (Based off the Item) Ability to units in the targeted Area. It goes like this: JASS:function Trig_Mineralize_Conditions takes nothing returns boolean if ( not ( GetSpellAbilityId() == 'A083' ) ) then return false endif return true endfunction function Mineralize_Is_Ally takes nothing returns boolean return true endfunction function Trig_Mineralize_Actions takes nothing returns nothing local unit lord = GetTriggerUnit() local unit f = GetTriggerUnit() local group g local player p = GetOwningPlayer(lord) local group gtwo local location loc = GetSpellTargetLoc() local integer lev = GetUnitAbilityLevel(lord,'A083') call GroupEnumUnitsInRangeOfLoc(g,loc,200,Condition(function Mineralize_Is_Ally)) call GroupEnumUnitsInRangeOfLoc(gtwo,loc,200,Condition(function Mineralize_Is_Ally)) loop set f = FirstOfGroup(g) exitwhen f == null if (IsUnitAlly(f,p) == true) then call UnitAddAbility(f,'A085') call UnitAddAbility(f,'A084') call SetUnitAbilityLevel(f,'A085',lev) endif call GroupRemoveUnit(g,f) endloop call TriggerSleepAction(25) loop set f = FirstOfGroup(gtwo) exitwhen f == null call UnitRemoveAbility(f,'A085') call UnitRemoveAbility(f,'A084') call GroupRemoveUnit(gtwo,f) endloop call DestroyGroup(g) call DestroyGroup(gtwo) call RemoveLocation(loc) set lord = null set f = null set g = null set p = null set gtwo = null set loc = null endfunction //=========================================================================== function InitTrig_Mineralize takes nothing returns nothing set gg_trg_Mineralize = CreateTrigger( ) call TriggerRegisterAnyUnitEventBJ( gg_trg_Mineralize, EVENT_PLAYER_UNIT_SPELL_EFFECT ) call TriggerAddCondition( gg_trg_Mineralize, Condition( function Trig_Mineralize_Conditions ) ) call TriggerAddAction( gg_trg_Mineralize, function Trig_Mineralize_Actions ) endfunction The other spell needs to add an attack speed increase to all units around the caster. Yes, the ability is also based off an Item Ability. It goes as such: JASS:function Trig_Erosion_Conditions takes nothing returns boolean if ( not ( GetSpellAbilityId() == 'A086' ) ) then return false endif return true endfunction function Erosion_Filter takes nothing returns boolean return GetUnitState(GetFilterUnit(), UNIT_STATE_LIFE) >= 0 endfunction function Trig_Erosion_Actions takes nothing returns nothing local unit lord = GetTriggerUnit() local location loc = GetUnitLoc(lord) local group g local group gtwo local integer lev = GetUnitAbilityLevel(lord,'A086') local unit f = GetTriggerUnit() call GroupEnumUnitsInRangeOfLoc(g,loc,500,Condition(function Erosion_Filter)) call GroupEnumUnitsInRangeOfLoc(gtwo,loc,500,Condition(function Erosion_Filter)) loop set f = FirstOfGroup(g) exitwhen f == null call UnitAddAbility(f,'A087') call GroupRemoveUnit(g,f) endloop call TriggerSleepAction(20) loop set f = FirstOfGroup(gtwo) exitwhen f == null call UnitRemoveAbility(f,'A087') call GroupRemoveUnit(gtwo,f) endloop call DestroyGroup(g) call DestroyGroup(gtwo) call RemoveLocation(loc) set g = null set gtwo = null set loc = null set lord = null set f = null endfunction //=========================================================================== function InitTrig_Erosion takes nothing returns nothing set gg_trg_Erosion = CreateTrigger( ) call TriggerRegisterAnyUnitEventBJ( gg_trg_Erosion, EVENT_PLAYER_UNIT_SPELL_EFFECT ) call TriggerAddCondition( gg_trg_Erosion, Condition( function Trig_Erosion_Conditions ) ) call TriggerAddAction( gg_trg_Erosion, function Trig_Erosion_Actions ) endfunction As far as I can tell, they should work, but they don't. I've checked to see what the problem may be by even adding "KillUnit(f)" in the loops, but it does nothing, so i think the problem is with the looping. Any Ideas? |
| 04-07-2008, 03:17 AM | #2 |
JASS:local group g local player p = GetOwningPlayer(lord) local group gtwo local location loc = GetSpellTargetLoc() local integer lev = GetUnitAbilityLevel(lord,'A083') call GroupEnumUnitsInRangeOfLoc(g,loc,200,Condition(function Mineralize_Is_Ally)) call GroupEnumUnitsInRangeOfLoc(gtwo,loc,200,Condition(function Mineralize_Is_Ally)) JASS:local group g = CreateGroup() local player p = GetOwningPlayer(lord) local group gtwo = CreateGroup() local location loc = GetSpellTargetLoc() local integer lev = GetUnitAbilityLevel(lord,'A083') call GroupEnumUnitsInRangeOfLoc(g,loc,200,Condition(function Mineralize_Is_Ally)) call GroupEnumUnitsInRangeOfLoc(gtwo,loc,200,Condition(function Mineralize_Is_Ally)) |
| 04-07-2008, 03:27 AM | #3 |
Oh, I didn't know you had to do that. Thanks :). Do you have to do that with any other handles? |
| 04-07-2008, 03:29 AM | #4 |
You always have to initialize variables to something before you can call things on them, handles and integers and the rest alike. |
